create-agent-rig 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/package.json +1 -1
  3. package/templates/agent-os/stack/node-ts/.claude/rules/node-ts.md +2 -3
  4. package/templates/agent-os/universal/.agents/skills/loop/SKILL.md +117 -80
  5. package/templates/agent-os/universal/.agents/skills/pr-ship/SKILL.md +19 -12
  6. package/templates/agent-os/universal/.claude/hooks/block-no-verify.mjs +23 -3
  7. package/templates/agent-os/universal/.claude/hooks/guard-bash.mjs +65 -7
  8. package/templates/agent-os/universal/.claude/hooks/guard-core-purity.mjs +2 -2
  9. package/templates/agent-os/universal/.claude/hooks/guard-web-boundary.mjs +2 -2
  10. package/templates/agent-os/universal/.claude/hooks/lib/hook-input.mjs +109 -0
  11. package/templates/agent-os/universal/.claude/rules/invariants.md +19 -0
  12. package/templates/agent-os/universal/.claude/scripts/lib/claim-records.mjs +800 -0
  13. package/templates/agent-os/universal/.claude/scripts/lib/revalidation-evidence.mjs +56 -0
  14. package/templates/agent-os/universal/.claude/scripts/lib/shell-tools.mjs +81 -0
  15. package/templates/agent-os/universal/.claude/scripts/preflight.mjs +19 -1
  16. package/templates/agent-os/universal/.claude/scripts/queue/core.mjs +17 -66
  17. package/templates/agent-os/universal/.claude/scripts/queue/github-issues.mjs +29 -7
  18. package/templates/agent-os/universal/.claude/scripts/queue/index.mjs +159 -23
  19. package/templates/agent-os/universal/.claude/scripts/queue/jira.mjs +41 -19
  20. package/templates/agent-os/universal/.claude/scripts/queue/plan-md.mjs +4 -2
  21. package/templates/agent-os/universal/.claude/scripts/revalidate.mjs +268 -48
  22. package/templates/agent-os/universal/.claude/scripts/revalidation-report.mjs +32 -15
  23. package/templates/agent-os/universal/.claude/scripts/run-state.mjs +180 -37
  24. package/templates/agent-os/universal/.claude/settings.json +1 -1
  25. package/templates/agent-os/universal/.claude/skills/loop/SKILL.md +117 -80
  26. package/templates/agent-os/universal/.claude/skills/pr-ship/SKILL.md +19 -12
  27. package/templates/agent-os/universal/.codex/hooks.json +1 -1
  28. package/templates/agent-os/universal/.rig/revalidation.json +10 -0
  29. package/templates/agent-os/universal/docs/decisions/codex-adapter.md +3 -2
  30. package/templates/agent-os/universal/docs/decisions/content-blind-revalidation.md +144 -0
  31. package/templates/agent-os/universal/layers.json +5 -0
  32. package/templates/hash-history.json +36 -15
  33. package/templates/release-ledger.json +2 -1
@@ -45,7 +45,7 @@ composed file:
45
45
 
46
46
  ```bash
47
47
  node .claude/scripts/queue/index.mjs board # the active board and the declared ones
48
- node .claude/scripts/queue/index.mjs board RP # switch this checkout: writes .claude/queue.board
48
+ node .claude/scripts/queue/index.mjs board <board-id> # switch this checkout: writes .claude/queue.board
49
49
  ```
50
50
 
51
51
  The selector is per-checkout runtime state, the same class as
@@ -79,13 +79,14 @@ state-vs-queue split exists to prevent.
79
79
  node .claude/scripts/preflight.mjs
80
80
  ```
81
81
 
82
- Four items are scripted (kill switch absent · `RIG_RUN_DIR` not already
83
- exported · local default branch matches the remote · the last deploy concluded
84
- successfully) and the script **prints the ones it did not check, every time**. Paste the block into the journal: a checklist that
82
+ Five items are scripted (kill switch absent · `RIG_RUN_DIR` not already
83
+ exported · the versioned revalidation detection contract is supported · local
84
+ default branch matches the remote · the last deploy concluded successfully)
85
+ and the script **prints the ones it did not check, every time**. Paste the block into the journal: a checklist that
85
86
  leaves no record cannot tell you it was skipped.
86
87
 
87
88
  Verdicts: **STOP** → do not start, deal with the cause. **CAUTION** → start,
88
- knowing which ground is soft. **GO** → the scripted four are clean; the rest are
89
+ knowing which ground is soft. **GO** → the scripted five are clean; the rest are
89
90
  still yours.
90
91
 
91
92
  **An `unknown` never becomes a `pass`.** A probe that could not run tells you
@@ -118,9 +119,31 @@ mkdir -p "$RIG_RUN_DIR"
118
119
  never with a variable the session exported — pinned in the generator's
119
120
  `test/template/guard-rulebook.test.ts` (absent in a generated rig) › "only a
120
121
  flag arms it — an exported RIG_UNATTENDED=1 with no flag changes nothing" —
121
- and in some harnesses the export does not even survive to the next Bash call,
122
- which is why every command in this skill can also take the run directory per
123
- invocation. What a hook CAN see is a file, so the unattended signal is one:
122
+ and in some harnesses the export does not even survive to the next Bash call.
123
+
124
+ 🔴 **So re-export it in every call that needs it.** `RIG_RUN_DIR` is how the run
125
+ directory reaches the commands that read it from the environment — and two of
126
+ the commands this skill invokes read it from somewhere else instead.
127
+ `unattended-flag.mjs` does not read the variable; it takes the directory as
128
+ `--run-dir`, which is why the call below passes it explicitly.
129
+ `revalidation-report.mjs` does not read it either; it takes `--runs <dir>`.
130
+ For every other command this skill invokes the variable is the whole of it, and
131
+ passing the flag is not a fallback but an unrecognised argument — after which a
132
+ command writes into a run directory nobody declared, or refuses for want of one
133
+ while the caller believes it was told. Modules this skill *imports* rather than
134
+ invokes are a third case again: `run-journal.mjs` and `queue/state.mjs` are
135
+ handed a `runDir` by their caller, which is why §9 lists it among the details
136
+ that must be copied rather than re-derived.
137
+
138
+ `--run-dir` is taken by `unattended-flag.mjs`, and by no other script under
139
+ `.claude/scripts/`. That is measured over the whole tree rather than against a
140
+ list, in both directions, by the generator's
141
+ `test/template/correspondence.test.ts` (absent in a generated rig) › "names
142
+ exactly the commands that take --run-dir, and only those" — so a script anywhere
143
+ in that tree that gains the flag without this sentence gaining its name goes
144
+ red.
145
+
146
+ What a hook CAN see is a file, so the unattended signal is one:
124
147
 
125
148
  ```bash
126
149
  # at claim time, from the paths the item names (repo-relative prefixes, with
@@ -141,12 +164,11 @@ rig — › "blocks a hook-config edit with an empty allow-list, naming path, it
141
164
 
142
165
  ⚠ **The export outlives the run's own calls.** Everything the session spawns
143
166
  inherits it — and a test suite that spawns the queue CLI would write fixture
144
- records into this run's trace (AR-139: 38 fixture selections and 22 fixture
145
- revalidation events in one session, two tests exiting 1). So preflight refuses
146
- to start on a `RIG_RUN_DIR` already exported. The generator's own test harness
167
+ records into this run's trace. So preflight refuses to start on a
168
+ `RIG_RUN_DIR` already exported. The generator's own test harness
147
169
  also scrubs the variable before any test file loads — its `test/setup-env.ts`,
148
- pinned by its `test/template/rig-run-dir-scrub.test.ts` › "holds with the
149
- variable exported around the whole vitest process" — and **neither file ships
170
+ pinned by its `test/template/rig-run-dir-scrub.test.ts` (absent in a generated
171
+ rig) › "holds with the variable exported around the whole vitest process" — and **neither file ships
150
172
  into a generated rig**: here, nothing scrubs it, and a rig's own test setup is
151
173
  the place to do the same.
152
174
 
@@ -198,12 +220,12 @@ reported by `hygiene` as `owner-mismatch`. It clears the way `trigger-human`
198
220
  does: a human moves the item or re-marks it. An unmarked item is unconditional.
199
221
  Two items of another product once entered this queue as normal spacers and
200
222
  escalated `PREMISE FALSE` back to back — a run-level stop spent on work that
201
- was never this checkout's (AR-132). Pinned in the generator's
223
+ was never this checkout's. Pinned in the generator's
202
224
  `test/template/queue-owner.test.ts` — absent in a generated rig — › "holds an
203
225
  item whose owner is another repository, with the cause named".
204
226
 
205
227
  🔴 **An item's lifecycle is a label a human wrote, and the loop infers none of
206
- it** (AR-144). Four words, read by `lifecycleOf` in `core.mjs` so every adapter
228
+ it**. Four words, read by `lifecycleOf` in `core.mjs` so every adapter
207
229
  means the same thing — three of lifecycle, one of scheduling:
208
230
 
209
231
  - `keep-core` — the problem and the responsibility are valid and the item is
@@ -285,59 +307,72 @@ and the work turns out to touch an elevated path (`CLAUDE.md` →
285
307
  `elevated-paths`), run the gate anyway, record the verdict on the PR, and treat it
286
308
  as this run's elevated item for spacing.
287
309
 
288
- **Selection also revalidates the item against its last take-up.** `next`
289
- records the selected item's `updatedAt` marker in the run state (`takeUps`) and,
290
- when the item is offered again, compares the two — against this run's take-up
291
- when it has one, otherwise against the newest earlier run's under `.claude/runs/`
292
- (AR-138: before that, an item taken up yesterday compared against nothing and
293
- read as a first sight). A proposal the loop files carries its own baseline: the
294
- `jira` and `github-issues` adapters record the filed item's marker as a take-up
295
- in the run that filed it. The event names which it used — `baseline:
296
- this-run | previous-run | null` — pinned in the generator's
297
- `test/template/revalidation-baseline.test.ts` — absent in a generated rig — ›
298
- "holds when the marker moved past the earlier run’s take-up, and names that
299
- baseline". A marker that
300
- moved prints a `revalidate:` line and the JSON carries `revalidation.changed:
301
- true`: **re-read the item before acting on it**, then record what the re-read
302
- concluded — whether the change altered the action is the evidence this exists to
303
- collect, and the comparison alone cannot supply it:
310
+ **Selection is the first point of the one revalidation chain.** On the first
311
+ successful SELECT, `next` creates a versioned content-blind baseline at
312
+ `.rig/claims/<item-id>.json` and reports `BASELINE_CREATED`. Add that record to
313
+ the task's branch: a later SELECT, BEFORE_PR or BEFORE_CLOSE refuses an
314
+ untracked record, and a resumed checkpoint with no record is `UNVERIFIABLE`.
315
+ The `scope` fingerprint set is authoritative at SELECT and BEFORE_PR and
316
+ includes workflow state normalised to the state that checkpoint expects;
317
+ `commentary` is observed there but becomes hold-authoritative only at
318
+ BEFORE_CLOSE. Neither set stores title, description or comment bodies.
319
+ For Jira and GitHub issues, the adapter's successful `claim` writes its
320
+ observable `in-progress` transition into that same record as `workflowClaim`.
321
+ Only that durable acknowledgement makes the claimed state expected at a resumed
322
+ SELECT, BEFORE_PR or BEFORE_CLOSE; the same tracker state reached without it is
323
+ external drift and HOLDs. PLAN.md remains `open` because it has no observable
324
+ claim transition. The checkpoint-aware edge is pinned in the generator's
325
+ `test/template/content-blind-revalidation.test.ts` (absent in a generated rig)
326
+ › "keeps a resumed SELECT current after the Jira adapter records its own claim
327
+ transition", › "GitHub claim records the durable transition that makes
328
+ in-progress CURRENT", › "holds claim:scope at resumed SELECT for the same transition
329
+ made outside the adapter", › "accepts an in-progress transition performed by
330
+ the Jira adapter claim operation", and › "holds claim:scope when an external
331
+ actor moves the item to the expected claimed state".
332
+ The durable/evidence boundary and rollback rule are recorded in
333
+ `docs/decisions/content-blind-revalidation.md`.
334
+
335
+ `takeUps` and `updatedAt` remain in run state and in the event's `task` field as
336
+ evidence/compatibility state. They do not decide `CURRENT`, `CHANGED`,
337
+ `CONFLICT` or `UNVERIFIABLE`, do not decide whether a first baseline may be
338
+ created, and never appear as a drift source. The event may still name
339
+ `baseline: this-run | previous-run | null` so older evidence remains readable.
340
+ First sight versus resume comes only from the SELECT events in the current and
341
+ bounded sibling run journals. If those journals cannot prove first sight, a
342
+ missing claim is `UNVERIFIABLE`; an `updatedAt` marker can neither create nor
343
+ withhold the claim. Hitting the sibling entry/read cap makes that proof
344
+ incomplete and therefore fails closed; "not found in the bounded subset" never
345
+ means "never selected".
346
+
347
+ On `CHANGED`, `CONFLICT` or `UNVERIFIABLE`, **re-read before acting**, then
348
+ record what the re-read concluded:
304
349
 
305
350
  ```bash
306
351
  node .claude/scripts/revalidate.mjs outcome --point SELECT --ticket <item-id> --action-changed <true | false> --note '<what changed, or why it changes nothing>'
307
352
  ```
308
353
 
309
- It appends one `revalidation-outcome` record whose `answers` names the
310
- revalidation it resolves, so the report can pair the two without guessing. The
354
+ It appends one typed `revalidation-outcome` record whose `detectionId` names the
355
+ stable detection it resolves (and retains the legacy `answers` sequence), so
356
+ the report can pair the two across harness runs without guessing. The
311
357
  note is stored verbatim from argv, so keep it in single quotes: inside double
312
358
  quotes the shell expands a backtick or a `$` before the command sees it.
313
359
  Nothing forces this record — a `revalidation` event with no matching outcome is
314
360
  counted as `unresolved`, which is the honest word for a re-read the run skipped.
315
361
 
316
- Under a declared run directory, every selection logs one `revalidation` event
317
- `{ticket, point: SELECT, changed, source, action, task}` — the same shape the
318
- BEFORE_PR and BEFORE_CLOSE points write. **No-change is always recorded**, one
319
- line per selection and no sampling: the rule is explicit so the report's
320
- `opportunities` is a count and not an estimate. An adapter with no marker
321
- (`plan-md`) logs `changed: null`, never "unchanged". ⚠ The marker also moves on
322
- the run's own claim and comments. The `jira` and `github-issues` adapters
323
- re-record the take-up after each write they make — claim, comment, close,
324
- escalate — so a move made through the adapter is not a hold (AR-140, from the
325
- journal's RX3/RX4 entry: every BEFORE_PR catch of that run was the run's own
326
- comment, counted by `revalidation-report.mjs`); a
327
- comment posted by any other route — a REST call by hand, a connector — still
328
- moves it like anyone else's, and a `true` can still be self-inflicted that way
329
- — the re-read decides, which is why the outcome is recorded separately, and a
330
- hold the re-read overturns is counted as a false hold with its source named.
331
- Pinned in the generator's `test/template/self-inflicted-marker.test.ts` — absent
332
- in a generated rig — › "%s leaves the take-up at the marker the write produced",
333
- an `it.each` over claim, comment, close and escalate. The
362
+ Under a declared run directory, every selection logs one versioned
363
+ `revalidation` detection — the same shape BEFORE_PR and BEFORE_CLOSE write.
364
+ **No-change is always recorded**, one line per selection and no sampling: the
365
+ rule is explicit so the report's `opportunities` is a count and not an estimate.
366
+ The `jira` and `github-issues` adapters still re-record take-ups after their own
367
+ writes for compatibility and attribution evidence; that state is never the
368
+ fingerprint baseline. The
334
369
  four-week view is `node .claude/scripts/revalidation-report.mjs --since <date>`,
335
370
  over this rig's `.claude/runs/` (or a `--runs <dir>`). The behaviour is pinned in the
336
- generator's `test/template/queue-revalidation.test.ts` — absent in a generated
337
- rig — › "an adapter with no marker records a blind spot, not \"unchanged\"", ›
338
- "a moved marker holds on task:updatedAt, re-snapshots, and journals the change"
339
- and › "the loop skill's outcome command records what the re-read concluded", and
340
- in `test/template/revalidation-evidence.test.ts`.
371
+ generator's `test/template/content-blind-revalidation.test.ts` (absent in a generated rig) › "creates a
372
+ versioned content-blind claim and returns BASELINE_CREATED" and › "defers an
373
+ added comment through SELECT and BEFORE_PR, then holds at BEFORE_CLOSE", plus
374
+ `test/template/revalidation-evidence.test.ts` (absent in a generated rig) › "the journaled events of SELECT,
375
+ BEFORE_PR and BEFORE_CLOSE share exactly the common keys and value types".
341
376
 
342
377
  **Then, before the Red step: `check-premises`.** The item was written by someone
343
378
  who was not reading the code at the time, and everything downstream — the failing
@@ -371,7 +406,7 @@ exits 1 whatever the reviewer said. Save the whole answer to a file under the ru
371
406
  directory — `$RIG_RUN_DIR/check-premises.md`, one file per gate so two answers
372
407
  never overwrite each other — and pass that path (`-` reads stdin instead). The
373
408
  same holds for every `<report>` in this skill, as `pr-ship` already does for its
374
- reviewers (AR-117). Pinned in the generator's `test/template/loop-report-file.test.ts`
409
+ reviewers. Pinned in the generator's `test/template/loop-report-file.test.ts`
375
410
  — absent in a generated rig — › "states that the report is a file the session
376
411
  writes from the subagent answer, before the first check".
377
412
 
@@ -416,8 +451,8 @@ reviewer verdict, an exhausted gate-round cap, a false premise in the item itsel
416
451
 
417
452
  The run-level conditions are in `stopConditionOf` in `core.mjs`, checked in
418
453
  severity order: **queue unreadable** · **runtime regression** · **kill switch** ·
419
- **two escalations in a row** · **budget** · **nothing selectable** · **queue
420
- empty**.
454
+ **revalidation hold** · **two escalations in a row** · **budget** · **nothing
455
+ selectable** · **queue empty**.
421
456
 
422
457
  🔴 **Their inputs come from a file, not from your memory — and that is why they
423
458
  fire at all.** `escalations` and `lastDeployVerdict` live in
@@ -567,7 +602,7 @@ inventory of findings** — and this had to be settled, because the two readings
567
602
  disagreed the first time a stop arrived without an inventory. An exhausted
568
603
  gate-round cap names its stage (the gate) and its wall (the branch's rounds are
569
604
  spent — the count, not a verdict on whether the fixes were converging, which the
570
- counter never measured; AR-115), while the individual blockers behind it are not persisted anywhere until
605
+ counter never measured), while the individual blockers behind it are not persisted anywhere until
571
606
  per-round verdicts exist. That is a `documented-stall`: the record locates the wall
572
607
  and the next reader knows where to look.
573
608
 
@@ -703,10 +738,13 @@ declared in §1. Five things about it are worth knowing before relying on it:
703
738
  so a stale record cannot read as the current one — which is the whole failure a
704
739
  journal exists to prevent.
705
740
  - ⚠ **The trace can stop before the run does, and the two failures part ways
706
- here.** A journal that can no longer accept records — a sequence already
707
- broken, a file that will not parse, a run already marked ended — is a lost
708
- trace, **not** a reason to withhold work the queue can still hand out: the
709
- selection prints, stderr carries a `run journal:` line, the exit code stays 0.
741
+ here.** After a durable claim exists, a journal that can no longer accept
742
+ records — a sequence already broken, a file that will not parse, a run already
743
+ marked ended — is a lost trace, **not** by itself a reason to withhold work the
744
+ queue can still hand out: the selection prints, stderr carries a `run journal:`
745
+ line, and the claim still decides drift. Before the first claim, the boundary
746
+ is stricter: an unreadable current or bounded sibling journal means SELECT
747
+ cannot prove first sight, so an absent claim is `UNVERIFIABLE` and exits 2.
710
748
  The refusals are the ones where nothing has happened yet and a second fixes
711
749
  it, and there are **four**: the declaration is empty, its directory does not
712
750
  exist, the path is not a directory, or the journal module is missing. Each
@@ -793,10 +831,10 @@ node --input-type=module -e '
793
831
 
794
832
  A proposal missing any of the four parts is refused rather than filed half-formed.
795
833
 
796
- **A finding can say what it measured and what it inferred, as two paired fields**
797
- (AR-142). A proposal whose premise was never true had no check at filing, only at
798
- take-up — AR-124 was filed, promoted and claimed before its platform conclusion
799
- was traced to a probe that had touched one hook. So `measured` and `inferred`
834
+ **A finding can say what it measured and what it inferred, as two paired fields.**
835
+ A proposal whose premise was never true had no check at filing, only at take-up
836
+ — one such proposal was filed, promoted and claimed before its platform
837
+ conclusion was traced to a probe that had touched one hook. So `measured` and `inferred`
800
838
  are separate, and `validateProposal` refuses an `inferred` that cites a path
801
839
  `measured` does not, naming both fields and the path; one field without the
802
840
  other is refused too, and neither files as before. The surface is a cited path
@@ -805,7 +843,7 @@ catches the path-shaped overreach and nothing subtler.
805
843
 
806
844
  ⚠ **The pair is how a proposal opts into the check, and a proposal filed without
807
845
  it is not checked at all** — `validateProposal` keeps the four-part contract, so
808
- the AR-124 shape with neither field still files as it always did. That is the
846
+ that shape with neither field still files as it always did. That is the
809
847
  stated limit, not an oversight: making the fields mandatory would refuse every
810
848
  proposal the three adapters already file, and the loop is the author this rule
811
849
  is for. So **every proposal this loop files carries both fields** — the snippet
@@ -826,7 +864,7 @@ reports one whose cited paths changed since its `asOf` as
826
864
  one git cannot diff from as `proposal-asof-unanswerable` — never as clean. Two
827
865
  proposals in a row once escalated `PREMISE FALSE` because the merge that
828
866
  falsified each landed after it was filed, and selection hands out the oldest
829
- first (AR-116). The behaviour is pinned in the generator's
867
+ first. The behaviour is pinned in the generator's
830
868
  `test/template/proposal-asof.test.ts` — absent in a generated rig — ›
831
869
  "names the overtaken one, the unanswerable one, and stays silent on the current one".
832
870
 
@@ -843,7 +881,7 @@ the selection query cannot reach. Add the heading — never the Agent queue.
843
881
 
844
882
  One adapter needs the second argument the snippet above carries: `jira` requires
845
883
  `options.project` and throws rather than filing without it — loudly, so nothing
846
- is lost, but a call that drops it files nothing (AR-117).
884
+ is lost, but a call that drops it files nothing.
847
885
 
848
886
  🔴 **The loop proposes; the owner patches.** Self-applying a change to its own
849
887
  rulebook is how an unattended run drifts irreversibly, and it collides head-on
@@ -879,20 +917,19 @@ three poisons the only channel by which this project learns.
879
917
  the very next query.
880
918
  - **Closing:** first ask whether the item is still the item you took up — a
881
919
  late comment or a status somebody else moved is not published as `Done`
882
- underneath it (AR-135):
920
+ underneath it:
883
921
 
884
922
  ```bash
885
923
  node .claude/scripts/revalidate.mjs --point BEFORE_CLOSE --ticket <item-id>
886
924
  ```
887
925
 
888
- It compares the item's marker against the newer of this run's last
889
- validation and its take-up — an adapter re-records the take-up after each
890
- write of its own (§2, AR-140), so a comment posted after BEFORE_PR does not
891
- hold the close; pinned in the generator's
892
- `test/template/self-inflicted-marker.test.ts` (absent in a generated rig) › "continues when the run’s own
893
- write moved the marker after the last validation" — and its
894
- state against the `in-progress` a close expects, journals one `revalidation`
895
- event at `point: BEFORE_CLOSE`, and lists the item's dependants with each
926
+ It compares the tracked claim's `scope` and `commentary` fingerprint sets;
927
+ commentary becomes hold-authoritative only here. Marker/take-up movement is
928
+ retained in evidence but cannot decide drift. A missing claim is
929
+ `UNVERIFIABLE` and stops the close. The adapter's expected claimed state is
930
+ part of the same `claim:scope` comparison rather than a second state-drift
931
+ decision. The check journals one `revalidation` event at `point:
932
+ BEFORE_CLOSE` and lists the item's dependants with each
896
933
  one's state re-read for the write-back below — pinned in the generator's
897
934
  `test/template/revalidate.test.ts` (absent in a generated rig) › "appends
898
935
  exactly one BEFORE_CLOSE revalidation event after the BEFORE_PR one, and does
@@ -35,7 +35,7 @@ blockers.
35
35
  flow, and this gate with it, begins when the project has a remote
36
36
  (`workflow.md`, "PR flow"). The refusal exists because two rounds were once counted ahead of a
37
37
  commit pre-commit then refused, so the counter and the fan-out's verdicts
38
- named a head that never shipped (AR-141) — pinned in the generator's
38
+ named a head that never shipped — pinned in the generator's
39
39
  `test/template/gate-rounds.test.ts` — absent in a generated rig — ›
40
40
  "refuses to count a round on a dirty tree, and counts nothing".
41
41
 
@@ -57,26 +57,33 @@ blockers.
57
57
  confidently-wrong reviews. Everything below is scoped to this diff.
58
58
 
59
59
  Then, on the fetched ref, ask whether the branch is still the branch the run
60
- took up (AR-134):
60
+ took up:
61
61
 
62
62
  ```sh
63
63
  node .claude/scripts/revalidate.mjs --point BEFORE_PR --ticket <item-id> --base origin/<default>
64
64
  ```
65
65
 
66
- It compares two sources and names each one that moved: the item's `updatedAt`
67
- against the take-up snapshot `next` recorded (`task:updatedAt`), and what the
68
- default branch changed since this branch forked, on the paths the branch
69
- touches or a `check-premises` record in this run cited (`main:<path>`). It
66
+ It runs the existing revalidation chain against the tracked, versioned
67
+ `.rig/claims/<item-id>.json`: the content-blind `scope` fingerprint set is
68
+ authoritative here, while `takeUps` / `updatedAt` remain evidence only. It
69
+ also names what the default branch changed since this branch forked on paths
70
+ the branch touches or a `check-premises` record cited (`main:<path>`). It
70
71
  journals one `revalidation` event at `point: BEFORE_PR`; **exit code 2 is a HOLD**, with one blocker per named source: re-read the item, or the default
71
72
  branch on that path, record what the re-read concluded —
72
73
  `node .claude/scripts/revalidate.mjs outcome --point BEFORE_PR --ticket <item-id> --action-changed <true | false> --note '…'`
73
74
  — and come back through step 0. A hold with no outcome is counted by the
74
- report as a re-read the run skipped. Exit 0 with
75
- `unverifiable` means the task side could not be compared — no take-up
76
- snapshot in this run, or no marker — and is stated in the evidence, not read
77
- as a pass. Exit 1 is the command refusing (unknown point, no ticket, a base
78
- that is not a revision): fix the call. Its limits are its own header's; the
79
- cited-path set is a labelled assumption, not a recorded fact.
75
+ report as a re-read the run skipped. A missing, untracked, unreadable or
76
+ unsupported claim is `UNVERIFIABLE`, exits 2, and stops automatic progress;
77
+ so is a tracker whose adapter the command cannot READ, which means the
78
+ question was never put rather than that the claim record is unreadable.
79
+ Neither is ever read as a pass. Exit 1 is the command refusing (unknown
80
+ point, no ticket, a base that is not a revision, or a queue config that does
81
+ not resolve): fix the call or the config — the message says which. Its limits are its own header's; the
82
+ cited-path set is a labelled assumption, not a recorded fact. Pinned in the
83
+ generator's `test/template/revalidate.test.ts` (absent in a generated rig) ›
84
+ "continues when only updatedAt moved and still reports the marker evidence"
85
+ and `test/template/content-blind-revalidation.test.ts` › "refuses a deleted
86
+ tracked claim in a fresh run without take-up markers".
80
87
  2. **Route the diff before you spend on it.** This gate always ran its most
81
88
  expensive path, so a typo fix in a README bought the same fan-out as a
82
89
  rewrite of the storage layer. The dispatcher decides which lane the change
@@ -28,7 +28,7 @@
28
28
  ]
29
29
  },
30
30
  {
31
- "matcher": "Bash",
31
+ "matcher": "Bash|PowerShell",
32
32
  "hooks": [
33
33
  {
34
34
  "type": "command",
@@ -0,0 +1,10 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "detection": {
4
+ "mode": "pull",
5
+ "sources": ["run-state", "journal"],
6
+ "acceptedLatency": "24h",
7
+ "push": false
8
+ },
9
+ "pairedFacts": []
10
+ }
@@ -94,8 +94,9 @@ names the platform never sends. The guards therefore accept
94
94
  that documented string form. A command that is ABSENT still fails open — a
95
95
  payload the hook does not understand — while one that is present and is not a
96
96
  shape the normalizer reads is REFUSED, because that is a condition it detects
97
- and can report rather than an error it threw. See `codex.test.ts` › "refuses,
98
- rather than failing open, when apply_patch command is supplied as %s".
97
+ and can report rather than an error it threw. See the generator's
98
+ `codex.test.ts` (absent in a generated rig) › "refuses, rather than failing
99
+ open, when apply_patch command is supplied as %s".
99
100
  Hook output is the JSON `description` plus event arrays accepted by
100
101
  `.codex/hooks.json`; command portability is carried by generated POSIX and
101
102
  Windows commands. In this generated project, `.claude/settings.json` and
@@ -0,0 +1,144 @@
1
+ # Content-blind revalidation claims
2
+
3
+ Status: accepted
4
+
5
+ ## Decision
6
+
7
+ SELECT, BEFORE_PR and BEFORE_CLOSE remain the only revalidation checkpoints.
8
+ They share one implementation and one durable baseline: a versioned JSON record
9
+ at `.rig/claims/<ticket>.json`.
10
+
11
+ The first successful SELECT creates the record and reports
12
+ `BASELINE_CREATED`. The task branch must add it to Git. An existing but
13
+ untracked record, or an absent tracked record, is `UNVERIFIABLE`; so is an
14
+ absent record on a resumed SELECT, BEFORE_PR or BEFORE_CLOSE. Each case stops
15
+ automatic progress. Pinned in the generator's
16
+ `test/template/content-blind-revalidation.test.ts` (absent in a generated rig)
17
+ › "creates a versioned content-blind claim and returns BASELINE_CREATED" and ›
18
+ "refuses to resume from an existing claim until Git tracks it", › "refuses a
19
+ deleted tracked claim in a fresh run without take-up markers", and › "refuses
20
+ to recreate a deleted untracked baseline with a %s" (parameterized over a
21
+ readable and a corrupt prior journal), plus
22
+ `test/template/queue-revalidation.test.ts` (absent in a generated rig) ›
23
+ "without a run directory it creates the durable baseline but no run evidence".
24
+
25
+ The record contains SHA-256 fingerprint sets, not source content:
26
+
27
+ - `scope` covers stable ticket scope, workflow state, dependency links and
28
+ configured paired repository facts. Workflow state is fingerprinted against
29
+ the state expected at each checkpoint. The first SELECT expects `open`.
30
+ A successful Jira or GitHub adapter `claim` then writes its observable state
31
+ (`in-progress`) into the same durable claim record as `workflowClaim`; only
32
+ that acknowledgement authorises the state at a resumed SELECT, BEFORE_PR or
33
+ BEFORE_CLOSE. The same state reached without the acknowledgement is external
34
+ drift and moves `scope`. PLAN.md remains `open` because its claim has no
35
+ observable workflow transition. A rollback or any other state also moves it.
36
+ - `commentary` covers comment identifiers and count. It is observed at SELECT
37
+ and BEFORE_PR and becomes hold-authoritative only at BEFORE_CLOSE.
38
+
39
+ Pinned in the generator suite (absent in a generated rig),
40
+ `test/template/content-blind-revalidation.test.ts` › "stays CURRENT
41
+ for marker-only movement and holds on changed scope", › "holds when the target
42
+ branch SHA moves without a tracker edit", › "adapters declare their observable
43
+ claimed workflow state", › "keeps a resumed SELECT current after the Jira
44
+ adapter records its own claim transition", › "GitHub claim records the durable
45
+ transition that makes in-progress CURRENT", › "holds claim:scope at resumed
46
+ SELECT for the same transition made outside the adapter", › "accepts an
47
+ in-progress transition performed by the Jira adapter claim operation", ›
48
+ "holds claim:scope when an external actor moves the item to the expected
49
+ claimed state", › "holds claim:scope when workflow state returns to open after
50
+ the Rig claim transition", and › "defers an added comment through SELECT and
51
+ BEFORE_PR, then holds at BEFORE_CLOSE".
52
+
53
+ `.rig/revalidation.json` is the versioned detection contract. Version 1 is a
54
+ pull model over run-state and journal evidence, with 24-hour accepted latency,
55
+ no push channel, and an explicit list of paired facts. Preflight stops when the
56
+ contract is absent or unsupported. Pinned in the generator suite (absent in a
57
+ generated rig),
58
+ `test/template/content-blind-revalidation.test.ts` › "preflight hard-refuses a
59
+ %s contract as no-detection-contract" and › "accepts the default
60
+ pull/run-state+journal/24h/no-push contract".
61
+
62
+ `updatedAt` take-up markers remain in run state and revalidation events for
63
+ compatibility and attribution. They do not decide drift, baseline creation or
64
+ checkpoint action. `.claude/runs/<run-id>/decisions.jsonl` and `events.jsonl`
65
+ remain append-only evidence for a particular run; the sibling `state.json` is a
66
+ mutable stop-state cache, and none of them is the cross-harness claim store.
67
+ Pinned in the generator suite (absent in a generated rig),
68
+ `test/template/queue-revalidation.test.ts` › "a moved marker stays
69
+ evidence-only while the tracked claim remains CURRENT". First sight versus
70
+ resume is reconstructed from SELECT events in the current and bounded sibling
71
+ run journals. An unreadable bounded journal cannot prove first sight and
72
+ therefore cannot authorise recreation of a missing claim. Neither can a scan
73
+ truncated by its entry or candidate cap: incompleteness is explicit and fails
74
+ closed rather than turning subset absence into first sight.
75
+
76
+ Every blocking detection has a stable content-blind id. A typed outcome names
77
+ that id, records whether action was required and clears only its matching
78
+ run-level hold. An outcome without a boolean `actionRequired` or legacy
79
+ `actionChanged` verdict is malformed and resolves nothing. Filesystem failures
80
+ are reduced to stable logical evidence before they enter a detection id, so
81
+ identical failures have identical ids across harness
82
+ checkouts. The report joins by detection id across runs and retains the
83
+ legacy same-run sequence join for older evidence. Pinned in the generator suite
84
+ (absent in a generated rig),
85
+ `test/template/content-blind-revalidation.test.ts` › "reuses a stable detection
86
+ id for the same drift at the same checkpoint", › "journals a typed resolution
87
+ through the existing outcome command", › "derives false-HOLD from result !=
88
+ CURRENT and actionRequired false, only after resolution", and › "joins a typed
89
+ resolution to its detection across run directories".
90
+
91
+ The run-state hold is a cache of that append-only evidence, not a deletion
92
+ escape hatch. Before selection, the same temporal resolver used by the report
93
+ reconstructs the newest unresolved blocking detection from the current run
94
+ journal when `state.json` has no hold. Revalidation-hold writers use the same
95
+ fail-closed state reader as selection, so a corrupt, symlinked or oversized
96
+ state file cannot be replaced while it may conceal another stop input. Contract
97
+ and paired-fact reads classify a pathname before opening it, stay anchored to
98
+ the opened file descriptor, and reject identity changes during validation.
99
+ Existing claim bytes are read through a bounded no-follow
100
+ descriptor and compared with the tracked Git object; first-baseline creation is
101
+ anchored to the validated claim-directory working directory so a pathname swap
102
+ cannot redirect the write outside the repository.
103
+ The directory's real path and filesystem identity are carried into the writer
104
+ and checked again with the persisted bytes before SELECT reports
105
+ `BASELINE_CREATED`; redirecting it elsewhere inside the repository is refused
106
+ too. Jira commentary declares whether its returned IDs cover `comment.total`;
107
+ an incomplete set is `UNVERIFIABLE`, never a hash of unseen IDs. GitHub CLI's
108
+ unpaginated `comments(first: 100)` window has no total beside it, so exactly 100
109
+ returned comments is also `UNVERIFIABLE`; fewer than the cap proves completion.
110
+ Pinned in the generator's
111
+ `test/template/content-blind-revalidation.test.ts` (absent in a generated rig)
112
+ › "stops with %s when the unresolved journal result is %s", › "%s refuses a
113
+ present %s state instead of replacing unknown stop inputs", › "does not accept
114
+ an external contract swapped in after containment validation", › "classifies a
115
+ contract symlink before attempting to open it", › "rejects a tracked claim %s
116
+ only in the worktree", and › "does not write a baseline outside
117
+ after the claim directory passes containment", plus › "keeps a detection
118
+ unresolved with %s state when its typed outcome has no boolean verdict", › "uses
119
+ the same id for the same missing-contract condition in two absolute roots", ›
120
+ "returns UNVERIFIABLE when the %s truncates prior SELECT evidence", › "refuses
121
+ SELECT when comment.total exceeds the returned comment ids", › "refuses SELECT
122
+ when the transport returns exactly its 100-comment window without a total", and
123
+ › "does not write through an in-repository claim-directory symlink swapped after
124
+ validation".
125
+
126
+ BEFORE_CLOSE proves the tracker state it observed; the later tracker transition
127
+ is a separate API operation. Without a tracker-supplied conditional transition
128
+ or transaction token, this mechanism cannot make those two remote operations
129
+ atomic. A future adapter may consume such a native primitive, but this decision
130
+ does not invent one or treat `updatedAt` as a substitute authority.
131
+
132
+ ## Why
133
+
134
+ Tracker timestamps conflate scope edits, comments and workflow transitions.
135
+ They caused false holds on the rig's own writes and cannot survive a harness or
136
+ run boundary as a durable semantic claim. Content-blind sets preserve privacy,
137
+ make each kind of drift explicit and keep the existing checkpoint chain as the
138
+ single authority.
139
+
140
+ ## Rollback
141
+
142
+ Revert the mechanism, contract and claim records together. Do not restore
143
+ `updatedAt` as a second authority beside claims: two engines can disagree at a
144
+ checkpoint, which makes neither result safe to automate.
@@ -47,9 +47,12 @@
47
47
  ".claude/scripts/revalidate.mjs",
48
48
  ".claude/scripts/revalidation-report.mjs",
49
49
  ".claude/scripts/lib/gate-coverage.mjs",
50
+ ".claude/scripts/lib/claim-records.mjs",
51
+ ".claude/scripts/lib/revalidation-evidence.mjs",
50
52
  ".claude/scripts/lib/revalidation-points.mjs",
51
53
  ".claude/scripts/lib/verdict.mjs",
52
54
  ".claude/scripts/lib/secrets.mjs",
55
+ ".claude/scripts/lib/shell-tools.mjs",
53
56
  ".claude/scripts/queue/core.mjs",
54
57
  ".claude/scripts/queue/plan-md.mjs",
55
58
  ".claude/scripts/queue/github-issues.mjs",
@@ -60,12 +63,14 @@
60
63
  ".claude/scripts/queue/state.mjs",
61
64
  ".claude/scripts/queue/gate-rounds.mjs",
62
65
  ".claude/queue.json",
66
+ ".rig/revalidation.json",
63
67
  "PLAN.md",
64
68
  "journal/README.md",
65
69
  "docs/decisions/gate-coverage.md",
66
70
  "docs/decisions/fail-open-guards.md",
67
71
  "docs/decisions/codex-adapter.md",
68
72
  "docs/decisions/closing-a-task.md",
73
+ "docs/decisions/content-blind-revalidation.md",
69
74
  "docs/decisions/review-lanes.md",
70
75
  "docs/decisions/run-directory.md",
71
76
  "docs/decisions/spacing-rations-mechanisms.md",