The Garden Grows a Nervous System
Contents
Disclaimer & Intro
This post has been made as my notes, even though I attempt to explain what I have built and how, I do not owe anyone any explanation. Do NOT expect anything.
My blog is my garden.
WARNING: No AI was used in the making of this project. Not one token. Just source code, RFCs, and a free weekend.
You have read that line at the top of every post in this series, and it still governs. There is a language model wired into this blog — it summarises long posts and nothing else. It reads. It does not write, and it did not write a word of the four things below. Those came from the specs and the standard library, the same as everything before them. A feature I bolted to the side is not an author, and I am not going to start pretending otherwise now that the box has more corners.
Last post the garden grew teeth: a TL;DR that only reads, posts that verify themselves from your terminal, a 43-byte theft canary, self-destructing articles enforced at the edge. Weapons. Passive and patient. They wait for someone to steal, and then they bite.
This post is not about teeth. It is about reflexes. The garden learned to feel who is standing in it, to remember every word it has ever grown, to make a bot flinch before it can touch a thing, and to rearrange its own paths between one visit and the next. Four features that turned a static site into something that reacts.
And — say it with me — the budget did not move.
The Receipt, Unchanged
Same as last time, receipt first, because the receipt is the argument. Here is the Content-Security-Policy serving this page, lifted from _headers, byte-for-byte the policy from two posts ago:
Content-Security-Policy: default-src 'none'; script-src 'self' https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://bear-images.sfo2.cdn.digitaloceanspaces.com; font-src 'self'; connect-src 'self' https://cloudflareinsights.com; media-src 'none'; object-src 'none'; frame-src 'none'; frame-ancestors 'none'; worker-src 'none'; form-action 'self'; base-uri 'none'; manifest-src 'none'; navigate-to 'self'; upgrade-insecure-requests
Full-text search over every article. A cryptographic puzzle in front of every like. A live WebSocket telling you how many people are reading this with you. A DOM that scrambles itself on every deploy. script-src 'self'. connect-src 'self'. Not one new origin, not one inline script, not one vendor library.
I will be honest about the one thing that did cost something, because honesty about the bill is the whole point of this series and I am not going to hide it in a footnote. The live reader count needed a WebSocket, and a WebSocket needed me to flip a single toggle in Cloudflare's Network settings that had been sitting there switched off. That is not a CSP keyword — connect-src 'self' already covered a wss:// back to my own origin, so the policy above never changed. But it was a switch I had to reach for, and it was the only one. Everything else fit inside the box exactly as it was.
If a feature needs a third-party origin, an inline script, or
unsafe-anything, it does not ship. It gets redesigned until it fits, or it dies.
Nothing died. Watch.
The Garden Remembers Every Word
Last post I shipped a command palette — hit / and fuzzy-jump to any post. I was quietly proud of it and quietly aware of its lie. It searched titles and tags. A search.json of headlines. If you remembered a phrase from the middle of an article and not its title, the palette shrugged at you. It was a table of contents wearing a search box's clothes.
So I built the real thing: a full-text index over the body of every post, computed at build time, ranked properly, and resolved in your browser in well under a millisecond. No search vendor. No Algolia snippet couriering your queries to someone else's analytics. No serverless function round-trip per keystroke. A static JSON file and a scoring function.
The generator walks every post and folds four fields into one inverted index — token to a list of [document, weight] postings — with the title and tags weighted heavily so a title match still outranks a passing mention buried in paragraph nine:
posts.forEach((p, i) => {
const tags = Array.isArray(p.fm.tags) ? p.fm.tags : (p.fm.tags ? [p.fm.tags] : []);
add(i, p.title, 6); // a title hit dominates
add(i, tags.join(' '), 5);
add(i, p.fm.description || '', 3);
add(i, stripTags(p.html), 1); // ...and finally, the whole body
});
That last line is the entire upgrade. stripTags(p.html) — every word I have ever published, tokenised into the index. The file ships as a static asset next to the pages, cached hard, fetched once. It is bigger than the old headline list, and it does not care, because it loads lazily on the search page and never touches the two pages the build actually budgets to the byte.
The ranking is honest TF-IDF, the oldest trick in information retrieval and still the right one at this scale. A term that appears in every post tells you nothing; a term that appears in three posts tells you where to look. So each matched term's weight is scaled by how rare it is across the corpus, and the scores sum per document:
const idf = Math.log(1 + index.n / postings.length); // rare term ⇒ high signal
for (const [docId, tf] of postings) {
score.set(docId, (score.get(docId) || 0) + tf * idf);
}
Type entropy and it finds the DNS post — not because "entropy" is in the title, but because it is in a sentence about Shannon entropy in subdomain labels, three thousand words deep. Multi-word queries intersect: macos hardening returns only the posts that carry both. Prefix matching keeps it responsive from the first keystroke. And if the index ever fails to load, it silently falls back to the old title-and-tag filter, so search never hard-breaks — it just gets dumber for one page load.
Ten thousand posts and this stays instant, because the expensive part happened at build time and the runtime is a dictionary lookup. The garden does not search its memory. It has an index of it.
A Doorbell That Remembers No One
Here is one I did not have on any wish-list, and it is the one I find quietly unsettling in the best way. Open any post and, next to the read-time, you may see a small line: · 3 reading. A live count of the other people in the room with you, right now, updating as they arrive and leave.
Every analytics vendor on earth will sell you this. All of them do it by planting an identifier in your browser and phoning a count home to a database that keeps a row about you forever. I wanted the number and none of the surveillance. So the rule was the usual one, turned up to its cruelest setting: the server must store nothing. Not a cookie. Not a row. Not one byte.
The count is a Cloudflare Durable Object, one instance per post slug, holding the live WebSocket connections and nothing else. There is no table of who is here. The count is not stored anywhere — it is derived, on demand, from the number of sockets currently open. When the last reader closes the tab, the object empties and is evicted, and there is nothing left behind to delete because there was never anything there:
// The count IS the connections. Nothing is written down.
broadcast() {
const n = this.ctx.getWebSockets().length;
const msg = JSON.stringify({ count: n });
for (const ws of this.ctx.getWebSockets()) {
try { ws.send(msg); } catch { /* socket already gone */ }
}
}
It uses the WebSocket Hibernation API — this.ctx.acceptWebSocket(server) instead of the older accept() — so the object can be swept out of memory while the sockets stay open and only wakes on an actual event. No heartbeat loop burning cycles. No in-memory array of connections for me to get wrong. The runtime already knows who is connected; I just ask it to count.
This is the feature that cost the one switch I confessed above, and it cost a little structural honesty too: Cloudflare Pages, by design, cannot define a Durable Object — so the object lives in a tiny standalone Worker that the site binds to. Two moving parts where the rest of the blog has one. I went in with my eyes open, because the trade was worth it: a real-time presence indicator that is anonymous by construction. It cannot leak who was reading, because it never knew. It cannot be subpoenaed for a history it does not keep. The doorbell rings, you see the number, and the moment you leave, the room forgets you were ever in it.
And it degrades to silence. No WebSocket support, no binding, a flaky connection — the line simply does not appear, and the post reads exactly as it always did. A feature that vanishes cleanly is a feature that never held the page hostage.
Proof of Work: The Sketch Ships
Two posts running I have ended with the same promise and the same refusal. The promise: a hashcash puzzle guarding the interactive bits — invisible to a human doing one thing, ruinous to a bot doing ten thousand. The refusal: I will not embed Disqus, and I will not run a CAPTCHA farm doing free labelling work for Google's models while insulting my readers with traffic-light puzzles.
It shipped. Not on comments — I still have none — but where it actually earns its keep: in front of every like and every AI TL;DR request. Both are cheap for a person and both are exactly the kind of endpoint a bot wants to hammer, the TL;DR especially, because it can trigger model inference. So before the browser is allowed to POST a like or ask for a summary, it has to do some work and prove it.
The proof is a Hashcash stamp: find a nonce such that the SHA-256 of your challenge has a run of leading zero bits. There is no clever shortcut — you brute-force it — but verifying the answer is a single hash. Asymmetric cost, the way all good gatekeeping is. The whole solver is vanilla JavaScript, a SHA-256 I wrote by hand looping over nonces, no library, no WASM blob from a CDN:
for (;;) {
const stamp = prefix + counter.toString(36);
if (leadingZeroBits(sha256(enc.encode(stamp))) >= bits) return stamp; // solved
counter++;
}
Tuned so a real browser spends about fifty milliseconds — a flicker you will never notice behind a click — while a bot trying to spam ten thousand likes pays that toll ten thousand times over. The server re-hashes the stamp and checks three things: that the work was actually done, that the stamp is fresh, and that it has never been spent before. That last check is the one people forget, and it is what stops a bot from solving once and replaying the answer forever. The SHA-256 digest of the stamp is its own primary key:
if (leadingZeroBitsHex(hex) < bits) return false; // didn't do the work
// single-use: the digest of the stamp is the primary key, so a replay collides
const r = await env.LIKES_DB
.prepare('INSERT OR IGNORE INTO pow_stamps (stamp_hash, ts) VALUES (?, ?)')
.bind(hex, ts).run();
if (!r.meta.changes) return false; // seen before ⇒ replay
No third-party script. No frame-src for a widget. No cookie. No thirty-line block of Google's JavaScript watching your mouse to decide if you are human. Just a puzzle your own browser solves in the time it takes to blink, and a table of spent stamps that prunes itself because it only ever accepts a stamp minted in the last five minutes. The sketch I grinned at for two posts is real, and it fit — as always — inside connect-src 'self'.
A Different Garden Every Deploy
The teeth from last post were about theft after the fact. The canary phones home when someone re-hosts a post; the watermark rides along in the copy-paste. Both assume the scraper already got the bytes and just want to tell on it. This one is upstream of that. It makes the scraping itself brittle.
A DOM scraper is hard-coded to structure. It selects .post-header h1 for the title, .post-meta time for the date, .blog-posts li a for the links. Those class names are a contract the page never agreed to sign — and so, on every single build, I break it. A generator pass rewrites every presentational class name and CSS-only id to a fresh, short, random token, and applies the same map to the stylesheet and the markup at once:
// .post-header → .t1, .blog-posts → .t0, ... a new mapping every build.
const classMap = new Map(classTokens.map((t) => [t, next()]));
// The identical map rewrites the inlined CSS and the HTML in one pass,
// so the page is pixel-identical to a human and unrecognisable to a scraper.
To you, nothing changes. Not one pixel. The stylesheet and the markup are rewritten together, so .t1 styles exactly what .post-header styled yesterday. But the Puppeteer script somebody pointed at this site last week, keyed to .post-header, now selects nothing. Next deploy the names change again. The DOM is a moving target, re-shuffled every time I push, and the only way to scrape it reliably is to stop hard-coding structure and start reading the rendered page like a human would — which is to say, to do real work, which is the whole idea.
There is a leash on this one too, because unrestrained it would break the site for everyone. The randomiser is an allowlist: it only touches presentational classes that no script depends on. The hooks the JavaScript actually uses, the heading-anchor ids your deep-links point at, and — crucially — the content sidecar that the terminal signature hashes are all left deliberately, permanently stable. The garden shifts its paths for the intruder. It does not move the front door, and it does not touch the bytes you can verify. The parts that are yours to check stay exactly where they were.
The Roadmap, Revisited
Honesty means scoring the wish-list again.
Proof-of-work — shipped. I framed it last time as guarding comments; it landed guarding likes and the TL;DR instead, which is where the abuse actually lives. Same puzzle, same refusal of CAPTCHA, finally real.
The PGP dead drop — still a sketch, and still half-built in spirit, because the public key has been published since the verify feature. An endpoint where you encrypt a note in your own browser against that key before it ever crosses the wire, stored as ciphertext only my private key opens. An anonymous tip line with no plaintext ever resting on a server I run. It is next. I keep saying that. One of these posts it will be true before I say it.
Open-sourcing the engine — closer to yes than ever, and now with a new argument against my own hesitation. I keep shipping features and describing them in prose, and prose is the weakest possible proof. The honest way to show you do not need the vendor's platform is to hand you the thing that replaced it. The counter-argument has not changed — publish an engine and you have signed up to maintain it, and a garden tended for an audience stops being a garden. Still deciding. The like button below — now gated by a proof-of-work puzzle you will never feel — is still the only vote that counts.
Final Word
The first post in this series was subtraction — ripping out the framework, the bundler, the CMS, until nothing was left but HTML, CSS, and the specs.
The second was addition without regression — likes, flags, read-time, watermarks — for one honest CSP keyword.
The third grew teeth — an AI on a leash, self-destructing posts, theft canaries, signatures you verify from your own terminal.
This one grew a nervous system. It feels who is in the room and forgets them the instant they leave. It remembers every word it has ever grown and finds any of them before you lift your finger from the key. It makes a bot do real work before it can so much as press a button. And it rearranges its own body on every deploy so that the things which come to strip it have to start over, every time.
Search, presence, proof-of-work, a polymorphic DOM. Real-time, cryptographic, adaptive — the vocabulary the industry reserves for a stack of vendors and a monthly invoice. And the policy that started at default-src 'none' and moved exactly once, two posts ago, to 'self', still did not move. One switch in a Network panel. No new origin. No inline script. No library. No cookie. No identifier walking a single reader home.
The teeth were for the people who would take the garden. The nervous system is for the garden itself — so it can sense, remember, react, and change shape, without ever once needing to grow.
The garden grew teeth to defend itself. It grew a nervous system to become alive.
Jai Hind.
Wake up. Dig deeper.
#Web Hosting #cyber security #development #privacy #cloudflare #edge #ai #research
🔑 Verify authenticity
PGP key xer0x-public.asc · id e8270d03
sha256(post) 4f32e3bc4123d4a56ca20acd0d92283342a21128c932458f04ae08da3895dbbc
Confirm this post is byte-for-byte authentic — paste into any macOS or Linux terminal:
curl -fsSL https://xer0x.in/blog/garden-grows-a-nervous-system/content.txt | openssl dgst -sha256 | grep -qi 4f32e3bc4123d4a56ca20acd0d92283342a21128c932458f04ae08da3895dbbc && echo "signature ok" || echo "TAMPERED"