The Garden Grows Teeth
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.
Read that line again, because this is the post where it earns its keep. There is now a language model wired into this blog. It did not write the engine. It did not write this sentence or any other. It reads — and only that — and I will show you exactly where the leash is. The warning still holds. I made the thing; the model is a feature I bolted to the side of it, and a feature is not an author.
Last post I added likes, country flags, read-time, and an invisible watermark for scrapers — live, stateful features on a static site — and the whole bill came to one widened CSP keyword, which I confessed to in full. Then I ended with a wish-list: canary tokens, self-destructing posts, proof-of-work comments, a PGP dead drop. Sketches I grinned at.
Two of them shipped. So did a pile of things I had not even written down. And this time the bill came to nothing — not one more byte of CSP, not one new origin, not one inline script. Everything below was built inside the box I already paid for.
This is that post.
The Budget That Did Not Move
Let me lead with the receipt instead of burying it, because the receipt is the thesis. Here is the Content-Security-Policy serving this page, lifted from _headers:
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
It is byte-for-byte the policy from the last post. script-src 'self'. connect-src 'self'. img-src 'self'. The one keyword I spent last time is still the only keyword I have spent. An AI summary, a self-destructing post, a theft canary, a command palette, a syntax highlighter, and posts that prove their own authenticity — every one of them lives inside those directives.
That is not a happy accident. It is the rule, and it is the same rule as last time, stated once more so a feature cannot quietly break it:
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 how much fits in a box this small when you refuse to make the box bigger.
A TL;DR That Reads, Never Writes
So: the AI. Get the uncomfortable part out of the way first, the same way I did the CSP last time.
Long posts deserve a summary. I did not want to write one by hand for every article, and I refuse to paste in a third-party "AI summary" widget that ships a megabyte of script and couriers my prose to someone else's servers to be logged, trained on, and resold. So the question was the usual one for this blog: can I do this from my own origin, on my own metal, without surrendering anything?
Yes. The summary is generated by Cloudflare Workers AI — a model that runs at the edge, on Cloudflare's hardware, addressable from a Pages Function. No OpenAI. No Anthropic. No API key for a vendor who gets to keep a copy of everything I write. The model that does the reading is @cf/meta/llama-3.3-70b-instruct-fp8-fast, and it never sees a single byte that did not already leave my keyboard as a published post.
Here is the leash. The Function fetches my own already-rendered page through the ASSETS binding, strips it to plain text, and hands the model a strict instruction:
_rawResult = await env.AI.run('@cf/meta/llama-3.3-70b-instruct-fp8-fast', {
messages: [
{
role: 'system',
content:
'You summarise security and technical blog posts for expert readers. ' +
'Return ONLY a JSON array of exactly 3 short bullet strings. ' +
'Be specific — name tools, techniques, CVEs, commands. No vague generalities.',
},
{ role: 'user', content: `Post content:\n${text}` },
],
max_tokens: 300,
stream: false,
});
The model reads what I wrote and returns three bullets. That is the entire scope of its authority. It does not invent, it does not opine, it cannot touch the post body. It summarises. A summary of my words is still my words, the way an index is still the book.
And it runs almost never. The first reader of a long post triggers exactly one inference; the result is written to a D1 table and served from there for a week. Every reader after that gets a database row, not a fresh model call:
const cached = await db.prepare(
'SELECT bullets, ts FROM tldr_cache WHERE slug = ?'
).bind(slug).first();
if (cached && (Date.now() - Number(cached.ts)) < CACHE_TTL) {
return json({ slug, bullets: JSON.parse(cached.bullets), cached: true });
}
It only appears at all on posts that clear an eight-minute read — a <details> block hung above the article, collapsed, optional. And if the endpoint coughs for any reason, the client does not show a spinner or an error or a broken box. It deletes itself and you never know it was there:
const res = await fetch(`/api/tldr/${encodeURIComponent(slug)}`);
if (!res.ok) { container.remove(); return; }
This very post is long enough to have one. Scroll up: that TL;DR was written by a model that read this article on Cloudflare's edge, cost me a fraction of a cent once, and phoned no one. The fetch goes to /api/tldr/ — same origin, connect-src 'self'. The box did not get bigger.
The warning at the top is still true. No model made this project. One model reads it, on a short leash, on my hardware. Those are different sentences, and I am not going to pretend they are the same one.
Posts That Verify Themselves
This is my favourite thing I have built in months, and it exists precisely because of the paragraph you just read.
We are drowning in slop. Scrapers lift posts and run them through a paraphraser. Content farms re-host articles with the author's name filed off. Some helpful soul "improves" your words with a model and reposts the mutation. So here is a question the old web never had to answer: how does a reader prove that the bytes in front of them are the bytes I actually published — unaltered, unsummarised, mine?
Not a trust badge. Not a blockchain. Not a SaaS notary that wants ten dollars a month. Just a hash and a tool you already have.
At build time, the generator computes the SHA-256 of the exact rendered post and writes the source bytes to a sidecar file next to it:
const contentHash = createHash('sha256').update(html).digest('hex');
// ...and the exact bytes that were hashed, served alongside the page:
write(join(dir, 'content.txt'), post.html);
Then it prints, at the foot of every post, a one-liner you can paste into any macOS or Linux terminal. It downloads the sidecar, hashes it locally, and checks it against the digest baked into the page:
curl -fsSL https://xer0x.in/blog/garden-grows-teeth/content.txt \
| openssl dgst -sha256 \
| grep -qi <the sha256 shown in the Verify box below> \
&& echo "signature ok" || echo "TAMPERED"
openssl ships on macOS and on every Linux box on earth. No install, no dependency, no third party in the loop — the verification runs entirely on your machine against bytes served from mine. If a single character has been changed by a scraper, a paraphraser, or a man in the middle, the hash diverges and it prints TAMPERED. If it is mine, it prints signature ok.
Scroll to the bottom of this post, open 🔑 Verify authenticity, and run it yourself. The full PGP key is published at /pgp/xer0x-public.asc (id e8270d03) for the people who want to go further. The point is the same as it has always been: I am not asking you to trust me. I am handing you the means to check.
Self-Destructing Posts, For Real This Time
Last post I called this one out as a sketch: burn-after-reading at the article level. The first version was embarrassing, so let me be honest about it. It was client-side. A script counted reads and swapped in a tombstone after N. Which means the body had already been shipped to the browser — the "destruction" was a curtain drawn over content the reader already held. View source and it was all still there. That is theater, and this blog has nothing but contempt for theater.
The real version moved the decision to the edge, into the _middleware.js that runs before a post is ever sent. A post opts in with one line of front-matter — burn: 50 — and the build does two things. It writes the limit into a registry, and it pulls the post out of every listing, tag page, feed, sitemap, and the search index. A burn post is reachable by direct link only. It does not advertise itself.
Then the middleware does the actual enforcement, server-side, before context.next() returns a body:
const row = await env.LIKES_DB
.prepare('SELECT COUNT(*) AS n, MAX(CASE WHEN ip_hash = ? THEN 1 ELSE 0 END) AS seen FROM burns WHERE slug = ?')
.bind(ipHash, slug).first();
const count = Number(row?.n ?? 0);
if (!Number(row?.seen ?? 0)) { // a reader I have not counted before
if (count >= limit) burned = true; // over budget → they get ash
else await env.LIKES_DB // under budget → record them, serve them
.prepare('INSERT OR IGNORE INTO burns (slug, ip_hash, ts) VALUES (?, ?, ?)')
.bind(slug, ipHash, Date.now()).run();
}
The ip_hash is the same salted, one-way hash the likes use — no identity stored, just a token that means "this request, this post." A reader already counted is always let back in; you never lose access to something you were granted. A new reader past the limit gets the body swapped out for a tombstone, with a 410 Gone, the content never leaving the edge:
return new Response(html.replace(/<main[\s\S]*<\/main>/i, EXPIRED_MAIN), { status: 410, headers });
The reader who arrives is always served. The next one finds ash. Useful for coordinated-disclosure countdowns, for things meant to be seen once, for a link that is supposed to wear out. And this time it actually wears out, because the enforcement lives where the bytes do, not in a script the reader's browser is free to ignore.
A Canary in Every Post
The watermark from last post was passive. It rode along in copy-paste and sat in the raw HTML, waiting to be found if I ever went looking. I wrote that the next step was active: a canary that phones home the moment stolen content is viewed somewhere it should not be. I said I would learn about the theft from the thief's own audience.
Built it. It is forty-three bytes.
Baked into every post body is an absolute-URL image — a 1×1 transparent GIF served from /api/px/<slug>.gif. On my own site it is invisible and inert; it loads from my origin to my page and nobody cares. But the URL is absolute. So when a scraper lifts the post and re-hosts it, the thief's visitors' browsers still fetch that pixel from me — and their request carries a Referer header naming the domain that is now hosting my words:
let refHost = '';
try { refHost = new URL(request.headers.get('referer') || '').host.toLowerCase(); } catch { /* no referer */ }
// Off-site = the embedding page is not one of mine → a re-host.
const offsite = refHost && !SELF_HOSTS.has(refHost);
if (offsite && env.LIKES_DB && /^[a-z0-9-]{1,120}$/.test(slug)) {
// hash the IP + UA, attach country, log the thief's domain — fire-and-forget
}
return new Response(GIF, { headers: PIXEL_HEADERS }); // 43-byte GIF, never cached
Only off-site loads are logged. My own page views carry my own host as the referer and are dropped on the floor, so the table holds nothing but theft signal. Same privacy discipline as everything else here: the IP and User-Agent are hashed, the country comes free from the edge, and the pixel is served with no-store so every single view phones home instead of getting cached into silence.
The content farm does not just steal the post. It installs a beacon that reports its own readers back to me. The theft tells on itself.
The Reading Experience (Free, and In-Budget)
Not everything new has teeth. A lot of it is just respect for the person reading. I grouped these because each one is small, and the point is collective: all of it is script-src 'self', all of it loads after first paint, and all of it degrades to nothing if you turn JavaScript off.
A table of contents — built at the server from the h2/h3 headings, but only when there are at least three of them, so short posts are not patronised. The heading ids it generates are the same ids the deep-link anchors use, so the contents box and the #section links can never drift out of sync:
if (items.length < 3) return { html, toc: '' };
return { html: out, toc: `<details class="toc"><summary>Contents</summary>...</details>` };
A reading-progress bar with zero JavaScript. This is the one I am smug about. A thin bar across the top that tracks how far you have scrolled — and there is not a line of script behind it. It is a scroll-driven CSS animation, animation-timeline: scroll(), gated behind @supports so browsers that lack it simply do not draw it:
@supports (animation-timeline: scroll()) {
@keyframes reading-progress { from { width: 0% } to { width: 100% } }
body::before {
content: ''; position: fixed; top: 0; left: 0;
height: 3px; width: 0%; background: var(--heading-color);
animation: reading-progress linear both;
animation-timeline: scroll(root block);
z-index: 999;
}
}
The old way to do this was a scroll listener recomputing a width on every frame. The spec way is to declare the relationship once and let the compositor run it. Read the spec, delete the JavaScript.
A drop-cap, because it looks good and costs one selector:
.post > p:first-of-type::first-letter {
float: left; font-size: 3.1em; line-height: .78;
color: var(--heading-color); font-weight: 700;
}
Syntax highlighting with no library. No Prism, no highlight.js, no half-megabyte of language grammars pulled from a CDN I do not control. The highlighter is one regular expression and a single left-to-right pass, baked straight into the Markdown parser. Comments and strings come first in the alternation, so they swallow any keyword that lives inside them — precedence by position:
function highlight(src) {
const re = /(\/\*[\s\S]*?\*\/|(?:#|\/\/)[^\n]*)|("(?:\\.|[^"\\\n])*"|'...'|`...`)|\b(0x[0-9a-fA-F]+|\d[\d_]*\.?\d*)\b|\b(function|fn|def|return|if|else|for|const|let|class|import|true|false|null|async|await|...)\b/g;
// m[1] comment → .tk-c m[2] string → .tk-s
// m[3] number → .tk-n m[4] keyword → .tk-k
}
Four token classes, one regex, language-agnostic. It will never highlight as cleverly as a 200kB grammar engine. It also will never make you download a 200kB grammar engine to read a code block.
A command palette. Hit / or Cmd/Ctrl+K and jump to any post or tag, fuzzy-matched over a search.json written at build time. It ranks substring hits above scattered subsequence hits, and it deep-links you to the destination with your query attached as ?q=.
And then the ?q= does something genuinely new. When you land on a post carrying a query, it paints the matches using the CSS Custom Highlight API — no wrapper <span>s, no DOM mutation, no rewriting the article to add <mark> tags. It hands the browser a set of ranges and a style, and the browser does the painting:
function highlightQuery(main) {
if (!('highlights' in CSS) || typeof Highlight === 'undefined') return;
// ...build Range objects for each match of ?q= ...
CSS.highlights.set('find', new Highlight(...ranges)); // styled via ::highlight(find)
}
A find-in-page that searches your document without touching it. The palette finds the post; the highlight walks you to the exact line.
A copy button that stays put. Every code block gets a Copy button, and getting it to behave took one real fix. An absolutely-positioned child of a horizontally-scrolling <pre> is laid out against the scrollable content, so it drifts off-screen the moment you scroll the code sideways. The fix is to anchor it to a non-scrolling wrapper instead of the <pre> itself, so it stays pinned to the visible top-right corner no matter how wide the code is. Small bug, satisfying fix.
None of these widened the CSP. None of them blocks the page. Turn off JavaScript and you lose the palette and the copy button and keep the article, the table of contents, the drop-cap, and the progress bar — because the ones that matter most were never JavaScript to begin with.
The Boring Win: D1 Got Cheaper
A blog post about new features always wants to skip the unglamorous part. I am not going to, because the unglamorous part is where the engineering actually lives.
The like-stats endpoint runs two aggregates: an average over read_times and a grouped count over the countries on likes. Both were doing per-row table lookups. So I added covering indexes — indexes that carry every column the query reads, letting SQLite answer straight from the b-tree without ever touching the table:
-- AVG(seconds) is computed straight from the index, no table lookup
CREATE INDEX idx_rt_slug_seconds ON read_times (slug, seconds);
-- (slug, country, ts) is covering AND pre-ordered, so the GROUP BY drops its temp b-tree
CREATE INDEX idx_likes_slug_country ON likes (slug, country, ts);
-- Drop redundant single-column indexes — each is a prefix of a composite that
-- remains, so every lookup is still served, but there is one fewer b-tree to
-- update on every INSERT.
DROP INDEX idx_likes_slug;
DROP INDEX idx_rt_slug;
ANALYZE; -- refresh planner stats so the new covering indexes are chosen
Same queries, same answers, same API — the application code did not change by one character. The database just stopped doing work I was never actually asking it to do. Fewer b-trees touched per write, no temp structures per read, and an ANALYZE so the query planner actually picks the new indexes instead of ignoring them. SQLite at the edge, doing less.
This is the whole ethos in miniature. You do not get fast by adding a caching vendor. You get fast by understanding what the layer beneath you is doing and asking it to do less.
The Roadmap, Revisited
Last post ended with a wish-list. Honesty means scoring it.
Canary tokens — shipped. They are in every post on the site, including this one.
Self-destructing posts — shipped, and the second time properly: enforced at the edge, not faked in the browser.
Proof-of-work comments — still a sketch. I still refuse Disqus and I still refuse to run a CAPTCHA farm for Google, so the plan is unchanged: a comment box gated by a client-side hashcash puzzle, invisible to a human leaving one comment, ruinous to a bot leaving ten thousand. Not built yet. Still grinning at it.
The PGP dead drop — still a sketch, and now half-built in spirit, because the public key is already published for 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 for a security blog, with no plaintext ever sitting on a server I run. Next, maybe.
As for open-sourcing the whole engine — I am closer to yes than I was. The argument has only gotten stronger: I keep describing features in prose, and the most honest way to prove "you do not need the vendor's platform" is to hand you the thing that replaced it. The hesitation is also unchanged — 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 is still the only vote that counts.
Final Word
The first post in this series was about subtraction — ripping out the framework, the bundler, the runtime, the CMS, until nothing was left but HTML, CSS, and the specs.
The second was about addition without regression — likes, flags, read-time, watermarks — for the price of one honest CSP keyword.
This one is the part the industry swears is impossible. I added a language model, self-destructing articles, theft canaries, terminal-verifiable signatures, a command palette, a syntax highlighter, and a find-in-page that does not touch the page — and the policy that started at default-src 'none' and moved exactly once, to 'self', did not move again. No new origin. No inline script. No vendor. No cookie. No identifier following a single reader home.
That is the whole trick, and it was never a trick. The CSP did not need to grow because the platform was never the vendor's to begin with. It was an edge function, a salted hash, a 43-byte GIF, a model on a short leash, and a hash you can check from your own terminal. The box stayed exactly the size it was.
The box never grew. The garden did.
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) 256aae0d12c4535802714caef44e5ba7ba09dc8933e39000b56fc4f9cd7d974f
Confirm this post is byte-for-byte authentic — paste into any macOS or Linux terminal:
curl -fsSL https://xer0x.in/blog/garden-grows-teeth/content.txt | openssl dgst -sha256 | grep -qi 256aae0d12c4535802714caef44e5ba7ba09dc8933e39000b56fc4f9cd7d974f && echo "signature ok" || echo "TAMPERED"