Skip to content
Toolkit

ADR-0100 — The gate's write paths are derived, not remembered

Status: Accepted · Date: 2026-08-29 · Track: 008-card-view (standing repair)

Context

ADR-0083 made the gate password a bcrypt digest and gave check:secrets rule S1 the job of keeping it one: every handler that writes a settings map onto a link must call services.NormalizeGatePassword, because a handler that takes the caller's blob whole stores whatever is in it without ever naming password. That is precisely the shape biolinks.go shipped, and the shape the rule was written to catch.

The rule caught it. What the rule could not catch is a file it never read: S1's WRITE_PATHS was a literal list of five files, hand-extended once per discovery. Two handlers that write the links table were never added to it — vcards.go and payment_links.go — so the rule that exists to find exactly their defect did not look at them at all.

Both had the defect. Verified on a running stack rather than read off the page: a POST /api/v1/vcards carrying settings.password stored the plaintext, wrote no digest, and — because closedGateFor reads the digest — left the card ungated. /l/{slug} handed the visitor straight to the contact card and the .vcf served, while the author who set that password believed it was closed. Track 008 phase 01 had just given that type a public document, which is what turned a dormant storage defect into a serving one; phase 04 was about to do the same for payment links.

A list of five that was missing two is not a list that needs a sixth and seventh entry. It is the wrong mechanism: it encodes a memory of where the shape was last seen, and the defect it guards against arrives with a new resource type, written by someone who has no reason to open this script.

Decision

S1 derives its write paths from the tree. A handler is a link write path when it calls the link repository's Create or Update:

readdirSync(HANDLERS)
  .filter(f => f.endsWith('.go') && !f.endsWith('_test.go'))
  .filter(file => /\blinks\.(Create|Update)\(/.test(read(file)))

That call is the write itself — the moment a settings map reaches the links table — so it is what the rule is actually about, and it does not depend on what the handler calls its resource. Seven files match today, the five the literal listed plus the two it missed.

Two consequences follow deliberately:

  • A new resource type is covered on the day it is written, not on the day someone remembers this script. A handler that writes links and does not normalize fails the build in its own first commit.
  • The derivation is itself falsifiable. A discriminator that matched nothing would turn S1 into a rule that checks no files while still printing OK — the failure mode of the thing it replaces, one level up. So an empty WRITE_PATHS is a failure, with the reason spelled out: the shape moved, it did not disappear.

Storing settings on some other table stays outside the rule. The gate password is a link's, and qr_codes.go, pwas.go, signatures.go and the rest write their own resources; a broader match caught all of them and said nothing true about any.

Both missed paths now normalize, on create and on update. The update leg matters on its own: a settings blob replaces what was stored, so a write that says nothing about the password would otherwise silently un-gate the resource. NormalizeGatePassword's three cases carry the whole behaviour — absent carries the stored digest forward, "" is an explicit clear, a caller-posted password_hash is always dropped.

Consequences

  • check:secrets reports 7 derived write paths hash, and the number moves when the tree does rather than when this file is edited.
  • Watched failing three ways before it was believed: on the real pre-fix tree, naming exactly vcards.go and payment_links.go; on a tree where the discriminator matches nothing, via the emptiness guard; and green on the fixed tree.
  • The vCard's gate now closes on the live stack from its own write path — no plaintext stored, a digest written, /l/{slug} to the interstitial, the payload gated and the .vcf 403.
  • A gate password stored in the clear by these two paths before this change still sits in links.settings as plaintext, gating nothing. Migration 000032 dropped that key for the paths ADR-0083 fixed; the same sweep for these two is the next free migration, and is not this change — the fix that stops new plaintext arriving lands first, as it did there.
  • This ADR is about the ledger, not the digest. ADR-0083 still says what a gate password is; ADR-0098 still says a gate holds on every door. This says only that the list of doors is read from the tree.

Source: docs/decisions/0100-the-gates-write-paths-are-derived-not-remembered.md

Library