delegation-kit
Safe delegated-Agent execution for budget-bounded sessions. A supervisor
dispatches sub-agents that are cheap to spawn and expensive to trust; this kit
packages the supervisor-side protocol plus the two mechanizable pieces — a
trustworthy budget verdict (usage-verdict) and a commit-shape gate over gate
tampering (check-gate-tamper).
Why: three failure surfaces dominate delegation. Shared mutable state — two
committing agents race the git index and one sweeps the other’s staged files
under the wrong message (the index and HEAD are shared for every committing
agent, disjoint source files notwithstanding). Interrupted long units — a
usage-window wall fires mid-flight and the uncommitted investigation dies with
the session. Untrustworthy self-reports — a sub-agent’s “passed” claim, or
a gate quietly weakened to make its commit pass. The protocol closes all three;
usage-verdict and check-gate-tamper are its mechanical floors. See
SPEC.md for the full contracts.
Install
Vendor the kit beside gate-sdk (required), then:
-
Register the gates — add to your
gates.list:check-gate-tamper check-rule-citation # holds SPEC §The delegation model's rule citations to the template check-agent-tier-explicit # every tracked agent definition states a model: tierThey resolve through gate-sdk’s registry path and their
# graph:manifests put them in the generated pre-commit hook:bash gate-sdk/bin/gen-pre-commit.sh --write. - Bind the protocol skill and add its resident pointer:
- Create
.claude/commands/agent-execution.mdas a binding shim namingtemplates/agent-execution.mdand binding its two slots — the shared-file roster and the validate battery (SPEC §One template, a resident pointer). - Add a
### Agent executionblock to yourCLAUDE.md: your delegation pre-authorization sentence plus the/agent-executionpointer. The protocol loads behind that trigger, so the block stays a pointer, never a digest.
- Create
-
Wire a
usage.txtproducer sousage-verdicthas a snapshot to read — point your harnessstatusLineattemplates/statusline-usage.sh(or copy it), pointDELEGATION_KIT_REFRESH_CMDattemplates/usage-poller.shso every verdict call refreshes the snapshot on demand (or wire the same poller under a timer), keeping it fresh while a supervising session sits static, or have any producer honour the snapshot contract (SPEC §The usage.txt contract). The statusline producer also renders a status bar, whose field set is SPEC §The statusline template’s; the three mandatory snapshot lines are the floor, and supplying the optional weekly keys arms the second (7-day) pause axis. -
Optional — wire the Agent budget guard: copy
templates/agent-budget-guard.shinto your gates dir and register it underPreToolUsematcherAgentin.claude/settings.json. It firesusage-verdictat every dispatch, blocking on a PAUSE verdict and advising otherwise (SPEC §The delegation model). Unwired, it is inert. -
Optional — wire the turn-end liveness hook: copy
templates/subagent-stop-liveness.shinto your gates dir and register it underSubagentStopin.claude/settings.json(that event takes no matcher). It logs one line per subagent turn end saying whether any launch record named a live producer, and refuses the turn end — exit 2, its stderr the blocking reason — when that reading isred,corruptorunresolved; it emits no hook JSON on either path (SPEC §The turn-end liveness hook (template)). There is no knob: unwiring is the valve. Unwired, it is inert; wiring it is a permission-surface change, so it is yours to make. - Optional — retune: copy
templates/delegation-config.shinto your gates dir and override the budget thresholds, the gate-file globs, or the meta-layer prefixes. Defaults are this repo’s single-operator layout.
Use
bash delegation-kit/bin/usage-verdict.sh # budget verdict: exit 0 OK/RESET-OK, 1 PAUSE, 2 STALE
bash delegation-kit/bin/usage-verdict.sh <snapshot> # verdict for an explicit usage.txt (test injection)
bash delegation-kit/bin/usage-trend.sh # footprint trend over the sample log (needs DELEGATION_KIT_USAGE_HISTORY)
bash delegation-kit/bin/wait-probe.sh sweep # wait-primitive probe: the harness-uninvolved reproducer (sleeps for its declared sweep)
bash delegation-kit/bin/wait-probe.sh report # classify the recorded trials and print the verdict
With DELEGATION_KIT_USAGE_HISTORY set, usage-verdict logs one sample per
call; usage-trend reads that log and reports per-window footprint evolution
and weekly headroom (advisory — exit 0/2, never a pause verdict).
check-gate-tamper runs from the pre-commit hook and the battery; invoke it
directly with --fixture <dir> only for testing.
Test
bash gate-sdk/bin/run-gate-tests.sh delegation-kit/gate-tests delegation-kit/checks # every gate's fixture pair
bash delegation-kit/bin/run-usage-tests.sh # usage-verdict verdict table
bash delegation-kit/bin/run-budget-guard-tests.sh # budget-guard action table
bash delegation-kit/bin/run-trend-tests.sh # usage-trend segmentation assertions