checkwright 0.19.0 → 0.21.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 (34) hide show
  1. package/package.json +2 -2
  2. package/payload/canon-kit/SPEC.md +2 -2
  3. package/payload/canon-kit/checks/check-md-refs.sh +22 -9
  4. package/payload/canon-kit/checks/check-spec-pointer.sh +6 -2
  5. package/payload/context-kit/SPEC.md +13 -6
  6. package/payload/context-kit/lib/toolfloor.sh +1 -1
  7. package/payload/delegation-kit/README.md +2 -1
  8. package/payload/delegation-kit/SPEC.md +207 -35
  9. package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +61 -0
  10. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/agents/silent.md +7 -0
  11. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/args +1 -0
  12. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/expect.txt +1 -0
  13. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-cheap.md +7 -0
  14. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-inherit.md +8 -0
  15. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/args +1 -0
  16. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/expect.txt +1 -0
  17. package/payload/delegation-kit/lib/delegation.sh +2 -0
  18. package/payload/delegation-kit/smoke/install.sh +1 -0
  19. package/payload/delegation-kit/templates/agent-execution.md +74 -9
  20. package/payload/gate-sdk/SPEC.md +6 -5
  21. package/payload/gate-sdk/bin/gen-pre-commit.sh +1 -1
  22. package/payload/gate-sdk/bin/run-gates.sh +1 -1
  23. package/payload/gate-sdk/checks/check-graph.sh +3 -3
  24. package/payload/gate-sdk/checks/check-reads-couples.sh +3 -1
  25. package/payload/gate-sdk/checks/check-tree-terms.sh +11 -7
  26. package/payload/gate-sdk/lib/gate.sh +29 -13
  27. package/payload/lifecycle-kit/SPEC.md +14 -4
  28. package/payload/lifecycle-kit/templates/lead.md +38 -3
  29. package/payload/site-kit/README.md +12 -5
  30. package/payload/site-kit/SPEC.md +284 -28
  31. package/payload/site-kit/checks/check-docs-render-fidelity.sh +100 -27
  32. package/payload/site-kit/gate-tests/check-docs-render-fidelity-batch.test.sh +158 -0
  33. package/payload/site-kit/lib/site.sh +16 -2
  34. package/payload/site-kit/templates/site-health.yml +128 -6
@@ -17,7 +17,27 @@ reach-through, not a change to this protocol; every rule below still applies.
17
17
  stops and reports rather than choosing.
18
18
  - **Background + notification, never poll.** Always `run_in_background`; wait for
19
19
  the completion notification; do not read the output file. Backgrounding keeps
20
- the main loop free to redirect.
20
+ the main loop free to redirect. Backgrounding survives a **turn**, not a
21
+ **session**. A supervisor's turn ends and its session lives on, so a
22
+ backgrounded dispatch wakes it by notification — that is the sanctioned
23
+ pattern just stated. A **dispatched agent's** turn end *is* its session end,
24
+ and what that reliably kills is the **observer, not the work**: an `Agent`
25
+ child is reaped with its parent, but a shell `run_in_background` child
26
+ survives — orphaned, still writing, with nothing left able to read it. The
27
+ survivor is the worse case, because it keeps mutating shared files while the
28
+ next actor moves against them. Either way the caller gets no result, so a
29
+ dispatched agent **never ends a turn on work still running** — it awaits its
30
+ own long-running work to completion, however long, and reports only results
31
+ it holds. Awaiting, not "dispatch in the foreground": foreground is a choice
32
+ for a shell command and not reliably one for an `Agent` dispatch, which the
33
+ harness may detach whether or not backgrounding was requested. And not by
34
+ ending the turn to wait for the completion notification — that is the one act
35
+ that revokes the channel, which is how a *careful* reader reaches this
36
+ failure. Wait **in-turn on a condition** instead: loop on the work's own
37
+ artifact (evidence file, lock, exit marker) with the harness's waiting
38
+ primitive. Never-poll governs waiting on an `Agent`'s completion notification,
39
+ a channel a supervisor has; condition-waiting is the only one a dispatched
40
+ role has.
21
41
  - **Serialize on shared files; ≤`DELEGATION_KIT_FAN_WIDTH`-wide otherwise.**
22
42
  Agents that edit a shared file (see the roster below) run one at a time —
23
43
  dispatch, await notification, validate, dispatch the next. Independent
@@ -29,6 +49,13 @@ reach-through, not a change to this protocol; every rule below still applies.
29
49
  `isolation: worktree` (own index); reserve the unlocked
30
50
  ≤`DELEGATION_KIT_FAN_WIDTH`-wide bound for **read-only** fan-outs. "No lockfile
31
51
  churn" is a false safety signal — the index is shared regardless.
52
+ Serialization is by **completion**, not by notification: the next dispatch
53
+ begins after the previous one has *returned and been validated*. A supervisor
54
+ reaches that point via the completion notification; a **dispatched agent**
55
+ reaches it in-turn, awaiting each child before dispatching the next (it cannot
56
+ end its turn to wait — see the backgrounding rule). The ordering requirement
57
+ is identical for both; only the waiting mechanism differs, and neither role
58
+ may overlap two agents on a shared file or the git index.
32
59
  - **One commit per unit, sized to finish within budget.** Each unit gets its own
33
60
  commit (+ a `[blocked-by: prior]` tag where ordered). A unit that investigates
34
61
  long before its first commit is the only thing an interrupt can destroy —
@@ -37,7 +64,7 @@ reach-through, not a change to this protocol; every rule below still applies.
37
64
  - **Gate-driven worklist where one exists.** Drive the sweep from the gate's
38
65
  output, so an interrupt loses only the in-flight uncommitted unit and a fresh
39
66
  session re-runs the gate to resume.
40
- - **Resume journal — agent writes, supervisor deletes.** The agent `Write`s a
67
+ - **Resume journal — agent writes, scratch reset sweeps.** The agent `Write`s a
41
68
  running progress journal (findings triaged, edits applied, what remains) to a
42
69
  repo-local gitignored scratch dir in the main checkout — `.tmp/` here — never a
43
70
  temporary worktree (deleted with the worktree) nor a system temp dir (a restart
@@ -48,14 +75,23 @@ reach-through, not a change to this protocol; every rule below still applies.
48
75
  `DONE` marker. Each finding is
49
76
  written into the journal *inline as it is confirmed* — never "see final
50
77
  output": the agent's return message dies with the session, so a pointer-only
51
- journal makes `DONE` lie about recoverability. **Agents have no `rm`, so the
52
- supervisor deletes the journal at the post-commit validation checkpoint.** A
53
- journal *without* a `DONE` marker signals interruption only in a **cold read**
78
+ journal makes `DONE` lie about recoverability. **Nobody deletes a journal
79
+ while the work it covers is live** — not the agent (no `rm`) and not the
80
+ supervisor, whose deletion would take the file out from under a resumed agent
81
+ and destroy its own pull channel mid-unit. Cleanup is the consumer's scratch
82
+ reset at its next work-unit boundary, not a chore in this protocol. `DONE` is
83
+ the completion marker and counts **only as the file's last line**: a session
84
+ resumed past its own marker appends after it. A journal *without* a `DONE`
85
+ marker signals interruption only in a **cold read**
54
86
  — the supervisor found a journal but never consumed the agent's return (its
55
87
  session died before returning); there, no `DONE` = interrupted, resume from
56
88
  it. On the ordinary path the supervisor consumed the return and ran its
57
89
  post-commit verification, which *is* the completion attest, so the missing
58
- marker is redundant, not a signal of interruption. **Caveat — a background agent's sandbox may block
90
+ marker is redundant, not a signal of interruption. Since every journal now
91
+ outlives its session, presence alone signals nothing — tell a live journal
92
+ from a spent one by its per-session name, the work cursor, and `git log`
93
+ (delegation-kit/SPEC.md §Resume journal — agent writes, scratch reset
94
+ sweeps). **Caveat — a background agent's sandbox may block
59
95
  the journal write.** `run_in_background` agents have been observed unable to
60
96
  `Write` to the granted path and silently falling back to returning findings in
61
97
  their final message — which makes the journal mechanic non-functional exactly
@@ -63,7 +99,23 @@ reach-through, not a change to this protocol; every rule below still applies.
63
99
  (audit, survey), the return value *is* the contract — don't rely on a journal.
64
100
  Reserve the journal / worktree isolation for agents that **mutate files**, and
65
101
  for those grant the journal path explicitly before dispatch rather than
66
- assuming the write succeeds.
102
+ assuming the write succeeds. A contract has two ends, though: the child owes
103
+ no journal, and the **parent** owes the durable landing of what it received
104
+ before acting on it (next bullet). The caveat is about a backgrounded child's
105
+ write failing silently, so it never licensed the parent — which has already
106
+ demonstrated it can write, being the session that granted the path.
107
+
108
+ - **Findings you will act on are durable before you act on them.** A child's
109
+ return value lives only in your context, and your context dies with your
110
+ session. Before you *act* on a dispatched agent's findings — edit against
111
+ them, rule from them, plan the next wave on them — land them somewhere that
112
+ survives you: a commit, or your own journal. The write is the parent's,
113
+ discharged on receipt, not a chore delegated back to the child. This binds
114
+ whoever holds findings they will act on, at any depth. It costs one write per
115
+ returned child, not a running narration. A session that is itself dispatched
116
+ writes to the journal path it was granted; a top-level session has no journal
117
+ in this contract and discharges by committing, which it is by construction
118
+ able to do.
67
119
  - **Validate after every agent commit** — a sub-agent's "passed" claim is not
68
120
  trustworthy. Re-run the relevant gates (the sweep's own gate) and the consumer
69
121
  validate battery below. **Diff every gate change in an agent commit before
@@ -90,6 +142,13 @@ reach-through, not a change to this protocol; every rule below still applies.
90
142
  window-expensive than its
91
143
  subagent-token total suggests, so size waves to leave the next one headroom, or
92
144
  accept one wave per window.
145
+ **The projection reaches downward as well as forward.** The guard re-arms at
146
+ every depth — a dispatched session's own dispatches fire it too — but each
147
+ verdict prices **one call**, never the subtree that call opens. Nothing
148
+ between a dispatch and its children's children ever sees the whole. So budget
149
+ a dispatch you expect to fan out for its **subtree**, not its own turn, and
150
+ read a child's fan-out as your spend even though its verdicts land in a
151
+ context you never see.
93
152
  **Do not read live budget off the statusline while parked on a dispatch.**
94
153
  Observed: the harness statusline does not refresh while the main session waits
95
154
  on a background agent's completion notification, so its displayed budget
@@ -113,8 +172,14 @@ reach-through, not a change to this protocol; every rule below still applies.
113
172
  whose description commits to review work, never one that disclaims it (an
114
173
  excerpt-locator serves pure search, not audit). Selection sits with the
115
174
  dispatching session — its context holds what selection
116
- needs — and a standing choice lands in a tracked agent-type definition, never
117
- per-dispatch habit.
175
+ needs — and it is **affirmative**: an unselected dispatch does not fall back
176
+ to a cheap default, it **inherits the dispatcher's tier**, so declining to
177
+ choose silently buys the most expensive tier in reach — and buys it precisely
178
+ for the read-only fan-outs that are the cheapest work you dispatch. That is
179
+ why a standing choice lands in a tracked agent-type definition rather than
180
+ per-dispatch habit, and why an omitted `model:` field there is not a neutral
181
+ default but the inherit default: the field is stated even when the answer is
182
+ to inherit.
118
183
  - **Never revert substantial completed work on your own design judgment** —
119
184
  especially an expensive delegated sweep. Surface the tension and wait for the
120
185
  explicit go-ahead before discarding it: a self-judged revert forfeits the
@@ -346,8 +346,9 @@ Every registered gate's header carries a one-line coupling manifest:
346
346
 
347
347
  - `couples=` — the surfaces the gate binds (comma-separated globs). One token
348
348
  is special: `kit:<glob>`, which the shared manifest reader in `lib/gate.sh`
349
- (`gate_expand_couples`) expands to `<kit-root>/<glob>` — repo-root-relative —
350
- for every `gate_kit_roots` member at read time; the same reader feeds
349
+ (`gate_expand_couples_var`) expands to `<kit-root>/<glob>` —
350
+ repo-root-relative — for every `gate_kit_roots` member at read time; the same
351
+ reader feeds
351
352
  `gen-pre-commit` (hook emission), `check-graph` (freshness + the HTML
352
353
  projection), and `run-gates --for` (path-scoped selection §run-gates), so
353
354
  emitter, checker, and selector cannot desync on the kit set. A
@@ -659,7 +660,7 @@ contract); the runner captures it.
659
660
  `run-gates.sh --for <path> [<path>...]` is the path-scoped selector, the
660
661
  agent-callable half of the oracle-first rule: it resolves the registry exactly
661
662
  as a bare run, then runs only the members whose *effective trigger* (`trigger=`
662
- else `couples=`, expanded through `gate_expand_couples`) glob-matches at least
663
+ else `couples=`, expanded through `gate_expand_couples_var`) glob-matches at least
663
664
  one given repo-relative path. Registry order and per-gate output are unchanged;
664
665
  a bare `run-gates.sh` keeps its behavior. The loop this buys — edit → run
665
666
  coupled gates → read the verdict+help — is strictly cheaper than reading gate
@@ -672,7 +673,7 @@ staged-path matching**: the glob step is `gate_staged_matches` in `lib/gate.sh`,
672
673
  whose body `gen-pre-commit` emits verbatim as the hook's `staged_matches` (the
673
674
  self-contained hook and the selector share one source, held in sync by
674
675
  check-graph's freshness assertion §check-graph), and both draw the `# graph:`
675
- fields through `gate_manifest_field` + `gate_expand_couples` — the single reader
676
+ fields through `gate_manifest_field` + `gate_expand_couples_var` — the single reader
676
677
  §The `# graph:` manifest names. Two hook behaviors the selector reproduces
677
678
  beyond that matcher: a `trigger=*` gate is selected for every path, and a
678
679
  `mode=staged` gate — whose hook branch matches by git pathspec (exact path or
@@ -867,7 +868,7 @@ failure report as before) or when `GATE_SDK_VERBOSE` is set, and a fully green
867
868
  hook run prints one summary line carrying its executed-invocation count. The
868
869
  wrapper lives in the emitter's heredoc, so the freshness assertion carries any
869
870
  change into the committed hooks. A `trigger=`/`couples=` `kit:<glob>` token is emitted *expanded*
870
- (via `gate_expand_couples`), so adding a kit later reddens `check-graph`
871
+ (via `gate_expand_couples_var`), so adding a kit later reddens `check-graph`
871
872
  (committed hook ≠ `--emit`) until regeneration — the freshness gate keeps the
872
873
  static hooks honest across a kit-set change.
873
874
 
@@ -69,7 +69,7 @@ emit_block() {
69
69
  local gate="$1" couples trigger mode gen relpath
70
70
  couples="$(manifest_field "$gate" couples)"
71
71
  trigger="$(manifest_field "$gate" trigger)"; trigger="${trigger:-$couples}"
72
- trigger="$(gate_expand_couples "$trigger")"
72
+ gate_expand_couples_var trigger "$trigger"
73
73
  mode="$(manifest_field "$gate" mode)"
74
74
  gen="$(manifest_field "$gate" gen)"
75
75
  relpath="$(resolve_rel "$gate")" || relpath="$GATES_DIR/$gate.sh"
@@ -60,7 +60,7 @@ select_for() {
60
60
  }
61
61
  couples="$(gate_manifest_field "$src" couples)"
62
62
  trigger="$(gate_manifest_field "$src" trigger)"; trigger="${trigger:-$couples}"
63
- trigger="$(gate_expand_couples "$trigger")"
63
+ gate_expand_couples_var trigger "$trigger"
64
64
  mode="$(gate_manifest_field "$src" mode)"
65
65
  IFS=',' read -ra globs <<<"$trigger"
66
66
  if [[ "$trigger" == '*' ]]; then
@@ -112,7 +112,7 @@ emit_graph() {
112
112
  valve=*) valve="${kv#valve=}" ;;
113
113
  esac
114
114
  done
115
- couples="$(gate_expand_couples "$couples")"
115
+ gate_expand_couples_var couples "$couples"
116
116
  C_COUPLES[$c]="$couples"; C_DIR[$c]="$dir"; C_VALVE[$c]="$valve"
117
117
  local -a csurf; IFS=',' read -ra csurf <<<"$couples"
118
118
  for s in "${csurf[@]}"; do NODE_SEEN[$s]=1; done
@@ -517,8 +517,8 @@ for c in "${CHECKS[@]}"; do
517
517
  *) errors+=("MANIFEST: $script unknown manifest key '$kv'") ;;
518
518
  esac
519
519
  done
520
- couples="$(gate_expand_couples "$couples")"
521
- [[ -n "$trigger" ]] && trigger="$(gate_expand_couples "$trigger")"
520
+ gate_expand_couples_var couples "$couples"
521
+ [[ -n "$trigger" ]] && gate_expand_couples_var trigger "$trigger"
522
522
  [[ "$dir" == bi || "$dir" == one ]] || errors+=("MANIFEST: $script dir= must be bi|one (got '$dir')")
523
523
  [[ "$valve" == none || "$valve" == PROPOSED ]] || errors+=("MANIFEST: $script valve= must be none|PROPOSED (got '$valve')")
524
524
  [[ "$tier" == precommit || "$tier" == align-only || "$tier" == commit-msg ]] || errors+=("MANIFEST: $script tier= must be precommit|align-only|commit-msg (got '$tier')")
@@ -102,7 +102,9 @@ findings=()
102
102
 
103
103
  for src in "${sources[@]+"${sources[@]}"}"; do
104
104
  [[ -f "$src" ]] || continue
105
- couples="$(gate_expand_couples "$(gate_manifest_field "$src" couples)")"
105
+ couples=""
106
+ couples_field="$(gate_manifest_field "$src" couples)"
107
+ gate_expand_couples_var couples "$couples_field"
106
108
  IFS=',' read -ra COUPLE_GLOBS <<<"$couples"
107
109
  walks="$(extract_walks "$src")"; st=$?
108
110
  fail_closed "$st" READS-COUPLES "awk walk-scan($src)"
@@ -34,20 +34,24 @@ fi
34
34
  listing="$(git ls-files -- "$SCANROOT")"; st=$?
35
35
  fail_closed "$st" TREE-TERMS git-ls-files
36
36
 
37
- patfile="$(printf '%s\n' "$patterns")"
38
- hits=""
39
- scanned=0
37
+ # spec: gate-sdk/SPEC.md §check-tree-terms — the filter pass (pruned dirs, the pattern-file's own basename, non-regular files) stays a per-path loop with no fork in it; the grep itself batches every surviving path into one process instead of re-materialising the pattern file and re-execing grep per file
38
+ paths=()
40
39
  while IFS= read -r path; do
41
40
  [[ -n "$path" ]] || continue
42
41
  gate_path_pruned "$path" && continue
43
42
  base="${path##*/}"
44
43
  [[ "$base" == msg-patterns* ]] && continue
45
44
  [[ -f "$path" ]] || continue
46
- scanned=$((scanned + 1))
47
- m="$(grep -EnHf <(printf '%s\n' "$patfile") "$path")"; mst=$?
48
- [[ "$mst" -le 1 ]] || fail_closed "$mst" TREE-TERMS grep
49
- [[ -n "$m" ]] && hits+="$m"$'\n'
45
+ paths+=("$path")
50
46
  done <<< "$listing"
47
+ scanned="${#paths[@]}"
48
+
49
+ hits=""
50
+ if [[ "$scanned" -gt 0 ]]; then
51
+ m="$(grep -EnHf <(printf '%s\n' "$patterns") "${paths[@]}")"; mst=$?
52
+ [[ "$mst" -le 1 ]] || fail_closed "$mst" TREE-TERMS grep
53
+ [[ -n "$m" ]] && hits="$m"$'\n'
54
+ fi
51
55
 
52
56
  if [[ -n "$hits" ]]; then
53
57
  echo "check-tree-terms: tracked file(s) match a banned pattern (leaked local/private term):"
@@ -122,39 +122,55 @@ gate_fixture_suites() {
122
122
  done
123
123
  }
124
124
 
125
- # spec: gate-sdk/SPEC.md §lib/gate.sh — gate_kit_roots as repo-root-relative dirs (the anchor the couples globs share); absolute roots resolve against the kits' parent, relative roots (a GATE_SDK_KIT_DIRS override) pass through
126
- gate_kit_roots_rel() {
125
+ # spec: gate-sdk/SPEC.md §lib/gate.sh — the gate_kit_roots_rel cache-fill, split out so an in-process caller (gate_expand_couples) can prime the shared _gate_kit_roots_rel_cache array and read it directly, with no stdout round-trip / process-substitution fork of its own. The kit-root set cannot change mid-process, so a cold-cache fill (the realpath-per-root fork cost) happens at most once per gate invocation.
126
+ _gate_kit_roots_rel_ensure_cache() {
127
+ [[ -n "${_gate_kit_roots_rel_cache_set:-}" ]] && return 0
127
128
  local anchor root
128
129
  anchor="${GATE_SDK_ROOT:-$(gate_sdk_root)}"; anchor="${anchor%/*}"
130
+ _gate_kit_roots_rel_cache=()
129
131
  while IFS= read -r root; do
130
132
  if [[ "$root" == /* ]]; then
131
- realpath --relative-to="$anchor" "$root" 2>/dev/null || printf '%s\n' "$root"
132
- else
133
- printf '%s\n' "$root"
133
+ root="$(realpath --relative-to="$anchor" "$root" 2>/dev/null || printf '%s' "$root")"
134
134
  fi
135
+ _gate_kit_roots_rel_cache+=("$root")
135
136
  done < <(gate_kit_roots)
137
+ _gate_kit_roots_rel_cache_set=1
136
138
  }
137
139
 
138
- # spec: gate-sdk/SPEC.md §check-graph — expand each kit:<glob> token in a comma-joined couples/trigger field to <kit-root>/<glob> for every gate_kit_roots_rel member; non-kit tokens pass through verbatim. The single reader gen-pre-commit, check-graph, and the hook share, so emitter and checker cannot desync.
139
- gate_expand_couples() {
140
- local field="$1"
141
- local -a roots=() parts=() out=()
142
- mapfile -t roots < <(gate_kit_roots_rel)
140
+ # spec: gate-sdk/SPEC.md §lib/gate.sh — gate_kit_roots as repo-root-relative dirs (the anchor the couples globs share); absolute roots resolve against the kits' parent, relative roots (a GATE_SDK_KIT_DIRS override) pass through
141
+ gate_kit_roots_rel() {
142
+ _gate_kit_roots_rel_ensure_cache
143
+ printf '%s\n' "${_gate_kit_roots_rel_cache[@]}"
144
+ }
145
+
146
+ # spec: gate-sdk/SPEC.md §check-graph — expand each kit:<glob> token in a comma-joined couples/trigger field to <kit-root>/<glob> for every gate_kit_roots_rel member; non-kit tokens pass through verbatim. Assigns into the caller's <outvar> by nameref rather than printing, so a per-manifest-line loop calls this directly (no `$(...)` fork) and the whole loop shares one _gate_kit_roots_rel_ensure_cache fill instead of paying it — and forking — once per line. gate_expand_couples below is the same expansion for a caller that still wants the stdout form.
147
+ gate_expand_couples_var() {
148
+ local -n _gate_expand_couples_out="$1"
149
+ local field="$2"
150
+ local -a parts=() out=()
151
+ _gate_kit_roots_rel_ensure_cache
143
152
  IFS=',' read -ra parts <<<"$field"
144
153
  local tok r glob
145
154
  for tok in "${parts[@]}"; do
146
155
  if [[ "$tok" == kit:* ]]; then
147
156
  glob="${tok#kit:}"
148
- for r in "${roots[@]}"; do out+=("${r%/}/$glob"); done
157
+ for r in "${_gate_kit_roots_rel_cache[@]}"; do out+=("${r%/}/$glob"); done
149
158
  else
150
159
  out+=("$tok")
151
160
  fi
152
161
  done
153
162
  local IFS=','
154
- printf '%s\n' "${out[*]}"
163
+ _gate_expand_couples_out="${out[*]}"
164
+ }
165
+
166
+ # spec: gate-sdk/SPEC.md §check-graph — the gate_expand_couples_var expansion, printed to stdout for a `$(...)` caller; gate_expand_couples_var is the in-process form a hot per-line loop should call instead.
167
+ gate_expand_couples() {
168
+ local __gate_expand_couples_result
169
+ gate_expand_couples_var __gate_expand_couples_result "$1"
170
+ printf '%s\n' "$__gate_expand_couples_result"
155
171
  }
156
172
 
157
- # spec: gate-sdk/SPEC.md §The `# graph:` manifest — read one field from a resolved gate's `# graph:` line; the shared field reader gen-pre-commit and run-gates --for selection draw the manifest through (the couples-token expansion stays gate_expand_couples, the reader check-graph also shares). Emits the value, empty when the field is absent; never fails on a missing field.
173
+ # spec: gate-sdk/SPEC.md §The `# graph:` manifest — read one field from a resolved gate's `# graph:` line; the shared field reader gen-pre-commit and run-gates --for selection draw the manifest through (the couples-token expansion is gate_expand_couples_var, the reader check-graph also shares). Emits the value, empty when the field is absent; never fails on a missing field.
158
174
  gate_manifest_field() {
159
175
  local src="$1" key="$2" man kv
160
176
  man="$(grep -m1 '^# graph: ' "$src" 2>/dev/null || true)"
@@ -1468,8 +1468,10 @@ resume journal, escalations to the message channel), the compact economics —
1468
1468
  the split-where-the-tail-dominates rule, the unified posture's handoff compact,
1469
1469
  and operator-suggested compacts at the acceptance
1470
1470
  boundaries that pay under the cold-wakes-times-compressible-residue rule —
1471
- with the dispatch-granularity rule (batch units sharing a kit or SPEC
1472
- surface, split on a model-tier change or a delegation-kit split trigger) and
1471
+ with the dispatch-granularity rule (the roster derived from every unit the
1472
+ iteration promoted rather than from the amendment set, then batch units
1473
+ sharing a kit or SPEC surface, split on a model-tier change or a
1474
+ delegation-kit split trigger) and
1473
1475
  the lead-owns-batching clause (an intra-stage batch split is N sibling stage
1474
1476
  sessions the lead dispatches and validates — each a same-stage re-entry,
1475
1477
  §The state machine — and a stage session never dispatches a sibling stage
@@ -1478,9 +1480,17 @@ the stamps-authoritative invariant carried from §The state machine as the
1478
1480
  design's load-bearing rule — with its two corollaries: the lead never
1479
1481
  hand-derives prior-stage completeness from WORKFLOW-STATE or the git log (it
1480
1482
  dispatches and trusts `enter-stage.sh`'s fail-closed refusal, or gates an
1481
- expensive dispatch with `--simulate`, §bin/enter-stage.sh), and a ruling
1483
+ expensive dispatch with `--simulate`, and reads that same drain-entry verdict
1484
+ **before** declaring a stage's batches complete rather than after,
1485
+ §bin/enter-stage.sh), and a ruling
1482
1486
  whose acting session is not imminent is filed to a durable governed surface
1483
- in the moment it is made. The template also carries the lead's first step —
1487
+ in the moment it is made. An earlier second assertion over the drain
1488
+ assertion's own population is **ruled out** on record: a batching roster has
1489
+ dropped a promoted unit in practice and `check-stage-entry` named
1490
+ it at the refused entry, so the defect is detected late — at the price of one
1491
+ wasted dispatch — rather than undetected, and a duplicate reading of one fact
1492
+ would buy only the timing the simulate read already buys for free.
1493
+ The template also carries the lead's first step —
1484
1494
  writing the session-role marker context-kit's hook reads
1485
1495
  (context-kit/SPEC.md §The session-context hook). Dispatch safety is not re-owned — it inherits
1486
1496
  delegation-kit's protocol by citation (delegation-kit/SPEC.md §The delegation
@@ -132,11 +132,18 @@ goes to the operator, never substituted by the lead's own judgment.
132
132
  ## Channel design
133
133
 
134
134
  Two channels, each with one job. Routine narration and findings go to the
135
- **resume journal** (a pull channel — delegation-kit's journal mechanics apply
136
- unchanged). The **message channel** carries only the escalation classes. This
135
+ **resume journal** (a pull channel — delegation-kit's journal mechanics own
136
+ the rest). The **message channel** carries only the escalation classes. This
137
137
  is how verbosity is controlled: by channel design, not by asking a session to
138
138
  be quiet.
139
139
 
140
+ A pull channel is read, never consumed: the lead **does not delete** a stage
141
+ session's journal, at the post-commit checkpoint or anywhere else. A resumable
142
+ session is still writing to it, and deleting it is how a lead destroys the
143
+ channel it is meant to keep reading for the rest of the unit. It is swept with
144
+ the rest of the scratch dir at the iteration boundary
145
+ (delegation-kit/SPEC.md §Resume journal — agent writes, scratch reset sweeps).
146
+
140
147
  ## Policy is config, not prose
141
148
 
142
149
  All *standing* dispatch policy — everything true of every dispatch, not the
@@ -187,6 +194,15 @@ consequences:
187
194
  context is actually common; split where the model tier changes or a
188
195
  delegation-kit split trigger fires — per-batch model tiering is the dominant
189
196
  window lever, not token counts.
197
+ The set being batched is **every unit the iteration promoted** — every
198
+ top-level entry in the configured active queue sections, debt units as much as
199
+ feature units — never the amendment set. A debt unit converges an
200
+ implementation on existing spec and mints no governed name, so it carries no
201
+ `[spec:]` ref; keying the roster on amendments makes exactly the
202
+ amendment-free half of the queue invisible, and it disappears silently because
203
+ the units that vanish are the ones that left no artifact to miss. Derive the
204
+ roster from the queue, which is the record of what was promoted, and re-read
205
+ it rather than carrying a count.
190
206
  - **Tier each batch to its work class.** The lead reads the **work-class**
191
207
  labels of the deltas in a batch — via the `[spec:]` amendments the batch's
192
208
  entries point at, where `/spec` emits one `{mechanical | design-bearing}` tag
@@ -258,7 +274,7 @@ Cache-keepalive pinging is ruled out: at batched escalation rates the idle
258
274
  re-warm pings cost more than the cold reads they avoid, burn the shared budget
259
275
  window, and invite idle-turn drift.
260
276
 
261
- ## Mechanical floor — the escalation-shape guard
277
+ ## Mechanical floor
262
278
 
263
279
  Prompts request; guards enforce. The four-header escalation shape has an
264
280
  optional guard-kit mechanical floor — a SendMessage guard registered in the
@@ -269,3 +285,22 @@ kit mechanism; the ruling-class roster stays consumer config (above).
269
285
  *<escalation-guard: whether this consumer wires the optional guard-kit
270
286
  SendMessage guard for its stage sessions, or leaves it inert — the mechanical
271
287
  floor and where its opt-in lives.>*
288
+
289
+ The floor under the batching-roster rule is `check-stage-entry`'s drain-entry
290
+ assertion: the drain stage refuses to be entered while the active queue still
291
+ carries entries, so a dropped unit surfaces as a **refused entry** at the next
292
+ stage rather than never. That is a backstop, not the working signal — it costs
293
+ a dispatch to learn from. Read it early and cheaply instead: the `--simulate`
294
+ read §The lead model already names for gating an expensive dispatch, aimed at
295
+ the drain stage, returns the same verdict with no session spent. Run it
296
+ **before** declaring a stage's batches complete, not after — a simulate run
297
+ that follows the declaration confirms the drop instead of preventing it, and a
298
+ roster has already lost a promoted unit in practice. Keying the roster on the
299
+ wrong set is only one way to lose a unit: a plain miscount against the queue
300
+ loses one just as quietly, and neither failure reddens on its own. That is why
301
+ the rule is to re-read the queue rather than to key it differently.
302
+
303
+ The floor's honest limit belongs with it: it fires on the queue's *residue*, so
304
+ it catches a dropped unit and says nothing about a unit batched onto the wrong
305
+ surface or tiered wrongly. Those stay prompt-side — the ordinary
306
+ prompts-request/guards-enforce split rather than a gap.
@@ -20,9 +20,10 @@ absent; the dependency joins a consumer's toolchain only when the gate is
20
20
  registered.
21
21
 
22
22
  The template — `templates/site-health.yml` — is a scheduled probe of the live
23
- site (apex/www/http HTTPS, redirects, certificate expiry). It verifies a
24
- *deployment*, not a tree, so it ships as a workflow a consumer copies, never a
25
- gate: a monitor reds on causes no commit produced. See [SPEC.md](SPEC.md#the-monitor-boundary)
23
+ site (apex/www/http HTTPS, redirects, certificate expiry, and release-body note
24
+ pointers). It verifies a *deployment*, not a tree, so it ships as a workflow a
25
+ consumer copies, never a gate: the line is where the asserted object lives, and
26
+ none of what it asserts is in any checkout. See [SPEC.md](SPEC.md#the-monitor-boundary)
26
27
  for why that boundary is load-bearing.
27
28
 
28
29
  ## Install
@@ -51,8 +52,14 @@ Vendor the kit beside [gate-sdk](../gate-sdk/) (required), then:
51
52
  unset the gate holds on defaults and finds nothing.
52
53
 
53
54
  4. Optional live monitor — copy `templates/site-health.yml` verbatim into
54
- `.github/workflows/`, set its `ALT_DOMAIN` (or drop the alternate-host probe),
55
- and it opens/updates/closes a `site-health` issue on its own schedule.
55
+ `.github/workflows/`, then set two groups of step env or delete the arm each
56
+ belongs to: `ALT_DOMAIN` (drop the alternate-host probe if you serve no
57
+ redirect alias), and `RELEASE_NOTE_GLOB` / `RELEASE_NOTE_TAG_KEY` /
58
+ `RELEASE_NOTE_URL_PATH` (drop the release-body arm if you publish no release
59
+ notes). It opens/updates/closes a `site-health` issue on its own schedule.
60
+ The release-body arm needs the template's `contents: read` permission — it is
61
+ an allowlist, not an addition — and `RELEASE_NOTE_URL_PATH` is the value worth
62
+ checking twice: site-kit/SPEC.md §templates/site-health.yml names the trap.
56
63
 
57
64
  ## Test
58
65