checkwright 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/payload/canon-kit/SPEC.md +2 -2
- package/payload/canon-kit/checks/check-md-refs.sh +22 -9
- package/payload/canon-kit/checks/check-spec-pointer.sh +6 -2
- package/payload/context-kit/SPEC.md +13 -6
- package/payload/context-kit/lib/toolfloor.sh +1 -1
- package/payload/delegation-kit/README.md +2 -1
- package/payload/delegation-kit/SPEC.md +207 -35
- package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +61 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/agents/silent.md +7 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/args +1 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/expect.txt +1 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-cheap.md +7 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-inherit.md +8 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/args +1 -0
- package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/expect.txt +1 -0
- package/payload/delegation-kit/lib/delegation.sh +2 -0
- package/payload/delegation-kit/smoke/install.sh +1 -0
- package/payload/delegation-kit/templates/agent-execution.md +74 -9
- package/payload/gate-sdk/SPEC.md +6 -5
- package/payload/gate-sdk/bin/gen-pre-commit.sh +1 -1
- package/payload/gate-sdk/bin/run-gates.sh +1 -1
- package/payload/gate-sdk/checks/check-graph.sh +3 -3
- package/payload/gate-sdk/checks/check-reads-couples.sh +3 -1
- package/payload/gate-sdk/checks/check-tree-terms.sh +11 -7
- package/payload/gate-sdk/lib/gate.sh +29 -13
- package/payload/lifecycle-kit/SPEC.md +14 -4
- package/payload/lifecycle-kit/templates/lead.md +38 -3
- package/payload/site-kit/SPEC.md +104 -12
- package/payload/site-kit/checks/check-docs-render-fidelity.sh +100 -27
- package/payload/site-kit/gate-tests/check-docs-render-fidelity-batch.test.sh +158 -0
- package/payload/site-kit/lib/site.sh +16 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "checkwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Vendors pinned Checkwright kit source into your repository and commits it — a coding-agent-assisted delivery methodology (gate SDK, evidence-stamped lifecycle, agent context economics).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"checkwright": {
|
|
22
|
-
"commit": "
|
|
22
|
+
"commit": "97b50392d51cd399deba4771f91d0e0937f6ef2f"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -892,8 +892,8 @@ heading while the structured directive and the markdown-link anchor were both
|
|
|
892
892
|
verdict-checked. It scans the manifest set (`spec_manifest_files`, the same
|
|
893
893
|
surface the manifest-narration gate family reads) over a blank-line-delimited
|
|
894
894
|
paragraph join so a heading that wraps a line reassembles, and resolves the
|
|
895
|
-
heading through
|
|
896
|
-
|
|
895
|
+
heading through one shared resolution path — the directive pass and the
|
|
896
|
+
citation pass call the same helper, so they cannot diverge. Free prose runs on past the heading with no delimiter, so
|
|
897
897
|
the citation pass matches a heading as a boundary-anchored **prefix** of the
|
|
898
898
|
fragment where the directive pass matches it whole. A cited path that is not a
|
|
899
899
|
tracked file is out of this pass's scope — path liveness stays with the gates
|
|
@@ -37,16 +37,29 @@ fi
|
|
|
37
37
|
# spec: canon-kit/SPEC.md §check-md-refs — the self-repo blob-link prefix, derived from origin through the shared gate.sh adapter (git@ and https forms normalize to one identity); CANON_KIT_DOCS_BLOB_REF is the ref policy, empty ⇒ no origin, the self-repo pass is skipped
|
|
38
38
|
self_repo_prefix="$(gate_self_repo_prefix "$CANON_KIT_DOCS_BLOB_REF")"
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
# spec: canon-kit/SPEC.md §check-md-refs — the tracked-file membership set, filled once from a single git ls-files pass rather than a per-link `git ls-files --error-unmatch` exec; check-ignore and the directory listing stay per-call (the fallback path, not the hot one)
|
|
41
|
+
declare -A TRACKED=()
|
|
42
|
+
while IFS= read -r -d '' _tf; do TRACKED["$_tf"]=1; done < <(git ls-files -z)
|
|
43
|
+
|
|
44
|
+
# spec: canon-kit/SPEC.md §check-md-refs — anchor_ok memoizes a target file's slug set on first use: one heading-extraction sed and one bulk slugify sed per file, however many anchors across however many links cite it, instead of re-forking sed per heading per link
|
|
45
|
+
declare -A ANCHOR_SLUGS=()
|
|
46
|
+
declare -A ANCHOR_SLUGS_DONE=()
|
|
44
47
|
|
|
45
48
|
anchor_ok() { # $1=target file, $2=anchor slug
|
|
46
|
-
local
|
|
47
|
-
|
|
48
|
-
[
|
|
49
|
-
|
|
49
|
+
local file="$1" headings s
|
|
50
|
+
if [[ -z "${ANCHOR_SLUGS_DONE[$file]:-}" ]]; then
|
|
51
|
+
ANCHOR_SLUGS_DONE["$file"]=1
|
|
52
|
+
headings="$(sed -nE 's/^#{1,6}[[:space:]]+(.*[^[:space:]])[[:space:]]*$/\1/p' "$file")"
|
|
53
|
+
if [[ -n "$headings" ]]; then
|
|
54
|
+
headings="${headings,,}"
|
|
55
|
+
ANCHOR_SLUGS["$file"]="$(sed -E 's/[^a-z0-9 _-]//g; s/ +/-/g' <<< "$headings")"
|
|
56
|
+
else
|
|
57
|
+
ANCHOR_SLUGS["$file"]=""
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
while IFS= read -r s; do
|
|
61
|
+
[[ "$s" == "$2" ]] && return 0
|
|
62
|
+
done <<< "${ANCHOR_SLUGS[$file]}"
|
|
50
63
|
return 1
|
|
51
64
|
}
|
|
52
65
|
|
|
@@ -54,7 +67,7 @@ target_resolves() { # $1=repo-relative path
|
|
|
54
67
|
local p="$1"
|
|
55
68
|
[[ "$p" == ..* ]] && return 1
|
|
56
69
|
if [[ -f "$p" ]]; then
|
|
57
|
-
|
|
70
|
+
[[ -n "${TRACKED[$p]:-}" ]] && return 0
|
|
58
71
|
git check-ignore -q -- "$p" && return 0
|
|
59
72
|
return 1
|
|
60
73
|
fi
|
|
@@ -99,6 +99,10 @@ FNR == 1 { flush(); fence = 0 }
|
|
|
99
99
|
END { flush() }
|
|
100
100
|
AWK
|
|
101
101
|
|
|
102
|
+
# spec: canon-kit/SPEC.md §check-spec-pointer — the tracked-file membership set, filled once from a single git ls-files pass rather than a per-pointer `git ls-files --error-unmatch` exec
|
|
103
|
+
declare -A TRACKED=()
|
|
104
|
+
while IFS= read -r -d '' _tf; do TRACKED["$_tf"]=1; done < <(git -C "$ROOT" ls-files -z)
|
|
105
|
+
|
|
102
106
|
errors=()
|
|
103
107
|
scanned=0
|
|
104
108
|
pointers=0
|
|
@@ -133,7 +137,7 @@ while IFS= read -r f; do
|
|
|
133
137
|
errors+=("$rel:$lineno: target file not found: $path")
|
|
134
138
|
continue
|
|
135
139
|
fi
|
|
136
|
-
if
|
|
140
|
+
if [[ -z "${TRACKED[$path]:-}" ]]; then
|
|
137
141
|
errors+=("$rel:$lineno: target file untracked: $path")
|
|
138
142
|
continue
|
|
139
143
|
fi
|
|
@@ -156,7 +160,7 @@ if [[ ${#manifest_files[@]} -gt 0 ]]; then
|
|
|
156
160
|
while IFS=$'\t' read -r pfile plineno ppath pfrag; do
|
|
157
161
|
[[ -n "$ppath" ]] || continue
|
|
158
162
|
[[ -f "$ROOT/$ppath" ]] || continue
|
|
159
|
-
|
|
163
|
+
[[ -n "${TRACKED[$ppath]:-}" ]] || continue
|
|
160
164
|
prose_cites=$((prose_cites + 1))
|
|
161
165
|
[[ -n "$pfrag" ]] || continue
|
|
162
166
|
if ! heading_present "$ROOT/$ppath" "$pfrag" prefix; then
|
|
@@ -258,10 +258,17 @@ is provable).
|
|
|
258
258
|
|
|
259
259
|
The constrained members and what forces each:
|
|
260
260
|
|
|
261
|
-
- `bash:4.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
- `bash:4.3` — the floor is set by the **highest** construct the battery runs,
|
|
262
|
+
not the most numerous. Three bash-4.0 constructs are widespread — `declare -A`
|
|
263
|
+
(gate-sdk, guard-kit, delegation-kit, evidence-kit checks), `mapfile` (across
|
|
264
|
+
the kits), the `${x,,}` case expansion (canon-kit's `lib/spec.sh` and checks, a
|
|
265
|
+
delegation-kit template) — but the **nameref** (`local -n`, bash 4.3) outranks
|
|
266
|
+
them: `gate-sdk/lib/gate.sh`'s couples expander, which every gate sources, and
|
|
267
|
+
`canon-kit/checks/check-comment-tier.sh`. The nameref in the shared gate
|
|
268
|
+
library makes 4.3 universal rather than one leaf gate's requirement, so a
|
|
269
|
+
consumer below it cannot run the battery at all. Recorded here because the
|
|
270
|
+
earlier `4.0` was a fail-open: `env-probe` reported `ok` on a 4.2 box the
|
|
271
|
+
battery would fail with an obscure syntax error.
|
|
265
272
|
- `awk::GNU` — no version floor, one implementation constraint: the 3-arg
|
|
266
273
|
`match()` in `check-gate-assertions`, whose dependency gate-sdk/SPEC.md
|
|
267
274
|
§check-gate-assertions already owns.
|
|
@@ -297,8 +304,8 @@ gate-sdk/SPEC.md §The gate model requires of a gate, applied to a probe that is
|
|
|
297
304
|
not one.
|
|
298
305
|
|
|
299
306
|
**The rendered verdict.** Each toolchain bullet carries the probed banner and,
|
|
300
|
-
for a constrained member, the constraint and its verdict — `` (floor 4.
|
|
301
|
-
`` (requires GNU — below contract) ``, `` (floor 4.
|
|
307
|
+
for a constrained member, the constraint and its verdict — `` (floor 4.3, ok) ``,
|
|
308
|
+
`` (requires GNU — below contract) ``, `` (floor 4.3 — unverified) ``; an
|
|
302
309
|
unconstrained member carries no parenthetical. A `**Below contract:**` line joins
|
|
303
310
|
the existing `**Absent:**` line, reading `none` when clean and otherwise naming
|
|
304
311
|
each failing member through the verdict's own fields: `below` and `wrong-impl`
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# spec: context-kit/SPEC.md §bin/env-probe — the roster, `<name>[:<min-version>[:<impl-token>]]`; a member gains a floor only where a construct the battery runs forces one, and the SPEC records that construct beside the token
|
|
5
5
|
# shellcheck disable=SC2034 # read by whoever sources this file (bin/env-probe.sh), never here
|
|
6
|
-
PROBE_SET=(bash:4.
|
|
6
|
+
PROBE_SET=(bash:4.3 git jq awk::GNU sort::coreutils shellcheck)
|
|
7
7
|
|
|
8
8
|
# spec: context-kit/SPEC.md §bin/env-probe — positional fields, an empty field meaning unconstrained on that axis exactly as an omitted trailing one does, so `awk`, `awk:` and `awk::` parse to one member
|
|
9
9
|
tool_floor_parse() { # $1 = roster element -> TOOL_FLOOR_NAME / _MIN / _IMPL
|
|
@@ -26,6 +26,7 @@ Vendor the kit beside [gate-sdk](../gate-sdk/) (required), then:
|
|
|
26
26
|
```
|
|
27
27
|
check-gate-tamper
|
|
28
28
|
check-rule-citation # holds SPEC §The delegation model's rule citations to the template
|
|
29
|
+
check-agent-tier-explicit # every tracked agent definition states a model: tier
|
|
29
30
|
```
|
|
30
31
|
<!-- gate-roster:end -->
|
|
31
32
|
|
|
@@ -80,7 +81,7 @@ directly with `--fixture <dir>` only for testing.
|
|
|
80
81
|
## Test
|
|
81
82
|
|
|
82
83
|
```bash
|
|
83
|
-
bash gate-sdk/bin/run-gate-tests.sh delegation-kit/gate-tests delegation-kit/checks #
|
|
84
|
+
bash gate-sdk/bin/run-gate-tests.sh delegation-kit/gate-tests delegation-kit/checks # every gate's fixture pair
|
|
84
85
|
bash delegation-kit/bin/run-usage-tests.sh # usage-verdict verdict table
|
|
85
86
|
bash delegation-kit/bin/run-budget-guard-tests.sh # budget-guard action table
|
|
86
87
|
bash delegation-kit/bin/run-trend-tests.sh # usage-trend segmentation assertions
|
|
@@ -41,6 +41,60 @@ disjointness — so the cap is a correctness bound, never a preference a consume
|
|
|
41
41
|
may configure up for committing agents (the knob's derivation: §Layout and
|
|
42
42
|
configuration).
|
|
43
43
|
|
|
44
|
+
The template's **Background + notification, never poll** rule reads as
|
|
45
|
+
universal but is not, and the sentence that scopes it is a fact rather than a
|
|
46
|
+
role list: backgrounding survives a turn, and a dispatched agent's turn end is
|
|
47
|
+
its session end. Attested failure surface — a stage session read the rule,
|
|
48
|
+
backgrounded its whole validate suite, ended its turn to report progress, and
|
|
49
|
+
its child died with it: an entry stamp, no results, the suite re-run from
|
|
50
|
+
scratch. Nothing reddened, because missing evidence is indistinguishable from
|
|
51
|
+
pending evidence. Two phrasings were drafted and rejected on the way to the
|
|
52
|
+
current one, and both failures are instructive: a role-neutral "never end your
|
|
53
|
+
turn with detached work" forbids the supervisor pattern the same rule
|
|
54
|
+
prescribes, and "await it in the **foreground**" names a lever the agent may
|
|
55
|
+
not have — dispatches made *without* requesting backgrounding have been
|
|
56
|
+
observed detached anyway, so a rule stated on foreground is unfollowable
|
|
57
|
+
exactly where it is needed. That a subagent's return terminates its background
|
|
58
|
+
children was **attested here and inferred from the harness docs, not stated by
|
|
59
|
+
them**, and a counter-observation has since narrowed it: a validate session
|
|
60
|
+
backgrounded a *shell* producer, ended its turn, and the process kept running
|
|
61
|
+
and kept writing its output file for minutes. Reaping holds for an `Agent`
|
|
62
|
+
child and not for a shell one, so the rule's mechanism is the unconditional
|
|
63
|
+
loss of the **observer**, not the conditional loss of the work — and the
|
|
64
|
+
surviving-producer case is the worse of the two, since it is
|
|
65
|
+
`validate-producer-liveness-unobservable`'s hazard (an unread producer mutating
|
|
66
|
+
shared files while the next actor moves) arriving through the backgrounding
|
|
67
|
+
door. The rule is anchored on the invariant either way — an agent's contract
|
|
68
|
+
with its caller is its return value, so work whose result is not in the return
|
|
69
|
+
did not happen as far as the caller is concerned — which is why the
|
|
70
|
+
counter-observation cost the rule a sentence and not its content, exactly as
|
|
71
|
+
this paragraph predicted a reaping change would.
|
|
72
|
+
|
|
73
|
+
**Why that correction needed an affordance, not just a better reason.** The
|
|
74
|
+
session that produced the counter-observation reasoned *correctly* into the
|
|
75
|
+
failure: it read the producer-liveness hazard, concluded it must not let the
|
|
76
|
+
next actor proceed until the producer finished, and ended its turn to wait for
|
|
77
|
+
the completion notification — the one act that destroys that channel for a
|
|
78
|
+
dispatched role. A rule whose correct application requires a channel the reader
|
|
79
|
+
does not have is defeated by careful readers and not only careless ones, so the
|
|
80
|
+
template names the channel a dispatched role *does* have: an in-turn wait on the
|
|
81
|
+
work's own artifact. This is the case where the backgrounding rule and the
|
|
82
|
+
liveness hazard meet and neither, alone, covered it.
|
|
83
|
+
|
|
84
|
+
The template's **Findings you will act on are durable before you act on them**
|
|
85
|
+
rule rests on a near-loss rather than a loss: a close stage dispatched two
|
|
86
|
+
audit sweeps and then hit the session wall. Both had already returned, which
|
|
87
|
+
was luck; had the wall landed mid-sweep the audit work would have been gone
|
|
88
|
+
with no record it ran. The gap is that the journal mechanics are written for a
|
|
89
|
+
dispatched *mutating* agent, so a read-only child journals nothing and its
|
|
90
|
+
findings exist only as a return value in the parent's context. The fix
|
|
91
|
+
deliberately does **not** overturn the read-only-fan-out caveat in §Resume
|
|
92
|
+
journal — that caveat was re-examined against this evidence and kept, with its
|
|
93
|
+
duty relocated to the receiving end, because overturning it would put the write
|
|
94
|
+
back exactly where the observed failures are. Recorded here because the rule
|
|
95
|
+
and the caveat otherwise read as each other's contradiction and the next
|
|
96
|
+
reader re-litigates them.
|
|
97
|
+
|
|
44
98
|
`templates/agent-budget-guard.sh` closes the gap the template's
|
|
45
99
|
**Budget-check before *each* dispatch in a fan-out** rule leaves when it relies
|
|
46
100
|
on the agent *choosing* to run the tool: a memory-quoted percentage acts in its
|
|
@@ -76,6 +130,24 @@ consumer). Registration is the opt-in valve: a consumer wanting pure advice
|
|
|
76
130
|
does not wire the hook. No new persistent state and no new key on the
|
|
77
131
|
`usage.txt` contract — the verdict line is the only interface.
|
|
78
132
|
|
|
133
|
+
**Covered at every depth, aggregated at none.** The hook's registration is
|
|
134
|
+
session-wide, so it fires inside dispatched sessions too: a dispatched
|
|
135
|
+
session's own dispatches re-arm it, carrying that session's identity, and the
|
|
136
|
+
coverage reaches every depth rather than stopping at the root. What it cannot
|
|
137
|
+
do is **aggregate** — each fire is independent and holds no state about the
|
|
138
|
+
tree, so a verdict prices the one call it gates and never the subtree that call
|
|
139
|
+
opens. That pairing is what the subtree clause of the template's
|
|
140
|
+
**Budget-check before *each* dispatch in a fan-out** rule exists to compensate,
|
|
141
|
+
and stating both halves here is what stops the next reader re-filing either.
|
|
142
|
+
Calibration history, because the silence invited the wrong turn: the hook
|
|
143
|
+
script is stateless and carries no depth counter, and a scope survey read that
|
|
144
|
+
as *the guard does not reach below the root* and filed against it. The reading
|
|
145
|
+
of the script was exact; the inference from it was false. A guard whose output
|
|
146
|
+
is only ever seen by the session it fires in looks absent from every other
|
|
147
|
+
vantage point — so a supervisor counting its own hook fires is watching a
|
|
148
|
+
strict undercount of its own tree, which is the observation the residual
|
|
149
|
+
projection gap is stated against rather than a coverage gap to be re-armed.
|
|
150
|
+
|
|
79
151
|
A knob-raise ruling has one working transport in this harness: the settings
|
|
80
152
|
env block (`.claude/settings.local.json`), which hooks re-read per fire — the
|
|
81
153
|
raised `DELEGATION_KIT_PAUSE_PCT` reaches the guard on the next dispatch with
|
|
@@ -86,7 +158,29 @@ Propagation is asymmetric within a live session: the hook re-reads the file
|
|
|
86
158
|
per fire, but the Bash tool environment retains an injected value after the
|
|
87
159
|
entry is deleted until the session restarts — an in-session `usage-verdict`
|
|
88
160
|
run and a hook fire can judge against different thresholds in that window, so
|
|
89
|
-
the hook's verdict line, not an in-session re-run, is the acting reading.
|
|
161
|
+
the hook's verdict line, not an in-session re-run, is the acting reading. That
|
|
162
|
+
this transport *works* is not a permission to use it for everything a harness
|
|
163
|
+
env var reaches: the subagent-model override below rides the same block and is
|
|
164
|
+
refused there, so the two must not read as one sanction.
|
|
165
|
+
|
|
166
|
+
**The subagent-model environment override is refused, and the reason is
|
|
167
|
+
precedence.** Model resolution runs in a fixed order — the subagent-model
|
|
168
|
+
environment override, then a dispatch's own `model` parameter, then the agent
|
|
169
|
+
definition's `model:` frontmatter, then the dispatching conversation's model —
|
|
170
|
+
and the environment rung sits *above* the per-dispatch parameter. Setting it
|
|
171
|
+
would pin every subagent to a cheap tier in one line, and would thereby
|
|
172
|
+
silently defeat a supervisor's deliberate per-batch tier pin, the mechanism
|
|
173
|
+
`lifecycle-kit/templates/lead.md` §Economics — batch, and compact where it pays
|
|
174
|
+
depends on to tier a batch by its work classes. A lever that overrides the
|
|
175
|
+
deliberate choice is not a default; it is a ceiling, so it is recorded as
|
|
176
|
+
rejected rather than left to be rediscovered as an improvement. The correct
|
|
177
|
+
rung is the **frontmatter**, third in the chain: it supplies the standing
|
|
178
|
+
default the template's **Match the dispatched model and effort to the unit's
|
|
179
|
+
shape** rule asks for while the per-dispatch parameter still overrides it. The
|
|
180
|
+
same rule's affirmative-selection clause is why the field is *stated* rather
|
|
181
|
+
than left out — an omitted `model:` resolves to the literal `inherit`, so
|
|
182
|
+
omission spells the dispatcher's tier rather than a neutral absence, and
|
|
183
|
+
`check-agent-tier-explicit` is that clause's oracle over the tracked surface.
|
|
90
184
|
|
|
91
185
|
### One template, a resident pointer
|
|
92
186
|
|
|
@@ -129,42 +223,75 @@ doctrine lives behind the trigger, not in the always-loaded file. Honest limit:
|
|
|
129
223
|
the guard enforces budget mechanically, not protocol literacy — a session that
|
|
130
224
|
dispatches without invoking the skill carries only the resident pointer.
|
|
131
225
|
|
|
132
|
-
## Resume journal — agent writes,
|
|
133
|
-
|
|
134
|
-
A mutating agent
|
|
135
|
-
|
|
136
|
-
in the
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
the
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
226
|
+
## Resume journal — agent writes, scratch reset sweeps
|
|
227
|
+
|
|
228
|
+
**The contract, in four clauses.** A mutating agent journals to a repo-local
|
|
229
|
+
gitignored scratch directory in the main checkout; the supervisor grants that
|
|
230
|
+
path **absolute** in the dispatch prompt; each finding lands inline as it is
|
|
231
|
+
confirmed; a `DONE` marker is appended on success. The operative text — what
|
|
232
|
+
each clause requires of an agent, and why a temporary worktree and a system
|
|
233
|
+
temp dir both fail the survivability test — is
|
|
234
|
+
`templates/agent-execution.md`'s **Resume journal — agent writes, scratch reset
|
|
235
|
+
sweeps** bullet, which is the surface an agent loads. This section owns what
|
|
236
|
+
that bullet cannot carry: the lifetime rule's reasoning, the attestation it was
|
|
237
|
+
priced against, and the two readings the marker carries.
|
|
238
|
+
|
|
239
|
+
**Lifetime — why retention rather than an eager deletion chore.** Cleanup is
|
|
240
|
+
the consumer's own scratch reset at its next work-unit boundary, a mechanism
|
|
241
|
+
the consumer already owns (here, `enter-stage.sh`'s boundary wipe of `.tmp/` at
|
|
242
|
+
the next scope entry — lifecycle-kit/SPEC.md §bin/enter-stage.sh). Two things
|
|
243
|
+
break when the supervisor deletes on its own schedule instead, and both appear
|
|
244
|
+
only once a dispatched agent is **resumable** rather than one-shot: a resumed
|
|
245
|
+
agent is still writing to the file, and a supervisor treating the journal as
|
|
246
|
+
its **pull channel** (lifecycle-kit/templates/lead.md §Channel design)
|
|
247
|
+
destroys at the first validated commit the channel it is supposed to keep
|
|
248
|
+
reading. A one-shot sweep hides both, which is why an eager deletion chore
|
|
249
|
+
read as correct for as long as it did.
|
|
250
|
+
|
|
251
|
+
**Attested.** A supervisor deleted a resumable session's journal after
|
|
252
|
+
validating that session's first commits; the session resumed minutes later,
|
|
253
|
+
found the file gone mid-write, rebuilt it from context, and reported the
|
|
254
|
+
disappearance as a suspected scratch-directory reliability defect. The lost
|
|
255
|
+
working state was the cheaper half — the false defect signal, raised against
|
|
256
|
+
the scratch dir and against an unrelated sibling unit, is what retention is
|
|
257
|
+
priced against. The same supervisor then retained two later sessions'
|
|
258
|
+
journals against the then-governed text; that deviation is what this section
|
|
259
|
+
now states.
|
|
260
|
+
|
|
261
|
+
**Reading `DONE` under retention.** Retention costs the *presence* of a
|
|
262
|
+
journal its meaning: every journal now survives its session, so finding one
|
|
263
|
+
signals nothing by itself. The marker still carries the completion claim, with
|
|
264
|
+
one sharpening a resumable session forces — `DONE` is meaningful **only as the
|
|
265
|
+
file's last line**, since a session resumed past its own marker appends after
|
|
266
|
+
it, and a mid-file `DONE` claims a completion the later content contradicts.
|
|
267
|
+
Whether a *missing* marker signals interruption still turns on whether the
|
|
268
|
+
supervisor consumed the agent's return. On the ordinary completion path it
|
|
269
|
+
did, and that return plus its post-commit verification (§Validate after every
|
|
270
|
+
agent commit) *is* the recovery contract, so the marker is redundant there.
|
|
271
|
+
Only in a **cold read** — a journal found with no return ever consumed, the
|
|
272
|
+
agent's session having died before returning (a background sandbox died, a
|
|
273
|
+
crash, a timeout) — is the marker the sole signal, and there the original
|
|
274
|
+
reading holds: no `DONE` = interrupted, resume from it. A live journal is told
|
|
275
|
+
from a spent one by per-session journal naming, the consumer's own work
|
|
276
|
+
cursor, and `git log`, which together say more than presence ever did, and the
|
|
277
|
+
boundary sweep bounds the ambiguity to the current work unit. The
|
|
278
|
+
inline-findings rule above is that cold arm's insurance — with no surviving
|
|
279
|
+
return, a pointer-only journal would make a would-be `DONE` lie about
|
|
280
|
+
recoverability.
|
|
160
281
|
|
|
161
282
|
**Caveat — the sandbox may block the journal write.** Background agents
|
|
162
283
|
have been observed unable to `Write` to the granted path, silently falling
|
|
163
284
|
back to returning findings in the final message — which defeats the journal
|
|
164
|
-
exactly when it matters (a long, interruptible run).
|
|
165
|
-
fan-out
|
|
166
|
-
|
|
167
|
-
|
|
285
|
+
exactly when it matters (a long, interruptible run). The template's
|
|
286
|
+
read-only-fan-out carve-out and its grant-the-path-explicitly clause both
|
|
287
|
+
follow from this observation. That contract has two ends. The caveat's
|
|
288
|
+
evidence is about **the child's** write failing silently, and its true
|
|
289
|
+
content is *do not make recoverability depend on a backgrounded child's
|
|
290
|
+
write* — which is why it is kept rather than overturned by the template's
|
|
291
|
+
**Findings you will act on are durable before you act on them** rule. That
|
|
292
|
+
rule's duty falls on **the parent**, which has already demonstrated it can
|
|
293
|
+
write, being the session that granted the path. The two are disjoint
|
|
294
|
+
readings of one contract, not each other's contradiction.
|
|
168
295
|
|
|
169
296
|
## Validate after every agent commit
|
|
170
297
|
|
|
@@ -195,6 +322,35 @@ diff review of agent gate edits remains a supervisor duty. `--fixture <dir>`
|
|
|
195
322
|
injects `staged-files` / `added-exemptions` lists (fixture-pair test
|
|
196
323
|
capability); live mode reads `git diff --cached`.
|
|
197
324
|
|
|
325
|
+
## check-agent-tier-explicit
|
|
326
|
+
|
|
327
|
+
Every agent definition under `DELEGATION_KIT_AGENT_DIR` declares a `model:`
|
|
328
|
+
field in its frontmatter. This is the oracle over the tracked half of the
|
|
329
|
+
template's **Match the dispatched model and effort to the unit's shape** rule:
|
|
330
|
+
the per-dispatch habit leaves no artifact, but a standing choice does, and the
|
|
331
|
+
gate reads it.
|
|
332
|
+
|
|
333
|
+
**It polices silence, not the choice.** An explicit `inherit`-valued `model:`
|
|
334
|
+
**passes** — a dispatched session that should ride its dispatcher's tier is a
|
|
335
|
+
legitimate answer and the gate has no business overruling it. What reds is
|
|
336
|
+
*omission*, the one state indistinguishable from not having thought about it,
|
|
337
|
+
and the one state that is not the neutral absence it looks like — the refused
|
|
338
|
+
environment override and the precedence chain behind that reading are in
|
|
339
|
+
§The delegation model. A reader arriving at this gate expecting it to enforce
|
|
340
|
+
cheapness has the wrong model of it.
|
|
341
|
+
|
|
342
|
+
**Counted inertness.** A consumer with no such directory — or one holding no
|
|
343
|
+
definitions — scans zero and reports a clean counted line, the derived-scan-set
|
|
344
|
+
shape the kit's other gates use. There is no roster and no registration list to
|
|
345
|
+
maintain: the scan set is the directory's contents.
|
|
346
|
+
|
|
347
|
+
**Honest limit.** It holds the tracked surface only. A dispatch naming no agent
|
|
348
|
+
type and no `model` parameter inherits and leaves no artifact for any gate to
|
|
349
|
+
read, so the gate converts the standing-choice class from unenforceable to
|
|
350
|
+
enforced and leaves the per-dispatch class to the rule's prose. That is
|
|
351
|
+
strictly better than nothing and not a claim to have closed the tier question
|
|
352
|
+
mechanically.
|
|
353
|
+
|
|
198
354
|
## usage-verdict
|
|
199
355
|
|
|
200
356
|
Emits a trustworthy budget verdict from a usage snapshot file, closing the
|
|
@@ -530,8 +686,10 @@ delegation-kit/
|
|
|
530
686
|
usage-tests/trend-history.log # fixture history for the trend runner
|
|
531
687
|
checks/check-gate-tamper.sh
|
|
532
688
|
checks/check-rule-citation.sh
|
|
689
|
+
checks/check-agent-tier-explicit.sh
|
|
533
690
|
gate-tests/check-gate-tamper/{good,bad}/
|
|
534
691
|
gate-tests/check-rule-citation/{good,bad}/
|
|
692
|
+
gate-tests/check-agent-tier-explicit/{good,bad}/
|
|
535
693
|
templates/agent-execution.md # full protocol, bound as a skill shim
|
|
536
694
|
templates/dispatch-checklists.md # deletion/rename/audit pre-flight, reached by a pointer
|
|
537
695
|
templates/agent-budget-guard.sh # PreToolUse(Agent) budget guard
|
|
@@ -596,6 +754,12 @@ layout as defaults):
|
|
|
596
754
|
window raises the affordable width, not the reviewable one, so budget is
|
|
597
755
|
never the sole input to widening. `usage-verdict` surfaces the live value
|
|
598
756
|
as the `width=` field (§usage-verdict), the knob's mechanical reader.
|
|
757
|
+
- `DELEGATION_KIT_AGENT_DIR` — the directory `check-agent-tier-explicit` walks
|
|
758
|
+
for agent definitions; default `.claude/agents`, this harness's conventional
|
|
759
|
+
agent-definition location, validated non-empty by the loader. Positional `$1`
|
|
760
|
+
overrides (fixture injection). A consumer whose harness keeps definitions
|
|
761
|
+
elsewhere repoints it; one with no such directory leaves it and the gate
|
|
762
|
+
reports its counted-inert clean line (§check-agent-tier-explicit).
|
|
599
763
|
- `DELEGATION_KIT_GATE_FILES` — globs naming gate files for tamper
|
|
600
764
|
assertion A; default
|
|
601
765
|
`("${GATE_SDK_GATES_DIR:-scripts}/check-*.sh")` plus the gate-sdk lib and
|
|
@@ -637,8 +801,9 @@ edit; the context-kit template stays uncoupled from delegation-kit.
|
|
|
637
801
|
**An `OK` verdict is a floor, not a recommendation.** The guard answers one
|
|
638
802
|
question — is there headroom in the window *right now* — and blocks only on
|
|
639
803
|
`PAUSE`. Everything else a dispatch decision turns on sits outside its reach:
|
|
640
|
-
how long the dispatched work runs,
|
|
641
|
-
(the guard
|
|
804
|
+
how long the dispatched work runs, what a fan-out beneath the checkpoint will
|
|
805
|
+
cost in total (the guard re-arms on those children but prices each of them
|
|
806
|
+
alone: covered at every depth, aggregated at none — §The delegation model),
|
|
642
807
|
and whether anything forces the dispatch now rather than after the window
|
|
643
808
|
resets. `OK` is therefore one input to that decision and never the decision
|
|
644
809
|
itself; a dispatcher reading `OK` as "go" has substituted the guard's question
|
|
@@ -658,6 +823,13 @@ costs the work in flight.
|
|
|
658
823
|
naming an absent lead-in), driven by `run-gate-tests.sh` over fixture-local
|
|
659
824
|
spec + template files passed as its two positional arguments.
|
|
660
825
|
|
|
826
|
+
`check-agent-tier-explicit` speaks the same gate contract and ships the standard
|
|
827
|
+
`good/`+`bad/` fixture pair over a fixture-local agent directory passed as its
|
|
828
|
+
one positional argument. The `good/` side carries both passing shapes — a
|
|
829
|
+
definition naming a cheaper class outright and one declaring `inherit` — so the
|
|
830
|
+
pair proves the gate discriminates omission from choice rather than merely
|
|
831
|
+
finding a `model:` string; the `bad/` side omits the field.
|
|
832
|
+
|
|
661
833
|
`usage-verdict` does not fit the gate contract (a three-state verdict, not a
|
|
662
834
|
clean/violation pair), so — like guard-kit's guard-tests — the kit ships
|
|
663
835
|
its own decision-table runner: `usage-tests/cases.tsv` pairs an expected
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# graph: couples=.claude/agents/*.md dir=one valve=none tier=precommit
|
|
3
|
+
# spec: delegation-kit/SPEC.md §check-agent-tier-explicit — every agent definition under the scanned directory declares a `model:` field in its frontmatter (an explicit `inherit` passes; only omission reds)
|
|
4
|
+
#
|
|
5
|
+
# usage: check-agent-tier-explicit.sh [agent-dir]
|
|
6
|
+
# defaults DELEGATION_KIT_AGENT_DIR; a fixture passes its own directory.
|
|
7
|
+
set -uo pipefail
|
|
8
|
+
|
|
9
|
+
KIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
10
|
+
SDK="${GATE_SDK_ROOT:-$KIT/../gate-sdk}"
|
|
11
|
+
# shellcheck source=../../gate-sdk/lib/gate.sh
|
|
12
|
+
source "$SDK/lib/gate.sh"
|
|
13
|
+
# shellcheck source=../lib/delegation.sh
|
|
14
|
+
source "$KIT/lib/delegation.sh"
|
|
15
|
+
|
|
16
|
+
DIR="${1:-$DELEGATION_KIT_AGENT_DIR}"; DIR="${DIR%/}"
|
|
17
|
+
|
|
18
|
+
if [[ ! -d "$DIR" ]]; then
|
|
19
|
+
echo "AGENT-TIER-EXPLICIT: clean (0 agent definition(s) under $DIR; no agent-definition directory)"
|
|
20
|
+
exit 0
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
listing="$(find "$DIR" -type f -name '*.md' | LC_ALL=C sort)"; st=$?
|
|
24
|
+
fail_closed "$st" AGENT-TIER-EXPLICIT find
|
|
25
|
+
|
|
26
|
+
files=()
|
|
27
|
+
while IFS= read -r path; do
|
|
28
|
+
[[ -n "$path" ]] || continue
|
|
29
|
+
gate_path_pruned "$path" && continue
|
|
30
|
+
files+=("$path")
|
|
31
|
+
done <<< "$listing"
|
|
32
|
+
|
|
33
|
+
if [[ ${#files[@]} -eq 0 ]]; then
|
|
34
|
+
echo "AGENT-TIER-EXPLICIT: clean (0 agent definition(s) under $DIR; nothing to check)"
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
bare="$(awk '
|
|
39
|
+
FNR == 1 { if (fname != "" && !seen) print fname; fname = FILENAME; seen = 0; open = 0; shut = 0; ln = 0 }
|
|
40
|
+
{ ln++ }
|
|
41
|
+
ln == 1 { if ($0 == "---") open = 1; else shut = 1; next }
|
|
42
|
+
shut || !open { next }
|
|
43
|
+
$0 == "---" { shut = 1; next }
|
|
44
|
+
$0 ~ /^model:[[:space:]]*[^[:space:]]/ { seen = 1 }
|
|
45
|
+
END { if (fname != "" && !seen) print fname }
|
|
46
|
+
' "${files[@]}")"; st=$?
|
|
47
|
+
fail_closed "$st" AGENT-TIER-EXPLICIT awk
|
|
48
|
+
|
|
49
|
+
if [[ -n "$bare" ]]; then
|
|
50
|
+
echo "check-agent-tier-explicit: agent definition(s) whose frontmatter omits the model: field:"
|
|
51
|
+
while IFS= read -r f; do
|
|
52
|
+
[[ -n "$f" ]] && echo " $f: no 'model:' field in frontmatter"
|
|
53
|
+
done <<< "$bare"
|
|
54
|
+
echo " help: state the tier in the definition's frontmatter — an omitted model: is not a neutral"
|
|
55
|
+
echo " default but the literal 'inherit' (the dispatcher's tier), so declare it even when"
|
|
56
|
+
echo " the answer is to inherit; 'model: inherit' passes."
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
echo "AGENT-TIER-EXPLICIT: clean (${#files[@]} agent definition(s) under $DIR, each declaring an explicit model:)"
|
|
61
|
+
exit 0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agents
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
no 'model:' field in frontmatter
|
package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-inherit.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: explicit-inherit
|
|
3
|
+
description: Fixture agent definition choosing to ride its dispatcher's tier, and saying so.
|
|
4
|
+
model: inherit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Fixture body. An explicit `inherit` is a legitimate answer — the gate polices
|
|
8
|
+
omission, not the choice — so this file passes too.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agents
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENT-TIER-EXPLICIT: clean (2 agent definition(s) under agents
|
|
@@ -27,6 +27,7 @@ unset _dk_cfg
|
|
|
27
27
|
[[ -v DELEGATION_KIT_REFRESH_MIN_AGE ]] || DELEGATION_KIT_REFRESH_MIN_AGE=60
|
|
28
28
|
[[ -v DELEGATION_KIT_USAGE_HISTORY ]] || DELEGATION_KIT_USAGE_HISTORY=""
|
|
29
29
|
[[ -v DELEGATION_KIT_FAN_WIDTH ]] || DELEGATION_KIT_FAN_WIDTH=2
|
|
30
|
+
[[ -v DELEGATION_KIT_AGENT_DIR ]] || DELEGATION_KIT_AGENT_DIR=".claude/agents"
|
|
30
31
|
|
|
31
32
|
declare -p DELEGATION_KIT_GATE_FILES &>/dev/null || DELEGATION_KIT_GATE_FILES=(
|
|
32
33
|
"${GATE_SDK_GATES_DIR:-scripts}/check-*.sh"
|
|
@@ -71,6 +72,7 @@ _dk_errs=()
|
|
|
71
72
|
|| _dk_errs+=("DELEGATION_KIT_REFRESH_MIN_AGE must be a non-negative integer (got '$DELEGATION_KIT_REFRESH_MIN_AGE')")
|
|
72
73
|
[[ "$DELEGATION_KIT_FAN_WIDTH" =~ ^[0-9]+$ && "$DELEGATION_KIT_FAN_WIDTH" -gt 0 ]] \
|
|
73
74
|
|| _dk_errs+=("DELEGATION_KIT_FAN_WIDTH must be a positive integer (got '$DELEGATION_KIT_FAN_WIDTH')")
|
|
75
|
+
[[ -n "$DELEGATION_KIT_AGENT_DIR" ]] || _dk_errs+=("DELEGATION_KIT_AGENT_DIR is empty")
|
|
74
76
|
[[ ${#DELEGATION_KIT_GATE_FILES[@]} -gt 0 ]] || _dk_errs+=("DELEGATION_KIT_GATE_FILES is empty")
|
|
75
77
|
[[ ${#DELEGATION_KIT_META_PATHS[@]} -gt 0 ]] || _dk_errs+=("DELEGATION_KIT_META_PATHS is empty")
|
|
76
78
|
if [[ ${#_dk_errs[@]} -gt 0 ]]; then
|