checkwright 0.21.0 → 0.23.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 +1013 -50
- package/lib/common/digest.sh +18 -0
- package/lib/common/lock.sh +40 -0
- package/lib/common/profile.sh +33 -0
- package/lib/common/recipe.sh +56 -43
- package/lib/diff.sh +64 -0
- package/lib/doctor.sh +81 -7
- package/lib/init.sh +167 -52
- package/lib/uninstall.sh +212 -0
- package/lib/update.sh +34 -0
- 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 +2 -0
- package/payload/canon-kit/SPEC.md +666 -59
- package/payload/canon-kit/checks/check-amendment-queue.sh +1 -0
- package/payload/canon-kit/checks/check-comment-tier.gate +3 -0
- package/payload/canon-kit/checks/check-deprecation-task.gate +3 -0
- package/payload/canon-kit/checks/check-docs-cmd.gate +3 -0
- package/payload/canon-kit/checks/check-docs-link-convention.sh +12 -4
- package/payload/canon-kit/checks/check-install-claim.gate +3 -0
- package/payload/canon-kit/checks/check-knob-citation.gate +3 -0
- package/payload/canon-kit/checks/check-knob-default-coupling.sh +1 -0
- package/payload/canon-kit/checks/check-manifest-count.gate +3 -0
- package/payload/canon-kit/checks/check-manifest-temporal.gate +3 -0
- package/payload/canon-kit/checks/check-md-refs.gate +3 -0
- package/payload/canon-kit/checks/check-measured-claim.gate +3 -0
- package/payload/canon-kit/checks/check-payload-claim.gate +3 -0
- package/payload/canon-kit/checks/check-prose-enum.gate +3 -0
- package/payload/canon-kit/checks/check-prose-tells.sh +1 -0
- package/payload/canon-kit/checks/check-spec-derivable-section.gate +3 -0
- package/payload/canon-kit/checks/check-spec-dod-singleton.gate +3 -0
- package/payload/canon-kit/checks/check-spec-embedded-source.sh +1 -0
- package/payload/canon-kit/checks/check-spec-fence-balance.gate +3 -0
- package/payload/canon-kit/checks/check-spec-pointer.gate +3 -0
- package/payload/canon-kit/checks/check-surface-duplication.sh +1 -0
- package/payload/canon-kit/checks/check-todo-task-liveness.gate +3 -0
- package/payload/canon-kit/checks/check-tracking-claim.gate +3 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/bad/.workflow/fixture-state.txt +4 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/bad/bad.gate +4 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/bad/bad.rs +5 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/bad/expect.txt +4 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/bad/templates/bad-tmpl.sh +4 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/good/.workflow/fixture-state.txt +3 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/good/expect.txt +1 -1
- package/payload/canon-kit/gate-tests/check-comment-tier/good/good.gate +4 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/good/good.rs +5 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/good/good.sh +3 -0
- package/payload/canon-kit/gate-tests/check-comment-tier/good/templates/good-tmpl.sh +5 -0
- package/payload/canon-kit/gate-tests/check-comment-tier.test.sh +29 -5
- package/payload/canon-kit/gate-tests/check-deprecation-task/bad/.workflow/fixture-state.txt +3 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/bad/bad.gate +2 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/bad/bad.rs +4 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/bad/expect.txt +3 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/bad/scripts/canon-config.sh +6 -5
- package/payload/canon-kit/gate-tests/check-deprecation-task/bad/templates/tmpl.sh +5 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/good/.workflow/fixture-state.txt +3 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/good/expect.txt +1 -1
- package/payload/canon-kit/gate-tests/check-deprecation-task/good/good.gate +2 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/good/good.rs +4 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task/good/scripts/canon-config.sh +6 -5
- package/payload/canon-kit/gate-tests/check-deprecation-task/good/templates/tmpl.sh +5 -0
- package/payload/canon-kit/gate-tests/check-deprecation-task.test.sh +4 -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-knob-citation.test.sh +2 -2
- package/payload/canon-kit/gate-tests/check-manifest-count/good/SPEC.md +4 -0
- package/payload/canon-kit/gate-tests/check-manifest-count.test.sh +32 -8
- package/payload/canon-kit/gate-tests/check-md-refs.test.sh +61 -9
- package/payload/canon-kit/gate-tests/check-measured-claim/bad/SPEC.md +12 -0
- package/payload/canon-kit/gate-tests/check-measured-claim/bad/expect.txt +3 -0
- package/payload/canon-kit/gate-tests/check-measured-claim/bad/scripts/canon-config.sh +6 -0
- package/payload/canon-kit/gate-tests/check-measured-claim/good/SPEC.md +23 -0
- package/payload/canon-kit/gate-tests/check-measured-claim/good/expect.txt +1 -0
- package/payload/canon-kit/gate-tests/check-measured-claim/good/scripts/canon-config.sh +6 -0
- package/payload/canon-kit/gate-tests/check-measured-claim.test.sh +90 -0
- 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 +27 -4
- package/payload/canon-kit/gate-tests/check-spec-dod-singleton.test.sh +21 -7
- package/payload/canon-kit/gate-tests/check-spec-pointer/bad/.workflow/fixture-state.txt +2 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/bad/bad.gate +2 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/bad/bad.rs +4 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/bad/expect.txt +4 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/bad/templates/tmpl.sh +5 -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/.workflow/fixture-state.txt +2 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/good/expect.txt +1 -1
- package/payload/canon-kit/gate-tests/check-spec-pointer/good/good.gate +2 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/good/good.rs +4 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/good/templates/tmpl.sh +5 -0
- package/payload/canon-kit/gate-tests/check-spec-pointer/good/widget.sh +1 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/.workflow/fixture-state.txt +3 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/bad.gate +2 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/bad.rs +4 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/expect.txt +3 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/templates/tmpl.sh +5 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/.workflow/fixture-state.txt +3 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/expect.txt +1 -1
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/good.gate +2 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/good.rs +4 -0
- package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/templates/tmpl.sh +5 -0
- package/payload/canon-kit/gate-tests/check-tracking-claim.test.sh +1 -2
- package/payload/canon-kit/lib/spec.sh +109 -70
- package/payload/canon-kit/smoke/install.sh +21 -1
- package/payload/canon-kit/templates/SPEC-amendment.md +9 -2
- package/payload/context-kit/README.md +4 -1
- package/payload/context-kit/SPEC.md +166 -9
- package/payload/context-kit/bin/env-probe.sh +19 -6
- package/payload/context-kit/checks/check-brevity.sh +1 -0
- package/payload/context-kit/checks/check-footprint-fresh.sh +1 -0
- package/payload/context-kit/checks/check-memory-off.sh +1 -0
- package/payload/context-kit/checks/check-settings-paths.sh +94 -0
- package/payload/context-kit/checks/check-settings-pins.sh +1 -0
- package/payload/context-kit/gate-tests/check-settings-paths/bad/args +1 -0
- package/payload/context-kit/gate-tests/check-settings-paths/bad/expect.txt +3 -0
- package/payload/context-kit/gate-tests/check-settings-paths/bad/settings.json +12 -0
- package/payload/context-kit/gate-tests/check-settings-paths/bad/tools/real-tool.sh +4 -0
- package/payload/context-kit/gate-tests/check-settings-paths/good/args +1 -0
- package/payload/context-kit/gate-tests/check-settings-paths/good/expect.txt +1 -0
- package/payload/context-kit/gate-tests/check-settings-paths/good/settings.json +16 -0
- package/payload/context-kit/gate-tests/check-settings-paths/good/tools/real-tool.sh +4 -0
- package/payload/context-kit/index-tests/expected/toolfloor.txt +9 -0
- package/payload/context-kit/index-tests/toolfloor-cases.sh +20 -0
- package/payload/context-kit/lib/toolfloor.sh +15 -4
- package/payload/context-kit/smoke/agents-md.sh +12 -1
- package/payload/context-kit/smoke/install.sh +4 -1
- package/payload/delegation-kit/README.md +3 -3
- package/payload/delegation-kit/SPEC.md +499 -26
- package/payload/delegation-kit/bin/run-dispatch-guard-tests.sh +97 -0
- package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +1 -0
- package/payload/delegation-kit/checks/check-gate-tamper.sh +2 -1
- package/payload/delegation-kit/checks/check-rule-citation.sh +1 -0
- 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 +127 -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/templates/statusline-usage.sh +23 -1
- package/payload/delegation-kit/usage-tests/dispatch-guard-cases.tsv +30 -0
- package/payload/doctrine-kit/DOCTRINE.md +112 -11
- package/payload/doctrine-kit/README.md +12 -3
- package/payload/doctrine-kit/SPEC.md +163 -11
- package/payload/doctrine-kit/bin/install-doctrine.sh +167 -17
- package/payload/doctrine-kit/checks/check-doctrine-registration.sh +41 -11
- package/payload/doctrine-kit/gate-tests/check-doctrine-registration/bad/DOCTRINE.md +3 -0
- package/payload/doctrine-kit/gate-tests/check-doctrine-registration/good/DOCTRINE.md +3 -0
- package/payload/doctrine-kit/gate-tests/check-doctrine-registration.test.sh +82 -2
- package/payload/doctrine-kit/smoke/install.sh +167 -1
- package/payload/drift-kit/README.md +3 -2
- package/payload/drift-kit/SPEC.md +264 -22
- package/payload/drift-kit/bin/kfric.sh +21 -2
- 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 +183 -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 +87 -0
- package/payload/evidence-kit/checks/check-evidence-baseline.sh +1 -0
- package/payload/evidence-kit/checks/check-evidence-manifest.sh +1 -0
- package/payload/evidence-kit/checks/check-producer-liveness.sh +35 -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 +17 -1
- package/payload/gate-sdk/SPEC.md +4427 -92
- package/payload/gate-sdk/bin/build-native.sh +38 -0
- package/payload/gate-sdk/bin/enforcement-map.sh +2 -1
- package/payload/gate-sdk/bin/gen-pre-commit.sh +32 -2
- package/payload/gate-sdk/bin/port-blockers.sh +445 -0
- package/payload/gate-sdk/bin/run-consumer-smoke.sh +129 -2
- package/payload/gate-sdk/bin/run-gate-tests.sh +61 -9
- package/payload/gate-sdk/bin/run-gates.sh +37 -2
- package/payload/gate-sdk/bin/upgrade-smoke.sh +55 -7
- package/payload/gate-sdk/checks/check-action-gh-repo.gate +3 -0
- package/payload/gate-sdk/checks/check-action-pinning.gate +3 -0
- package/payload/gate-sdk/checks/check-action-run-shell.sh +4 -1
- package/payload/gate-sdk/checks/check-assertion-strength.gate +3 -0
- package/payload/gate-sdk/checks/check-commit-msg.sh +1 -0
- package/payload/gate-sdk/checks/check-commit-subject.sh +1 -0
- package/payload/gate-sdk/checks/check-core-files.sh +28 -4
- package/payload/gate-sdk/checks/check-crate-arms.sh +61 -0
- package/payload/gate-sdk/checks/check-enforcement-fresh.sh +1 -0
- package/payload/gate-sdk/checks/check-exec-bit.sh +21 -1
- package/payload/gate-sdk/checks/check-gate-assertions.sh +31 -6
- package/payload/gate-sdk/checks/check-gate-binary-fresh.sh +107 -0
- package/payload/gate-sdk/checks/check-gate-exemption-tasks.sh +7 -7
- package/payload/gate-sdk/checks/check-gate-fail-closed.sh +1 -0
- package/payload/gate-sdk/checks/check-gate-fixture-coverage.sh +1 -0
- package/payload/gate-sdk/checks/check-gate-output.sh +41 -3
- package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +333 -0
- package/payload/gate-sdk/checks/check-graph.sh +5 -5
- package/payload/gate-sdk/checks/check-hook-exec-bit.sh +1 -0
- package/payload/gate-sdk/checks/check-identity.sh +1 -0
- package/payload/gate-sdk/checks/check-install-disposition.sh +92 -0
- package/payload/gate-sdk/checks/check-kit-enum.sh +1 -0
- package/payload/gate-sdk/checks/check-kit-registration.gate +3 -0
- package/payload/gate-sdk/checks/check-readme-roster.sh +6 -0
- package/payload/gate-sdk/checks/check-reads-couples.sh +71 -21
- package/payload/gate-sdk/checks/check-root-tiering.sh +1 -0
- package/payload/gate-sdk/checks/check-shellcheck.sh +1 -0
- package/payload/gate-sdk/checks/check-smoke-entry-guard.gate +3 -0
- package/payload/gate-sdk/checks/check-template-copy-parity.sh +1 -0
- package/payload/gate-sdk/checks/check-template-registry-parity.gate +3 -0
- package/payload/gate-sdk/checks/check-test-hermetic.gate +3 -0
- package/payload/gate-sdk/checks/check-tree-terms.sh +1 -0
- package/payload/gate-sdk/checks/check-workflow-tiering.sh +2 -1
- 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-crate-arms/bad/crate/Cargo.toml +7 -0
- package/payload/gate-sdk/gate-tests/check-crate-arms/bad/crate/src/lib.rs +12 -0
- package/payload/gate-sdk/gate-tests/check-crate-arms/bad/expect.txt +5 -0
- package/payload/gate-sdk/gate-tests/check-crate-arms/bad/scripts/gate-sdk-config.sh +2 -0
- package/payload/gate-sdk/gate-tests/check-crate-arms/good/crate/Cargo.toml +7 -0
- package/payload/gate-sdk/gate-tests/check-crate-arms/good/crate/src/lib.rs +11 -0
- package/payload/gate-sdk/gate-tests/check-crate-arms/good/expect.txt +2 -0
- package/payload/gate-sdk/gate-tests/check-crate-arms/good/scripts/gate-sdk-config.sh +2 -0
- package/payload/gate-sdk/gate-tests/check-gate-assertions/good/expect.txt +1 -1
- 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-native-sample.gate +3 -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/bad/expect.txt +3 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/bad/gates.list +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/bad/native/Cargo.toml +4 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/bad/native/src/gates/native_sample.rs +7 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/good/check-native-sample.gate +3 -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-output/good/gates.list +1 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/good/native/Cargo.toml +4 -0
- package/payload/gate-sdk/gate-tests/check-gate-output/good/native/src/gates/native_sample.rs +11 -0
- package/payload/gate-sdk/gate-tests/check-gate-output.test.sh +111 -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 +184 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/checks/check-alpha.sh +6 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/checks/check-delta.sh +5 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/checks/check-epsilon.sh +6 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/smoke/install.sh +7 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/args +6 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/installer/lib/common/recipe.sh +9 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/bad/scripts/gate-sdk-config.sh +5 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/checks/check-alpha.sh +6 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/checks/check-beta.gate +3 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/checks/check-gamma.sh +6 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/smoke/install.sh +8 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/args +6 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/installer/lib/common/recipe.sh +10 -0
- package/payload/gate-sdk/gate-tests/check-install-disposition/good/scripts/gate-sdk-config.sh +5 -0
- package/payload/gate-sdk/gate-tests/check-kit-registration.test.sh +6 -5
- 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/check-test-hermetic-smoke.test.sh +2 -3
- package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +4 -4
- package/payload/gate-sdk/gate-tests/lib-gate.test.sh +151 -1
- package/payload/gate-sdk/gate-tests/run-dispatch-streams.test.sh +73 -0
- package/payload/gate-sdk/gate-tests/run-gate-tests.test.sh +144 -0
- package/payload/gate-sdk/lib/consumer-smoke.sh +41 -4
- package/payload/gate-sdk/lib/gate.sh +208 -9
- package/payload/gate-sdk/lib/inject.sh +46 -1
- package/payload/gate-sdk/lib/test-hermetic.sh +26 -0
- package/payload/gate-sdk/smoke/install.sh +61 -1
- package/payload/guard-kit/README.md +18 -14
- package/payload/guard-kit/SPEC.md +366 -72
- package/payload/guard-kit/bin/compare-settings-allow.sh +40 -7
- package/payload/guard-kit/bin/run-guard-tests.sh +1 -0
- package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +64 -0
- package/payload/guard-kit/gate-tests/guard-read-path.test.sh +52 -0
- package/payload/guard-kit/guard-tests/cases.tsv +49 -7
- package/payload/guard-kit/lib/guard.sh +277 -54
- package/payload/guard-kit/templates/close-triage.md +38 -10
- package/payload/guard-kit/templates/guard-config.sh +3 -0
- package/payload/guard-kit/templates/settings-hooks.json +7 -1
- package/payload/lifecycle-kit/README.md +12 -1
- package/payload/lifecycle-kit/SPEC.md +991 -41
- package/payload/lifecycle-kit/bin/cite-survey.sh +81 -0
- package/payload/lifecycle-kit/bin/enter-stage.sh +139 -13
- package/payload/lifecycle-kit/bin/file-gap.sh +60 -2
- package/payload/lifecycle-kit/bin/file-survey.sh +69 -0
- package/payload/lifecycle-kit/checks/check-close-surfaces.sh +1 -0
- package/payload/lifecycle-kit/checks/check-gap-inbox-neutrality.gate +3 -0
- package/payload/lifecycle-kit/checks/check-lesson-disposition.gate +3 -0
- package/payload/lifecycle-kit/checks/check-lifecycle-registration.gate +3 -0
- package/payload/lifecycle-kit/checks/check-merge-attrs.gate +3 -0
- package/payload/lifecycle-kit/checks/check-scratch-citation.gate +3 -0
- package/payload/lifecycle-kit/checks/check-shim-restatement.gate +3 -0
- package/payload/lifecycle-kit/checks/check-skill-binding.gate +3 -0
- package/payload/lifecycle-kit/checks/check-stage-entry.sh +1 -0
- package/payload/lifecycle-kit/checks/check-stage-evidence.gate +3 -0
- package/payload/lifecycle-kit/checks/check-stage-skill-coverage.gate +3 -0
- package/payload/lifecycle-kit/checks/check-survey-record.gate +3 -0
- package/payload/lifecycle-kit/gate-tests/check-close-surfaces.test.sh +1 -2
- package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/bad/args +2 -0
- package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/bad/expect.txt +3 -0
- package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/bad/gap-inbox.md +5 -0
- package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/good/args +2 -0
- package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/good/expect.txt +1 -0
- package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/good/gap-inbox.md +4 -0
- package/payload/lifecycle-kit/gate-tests/check-lesson-disposition.test.sh +2 -3
- package/payload/lifecycle-kit/gate-tests/check-lifecycle-registration.test.sh +2 -3
- 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 +3 -3
- package/payload/lifecycle-kit/gate-tests/check-scratch-citation/bad/expect.txt +1 -0
- package/payload/lifecycle-kit/gate-tests/check-scratch-citation/bad/scripts/lifecycle-config.sh +4 -0
- package/payload/lifecycle-kit/gate-tests/check-scratch-citation/bad/surfaces/queue.md +13 -0
- package/payload/lifecycle-kit/gate-tests/check-scratch-citation/good/expect.txt +1 -0
- package/payload/lifecycle-kit/gate-tests/check-scratch-citation/good/scripts/lifecycle-config.sh +4 -0
- package/payload/lifecycle-kit/gate-tests/check-scratch-citation/good/surfaces/queue.md +31 -0
- package/payload/lifecycle-kit/gate-tests/check-shim-restatement.test.sh +2 -3
- package/payload/lifecycle-kit/gate-tests/check-skill-binding.test.sh +2 -3
- package/payload/lifecycle-kit/gate-tests/check-stage-entry.test.sh +2 -3
- package/payload/lifecycle-kit/gate-tests/check-stage-evidence.test.sh +9 -5
- 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 +83 -0
- package/payload/lifecycle-kit/gate-tests/file-gap-recurrence.test.sh +122 -0
- package/payload/lifecycle-kit/gate-tests/rename-iteration.test.sh +142 -0
- package/payload/lifecycle-kit/gate-tests/survey-record-entry.test.sh +102 -0
- package/payload/lifecycle-kit/gate-tests/workflow-state-guard.test.sh +100 -0
- package/payload/lifecycle-kit/lib/stages.sh +12 -2
- package/payload/lifecycle-kit/smoke/install.sh +83 -4
- package/payload/lifecycle-kit/templates/consult.md +73 -0
- package/payload/lifecycle-kit/templates/lead.md +139 -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 +45 -5
- package/payload/lifecycle-kit/templates/stages/scope.md +42 -3
- package/payload/lifecycle-kit/templates/stages/spec.md +13 -1
- package/payload/lifecycle-kit/templates/stages/validate.md +8 -0
- package/payload/lifecycle-kit/templates/workflow-state-guard.sh +29 -0
- package/payload/queue-kit/README.md +6 -1
- package/payload/queue-kit/SPEC.md +350 -6
- package/payload/queue-kit/bin/queue-counts.sh +35 -0
- package/payload/queue-kit/bin/queue-edges.sh +78 -0
- package/payload/queue-kit/checks/check-queue-entry-budget.gate +3 -0
- package/payload/queue-kit/checks/check-queue-hygiene.gate +3 -0
- package/payload/queue-kit/checks/check-queue-prose-precondition.sh +1 -0
- package/payload/queue-kit/checks/check-queue-sections.gate +3 -0
- package/payload/queue-kit/checks/check-queue-slug-liveness.gate +3 -0
- package/payload/queue-kit/checks/check-queue-wrap.gate +3 -0
- package/payload/queue-kit/checks/check-roadmap-fresh.sh +1 -0
- package/payload/queue-kit/checks/check-tag-lead-line.gate +3 -0
- package/payload/queue-kit/checks/check-task-conservation.gate +4 -0
- package/payload/queue-kit/checks/check-task-names.gate +3 -0
- package/payload/queue-kit/gate-tests/check-queue-hygiene/good/TASK-QUEUE.md +5 -0
- package/payload/queue-kit/gate-tests/queue-counts.test.sh +116 -0
- package/payload/queue-kit/gate-tests/queue-edges.test.sh +130 -0
- package/payload/queue-kit/gate-tests/queue-lib-parity.test.sh +215 -0
- package/payload/queue-kit/lib/queue.sh +4 -19
- 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 +64 -27
- package/payload/site-kit/checks/check-docs-cname-parity.sh +1 -0
- package/payload/site-kit/checks/check-docs-render-fidelity.sh +1 -0
- package/payload/site-kit/smoke/install.sh +9 -1
- package/profiles.list +36 -8
- package/payload/canon-kit/checks/check-comment-tier.sh +0 -211
- package/payload/canon-kit/checks/check-deprecation-task.sh +0 -90
- package/payload/canon-kit/checks/check-docs-cmd.sh +0 -153
- package/payload/canon-kit/checks/check-install-claim.sh +0 -146
- package/payload/canon-kit/checks/check-knob-citation.sh +0 -117
- package/payload/canon-kit/checks/check-manifest-count.sh +0 -46
- package/payload/canon-kit/checks/check-manifest-temporal.sh +0 -83
- package/payload/canon-kit/checks/check-md-refs.sh +0 -128
- package/payload/canon-kit/checks/check-prose-enum.sh +0 -115
- package/payload/canon-kit/checks/check-spec-derivable-section.sh +0 -69
- package/payload/canon-kit/checks/check-spec-dod-singleton.sh +0 -45
- package/payload/canon-kit/checks/check-spec-fence-balance.sh +0 -42
- package/payload/canon-kit/checks/check-spec-pointer.sh +0 -180
- package/payload/canon-kit/checks/check-todo-task-liveness.sh +0 -80
- package/payload/canon-kit/checks/check-tracking-claim.sh +0 -136
- package/payload/gate-sdk/checks/check-action-gh-repo.sh +0 -321
- package/payload/gate-sdk/checks/check-action-pinning.sh +0 -55
- package/payload/gate-sdk/checks/check-assertion-strength.sh +0 -134
- package/payload/gate-sdk/checks/check-kit-registration.sh +0 -68
- package/payload/gate-sdk/checks/check-smoke-entry-guard.sh +0 -53
- package/payload/gate-sdk/checks/check-test-hermetic.sh +0 -119
- package/payload/lifecycle-kit/checks/check-lesson-disposition.sh +0 -98
- package/payload/lifecycle-kit/checks/check-lifecycle-registration.sh +0 -54
- package/payload/lifecycle-kit/checks/check-merge-attrs.sh +0 -69
- package/payload/lifecycle-kit/checks/check-shim-restatement.sh +0 -97
- package/payload/lifecycle-kit/checks/check-skill-binding.sh +0 -59
- package/payload/lifecycle-kit/checks/check-stage-evidence.sh +0 -81
- package/payload/lifecycle-kit/checks/check-stage-skill-coverage.sh +0 -47
- package/payload/queue-kit/checks/check-queue-entry-budget.sh +0 -104
- package/payload/queue-kit/checks/check-queue-hygiene.sh +0 -81
- package/payload/queue-kit/checks/check-queue-sections.sh +0 -44
- package/payload/queue-kit/checks/check-queue-slug-liveness.sh +0 -63
- package/payload/queue-kit/checks/check-queue-wrap.sh +0 -56
- package/payload/queue-kit/checks/check-tag-lead-line.sh +0 -70
- package/payload/queue-kit/checks/check-task-conservation.sh +0 -50
- package/payload/queue-kit/checks/check-task-names.sh +0 -128
|
@@ -23,10 +23,11 @@ unset _frik_cfg
|
|
|
23
23
|
: "${GUARD_KIT_WAKEUP_LOG:=${GATE_SDK_WORKFLOW_DIR:-.workflow}/wakeup-attempts.log}"
|
|
24
24
|
: "${GUARD_KIT_SETTINGS:=.claude/settings.json}"
|
|
25
25
|
: "${GUARD_KIT_SETTINGS_LOCAL:=.claude/settings.local.json}"
|
|
26
|
+
declare -p GUARD_KIT_BREADTH_PROBES >/dev/null 2>&1 || GUARD_KIT_BREADTH_PROBES=()
|
|
26
27
|
declare -p GUARD_KIT_RO_SCRIPTS >/dev/null 2>&1 || GUARD_KIT_RO_SCRIPTS=("check-*.sh")
|
|
27
28
|
declare -p GUARD_KIT_SCRATCH_DIRS >/dev/null 2>&1 || GUARD_KIT_SCRATCH_DIRS=(".tmp")
|
|
28
29
|
declare -p GUARD_KIT_RO_BINS >/dev/null 2>&1 || GUARD_KIT_RO_BINS=(
|
|
29
|
-
grep egrep fgrep rg head tail cat wc sort uniq cut tr nl rev tac paste comm column diff jq find ls
|
|
30
|
+
grep egrep fgrep rg head tail cat wc sort uniq cut tr nl rev tac paste comm column diff jq find ls xargs
|
|
30
31
|
)
|
|
31
32
|
|
|
32
33
|
guard_read_command() {
|
|
@@ -37,6 +38,15 @@ guard_read_command() {
|
|
|
37
38
|
printf '%s' "$cmd"
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
# spec: guard-kit/SPEC.md §The guard framework — the path counterpart of guard_read_command; a call carrying no file_path returns non-zero so a matcher covering it falls through instead of blocking
|
|
42
|
+
guard_read_path() {
|
|
43
|
+
local input path
|
|
44
|
+
input="$(cat 2>/dev/null)" || return 1
|
|
45
|
+
path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty' 2>/dev/null)" || return 1
|
|
46
|
+
[[ -z "$path" ]] && return 1
|
|
47
|
+
printf '%s' "$path"
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
guard_block() {
|
|
41
51
|
printf '%s\n' "${GUARD_NAME:-guard}: $1" >&2
|
|
42
52
|
exit 2
|
|
@@ -71,35 +81,212 @@ guard_allow_match() {
|
|
|
71
81
|
[[ "$s" == $glob ]]
|
|
72
82
|
}
|
|
73
83
|
|
|
74
|
-
# spec: guard-kit/SPEC.md §The guard framework — one
|
|
84
|
+
# spec: guard-kit/SPEC.md §The guard framework — the one context-aware normalizer; a rule names the classes inert for it and every lexical view in the file comes from here
|
|
85
|
+
guard_skeleton() {
|
|
86
|
+
local cmd="$1"
|
|
87
|
+
shift
|
|
88
|
+
local c want_sq=0 want_dq=0 want_hd=0 want_hdq=0
|
|
89
|
+
for c in "$@"; do
|
|
90
|
+
case "$c" in
|
|
91
|
+
sq) want_sq=1 ;;
|
|
92
|
+
dq) want_dq=1 ;;
|
|
93
|
+
hd) want_hd=1 ;;
|
|
94
|
+
hdq) want_hdq=1 ;;
|
|
95
|
+
esac
|
|
96
|
+
done
|
|
97
|
+
|
|
98
|
+
# comment-tier-exempt: measured local fact — jumping between significant characters rather than stepping per character took a 355-char command from 2.3ms to 0.17ms, at fourteen call sites per guarded call
|
|
99
|
+
local nl=$'\n'
|
|
100
|
+
local live_class="[\"'\\\\<${nl}]*" dq_class="[\"\\\\]*"
|
|
101
|
+
local n=${#cmd} i=0 out='' span='' state=none ch rest chunk line term body quoted
|
|
102
|
+
local -a pending=() pending_q=()
|
|
103
|
+
while ((i < n)); do
|
|
104
|
+
rest="${cmd:i}"
|
|
105
|
+
if [[ "$state" == sq ]]; then
|
|
106
|
+
chunk="${rest%%\'*}"
|
|
107
|
+
if [[ "$chunk" == "$rest" ]]; then
|
|
108
|
+
span+="$rest"
|
|
109
|
+
i=$n
|
|
110
|
+
continue
|
|
111
|
+
fi
|
|
112
|
+
span+="$chunk'"
|
|
113
|
+
((i += ${#chunk} + 1))
|
|
114
|
+
if ((want_sq)); then out+='SQ'; else out+="$span"; fi
|
|
115
|
+
span=''
|
|
116
|
+
state=none
|
|
117
|
+
continue
|
|
118
|
+
fi
|
|
119
|
+
if [[ "$state" == dq ]]; then
|
|
120
|
+
chunk="${rest%%$dq_class}"
|
|
121
|
+
span+="$chunk"
|
|
122
|
+
((i += ${#chunk}))
|
|
123
|
+
if ((i >= n)); then continue; fi
|
|
124
|
+
if [[ "${cmd:i:1}" == '\' ]]; then
|
|
125
|
+
span+="${cmd:i:2}"
|
|
126
|
+
((i += 2))
|
|
127
|
+
continue
|
|
128
|
+
fi
|
|
129
|
+
span+='"'
|
|
130
|
+
((i++))
|
|
131
|
+
if ((want_dq)); then out+='DQ'; else out+="$span"; fi
|
|
132
|
+
span=''
|
|
133
|
+
state=none
|
|
134
|
+
continue
|
|
135
|
+
fi
|
|
136
|
+
chunk="${rest%%$live_class}"
|
|
137
|
+
if [[ -n "$chunk" ]]; then
|
|
138
|
+
out+="$chunk"
|
|
139
|
+
((i += ${#chunk}))
|
|
140
|
+
((i >= n)) && continue
|
|
141
|
+
fi
|
|
142
|
+
ch="${cmd:i:1}"
|
|
143
|
+
case "$ch" in
|
|
144
|
+
"'")
|
|
145
|
+
state=sq
|
|
146
|
+
span="'"
|
|
147
|
+
((i++))
|
|
148
|
+
continue ;;
|
|
149
|
+
'"')
|
|
150
|
+
state=dq
|
|
151
|
+
span='"'
|
|
152
|
+
((i++))
|
|
153
|
+
continue ;;
|
|
154
|
+
'\')
|
|
155
|
+
out+="${cmd:i:2}"
|
|
156
|
+
((i += 2))
|
|
157
|
+
continue ;;
|
|
158
|
+
'<')
|
|
159
|
+
if [[ "${cmd:i:3}" == '<<<' ]]; then
|
|
160
|
+
out+='<<<'
|
|
161
|
+
((i += 3))
|
|
162
|
+
continue
|
|
163
|
+
fi
|
|
164
|
+
if [[ "${cmd:i}" =~ ^\<\<-?[[:space:]]*(\"[^\"]*\"|\'[^\']*\'|[A-Za-z_][A-Za-z0-9_]*) ]]; then
|
|
165
|
+
out+="${BASH_REMATCH[0]}"
|
|
166
|
+
((i += ${#BASH_REMATCH[0]}))
|
|
167
|
+
term="${BASH_REMATCH[1]}"
|
|
168
|
+
case "$term" in
|
|
169
|
+
\"*\" | \'*\') pending_q+=(1) ;;
|
|
170
|
+
*) pending_q+=(0) ;;
|
|
171
|
+
esac
|
|
172
|
+
term="${term#[\"\']}"
|
|
173
|
+
term="${term%[\"\']}"
|
|
174
|
+
pending+=("$term")
|
|
175
|
+
continue
|
|
176
|
+
fi
|
|
177
|
+
;;
|
|
178
|
+
$'\n')
|
|
179
|
+
out+=$'\n'
|
|
180
|
+
((i++))
|
|
181
|
+
while ((${#pending[@]} > 0)); do
|
|
182
|
+
term="${pending[0]}"
|
|
183
|
+
quoted="${pending_q[0]}"
|
|
184
|
+
pending=("${pending[@]:1}")
|
|
185
|
+
pending_q=("${pending_q[@]:1}")
|
|
186
|
+
body=''
|
|
187
|
+
while ((i < n)); do
|
|
188
|
+
rest="${cmd:i}"
|
|
189
|
+
line="${rest%%$'\n'*}"
|
|
190
|
+
[[ "${line#"${line%%[![:space:]]*}"}" == "$term" ]] && break
|
|
191
|
+
body+="$line"$'\n'
|
|
192
|
+
((i += ${#line} + 1))
|
|
193
|
+
((i > n)) && i=$n
|
|
194
|
+
done
|
|
195
|
+
if [[ -n "$body" ]]; then
|
|
196
|
+
if ((want_hd)) || { ((want_hdq)) && ((quoted)); }; then
|
|
197
|
+
out+='HD'$'\n'
|
|
198
|
+
else
|
|
199
|
+
out+="$body"
|
|
200
|
+
fi
|
|
201
|
+
fi
|
|
202
|
+
if ((i < n)); then
|
|
203
|
+
rest="${cmd:i}"
|
|
204
|
+
line="${rest%%$'\n'*}"
|
|
205
|
+
out+="$line"
|
|
206
|
+
((i += ${#line}))
|
|
207
|
+
if ((i < n)); then
|
|
208
|
+
out+=$'\n'
|
|
209
|
+
((i++))
|
|
210
|
+
fi
|
|
211
|
+
fi
|
|
212
|
+
done
|
|
213
|
+
continue ;;
|
|
214
|
+
esac
|
|
215
|
+
out+="$ch"
|
|
216
|
+
((i++))
|
|
217
|
+
done
|
|
218
|
+
[[ -n "$span" ]] && out+="$span"
|
|
219
|
+
printf '%s' "$out"
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
# spec: guard-kit/SPEC.md §The guard framework — one splitter for every consumer that reasons per compound segment (rules 8/13/14/16, the read-compound carve-out, scan-prompts), fed a guard_skeleton view so the harness's per-segment boundary set never drifts
|
|
75
223
|
guard_split_compound() {
|
|
76
224
|
sed -E 's/\|\||&&|;|\|/\n/g' <<<"$1"
|
|
77
225
|
}
|
|
78
226
|
|
|
227
|
+
# spec: guard-kit/SPEC.md §The generic ruleset — the committed Bash(...) allow inners, one per line; the fail-open read rules 13 and 14 share, so a missing jq or settings file emits nothing and every reader declines
|
|
228
|
+
_guard_allow_inners() {
|
|
229
|
+
command -v jq >/dev/null 2>&1 || return 0
|
|
230
|
+
[[ -f "$GUARD_KIT_SETTINGS" ]] || return 0
|
|
231
|
+
local e inner
|
|
232
|
+
while IFS= read -r e; do
|
|
233
|
+
case "$e" in
|
|
234
|
+
Bash\(*\)) inner="${e#Bash(}"; inner="${inner%)}" ;;
|
|
235
|
+
*) continue ;;
|
|
236
|
+
esac
|
|
237
|
+
[[ -n "$inner" ]] && printf '%s\n' "$inner"
|
|
238
|
+
done < <(jq -r '.permissions.allow[]?' "$GUARD_KIT_SETTINGS" 2>/dev/null)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
# spec: guard-kit/SPEC.md §The generic ruleset — a segment with its redirects removed and trimmed: what rules 13 and 14 compare against a committed bare allow entry
|
|
242
|
+
_guard_segment_core() {
|
|
243
|
+
local seg
|
|
244
|
+
seg="$(sed -E 's/[[:space:]]*[0-9]*(>>?|<)[[:space:]]*(&?[0-9-]+|[^[:space:]]+)?//g' <<<"$1")"
|
|
245
|
+
seg="${seg#"${seg%%[![:space:]]*}"}"
|
|
246
|
+
seg="${seg%"${seg##*[![:space:]]}"}"
|
|
247
|
+
printf '%s' "$seg"
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
# spec: guard-kit/SPEC.md §The generic ruleset — true when the segment exactly matches a committed *bare* allow entry (no glob): the reviewed-lead half of rule 13's predicate and rule 14's lead test
|
|
251
|
+
_guard_is_bare_allow() {
|
|
252
|
+
local core bl
|
|
253
|
+
core="$(_guard_segment_core "$1")"
|
|
254
|
+
[[ -n "$core" ]] || return 1
|
|
255
|
+
while IFS= read -r bl; do
|
|
256
|
+
case "$bl" in *'*'*) continue ;; esac
|
|
257
|
+
[[ "$core" == "$bl" ]] && return 0
|
|
258
|
+
done < <(_guard_allow_inners)
|
|
259
|
+
return 1
|
|
260
|
+
}
|
|
261
|
+
|
|
79
262
|
# spec: guard-kit/SPEC.md §The generic ruleset — the guard_rule_* run below; order is load-bearing
|
|
80
263
|
guard_rule_cd_compound() {
|
|
81
|
-
local cmd
|
|
264
|
+
local cmd
|
|
265
|
+
cmd="$(guard_skeleton "$1" sq dq hd)"
|
|
82
266
|
if grep -qE '(^|[;&|(])[[:space:]]*cd[[:space:]]' <<<"$cmd" && grep -qE '[;&|]' <<<"$cmd"; then
|
|
83
|
-
guard_block "don't use 'cd' in a compound command (
|
|
267
|
+
guard_block "don't use 'cd' in a compound command (cwd drift, and the allowlist can't match the compound — the call costs an out-of-band permission decision). Pass absolute paths, or 'git -C <dir>' for git."
|
|
84
268
|
fi
|
|
85
269
|
}
|
|
86
270
|
|
|
87
271
|
guard_rule_git_c_root() {
|
|
88
|
-
local cmd
|
|
272
|
+
local cmd
|
|
273
|
+
cmd="$(guard_skeleton "$1" sq dq hd)"
|
|
89
274
|
if grep -qF "git -C $PWD " <<<"$cmd"; then
|
|
90
|
-
guard_block "drop 'git -C $PWD ' — cwd is the repo root, so the bare 'git <subcommand>' form is allowlisted and
|
|
275
|
+
guard_block "drop 'git -C $PWD ' — cwd is the repo root, so the bare 'git <subcommand>' form is allowlisted and resolves on the match; the absolute '-C' spelling matches nothing and costs an out-of-band permission decision. Reserve 'git -C <dir>' for a different repo."
|
|
91
276
|
fi
|
|
92
277
|
}
|
|
93
278
|
|
|
94
279
|
guard_rule_scratch_redirect() {
|
|
95
|
-
local cmd
|
|
280
|
+
local cmd
|
|
281
|
+
cmd="$(guard_skeleton "$1" sq dq hd)"
|
|
96
282
|
if grep -qE '(^|[[:space:]])([0-9]*|&)>>?[[:space:]]*[^[:space:]/|&]+\.(err|out|log)([[:space:]]|$)' <<<"$cmd"; then
|
|
97
283
|
guard_block "don't redirect scratch to a bare repo-root filename (e.g. 2> op.err) — it pollutes cwd and risks a 'git add -A'. Send it to a gitignored scratch dir (e.g. ${GUARD_KIT_SCRATCH_DIRS[0]}/<name>.err)."
|
|
98
284
|
fi
|
|
99
285
|
}
|
|
100
286
|
|
|
101
287
|
guard_rule_abs_script() {
|
|
102
|
-
local
|
|
288
|
+
local raw="$1" cmd rest base g relcmd
|
|
289
|
+
cmd="$(guard_skeleton "$raw" sq dq hd)"
|
|
103
290
|
case "$cmd" in
|
|
104
291
|
"bash $PWD/"*) rest="${cmd#bash "$PWD/"}" ;;
|
|
105
292
|
"$PWD/"*) rest="${cmd#"$PWD/"}" ;;
|
|
@@ -108,39 +295,44 @@ guard_rule_abs_script() {
|
|
|
108
295
|
rest="${rest%%[[:space:]]*}" # first token = repo-relative script path
|
|
109
296
|
case "$rest" in *.sh) ;; *) return 0 ;; esac # only .sh scripts; rule 5 handles the rest
|
|
110
297
|
base="${rest##*/}"
|
|
111
|
-
relcmd="${
|
|
298
|
+
relcmd="${raw//"$PWD/"/}" # the rewrite carries the real command, not its skeleton
|
|
112
299
|
for g in "${GUARD_KIT_RO_SCRIPTS[@]}"; do
|
|
113
300
|
# shellcheck disable=SC2053 # intentional glob match: $g is a pattern, not a literal
|
|
114
301
|
if [[ "$base" == $g || "$rest" == $g ]]; then
|
|
115
302
|
guard_rewrite "$relcmd" "abs repo read-only script normalized to relative (${GUARD_NAME:-guard})"
|
|
116
303
|
fi
|
|
117
304
|
done
|
|
118
|
-
guard_block "use the repo-relative form '$rest' (cwd is the repo root) — it's allowlisted and
|
|
305
|
+
guard_block "use the repo-relative form '$rest' (cwd is the repo root) — it's allowlisted and resolves on the match; the absolute spelling matches nothing and costs an out-of-band permission decision. If you truly need the absolute path, run it yourself with !<command>."
|
|
119
306
|
}
|
|
120
307
|
|
|
121
308
|
guard_rule_abs_prefix() {
|
|
122
|
-
local cmd
|
|
309
|
+
local cmd
|
|
310
|
+
cmd="$(guard_skeleton "$1" sq dq hd)"
|
|
123
311
|
[[ "$cmd" == git\ * ]] && return 0
|
|
124
312
|
if grep -qF "$PWD/" <<<"$cmd"; then
|
|
125
|
-
guard_block "drop the repo-root absolute prefix '$PWD/' — cwd is the repo root, so the repo-relative path is allowlisted and
|
|
313
|
+
guard_block "drop the repo-root absolute prefix '$PWD/' — cwd is the repo root, so the repo-relative path is allowlisted and resolves on the match; the absolute spelling matches nothing and costs an out-of-band permission decision. If you truly need the absolute path, run it yourself with !<command>."
|
|
126
314
|
fi
|
|
127
315
|
}
|
|
128
316
|
|
|
129
317
|
guard_rule_expansion() {
|
|
130
318
|
local cmd="$1" sqexp expn
|
|
131
|
-
|
|
319
|
+
# spec: guard-kit/SPEC.md §The generic ruleset — a double-quoted "$x" still expands, so 'dq'
|
|
320
|
+
# stays live; a quoted-delimiter heredoc body cannot, which is what 'hdq' names
|
|
321
|
+
sqexp="$(guard_skeleton "$cmd" sq hdq)"
|
|
132
322
|
if grep -qE '\$\{|\$\(|<\(|\$[A-Za-z_]' <<<"$sqexp"; then
|
|
133
|
-
guard_block "avoid shell variables/expansions (\$VAR, \${...}, \$(...), <(...)) — the harness
|
|
323
|
+
guard_block "avoid shell variables/expansions (\$VAR, \${...}, \$(...), <(...)) — the harness's matcher refuses every expansion, so no allowlist entry can match the command and it costs an out-of-band permission decision. Inline the literal path, use a relative path, or 'git -C <dir>'. If you genuinely need the expansion, run it yourself with !<command>."
|
|
134
324
|
fi
|
|
135
|
-
expn="$(
|
|
325
|
+
expn="$(guard_skeleton "$cmd" sq dq hdq)"
|
|
136
326
|
if grep -qE '(^|[;(]|&&|\|\|)[[:space:]]*[A-Za-z_][A-Za-z0-9_]*=[^[:space:];|&]*[[:space:]]*($|;)' <<<"$expn"; then
|
|
137
|
-
guard_block "avoid shell variable assignments (NAME=value; ... \$NAME) — they
|
|
327
|
+
guard_block "avoid shell variable assignments (NAME=value; ... \$NAME) — they defeat allowlist matching, so the call costs an out-of-band permission decision no allowlist entry can pre-empt. Inline the literal value/path at each use site, or 'git -C <dir>'. If you genuinely need it, run it yourself with !<command>."
|
|
138
328
|
fi
|
|
139
329
|
}
|
|
140
330
|
|
|
141
331
|
guard_rule_brace_glyph() {
|
|
142
332
|
local cmd="$1" sqstripped resid ph='{}' q="'{}'"
|
|
143
|
-
|
|
333
|
+
# spec: guard-kit/SPEC.md §The generic ruleset — 'sq dq hd': '{' is a matcher glyph, not a
|
|
334
|
+
# shell expansion, so rule 6's reason to keep double-quoted spans live does not carry here.
|
|
335
|
+
sqstripped="$(guard_skeleton "$cmd" sq dq hd)"
|
|
144
336
|
case "$sqstripped" in *'{'*) ;; *) return 0 ;; esac
|
|
145
337
|
resid="${sqstripped//"$ph"/}"
|
|
146
338
|
case "$resid" in
|
|
@@ -149,12 +341,12 @@ guard_rule_brace_glyph() {
|
|
|
149
341
|
"bare {} placeholder single-quoted so the harness matcher passes it (${GUARD_NAME:-guard})" ;;
|
|
150
342
|
esac
|
|
151
343
|
if grep -qF '@{' <<<"$sqstripped"; then
|
|
152
|
-
guard_block "spell out the git-ref shorthand '@{...}' — the harness
|
|
344
|
+
guard_block "spell out the git-ref shorthand '@{...}' — the harness's matcher refuses the '{' glyph, so the call costs an out-of-band permission decision. Use 'origin/<branch>..HEAD' for '@{u}..', or the resolved ref/hash for a reflog form."
|
|
153
345
|
fi
|
|
154
346
|
if grep -qE '\{[^}]*(,|\.\.)[^}]*\}' <<<"$sqstripped"; then
|
|
155
|
-
guard_block "write out the brace expansion '{a,b}'/'{a..b}' — the harness
|
|
347
|
+
guard_block "write out the brace expansion '{a,b}'/'{a..b}' — the harness's matcher refuses the '{' glyph and no allowlist entry can match around it, so the call costs an out-of-band permission decision. Spell the members (e.g. 'mkdir -p a/b a/c') or use a loop for a long range."
|
|
156
348
|
fi
|
|
157
|
-
guard_block "
|
|
349
|
+
guard_block "quote the '{' if it's literal (an unquoted awk/sed program), or write it out if it expands — the harness's matcher refuses every bare '{' glyph before allowlist matching, so the call is decided out of band. A brace inside quotes of either kind, or in a heredoc body, is already inert and never reaches this block."
|
|
158
350
|
}
|
|
159
351
|
|
|
160
352
|
_guard_sed_segment() {
|
|
@@ -186,7 +378,7 @@ _guard_sed_segment() {
|
|
|
186
378
|
|
|
187
379
|
guard_rule_sed_file() {
|
|
188
380
|
local cmd="$1" s seg
|
|
189
|
-
s="$(
|
|
381
|
+
s="$(guard_skeleton "$cmd" sq dq hd)"
|
|
190
382
|
while IFS= read -r seg; do
|
|
191
383
|
seg="${seg#"${seg%%[![:space:]]*}"}"
|
|
192
384
|
case "$seg" in
|
|
@@ -214,6 +406,34 @@ _guard_is_cat_read() {
|
|
|
214
406
|
[[ "$operands" == 1 ]]
|
|
215
407
|
}
|
|
216
408
|
|
|
409
|
+
# spec: guard-kit/SPEC.md §The generic ruleset — rule 13's xargs discriminator: xargs runs a command rather than filtering text, so the segment is read-only only when the command it runs is itself on the roster
|
|
410
|
+
_guard_is_ro_xargs() {
|
|
411
|
+
local seg="${1#"${1%%[![:space:]]*}"}" tok want_arg=0 cmdtok='' b i n
|
|
412
|
+
local -a toks
|
|
413
|
+
read -ra toks <<<"$seg"
|
|
414
|
+
[[ "${toks[0]:-}" == xargs ]] || return 1
|
|
415
|
+
n=${#toks[@]}
|
|
416
|
+
for ((i = 1; i < n; i++)); do
|
|
417
|
+
tok="${toks[i]}"
|
|
418
|
+
if [[ "$want_arg" == 1 ]]; then want_arg=0; continue; fi
|
|
419
|
+
case "$tok" in
|
|
420
|
+
-0 | -t | -r | -x | -p | --null | --no-run-if-empty | --verbose | --exit | --interactive | --open-tty) ;;
|
|
421
|
+
-I | -L | -n | -P | -s | -E | -d | -a) want_arg=1 ;;
|
|
422
|
+
-[0ILnPsEdae]*) ;;
|
|
423
|
+
--*=*) ;;
|
|
424
|
+
-*) return 1 ;;
|
|
425
|
+
*) cmdtok="$tok"; break ;;
|
|
426
|
+
esac
|
|
427
|
+
done
|
|
428
|
+
[[ -z "$cmdtok" ]] && return 0
|
|
429
|
+
[[ "$cmdtok" == xargs ]] && return 1
|
|
430
|
+
case "$cmdtok" in echo | printf) return 0 ;; esac
|
|
431
|
+
for b in "${GUARD_KIT_RO_BINS[@]}"; do
|
|
432
|
+
[[ "$cmdtok" == "$b" ]] && return 0
|
|
433
|
+
done
|
|
434
|
+
return 1
|
|
435
|
+
}
|
|
436
|
+
|
|
217
437
|
# spec: guard-kit/SPEC.md §The generic ruleset — one segment is a bare find listing: leads with find, carries no action predicate
|
|
218
438
|
_guard_is_find_listing() {
|
|
219
439
|
local seg="${1#"${1%%[![:space:]]*}"}"
|
|
@@ -241,27 +461,27 @@ guard_rule_find_glob() {
|
|
|
241
461
|
local cmd="$1" s
|
|
242
462
|
grep -qE '\$\(|<\(|>\(' <<<"$cmd" && return 0
|
|
243
463
|
case "$cmd" in *'`'*) return 0 ;; esac
|
|
244
|
-
s="$(
|
|
464
|
+
s="$(guard_skeleton "$cmd" sq dq hd)"
|
|
245
465
|
grep -qE '(&&|\|\||\||&|<|>)' <<<"$s" && return 0
|
|
246
466
|
_guard_is_read_batch "$s" _guard_is_find_listing || return 0
|
|
247
|
-
guard_block "don't list files with a bare 'find' — use the Glob tool: it returns matching paths (registered for a later Read)
|
|
467
|
+
guard_block "don't list files with a bare 'find' — use the Glob tool: it returns matching paths (registered for a later Read) and needs no permission decision at all. This fires on a lone listing and on a ';'-sequence of them (a literal echo/printf banner between them is fine); a 'find' carrying an action predicate (-exec/-delete/…), piped into a consumer, or redirected is untouched. If you genuinely need find, run it yourself with !<command>."
|
|
248
468
|
}
|
|
249
469
|
|
|
250
470
|
guard_rule_cat_file() {
|
|
251
471
|
local cmd="$1" s
|
|
252
472
|
grep -qE '\$\(|<\(|>\(' <<<"$cmd" && return 0
|
|
253
473
|
case "$cmd" in *'`'*) return 0 ;; esac
|
|
254
|
-
s="$(
|
|
474
|
+
s="$(guard_skeleton "$cmd" sq dq hd)"
|
|
255
475
|
grep -qE '(&&|\|\||\||&|<|>)' <<<"$s" && return 0
|
|
256
476
|
_guard_is_read_batch "$s" _guard_is_cat_read || return 0
|
|
257
|
-
guard_block "don't read files with a bare 'cat' — use the Read tool: it returns numbered lines registered for a later Edit,
|
|
477
|
+
guard_block "don't read files with a bare 'cat' — use the Read tool: it returns numbered lines registered for a later Edit, and needs no permission decision at all. This fires on a lone 'cat <file>' and on a ';'-sequence of them (a literal echo/printf banner between reads is fine — batch them into one Read); a 'cat' feeding a pipe or heredoc, redirecting, or concatenating multiple files in one command is composition and untouched. If you genuinely need cat, run it yourself with !<command>."
|
|
258
478
|
}
|
|
259
479
|
|
|
260
480
|
guard_rule_git_grep() {
|
|
261
481
|
local cmd="$1" s tok i n positionals=0 want_arg=0 pat_opt=0 working_tree=0
|
|
262
482
|
grep -qE '\$\(|<\(|>\(' <<<"$cmd" && return 0
|
|
263
483
|
case "$cmd" in *'`'*) return 0 ;; esac
|
|
264
|
-
s="$(
|
|
484
|
+
s="$(guard_skeleton "$cmd" sq dq hd)"
|
|
265
485
|
grep -qE '(&&|\|\||;|\||&|<|>)' <<<"$s" && return 0
|
|
266
486
|
local -a toks
|
|
267
487
|
read -ra toks <<<"$s"
|
|
@@ -286,11 +506,12 @@ guard_rule_git_grep() {
|
|
|
286
506
|
[[ "$positionals" == 1 ]] && working_tree=1
|
|
287
507
|
fi
|
|
288
508
|
[[ "$working_tree" == 1 ]] || return 0
|
|
289
|
-
guard_block "don't search with 'git grep' over the working tree — use the Grep tool: it returns matching lines (files registered for a later Read)
|
|
509
|
+
guard_block "don't search with 'git grep' over the working tree — use the Grep tool: it returns matching lines (files registered for a later Read) and needs no permission decision at all. A 'git grep' naming a revision, searching the index (--cached), or piped into a consumer is untouched — those reach beyond the working tree the Grep tool sees. If you genuinely need git grep, run it yourself with !<command>."
|
|
290
510
|
}
|
|
291
511
|
|
|
292
512
|
guard_rule_truncate_scratch() {
|
|
293
|
-
local cmd
|
|
513
|
+
local cmd
|
|
514
|
+
cmd="$(guard_skeleton "$1" sq dq hd)"
|
|
294
515
|
if [[ "$cmd" =~ ^[[:space:]]*:([[:space:]]+[0-9]*\>\>?[[:space:]]*[^[:space:]\&\|\;\<]+)+[[:space:]]*$ ]]; then
|
|
295
516
|
local all_ignored=1 tgt
|
|
296
517
|
while read -r tgt; do
|
|
@@ -306,10 +527,11 @@ guard_rule_truncate_scratch() {
|
|
|
306
527
|
|
|
307
528
|
guard_rule_ro_pipeline() {
|
|
308
529
|
local raw="$1"
|
|
530
|
+
# spec: guard-kit/SPEC.md §The guard framework — the raw-command carve-out these two tests take
|
|
309
531
|
grep -qE '\$\(|<\(|>\(' <<<"$raw" && return 0
|
|
310
532
|
case "$raw" in *'`'*) return 0 ;; esac
|
|
311
533
|
local s
|
|
312
|
-
s="$(
|
|
534
|
+
s="$(guard_skeleton "$raw" sq dq hd)"
|
|
313
535
|
grep -q "['\"]" <<<"$s" && return 0
|
|
314
536
|
grep -qE '(&&|\|\||;|&)' <<<"$s" && return 0
|
|
315
537
|
local tgt
|
|
@@ -319,47 +541,49 @@ guard_rule_ro_pipeline() {
|
|
|
319
541
|
/dev/null | '&'[0-9]*) ;;
|
|
320
542
|
*) return 0 ;;
|
|
321
543
|
esac
|
|
322
|
-
done < <(grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]
|
|
544
|
+
done < <(grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]|;&]+' <<<"$s" \
|
|
323
545
|
| sed -E 's/^[0-9]*>>?[[:space:]]*//')
|
|
324
546
|
if grep -qE '(^|[[:space:]])find([[:space:]]|$)' <<<"$s" \
|
|
325
547
|
&& grep -qE '\-(exec|execdir|ok|delete)\b' <<<"$s"; then
|
|
326
548
|
return 0
|
|
327
549
|
fi
|
|
328
|
-
local
|
|
329
|
-
|
|
550
|
+
local -a segs
|
|
551
|
+
mapfile -t segs < <(guard_split_compound "$s")
|
|
552
|
+
local seg first b i matched reads=0
|
|
553
|
+
for ((i = 0; i < ${#segs[@]}; i++)); do
|
|
554
|
+
seg="${segs[i]}"
|
|
330
555
|
seg="${seg#"${seg%%[![:space:]]*}"}"
|
|
331
556
|
[[ -z "$seg" ]] && continue
|
|
557
|
+
_guard_is_banner "$seg" && continue
|
|
332
558
|
first="${seg%%[[:space:]]*}"
|
|
559
|
+
[[ "$first" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 0; }
|
|
333
560
|
matched=0
|
|
334
561
|
for b in "${GUARD_KIT_RO_BINS[@]}"; do
|
|
335
562
|
[[ "$first" == "$b" ]] && { matched=1; break; }
|
|
336
563
|
done
|
|
337
|
-
[[ "$matched" ==
|
|
338
|
-
|
|
564
|
+
if [[ "$matched" == 0 ]]; then
|
|
565
|
+
# spec: guard-kit/SPEC.md §The generic ruleset — rule 13's widened lead: a bare
|
|
566
|
+
# committed allow entry qualifies, but only where something decorates it
|
|
567
|
+
[[ "$i" == 0 && "${#segs[@]}" -gt 1 ]] || return 0
|
|
568
|
+
_guard_is_bare_allow "$seg" || return 0
|
|
569
|
+
fi
|
|
570
|
+
reads=$((reads + 1))
|
|
571
|
+
done
|
|
572
|
+
[[ "$reads" -ge 1 ]] || return 0
|
|
339
573
|
guard_allow "read-only search pipeline (${GUARD_NAME:-guard} auto-allow)"
|
|
340
574
|
}
|
|
341
575
|
|
|
342
576
|
guard_rule_allowlist_chain() {
|
|
343
|
-
local cmd="$1"
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
local -a allow_entries
|
|
348
|
-
mapfile -t allow_entries < <(jq -r '.permissions.allow[]?' "$GUARD_KIT_SETTINGS" 2>/dev/null) || return 0
|
|
349
|
-
[[ ${#allow_entries[@]} -gt 0 ]] || return 0
|
|
350
|
-
|
|
351
|
-
local e inner
|
|
352
|
-
local -a bare_leads pattern_inners
|
|
353
|
-
for e in "${allow_entries[@]}"; do
|
|
354
|
-
case "$e" in Bash\(*\)) inner="${e#Bash(}"; inner="${inner%)}" ;; *) continue ;; esac
|
|
355
|
-
[[ -z "$inner" ]] && continue
|
|
577
|
+
local cmd="$1" inner
|
|
578
|
+
local -a bare_leads=() pattern_inners=()
|
|
579
|
+
while IFS= read -r inner; do
|
|
356
580
|
pattern_inners+=("$inner")
|
|
357
581
|
case "$inner" in *'*'*) ;; *) bare_leads+=("$inner") ;; esac
|
|
358
|
-
done
|
|
582
|
+
done < <(_guard_allow_inners)
|
|
359
583
|
[[ ${#bare_leads[@]} -gt 0 ]] || return 0
|
|
360
584
|
|
|
361
585
|
local skel
|
|
362
|
-
skel="$(
|
|
586
|
+
skel="$(guard_skeleton "$cmd" sq dq hd)"
|
|
363
587
|
|
|
364
588
|
local -a segs
|
|
365
589
|
mapfile -t segs < <(guard_split_compound "$skel")
|
|
@@ -368,8 +592,7 @@ guard_rule_allowlist_chain() {
|
|
|
368
592
|
lead="${lead#"${lead%%[![:space:]]*}"}"; lead="${lead%"${lead##*[![:space:]]}"}"
|
|
369
593
|
|
|
370
594
|
local lead_core
|
|
371
|
-
lead_core="$(
|
|
372
|
-
lead_core="${lead_core#"${lead_core%%[![:space:]]*}"}"; lead_core="${lead_core%"${lead_core##*[![:space:]]}"}"
|
|
595
|
+
lead_core="$(_guard_segment_core "$lead")"
|
|
373
596
|
|
|
374
597
|
local bl matched_lead=0
|
|
375
598
|
for bl in "${bare_leads[@]}"; do
|
|
@@ -377,7 +600,7 @@ guard_rule_allowlist_chain() {
|
|
|
377
600
|
done
|
|
378
601
|
[[ "$matched_lead" == 1 ]] || return 0
|
|
379
602
|
|
|
380
|
-
local steer="run '$lead_core' bare — it's a statically allowlisted command, but the decoration (chaining or a redirect)
|
|
603
|
+
local steer="run '$lead_core' bare — it's a statically allowlisted command, but the decoration (chaining or a redirect) leaves a segment nothing grants, so the whole call falls off the match path and costs an out-of-band permission decision. Run the allowlisted command on its own; issue the rest as separate calls."
|
|
381
604
|
|
|
382
605
|
[[ "$lead" != "$lead_core" ]] && guard_block "$steer"
|
|
383
606
|
|
|
@@ -399,7 +622,7 @@ guard_rule_allowlist_chain() {
|
|
|
399
622
|
|
|
400
623
|
guard_rule_git_rewrite() {
|
|
401
624
|
local cmd="$1" s
|
|
402
|
-
s="$(
|
|
625
|
+
s="$(guard_skeleton "$cmd" sq dq hd)"
|
|
403
626
|
if { grep -qE '(^|[[:space:]])git[[:space:]]+commit([[:space:]]|$)' <<<"$s" \
|
|
404
627
|
&& grep -qE '(^|[[:space:]])(-F|--file|--amend)\b' <<<"$s"; } \
|
|
405
628
|
|| { grep -qE '(^|[[:space:]])git[[:space:]]+reset([[:space:]]|$)' <<<"$s" \
|
|
@@ -412,7 +635,7 @@ guard_rule_rm_tracked() {
|
|
|
412
635
|
local raw="$1" s
|
|
413
636
|
grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
|
|
414
637
|
case "$raw" in *'`'*) return 0 ;; esac
|
|
415
|
-
s="$(
|
|
638
|
+
s="$(guard_skeleton "$raw" sq dq hd)"
|
|
416
639
|
local seg lead arg
|
|
417
640
|
while IFS= read -r seg; do
|
|
418
641
|
seg="${seg#"${seg%%[![:space:]]*}"}"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
permission-friction loop a habit, not a one-off cleanup. Splice this in place
|
|
3
3
|
of lifecycle-kit's `tooling-friction triage` placeholder (close skill, step 2).
|
|
4
4
|
|
|
5
|
-
1. **Rank what
|
|
5
|
+
1. **Rank what nothing granted.** Run `bash guard-kit/bin/scan-prompts.sh` — it
|
|
6
6
|
filters the friction log against the committed allowlist and the harness's
|
|
7
7
|
built-in read-only auto-allows, then ranks the survivors by command pattern.
|
|
8
8
|
2. **Resolve each recurring pattern by the triage criterion** — never default
|
|
@@ -14,18 +14,46 @@ of lifecycle-kit's `tooling-friction triage` placeholder (close skill, step 2).
|
|
|
14
14
|
- **Habit change** (a noted convention) for a true one-off.
|
|
15
15
|
Caution: an allowlist entry can *mask* a steering opportunity — before
|
|
16
16
|
blessing a form, confirm it is the one to reinforce.
|
|
17
|
+
**Diagnose before you reach for the allowlist.** A pattern can rank high while
|
|
18
|
+
already being granted: an allowlist entry matches a *bare* command, so a call
|
|
19
|
+
that chains (`&&`, `;`), redirects, or expands breaks the match and is decided
|
|
20
|
+
out of band anyway. Check a ranked pattern against the committed allowlist first — if it is
|
|
21
|
+
already there, the finding is (c) habit change, and adding coverage buys
|
|
22
|
+
nothing while reading as a fix.
|
|
17
23
|
3. **Review the wakeup log** if the wakeup-guard is wired: read
|
|
18
24
|
`.workflow/wakeup-attempts.log`, act on any surfaced intent, then delete it.
|
|
19
|
-
4. **Prune the local overlay.** Run
|
|
20
|
-
`bash guard-kit/bin/compare-settings-allow.sh`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
4. **Prune and narrow the local overlay.** Run
|
|
26
|
+
`bash guard-kit/bin/compare-settings-allow.sh` — it reports two sets, and
|
|
27
|
+
each has its own disposition.
|
|
28
|
+
- **Redundant**: remove every listed `settings.local.json` entry (a committed
|
|
29
|
+
glob already grants it).
|
|
30
|
+
- **Too broad**: for every entry the breadth report names, either narrow the
|
|
31
|
+
glob or record that its breadth is intended. The probe printed beside it is
|
|
32
|
+
the witness — the command that glob auto-allows. An empty breadth report is
|
|
33
|
+
not a proof of narrowness: probes are witnesses, and no completeness is
|
|
34
|
+
claimed (the section is absent entirely when no probes are declared).
|
|
35
|
+
|
|
36
|
+
- **Not content-pinned**: an entry naming a *script path* rather than a fixed
|
|
37
|
+
command grants whatever that file says at run time, so its meaning changes
|
|
38
|
+
whenever the file does — and a path under the gitignored scratch dir is
|
|
39
|
+
rewritable by any session. Read the shape, not the literal: it reads as a
|
|
40
|
+
specific command until one notices the target is writable. Such a run has a
|
|
41
|
+
sanctioned form already — `bin/scratch-run.sh`, whose echo-at-execution is
|
|
42
|
+
the compensating control (§scratch-run) — so route the run through the
|
|
43
|
+
runner and remove the direct-path grant. Removing instances without applying
|
|
44
|
+
this criterion re-arms for the next one.
|
|
45
|
+
|
|
46
|
+
Then, by judgment, prune the remaining one-off exact-string local entries and
|
|
47
|
+
promote recurring safe patterns to the committed `settings.json` as globs.
|
|
48
|
+
Widening the committed set is the **consumer's** call, not the session's: an
|
|
49
|
+
agent may propose a standing grant and may prune, but it does not widen its
|
|
50
|
+
own auto-allow set on its own say-so.
|
|
24
51
|
5. **Clear the friction log** — its named reclaim path:
|
|
25
52
|
`: > .workflow/prompt-friction.log`. Run each clear as its own bare command:
|
|
26
53
|
the allowlist entry is an exact string, so compounding it (`&&`, `;`, a
|
|
27
|
-
trailing `echo`/`wc`) breaks the match and
|
|
28
|
-
just triaged away.
|
|
54
|
+
trailing `echo`/`wc`) breaks the match and buys the very out-of-band decision
|
|
55
|
+
this step just triaged away.
|
|
29
56
|
|
|
30
|
-
Goal: the local set stays small,
|
|
31
|
-
committed, reviewable allowlist
|
|
57
|
+
Goal: the local set stays small, every durable pattern lives in the
|
|
58
|
+
committed, reviewable allowlist, and no local glob auto-allows a command you
|
|
59
|
+
declared bad.
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
# shellcheck shell=bash
|
|
2
2
|
# spec: guard-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: guard-kit/SPEC.md §compare-settings-allow — declare your own probes; the kit ships none
|
|
5
|
+
# GUARD_KIT_BREADTH_PROBES=("Bash(rm -rf /)")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"//": "guard-kit hook wiring — merge into .claude/settings.json. The bash-guard is the PreToolUse(Bash) hook; the wakeup-guard
|
|
2
|
+
"//": "guard-kit hook wiring — merge into .claude/settings.json. The bash-guard is the PreToolUse(Bash) hook; the wakeup-guard and the path-guard block are optional (drop a block to skip it). The third block shows the path-shaped guard shape guard_read_path serves — lifecycle-kit's workflow-state-guard is the shipped instance. Paths assume the guards were copied into scripts/.",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"PreToolUse": [
|
|
5
5
|
{
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
"hooks": [
|
|
14
14
|
{ "type": "command", "command": "bash scripts/wakeup-guard.sh" }
|
|
15
15
|
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"matcher": "Write|Edit",
|
|
19
|
+
"hooks": [
|
|
20
|
+
{ "type": "command", "command": "bash scripts/workflow-state-guard.sh" }
|
|
21
|
+
]
|
|
16
22
|
}
|
|
17
23
|
]
|
|
18
24
|
}
|