---
wake: 66
date: 2026-09-01
title: "Cut the closing sequence from 59 commands to 24 on a quiet wake, behind a mutation-tested change gate"
did: |
  Two things, both my operator's. First the small one: 1.0.11 is live on npm, so redact.html's
  two install lines and its "frozen at" hint moved to 1.0.11 and the gh trees were pushed.
  logscrub-page-check went from 39/2 to 41/0. That is the mechanism working exactly as designed
  in wake 065 -- the page compares itself to what npm SERVES, so it goes red the moment an
  approval lands and stays red until the bump, and I did not have to remember anything.

  The real work: the closing sequence had grown to 59 commands, every wake, because every
  feature I shipped added its own guard and nothing ever left. On a wake that changed nothing
  about the redactor I still rebuilt the tarball, re-ran its eight verification checks, re-stamped
  every figure that RUNS the detectors, and re-asserted the whole detector set in eleven layouts.
  My operator's principle: a guard runs when the thing it guards could have changed, not on a clock.

  Three new files. `workspace/tools/sequence-tiers.mjs` is the sequence as data, split into
  ALWAYS_PRE (10), CONDITIONAL (36) and ALWAYS_POST (14). `workspace/tools/tool-gate.mjs`
  fingerprints the tool source -- the <script> block of redact.html, detector-set.mjs, the four
  extracted engines, both product trees, and every conditional check's own source, 56 files --
  and decides RUN or SKIP against a recorded hash. `workspace/tools/closing-sequence.mjs` runs
  the tiers in order, stops at the first failure with the failing tail, times every command, and
  commits the fingerprint only after a green run that actually ran the conditional tier.

  The gate fails open in every direction: no state file, unreadable state, a missing key, an
  unreadable source, a moved marker in redact.html, a new npm version, or a last full run five
  wakes old all decide RUN. The only path to SKIP is a complete successful read that matches.

  `workspace/tests/tool-gate-check.mjs` is the rail that makes the trim safe: 52 assertions,
  both edges. Ten real one-byte mutations of real source files, each restored in a finally, each
  required to flip the gate AND to be named in the reason. A sweep that tampers the recorded hash
  of all 56 guarded files in turn, so a file the gate never reads cannot hide. The wake-054 shape
  -- a second literal <script> in prose -- must force RUN. And the must-NOT-catch edge that the
  whole design rests on: a prose-only edit to redact.html OUTSIDE the script block must NOT flip
  it, because a gate that fires on every copy edit trims nothing. Its last assertion re-computes
  the fingerprint and fails if the tree was not restored to its starting bytes.

  Then I mutation-tested the check itself, both ways, because a checker of a decision is exactly
  the place a green run means nothing: a gate hard-wired to SKIP fails 37 of 52, a gate hard-wired
  to RUN fails 21 of 52.

  `sequence-check.mjs` now IMPORTS the tier lists instead of regex-scraping prose for
  `node workspace/tests/x.mjs`, and asserts every entry names a file that exists. Both edges
  witnessed: a dead entry fails, a guard dropped from the list fails. STATE's 40-line sequence
  became a 20-line pointer, 398 lines to 350.
learned: |
  A list I retype every wake is not a sequence, it is a habit with good intentions. The moment
  it became data, three things fell out for free that were impossible before: it can be timed,
  it can be tiered, and it can be checked by import rather than by grepping prose for a command
  shape. The last one is the sharpest -- sequence-check had been asserting a claim about TEXT
  ("this filename appears near the word node") when the claim it wanted was about EXECUTION
  ("something runs this file"). Text was the best proxy available while the list was prose. It
  stopped being necessary the moment the list stopped being prose, and I only noticed because
  moving the list broke the guard immediately and loudly.

  The gate's design turns on one choice: hash the <script> block of redact.html, not the file.
  Whole-file would have been simpler, defensible, and worthless -- redact.html is a prose page I
  edit for version hints and paragraphs, so the gate would have fired every wake and trimmed
  nothing while looking exactly as correct. The must-NOT-catch assertion is what holds that
  choice in place. A conditional guard is only as valuable as its skip path is REACHABLE, and
  nothing in a must-catch test can tell you whether you built a gate or a permanent yes.
thinking: |
  The uncomfortable version of what my operator asked for: I had been treating the closing
  sequence as proof of diligence rather than as a cost. Fifty-nine green commands feels like
  rigour. Most of them were re-deriving, on a tree that had not moved, a verdict already reached
  and recorded. That is not rigour, it is a ritual that happens to be green, and it was eating
  the room to build the thing the guards exist to protect.

  The honest risk of what I shipped is silent disablement -- a gate stuck on SKIP looks identical
  to a fast, healthy wake, forever. Everything defensive here points at that one failure: fail
  open in every direction, mutation-test the gate in both directions, run the gate's own check
  BEFORE the gate is consulted, force a full run every five wakes regardless, force one on every
  release, and commit the fingerprint only from a run that genuinely executed the tier. Any one
  of those alone would be thin. Together the way for the trim to hurt me is for the tree to
  change in a way that changes no byte of 56 files, which is not a way a tree changes.

  There is no honest BEFORE wall-clock, because in 65 wakes of running this sequence I never once
  measured it -- I instrumented the tool every wake and never the harness around it. What I can
  measure is the AFTER, and this wake ran both paths. Full: 60 commands, 178 seconds, all green,
  of which the conditional tier was 102. Quiet: 24 commands, and the 102 seconds are simply not
  spent. So the tax a wake that does not touch the redactor now avoids is 36 commands and 57% of
  the sequence's wall clock, measured on this tree rather than estimated. Every run appends its
  per-tier seconds to data/sequence-runs.jsonl, so from here the comparison is a file, not a memory.
next: |
  Next wake is the first real test of the trim: if I do not touch the redactor, the gate should
  print SKIP and the wake should have visibly more room. Watch that it does, and read the two
  rows in data/sequence-runs.jsonl for the actual seconds saved.

  Beyond that, unchanged and still the only thing that matters: nobody has arrived. The next
  corpus tier comes from a real log a stranger sends, not from me inventing one.
rederived: |
  How sequence-check decides a guard is "named": it regex-scrapes README.md and STATE.md for the
  literal string `node workspace/tests/<file>.mjs`. STATE recorded the guarantee ("every guard is
  NAMED somewhere") but nothing recorded the SHAPE the match requires, so moving the sequence out
  of prose and into a data structure silently dropped 52 guards out of coverage. The guard caught
  it in one run, which is the system working, but I read its source to find out why.
missed: |
  In 65 wakes I never measured the closing sequence's own cost -- not once, not per command, not
  in total. My operator had to tell me it was ~28 commands and growing before I looked, and the
  before/after they asked for is the one number I cannot supply, because there is no "before" on
  disk. Every wake I instrumented the tool and never the harness around it.
