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.
Files changed (84) hide show
  1. package/README.md +3 -3
  2. package/package.json +2 -2
  3. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
  4. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
  5. package/payload/canon-kit/README.md +2 -0
  6. package/payload/canon-kit/SPEC.md +329 -15
  7. package/payload/canon-kit/checks/check-amendment-update-target.gate +3 -0
  8. package/payload/canon-kit/checks/check-unmarked-claim.gate +3 -0
  9. package/payload/canon-kit/gate-tests/check-amendment-update-target/bad/SPEC-thing.md +26 -0
  10. package/payload/canon-kit/gate-tests/check-amendment-update-target/bad/expect.txt +8 -0
  11. package/payload/canon-kit/gate-tests/check-amendment-update-target/good/SPEC-widget.md +47 -0
  12. package/payload/canon-kit/gate-tests/check-amendment-update-target/good/expect.txt +1 -0
  13. package/payload/canon-kit/gate-tests/check-amendment-update-target.test.sh +82 -0
  14. package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/SPEC.md +11 -0
  15. package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/expect.txt +3 -0
  16. package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/scripts/canon-config.sh +6 -0
  17. package/payload/canon-kit/gate-tests/check-unmarked-claim/good/SPEC.md +18 -0
  18. package/payload/canon-kit/gate-tests/check-unmarked-claim/good/expect.txt +1 -0
  19. package/payload/canon-kit/gate-tests/check-unmarked-claim/good/scripts/canon-config.sh +6 -0
  20. package/payload/canon-kit/gate-tests/check-unmarked-claim.test.sh +85 -0
  21. package/payload/canon-kit/lib/spec.sh +16 -0
  22. package/payload/canon-kit/smoke/install.sh +2 -0
  23. package/payload/canon-kit/templates/SPEC-amendment.md +17 -2
  24. package/payload/context-kit/SPEC.md +16 -5
  25. package/payload/delegation-kit/README.md +11 -1
  26. package/payload/delegation-kit/SPEC.md +392 -26
  27. package/payload/delegation-kit/bin/wait-probe.sh +184 -0
  28. package/payload/delegation-kit/gate-tests/subagent-stop-liveness.test.sh +99 -0
  29. package/payload/delegation-kit/smoke/install.sh +20 -0
  30. package/payload/delegation-kit/templates/agent-execution.md +26 -9
  31. package/payload/delegation-kit/templates/subagent-stop-liveness.sh +56 -0
  32. package/payload/gate-sdk/README.md +7 -2
  33. package/payload/gate-sdk/SPEC.md +800 -66
  34. package/payload/gate-sdk/bin/build-native.sh +66 -1
  35. package/payload/gate-sdk/bin/run-gates.sh +136 -34
  36. package/payload/gate-sdk/checks/check-action-run-shell.sh +1 -1
  37. package/payload/gate-sdk/checks/check-gate-assertions.gate +3 -0
  38. package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +55 -2
  39. package/payload/gate-sdk/checks/check-tree-terms.gate +3 -0
  40. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/expect.txt +5 -1
  41. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/SPEC.md +22 -0
  42. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-count.sh +11 -0
  43. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-extra.sh +14 -0
  44. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-zero.sh +7 -0
  45. package/payload/gate-sdk/gate-tests/check-gate-assertions/good/expect.txt +1 -1
  46. package/payload/gate-sdk/gate-tests/check-gate-assertions/good/scripts/SPEC.md +27 -0
  47. package/payload/gate-sdk/gate-tests/check-gate-assertions/good/scripts/check-qux.sh +13 -0
  48. package/payload/gate-sdk/gate-tests/check-gate-assertions.test.sh +117 -0
  49. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +2 -0
  50. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kit-spec.md +6 -0
  51. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-nospec.sh +4 -0
  52. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-ungrounded.sh +5 -0
  53. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +2 -0
  54. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +1 -1
  55. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kit-spec.md +12 -0
  56. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-held.sh +1 -0
  57. package/payload/gate-sdk/gate-tests/check-tree-terms/bad/expect.txt +5 -0
  58. package/payload/gate-sdk/gate-tests/check-tree-terms/bad/tree/multi.txt +4 -0
  59. package/payload/gate-sdk/gate-tests/check-tree-terms/bad/tree/second-leak.txt +2 -0
  60. package/payload/gate-sdk/gate-tests/check-tree-terms/good/expect.txt +1 -1
  61. package/payload/gate-sdk/gate-tests/check-tree-terms/good/patterns.list +3 -0
  62. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/anchored.txt +4 -0
  63. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/msg-patterns.list +2 -0
  64. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/msg-patterns.local.list +3 -0
  65. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/worktrees/vendored-note.txt +3 -0
  66. package/payload/gate-sdk/gate-tests/check-tree-terms.test.sh +94 -0
  67. package/payload/gate-sdk/smoke/install.sh +23 -0
  68. package/payload/guard-kit/README.md +4 -3
  69. package/payload/guard-kit/SPEC.md +409 -57
  70. package/payload/guard-kit/bin/compare-settings-allow.sh +36 -12
  71. package/payload/guard-kit/bin/run-guard-tests.sh +22 -4
  72. package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +46 -1
  73. package/payload/guard-kit/guard-tests/background-cases.tsv +14 -0
  74. package/payload/guard-kit/guard-tests/cases.tsv +41 -11
  75. package/payload/guard-kit/lib/guard.sh +213 -34
  76. package/payload/guard-kit/templates/bash-guard.sh +2 -0
  77. package/payload/guard-kit/templates/close-triage.md +10 -3
  78. package/payload/guard-kit/templates/guard-config.sh +3 -0
  79. package/payload/lifecycle-kit/SPEC.md +2 -2
  80. package/payload/lifecycle-kit/templates/lead.md +8 -0
  81. package/payload/queue-kit/SPEC.md +78 -0
  82. package/payload/site-kit/SPEC.md +12 -0
  83. package/payload/gate-sdk/checks/check-gate-assertions.sh +0 -149
  84. package/payload/gate-sdk/checks/check-tree-terms.sh +0 -67
@@ -24,15 +24,38 @@ unset _frik_cfg
24
24
  : "${GUARD_KIT_SETTINGS:=.claude/settings.json}"
25
25
  : "${GUARD_KIT_SETTINGS_LOCAL:=.claude/settings.local.json}"
26
26
  declare -p GUARD_KIT_BREADTH_PROBES >/dev/null 2>&1 || GUARD_KIT_BREADTH_PROBES=()
27
+ declare -p GUARD_KIT_BREADTH_DECLARED >/dev/null 2>&1 || declare -A GUARD_KIT_BREADTH_DECLARED=()
27
28
  declare -p GUARD_KIT_RO_SCRIPTS >/dev/null 2>&1 || GUARD_KIT_RO_SCRIPTS=("check-*.sh")
28
29
  declare -p GUARD_KIT_SCRATCH_DIRS >/dev/null 2>&1 || GUARD_KIT_SCRATCH_DIRS=(".tmp")
29
30
  declare -p GUARD_KIT_RO_BINS >/dev/null 2>&1 || GUARD_KIT_RO_BINS=(
30
31
  grep egrep fgrep rg head tail cat wc sort uniq cut tr nl rev tac paste comm column diff jq find ls xargs
31
32
  )
33
+ declare -p GUARD_KIT_APPEND_BINS >/dev/null 2>&1 || GUARD_KIT_APPEND_BINS=(cat printf echo)
32
34
 
35
+ # spec: guard-kit/SPEC.md §The guard framework — the payload cache: called directly (never in a substitution, which would kill the global with its subshell) so a rule needing a second field can have one
36
+ guard_read_input() {
37
+ GUARD_INPUT="$(cat 2>/dev/null)" || return 1
38
+ [[ -n "$GUARD_INPUT" ]] || return 1
39
+ return 0
40
+ }
41
+
42
+ # spec: guard-kit/SPEC.md §The guard framework — one field of the cached payload by jq path; an unset or empty GUARD_INPUT and an absent path alike print nothing, which is what keeps a guard that never opted in working unchanged
43
+ guard_input_field() {
44
+ local v
45
+ [[ -n "${GUARD_INPUT:-}" ]] || return 0
46
+ v="$(printf '%s' "$GUARD_INPUT" | jq -r "$1" 2>/dev/null)" || return 0
47
+ [[ "$v" == "null" ]] && return 0
48
+ printf '%s' "$v"
49
+ }
50
+
51
+ # spec: guard-kit/SPEC.md §The guard framework — GUARD_INPUT first, stdin otherwise: the fallback is what keeps every consumer copy that never opted in byte-identical
33
52
  guard_read_command() {
34
53
  local input cmd
35
- input="$(cat 2>/dev/null)" || return 1
54
+ if [[ -n "${GUARD_INPUT:-}" ]]; then
55
+ input="$GUARD_INPUT"
56
+ else
57
+ input="$(cat 2>/dev/null)" || return 1
58
+ fi
36
59
  cmd="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null)" || return 1
37
60
  [[ -z "$cmd" ]] && return 1
38
61
  printf '%s' "$cmd"
@@ -41,7 +64,11 @@ guard_read_command() {
41
64
  # spec: guard-kit/SPEC.md §The guard framework — the path counterpart of guard_read_command; a call carrying no file_path returns non-zero so a matcher covering it falls through instead of blocking
42
65
  guard_read_path() {
43
66
  local input path
44
- input="$(cat 2>/dev/null)" || return 1
67
+ if [[ -n "${GUARD_INPUT:-}" ]]; then
68
+ input="$GUARD_INPUT"
69
+ else
70
+ input="$(cat 2>/dev/null)" || return 1
71
+ fi
45
72
  path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty' 2>/dev/null)" || return 1
46
73
  [[ -z "$path" ]] && return 1
47
74
  printf '%s' "$path"
@@ -219,12 +246,12 @@ guard_skeleton() {
219
246
  printf '%s' "$out"
220
247
  }
221
248
 
222
- # spec: guard-kit/SPEC.md §The guard framework — one splitter for every consumer that reasons per compound segment (rules 8/12/14/16/17/19, the read-compound carve-out, scan-prompts), fed a guard_skeleton view so the harness's per-segment boundary set never drifts
249
+ # spec: guard-kit/SPEC.md §The guard framework — one splitter for every consumer that reasons per compound segment (rules 8/12/14/15/17/18/19/21, the read-compound carve-out, scan-prompts), fed a guard_skeleton view so the harness's per-segment boundary set never drifts
223
250
  guard_split_compound() {
224
251
  sed -E 's/\|\||&&|;|\|/\n/g' <<<"$1"
225
252
  }
226
253
 
227
- # spec: guard-kit/SPEC.md §The generic ruleset — the committed Bash(...) allow inners, one per line; the fail-open read rules 16 and 17 share, so a missing jq or settings file emits nothing and every reader declines
254
+ # spec: guard-kit/SPEC.md §The generic ruleset — the committed Bash(...) allow inners, one per line; the fail-open read rules 18 and 19 share, so a missing jq or settings file emits nothing and every reader declines
228
255
  _guard_allow_inners() {
229
256
  command -v jq >/dev/null 2>&1 || return 0
230
257
  [[ -f "$GUARD_KIT_SETTINGS" ]] || return 0
@@ -238,7 +265,7 @@ _guard_allow_inners() {
238
265
  done < <(jq -r '.permissions.allow[]?' "$GUARD_KIT_SETTINGS" 2>/dev/null)
239
266
  }
240
267
 
241
- # spec: guard-kit/SPEC.md §The generic ruleset — a segment with its redirects removed and trimmed: what rules 16 and 17 compare against a committed bare allow entry
268
+ # spec: guard-kit/SPEC.md §The generic ruleset — a segment with its redirects removed and trimmed: what rules 18 and 19 compare against a committed bare allow entry
242
269
  _guard_segment_core() {
243
270
  local seg
244
271
  seg="$(sed -E 's/[[:space:]]*[0-9]*(>>?|<)[[:space:]]*(&?[0-9-]+|[^[:space:]]+)?//g' <<<"$1")"
@@ -247,7 +274,7 @@ _guard_segment_core() {
247
274
  printf '%s' "$seg"
248
275
  }
249
276
 
250
- # spec: guard-kit/SPEC.md §The generic ruleset — true when the segment exactly matches a committed *bare* allow entry (no glob): the reviewed-lead half of rule 16's predicate and rule 17's lead test
277
+ # spec: guard-kit/SPEC.md §The generic ruleset — true when the segment exactly matches a committed *bare* allow entry (no glob): the reviewed-lead half of rule 18's predicate and rule 19's lead test
251
278
  _guard_is_bare_allow() {
252
279
  local core bl
253
280
  core="$(_guard_segment_core "$1")"
@@ -406,7 +433,7 @@ _guard_is_cat_read() {
406
433
  [[ "$operands" == 1 ]]
407
434
  }
408
435
 
409
- # spec: guard-kit/SPEC.md §The generic ruleset — rule 16's xargs discriminator: xargs runs a command rather than filtering text, so the segment is read-only only when the command it runs is itself on the roster
436
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 18's xargs discriminator: xargs runs a command rather than filtering text, so the segment is read-only only when the command it runs is itself on the roster
410
437
  _guard_is_ro_xargs() {
411
438
  local seg="${1#"${1%%[![:space:]]*}"}" tok want_arg=0 cmdtok='' b i n
412
439
  local -a toks
@@ -574,32 +601,47 @@ guard_rule_pgrep_self_match() {
574
601
  done < <(guard_split_compound "$raw" | tr '&' '\n')
575
602
  }
576
603
 
577
- # spec: guard-kit/SPEC.md §The generic ruleset — rule 13's loop-wrapper span: 'until <cond>; do sleep N; done' is the sanctioned wait, so only a sleep outside every do…done span fires, and an unresolvable span declines
578
- guard_rule_bare_sleep() {
579
- local raw="$1" s tok depth=0 cmdpos=1 bare=0
580
- grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
581
- case "$raw" in *'`'*) return 0 ;; esac
582
- s="$(guard_skeleton "$raw" sq dq hd)"
583
- s="$(tr '\n' ';' <<<"$s" | sed -E 's/(\|\||&&|;|\||&|\(|\)|\{|\})/ \1 /g')"
604
+ # spec: guard-kit/SPEC.md §The generic ruleset — the ruleset's one shell-keyword walk, shared by rules 13 and 15: emits '<depth> <cmdpos> <token>' per skeleton token and returns non-zero on an unbalanced do/done so both callers decline rather than guess
605
+ _guard_loop_span() {
606
+ local s tok depth=0 cmdpos=1
607
+ s="$(tr '\n' ';' <<<"$1" | sed -E 's/(\|\||&&|;|\||&|\(|\)|\{|\})/ \1 /g')"
584
608
  local -a toks
585
609
  read -ra toks <<<"$s"
586
610
  for tok in "${toks[@]}"; do
587
611
  case "$tok" in
588
- ';' | '|' | '||' | '&&' | '&' | '(' | ')' | '{' | '}') cmdpos=1 ;;
589
- '!' | until | while | if | then | else | elif | for) cmdpos=1 ;;
590
- do) depth=$((depth + 1)); cmdpos=1 ;;
612
+ ';' | '|' | '||' | '&&' | '&' | '(' | ')' | '{' | '}' | \
613
+ '!' | until | while | if | then | else | elif | for)
614
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
615
+ cmdpos=1 ;;
616
+ do)
617
+ depth=$((depth + 1))
618
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
619
+ cmdpos=1 ;;
591
620
  done)
592
621
  depth=$((depth - 1))
593
- [[ "$depth" -lt 0 ]] && return 0
622
+ [[ "$depth" -lt 0 ]] && return 1
623
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
594
624
  cmdpos=1 ;;
595
- sleep)
596
- [[ "$cmdpos" == 1 && "$depth" == 0 ]] && bare=1
625
+ *)
626
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
597
627
  cmdpos=0 ;;
598
- *) cmdpos=0 ;;
599
628
  esac
600
629
  done
601
- [[ "$depth" == 0 && "$bare" == 1 ]] || return 0
602
- guard_block "don't wait by sleeping in the foreground — a wait must end when its condition goes true, not when a duration expires, and a foreground sleep spends a full-price turn doing nothing. Background a command that *exits* on the condition ('run_in_background' wrapping 'until <cond>; do sleep N; done') and take its completion notification: it fires the moment the condition holds and then ends. A dispatched agent is awaited by its own completion notification and never by a path on disk. The harness's event-stream form stays armed to its deadline even after its event fires, so it is the wrong tool for a single completion. A sleep inside a condition loop is untouched — that is the sanctioned form. If you genuinely need the settle, run it yourself with !<command>."
630
+ [[ "$depth" -eq 0 ]]
631
+ }
632
+
633
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 13's loop-wrapper span: 'until <cond>; do sleep N; done' is the sanctioned wait, so only a sleep outside every do…done span fires, and an unresolvable span declines
634
+ guard_rule_bare_sleep() {
635
+ local raw="$1" s span depth cmdpos tok bare=0
636
+ grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
637
+ case "$raw" in *'`'*) return 0 ;; esac
638
+ s="$(guard_skeleton "$raw" sq dq hd)"
639
+ span="$(_guard_loop_span "$s")" || return 0
640
+ while read -r depth cmdpos tok; do
641
+ [[ "$tok" == sleep && "$cmdpos" == 1 && "$depth" == 0 ]] && bare=1
642
+ done <<<"$span"
643
+ [[ "$bare" == 1 ]] || return 0
644
+ guard_block "don't wait by sleeping in the foreground — a wait must end when its condition goes true, not when a duration expires, and a foreground sleep spends a full-price turn doing nothing. Background a command that *exits* on the condition ('run_in_background' wrapping 'until <cond>; do sleep N; done') and take its completion notification: it fires the moment the condition holds and then ends. A dispatched agent is awaited by its own completion notification and never by a path on disk. The harness's event-stream form stays armed to its deadline after its event fires when the command it was armed with is unbounded, so it is the second choice for a single completion. Mind the polarity: 'until' takes a done predicate ('until [ -f marker ]'), while a PID's liveness is a still-running one and takes 'while' ('while kill -0 \"\$pid\" 2>/dev/null; do sleep N; done') — inverted, the loop exits at once with the producer still running. A sleep inside a condition loop is untouched — that is the sanctioned form. If you genuinely need the settle, run it yourself with !<command>."
603
645
  }
604
646
 
605
647
  # spec: guard-kit/SPEC.md §The generic ruleset — rule 14's record reader: the one-line 'pid=<n> run=<key>' grammar is evidence-kit/SPEC.md §The producer-liveness lock's and is read rather than sourced, because a PreToolUse hook cannot depend on a sibling kit being vendored; a record that does not parse yields nothing, so the rule declines on one
@@ -670,6 +712,76 @@ guard_rule_git_mutation_under_producer() {
670
712
  guard_block "don't run '${writes[0]}' while a producer you recorded is still running — ${list%; } names a live pid, and a tracked-tree mutation under a live producer is what the wait rule exists to prevent: the run is still writing, so a commit taken now dirties the worktree underneath it and its verdict has to be discarded and re-run. Two exits, both cheap: wait for that producer on its own artifact (loop on the recorded pid's liveness, 'until ! kill -0 <pid> 2>/dev/null; do sleep 5; done', backgrounded so its completion notifies you), or — if the producer has already exited — delete its .run file, which is not a workaround but the statement of fact becoming false and being retracted. Read-only git ('status', 'log', 'diff', 'show') is untouched. If you genuinely need this mutation now, run it yourself with !<command>."
671
713
  }
672
714
 
715
+ # spec: guard-kit/SPEC.md §The generic ruleset — every redirect target in a skeleton, one per line: the corpus rules 15 and 18 both read
716
+ _guard_redirect_targets() {
717
+ grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]|;&]+' <<<"$1" \
718
+ | sed -E 's/^[0-9]*>>?[[:space:]]*//'
719
+ }
720
+
721
+ # spec: guard-kit/SPEC.md §The generic ruleset — the read-only-segment test rules 15 and 18 share, xargs discriminator included because xargs runs a command rather than filtering text
722
+ _guard_is_ro_segment() {
723
+ local seg="${1#"${1%%[![:space:]]*}"}" first b
724
+ first="${seg%%[[:space:]]*}"
725
+ [[ -n "$first" ]] || return 1
726
+ [[ "$first" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 1; }
727
+ for b in "${GUARD_KIT_RO_BINS[@]}"; do
728
+ [[ "$first" == "$b" ]] && return 0
729
+ done
730
+ return 1
731
+ }
732
+
733
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 15's shell arm: a statement-ending bare '&' in the skeleton, never the '&&' operator and never a redirect's fd-dup
734
+ _guard_shell_backgrounds() {
735
+ grep -qE '(^|[^&>])&([[:space:]]|;|$)' <<<"$1"
736
+ }
737
+
738
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 15's record-writing test: at PreToolUse the child has not started and no record can exist yet, so the only observable is whether the launch is going to write one
739
+ _guard_writes_run_record() {
740
+ local d tgt
741
+ while read -r tgt; do
742
+ case "$tgt" in *.run) ;; *) continue ;; esac
743
+ for d in ${GUARD_KIT_SCRATCH_DIRS[@]+"${GUARD_KIT_SCRATCH_DIRS[@]}"}; do
744
+ case "$tgt" in "$d"/*) return 0 ;; esac
745
+ done
746
+ done < <(_guard_redirect_targets "$1")
747
+ return 1
748
+ }
749
+
750
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 15's exemption 3: a child that writes nothing has nothing for a later commit to corrupt, so it owes no record
751
+ _guard_is_ro_background() {
752
+ local s="$1" tgt seg reads=0
753
+ while read -r tgt; do
754
+ case "$tgt" in
755
+ /dev/null | '&'[0-9]*) ;;
756
+ *) return 1 ;;
757
+ esac
758
+ done < <(_guard_redirect_targets "$s")
759
+ while IFS= read -r seg; do
760
+ seg="${seg#"${seg%%[![:space:]]*}"}"
761
+ [[ -z "$seg" ]] && continue
762
+ _guard_is_banner "$seg" && continue
763
+ _guard_is_ro_segment "$seg" || return 1
764
+ reads=$((reads + 1))
765
+ done < <(guard_split_compound "$s")
766
+ [[ "$reads" -ge 1 ]]
767
+ }
768
+
769
+ guard_rule_background_no_record() {
770
+ local raw="$1" s span depth cmdpos tok
771
+ grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
772
+ case "$raw" in *'`'*) return 0 ;; esac
773
+ s="$(guard_skeleton "$raw" sq dq hd)"
774
+ [[ "$(guard_input_field '.tool_input.run_in_background')" == "true" ]] \
775
+ || _guard_shell_backgrounds "$s" || return 0
776
+ _guard_writes_run_record "$s" && return 0
777
+ span="$(_guard_loop_span "$s")" || return 0
778
+ while read -r depth cmdpos tok; do
779
+ [[ "$depth" -ge 1 ]] && return 0
780
+ done <<<"$span"
781
+ _guard_is_ro_background "$s" && return 0
782
+ guard_advise "this call backgrounds a child and writes no liveness record — write one at the launch, in the same command: a single line 'pid=<n> run=<key>' in a '<key>.run' file under your gitignored scratch dir (e.g. ${GUARD_KIT_SCRATCH_DIRS[0]}/<key>.run), naming the PID you just backgrounded. The record buys two things nothing else does: it is what gives the tracked-tree-mutation rule its reach, so a commit taken while this child is still writing is refused rather than silently taken; and it is what lets the next arrival tell whether the producer is still writing instead of guessing at a process table. Delete it once the producer has exited, and not before — a record naming a dead pid blocks nothing, and one deleted early buys the harm back. A backgrounded wait loop and a backgrounded read-only pipeline own no work a commit could corrupt and owe no record."
783
+ }
784
+
673
785
  guard_rule_truncate_scratch() {
674
786
  local cmd
675
787
  cmd="$(guard_skeleton "$1" sq dq hd)"
@@ -686,6 +798,77 @@ guard_rule_truncate_scratch() {
686
798
  fi
687
799
  }
688
800
 
801
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 17's redirect scan, operator and target together and fd-dups included: _guard_redirect_targets' target class excludes '&', so it drops an fd-dup target entirely and a rule that must exempt one cannot see it there
802
+ _guard_redirect_pairs() {
803
+ grep -oE '[0-9]*>>?[[:space:]]*(&[0-9-]+|[^[:space:]|;&<>]+)' <<<"$1"
804
+ }
805
+
806
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 17's single-statement test: guard_skeleton leaves a heredoc's body placeholder and terminator on lines of their own and guard_split_compound emits per line, so one statement is one segment plus exactly the residue that segment's own openers produce, never one segment
807
+ _guard_only_heredoc_residue() {
808
+ local -a segs=() terms=()
809
+ local t seg i=1
810
+ mapfile -t segs < <(guard_split_compound "$1")
811
+ [[ "${#segs[@]}" -ge 1 ]] || return 1
812
+ while IFS= read -r t; do
813
+ t="${t#*<<}"
814
+ t="${t#-}"
815
+ t="${t#"${t%%[![:space:]]*}"}"
816
+ t="${t#[\"\']}"
817
+ t="${t%[\"\']}"
818
+ terms+=("$t")
819
+ done < <(grep -oE '<<-?[[:space:]]*("[^"]*"|'\''[^'\'']*'\''|[A-Za-z_][A-Za-z0-9_]*)' <<<"${segs[0]}")
820
+ for t in ${terms[@]+"${terms[@]}"}; do
821
+ seg="${segs[i]:-}"
822
+ seg="${seg#"${seg%%[![:space:]]*}"}"
823
+ if [[ "$seg" == HD ]]; then
824
+ ((i++))
825
+ seg="${segs[i]:-}"
826
+ seg="${seg#"${seg%%[![:space:]]*}"}"
827
+ fi
828
+ [[ "$seg" == "$t" ]] || return 1
829
+ ((i++))
830
+ done
831
+ [[ "$i" -eq "${#segs[@]}" ]]
832
+ }
833
+
834
+ guard_rule_append_scratch() {
835
+ local raw="$1" s
836
+ # spec: guard-kit/SPEC.md §The guard framework — the raw-command carve-out every auto-allow rule takes; rule 6 blocks three of the four substitution spellings and exits 2 first, but not the output-process-substitution one, and a grant may not rest on a coverage claim that is only mostly true
837
+ grep -qE '\$\(|<\(|>\(' <<<"$raw" && return 0
838
+ case "$raw" in *'`'*) return 0 ;; esac
839
+ s="$(guard_skeleton "$raw" sq dq hd)"
840
+ _guard_shell_backgrounds "$s" && return 0
841
+ _guard_only_heredoc_residue "$s" || return 0
842
+
843
+ local lead b on_roster=0
844
+ lead="${s%%$'\n'*}"
845
+ lead="${lead#"${lead%%[![:space:]]*}"}"
846
+ lead="${lead%%[[:space:]]*}"
847
+ for b in "${GUARD_KIT_APPEND_BINS[@]}"; do
848
+ [[ "$lead" == "$b" ]] && { on_roster=1; break; }
849
+ done
850
+ [[ "$on_roster" == 1 ]] || return 0
851
+
852
+ local pair op tgt
853
+ local -a targets=()
854
+ while IFS= read -r pair; do
855
+ [[ -z "$pair" ]] && continue
856
+ pair="${pair#"${pair%%[!0-9]*}"}"
857
+ if [[ "$pair" == '>>'* ]]; then op='>>'; tgt="${pair#>>}"; else op='>'; tgt="${pair#>}"; fi
858
+ tgt="${tgt#"${tgt%%[![:space:]]*}"}"
859
+ case "$tgt" in /dev/null | '&'[0-9-]*) continue ;; esac
860
+ case "$tgt" in *[\"\']*) return 0 ;; esac
861
+ [[ "$op" == '>>' ]] || return 0
862
+ targets+=("$tgt")
863
+ done < <(_guard_redirect_pairs "$s")
864
+ [[ "${#targets[@]}" -ge 1 ]] || return 0
865
+
866
+ for tgt in "${targets[@]}"; do
867
+ git check-ignore --quiet -- "$tgt" || return 0
868
+ done
869
+ guard_allow "append to gitignored scratch (${GUARD_NAME:-guard} auto-allow)"
870
+ }
871
+
689
872
  guard_rule_ro_pipeline() {
690
873
  local raw="$1"
691
874
  # spec: guard-kit/SPEC.md §The guard framework — the raw-command carve-out these two tests take
@@ -702,28 +885,22 @@ guard_rule_ro_pipeline() {
702
885
  /dev/null | '&'[0-9]*) ;;
703
886
  *) return 0 ;;
704
887
  esac
705
- done < <(grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]|;&]+' <<<"$s" \
706
- | sed -E 's/^[0-9]*>>?[[:space:]]*//')
888
+ done < <(_guard_redirect_targets "$s")
707
889
  if grep -qE '(^|[[:space:]])find([[:space:]]|$)' <<<"$s" \
708
890
  && grep -qE '\-(exec|execdir|ok|delete)\b' <<<"$s"; then
709
891
  return 0
710
892
  fi
711
893
  local -a segs
712
894
  mapfile -t segs < <(guard_split_compound "$s")
713
- local seg first b i matched reads=0
895
+ local seg i reads=0
714
896
  for ((i = 0; i < ${#segs[@]}; i++)); do
715
897
  seg="${segs[i]}"
716
898
  seg="${seg#"${seg%%[![:space:]]*}"}"
717
899
  [[ -z "$seg" ]] && continue
718
900
  _guard_is_banner "$seg" && continue
719
- first="${seg%%[[:space:]]*}"
720
- [[ "$first" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 0; }
721
- matched=0
722
- for b in "${GUARD_KIT_RO_BINS[@]}"; do
723
- [[ "$first" == "$b" ]] && { matched=1; break; }
724
- done
725
- if [[ "$matched" == 0 ]]; then
726
- # spec: guard-kit/SPEC.md §The generic ruleset — rule 16's widened lead: a bare
901
+ [[ "${seg%%[[:space:]]*}" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 0; }
902
+ if ! _guard_is_ro_segment "$seg"; then
903
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 18's widened lead: a bare
727
904
  # committed allow entry qualifies, but only where something decorates it
728
905
  [[ "$i" == 0 && "${#segs[@]}" -gt 1 ]] || return 0
729
906
  _guard_is_bare_allow "$seg" || return 0
@@ -827,7 +1004,9 @@ guard_generic_rules() {
827
1004
  guard_rule_pgrep_self_match "$cmd"
828
1005
  guard_rule_bare_sleep "$cmd"
829
1006
  guard_rule_git_mutation_under_producer "$cmd"
1007
+ guard_rule_background_no_record "$cmd"
830
1008
  guard_rule_truncate_scratch "$cmd"
1009
+ guard_rule_append_scratch "$cmd"
831
1010
  guard_rule_ro_pipeline "$cmd"
832
1011
  guard_rule_allowlist_chain "$cmd"
833
1012
  guard_rule_git_rewrite "$cmd"
@@ -9,6 +9,8 @@ GUARD_KIT_LIB="${GUARD_KIT_LIB:-guard-kit/lib/guard.sh}"
9
9
  # shellcheck source=/dev/null # vendored lib path is resolved at runtime; fail-open above if absent, but the lib's own exit 2 (set-but-missing config) must stay loud
10
10
  source "$GUARD_KIT_LIB"
11
11
 
12
+ # spec: guard-kit/SPEC.md §The guard framework — cache the payload before the first field is read, so a rule needing a tool-input field beyond the command can reach one
13
+ guard_read_input || exit 0
12
14
  cmd="$(guard_read_command)" || exit 0
13
15
 
14
16
  # spec: guard-kit/SPEC.md §Consumer rules — add project block/steer/allow rules here (compose guard.sh primitives), before the generic ruleset [EDIT ME]
@@ -27,11 +27,18 @@ of lifecycle-kit's `tooling-friction triage` placeholder (close skill, step 2).
27
27
  each has its own disposition.
28
28
  - **Redundant**: remove every listed `settings.local.json` entry (a committed
29
29
  glob already grants it).
30
- - **Too broad**: for every entry the breadth report names, either narrow the
31
- glob or record that its breadth is intended. The probe printed beside it is
32
- the witness — the command that glob auto-allows. An empty breadth report is
30
+ - **Too broad**: for every entry the report lists as a *narrowing candidate*,
31
+ either narrow the glob or record that its breadth is intended — as a
32
+ `GUARD_KIT_BREADTH_DECLARED` entry (glob plus reason) in the committed
33
+ `guard-config.sh`, which moves it into the report's *declared intended*
34
+ section and stops it re-reporting. A per-clone note does not: the ruling is
35
+ durable only where it is tracked. The probe printed beside an entry is the
36
+ witness — the command that glob auto-allows. An empty breadth report is
33
37
  not a proof of narrowness: probes are witnesses, and no completeness is
34
38
  claimed (the section is absent entirely when no probes are declared).
39
+ Read the declared section too — it is the record of what was ruled, and a
40
+ declaration whose glob is gone from the overlay is spent and should be
41
+ dropped.
35
42
 
36
43
  - **Not content-pinned**: an entry naming a *script path* rather than a fixed
37
44
  command grants whatever that file says at run time, so its meaning changes
@@ -3,3 +3,6 @@
3
3
 
4
4
  # spec: guard-kit/SPEC.md §compare-settings-allow — declare your own probes; the kit ships none
5
5
  # GUARD_KIT_BREADTH_PROBES=("Bash(rm -rf /)")
6
+
7
+ # spec: guard-kit/SPEC.md §compare-settings-allow — a breadth ruled intended, keyed on the exact local allow-rule string; the kit ships no declarations either
8
+ # declare -A GUARD_KIT_BREADTH_DECLARED=(["Bash(mytool *)"]="every subcommand is read-only")
@@ -1909,7 +1909,7 @@ exit 1). The stale-block report prints **every** hunk: the format and the
1909
1909
  uncapped contract are the crate renderer's, whose home is
1910
1910
  gate-sdk/SPEC.md §The diff renderer since it stopped being this gate's private
1911
1911
  mechanism, and this gate is its one live consumer. Resolution fails closed: a missing agent file, a begin marker without
1912
- its end, or an errored awk capture is exit 2 — a half-written or unreadable
1912
+ its end, or an errored marker capture is exit 2 — a half-written or unreadable
1913
1913
  target must not pass as clean. The gate satisfies the four gate-sdk contracts
1914
1914
  (gate-sdk/SPEC.md §The gate model): the single `LIFECYCLE-REGISTRATION: clean`
1915
1915
  line and a `help:` remedy on each finding path (output); exit 2 on an
@@ -2604,7 +2604,7 @@ slot's content:
2604
2604
  you own the ritual prose, an upgrade's re-vendor does not reach it, and the
2605
2605
  shim gates do not cover it. It is kept deliberately — the blessed escape hatch
2606
2606
  that keeps legitimate structural divergence (different stages, a reshaped
2607
- machine) visible and contained, and the harness-agnostic floor the bare-bash
2607
+ machine) visible and contained, and the harness-agnostic floor the
2608
2608
  upgrade smoke assumes; removing it would drive forks into edits of the
2609
2609
  vendored template, which break Phase-A upgrade determinism with no gate to
2610
2610
  catch them.
@@ -208,6 +208,14 @@ resumed, the lead answers from the governed surfaces the rulings already live
208
208
  in — the amendments, the queue entries — and a question not derivable there
209
209
  goes to the operator, never substituted by the lead's own judgment.
210
210
 
211
+ **A split ask arrives with its own test already applied.** A session the queue's
212
+ per-entry cap blocks may ask to split the entry, and that ask carries the
213
+ session's statement of which side of `queue-kit/SPEC.md`
214
+ §check-queue-entry-budget's split test its entry falls on. The lead rules against
215
+ that test rather than re-deriving one; the authorization stays the lead's, on
216
+ that section's own ground — a new entry is a new unit competing for the scope
217
+ attention that ranks both.
218
+
211
219
  **One class the lead never rules, under either posture.** Reversing, demoting
212
220
  or re-scoping a **recorded operator ruling** or a stated objective is
213
221
  operator-class: the lead relays it, however well-grounded the escalating
@@ -1061,6 +1061,14 @@ name against that arm's standing no-fourth-mode refusal, where this
1061
1061
  exposure spends nothing beyond a print at the compiled assertion's existing
1062
1062
  computation.
1063
1063
 
1064
+ **No collision counter is minted either, and this line is where that decision is
1065
+ recorded** rather than left as the absence of one. A count of how often the cap
1066
+ displaced a mandated write would be a second measurement of a quantity this
1067
+ headroom line already prints, maintained by hand, against a criterion (the split
1068
+ test below) that reads an entry's *composition* rather than its collision
1069
+ history. What a firing count would have been evidence for, the split criterion
1070
+ decides directly.
1071
+
1064
1072
  *Why one `recurrence:` line is discounted, and why exactly one.* The line is
1065
1073
  **fixed-shape and width-bounded** — §The tag algebra rules its ceiling to be
1066
1074
  `check-queue-wrap`'s budget and rules reaching that ceiling the *correct*
@@ -1128,6 +1136,76 @@ contract — and that third relief is **two acts wearing one name**.
1128
1136
  (lifecycle-kit/SPEC.md §check-stage-entry), and the gate's failure text
1129
1137
  therefore cites this section rather than inlining the recipe.
1130
1138
 
1139
+ **An entry is a split candidate when it carries two or more deliverables that
1140
+ can take different dispositions** — where *different dispositions* means one
1141
+ could be promoted, deferred, declined or closed while the other stays open. The
1142
+ test is executed by reading the entry's deliverable statements and asking
1143
+ whether ruling one leaves the other unruled. If it does, the entry is two units
1144
+ wearing one slug, and its grounds are two ground-sets sharing one cap.
1145
+
1146
+ **The counter-class is what makes it a class**, and it is stated with the
1147
+ criterion rather than left to inference: an entry accumulating **further
1148
+ grounds for one deliverable** — recurrence evidence, a repeated measurement, an
1149
+ answered objection, a corroborating firing — is **not** a split candidate
1150
+ however hard it collides. Those are one unit's history, and splitting them
1151
+ mints exactly the ranking peer competing with its own parent that the
1152
+ two-acts paragraph below names as the sharpest displacement shape. Compression
1153
+ by answering is the correct relief there and stays the default.
1154
+
1155
+ *Why dispositionability, and not size, age or ruling-count.* **Size** is the cap
1156
+ itself, so it would make the criterion circular. **Age** is refuted by the
1157
+ measurements a colliding pool actually produces — the collider is the most
1158
+ recently ruled-on entry rather than the longest-lived, which is the opposite of
1159
+ what a first reading of a collision log suggests. **Ruling-count** is the near
1160
+ miss and the one worth stating, because collisions genuinely do concentrate
1161
+ where rulings accumulate; it is refused because it is a **symptom shared by
1162
+ both classes**. An entry accumulating rulings on one deliverable collides
1163
+ exactly as hard as one accumulating rulings on two, so a criterion that cannot
1164
+ separate them licenses the split that mints a competing peer. Dispositionability
1165
+ separates them and is decidable by inspection, which is what an authoring
1166
+ contract needs.
1167
+
1168
+ **The criterion is read at the collision, and it is an input to the
1169
+ authorization rather than a licence.** The blocked session states which side of
1170
+ the test its entry falls on when it asks; the authorizing session rules with
1171
+ that statement in front of it. What changes is the **shape of the ask**, never
1172
+ who answers it. Without a test the authorizing session has only the blocked
1173
+ session's summary of its own entry, so the answer is a judgment call re-derived
1174
+ per firing — which is the mechanism behind the pattern a collision log shows:
1175
+ relief was always available, so the question was always answered by the
1176
+ cheapest relief rather than by composition. **A denied split is not a dead
1177
+ end**, stated so the criterion does not read as gating relief: an entry that
1178
+ fails the test still has compression by answering and the self-served
1179
+ relocation, which are the reliefs it should have been using, and an entry that
1180
+ passes and is denied anyway gets the denial's ground recorded on it as any
1181
+ other ruling would be.
1182
+
1183
+ **An authorized split records itself through the citation grammar already
1184
+ here** — the parent names the child and the child names the parent, each with
1185
+ the single-backticked slug §The tag algebra already rules a citation. A
1186
+ `split-of:` declaration is refused on exactly the ground `relocated:` is
1187
+ refused on above, so the two refusals read as one rule: it would cost a counted
1188
+ line against this very cap, on the two entries least able to pay it — the
1189
+ parent that just overflowed and the child carrying what would not fit. The
1190
+ backticked slug costs no line of its own, because it rides prose the split is
1191
+ writing anyway. **Bidirectional rather than child-to-parent alone**, because
1192
+ the failure a one-way citation leaves is the one this whole class is about: a
1193
+ reader meeting the **parent** sees an entry whose deliverable set silently
1194
+ shrank, with no surviving statement of what left or why, and re-derives the
1195
+ missing half as a gap — the same information loss the compression rule forbids,
1196
+ arriving through a split instead of through a deletion.
1197
+
1198
+ **The pair is an aggregated edge only while both slugs are live**, on §The tag
1199
+ algebra's resolution rule, and the bound is stated because the parent is the
1200
+ end that reaches it first: a `## Done` entry is a bare slug, so it leaves the
1201
+ live set and takes the parent's citation with the rest of its prose, and the
1202
+ edge silently stops being an edge. That is the correct outcome rather than a
1203
+ loss — the parent-side citation exists to stop a *live* parent reading as an
1204
+ entry whose deliverable set shrank, and a completed parent has no open
1205
+ deliverable set to misread. What it means is that the split's durable record is
1206
+ the **child's** citation, and the parent's is owed for exactly as long as the
1207
+ parent is open.
1208
+
1131
1209
  *Why the line falls between the two acts.* Grounds are not rankable work, so
1132
1210
  moving them into an entry that already owns their subject mints no ranking peer;
1133
1211
  a new entry *is* a new unit, competing for the scope attention that ranks both,
@@ -237,6 +237,18 @@ consumer registers this gate; it stays outside env-probe's probe-set floor, and
237
237
  published docs site simply omits the gate by the registry-not-array convention
238
238
  and never installs the dependency.
239
239
 
240
+ **This member is held on shell, and the hop from its declaration lands here.** The
241
+ program the rule requires is the **first element of `SITE_KIT_RENDERER`**, so
242
+ gate-sdk's criterion 7 blocks the port, and the blocker is class (i) under that
243
+ criterion's hold-worthiness test: the renderer *is* the contract this gate renders
244
+ through, so removing it changes the verdict and designing it away means
245
+ re-deciding the rule. The declaration therefore carries `# port-until:` naming the
246
+ queue entry that owns the blocker (gate-sdk/SPEC.md §The `# graph:` manifest). The
247
+ dependency itself, and the fact that a consumer who repoints the knob moves it, are
248
+ owned at §Layout and configuration under that knob and are not restated here — the
249
+ knob's value is what the blocker is a property of, so that bullet is its right home
250
+ and this paragraph is the pointer a reader arriving from the declaration needs.
251
+
240
252
  **The batch stream, and why the count is the fail-closed.** One renderer process
241
253
  per page is the gate's whole cost — the interpreter restarts, not the rendering —
242
254
  so where `SITE_KIT_RENDERER_BATCH` is non-empty the gate renders the corpus over