checkwright 0.24.0 → 0.25.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.
- package/README.md +3 -3
- package/package.json +2 -2
- package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
- package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
- package/payload/canon-kit/README.md +2 -0
- package/payload/canon-kit/SPEC.md +329 -15
- package/payload/canon-kit/checks/check-amendment-update-target.gate +3 -0
- package/payload/canon-kit/checks/check-unmarked-claim.gate +3 -0
- package/payload/canon-kit/gate-tests/check-amendment-update-target/bad/SPEC-thing.md +26 -0
- package/payload/canon-kit/gate-tests/check-amendment-update-target/bad/expect.txt +8 -0
- package/payload/canon-kit/gate-tests/check-amendment-update-target/good/SPEC-widget.md +47 -0
- package/payload/canon-kit/gate-tests/check-amendment-update-target/good/expect.txt +1 -0
- package/payload/canon-kit/gate-tests/check-amendment-update-target.test.sh +82 -0
- package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/SPEC.md +11 -0
- package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/expect.txt +3 -0
- package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/scripts/canon-config.sh +6 -0
- package/payload/canon-kit/gate-tests/check-unmarked-claim/good/SPEC.md +18 -0
- package/payload/canon-kit/gate-tests/check-unmarked-claim/good/expect.txt +1 -0
- package/payload/canon-kit/gate-tests/check-unmarked-claim/good/scripts/canon-config.sh +6 -0
- package/payload/canon-kit/gate-tests/check-unmarked-claim.test.sh +85 -0
- package/payload/canon-kit/lib/spec.sh +16 -0
- package/payload/canon-kit/smoke/install.sh +2 -0
- package/payload/canon-kit/templates/SPEC-amendment.md +17 -2
- package/payload/context-kit/SPEC.md +16 -5
- package/payload/delegation-kit/README.md +11 -1
- package/payload/delegation-kit/SPEC.md +392 -26
- package/payload/delegation-kit/bin/wait-probe.sh +184 -0
- package/payload/delegation-kit/gate-tests/subagent-stop-liveness.test.sh +99 -0
- package/payload/delegation-kit/smoke/install.sh +20 -0
- package/payload/delegation-kit/templates/agent-execution.md +26 -9
- package/payload/delegation-kit/templates/subagent-stop-liveness.sh +56 -0
- package/payload/gate-sdk/README.md +7 -2
- package/payload/gate-sdk/SPEC.md +800 -66
- package/payload/gate-sdk/bin/build-native.sh +66 -1
- package/payload/gate-sdk/bin/run-gates.sh +136 -34
- package/payload/gate-sdk/checks/check-action-run-shell.sh +1 -1
- package/payload/gate-sdk/checks/check-gate-assertions.gate +3 -0
- package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +55 -2
- package/payload/gate-sdk/checks/check-tree-terms.gate +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/expect.txt +5 -1
- package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/SPEC.md +22 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-count.sh +11 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-extra.sh +14 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-zero.sh +7 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions/good/expect.txt +1 -1
- package/payload/gate-sdk/gate-tests/check-gate-assertions/good/scripts/SPEC.md +27 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions/good/scripts/check-qux.sh +13 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions.test.sh +117 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kit-spec.md +6 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-nospec.sh +4 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-ungrounded.sh +5 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +1 -1
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kit-spec.md +12 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-held.sh +1 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/expect.txt +5 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/tree/multi.txt +4 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/tree/second-leak.txt +2 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/expect.txt +1 -1
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/patterns.list +3 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/anchored.txt +4 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/msg-patterns.list +2 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/msg-patterns.local.list +3 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/worktrees/vendored-note.txt +3 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms.test.sh +94 -0
- package/payload/gate-sdk/smoke/install.sh +23 -0
- package/payload/guard-kit/README.md +4 -3
- package/payload/guard-kit/SPEC.md +409 -57
- package/payload/guard-kit/bin/compare-settings-allow.sh +36 -12
- package/payload/guard-kit/bin/run-guard-tests.sh +22 -4
- package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +46 -1
- package/payload/guard-kit/guard-tests/background-cases.tsv +14 -0
- package/payload/guard-kit/guard-tests/cases.tsv +41 -11
- package/payload/guard-kit/lib/guard.sh +213 -34
- package/payload/guard-kit/templates/bash-guard.sh +2 -0
- package/payload/guard-kit/templates/close-triage.md +10 -3
- package/payload/guard-kit/templates/guard-config.sh +3 -0
- package/payload/lifecycle-kit/SPEC.md +2 -2
- package/payload/lifecycle-kit/templates/lead.md +8 -0
- package/payload/queue-kit/SPEC.md +78 -0
- package/payload/site-kit/SPEC.md +12 -0
- package/payload/gate-sdk/checks/check-gate-assertions.sh +0 -149
- package/payload/gate-sdk/checks/check-tree-terms.sh +0 -67
|
@@ -106,7 +106,17 @@ run the core command bare.
|
|
|
106
106
|
Primitives a consumer guard composes; each emits the harness's
|
|
107
107
|
`PreToolUse` hook protocol:
|
|
108
108
|
|
|
109
|
-
- `
|
|
109
|
+
- `guard_read_input` — read stdin **once** into the global `GUARD_INPUT`,
|
|
110
|
+
returning non-zero when stdin yielded nothing. Called **directly**, never in a
|
|
111
|
+
command substitution, and before the first field accessor. It exists because
|
|
112
|
+
the payload was otherwise unreadable past its first field: `guard_read_command`
|
|
113
|
+
is invoked as `cmd="$(guard_read_command)"`, so any cache it set died with the
|
|
114
|
+
substitution's subshell and stdin was already consumed — a rule needing a
|
|
115
|
+
second field could not get one.
|
|
116
|
+
- `guard_input_field <jq-path>` — the value at `<jq-path>` in `GUARD_INPUT`, or
|
|
117
|
+
nothing when `GUARD_INPUT` is unset or empty or the path is absent. The
|
|
118
|
+
accessor a rule reaching past the headline fields uses.
|
|
119
|
+
- `guard_read_command` — parse the hook JSON, emit the command;
|
|
110
120
|
**fail-open** on any parse problem (exit 0) so a guard can never wedge
|
|
111
121
|
the agent.
|
|
112
122
|
- `guard_read_path` — the same accessor for `.tool_input.file_path`, the field a
|
|
@@ -132,7 +142,7 @@ Primitives a consumer guard composes; each emits the harness's
|
|
|
132
142
|
the string matches a committed allow pattern, with the harness `:*` prefix
|
|
133
143
|
idiom (`Bash(printf:*)` ≡ any `printf …`) normalized to a trailing `*`. Not a
|
|
134
144
|
hook primitive — a shared helper, one implementation behind
|
|
135
|
-
compare-settings-allow's redundancy detection and rule
|
|
145
|
+
compare-settings-allow's redundancy detection and rule 19's silent-grant
|
|
136
146
|
guard so the two never drift.
|
|
137
147
|
- `guard_skeleton <cmd> <inert-class>…` — the context-aware normalizer, and the
|
|
138
148
|
only place a rule learns what part of a command is live. It returns the command
|
|
@@ -151,7 +161,7 @@ Primitives a consumer guard composes; each emits the harness's
|
|
|
151
161
|
- `guard_split_compound <skeleton>` — the compound splitter: emits one segment
|
|
152
162
|
per line, splitting on the harness's statement separators (`;`, `&&`, `||`,
|
|
153
163
|
`|`). Also not a hook primitive — the single implementation every consumer
|
|
154
|
-
that reasons *per segment* shares (rules 8/12/14/
|
|
164
|
+
that reasons *per segment* shares (rules 8/12/14/15/17/18/19/21, the read-compound
|
|
155
165
|
carve-out of rules 9/10, and scan-prompts' `allowed()`), so the harness's
|
|
156
166
|
per-segment matching surface is modelled in exactly one place and cannot drift
|
|
157
167
|
between them. Fed a `guard_skeleton` view, so a separator inside a quoted
|
|
@@ -185,12 +195,16 @@ stays live, which is the conservative direction. And the normalizer models **quo
|
|
|
185
195
|
shell semantics**: a construct that survives its scan and is not one of the three
|
|
186
196
|
classes is treated as live, the fail-toward-matching direction and the one a
|
|
187
197
|
guard should err in. That bound is why the command/process-substitution and
|
|
188
|
-
backtick tests in rules 9, 10, 11, 12, 13, 14,
|
|
189
|
-
rather than
|
|
198
|
+
backtick tests in rules 9, 10, 11, 12, 13, 14, 15, 17, 18 and 21 read the **raw**
|
|
199
|
+
command rather than
|
|
190
200
|
a skeleton and must keep doing so — a `"$(…)"` inside double quotes still
|
|
191
201
|
executes, so a rule that declared `dq` inert for *that* test would hand an
|
|
192
202
|
auto-allow to a command substitution it could not see. Those tests are
|
|
193
|
-
conservative declines, not verdict matching.
|
|
203
|
+
conservative declines, not verdict matching. **That roster is derived from the
|
|
204
|
+
rule bodies, not from memory**: it named rules that carry no raw test and
|
|
205
|
+
omitted rules that do until it was re-read against them, which is the same
|
|
206
|
+
drift the number-bearing cross-references below take and the reason each is
|
|
207
|
+
re-derived rather than carried.
|
|
194
208
|
|
|
195
209
|
**Rule 12 is the one rule that reaches its verdict off the raw command, and the
|
|
196
210
|
exception is forced rather than chosen.** Its predicate is *the pattern literal
|
|
@@ -198,19 +212,38 @@ exception is forced rather than chosen.** Its predicate is *the pattern literal
|
|
|
198
212
|
placeholder — the quoted operand is the normal spelling — so a skeleton view
|
|
199
213
|
would blind the rule to the only thing it tests. It pays for the exception in the
|
|
200
214
|
same conservative direction every other clause takes: it declines outright on any
|
|
201
|
-
expansion, substitution or backtick (rule 6 blocks
|
|
215
|
+
expansion, substitution or backtick (rule 6 blocks the expansion and substitution
|
|
216
|
+
shapes; the backtick decline is this rule's own arm, per the raw-command reading
|
|
217
|
+
above), and a
|
|
202
218
|
pattern operand carrying a stray quote — the evidence that the compound split
|
|
203
219
|
landed *inside* a quoted span — declines rather than guesses at the operand.
|
|
204
220
|
|
|
205
|
-
|
|
206
|
-
`
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
221
|
+
**`GUARD_INPUT` first, stdin otherwise, and the fallback is the whole point of
|
|
222
|
+
the shape.** `guard_read_command` and `guard_read_path` parse `GUARD_INPUT` when
|
|
223
|
+
it is set and non-empty and read stdin exactly as they always did otherwise, so
|
|
224
|
+
every consumer copy that never opted in keeps working byte-identically without an
|
|
225
|
+
edit — it never sets `GUARD_INPUT`, so both readers take the stdin path. A guard
|
|
226
|
+
that wants a second field opts in by adding one line, `guard_read_input || exit 0`
|
|
227
|
+
ahead of the first accessor, which is what the shipped template carries. Making
|
|
228
|
+
`guard_read_input` mandatory was refused: it would break every consumer copy on
|
|
229
|
+
upgrade for a field only one rule needs.
|
|
230
|
+
|
|
231
|
+
**What a `PreToolUse` payload actually carries, recorded so no session re-buys
|
|
232
|
+
the probe.** Top-level keys: `agent_id`, `agent_type`, `cwd`, `effort`,
|
|
233
|
+
`hook_event_name`, `permission_mode`, `prompt_id`, `session_id`, `tool_input`,
|
|
234
|
+
`tool_name`, `tool_use_id`, `transcript_path`. On a Bash call `tool_input` carries
|
|
235
|
+
`command`, `description`, and `run_in_background` — a JSON boolean `true` on a
|
|
236
|
+
backgrounded call, and **absent** on a foreground one. It is a fact about this
|
|
237
|
+
framework's own inputs, so without it each session re-establishes it from the
|
|
238
|
+
vendor hook reference.
|
|
239
|
+
|
|
240
|
+
**The live permission mode is in that payload and no rule reads it.**
|
|
241
|
+
`permission_mode` sits alongside the fields the accessors pick off, so a rule
|
|
242
|
+
whose rationale is mode-*conditional* — "no allowlist entry can suppress this
|
|
243
|
+
prompt" is false under an auto-approving mode and true under the others —
|
|
244
|
+
asserts a mode rather than reading one. Whether a guard *should* read the mode is
|
|
245
|
+
a consumer decision and is not settled here; the same holds for `agent_id`,
|
|
246
|
+
`agent_type` and `effort`, each of which belongs to a question of its own.
|
|
214
247
|
|
|
215
248
|
Fail-open is the default posture. The one sanctioned fail-closed shape is a
|
|
216
249
|
deny-guard whose hook *matcher* already proves the tool identity (see
|
|
@@ -255,7 +288,11 @@ guard-kit gains no dependency on a kit it does not otherwise know about
|
|
|
255
288
|
|
|
256
289
|
A consumer's project-specific block/steer/allow rules live in its copy of
|
|
257
290
|
`templates/bash-guard.sh`, composed from the `lib/guard.sh` primitives above and
|
|
258
|
-
placed **before** the generic ruleset — the template marks the position.
|
|
291
|
+
placed **before** the generic ruleset — the template marks the position. The
|
|
292
|
+
template's head reads the payload once (`guard_read_input || exit 0`) before the
|
|
293
|
+
first field accessor, which is what makes a rule reading a tool-input field
|
|
294
|
+
beyond the command reachable in a shipped guard rather than only in the tests; a
|
|
295
|
+
copy without that line still runs every rule, on the fallback above. Order
|
|
259
296
|
is the whole reason the seam sits here: a project rule that fires must fire
|
|
260
297
|
ahead of the generic rule it refines, or the generic verdict wins and the
|
|
261
298
|
project rule is dead code.
|
|
@@ -390,7 +427,7 @@ that harness exists would be designing against no case.
|
|
|
390
427
|
so `-e`/`-f` consume their argument and the first bare operand is the script
|
|
391
428
|
— a *second* bare operand is the file that fires the rule. **Placed before
|
|
392
429
|
both auto-allow rules:** a consumer that widens `GUARD_KIT_RO_BINS` with
|
|
393
|
-
`sed` would otherwise have rule
|
|
430
|
+
`sed` would otherwise have rule 18 silently grant an in-place rewrite.
|
|
394
431
|
9. **Listing-only `find`** — a bare `find` that only lists is blocked with
|
|
395
432
|
the steer to the harness's Glob tool (the same shape as rule 8's `sed`
|
|
396
433
|
read-steer: a better tool exists, and Glob returns paths registered for a
|
|
@@ -403,7 +440,7 @@ that harness exists would be designing against no case.
|
|
|
403
440
|
batch of independent listings, exactly what the Glob steer collapses into one
|
|
404
441
|
call. A literal `echo`/`printf` banner segment between them is the natural
|
|
405
442
|
separator of such a batch and is tolerated; at least one segment must be a
|
|
406
|
-
listing. A piped `find` is a legitimate producer (rule
|
|
443
|
+
listing. A piped `find` is a legitimate producer (rule 18 may still
|
|
407
444
|
auto-allow it), an action-predicate `find` is an executor, a redirected
|
|
408
445
|
`find` has a downstream reader, and a **mixed** compound (a segment that is
|
|
409
446
|
neither a listing nor a banner) all pass untouched. **Placed before both
|
|
@@ -481,15 +518,20 @@ that harness exists would be designing against no case.
|
|
|
481
518
|
read-steer rules and before both auto-allow rules**, on rule 8's stated
|
|
482
519
|
reasoning: `pgrep` is a plausible member of a widened `GUARD_KIT_RO_BINS` — it
|
|
483
520
|
is, after all, a read-only query — and a consumer who added it would otherwise
|
|
484
|
-
have rule
|
|
521
|
+
have rule 18 silently bless a waiter that can never exit.
|
|
485
522
|
13. **Bare foreground `sleep`** — a `sleep` standing in for a wait is
|
|
486
523
|
**blocked**, and the discriminator is the whole rule: a blanket `sleep` block
|
|
487
|
-
is wrong and is refused. The sanctioned wait *is* a condition loop, and
|
|
488
|
-
|
|
524
|
+
is wrong and is refused. The sanctioned wait *is* a condition loop, and such
|
|
525
|
+
a loop is expressly legitimate **in either spelling** —
|
|
526
|
+
`until <cond>; do sleep N; done` and `while <cond>; do sleep N; done` alike,
|
|
527
|
+
because the span walk below reads `do … done` and never the loop keyword, so
|
|
528
|
+
correcting a wait loop's polarity is free at the guard. So the rule fires on
|
|
489
529
|
exactly one shape — a bare foreground `sleep` in command position, outside
|
|
490
530
|
every loop wrapper — and never on a `sleep` inside a loop body. *The
|
|
491
|
-
discriminator is new territory:*
|
|
492
|
-
|
|
531
|
+
discriminator is new territory:* this ruleset carries exactly one shell-keyword
|
|
532
|
+
parse and this rule is where it came from — rule 15's wait-loop exemption now
|
|
533
|
+
shares it rather than copying it, so the ruleset keeps one keyword-parsing
|
|
534
|
+
dialect. This one takes the skeleton view (so a `sleep` merely *named* in a
|
|
493
535
|
quoted span or a heredoc body is already inert), then walks it for `do … done`
|
|
494
536
|
spans and treats a `sleep` inside one as **inert** — structurally the carve-out
|
|
495
537
|
`_guard_is_banner` already performs for `echo`/`printf` segments in the batched-read
|
|
@@ -498,15 +540,20 @@ that harness exists would be designing against no case.
|
|
|
498
540
|
or a span the rule cannot attribute — it **declines**, the direction every
|
|
499
541
|
other conservative clause here takes; a `sleep` that is an *argument* rather
|
|
500
542
|
than a command word never fires at all. **Blocks** rather than advises, on
|
|
501
|
-
rule
|
|
543
|
+
rule 19's reasoning: no consumer allowlist is presumed to grant a bare
|
|
502
544
|
`sleep`, so the rule fires on a command that would be decided out of band
|
|
503
545
|
anyway and converts that decision into a durable steer at no extra cost. *The
|
|
504
546
|
corrective names the property and both forms* rather than one spelling: a wait
|
|
505
547
|
must end when its condition goes true, not when a duration expires; a
|
|
506
548
|
backgrounded command that *exits* on the condition fires one notification the
|
|
507
549
|
moment the condition holds, while the harness's event-stream form stays armed
|
|
508
|
-
to its deadline
|
|
509
|
-
|
|
550
|
+
to its deadline after its event fires when the command it was armed with is
|
|
551
|
+
unbounded, which makes it the second choice for a single completion. *It also
|
|
552
|
+
names the loop's polarity*, because that is the next mistake and it is the one
|
|
553
|
+
with an attested cost: `until` takes a done predicate, `while` takes a
|
|
554
|
+
still-running one such as a PID's liveness, and inverting them yields a loop
|
|
555
|
+
that exits at once with the producer still running
|
|
556
|
+
(delegation-kit/SPEC.md §bin/wait-probe measured it). Naming one form teaches a spelling; naming the property
|
|
510
557
|
and sorting both under it teaches the rule — the discriminator is owned by
|
|
511
558
|
delegation-kit/SPEC.md §The delegation model. **Placed with rule 12, before both
|
|
512
559
|
auto-allow rules,** for the same reason: `sleep` is not on the default
|
|
@@ -529,10 +576,14 @@ that harness exists would be designing against no case.
|
|
|
529
576
|
reaching them would refuse the very mechanic the resume-journal contract
|
|
530
577
|
requires *while a wait is in progress*.
|
|
531
578
|
**This is the enforcement half of the waiting rule, and it works by
|
|
532
|
-
relocation.** The turn-end
|
|
533
|
-
(delegation-kit/SPEC.md §Operative residency);
|
|
534
|
-
arrives as an ordinary tool call at a chokepoint
|
|
535
|
-
what this rule fires on.
|
|
579
|
+
relocation.** The turn-end passes no `PreToolUse` chokepoint, so it is
|
|
580
|
+
unreachable from this ruleset (delegation-kit/SPEC.md §Operative residency);
|
|
581
|
+
the **harm** it causes arrives as an ordinary tool call at a chokepoint
|
|
582
|
+
already wired, which is what this rule fires on. The harness's own turn-end
|
|
583
|
+
event does reach it on a different axis, measured rather than assumed
|
|
584
|
+
(delegation-kit/SPEC.md §The turn-end liveness probe (template)), and
|
|
585
|
+
observing there is not refusing there — so this rule stays the enforcement
|
|
586
|
+
and is unchanged.
|
|
536
587
|
**Why the block is right even though it over-reaches, stated rather than
|
|
537
588
|
softened.** A read-only producer takes no harm from a commit, and the record
|
|
538
589
|
cannot say which kind it is. This ruleset's established direction is to bias
|
|
@@ -558,19 +609,177 @@ that harness exists would be designing against no case.
|
|
|
558
609
|
consumer that widened it would otherwise have the read-only-pipeline rule
|
|
559
610
|
silently grant the mutation). **Two collisions make the placement necessary
|
|
560
611
|
rather than tidy**, and both are with rules that sit *after* the
|
|
561
|
-
auto-allows: rule
|
|
612
|
+
auto-allows: rule 19 would block a chained `git commit` first and hand back
|
|
562
613
|
*run it bare* — a corrective that is wrong under a live producer and that
|
|
563
|
-
the session can follow; and rule
|
|
614
|
+
the session can follow; and rule 20 **advises** on `git commit --amend`, so
|
|
564
615
|
a rewrite under a live producer would proceed with a re-verification steer
|
|
565
616
|
instead of stopping.
|
|
566
|
-
|
|
617
|
+
**The bound this rule ships with is narrowed at the launch chokepoint, not
|
|
618
|
+
closed.** A session that backgrounds without recording is still invisible
|
|
619
|
+
here; rule 15 advises at the launch itself, which makes the omission visible
|
|
620
|
+
at the moment it is made without refusing it.
|
|
621
|
+
15. **Backgrounded launch that records no producer** — a backgrounding Bash call
|
|
622
|
+
that neither writes a liveness record nor meets an exemption below is
|
|
623
|
+
**advised**: the message names the record, its grammar, its home, and the two
|
|
624
|
+
things it buys — rule 14's reach, and the next arrival's ability to tell
|
|
625
|
+
whether the producer is still writing.
|
|
626
|
+
**Two backgrounding forms, and both arms ship in one rule.** *Harness form* —
|
|
627
|
+
`.tool_input.run_in_background` is `true`, read through `guard_input_field`
|
|
628
|
+
(§The guard framework records the field and its shape). *Shell form* — the
|
|
629
|
+
skeleton (`sq dq hd`) ends a statement with a bare `&` that is neither the
|
|
630
|
+
`&&` operator nor a redirect's fd-dup. Building only the shell arm was
|
|
631
|
+
refused as worse than not building it: every attested firing used the harness
|
|
632
|
+
form, so a shell-only rule would cover the spelling nobody uses and pass the
|
|
633
|
+
one that fires — coverage in appearance
|
|
634
|
+
(delegation-kit/SPEC.md §The delegation model).
|
|
635
|
+
**The record-writing test reads the command text, and that is forced rather
|
|
636
|
+
than chosen.** At `PreToolUse` the child has not started and no record can
|
|
637
|
+
exist yet, so the only thing observable at this chokepoint is whether the
|
|
638
|
+
launch is *going to* write one: the call writes a record when its skeleton
|
|
639
|
+
carries a redirect whose target is a path under a `GUARD_KIT_SCRATCH_DIRS`
|
|
640
|
+
member ending in `.run`. That is the honest predicate, and it is part of why
|
|
641
|
+
the rule advises rather than refuses.
|
|
642
|
+
**Three exemptions, each reusing machinery already in the lib.** (1) *The call
|
|
643
|
+
writes a record* — the obligation is discharged inline. (2) *The call is a
|
|
644
|
+
wait loop* — a backgrounded `until <cond>; do sleep N; done` is the sanctioned
|
|
645
|
+
primitive rule 13 steers **toward**, a waiter rather than a producer, and
|
|
646
|
+
advising there would make the ruleset warn against the form its own corrective
|
|
647
|
+
recommends; detected by the `do … done` span walk rule 13 already performs.
|
|
648
|
+
(3) *The call is a read-only pipeline* — every segment leads with a
|
|
649
|
+
`GUARD_KIT_RO_BINS` member and every redirect target is `/dev/null` or an
|
|
650
|
+
fd-dup, rule 18's own test, since a child that writes nothing has nothing for
|
|
651
|
+
a later commit to corrupt.
|
|
652
|
+
**Advises rather than blocks, and the refusal of a block is reasoned rather
|
|
653
|
+
than hedged.** The guard cannot tell a producer from a trivial child — a
|
|
654
|
+
backgrounded `printf` and a backgrounded gate battery are the same shape at
|
|
655
|
+
this chokepoint — so a block's false-fire population is every short-lived
|
|
656
|
+
backgrounded call in the tree, and this ruleset's established direction is to
|
|
657
|
+
bias toward passing. Rule 14 departs from that direction on an attested record
|
|
658
|
+
of failure; this rule has none to depart on: both attested firings
|
|
659
|
+
(2026-08-19 and 2026-08-21, the second self-disclosed) produced no orphan, so
|
|
660
|
+
the harm is latent and a block is not warranted by a latent harm when the
|
|
661
|
+
reminder is what was missing. The harm already has a block — rule 14 refuses
|
|
662
|
+
the mutation — and this rule covers the **omission** that hides it, one step
|
|
663
|
+
upstream, where a second refusal buys a second stop rather than a second
|
|
664
|
+
catch. Both firings were a session that *knew* the rule and forgot it at the
|
|
665
|
+
call, which is exactly what an `additionalContext` note at the call fixes, at
|
|
666
|
+
the cost of one sentence rather than a stopped turn.
|
|
667
|
+
**The re-opening condition is named rather than left to judgment:** a firing
|
|
668
|
+
of the recording omission *after* this advisory ships is the attested record
|
|
669
|
+
rule 14's own departure required, and the block is then the next step.
|
|
670
|
+
**The honest limit.** An advisory does not refuse. A session determined to
|
|
671
|
+
background without recording still can, so rule 14's bound — *only for a
|
|
672
|
+
session that recorded* — is **narrowed rather than closed**. What closes at
|
|
673
|
+
this chokepoint is the silent case: the omission is now visible at the moment
|
|
674
|
+
it is made, to the only party that can fix it.
|
|
675
|
+
Conservative in this ruleset's established directions: an expansion or
|
|
676
|
+
substitution anywhere in the command declines outright (rule 6 blocks those
|
|
677
|
+
shapes already), an unbalanced `do`/`done` declines, and an absent
|
|
678
|
+
`GUARD_INPUT` on a call carrying no shell `&` simply leaves the harness arm
|
|
679
|
+
unavailable and the rule inert — the graceful degradation §The guard
|
|
680
|
+
framework's `GUARD_INPUT`-then-stdin fallback buys. **Placed with rules 12, 13
|
|
681
|
+
and 14 as the fourth member of the wait-discipline family, before both
|
|
682
|
+
auto-allow rules**, and the placement is required rather than tidy: a
|
|
683
|
+
backgrounded read-only pipeline is granted outright by rule 18, so a rule
|
|
684
|
+
sitting after the auto-allows would never run on the shapes it exists for.
|
|
685
|
+
**No knob is minted, and that is a seam decision rather than an economy**: a
|
|
686
|
+
producer roster — *which backgrounded commands are worth a record* — is
|
|
687
|
+
exactly the consumer vocabulary the provenance seam keeps out of a kit, so the
|
|
688
|
+
rule recognizes shapes and advises, and a consumer wanting a narrower
|
|
689
|
+
population narrows the two knobs that already exist.
|
|
690
|
+
16. **Auto-allow `: > file` truncation** — a leading `:` plus redirect
|
|
567
691
|
defeats the permission matcher, so it is always decided out of band. Granted
|
|
568
692
|
silently when the command is *only* `:` followed by redirects and every target is
|
|
569
693
|
gitignored (`git check-ignore`): truncating scratch is safe; a tracked
|
|
570
694
|
file must still take that decision. The `git` subprocess is gated behind the rare
|
|
571
695
|
`:`-redirect match; expansions (rule 6) and brace forms (rule 7) are
|
|
572
696
|
already blocked, so a surviving target is a literal path.
|
|
573
|
-
|
|
697
|
+
17. **Auto-allow an append-only write to a gitignored target** — the mandated
|
|
698
|
+
resume-journal append that
|
|
699
|
+
delegation-kit/SPEC.md §Resume journal — agent writes, scratch reset sweeps
|
|
700
|
+
obliges is a redirect, and the harness checks a redirect
|
|
701
|
+
**target** as a file write, so no `Bash(…)` allow entry can grant it: such a
|
|
702
|
+
rule grants the command and never the target. Granted silently when **every
|
|
703
|
+
clause below** holds, falling through untouched otherwise:
|
|
704
|
+
- **(0) Not a backgrounded launch.** A statement-ending `&` refuses before
|
|
705
|
+
any other clause is read: a backgrounded append is rule 15's subject, and
|
|
706
|
+
granting it here would bless a launch the liveness-record rule is about.
|
|
707
|
+
- **(a) Append-only.** Every redirect operator is `>>` (an fd prefix
|
|
708
|
+
allowed: `2>>`); a single truncating `>` **anywhere** refuses. This clause
|
|
709
|
+
carries the append-only split — a mistyped redirect must not be able to
|
|
710
|
+
destroy a journal — and it is the one no settings rule can express, since a
|
|
711
|
+
redirect-target check is a **file-write** check and cannot tell `>>` from
|
|
712
|
+
`>`. That is why the grant is a hook rather than an anchored `Edit` rule,
|
|
713
|
+
which would reach the target correctly and grant the truncating form with it.
|
|
714
|
+
- **(b) Every target gitignored**, on rule 16's exact `git check-ignore
|
|
715
|
+
--quiet --` predicate and its exact subprocess, gated behind the same
|
|
716
|
+
rarity: `git` is reached only once (a) and (c) have already matched.
|
|
717
|
+
- **(c) The leading command emits to stdout and nothing else**, and the
|
|
718
|
+
command is one statement. The roster is `GUARD_KIT_APPEND_BINS`.
|
|
719
|
+
- **(d) Conservative decline on anything unmodelled** — a command or process
|
|
720
|
+
substitution or a backtick anywhere in the **raw** command, or a redirect
|
|
721
|
+
target that survives normalization carrying a quote. Declares `sq dq hd`.
|
|
722
|
+
|
|
723
|
+
**Why (c) is the clause the safety argument rests on.** A
|
|
724
|
+
`permissionDecision: allow` blesses the whole call, so a rule keyed on the
|
|
725
|
+
redirect alone would grant `rm -rf .tmp/../.git >> .tmp/j.md` — the target is
|
|
726
|
+
gitignored, the operator is `>>`, and the command destroys the repository.
|
|
727
|
+
Bounding the *emitter* is what makes the grant safe, and bounding it to
|
|
728
|
+
**stdout-only** emitters is what makes the bound checkable: `cat`, `printf`
|
|
729
|
+
and `echo` write nowhere the redirect does not send them, so the redirect
|
|
730
|
+
target is the whole of what the call can touch. `tee` is deliberately **off**
|
|
731
|
+
the roster despite being the obvious fourth member — it takes a path
|
|
732
|
+
**argument**, so `tee -a <tracked file>` writes a tracked file with no
|
|
733
|
+
redirect at all and (a) and (b) never see it. The honest limit is the mirror
|
|
734
|
+
of the one rule 18 carries for `GUARD_KIT_RO_BINS`, reached from the writing
|
|
735
|
+
side rather than the reading side: the grant is exactly as safe as the
|
|
736
|
+
roster's stdout-only property, which the rule asserts of the roster and
|
|
737
|
+
cannot verify of a member.
|
|
738
|
+
**One statement is one segment plus its own heredoc residue, never one
|
|
739
|
+
segment.** `guard_split_compound` emits per **line** and `guard_skeleton`'s
|
|
740
|
+
`hd` class leaves a heredoc's body placeholder and terminator on lines of
|
|
741
|
+
their own, so the mandated `cat >> … <<'EOF'` form splits into *three*
|
|
742
|
+
segments and a one-segment test would refuse the exact command this rule
|
|
743
|
+
exists to grant. The test is therefore that every segment past the first is
|
|
744
|
+
exactly the residue the first segment's own openers produce — which still
|
|
745
|
+
refuses a second statement on a line of its own (`printf x >> .tmp/j.md`,
|
|
746
|
+
newline, `rm -rf …`), the hazard the one-statement bound is for.
|
|
747
|
+
**Two inert targets are exempt from (a) and (b)**, and the carve-out is
|
|
748
|
+
precedented rather than invented: `/dev/null` and an fd-dup (`&1`, `&2`) are
|
|
749
|
+
what rule 18 already treats as targets that are not files. Neither is a file
|
|
750
|
+
the append-only split protects and neither is a path `git check-ignore` can
|
|
751
|
+
answer about. Every **other** target takes both tests, and at least one such
|
|
752
|
+
target must exist — a call redirecting only to inert targets has no append to
|
|
753
|
+
grant. Seeing an fd-dup at all takes this rule's own operator-and-target
|
|
754
|
+
scan, because `_guard_redirect_targets`' target class excludes `&` and drops
|
|
755
|
+
an fd-dup target entirely.
|
|
756
|
+
**The raw-command arm is not redundant with rule 6**, and that was measured
|
|
757
|
+
rather than assumed: rule 6 blocks `${…}`, `$(…)`, `<(…)` and `$NAME` and
|
|
758
|
+
exits 2 first, but **not** `>(…)`, which does run its command. An auto-allow
|
|
759
|
+
may not rest on a coverage claim that is only mostly true, so this rule takes
|
|
760
|
+
the same full raw-command decline rule 18 takes.
|
|
761
|
+
**Placed immediately after rule 16 and before rule 18**, and the position is
|
|
762
|
+
load-bearing rather than tidy: placing it after the decorated-allowlist rule
|
|
763
|
+
would be wrong because that rule blocks a bare allow entry decorated by a
|
|
764
|
+
trailing redirect, which is one plausible spelling of the very command this
|
|
765
|
+
rule grants.
|
|
766
|
+
**The mandated in-turn wait is a stated non-target**, recorded so the
|
|
767
|
+
omission is not read as an oversight: its `kill -0 "$pid"` loop is
|
|
768
|
+
ungrantable by a settings rule for the same structural reason — the mandated
|
|
769
|
+
form *is* a loop condition, so it is decorated by construction — but a grant
|
|
770
|
+
minted around the currently-sanctioned loop form would be shaped to a
|
|
771
|
+
primitive that measurement may correct, and a guard on the wrong primitive
|
|
772
|
+
inherits its failure. Measure first, then grant. **The measurement has since
|
|
773
|
+
returned and the precondition is discharged**, so what remains is the grant
|
|
774
|
+
itself rather than the question it waited on: the backgrounded condition loop
|
|
775
|
+
stands unchanged as the sanctioned form and the correction landed on the
|
|
776
|
+
loop's *polarity*, so a grant is now shaped to `while kill -0 "$pid" …` as
|
|
777
|
+
well as `until <cond> …` (delegation-kit/SPEC.md §bin/wait-probe holds the
|
|
778
|
+
trials; §Operative residency holds the finding). Recorded here rather than
|
|
779
|
+
left as a closed refusal because the two read differently: this one is now
|
|
780
|
+
unblocked work, and rule 6 decides the mandated spelling out of band on every
|
|
781
|
+
call until it is minted.
|
|
782
|
+
18. **Auto-allow read-only pipeline** — granted silently when every pipe
|
|
574
783
|
segment leads with a roster binary (`GUARD_KIT_RO_BINS`, default the
|
|
575
784
|
grep/head/cat/find/jq family) and every redirect target is `/dev/null`
|
|
576
785
|
or an fd-dup. Declares `sq dq hd`. Conservative by construction:
|
|
@@ -598,7 +807,7 @@ that harness exists would be designing against no case.
|
|
|
598
807
|
least one non-banner roster segment must remain, so a banner-only pipeline
|
|
599
808
|
is not granted.
|
|
600
809
|
- **The lead segment may instead be a bare committed allow entry** — an
|
|
601
|
-
exact `Bash(<cmd>)` with no glob, on rule
|
|
810
|
+
exact `Bash(<cmd>)` with no glob, on rule 19's own reasoning that a
|
|
602
811
|
glob-headed family coexists with allowlisted decorators and would admit
|
|
603
812
|
far more than the reviewed command. The shape this repairs is an
|
|
604
813
|
allowlisted script piped into `head`: the lead is statically allowlisted,
|
|
@@ -612,7 +821,7 @@ that harness exists would be designing against no case.
|
|
|
612
821
|
exactly as it behaves without it. A grant that depends on a settings read
|
|
613
822
|
must never turn a missing settings file into a grant, and declining is the
|
|
614
823
|
only direction that cannot.
|
|
615
|
-
|
|
824
|
+
19. **Decorated allowlisted command** — the leading command exactly matches a
|
|
616
825
|
committed **bare** allow entry (a `Bash(<cmd>)` with no `:*`/`*` glob) but
|
|
617
826
|
the command decorates it — `&&`/`;`/`|` chaining, a trailing redirect, or
|
|
618
827
|
`2>&1` — which leaves a segment nothing grants, so the whole call falls off
|
|
@@ -632,17 +841,17 @@ that harness exists would be designing against no case.
|
|
|
632
841
|
allow entry, reusing `guard_allow_match`'s shell-glob semantics. Reads
|
|
633
842
|
`GUARD_KIT_SETTINGS`; **fail-open** — no `jq`, no settings file, or a
|
|
634
843
|
parse error and the rule silently declines and falls through. Placed after
|
|
635
|
-
the auto-allow rules (
|
|
636
|
-
reaches it — which is also **why the allowlisted-lead grant lives in rule
|
|
844
|
+
the auto-allow rules (16, 17, 18) so a silently granted read-only pipeline never
|
|
845
|
+
reaches it — which is also **why the allowlisted-lead grant lives in rule 18
|
|
637
846
|
and not here**. Grant, not fall-through, is what removes the friction of an
|
|
638
847
|
allowlisted command decorated only by a read-only reduction of its own
|
|
639
848
|
output, and this rule's own text refuses to grant, correctly: granting here
|
|
640
|
-
would bless segments the allowlist never reviewed. Rule
|
|
849
|
+
would bless segments the allowlist never reviewed. Rule 18 is already the
|
|
641
850
|
sanctioned place for a grant of exactly that shape and is already ordered
|
|
642
851
|
ahead of this rule, so a granted pipeline never arrives and nothing
|
|
643
852
|
ungranted becomes granted that either half would not have granted alone.
|
|
644
853
|
Declares `sq dq hd`.
|
|
645
|
-
|
|
854
|
+
20. **Git history-rewrite advisory** — a `git commit` carrying `--amend`, `-F`,
|
|
646
855
|
or `--file`, or a `git reset --soft`, gets a `guard_advise` steer carrying
|
|
647
856
|
the checklist from DOCTRINE.md's *Re-verify volatile state before a git
|
|
648
857
|
history rewrite* rule (verify HEAD before amend/squash; re-stage and verify
|
|
@@ -652,29 +861,31 @@ that harness exists would be designing against no case.
|
|
|
652
861
|
DOCTRINE.md rule is cited by **name**, not number — the doctrine's craft
|
|
653
862
|
rules renumber as it grows, and this ruleset renumbers on its own account
|
|
654
863
|
too — this rule's own number moved when rules 12 and 13 were inserted ahead
|
|
655
|
-
of it,
|
|
864
|
+
of it, again when rule 14 was, again when rule 15 was, and again when the
|
|
865
|
+
append grant landed as rule 17 — so a
|
|
656
866
|
doc-qualified number would rot on either renumber and read ambiguously
|
|
657
867
|
against the local numbering. Placed
|
|
658
|
-
after the auto-allow rules (
|
|
868
|
+
after the auto-allow rules (16, 17, 18) and the decorated-allowlist rule (19),
|
|
659
869
|
so it fires only on a bare rewrite command none of those claimed; a
|
|
660
|
-
decorated form meets rule
|
|
870
|
+
decorated form meets rule 19's block first and the advisory fires on the
|
|
661
871
|
re-issued bare command.
|
|
662
|
-
|
|
872
|
+
21. **Bare `rm` of a tracked path** — an `rm` statement naming a git-tracked
|
|
663
873
|
file (`git ls-files --error-unmatch`) is **blocked** with the steer to
|
|
664
874
|
`git rm -q <path>`, which deletes and stages that one deletion in a single
|
|
665
875
|
motion. The deletion is the point: a bare `rm` leaves it unstaged, so it
|
|
666
876
|
lands only via a later `git add -A` — the form the shared-index discipline
|
|
667
877
|
warns against, since it sweeps a concurrent session's foreign path into the
|
|
668
|
-
commit. Block, not advise, on rule
|
|
878
|
+
commit. Block, not advise, on rule 19's reasoning: no consumer allowlist is
|
|
669
879
|
presumed to grant `rm`, so the rule fires on a command that would be decided
|
|
670
880
|
out of band anyway and converts that decision into a durable steer. Fires per statement
|
|
671
881
|
(`;`/`&&`/`||`/`|` split), so a decorated form steers on the same premise as
|
|
672
882
|
the bare one. Conservative by construction: expansions and backticks decline
|
|
673
|
-
outright (rule 6 already blocks
|
|
883
|
+
outright (rule 6 already blocks the expansions; the backtick arm is this
|
|
884
|
+
rule's own), option words are skipped, and a
|
|
674
885
|
tracked *directory* under `rm -r` does not match `--error-unmatch` — each
|
|
675
886
|
biases toward passing rather than a false steer. An untracked or gitignored
|
|
676
887
|
target never matches, so scratch deletion is untouched.
|
|
677
|
-
|
|
888
|
+
22. **Fall-through logging** — anything neither blocked nor auto-allowed is
|
|
678
889
|
appended to the friction log. Always last; never affects the decision.
|
|
679
890
|
|
|
680
891
|
**Nothing above claims the sleep half was already enforced.** Before rule 13, no
|
|
@@ -799,7 +1010,7 @@ close-stage audit. A committed pattern subsumes a local entry when the
|
|
|
799
1010
|
local string matches it under shell-glob semantics; the harness `:*` prefix
|
|
800
1011
|
idiom (`Bash(printf:*)` ≡ any `printf …`) is normalized to a trailing `*`
|
|
801
1012
|
so one glob test covers both forms — the match core is `guard_allow_match`
|
|
802
|
-
in `lib/guard.sh`, shared with rule
|
|
1013
|
+
in `lib/guard.sh`, shared with rule 19. Read-only — reports candidates, never
|
|
803
1014
|
mutates (the operator prunes). It is the detector, not the policy: a
|
|
804
1015
|
non-redundant local entry can still be one-off junk worth pruning by
|
|
805
1016
|
judgment.
|
|
@@ -825,6 +1036,65 @@ a report worded as coverage would be the false-confidence proxy gate-sdk/SPEC.md
|
|
|
825
1036
|
is omitted entirely rather than printed clean, so a consumer that declared no
|
|
826
1037
|
vocabulary cannot read silence as coverage.
|
|
827
1038
|
|
|
1039
|
+
**The second disposition has a mechanism, and where the ruling lives is what makes
|
|
1040
|
+
it durable.** `GUARD_KIT_BREADTH_DECLARED` (§Layout and configuration) maps a
|
|
1041
|
+
permission-rule string to the reason that breadth was ruled intended — a pair,
|
|
1042
|
+
never a bare list, since a bare list re-loses the reason it exists to keep. It
|
|
1043
|
+
lives in the **committed** config the consumer tracks, so the ruling survives in a
|
|
1044
|
+
reviewable surface rather than in a session's memory or a commit message, which
|
|
1045
|
+
spec-over-precedent says is not ground truth. That fixes where a declaration
|
|
1046
|
+
*lives*; it does not widen what the breadth question *reads*, which stays the
|
|
1047
|
+
local overlay named above. An over-broad local glob keeps re-reporting until a
|
|
1048
|
+
**committed** declaration rules it, and a per-clone declaration cannot silence
|
|
1049
|
+
one.
|
|
1050
|
+
|
|
1051
|
+
**The declaration match is exact-string, never glob.** An entry is declared when
|
|
1052
|
+
the exact local allow-rule string is a key of the map — a key test and nothing
|
|
1053
|
+
else. Routing it through `guard_allow_match` is refused: the kit's one matcher
|
|
1054
|
+
would let a single declaration silence globs the operator's ruling never named,
|
|
1055
|
+
which is a declaration widening itself, and a durable ruling about intended
|
|
1056
|
+
breadth is a ruling about **one** glob. The consequence is stated rather than left
|
|
1057
|
+
to be discovered — narrowing a declared glob, or re-spelling it, drops its
|
|
1058
|
+
declaration and the entry re-reports. That is correct, since the ruling was taken
|
|
1059
|
+
on the old string, and it is what keeps a declaration from outliving the glob it
|
|
1060
|
+
ruled.
|
|
1061
|
+
|
|
1062
|
+
**A declared glob is not dropped from the report.** The over-broad set partitions
|
|
1063
|
+
in two and both halves print:
|
|
1064
|
+
|
|
1065
|
+
- **narrowing candidates** — over-broad and undeclared, printed with the
|
|
1066
|
+
two-disposition help text above.
|
|
1067
|
+
- **declared intended** — over-broad and declared, printed as
|
|
1068
|
+
`<glob> ⊇ <probe> — <reason>` under its own heading, with help text naming
|
|
1069
|
+
the committed config as where the ruling lives.
|
|
1070
|
+
|
|
1071
|
+
Dropping a declared glob would make the knob a silencer whose contents nobody ever
|
|
1072
|
+
reads, and a field with no named reader is removed rather than shipped
|
|
1073
|
+
(canon-kit/SPEC.md §The causal-completeness check, point 4). An over-broad set
|
|
1074
|
+
that is **entirely** declared therefore prints the declared section and **no**
|
|
1075
|
+
narrowing section: *no over-broad local entries* would be false there. With no
|
|
1076
|
+
over-broad entries at all the report is unchanged, and with the map empty — the
|
|
1077
|
+
default, and the shipped state for a consumer who declares nothing — the partition
|
|
1078
|
+
is trivial, the declared subsection is omitted, and every byte of output matches
|
|
1079
|
+
the tool as it behaved before the declaration shipped. The asymmetry with
|
|
1080
|
+
`GUARD_KIT_BREADTH_PROBES` is deliberate: an empty probe set omits the whole
|
|
1081
|
+
breadth section because silence there could be misread as coverage, while an empty
|
|
1082
|
+
declaration set omits only the declared subsection, where no coverage claim is
|
|
1083
|
+
available to misread and an absent section says exactly that nothing was declared.
|
|
1084
|
+
|
|
1085
|
+
**The honest limit: a declaration can outlive its subject and nothing notices.**
|
|
1086
|
+
The knob records a ruling; it does not verify that the glob it names is still in
|
|
1087
|
+
`GUARD_KIT_SETTINGS_LOCAL`, still over-broad, or still real. A stale declaration
|
|
1088
|
+
is silent. A stale-declaration report was weighed and refused, because it would
|
|
1089
|
+
print every declaration naming a **committed** glob as stale — and a committed
|
|
1090
|
+
glob was never in this report to begin with, so a declaration naming one is a
|
|
1091
|
+
durable record that the report itself does not read. That is exactly the shape a
|
|
1092
|
+
re-derivation of the committed allowlist produces when it rules a glob safe and
|
|
1093
|
+
keeps it broad, and it is stated rather than covered; the gap is filed rather than
|
|
1094
|
+
flagged-and-skipped. Nothing here makes a gate of the tool either: the placement
|
|
1095
|
+
ruling below is unchanged and unweakened by a knob that records exactly the
|
|
1096
|
+
operator intent that ruling turns on.
|
|
1097
|
+
|
|
828
1098
|
This is the criterion's home rather than a gate, and the placement is ruled
|
|
829
1099
|
rather than defaulted: the subject is a gitignored per-machine file CI cannot
|
|
830
1100
|
see, and the verdict is operator-intent-dependent (a blanket grant is fine in a
|
|
@@ -845,7 +1115,11 @@ owns the committed settings file as a gate subject. This kit holds the three
|
|
|
845
1115
|
by parsing technique does not outrank placement by governed surface.
|
|
846
1116
|
|
|
847
1117
|
`--count` emits both bare counts on one line, redundancy first and breadth
|
|
848
|
-
second
|
|
1118
|
+
second, and the breadth number counts the **narrowing candidates** rather than
|
|
1119
|
+
every over-broad entry: the count's one purpose is *how much is outstanding*, and
|
|
1120
|
+
a declared entry is not outstanding. A third number for the declared count is
|
|
1121
|
+
refused — no reader needs it, and the two-number line is a shape a consumer may
|
|
1122
|
+
already parse.
|
|
849
1123
|
|
|
850
1124
|
## wakeup-guard (template)
|
|
851
1125
|
|
|
@@ -893,8 +1167,10 @@ lifecycle-kit's close template. The step: run `scan-prompts`, resolve each
|
|
|
893
1167
|
recurring pattern by the triage criterion; review and delete the wakeup
|
|
894
1168
|
log if present; run `compare-settings-allow` and take its **two**
|
|
895
1169
|
dispositions — prune the listed redundant local entries, and for each entry the
|
|
896
|
-
breadth report names, either narrow the glob or record
|
|
897
|
-
|
|
1170
|
+
breadth report names as a narrowing candidate, either narrow the glob or record
|
|
1171
|
+
that its breadth is intended as a `GUARD_KIT_BREADTH_DECLARED` entry in the
|
|
1172
|
+
committed config, which is what moves it into the report's declared section and
|
|
1173
|
+
stops it re-reporting — then by judgment prune the remaining one-off exact-string local
|
|
898
1174
|
entries and promote recurring safe patterns to the committed settings as
|
|
899
1175
|
globs; clear the friction log. Two judgments the reports cannot make sit in
|
|
900
1176
|
that last step. An entry naming a **script path** rather than a fixed command is
|
|
@@ -924,6 +1200,7 @@ guard-kit/
|
|
|
924
1200
|
bin/run-guard-tests.sh # decision-table runner
|
|
925
1201
|
guard-tests/cases.tsv # expected-decision <TAB> command
|
|
926
1202
|
guard-tests/escalation-cases.tsv # expected-decision <TAB> to <TAB> message
|
|
1203
|
+
guard-tests/background-cases.tsv # expected-decision <TAB> run_in_background <TAB> command
|
|
927
1204
|
gate-tests/scratch-run.test.sh # bespoke unit test, run by gate-sdk's runner
|
|
928
1205
|
gate-tests/scan-prompts.test.sh # bespoke unit test, run by gate-sdk's runner
|
|
929
1206
|
gate-tests/compare-settings-allow.test.sh # bespoke unit test, run by gate-sdk's runner
|
|
@@ -967,11 +1244,36 @@ repo's layout as defaults):
|
|
|
967
1244
|
both sides, so a consumer can probe non-`Bash` rules with the same mechanism.
|
|
968
1245
|
The kit ships **no** default probes: every string naming a command is the
|
|
969
1246
|
consumer's vocabulary, never the kit's (CLAUDE.md §The provenance seam).
|
|
1247
|
+
- `GUARD_KIT_BREADTH_DECLARED` — associative array recording the breadths ruled
|
|
1248
|
+
intended (§compare-settings-allow): the key is a permission-rule string, the
|
|
1249
|
+
value the reason that breadth was ruled intended; default empty, in which case
|
|
1250
|
+
the declared subsection is absent and the tool behaves exactly as it did before
|
|
1251
|
+
the declaration shipped. **Associative rather than a delimited indexed array,
|
|
1252
|
+
and the choice is not cosmetic:** a permission rule may contain any character a
|
|
1253
|
+
command may, so every single-character separator an indexed array would need
|
|
1254
|
+
(`|`, `::`, a tab) is a character a legitimate rule can carry, and the knob
|
|
1255
|
+
would ship a grammar that cannot express part of its own subject. An
|
|
1256
|
+
associative key holds the rule verbatim, and a key is unique by construction, so
|
|
1257
|
+
the *which reason wins* question the delimited shape would raise cannot arise.
|
|
1258
|
+
Report order never depends on the map's iteration order: the tool walks the
|
|
1259
|
+
settings file's own allow list and looks each entry up, so the map is never
|
|
1260
|
+
iterated and the unordered iteration never reaches output. The kit ships **no**
|
|
1261
|
+
default declarations, on the same seam reasoning as the probes above.
|
|
970
1262
|
- `GUARD_KIT_RO_SCRIPTS` — array of globs eligible for the
|
|
971
1263
|
absolute→relative rewrite (rule 4); default `("check-*.sh")`.
|
|
972
|
-
- `GUARD_KIT_RO_BINS` — read-only pipeline roster (rule
|
|
1264
|
+
- `GUARD_KIT_RO_BINS` — read-only pipeline roster (rule 18); default the
|
|
973
1265
|
grep/head/cat/find/jq family, plus `xargs`, whose membership is qualified by
|
|
974
|
-
rule
|
|
1266
|
+
rule 18's discriminator rather than granting on the leads-with test alone.
|
|
1267
|
+
- `GUARD_KIT_APPEND_BINS` — the emitter roster of the append grant (rule 17);
|
|
1268
|
+
default `(cat printf echo)`. A knob rather than a kit literal on
|
|
1269
|
+
`GUARD_KIT_RO_BINS`'s reasoning: a consumer whose mandated write rides a
|
|
1270
|
+
different emitter shadows the array instead of forking the rule, and three
|
|
1271
|
+
POSIX utility names are shipped mechanism rather than a vocabulary, so
|
|
1272
|
+
defaulting them crosses no provenance seam. The roster's contract is **writes
|
|
1273
|
+
only to its stdout**, and a consumer adding a command that writes anywhere
|
|
1274
|
+
else widens the grant past rule 17(c)'s safety argument — the same widening
|
|
1275
|
+
hazard `GUARD_KIT_RO_BINS` carries, stated here because this roster's members
|
|
1276
|
+
are what bound a *write* rather than a read.
|
|
975
1277
|
- `GUARD_KIT_SCRATCH_DIRS` — gitignored scratch dirs named in the
|
|
976
1278
|
rule-3 corrective message; default `(".tmp")`.
|
|
977
1279
|
|
|
@@ -992,13 +1294,38 @@ make a command expressible in one tab-separated cell: `@ROOT@` becomes the git
|
|
|
992
1294
|
sandbox root, and `@NL@` becomes a newline — without the second a heredoc case
|
|
993
1295
|
cannot be written at all, and the heredoc class would ship untested.
|
|
994
1296
|
|
|
1297
|
+
**The runner drives each case from inside the sandbox**, which decides how a
|
|
1298
|
+
target is spelled and is stated because getting it wrong reads as a rule defect
|
|
1299
|
+
rather than as a spelling one: a path is written **relative** unless the case is
|
|
1300
|
+
*about* an absolute one, since rule 5 blocks any command carrying the repo-root
|
|
1301
|
+
prefix and an `@ROOT@`-absolute target therefore never reaches the rule under
|
|
1302
|
+
test. `@ROOT@` is for the cases whose subject is the absolute form — rules 2, 4
|
|
1303
|
+
and 5 — and for a foreign-repo contrast.
|
|
1304
|
+
|
|
1305
|
+
**Any ad-hoc invocation of a consumer's guard script must set `GUARD_KIT_LOG` to
|
|
1306
|
+
a scratch path**, because the logger's default is the *live* friction log and a
|
|
1307
|
+
throwaway probe otherwise files its synthetic commands as real friction. The
|
|
1308
|
+
kit's own runners all set it — the decision table into its sandbox, the
|
|
1309
|
+
`scan-prompts` fixture into its own — so the convention is invisible until a
|
|
1310
|
+
hand-written latency or behaviour probe drives `bash-guard.sh` in a loop and
|
|
1311
|
+
poisons the next close's ranking with its payload. Measured rather than
|
|
1312
|
+
hypothetical: one such probe contributed 30 of 237 ranked prompting calls at a
|
|
1313
|
+
single close, ranking second. **No scanner is proposed:** the polluting caller is
|
|
1314
|
+
a one-off script in the gitignored scratch dir, so there is no committed corpus
|
|
1315
|
+
to scan and the convention is carried by this sentence and by
|
|
1316
|
+
`bin/scratch-run.sh`'s echo-at-execution.
|
|
1317
|
+
|
|
995
1318
|
**The decision table is the instrument for any change to what the guard
|
|
996
1319
|
refuses, and its red condition is not monotone.** A change that *narrows*
|
|
997
1320
|
refusal cannot be cleared by inspection, because the table fails on a verdict
|
|
998
1321
|
mismatch **in either direction** rather than on a violation count: every
|
|
999
1322
|
existing case whose command carries a double-quoted brace, a heredoc, a banner
|
|
1000
|
-
segment,
|
|
1001
|
-
|
|
1323
|
+
segment, an append redirect to a gitignored target, or an allowlisted lead with
|
|
1324
|
+
a read-only tail must have its expected
|
|
1325
|
+
column **re-derived**, never assumed still correct. Rule 17's landing is the
|
|
1326
|
+
worked instance and the cheap one: it narrowed refusal and flipped exactly one
|
|
1327
|
+
pre-existing row, which the table reported and inspection had not.
|
|
1328
|
+
`bin/scan-prompts.sh` cannot
|
|
1002
1329
|
substitute for it, and the reason is structural rather than a matter of
|
|
1003
1330
|
precision: `guard_block` exits 2 before `guard_log_fallthrough` runs, so a
|
|
1004
1331
|
blocked command never reaches `GUARD_KIT_LOG` and that report is blind to every
|
|
@@ -1013,6 +1340,24 @@ headerless message to `main` → advise) and its non-firing pair (a fully shaped
|
|
|
1013
1340
|
block, and a non-`main` recipient → fallthrough) hold the same fixture-pair
|
|
1014
1341
|
discipline for the advisory.
|
|
1015
1342
|
|
|
1343
|
+
A **third** table, `guard-tests/background-cases.tsv`
|
|
1344
|
+
(`<decision> <TAB> <run_in_background> <TAB> <command>`), extends that same
|
|
1345
|
+
precedent to rule 15's harness arm, and it is forced rather than tidy: the
|
|
1346
|
+
`cases.tsv` grammar pairs a decision with a *command*, and the harness arm's
|
|
1347
|
+
input is a **tool parameter**, so that arm cannot be written there at all and
|
|
1348
|
+
would otherwise ship untested — the coverage-in-appearance this rule's own design
|
|
1349
|
+
refuses. The runner feeds a Bash-shaped payload carrying the flag. Rows, each a
|
|
1350
|
+
firing/non-firing pair: harness-form background with no record → advise;
|
|
1351
|
+
harness-form background writing a `.run` record → fallthrough; harness-form
|
|
1352
|
+
background of a wait loop → fallthrough; harness-form background of a read-only
|
|
1353
|
+
pipeline → the auto-allow it already earns; and a foreground call carrying
|
|
1354
|
+
neither → fallthrough, which is what proves the rule inert off the backgrounding
|
|
1355
|
+
path. The shell-`&` arm *is* a command, so its firing and non-firing rows stay in
|
|
1356
|
+
`cases.tsv`. Rule 15 emits an **advise**, so it converts a `fallthrough` row into
|
|
1357
|
+
an `advise` row wherever it fires: every existing row whose command carries a
|
|
1358
|
+
trailing `&` has its expected column re-derived under the non-monotone rule
|
|
1359
|
+
above, never assumed still correct.
|
|
1360
|
+
|
|
1016
1361
|
`smoke/install.sh` copies the templates into the scratch consumer (guard
|
|
1017
1362
|
and config into the gates dir, hook wiring into `.claude/settings.json`,
|
|
1018
1363
|
log paths gitignored) and then drives one crafted payload directly through
|
|
@@ -1025,7 +1370,14 @@ makes that file conditional on exactly this).
|
|
|
1025
1370
|
same reason, at `gate-tests/compare-settings-allow.test.sh`: a firing probe
|
|
1026
1371
|
(a blanket local glob reported with its witness), a non-firing one (a narrow
|
|
1027
1372
|
entry reporting clean), and the empty-knob silence that proves the section is
|
|
1028
|
-
omitted rather than printed clean
|
|
1373
|
+
omitted rather than printed clean — which, with `GUARD_KIT_BREADTH_DECLARED`
|
|
1374
|
+
empty, also proves the declared subsection absent. The declaration's own cases sit
|
|
1375
|
+
beside them: a declared over-broad entry printing in the declared section with its
|
|
1376
|
+
reason and **not** in the narrowing set; an all-declared over-broad set printing
|
|
1377
|
+
the declared section, no narrowing section and no false clean line; `--count`'s
|
|
1378
|
+
breadth number excluding the declared entry; and an exactness case — a declaration
|
|
1379
|
+
differing from the local entry by one character leaves that entry in the narrowing
|
|
1380
|
+
set, which is the assertion that the lookup never became a glob match. It drives the tool through
|
|
1029
1381
|
`GUARD_KIT_CONFIG_FILE` pointed at a sandbox config, so the consumer's own probe
|
|
1030
1382
|
array cannot leak into the fixture.
|
|
1031
1383
|
|