checkwright 0.21.0 → 0.22.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 +385 -19
- package/lib/common/digest.sh +18 -0
- package/lib/common/lock.sh +11 -0
- package/lib/common/recipe.sh +8 -11
- package/lib/doctor.sh +49 -0
- package/lib/init.sh +152 -29
- package/package.json +2 -2
- package/payload/artifact/targets.list +30 -0
- package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
- package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -0
- package/payload/canon-kit/README.md +1 -0
- package/payload/canon-kit/SPEC.md +279 -24
- package/payload/canon-kit/checks/check-comment-tier.sh +7 -2
- package/payload/canon-kit/checks/check-docs-link-convention.sh +11 -4
- package/payload/canon-kit/checks/check-payload-claim.sh +133 -0
- package/payload/canon-kit/checks/check-prose-enum.sh +1 -1
- package/payload/canon-kit/checks/check-spec-pointer.sh +9 -2
- package/payload/canon-kit/gate-tests/check-comment-tier/good/good.sh +3 -0
- package/payload/canon-kit/gate-tests/check-comment-tier.test.sh +26 -3
- package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/OUTSIDE.md +4 -0
- package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/docs/index.md +3 -0
- package/payload/canon-kit/gate-tests/check-docs-link-convention/good/OUTSIDE.md +4 -0
- package/payload/canon-kit/gate-tests/check-docs-link-convention/good/docs/methodology.md +8 -0
- package/payload/canon-kit/gate-tests/check-docs-link-convention.test.sh +94 -0
- package/payload/canon-kit/gate-tests/check-manifest-count.test.sh +5 -3
- package/payload/canon-kit/gate-tests/check-payload-claim/bad/README.md +15 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/bad/expect.txt +2 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/bad/install.md +19 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/bad/posts/note.md +6 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/canon-config.sh +8 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/payload-claims.sh +7 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/good/README.md +15 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/good/expect.txt +2 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/good/install.md +20 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/good/posts/note.md +6 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/canon-config.sh +8 -0
- package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/payload-claims.sh +7 -0
- package/payload/canon-kit/gate-tests/check-prose-enum.test.sh +24 -1
- package/payload/canon-kit/gate-tests/check-spec-pointer/bad/expect.txt +1 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/bad/widget.sh +1 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/good/widget.sh +1 -0
- package/payload/canon-kit/lib/spec.sh +22 -12
- package/payload/canon-kit/smoke/install.sh +20 -1
- package/payload/canon-kit/templates/SPEC-amendment.md +5 -1
- package/payload/context-kit/SPEC.md +25 -1
- package/payload/context-kit/lib/toolfloor.sh +1 -1
- package/payload/context-kit/smoke/install.sh +3 -1
- package/payload/delegation-kit/SPEC.md +383 -13
- package/payload/delegation-kit/bin/run-dispatch-guard-tests.sh +97 -0
- package/payload/delegation-kit/checks/check-gate-tamper.sh +1 -1
- package/payload/delegation-kit/lib/delegation.sh +1 -0
- package/payload/delegation-kit/smoke/install.sh +2 -1
- package/payload/delegation-kit/templates/agent-dispatch-guard.sh +61 -0
- package/payload/delegation-kit/templates/agent-execution.md +103 -12
- package/payload/delegation-kit/templates/delegation-config.sh +4 -0
- package/payload/delegation-kit/templates/dispatch-checklists.md +1 -1
- package/payload/delegation-kit/usage-tests/dispatch-guard-cases.tsv +30 -0
- package/payload/doctrine-kit/DOCTRINE.md +27 -0
- package/payload/doctrine-kit/README.md +5 -0
- package/payload/doctrine-kit/SPEC.md +62 -3
- package/payload/doctrine-kit/bin/install-doctrine.sh +84 -4
- package/payload/doctrine-kit/smoke/install.sh +77 -1
- package/payload/drift-kit/README.md +3 -2
- package/payload/drift-kit/SPEC.md +253 -20
- package/payload/drift-kit/bin/stage-economics.sh +157 -3
- package/payload/drift-kit/kpis/kpi-incident-recurrence.sh +42 -0
- package/payload/drift-kit/smoke/install.sh +155 -1
- package/payload/drift-kit/templates/economics.md +9 -0
- package/payload/drift-kit/templates/kpis.list +6 -1
- package/payload/evidence-kit/README.md +20 -6
- package/payload/evidence-kit/SPEC.md +355 -17
- package/payload/evidence-kit/bin/run-validate.sh +51 -9
- package/payload/evidence-kit/checks/check-battery-roster.sh +86 -0
- package/payload/evidence-kit/checks/check-producer-liveness.sh +34 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/bad/args +1 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/bad/expect.txt +1 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/bad/runner.md +14 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/bad/scripts/evidence-config.sh +7 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/good/args +1 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/good/expect.txt +1 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/good/runner.md +14 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster/good/scripts/evidence-config.sh +7 -0
- package/payload/evidence-kit/gate-tests/check-battery-roster.test.sh +68 -0
- package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/args +1 -0
- package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/expect.txt +1 -0
- package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/run-validate.lock +1 -0
- package/payload/evidence-kit/gate-tests/check-producer-liveness/good/args +1 -0
- package/payload/evidence-kit/gate-tests/check-producer-liveness/good/expect.txt +2 -0
- package/payload/evidence-kit/gate-tests/check-producer-liveness/good/run-validate.lock +1 -0
- package/payload/evidence-kit/gate-tests/producer-lock.test.sh +109 -0
- package/payload/evidence-kit/lib/evidence.sh +18 -0
- package/payload/evidence-kit/smoke/install.sh +17 -3
- package/payload/gate-sdk/README.md +4 -1
- package/payload/gate-sdk/SPEC.md +1949 -74
- package/payload/gate-sdk/bin/gen-pre-commit.sh +12 -2
- package/payload/gate-sdk/bin/run-consumer-smoke.sh +121 -1
- package/payload/gate-sdk/bin/run-gate-tests.sh +40 -9
- package/payload/gate-sdk/bin/run-gates.sh +31 -2
- package/payload/gate-sdk/bin/upgrade-smoke.sh +3 -3
- package/payload/gate-sdk/checks/check-action-gh-repo.gate +2 -0
- package/payload/gate-sdk/checks/check-action-pinning.gate +2 -0
- package/payload/gate-sdk/checks/check-action-run-shell.sh +3 -1
- package/payload/gate-sdk/checks/check-core-files.sh +27 -4
- package/payload/gate-sdk/checks/check-exec-bit.sh +20 -1
- package/payload/gate-sdk/checks/check-gate-binary-fresh.sh +106 -0
- package/payload/gate-sdk/checks/check-gate-exemption-tasks.sh +6 -7
- package/payload/gate-sdk/checks/check-gate-output.sh +9 -1
- package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +302 -0
- package/payload/gate-sdk/checks/check-graph.sh +4 -5
- package/payload/gate-sdk/checks/check-readme-roster.sh +5 -0
- package/payload/gate-sdk/checks/check-reads-couples.sh +70 -21
- package/payload/gate-sdk/checks/check-template-registry-parity.sh +81 -0
- package/payload/gate-sdk/gate-tests/check-action-run-shell.test.sh +16 -1
- package/payload/gate-sdk/gate-tests/check-core-files.test.sh +64 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/args +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/expect.txt +5 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/kitroot/checks/check-vendored.gate +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/check-ported.gate +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gate-sdk-config.sh +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gates.list +4 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stamp.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stub-bin +6 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/args +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/expect.txt +5 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/kitroot/checks/check-vendored.gate +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/check-ported.gate +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gate-sdk-config.sh +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gates.list +4 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stamp.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stub-bin +5 -0
- package/payload/gate-sdk/gate-tests/check-gate-binary-fresh.test.sh +81 -0
- package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/TASK-QUEUE.md +3 -1
- package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/expect.txt +3 -1
- package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/gates/check-sample.sh +3 -1
- package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/bad/check-sample.sh +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/good/check-sample.sh +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/args +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/conservation.md +7 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +12 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/impl/gate.rs +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kitroot/check-orphan.rs +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/publish.yml +15 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-alpha.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.gate +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-orphan.gate +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gate-sdk-config.sh +6 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/stub-bin +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/targets.list +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/args +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/conservation.md +8 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +7 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/impl/gate.rs +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kitroot/check-other.rs +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/publish.yml +15 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-alpha.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-ported.gate +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gate-sdk-config.sh +6 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gates.list +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/stub-bin +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/targets.list +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-substrate-parity.test.sh +123 -0
- package/payload/gate-sdk/gate-tests/check-reads-couples.test.sh +139 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/templates/widgets.list +4 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-one.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-two.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/args +4 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/scripts/gate-sdk-config.sh +5 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/templates/widgets.list +4 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-one.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-two.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/args +8 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/rules.list +5 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/table.tsv +4 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/scripts/gate-sdk-config.sh +5 -0
- package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +4 -4
- package/payload/gate-sdk/gate-tests/lib-gate.test.sh +41 -1
- package/payload/gate-sdk/gate-tests/run-gate-tests.test.sh +144 -0
- package/payload/gate-sdk/lib/consumer-smoke.sh +26 -1
- package/payload/gate-sdk/lib/gate.sh +75 -0
- package/payload/gate-sdk/lib/inject.sh +21 -1
- package/payload/gate-sdk/smoke/install.sh +19 -1
- package/payload/guard-kit/README.md +4 -3
- package/payload/guard-kit/SPEC.md +88 -10
- package/payload/guard-kit/bin/compare-settings-allow.sh +40 -7
- package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +64 -0
- package/payload/guard-kit/lib/guard.sh +1 -0
- package/payload/guard-kit/templates/close-triage.md +35 -7
- package/payload/guard-kit/templates/guard-config.sh +3 -0
- package/payload/lifecycle-kit/README.md +1 -0
- package/payload/lifecycle-kit/SPEC.md +575 -29
- package/payload/lifecycle-kit/bin/enter-stage.sh +13 -3
- package/payload/lifecycle-kit/bin/file-gap.sh +42 -1
- package/payload/lifecycle-kit/bin/file-survey.sh +50 -0
- package/payload/lifecycle-kit/checks/check-merge-attrs.sh +1 -1
- package/payload/lifecycle-kit/checks/check-skill-binding.sh +1 -1
- package/payload/lifecycle-kit/checks/check-survey-record.sh +102 -0
- package/payload/lifecycle-kit/gate-tests/check-merge-attrs/bad/.gitattributes +1 -0
- package/payload/lifecycle-kit/gate-tests/check-merge-attrs/good/.gitattributes +1 -0
- package/payload/lifecycle-kit/gate-tests/check-merge-attrs.test.sh +1 -0
- package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/args +2 -0
- package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/expect.txt +4 -0
- package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/record.md +18 -0
- package/payload/lifecycle-kit/gate-tests/check-survey-record/good/args +2 -0
- package/payload/lifecycle-kit/gate-tests/check-survey-record/good/expect.txt +1 -0
- package/payload/lifecycle-kit/gate-tests/check-survey-record/good/record.md +13 -0
- package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +84 -0
- package/payload/lifecycle-kit/gate-tests/file-gap-recurrence.test.sh +94 -0
- package/payload/lifecycle-kit/gate-tests/survey-record-entry.test.sh +102 -0
- package/payload/lifecycle-kit/lib/stages.sh +8 -2
- package/payload/lifecycle-kit/smoke/install.sh +17 -1
- package/payload/lifecycle-kit/templates/consult.md +73 -0
- package/payload/lifecycle-kit/templates/lead.md +103 -7
- package/payload/lifecycle-kit/templates/stages/align.md +12 -0
- package/payload/lifecycle-kit/templates/stages/build.md +8 -0
- package/payload/lifecycle-kit/templates/stages/close.md +25 -4
- package/payload/lifecycle-kit/templates/stages/scope.md +34 -0
- package/payload/lifecycle-kit/templates/stages/spec.md +8 -0
- package/payload/lifecycle-kit/templates/stages/validate.md +8 -0
- package/payload/queue-kit/README.md +4 -1
- package/payload/queue-kit/SPEC.md +230 -6
- package/payload/queue-kit/bin/queue-edges.sh +78 -0
- package/payload/queue-kit/checks/check-queue-entry-budget.sh +5 -3
- package/payload/queue-kit/gate-tests/check-queue-hygiene/good/TASK-QUEUE.md +5 -0
- package/payload/queue-kit/gate-tests/queue-edges.test.sh +130 -0
- package/payload/queue-kit/smoke/install.sh +4 -1
- package/payload/queue-kit/templates/TASK-QUEUE.md +3 -0
- package/payload/site-kit/SPEC.md +41 -27
- package/payload/site-kit/smoke/install.sh +9 -1
- package/payload/gate-sdk/checks/check-action-gh-repo.sh +0 -321
- package/payload/gate-sdk/checks/check-action-pinning.sh +0 -55
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# spec: delegation-kit/SPEC.md §The delegation model — consumer-copy PreToolUse(Agent) dispatch-shape guard: D1 fork ban, D2 read-only isolation claim, D3 nested-dispatch advisory; register under matcher `Agent` beside the budget guard (§Layout and configuration)
|
|
3
|
+
set -uo pipefail
|
|
4
|
+
|
|
5
|
+
# shellcheck disable=SC2034 # consumed by the sourced lib/guard.sh (guard_block/guard_advise)
|
|
6
|
+
GUARD_NAME="agent-dispatch-guard"
|
|
7
|
+
GUARD_KIT_LIB="${GUARD_KIT_LIB:-guard-kit/lib/guard.sh}"
|
|
8
|
+
[[ -f "$GUARD_KIT_LIB" ]] || exit 0
|
|
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
|
+
source "$GUARD_KIT_LIB"
|
|
11
|
+
|
|
12
|
+
# spec: delegation-kit/SPEC.md §The delegation model — D2's roster is the only knob read here, so delegation-kit's validating loader is deliberately not sourced: a malformed *unrelated* knob must not wedge every dispatch
|
|
13
|
+
_adg_cfg="${DELEGATION_KIT_CONFIG_FILE:-${GATE_SDK_GATES_DIR:-scripts}/delegation-config.sh}"
|
|
14
|
+
_adg_roster_unreadable=""
|
|
15
|
+
if [[ -n "${DELEGATION_KIT_CONFIG_FILE:-}" && ! -f "$_adg_cfg" ]]; then
|
|
16
|
+
_adg_roster_unreadable="DELEGATION_KIT_CONFIG_FILE names no readable file"
|
|
17
|
+
elif [[ -f "$_adg_cfg" ]]; then
|
|
18
|
+
# shellcheck source=/dev/null # consumer-supplied config, path is config
|
|
19
|
+
source "$_adg_cfg"
|
|
20
|
+
fi
|
|
21
|
+
declare -p DELEGATION_KIT_READONLY_TYPES >/dev/null 2>&1 || DELEGATION_KIT_READONLY_TYPES=()
|
|
22
|
+
|
|
23
|
+
# spec: delegation-kit/SPEC.md §The delegation model — fail-open-but-loud: keep every advisory literal below free of any character JSON must escape, because the jq-absent arm hand-writes the envelope with no escaper
|
|
24
|
+
_adg_advise() {
|
|
25
|
+
local msg="agent-dispatch-guard: $1"
|
|
26
|
+
command -v jq >/dev/null 2>&1 && guard_advise "$msg"
|
|
27
|
+
printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"%s"}}\n' "$msg"
|
|
28
|
+
exit 0
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_adg_degraded() {
|
|
32
|
+
_adg_advise "allowed this dispatch WITHOUT enforcing the fork ban (D1) or the read-only isolation claim (D2) — $1. Check the dispatch by hand: no fork, and a child claimed read-only takes isolation: worktree (delegation-kit/SPEC.md §The delegation model)."
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
input="$(cat 2>/dev/null || true)"
|
|
36
|
+
|
|
37
|
+
command -v jq >/dev/null 2>&1 || _adg_degraded "jq is not on PATH, so the payload could not be read"
|
|
38
|
+
|
|
39
|
+
_adg_fields="$(printf '%s' "$input" | jq -r 'if (.tool_input | type) == "object" then [(.tool_input.subagent_type // ""), (.tool_input.isolation // ""), (if .agent_id then "nested" else "" end)] | @tsv else empty end' 2>/dev/null || true)"
|
|
40
|
+
[[ -n "$_adg_fields" ]] || _adg_degraded "the hook payload did not parse, or carried no tool_input object"
|
|
41
|
+
|
|
42
|
+
# spec: delegation-kit/SPEC.md §The delegation model — split on a non-whitespace separator: bash collapses runs of a *whitespace* IFS, so a tab split would silently shift an absent middle field onto the next name
|
|
43
|
+
IFS=$'\037' read -r _adg_type _adg_isolation _adg_nested <<<"${_adg_fields//$'\t'/$'\037'}"
|
|
44
|
+
|
|
45
|
+
# spec: delegation-kit/SPEC.md §The delegation model — D1 precedes D2 because the fork ban is unconditional and its message is the more specific one for a dispatch violating both
|
|
46
|
+
if [[ "$_adg_type" == "fork" ]]; then
|
|
47
|
+
guard_block "a fork inherits the dispatcher's whole context, toolset and model tier and disclaims nothing, so any narrowing this prompt states exists only as a sentence. Two lawful alternatives: dispatch a TYPED agent whose definition carries the narrower authority, brief and tier, so the narrowing is structural rather than requested; or, where the child does the same job at the same authority and you only want parallelism or its own index, dispatch that typed agent with isolation: worktree. There is no per-dispatch override — a knob here would restore the honour system this rule replaced, so the valve is unregistering the hook. The full protocol is /agent-execution (delegation-kit/SPEC.md §The delegation model)."
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
if [[ -n "$_adg_type" && "$_adg_isolation" != "worktree" && ${#DELEGATION_KIT_READONLY_TYPES[@]} -gt 0 ]]; then
|
|
51
|
+
for _adg_ro in "${DELEGATION_KIT_READONLY_TYPES[@]}"; do
|
|
52
|
+
[[ "$_adg_type" == "$_adg_ro" ]] && guard_block "'$_adg_type' is declared a read-only dispatch type (DELEGATION_KIT_READONLY_TYPES), but this dispatch's shape grants write reach — a subagent inherits its toolset from its type whatever the prompt says, and a type carrying no Edit or Write still reaches git through its shell. Make the claim with the shape: add isolation: worktree, whose commits and index are the child's own, and which the harness auto-cleans when the child really was read-only. If this type is not in fact dispatched read-only, drop it from the roster rather than working around the rule here (delegation-kit/SPEC.md §The delegation model)."
|
|
53
|
+
done
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
_adg_notes=""
|
|
57
|
+
[[ -n "$_adg_roster_unreadable" ]] && _adg_notes="D2 (the read-only isolation claim) went unenforced on this dispatch: $_adg_roster_unreadable. "
|
|
58
|
+
[[ "$_adg_nested" == "nested" ]] && _adg_notes="${_adg_notes}you are yourself a dispatched agent, so this call creates a grandchild with no upward channel to you: it cannot message you mid-run, and neither level knows its own address or its parent's. Give it return-value-only work, or grant it a durable path in the main checkout, named absolutely in its prompt, and read that path yourself (delegation-kit/SPEC.md §Operative residency)."
|
|
59
|
+
|
|
60
|
+
[[ -n "$_adg_notes" ]] || exit 0
|
|
61
|
+
_adg_advise "$_adg_notes"
|
|
@@ -11,6 +11,13 @@ For a **deletion, rename, or heavy cross-spec audit** dispatch, also load the
|
|
|
11
11
|
mechanical pre-flight in [dispatch-checklists.md](dispatch-checklists.md) — a
|
|
12
12
|
reach-through, not a change to this protocol; every rule below still applies.
|
|
13
13
|
|
|
14
|
+
Two bullets below — **Background + notification, never poll** and **Findings you
|
|
15
|
+
will act on are durable before you act on them** — bind a dispatched role that
|
|
16
|
+
fires no trigger loading this template, so each is also stated as a bare
|
|
17
|
+
imperative in the consumer's always-loaded agent definition under
|
|
18
|
+
delegation-kit/SPEC.md §Operative residency. That copy is sanctioned rather than
|
|
19
|
+
drift: do not delete it on sight, and when either rule changes here, propagate.
|
|
20
|
+
|
|
14
21
|
- **Supervisor owns rulings; agents surface, never guess.** SECURITY and design
|
|
15
22
|
rulings (e.g. a privileged caller set, a naming collision) are decided by the
|
|
16
23
|
supervisor and handed down; an agent that hits anything its brief doesn't cover
|
|
@@ -40,7 +47,7 @@ reach-through, not a change to this protocol; every rule below still applies.
|
|
|
40
47
|
role has.
|
|
41
48
|
- **Serialize on shared files; ≤`DELEGATION_KIT_FAN_WIDTH`-wide otherwise.**
|
|
42
49
|
Agents that edit a shared file (see the roster below) run one at a time —
|
|
43
|
-
dispatch, await notification,
|
|
50
|
+
dispatch, await notification, verify, dispatch the next. Independent
|
|
44
51
|
read-only units may run ≤`DELEGATION_KIT_FAN_WIDTH`-wide. **The git index and
|
|
45
52
|
HEAD are shared files for every agent that commits**, independent of
|
|
46
53
|
source-file disjointness: two committing agents racing `git add`/`git commit`
|
|
@@ -50,12 +57,49 @@ reach-through, not a change to this protocol; every rule below still applies.
|
|
|
50
57
|
≤`DELEGATION_KIT_FAN_WIDTH`-wide bound for **read-only** fan-outs. "No lockfile
|
|
51
58
|
churn" is a false safety signal — the index is shared regardless.
|
|
52
59
|
Serialization is by **completion**, not by notification: the next dispatch
|
|
53
|
-
begins after the previous one has *returned and been
|
|
60
|
+
begins after the previous one has *returned and been verified*. A supervisor
|
|
54
61
|
reaches that point via the completion notification; a **dispatched agent**
|
|
55
62
|
reaches it in-turn, awaiting each child before dispatching the next (it cannot
|
|
56
63
|
end its turn to wait — see the backgrounding rule). The ordering requirement
|
|
57
64
|
is identical for both; only the waiting mechanism differs, and neither role
|
|
58
65
|
may overlap two agents on a shared file or the git index.
|
|
66
|
+
- **Never dispatch a fork to narrow a child.** A fork is wrong exactly when the
|
|
67
|
+
dispatch's purpose is that the child does *less* than the parent: a fork
|
|
68
|
+
inherits the parent's context, toolset and model tier whole and disclaims
|
|
69
|
+
nothing, so every narrowing survives only as a sentence in the prompt. Three
|
|
70
|
+
dispatching contexts, each with its own grounds. A **read-only audit or
|
|
71
|
+
survey** wants narrower *authority* — the fork carries the parent's full
|
|
72
|
+
reach, so the restriction is a request, and one such fork completed a whole
|
|
73
|
+
stage, commits included. A **tier-split oracle** wants narrower *cost* — the
|
|
74
|
+
fork inherits the dispatcher's model, which is exactly the split the posture
|
|
75
|
+
exists to make (a lead posture that dispatches its own oracle is the named
|
|
76
|
+
instance). A **rule-injection dispatch** wants a *different* brief — attested
|
|
77
|
+
where five sibling forks each carried a line explaining that the roster's
|
|
78
|
+
agent definitions do not carry it, so fork was chosen to inject rules the
|
|
79
|
+
types lack and every one still paid to re-materialize its parent's context.
|
|
80
|
+
The boundary, stated honestly: a fork stays correct where the child does the
|
|
81
|
+
**same job at the same authority** and only parallelism or isolation is
|
|
82
|
+
wanted. The dispatch guard blocks there too, because a hook cannot read
|
|
83
|
+
intent and no sanctioned fork use exists in this doctrine — the valve is
|
|
84
|
+
unregistering the hook, never a per-dispatch knob, which would restore the
|
|
85
|
+
honour system the rule replaced (delegation-kit/SPEC.md §The delegation
|
|
86
|
+
model). Grounds measured rather than asserted: in one audited iteration ten
|
|
87
|
+
of twenty-four dispatched agents were forks, carrying 20.90 USD of 158.70 USD
|
|
88
|
+
of priced burn.
|
|
89
|
+
- **A read-only claim is made by isolation, not by sentence.** A dispatch whose
|
|
90
|
+
brief says "read-only, no edits" and whose *shape* grants write reach has made
|
|
91
|
+
no claim at all: a subagent inherits its toolset from its **type**, never from
|
|
92
|
+
the instruction text, and every type available for audit-shaped work carries
|
|
93
|
+
write tools or at least a shell that reaches `git` — so "it has no Edit tool"
|
|
94
|
+
is not the safety property it reads as. The claim is made by
|
|
95
|
+
`isolation: worktree`, whose commits and index are the child's own. Isolation
|
|
96
|
+
serves two purposes and only the first was ever written down here: an **own
|
|
97
|
+
index**, for an agent that *will* commit (the **Serialize on shared files**
|
|
98
|
+
rule above), and **write confinement**, for an agent *claimed* read-only. The
|
|
99
|
+
cost objection does not land — the harness auto-cleans a worktree left
|
|
100
|
+
unchanged, so the worktree survives **iff** the agent was not in fact
|
|
101
|
+
read-only, which makes the isolation simultaneously the confinement and the
|
|
102
|
+
detector.
|
|
59
103
|
- **One commit per unit, sized to finish within budget.** Each unit gets its own
|
|
60
104
|
commit (+ a `[blocked-by: prior]` tag where ordered). A unit that investigates
|
|
61
105
|
long before its first commit is the only thing an interrupt can destroy —
|
|
@@ -97,13 +141,48 @@ reach-through, not a change to this protocol; every rule below still applies.
|
|
|
97
141
|
their final message — which makes the journal mechanic non-functional exactly
|
|
98
142
|
when it matters (a long, interruptible run). So: for a **read-only fan-out**
|
|
99
143
|
(audit, survey), the return value *is* the contract — don't rely on a journal.
|
|
100
|
-
Reserve the journal
|
|
101
|
-
|
|
102
|
-
|
|
144
|
+
Reserve the **journal** for agents that **mutate files**, and for those grant
|
|
145
|
+
the journal path explicitly before dispatch rather than assuming the write
|
|
146
|
+
succeeds. **Worktree isolation is not reserved with it** — the two answer
|
|
147
|
+
different questions, and bundling them read as *a read-only fan-out needs no
|
|
148
|
+
isolation*, which is the reading that licensed an unreviewed commit on the
|
|
149
|
+
shared branch. A read-only fan-out takes isolation precisely *because* it is
|
|
150
|
+
claimed read-only (the **A read-only claim is made by isolation, not by
|
|
151
|
+
sentence** rule above). A contract has two ends, though: the child owes
|
|
103
152
|
no journal, and the **parent** owes the durable landing of what it received
|
|
104
153
|
before acting on it (next bullet). The caveat is about a backgrounded child's
|
|
105
154
|
write failing silently, so it never licensed the parent — which has already
|
|
106
155
|
demonstrated it can write, being the session that granted the path.
|
|
156
|
+
- **A child's only upward route is a durable artifact.** Probed, not assumed: a
|
|
157
|
+
child's sends to an invented dispatcher name and to its own agent type both
|
|
158
|
+
failed, only a send addressed to the **top-level session** arrived, and
|
|
159
|
+
neither level knows its own identity or its parent's. There is therefore no
|
|
160
|
+
address a child can use to reach the agent that dispatched it, and four
|
|
161
|
+
dispositions follow. **(1) A durable artifact, for anything mid-run** — the
|
|
162
|
+
dispatcher mints a path, names it **absolute into the main checkout** in the
|
|
163
|
+
prompt, and the child writes as it goes. That is already the journal rule
|
|
164
|
+
above; it is now also the *only* upward route there is, and it is stronger
|
|
165
|
+
than a message would be, because a file survives a child that dies before
|
|
166
|
+
returning. A **stop signal takes the same shape** — a sentinel the child
|
|
167
|
+
checks — so it is cooperative by construction and a wedged child stays out of
|
|
168
|
+
reach. **(2) Return-value only, otherwise** — a fan-out needing no mid-run
|
|
169
|
+
channel needs no artifact, which is the read-only carve-out above. **(3) The
|
|
170
|
+
downward half is a dispatch-shape rule** — a dispatcher that wants control
|
|
171
|
+
over its fan-out dispatches in the background and keeps the handle; what
|
|
172
|
+
actually failed was a dispatcher blocked on a foreground dispatch, holding
|
|
173
|
+
neither the handle nor a turn. **(4) Naming the address a child should use is
|
|
174
|
+
refused** — there is none, and the refusal is stated rather than omitted
|
|
175
|
+
because it is the first thing both original filings reached for. Two
|
|
176
|
+
corollaries defeat the workarounds a reader would otherwise invent: a message
|
|
177
|
+
that does reach the top-level session is attributed to the sender's **type**,
|
|
178
|
+
so a fan-out wider than one is ambiguous at the receiving end; and a child
|
|
179
|
+
resumed by a message from its dispatcher still cannot reply, so being
|
|
180
|
+
addressed creates no return path. One live hazard rides with them: the
|
|
181
|
+
message and stop tools may be **deferred** for a dispatched agent — callable
|
|
182
|
+
only after a discovery call it has to know to make — so a child that needs to
|
|
183
|
+
escalate may not hold the channel at all. Hence the obligation, which is the
|
|
184
|
+
part that binds you: **a dispatcher handing out work that will need a mid-run
|
|
185
|
+
channel grants a durable path with it**, and reads that path itself.
|
|
107
186
|
|
|
108
187
|
- **Findings you will act on are durable before you act on them.** A child's
|
|
109
188
|
return value lives only in your context, and your context dies with your
|
|
@@ -112,13 +191,25 @@ reach-through, not a change to this protocol; every rule below still applies.
|
|
|
112
191
|
survives you: a commit, or your own journal. The write is the parent's,
|
|
113
192
|
discharged on receipt, not a chore delegated back to the child. This binds
|
|
114
193
|
whoever holds findings they will act on, at any depth. It costs one write per
|
|
115
|
-
returned child, not a running narration.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
-
|
|
194
|
+
returned child, not a running narration. The obligation is **durability**, and
|
|
195
|
+
committing and journalling are two ways to discharge it — a session uses
|
|
196
|
+
whichever is available to it. A dispatched session journals, to the path it was
|
|
197
|
+
granted, because it cannot commit. A top-level session commits, because it can.
|
|
198
|
+
A top-level session that *cannot* commit right now — another session is holding
|
|
199
|
+
the shared index, the normal condition while an iteration is running — journals
|
|
200
|
+
for as long as that holds, and discharges by committing when the index frees.
|
|
201
|
+
Neither the supervising role nor a session running outside any dispatch is
|
|
202
|
+
exempt: the axis is what the session can do at this moment, never what it is.
|
|
203
|
+
- **Verify after every agent commit** — a sub-agent's "passed" claim is not
|
|
120
204
|
trustworthy. Re-run the relevant gates (the sweep's own gate) and the consumer
|
|
121
|
-
validate battery below
|
|
205
|
+
validate battery below — the act is `verify`, the artifact is the battery.
|
|
206
|
+
**Never verify a unit by re-running the producer of what it delivered**: where
|
|
207
|
+
the unit's deliverable *is* an evidence artifact, the verify is a **read** of
|
|
208
|
+
the committed artifact, because re-running its sole writer overwrites or
|
|
209
|
+
duplicates the record instead of checking it. Having already run the wrong
|
|
210
|
+
check, read delegation-kit/SPEC.md §Verify after every agent commit for which
|
|
211
|
+
of the two re-runs you are holding — only one of them leaves evidence to
|
|
212
|
+
restore. **Diff every gate change in an agent commit before
|
|
122
213
|
accepting** — a gate modification inside a feature commit is a supervisor-owned
|
|
123
214
|
ruling; an agent blocked by a gate will weaken it (a false exemption) to make
|
|
124
215
|
its commit pass instead of fixing the code. "The gate is in my way" almost
|
|
@@ -127,7 +218,7 @@ reach-through, not a change to this protocol; every rule below still applies.
|
|
|
127
218
|
two attested shapes (a gate edit co-staged with product code; a new path/glob
|
|
128
219
|
exemption co-staged with the file it excuses) — but it does **not** catch
|
|
129
220
|
semantic weakening inside a legitimate scripts-only commit, so the by-eye diff
|
|
130
|
-
review remains your duty (delegation-kit/SPEC.md §
|
|
221
|
+
review remains your duty (delegation-kit/SPEC.md §Verify after every agent
|
|
131
222
|
commit — the honest limit).
|
|
132
223
|
- **Budget-check before *each* dispatch in a fan-out**, not once at the start.
|
|
133
224
|
`bash delegation-kit/bin/usage-verdict.sh` (verdict exit 0/1/2 from `usage.txt` —
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
# shellcheck shell=bash
|
|
2
2
|
# spec: delegation-kit/SPEC.md §Layout and configuration — the knob table (every knob, its default, when to set it) and how to install this config; set only what you override
|
|
3
|
+
|
|
4
|
+
# spec: delegation-kit/SPEC.md §Layout and configuration — D2's roster: the consumer's own read-only-dispatched agent-type names; default empty (D2 inert) — never a kit-shipped vocabulary (CLAUDE.md §The provenance seam)
|
|
5
|
+
# shellcheck disable=SC2034 # consumed by templates/agent-dispatch-guard.sh after sourcing
|
|
6
|
+
# DELEGATION_KIT_READONLY_TYPES=()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
DISPATCH CHECKLISTS — a reach-through from [agent-execution.md](agent-execution.md),
|
|
2
2
|
loaded only when a dispatch is a deletion, a rename, or a heavy cross-spec audit.
|
|
3
3
|
It adds no new protocol: the safety, budget, resume-journal, and
|
|
4
|
-
|
|
4
|
+
verify-after-commit rules stay in `agent-execution.md` and still apply in full.
|
|
5
5
|
This file is the mechanical pre-flight for those dispatch shapes — the steps an
|
|
6
6
|
agent skips by reflex and the supervisor pays for later. Owned by
|
|
7
7
|
delegation-kit/SPEC.md §One template, a resident pointer.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Agent dispatch-guard decision table — <decision><TAB><subagent_type><TAB><isolation><TAB><nested><TAB><desc>.
|
|
2
|
+
# decision is block (exit 2) / advise (exit 0, additionalContext) / fallthrough
|
|
3
|
+
# (exit 0, no output). Tab-separated; # and blank lines ignored. '-' marks an
|
|
4
|
+
# absent isolation/nested value — never a truly empty field between tabs, since
|
|
5
|
+
# a whitespace IFS collapses runs of empty fields (the exact bug the guard's own
|
|
6
|
+
# jq-to-read split works around; see agent-dispatch-guard.sh).
|
|
7
|
+
#
|
|
8
|
+
# The runner fixes one roster for the whole table: DELEGATION_KIT_READONLY_TYPES=(ro-type).
|
|
9
|
+
# A subagent_type prefixed 'noroster:' runs with no roster config at all (an
|
|
10
|
+
# empty declare), proving D2 stays inert on the roster's absence rather than on
|
|
11
|
+
# this type's absence from a populated one; the prefix is stripped before it
|
|
12
|
+
# reaches the guard's payload. subagent_type UNPARSEABLE sends invalid JSON on
|
|
13
|
+
# stdin instead of a built payload.
|
|
14
|
+
|
|
15
|
+
# D1 — the fork ban is unconditional
|
|
16
|
+
block fork - - a fork dispatch blocks regardless of isolation or roster
|
|
17
|
+
fallthrough noroster:other-type - - a typed, non-fork dispatch is not blocked (no roster configured)
|
|
18
|
+
|
|
19
|
+
# D2 — a declared read-only type without isolation: worktree
|
|
20
|
+
block ro-type - - a rostered type dispatched without isolation: worktree blocks
|
|
21
|
+
fallthrough ro-type worktree - the same rostered type with isolation: worktree does not block
|
|
22
|
+
fallthrough other-type - - a typed dispatch outside a populated roster does not block
|
|
23
|
+
fallthrough noroster:ro-type - - D2 stays inert against an empty roster, even naming the type that would otherwise match
|
|
24
|
+
|
|
25
|
+
# D3 — nested-dispatch advisory (never blocks)
|
|
26
|
+
advise other-type - yes a payload carrying agent_id advises: this dispatch creates a grandchild
|
|
27
|
+
fallthrough other-type - - a payload with no agent_id falls through D3 untouched
|
|
28
|
+
|
|
29
|
+
# Degradation — fail-open, but loud
|
|
30
|
+
advise UNPARSEABLE - - an unparseable payload advises rather than blocks, naming what could not be enforced
|
|
@@ -384,3 +384,30 @@ link — an application of the load-trigger residency rule to the doctrine itsel
|
|
|
384
384
|
contract and the quiet-default run surfaces
|
|
385
385
|
([gate-sdk/SPEC.md](../gate-sdk/SPEC.md) §run-gates).
|
|
386
386
|
*Stages:* build
|
|
387
|
+
|
|
388
|
+
23. **An assertion reports the size of the set it ranged over.** A verification a
|
|
389
|
+
session writes — a scan, a probe, a predicate under edit — whose subject is a
|
|
390
|
+
set prints that set's size beside its verdict, because an exit code cannot
|
|
391
|
+
distinguish *asserted and held* from *asserted nothing*: both are zero
|
|
392
|
+
failures. The corollary governs the probe that proves an assertion bites — a
|
|
393
|
+
mutation is valid only against a target the assertion actually ranges over,
|
|
394
|
+
or it reports an empty red set and reads as a pass. *Quiet green, loud red*
|
|
395
|
+
puts that count on a batch runner's summary line; this is the same tripwire
|
|
396
|
+
one altitude down, for the one-off verification a session writes and reads
|
|
397
|
+
inside the session.
|
|
398
|
+
*Under agent work:* an agent writes the check and reads its verdict in one
|
|
399
|
+
motion, so the exit code is the only evidence it holds that the check bit —
|
|
400
|
+
and a predicate just rewritten (a regex carried between dialects, a path list
|
|
401
|
+
narrowed) fails by matching nothing, which is indistinguishable from success.
|
|
402
|
+
A printed count is the one signal that survives the rewrite.
|
|
403
|
+
*Enforced by:* judgment, over a class only partly mechanizable — stated
|
|
404
|
+
honestly rather than promised to a scanner. Shipped: the vacuous-pass
|
|
405
|
+
tripwire in [gate-sdk/SPEC.md](../gate-sdk/SPEC.md) §run-gates, and the
|
|
406
|
+
`good/`+`bad/` fixture pair every gate already owes
|
|
407
|
+
([gate-sdk/SPEC.md](../gate-sdk/SPEC.md) §The gate model), which exercises a
|
|
408
|
+
predicate rather than trusting it. Buildable but unbuilt: a branch-coverage
|
|
409
|
+
assertion over a check's fixture corpus, for the arm that ships with no
|
|
410
|
+
fixture to run it. Unreachable: whether a session's mutation probe targeted
|
|
411
|
+
something its assertion ranges over is a property of a session act that
|
|
412
|
+
leaves no residue in the tree, so that third stays judgment.
|
|
413
|
+
*Stages:* build, validate
|
|
@@ -62,6 +62,11 @@ Vendor the kit beside [gate-sdk](../gate-sdk/) (required), then:
|
|
|
62
62
|
inside the digest section. The gate holds the digest in per-rule lockstep with
|
|
63
63
|
the doctrine modulo declared trims, so a silent omission stays red; point
|
|
64
64
|
`DOCTRINE_KIT_DIGEST_SECTION` at your heading if it is not `## Delivery doctrine`.
|
|
65
|
+
The declaration survives the next run: the installer reads your block before it
|
|
66
|
+
rewrites it and carries each declared marker back into the trimmed rule's
|
|
67
|
+
position, so re-vendoring never restores a rule you removed. That is the only
|
|
68
|
+
customization it preserves — see
|
|
69
|
+
[SPEC.md](SPEC.md#install-doctrine) for the bound and the two findings it reports.
|
|
65
70
|
|
|
66
71
|
## Test
|
|
67
72
|
|
|
@@ -52,9 +52,11 @@ updated where it sits. A begin marker without its end is a malformed target: the
|
|
|
52
52
|
installer refuses (exit 2) rather than guess the block bounds. The agent file
|
|
53
53
|
must already exist — the installer edits an always-loaded file, it does not mint
|
|
54
54
|
one — so a missing target is exit 2. The marker insert/replace itself is not
|
|
55
|
-
this installer's code: it rides gate-sdk's shared `lib/inject.sh`
|
|
56
|
-
(`inject_marker_block`
|
|
57
|
-
|
|
55
|
+
this installer's code: it rides gate-sdk's shared `lib/inject.sh` helpers
|
|
56
|
+
(`inject_marker_block` to write, `read_marker_block` to read the block as it
|
|
57
|
+
stands), the single copy `lifecycle-kit`'s injector also uses;
|
|
58
|
+
`install-doctrine.sh` supplies the block content (the digest) on stdin and owns
|
|
59
|
+
every rule about what survives from one run to the next.
|
|
58
60
|
|
|
59
61
|
The block is the always-loaded shape applied to the doctrine itself: a one-line
|
|
60
62
|
digest of the methodology-maintenance rules plus a markdown link to the doctrine
|
|
@@ -70,6 +72,63 @@ keep resident stays legal, but rides a declared-trim marker rather than a silent
|
|
|
70
72
|
deletion: the gate asserts name-lockstep modulo declared trims (§check-doctrine-registration
|
|
71
73
|
assertion B).
|
|
72
74
|
|
|
75
|
+
**The declared-trim round-trip.** A generated block that is unconditionally
|
|
76
|
+
rewritten would revoke that right on the next run — and revoke it *silently*,
|
|
77
|
+
because a trim the installer restores to a bullet leaves an agent file whose
|
|
78
|
+
hash matches what the installer last recorded. So the run is read-compute-emit
|
|
79
|
+
rather than emit: `read_marker_block` returns the block as it stands, the
|
|
80
|
+
installer harvests every
|
|
81
|
+
`<!-- doctrine-digest-trim: <rule name> — <reason> -->` line out of it, and each
|
|
82
|
+
digest rule is emitted as **either** its bullet **or** — when that rule's name is
|
|
83
|
+
trimmed — the harvested marker line verbatim, **in the bullet's position**.
|
|
84
|
+
Substitution, not addition: a block carrying the trim *and* its bullet would
|
|
85
|
+
satisfy assertions B and C while handing the consumer back the rule they
|
|
86
|
+
removed, which is the customization defeated while appearing honored. In-place
|
|
87
|
+
rather than appended so the consumer's reason stays where the rule it answers
|
|
88
|
+
would have been; the gate accepts the marker anywhere in the digest section, so
|
|
89
|
+
readability decides. The rule names the substitution keys on are the digest's
|
|
90
|
+
own bullet names, read exactly as assertion C reads them — installer and gate
|
|
91
|
+
never disagree about which rule a marker names.
|
|
92
|
+
|
|
93
|
+
Four behaviors the round-trip fixes:
|
|
94
|
+
|
|
95
|
+
- **No trims declared → byte-identical output.** Load-bearing rather than
|
|
96
|
+
incidental: without it every consumer's agent file churns on every upgrade,
|
|
97
|
+
and the installer's caller starts reporting a file nobody edited.
|
|
98
|
+
- **A trim naming no rule in the current digest** — a rule renamed or dropped
|
|
99
|
+
upstream — is carried forward *and* reported. It has no bullet position to
|
|
100
|
+
take, so it is carried at the digest's end. Surfacing it at the re-vendor
|
|
101
|
+
moment is the declared-not-silent design working: that is the moment the
|
|
102
|
+
consumer's decision gets reconciled.
|
|
103
|
+
- **Duplicate trims for one rule** — the first is carried, the duplicate
|
|
104
|
+
dropped and reported. Silently collapsing them would be the same class of
|
|
105
|
+
quiet edit-loss one layer up.
|
|
106
|
+
- **The report has two channels, and the split is deliberate.** The standing
|
|
107
|
+
rule it instances: an installer a machine may drive puts **findings on
|
|
108
|
+
stderr** and narration on stdout, and stays silent on a clean run — stderr
|
|
109
|
+
chatter on success is how a channel gets ignored. So each finding above goes
|
|
110
|
+
to stderr, and the action line on stdout gains the count of trims carried and
|
|
111
|
+
a tally of those findings. What makes the rule binding here rather than merely
|
|
112
|
+
tidy is the caller class this script has: a vendoring installer whose own
|
|
113
|
+
stdout is a machine-read channel of seeded paths must discard this script's,
|
|
114
|
+
so stdout is exactly where a reconciliation the consumer owes would be lost.
|
|
115
|
+
The honest consequence is that under such a caller the count has no reader —
|
|
116
|
+
the carried trims are read from the commit that install makes — while every
|
|
117
|
+
finding still reaches whoever ran it.
|
|
118
|
+
|
|
119
|
+
**The honest bound.** The block is generated, and the declared trim is the only
|
|
120
|
+
customization preserved across a run. An unsanctioned edit *inside* the span — a
|
|
121
|
+
reworded bullet, an added line — is reverted by design, and would red
|
|
122
|
+
§check-doctrine-registration assertion C independently; everything *outside* the
|
|
123
|
+
markers is the adopter's and is never read or written. Stating the bound is what
|
|
124
|
+
makes the preserved case a contract rather than an accident.
|
|
125
|
+
|
|
126
|
+
The round-trip's acceptor is `smoke/install.sh`, per the coverage tier
|
|
127
|
+
gate-sdk/SPEC.md §lib/inject.sh sets for a sourced library with no gate surface:
|
|
128
|
+
it declares a trim in the block the installer just emitted, re-runs the
|
|
129
|
+
installer, and holds that the marker survived in the trimmed bullet's position,
|
|
130
|
+
that the bullet is gone, and that the gate is green across the re-run.
|
|
131
|
+
|
|
73
132
|
Positional overrides `install-doctrine.sh [agent-file [doctrine-file]]` let a
|
|
74
133
|
smoke or a fixture point both paths at a scratch tree without touching consumer
|
|
75
134
|
config; unset, they fall to the knob defaults.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# spec: doctrine-kit/SPEC.md §install-doctrine — idempotent insert/replace of the doctrine reference block between fixed markers in the always-loaded agent file
|
|
2
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — idempotent insert/replace of the doctrine reference block between fixed markers in the always-loaded agent file, carrying the consumer's declared trims across the rewrite
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
|
|
5
5
|
KIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
@@ -17,8 +17,8 @@ DOCTRINE_FILE="${2:-$DOCTRINE_KIT_DOCTRINE_FILE}"
|
|
|
17
17
|
BEGIN="<!-- doctrine-kit:begin -->"
|
|
18
18
|
END="<!-- doctrine-kit:end -->"
|
|
19
19
|
|
|
20
|
-
# spec: doctrine-kit/SPEC.md §install-doctrine — the
|
|
21
|
-
|
|
20
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — the untrimmed digest: the always-loaded shape applied to the doctrine itself, a one-line-per-rule digest plus the markdown link to the doctrine file
|
|
21
|
+
digest() {
|
|
22
22
|
cat <<EOF
|
|
23
23
|
## Delivery doctrine
|
|
24
24
|
|
|
@@ -40,5 +40,85 @@ an engineering-craft section behind the link:
|
|
|
40
40
|
EOF
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — a digest bullet's rule name, extracted exactly as check-doctrine-registration extracts it (assertion C), so the substitution keys on the same string the gate keys on
|
|
44
|
+
bullet_name() { # $1 = a digest line -> its bold lead-in name, non-zero when the line is not a rule bullet
|
|
45
|
+
local l="$1"
|
|
46
|
+
[[ "$l" == "- **"*"**"* ]] || return 1
|
|
47
|
+
l="${l#- \*\*}"
|
|
48
|
+
printf '%s\n' "${l%%\*\**}"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — the declared-trim grammar read exactly as check-doctrine-registration reads it (assertion B), so installer and gate never disagree about which rule a marker names
|
|
52
|
+
harvest_trims() { # block content on stdin -> one '<rule name><TAB><marker line verbatim>' per declared trim, in declaration order
|
|
53
|
+
awk '
|
|
54
|
+
/doctrine-digest-trim:/ {
|
|
55
|
+
name = $0
|
|
56
|
+
sub(/^.*doctrine-digest-trim:[[:space:]]*/, "", name)
|
|
57
|
+
sub(/[[:space:]]*—.*$/, "", name)
|
|
58
|
+
print name "\t" $0
|
|
59
|
+
}
|
|
60
|
+
'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — the round-trip's read half: the block as it stands is the only record of what the consumer declared, so it is harvested before the rewrite that would erase it
|
|
64
|
+
CURRENT="$(read_marker_block "$AGENT_FILE" "$BEGIN" "$END")" || exit $?
|
|
65
|
+
|
|
66
|
+
declare -A TRIM_LINE=()
|
|
67
|
+
TRIM_ORDER=()
|
|
68
|
+
DUPES=()
|
|
69
|
+
while IFS=$'\t' read -r tname tline; do
|
|
70
|
+
[[ -n "$tname" ]] || continue
|
|
71
|
+
if [[ -n "${TRIM_LINE[$tname]+set}" ]]; then
|
|
72
|
+
DUPES+=("$tname")
|
|
73
|
+
continue
|
|
74
|
+
fi
|
|
75
|
+
TRIM_LINE["$tname"]="$tline"
|
|
76
|
+
TRIM_ORDER+=("$tname")
|
|
77
|
+
done < <(printf '%s\n' "$CURRENT" | harvest_trims)
|
|
78
|
+
|
|
79
|
+
declare -A IS_RULE=()
|
|
80
|
+
while IFS= read -r dline; do
|
|
81
|
+
if rname="$(bullet_name "$dline")"; then IS_RULE["$rname"]=1; fi
|
|
82
|
+
done < <(digest)
|
|
83
|
+
|
|
84
|
+
ORPHANS=()
|
|
85
|
+
if [[ ${#TRIM_ORDER[@]} -gt 0 ]]; then
|
|
86
|
+
for tname in "${TRIM_ORDER[@]}"; do
|
|
87
|
+
[[ -n "${IS_RULE[$tname]:-}" ]] || ORPHANS+=("$tname")
|
|
88
|
+
done
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — the emit: a trimmed rule's marker replaces its bullet in place, because a block carrying both would satisfy the gate while handing back the rule the consumer removed
|
|
92
|
+
block() {
|
|
93
|
+
local line name
|
|
94
|
+
while IFS= read -r line; do
|
|
95
|
+
if name="$(bullet_name "$line")" && [[ -n "${TRIM_LINE[$name]+set}" ]]; then
|
|
96
|
+
printf '%s\n' "${TRIM_LINE[$name]}"
|
|
97
|
+
continue
|
|
98
|
+
fi
|
|
99
|
+
printf '%s\n' "$line"
|
|
100
|
+
done < <(digest)
|
|
101
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — a trim naming no live rule has no bullet position to take, so it is carried at the digest's end rather than dropped
|
|
102
|
+
if [[ ${#ORPHANS[@]} -gt 0 ]]; then
|
|
103
|
+
for name in "${ORPHANS[@]}"; do printf '%s\n' "${TRIM_LINE[$name]}"; done
|
|
104
|
+
fi
|
|
105
|
+
}
|
|
106
|
+
|
|
43
107
|
action="$(block | inject_marker_block "$AGENT_FILE" "$BEGIN" "$END")" || exit $?
|
|
44
|
-
|
|
108
|
+
|
|
109
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — findings go to stderr, the one channel init does not discard, so a reconciliation the consumer owes is never silent on the install path
|
|
110
|
+
if [[ ${#ORPHANS[@]} -gt 0 ]]; then
|
|
111
|
+
for tname in "${ORPHANS[@]}"; do
|
|
112
|
+
echo "install-doctrine: declared trim names '$tname', which no rule in the current doctrine digest matches — carried forward unchanged; adopt the renamed rule or drop the marker" >&2
|
|
113
|
+
done
|
|
114
|
+
fi
|
|
115
|
+
if [[ ${#DUPES[@]} -gt 0 ]]; then
|
|
116
|
+
for tname in "${DUPES[@]}"; do
|
|
117
|
+
echo "install-doctrine: duplicate declared trim for '$tname' — the first is carried, the duplicate dropped" >&2
|
|
118
|
+
done
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
findings=""
|
|
122
|
+
if [[ ${#ORPHANS[@]} -gt 0 ]]; then findings="$findings, ${#ORPHANS[@]} unmatched"; fi
|
|
123
|
+
if [[ ${#DUPES[@]} -gt 0 ]]; then findings="$findings, ${#DUPES[@]} duplicate"; fi
|
|
124
|
+
echo "install-doctrine: $action the doctrine reference block in $AGENT_FILE (link → $DOCTRINE_FILE); ${#TRIM_ORDER[@]} declared trim(s) carried$findings"
|
|
@@ -15,10 +15,86 @@ EOF
|
|
|
15
15
|
fi
|
|
16
16
|
bash "$SMOKE_KIT_ROOT/bin/install-doctrine.sh" >/dev/null
|
|
17
17
|
|
|
18
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — every assertion below reads the doctrine block alone, never the whole agent file: a consumer with several kits installed carries several marker blocks in one CLAUDE.md, and a bullet outside this kit's span is not this kit's to reason about
|
|
19
|
+
SMOKE_BEGIN="<!-- doctrine-kit:begin -->"
|
|
20
|
+
SMOKE_END="<!-- doctrine-kit:end -->"
|
|
21
|
+
smoke_block() { awk -v b="$SMOKE_BEGIN" -v e="$SMOKE_END" '$0 == e { inb = 0 } inb; $0 == b { inb = 1 }' CLAUDE.md; }
|
|
22
|
+
|
|
23
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — the declared-trim round-trip's acceptor. inject.sh is a sourced library with no gate surface (gate-sdk/SPEC.md §lib/inject.sh), so its read half and this installer's preservation rule are exercised here: declare a trim in the block the installer just emitted, re-run the installer, and hold that the marker survived *in the trimmed bullet's position* with the bullet gone and the gate green
|
|
24
|
+
mapfile -t SMOKE_RULES < <(smoke_block | awk '/^- \*\*/ { sub(/^- \*\*/, ""); sub(/\*\*.*/, ""); print }')
|
|
25
|
+
if [[ ${#SMOKE_RULES[@]} -lt 2 ]]; then
|
|
26
|
+
echo "doctrine smoke: the installed digest has fewer than two rule bullets — nothing to trim against" >&2
|
|
27
|
+
exit 2
|
|
28
|
+
fi
|
|
29
|
+
SMOKE_TRIMMED="${SMOKE_RULES[0]}"
|
|
30
|
+
SMOKE_NEXT="- **${SMOKE_RULES[1]}**"
|
|
31
|
+
SMOKE_TRIM="<!-- doctrine-digest-trim: $SMOKE_TRIMMED — smoke: the declared-trim round-trip acceptor -->"
|
|
32
|
+
|
|
33
|
+
awk -v b="$SMOKE_BEGIN" -v e="$SMOKE_END" -v bullet="- **$SMOKE_TRIMMED**" -v trim="$SMOKE_TRIM" '
|
|
34
|
+
$0 == b { inb = 1 }
|
|
35
|
+
$0 == e { inb = 0 }
|
|
36
|
+
inb && index($0, bullet) == 1 { print trim; next }
|
|
37
|
+
{ print }
|
|
38
|
+
' CLAUDE.md > CLAUDE.md.smoke && mv CLAUDE.md.smoke CLAUDE.md
|
|
39
|
+
|
|
40
|
+
bash "$SMOKE_KIT_ROOT/bin/install-doctrine.sh" >/dev/null
|
|
41
|
+
|
|
42
|
+
if ! smoke_block | grep -qF -- "$SMOKE_TRIM"; then
|
|
43
|
+
echo "doctrine smoke: the re-run dropped the declared trim for '$SMOKE_TRIMMED' — init silently revokes a customization doctrine-kit's own gate grants" >&2
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
if smoke_block | grep -qF -- "- **$SMOKE_TRIMMED**"; then
|
|
47
|
+
echo "doctrine smoke: the re-run restored the bullet for '$SMOKE_TRIMMED' — a block carrying the trim *and* its bullet hands back the rule the consumer removed" >&2
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
if [[ "$(smoke_block | grep -A1 -F -- "$SMOKE_TRIM" | tail -n1)" != "$SMOKE_NEXT"* ]]; then
|
|
51
|
+
echo "doctrine smoke: the carried trim for '$SMOKE_TRIMMED' is not in the trimmed bullet's position (expected '$SMOKE_NEXT' beneath it)" >&2
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
bash "$SMOKE_KIT_ROOT/checks/check-doctrine-registration.sh" >/dev/null \
|
|
55
|
+
|| { echo "doctrine smoke: check-doctrine-registration is not green across the trim round-trip" >&2; exit 1; }
|
|
56
|
+
|
|
57
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — the two reported findings, each carried *and* named. Both ride stderr, so this captures that channel and not stdout
|
|
58
|
+
SMOKE_ORPHAN="<!-- doctrine-digest-trim: Rule-that-left — smoke: renamed upstream -->"
|
|
59
|
+
SMOKE_DUP="<!-- doctrine-digest-trim: $SMOKE_TRIMMED — smoke: a second declaration for one rule -->"
|
|
60
|
+
awk -v e="$SMOKE_END" -v orphan="$SMOKE_ORPHAN" -v dup="$SMOKE_DUP" '
|
|
61
|
+
$0 == e { print orphan; print dup }
|
|
62
|
+
{ print }
|
|
63
|
+
' CLAUDE.md > CLAUDE.md.smoke && mv CLAUDE.md.smoke CLAUDE.md
|
|
64
|
+
|
|
65
|
+
SMOKE_ERR="$(bash "$SMOKE_KIT_ROOT/bin/install-doctrine.sh" 2>&1 >/dev/null)"
|
|
66
|
+
if ! smoke_block | grep -qF -- "$SMOKE_ORPHAN"; then
|
|
67
|
+
echo "doctrine smoke: the re-run dropped a trim naming no live rule — a rule renamed upstream must survive to the re-vendor moment, not vanish before the consumer can reconcile it" >&2
|
|
68
|
+
exit 1
|
|
69
|
+
fi
|
|
70
|
+
case "$SMOKE_ERR" in
|
|
71
|
+
*Rule-that-left*) : ;;
|
|
72
|
+
*) echo "doctrine smoke: a trim naming no live rule was carried but never reported (stderr was: $SMOKE_ERR)" >&2; exit 1 ;;
|
|
73
|
+
esac
|
|
74
|
+
if [[ "$(smoke_block | grep -cF -- "doctrine-digest-trim: $SMOKE_TRIMMED")" != "1" ]]; then
|
|
75
|
+
echo "doctrine smoke: the duplicate trim for '$SMOKE_TRIMMED' was not carried exactly once" >&2
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
case "$SMOKE_ERR" in
|
|
79
|
+
*duplicate*"$SMOKE_TRIMMED"*) : ;;
|
|
80
|
+
*) echo "doctrine smoke: the duplicate trim for '$SMOKE_TRIMMED' was collapsed silently (stderr was: $SMOKE_ERR)" >&2; exit 1 ;;
|
|
81
|
+
esac
|
|
82
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — carrying an unmatched trim forward is only safe if the gate tolerates one; a gate that red on it would hand the consumer a broken battery instead of a reconciliation
|
|
83
|
+
bash "$SMOKE_KIT_ROOT/checks/check-doctrine-registration.sh" >/dev/null \
|
|
84
|
+
|| { echo "doctrine smoke: check-doctrine-registration reds on a carried-forward trim naming no live rule — carrying it forward would break the consumer's battery" >&2; exit 1; }
|
|
85
|
+
|
|
86
|
+
# spec: doctrine-kit/SPEC.md §install-doctrine — the other direction, and the reason the smoke's steady state is an untrimmed consumer: withdrawing the declarations restores the bullet where it was
|
|
87
|
+
grep -v -F -e "$SMOKE_TRIM" -e "$SMOKE_ORPHAN" -e "$SMOKE_DUP" CLAUDE.md > CLAUDE.md.smoke && mv CLAUDE.md.smoke CLAUDE.md
|
|
88
|
+
bash "$SMOKE_KIT_ROOT/bin/install-doctrine.sh" >/dev/null
|
|
89
|
+
if ! smoke_block | grep -qF -- "- **$SMOKE_TRIMMED**"; then
|
|
90
|
+
echo "doctrine smoke: withdrawing the trim for '$SMOKE_TRIMMED' did not restore its bullet" >&2
|
|
91
|
+
exit 1
|
|
92
|
+
fi
|
|
93
|
+
|
|
18
94
|
cat >> scripts/gates.list <<'EOF'
|
|
19
95
|
# doctrine-kit
|
|
20
96
|
check-doctrine-registration
|
|
21
97
|
EOF
|
|
22
98
|
|
|
23
99
|
bash "$SDK/bin/gen-pre-commit.sh" --write >/dev/null
|
|
24
|
-
bash "$SDK/checks/check-graph.sh" --emit >
|
|
100
|
+
bash "$SDK/checks/check-graph.sh" --emit > scripts/CHECK-GRAPH.html
|
|
@@ -105,8 +105,9 @@ gates dir and naming it in the registry; shadow a bundled one with a same-named
|
|
|
105
105
|
file. The bundled set (drift-kit/SPEC.md §Bundled KPIs) covers, as lead KPIs, the
|
|
106
106
|
queue split and its per-iteration net delta, the gate backlog, amendment/deferred
|
|
107
107
|
age, prompt friction, the always-loaded surface, the local permission overlay,
|
|
108
|
-
gate runtime, session overhead, and the price table's age and expiry; and
|
|
109
|
-
|
|
108
|
+
gate runtime, session overhead, and the price table's age and expiry; and as lag
|
|
109
|
+
KPIs, `kpi-knowledge-friction` (fed by the loop below) and
|
|
110
|
+
`kpi-incident-recurrence` (fed by the queue's `recurrence:` declarations).
|
|
110
111
|
|
|
111
112
|
## Test
|
|
112
113
|
|