bryanhamilton.info / writing / article
The File on My Server Was Not the File in My Repo
Two needle-guarded deploy workers aborted back to back. The guards were right both times: the file I was patching was never the file in my repo. Reading the server first cost five minutes and saved the OG cards.
- Ships: a read-only peek worker before any needle gets written
- Grader: the served bytes of
og.php, not the repo copy - Cost: five minutes, one read, zero writes
Two aborts, telling the truth
My portfolio generates its own OG cards - the 1200x630 preview images that show up when a link lands in Slack or a chat. One article was serving the generic engineer card instead of its own, so I went to fix it. I have an og-card repo for this. I had built workers against that repo before. I knew that code cold.
Worker one used exact anchors from the repo source: find this function, patch inside it. Zero matches. Fine - code moves. Worker two was written layout-agnostic: no function names, no anchors, just structural invariants any version of the file should satisfy. Zero matches.
At that point the guards were telling me something, and I did not want to hear it. They were not saying "the file drifted." Two rewrites do not both miss by accident. They were saying: this file is not what you think it is.
The peek
So I shipped a worker that patches nothing. It reads og.php off the server and dumps it back to me. Cost: five minutes. What came back settled it - the host file was about 3KB of flat procedural PHP with a marker comment I had never seen, titles loaded from an og-manifest.json, cache keys built from an md5 of slug and title. The repo version had a different structure, different config, different cache layout. Different everything.
The repo was not a stale copy of production. It was documentation for a file that had been replaced at some point and never reconciled. Every future patch built from that repo would have failed - and a patch careless enough to "succeed" against it would have overwritten whatever is actually generating my cards right now.
The fix, and the rule it bought
The final worker was a full-file replacement built from the peeked bytes, not the repo: same manifest schema, same cache behavior, same query-parameter handling, because all of that is load-bearing on the live host. Its one needle - the marker the peek found - is guaranteed to exist, because it came from the real file instead of my memory of it. Backup, verify, self-delete, row in the receipts ledger. Both aborted workers had cleaned up after themselves, which is the only reason this is a story instead of an incident.
The lesson is now part of the pattern. My deploy rule has always been verify the served bytes, not the receipt - but that rule covered the output side. This week it learned the input side: dump the host bytes first, before any needle is written. A needle guard can only tell you that your assumption failed. It cannot tell you what the truth is. Only the real file can do that, and reading it first costs one worker; not reading it costs however many rewrites you spend defending a mental model that was already wrong.
So: when you patch production, what are you actually patching against - the repo, or the server? Have you checked lately that they are the same thing? The chat box in the corner is open.
More from the workshop
All writingEvery article, on this domain. My Homepage Said 23 Repos. GitHub Counted 32.Twelve drifted numbers, one needle-guarded pass, and why unverifiable claims teach machines you are noise.Every change to this site is logged in the ship log