@bookedsolid/rea 0.30.0 → 0.31.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.
@@ -109,56 +109,127 @@ export declare function checksFromProbeState(state: CodexProbeState): CheckResul
109
109
  * `.claude/settings.json` under PreToolUse with matcher `Agent|Skill`
110
110
  * AND that the hook file exists at the expected dogfood path.
111
111
  *
112
- * Status posture for 0.29.0:
113
- *
114
- * The 0.29.0 release introduces a new desired-hook entry in
115
- * `defaultDesiredHooks()` that `rea init` and `rea upgrade` will merge
116
- * into consumer `.claude/settings.json` files. Existing consumer
117
- * installs (and this repo's own dogfood, which is locked from
118
- * agent-driven edits by `settings-protection.sh`) won't have the
119
- * matcher registered until the operator runs `rea upgrade`.
120
- *
121
- * To keep the upgrade-lag period from breaking `rea doctor`, the
122
- * check is `warn` (not `fail`) for 0.29.0. The detail message names
123
- * the exact command to fix and points at the canonical
124
- * `delegation-capture.sh` install. After 0.29.0+1 consumer-install
125
- * cycles have propagated, this should be promoted to `fail` so a
126
- * skipped upgrade is loud rather than silent. Codex round 2 P2
127
- * (2026-05-12).
112
+ * Status posture:
113
+ *
114
+ * 0.29.0 shipped this check as `warn` (advisory) — the
115
+ * `defaultDesiredHooks()` entry was new, and existing consumer
116
+ * installs (plus this repo's own dogfood, locked from agent-driven
117
+ * edits by `settings-protection.sh`) wouldn't have the matcher
118
+ * registered until the operator ran `rea upgrade`. The comments
119
+ * promised promotion to `fail` "in 0.30.0".
120
+ *
121
+ * **0.31.0 makes good on that promise.** The 0.29.0 0.30.x consumer
122
+ * cycles have propagated; the `Agent|Skill` matcher has been in
123
+ * `defaultDesiredHooks()` for multiple minors. A consumer install
124
+ * that still lacks the registration is a real governance gap (the
125
+ * delegation telemetry and now the 0.31.0 nudge silently does
126
+ * nothing), so the check is `fail`. The detail message still names
127
+ * the exact `rea upgrade` fix.
128
128
  *
129
129
  * Hook-file presence is verified separately by `checkHooksInstalled`
130
- * via `EXPECTED_HOOKS` — that path stays at the hard-`fail` posture
131
- * because file presence is part of the install manifest and doesn't
132
- * suffer the same template-propagation lag.
130
+ * via `EXPECTED_HOOKS` — that path was always hard-`fail`.
133
131
  */
134
132
  export declare function checkDelegationHookRegistered(baseDir: string): CheckResult;
133
+ /**
134
+ * 0.31.0 — verify the delegation-advisory hook is registered in
135
+ * `.claude/settings.json` under PostToolUse with matcher
136
+ * `Bash|Edit|Write|MultiEdit|NotebookEdit`, that a
137
+ * `delegation-advisory.sh` command is present in that group, AND that
138
+ * the `.claude/hooks/delegation-advisory.sh` file actually exists.
139
+ *
140
+ * Status posture: `warn` (advisory) for 0.31.0. This is a brand-new
141
+ * `defaultDesiredHooks()` entry — the exact same upgrade-lag situation
142
+ * `checkDelegationHookRegistered` faced in 0.29.0. Existing consumer
143
+ * installs (and this repo's own dogfood, locked from agent-driven
144
+ * edits by `settings-protection.sh`) won't have the PostToolUse group
145
+ * until the operator runs `rea upgrade`. Holding at `warn` for one
146
+ * release cycle keeps `rea doctor` green during propagation; a future
147
+ * minor promotes it to `fail` once consumer installs have caught up —
148
+ * the same ratchet `checkDelegationHookRegistered` just completed.
149
+ *
150
+ * The hook is ALSO advisory at runtime (it never blocks a tool call,
151
+ * and `policy.delegation_advisory` defaults to disabled), so a missing
152
+ * registration is a lower-stakes gap than a missing security gate —
153
+ * `warn` is proportionate even setting the upgrade-lag aside.
154
+ *
155
+ * # Why this check verifies file presence AND executability (round-2/3 P2)
156
+ *
157
+ * `delegation-advisory.sh` is deliberately NOT in `EXPECTED_HOOKS` for
158
+ * 0.31.0 (staged rollout — see the `EXPECTED_HOOKS` comment). That
159
+ * leaves THIS function as the only 0.31.0 doctor signal covering the
160
+ * new hook, so it must check the file too:
161
+ *
162
+ * - File MISSING — a settings.json that references
163
+ * `delegation-advisory.sh` while the actual script is absent (a
164
+ * partial `rea upgrade`, manual drift) would otherwise report
165
+ * `pass`, and every matching PostToolUse dispatch would shell out
166
+ * to a nonexistent path.
167
+ * - File present but NOT EXECUTABLE — a script copied without its
168
+ * mode bits (a manual `cp`, an archive extracted without `+x`
169
+ * preservation) cannot be launched by Claude Code from
170
+ * `settings.json` at all. `checkHooksInstalled` performs this exact
171
+ * `0o111` check for every `EXPECTED_HOOKS` entry; because
172
+ * `delegation-advisory.sh` is held out of that list, the parity
173
+ * check has to live here.
174
+ *
175
+ * Both failures are held at the same `warn` tier as the registration
176
+ * failures: consistent posture for 0.31.0, and they promote to `fail`
177
+ * alongside them — at which point `delegation-advisory.sh` also joins
178
+ * `EXPECTED_HOOKS` and gets the hard-`fail` `checkHooksInstalled`
179
+ * coverage (presence + executability) the other hooks have.
180
+ */
181
+ export declare function checkDelegationAdvisoryHookRegistered(baseDir: string): CheckResult;
135
182
  /**
136
183
  * 0.29.0 — synthetic round-trip of the delegation-signal audit path.
137
- * Drives a synthetic Claude Code PreToolUse hook payload through the
138
- * REAL `rea hook delegation-signal` CLI by spawning a child process
139
- * (same path the shell hook hits) and asserts:
184
+ * 0.31.0 drives the REAL `.claude/hooks/delegation-capture.sh` shell
185
+ * hook, not just the `rea hook delegation-signal` CLI underneath it.
140
186
  *
141
- * - The CLI exited 0.
142
- * - A new `rea.delegation_signal` record landed on disk.
187
+ * Feeds a synthetic Claude Code PreToolUse hook payload to the shell
188
+ * hook (the exact entry point Claude Code's `Agent|Skill` matcher
189
+ * invokes in production) and asserts:
190
+ *
191
+ * - The shell hook exited 0.
192
+ * - A new `rea.delegation_signal` record landed on disk — the smoke
193
+ * check POLLS for it, because `delegation-capture.sh` backgrounds
194
+ * + disowns the CLI (`& disown`) so the shell hook returns before
195
+ * the audit append completes.
143
196
  * - The record's metadata contains the probe tag (so we don't
144
197
  * mistakenly attribute an existing record to our run).
198
+ * - The recorded `invocation_description_sha256` matches the
199
+ * expected hash of the probe description.
145
200
  * - Chain integrity holds (recomputed hash == stored hash).
146
201
  *
147
- * Codex round 1 P2 (2026-05-12): the previous implementation called
148
- * `appendAuditRecord()` directly — short-circuiting stdin parsing,
149
- * SHA-256 hashing, redact-secrets timing, and the `process.exit`
150
- * ordering that round 1's P1 exposed. That made the smoke check
151
- * report success even when the real production path was broken.
152
- *
153
- * This rewrite exercises the same surface the `Agent|Skill`
154
- * PreToolUse hook does in production, so future regressions in
155
- * stdin parsing, hashing, redaction, or process-lifecycle behavior
156
- * fail the smoke check loudly.
157
- *
158
- * Gated behind `--smoke` so a casual `rea doctor` doesn't write
159
- * probe records on every invocation. Operators run
160
- * `rea doctor --smoke` after install / upgrade to confirm the
161
- * pipeline is wired end-to-end.
202
+ * # Why drive the shell hook, not the CLI directly
203
+ *
204
+ * 0.29.0's version spawned `rea hook delegation-signal` directly. That
205
+ * exercised the CLI's stdin parsing / hashing / redaction / process-
206
+ * lifecycle but NOT the shell shim's own logic: the 2-tier sandboxed
207
+ * CLI resolution, the realpath sandbox check, the `& disown`
208
+ * backgrounding. A regression in the shim (a botched resolution order,
209
+ * a sandbox check that rejects the legitimate dogfood CLI, a
210
+ * backgrounding bug that drops the signal) would pass 0.29.0's smoke
211
+ * check while breaking production. 0.31.0 closes that gap: the smoke
212
+ * check now invokes `bash .claude/hooks/delegation-capture.sh` and
213
+ * the CLI is reached only through the shim.
214
+ *
215
+ * # Prerequisites and graceful degradation
216
+ *
217
+ * The check needs THREE things and degrades to `warn` (not `fail`)
218
+ * when any is absent — a missing prerequisite is an environment gap,
219
+ * not a wiring regression:
220
+ *
221
+ * - `bash` on PATH.
222
+ * - `.claude/hooks/delegation-capture.sh` present (the consumer
223
+ * install path; absent before `rea init` / `rea upgrade`).
224
+ * - A sandboxed rea CLI the shim can resolve — either
225
+ * `<baseDir>/node_modules/@bookedsolid/rea/dist/cli/index.js` OR
226
+ * `<baseDir>/dist/cli/index.js` (the rea-repo dogfood). Without
227
+ * one the shim silently drops the signal by design, so the smoke
228
+ * check would time out waiting for a record that will never land.
229
+ *
230
+ * Gated behind `--smoke` so a casual `rea doctor` doesn't write probe
231
+ * records on every invocation. Operators run `rea doctor --smoke`
232
+ * after install / upgrade to confirm the pipeline is wired end-to-end.
162
233
  */
163
234
  export declare function checkDelegationRoundTrip(baseDir: string): Promise<CheckResult>;
164
235
  /**