Skip to content
Toolkit

Job 007: enforcement

Status: DONE Owner: @work, the routine

Phase: CLOSED — all five phases met their own bar on a running stack: 00 (ledger + gate), 01 (redirect path), 02 (interstitials), 03 (pixels) and 04 (DNS verification). Close-out: ./reports/CLOSE.md · Status: DONE · Updated: 2026-08-29

Scoreboard: npm run check:enforcement — 8 of 8 enforced (phase 01 3/3, 02 3/3, 03 1/1, 04 1/1); 6 capability keys classified, 2 served and owed by a point, 4 discharged on the write path. The number is committed in scripts/enforcement-ledger.json and recomputed by the gate, so this line quotes it rather than restating a census.

Dependencies: none open. 004's capabilities are DONE and bill four of these five controls today; 005 is DONE and its t() rule applies to every new surface here. The gate password is already a bcrypt digest with an allowlisted public payload (ADR-0083), which is what leaves phase 02 a digest to compare against. Charter: ./README.md. Routine: ./ROUTINE.md (batch loop, claim refs claim/007-*, budgets — inherited from 005 unchanged). Source: product gap assessment .archives/removal-safe/docs/assessments/PRODUCT-GAP-ASSESSMENT-082926.md §Route, §Gate, §Measure, §Address.

Objective

The outcome the charter states: README.md.

Completed

  • Closed (#408). ./reports/CLOSE.md states each of the five charter rows against its own bar, with the evidence file or the watched-failing observation that earns it, and records what the track decided: a branch enforces only what its query loads, a gate holds on every door or is not a gate, a refusal that narrows who is silent while one that asks the visitor for something renders, and the product draws the author's data rather than their script. The charter's phase 01 row named the wrong columns and the close-out says so (ADR-0091). Ledger 8 of 8; ROADMAP's 007 row flips DONE and 008 takes the front.

  • The plaintext the sixth write path left behind (#407). Migration 000033 drops links.settings->'password' again, for the rows 000032 could not have caught: it enumerated five write paths and there were six, so every biolink gated between that release and ADR-0098's repair wrote a fresh plaintext into the column 000032 had just swept — and the anonymous endpoint served the blob it sat in. Same shape and same two reasons as 000032: bcrypt is not available in SQL here, so the value cannot be converted, and dropping it removes no protection, because the gate reads password_hash and a row carrying only password is already ungated at every door 007 built. check:secrets S1/S4 hold the code side, so this is a sweep of what the gap left behind, not a recurring one.

  • A gate holds on every door into the page (#406). ADR-0092 gated /l/{slug}; /api/public/biolinks/{slug}, the endpoint the public page actually fetches, took no part in it. Asking for the page that way returned every block of a gated biolink and the settings blob with the gate password inside it — because biolinks.go was a write path ADR-0083 did not enumerate and never hashed, and because ADR-0083's allowlist was applied to one of the two anonymous endpoints. Three absences compounding into a plaintext credential served to strangers. The fetched endpoint now evaluates all three reasons in the redirect path's own order, refuses with the reason and nothing else — no blocks, settings, owner, pixels, or recorded view — verifies grants with the same LinkGrantService (so an acknowledgment opens no password gate and no verifier means a gate that can never be answered), and serves the allowlist; the write path hashes; the public page redirects to phase 02's interstitial rather than drawing a second door (ADR-0098). Watched failing five ways across the two gates, and the live legs watched failing against the shipped tree with the ungated leg still passing — inert on absent data. Ledger 8 of 8 unchanged, reader anchors 56 → 65: the three gate rows name both serving paths, and E1 now validates every path a row lists rather than only a lone string, which a list used to skip entirely.

  • A pixel has a control that attaches it (#405). The emitter shipped with #402 and nothing sent the field, so links.pixels_ids was reachable only through the API — a feature wired to nothing on the surface an author uses. The biolink settings panel gains a Pixels tab over the workspace's own pixels, and PUT /api/v1/biolinks/{id} accepts pixels_ids on the same empty-list rule the links handler has: the page that emits is the biolink page (ADR-0096), so that is the write the control needs. The ceiling is said out loud per pixel rather than discovered: the types endpoint serves emits_beacon, derived from whether a provider publishes a no-JavaScript beacon, and the four that do are the four that count a visit. A provider that cannot emit stays attachable — told, not refused. The picker knows no provider; the fact comes from the server, as the address does. Six unit tests and a live leg driving the tab in a browser and reading the row back.

  • A reference the author cleared is a reference removed (#404). PUT /api/v1/links/{id} could not detach a splash page, a project or a domain: a *int64 gives the same nil for an absent key and for null, so the handler read the form's "none" as "unchanged" and answered 200 to a write that changed nothing. It is read from key presence now — sent-and-null detaches, absent carries forward — which is pixels_ids' empty-array rule one cardinality down (ADR-0097). All three columns move together, being one defect in one decode block behind one form. splash_page_id had worked until #402 only because GetByID did not select it, so every edit rewrote the column NULL — the same defect that was clearing a link's splash page on rename; project_id and domain_id were always selected, so those two never worked at all. Watched failing on the pre-fix condition: the two carry-forward cases pass, all four detach cases fail. Phase 02's live detach leg is green again and all thirteen phase-01/02/03 legs pass on one stack.

  • Phase 03 — closed on a running stack (#403). A biolink carrying three pixel ids, all read back out of links.pixels_ids: the facebook one emits its beacon with the id from the row, the google_analytics one emits nothing because it publishes no no-JavaScript endpoint, and a facebook pixel in another workspace emits nothing though the write stored its id — the serve resolves inside the link's own workspace. In a browser the beacon is an <img> the visitor's page carries and actually requests (intercepted and fulfilled locally, so no page view leaves the machine); the page holds no connect.facebook.net and no fbq(, which is ADR-0096's ceiling. Detached, it emits nothing at all. Watched failing one inversion per half — the emit branch neutered with the API rebuilt from that tree, and PixelBeacons returning null with the server still serving, which a payload-only proof would have missed (evidence .station/jobs/007-enforcement/evidence/phase-03-running-stack-2026-08-29.md). Ledger unchanged at 8 of 8; phase 03 ticks and every phase is closed.

  • Phase 03 — a pixel emits, as a beacon (#402). links.pixels_ids has been in the schema since 000001 with nothing on any side of it: the create handler decoded the field into an interface{} and dropped it, no INSERT, UPDATE or SELECT named the column, and no page emitted anything. All of it landed together. The surface is the author's document — the public biolink page — and never the product's chrome, which is ADR-0094's rule applied to the interstitials; the mechanism is the provider's own no-JavaScript beacon as a 1×1 image, because this page is served from the origin whose localStorage holds the session token, so a provider's <script> would read it (ADR-0096). Four of twenty-four providers publish such a beacon; the rest emit nothing rather than something half-true. Addresses are built server-side from the registry, so the renderer knows no provider. The write stores ids; the serve resolves them inside the link's workspace, so a foreign id emits nothing whoever wrote it. Watched failing three ways — the query neutered, the ledger's renderer anchor deleted, and GetByID restored to the select it had, which proved a rename was clearing four columns phases 01 and 02 enforce on (evidence .station/jobs/007-enforcement/evidence/phase-03-pixels-watched-failing-2026-08-29.md). Ledger 7 of 8 → 8 of 8; phase 03 ticks on its running-stack proof.

  • Phase 04 — a domain is verified only when DNS says so (#401). Verify set is_verified = TRUE for anything that called it and the handler asserted the same on the struct it answered with, over no DNS call anywhere in the tree; both halves went together. What "verified" means is fixed by what the product does with a domain — redirect.go serves a Host's links — so the check is that the host points here: a CNAME at DOMAIN_VERIFICATION_TARGET, or an apex sharing its addresses (ADR-0095). No target verifies nothing (503, nothing written); our own resolver failing leaves the row alone. Proved on a running stack with the real resolver, including a stale TRUE cleared by a failing re-check, and watched failing with the no-op restored (evidence .station/jobs/007-enforcement/evidence/phase-04-running-stack-2026-08-29.md). Ledger 6 of 8 → 7 of 8. The backfill is still blocker 1 and is not built.

  • Phase 02 — closed on a running stack (#400). All three reasons asserted against rows on a live server: a marked link and a splash link each withhold the destination from every byte the server sends, the splash payload carries the author's text and none of their custom_js, detaching the page makes the branch inert again, and both draw and continue in a browser. The bypass is tried end to end — an acknowledgment leaves the visitor at the password door, and the endpoint refuses the password reason outright. Watched failing three ways: both branches neutered with the API rebuilt from that tree (every leg failed at its enforcement assertion and nowhere else), and splash_page_id swapped for NULL in GetLinkByURL, which replays #393 one column over and is caught by the repository integration test directly (evidence .station/jobs/007-enforcement/evidence/phase-02-running-stack-2026-08-29.md). Ten phase-01 and phase-02 legs green on the same stack. Scoreboard unchanged at 6 of 8; phase 02 ticks. No Docker daemon here, so Postgres 16 was initdb'd from the container's own binaries — same migrations, same seed, same route.

  • Phase 02 — the splash interstitial, the third of three reasons (#399). The third reason, and the one that had never rendered for any link in the product's life: splash_page_id was written by the form, stored beside a whole table with its own CRUD, editor and unlock countdown, and selected by no serving path — so the query moved first and the integration test holds it there. The page is drawn by the app from an allowlist of the author's row — text, countdown, one http(s) button — and never their custom_js, custom_css or ad slots, because the app's origin is where sessions live (ADR-0094). All three reasons compose in cost order — password, warning, splash — each answer travelling to the next door, asserted table-driven. Watched failing with the branch neutered. Ledger 5 of 8 → 6 of 8; phase 02 3/3 built, and closed by the running-stack proof above.

  • Phase 02 — the content warning and its acknowledgment (#398). A resource its author marked sensitive_content no longer opens unannounced: the redirect path 302s to the same interstitial, now told which of the three reasons it is drawing, and POST /l/{slug}/acknowledge witnesses the answer. The grant carries its reason inside the signature (ADR-0093), so an endpoint that verifies nothing cannot mint a password answer — asserted end to end across both endpoints. A resource with both gates is answered one door at a time, password first, with the earlier answer travelling. Watched failing with the branch neutered (every case failed at its enforcement assertion) and the ledger gate watched failing on the new row's anchor. Ledger 4 of 8 → 5 of 8, phase 02 2/3.

  • Phase 02 — the password gate and its unlock (#397). A link with a digest never serves its destination: the redirect path 302s to the interstitial the app draws, POST /l/{slug}/unlock compares the ADR-0083 digest behind its own copy of the login lockout, and a correct password buys a signed grant scoped to that one link for fifteen minutes. The grant is stripped from the query before the destination is served, an unconfigured gate refuses rather than opens, and every failure answers identically (ADR-0092). The bar is an absence and it is asserted as one, on a running stack and in a browser, watched failing with the branch neutered (evidence .station/jobs/007-enforcement/evidence/phase-02-password-gate-2026-08-29.md). Ledger 3 of 8 → 4 of 8.

  • Phase 01 — closed on a running stack (#396). The charter's bar met against a live server: a targeted link serves the audience it names and 404s for the wrong device and the wrong language, a scheduled link 404s before it opens and after it closes, and a limited link serves expiration_url at its limit and the 404 with that setting cleared — each read back out of the row, and links.clicks asserted to count only what was served. Watched failing with all three branches neutered and the API rebuilt from that tree: every leg failed at its enforcement assertion and nowhere else (evidence .station/jobs/007-enforcement/evidence/phase-01-running-stack-2026-08-29.md). The charter's "two destinations by audience" is ADR-0090's 404, which is what the suite asserts. Scoreboard unchanged at 3 of 8; phase 01 ticks.

  • Phase 01 — the click limit on the redirect path (#395). A link whose clicks have reached settings.clicks_limit serves settings.expiration_url and takes the 404 when that setting is empty, unsafe or blank — the reference tree's own behaviour (l/Link.php:214), including clicks >= limit against the counter RecordClick increments and a falsy limit meaning no limit. It is the last of the three branches because it is the only one whose refusal is observable, and the composition under the two silent refusals is asserted table-driven. Both settings and clicks were already selected by GetLinkByURL; the integration test now holds them there too. Watched failing with the branch neutered. Ledger 2 of 8 → 3 of 8, phase 01 3/3 built.

  • Phase 01 — the schedule on the redirect path (#394). A link outside its window takes ADR-0090's 404 and records no click. The schedule is scheduled_at/scheduled_end, not start_date/end_date: those are columns and model fields nothing writes in either tree, so the branch the charter described could never have fired (ADR-0091, with the three-spelling census). The integration test's schedule assertion was watched failing with the columns dropped back out of the query. Composition with targeting is asserted table-driven, which closes that open item. Ledger 1 of 8 → 2 of 8.

  • Phase 01 — the redirect path loads what it enforces on (#393). #392's branch was inert: GetLinkByURL, the only read it can take input from, did not select display_rules, and an unselected column arrives as the zero value — indistinguishable from a link with no rules. Found by writing the integration test the charter's bar asks for, watched failing and passing against a real database. The ledger's reader is now a list: a row names the branch that decides and the query that loads what it decides on, and the widened rule is watched failing on the defect replayed (evidence .station/jobs/007-enforcement/evidence/phase-01-display-rules-loaded-2026-08-29.md). Scoreboard unchanged at 1 of 8 — the row was already flipped; this is what makes the flip true.

  • Phase 01 — display rules on the redirect path (#392). redirect.go matches link.DisplayRules through the existing DisplayRulesService, above the tracking cookie: an excluded visitor gets the 404 a nonexistent slug gets and leaves no click, because none resolved. The visitor both serving paths evaluate against is built once (newVisitorContext), so the biolink page and the redirect path cannot drift on who the visitor is. Inert on absent data — fifteen table-driven cases, including the three shapes that must still resolve. The refusal is a product call, so it is an ADR: ADR-0090 — narrowing who a link is for 404s, asking the visitor for something renders, which is what keeps phase 02's interstitials a different shape. Ledger 0 of 8 → 1 of 8.

  • Phase 00 — the enforcement ledger and its gate (#391). Eight points — three for phase 01, three for 02, one each for 03 and 04 — each naming what authors the control, where it is stored, the serving path that must read it, and the capability that bills it. All start unenforced; ADR-0089 fixes what a flip costs: a reader file plus the anchors it must mention, in the commit that adds the reader. check:enforcement joins npm run verify at 0 of 8, watched failing on four broken inputs — a deleted reader, a flip with no reader, an uncovered served capability, and a drifting count (evidence .station/jobs/007-enforcement/evidence/phase-00-gate-watched-failing-2026-08-29.md).

Active

Open items

None in flight. Residue handed back to the owner is listed here, once:

  • A branch enforces only what its query loads — discharged on both sides. GetLinkByURL selects every column a serving path reads (pixels_ids joined it with phase 03), and GetByID now selects every column Update writes, which it did not: a partial link edit was clearing splash_page_id, display_rules, timezone and the schedule (ADR-0096, the same rule on the write side). (start_date/end_date are ADR-0091's dead columns and never will be.)
  • Twenty of the twenty-four pixel providers cannot emit here. Only facebook, linkedin, pinterest and quora publish a no-JavaScript beacon; the rest are script-only, and a script on this origin can read the session token (ADR-0096). Blocker 2 is what lifts the ceiling. The picker now says so per pixel rather than letting an author discover it, and a provider that cannot emit is still attachable — told, not refused.
  • redirect.go composes branches in an order that matters — settled and asserted (#394): both refusals are silent, so their order is unobservable; only the click limit, which serves expiration_url, is distinguishable, and it is evaluated last.
  • Phase 03 has nowhere to emit on a bare 302 — discharged: phase 02 shipped two documents the product serves (the warning and the splash), beside the biolink page. The constraint stands as a rule, not a blocker: emission is limited to documents that exist, never a redirect shim invented to carry a tag.
  • A splash page cannot be detached through the API — fixed for all three reference columns together (ADR-0097): the handler reads which keys the body carried, so sent-and-null detaches and absent carries forward — pixels_ids' empty-array rule one cardinality down. splash_page_id had worked only as a side effect of the defect #402 fixed; project_id and domain_id were always selected, so their control had never worked at all. Phase 02's live detach leg is green again.
  • drawer-roundtrip.spec.ts's pixel drawer leg is red on main. Its getByLabel(/pixel id|code/i) matches the "QR codes" nav link as well as the Pixel ID input, so it dies on a strict-mode violation before it asserts anything. Confirmed pre-existing against a clean tree with the API rebuilt from it — a test defect, not the drawer. One line, one PR of its own.
  • The biolink Update handler has ADR-0097's defect too. Its project_id, domain_id and splash_page_id still read pointer-nil, so null there means "unchanged". No surface sends it — the settings panel patches only what it changes — so nothing is broken today; making the two handlers agree is one PR.
  • A splash page collects four settings that render nowhere. custom_js, custom_css, ads_header and ads_footer are in the editor and refused by the public payload on purpose (ADR-0094): they are another account's script on the origin where sessions live. Wiring them is not the option; withdrawing them from the editor is a product call and one PR.
  • @csxbase/studio-react exports Cluster but index.d.ts does not declare it, so a TypeScript consumer cannot use it — the #274 finding one component over, and check:studio-parity reads index.js, so the ledger says it ships. Found reaching for it here and deliberately not fixed: one PR of its own.
  • The content warning's wording is provisional. Blocker 2 is still the owner's: public.gate.sensitive.* ships a content warning with continue/leave and claims no age, and the acknowledgment lasts the grant's fifteen minutes. Replacing the wording is one file; remembering the acknowledgment longer is a cookie on the app origin, never a longer grant (ADR-0093).
  • handlers/domains.go:267 asserts IsVerified = true on the struct — both halves went together in phase 04: SetVerified takes the outcome, and the handler sets the struct field from what the lookup found.
  • The biolink public payload is not gated — closed, and it was three defects rather than one (ADR-0098): the endpoint served a gated page's blocks, served link.Settings wholesale rather than ADR-0083's allowlist, and biolinks.go never hashed the gate password at all — so the plaintext was stored and then served to strangers. All three are fixed, and check:secrets grew S4 plus a second S1 test shaped for a handler that stores a settings blob without naming password, which is why this path went unseen.
  • clicks_limit is stored as two types. The link form sends a JSON number (lib/linkForm.ts:107); the file-link and static-page multipart handlers store the raw form string (file_links.go:166, static_pages.go:191). The redirect path reads both, so nothing is unenforced; unifying the write is a data question and one PR of its own.
  • The display-rules editor writes scheduled_start; the matcher reads scheduled_at (DisplayRulesEditor.tsx:15 vs display_rules.go:91), so a schedule set inside the rules JSON matches nothing. Found while wiring phase 01 and deliberately not fixed there — one key, two spellings, and picking which one wins is a data question. One PR of its own.

Blockers

All three are owner decisions, each with options and a recommendation. None blocks the track's buildable remainder.

  1. Existing is_verified = TRUE rows now that phase 04 has landed — leave, reset all, or reset only non-matching. Recommendation unchanged: leave; nothing on the serving path reads the column, and a blanket reset flips a badge on every existing customer domain with no notice. Less pressing than it was: a failing re-check now clears a stale badge wherever anyone presses the button, so the population self-corrects rather than needing a migration to be correct at all.
  2. An origin for the public pages that holds no session — the ceiling ADR-0096 names. Serving /b/{slug} (and 008's renderers) from a separate origin is what would let the other twenty providers emit their real tags, since a script there could read no token. Options: leave it (four providers emit, the rest do not), a second origin for public pages, or move the token out of localStorage first. Recommendation: leave it for now and revisit at 008, which multiplies the public surfaces this would apply to. Nothing in the track is blocked either way.
  3. What the sensitive-content interstitial asserts — content warning, age gate, or both, and whether acknowledgment is remembered. Recommendation: a content warning with continue/leave and a per-resource cookie, no age assertion, since nothing in the tree collects a birthdate. Phase 02's password and splash slices are unaffected.

Decisions

Taken at chartering, each to be an ADR when the slice that needs it lands:

  • The matcher is not rebuilt. Phase 01 calls services/display_rules.go, the same matcher public_biolink.go already uses for blocks. A second matcher for links would be a defect in the second place (docs/guides/workstream.md).
  • Enforcement is inert on absent data. A link with no rules, no dates, no limit and no password takes the current path byte for byte. This is what makes each phase revertible alone.
  • A link over its click limit serves expiration_url, and 404s when that setting is empty — both are already collected by lib/linkForm.ts, so the behaviour is read from data rather than invented.

Files changed

Named per phase in the close-out and the pull requests it cites.

Verification

Bar: docs/guides/workstream.md — npm run verify exit 0 plus go vet ./... && go test ./... for every apps/api diff, a live E2E per new surface asserting a database read, and any new or widened gate watched failing once on a deliberately broken input with the observation in evidence/. Merge policy: the standing policy on ROADMAP.md.

Next actions

Nothing. This track is closed — no item here is claimable, and a run that reaches this file has read the wrong front track. Per ROUTINE's TRACK HANDOFF, the next run's single item is to charter 008 from ROADMAP's 008 section and the assessment's §Card view / §Resource types, under docs/guides/workstream.md — README, ROUTINE.md inheriting this track's protocol unchanged (claim namespace claim/008-*), and SESSION.md.

Two facts 008 should carry in rather than rediscover. Blocker 2 belongs to it: a separate origin for the public pages is what lifts ADR-0096's pixel ceiling, and 008 multiplies the public surfaces the question applies to, so it is the right place to take it. And ADR-0094's rule is a renderer rule before it was an interstitial one — the product draws the author's data, never their custom_js — which is the shape every renderer 008 adds will need.

Closed items that are not 008's and stay listed below: the seven open items, each one PR whenever it neighbours work in hand, and the three owner decisions under Blockers.

Source: .station/jobs/007-enforcement/SESSION.md

Library