@lannguyensi/harness 0.63.0 → 1.0.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/CHANGELOG.md +90 -0
- package/README.md +46 -42
- package/dist/cli/add/index.js +17 -21
- package/dist/cli/add/index.js.map +1 -1
- package/dist/cli/adopt/derive.d.ts +2 -2
- package/dist/cli/adopt/derive.js +2 -19
- package/dist/cli/adopt/derive.js.map +1 -1
- package/dist/cli/adopt/index.d.ts +1 -1
- package/dist/cli/adopt/index.js +1 -12
- package/dist/cli/adopt/index.js.map +1 -1
- package/dist/cli/apply/apply.d.ts +20 -35
- package/dist/cli/apply/apply.js +61 -136
- package/dist/cli/apply/apply.js.map +1 -1
- package/dist/cli/apply/generate-codex-config.js +10 -58
- package/dist/cli/apply/generate-codex-config.js.map +1 -1
- package/dist/cli/apply/generate-memory-index.js +1 -2
- package/dist/cli/apply/generate-memory-index.js.map +1 -1
- package/dist/cli/apply/generate-opencode-config.d.ts +2 -10
- package/dist/cli/apply/generate-opencode-config.js +74 -113
- package/dist/cli/apply/generate-opencode-config.js.map +1 -1
- package/dist/cli/apply/generate-settings.d.ts +11 -64
- package/dist/cli/apply/generate-settings.js +27 -132
- package/dist/cli/apply/generate-settings.js.map +1 -1
- package/dist/cli/apply/index.d.ts +1 -1
- package/dist/cli/apply/index.js +1 -1
- package/dist/cli/apply/index.js.map +1 -1
- package/dist/cli/apply/install-codex-config.d.ts +153 -1
- package/dist/cli/apply/install-codex-config.js +445 -70
- package/dist/cli/apply/install-codex-config.js.map +1 -1
- package/dist/cli/apply/next-steps.d.ts +7 -0
- package/dist/cli/apply/next-steps.js +13 -1
- package/dist/cli/apply/next-steps.js.map +1 -1
- package/dist/cli/bounded-stdin.d.ts +0 -23
- package/dist/cli/bounded-stdin.js +2 -49
- package/dist/cli/bounded-stdin.js.map +1 -1
- package/dist/cli/describe.d.ts +1 -1
- package/dist/cli/describe.js +0 -3
- package/dist/cli/describe.js.map +1 -1
- package/dist/cli/diff/engine.d.ts +0 -11
- package/dist/cli/diff/engine.js +1 -17
- package/dist/cli/diff/engine.js.map +1 -1
- package/dist/cli/diff/index.js +14 -25
- package/dist/cli/diff/index.js.map +1 -1
- package/dist/cli/doctor/claude-mcp.d.ts +4 -19
- package/dist/cli/doctor/claude-mcp.js +11 -22
- package/dist/cli/doctor/claude-mcp.js.map +1 -1
- package/dist/cli/doctor/codex.d.ts +12 -14
- package/dist/cli/doctor/codex.js +31 -144
- package/dist/cli/doctor/codex.js.map +1 -1
- package/dist/cli/doctor/format.js +23 -338
- package/dist/cli/doctor/format.js.map +1 -1
- package/dist/cli/doctor/hook-liveness.d.ts +56 -0
- package/dist/cli/doctor/hook-liveness.js +455 -0
- package/dist/cli/doctor/hook-liveness.js.map +1 -0
- package/dist/cli/doctor/index.d.ts +13 -87
- package/dist/cli/doctor/index.js +57 -705
- package/dist/cli/doctor/index.js.map +1 -1
- package/dist/cli/doctor/opencode.d.ts +2 -1
- package/dist/cli/doctor/opencode.js.map +1 -1
- package/dist/cli/doctor/types.d.ts +21 -378
- package/dist/cli/doctor/types.js.map +1 -1
- package/dist/cli/drain-stdio.d.ts +31 -0
- package/dist/cli/drain-stdio.js +76 -0
- package/dist/cli/drain-stdio.js.map +1 -0
- package/dist/cli/export.d.ts +3 -1
- package/dist/cli/export.js +7 -16
- package/dist/cli/export.js.map +1 -1
- package/dist/cli/gate/codex-disable.d.ts +29 -0
- package/dist/cli/gate/codex-disable.js +195 -0
- package/dist/cli/gate/codex-disable.js.map +1 -0
- package/dist/cli/gate/codex-enable.d.ts +41 -0
- package/dist/cli/gate/codex-enable.js +127 -0
- package/dist/cli/gate/codex-enable.js.map +1 -0
- package/dist/cli/gate/codex-snapshot.d.ts +208 -0
- package/dist/cli/gate/codex-snapshot.js +402 -0
- package/dist/cli/gate/codex-snapshot.js.map +1 -0
- package/dist/cli/gate/disable.d.ts +9 -0
- package/dist/cli/gate/disable.js +263 -28
- package/dist/cli/gate/disable.js.map +1 -1
- package/dist/cli/gate/enable.d.ts +26 -6
- package/dist/cli/gate/enable.js +152 -80
- package/dist/cli/gate/enable.js.map +1 -1
- package/dist/cli/gate/link-chain.d.ts +53 -0
- package/dist/cli/gate/link-chain.js +122 -0
- package/dist/cli/gate/link-chain.js.map +1 -0
- package/dist/cli/gate/snapshot.d.ts +289 -12
- package/dist/cli/gate/snapshot.js +481 -22
- package/dist/cli/gate/snapshot.js.map +1 -1
- package/dist/cli/index.d.ts +0 -9
- package/dist/cli/index.js +15 -2607
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/composer.d.ts +3 -6
- package/dist/cli/init/composer.js +6 -370
- package/dist/cli/init/composer.js.map +1 -1
- package/dist/cli/init/dependencies.d.ts +1 -2
- package/dist/cli/init/dependencies.js +4 -80
- package/dist/cli/init/dependencies.js.map +1 -1
- package/dist/cli/init/detect.js +5 -4
- package/dist/cli/init/detect.js.map +1 -1
- package/dist/cli/init/interactive.d.ts +1 -23
- package/dist/cli/init/interactive.js +33 -247
- package/dist/cli/init/interactive.js.map +1 -1
- package/dist/cli/init/profiles.d.ts +2 -2
- package/dist/cli/init/profiles.js +51 -243
- package/dist/cli/init/profiles.js.map +1 -1
- package/dist/cli/init/templates.d.ts +2 -37
- package/dist/cli/init/templates.js +25 -1237
- package/dist/cli/init/templates.js.map +1 -1
- package/dist/cli/list.d.ts +1 -1
- package/dist/cli/list.js +1 -38
- package/dist/cli/list.js.map +1 -1
- package/dist/cli/loader.d.ts +15 -1
- package/dist/cli/loader.js +56 -39
- package/dist/cli/loader.js.map +1 -1
- package/dist/cli/main.js +7 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/migrate-home/index.js +2 -2
- package/dist/cli/migrate-home/index.js.map +1 -1
- package/dist/cli/pack/add.js +1 -1
- package/dist/cli/pack/add.js.map +1 -1
- package/dist/cli/pack/hook-bootstrap.d.ts +5 -164
- package/dist/cli/pack/hook-bootstrap.js +15 -291
- package/dist/cli/pack/hook-bootstrap.js.map +1 -1
- package/dist/cli/pack/hook-branch-protection.d.ts +28 -21
- package/dist/cli/pack/hook-branch-protection.js +365 -340
- package/dist/cli/pack/hook-branch-protection.js.map +1 -1
- package/dist/cli/pack/index.d.ts +0 -1
- package/dist/cli/pack/index.js +0 -1
- package/dist/cli/pack/index.js.map +1 -1
- package/dist/cli/pack/list.js +1 -6
- package/dist/cli/pack/list.js.map +1 -1
- package/dist/cli/pack/mutate.d.ts +7 -9
- package/dist/cli/pack/mutate.js +6 -9
- package/dist/cli/pack/mutate.js.map +1 -1
- package/dist/cli/pack/reseed.d.ts +2 -2
- package/dist/cli/pack/reseed.js +16 -22
- package/dist/cli/pack/reseed.js.map +1 -1
- package/dist/cli/register-gate-group.d.ts +5 -0
- package/dist/cli/register-gate-group.js +348 -0
- package/dist/cli/register-gate-group.js.map +1 -0
- package/dist/cli/register-inspect-group.d.ts +6 -0
- package/dist/cli/register-inspect-group.js +189 -0
- package/dist/cli/register-inspect-group.js.map +1 -0
- package/dist/cli/register-operator-lifecycle.d.ts +5 -0
- package/dist/cli/register-operator-lifecycle.js +20 -0
- package/dist/cli/register-operator-lifecycle.js.map +1 -0
- package/dist/cli/register-pack-group.d.ts +5 -0
- package/dist/cli/register-pack-group.js +134 -0
- package/dist/cli/register-pack-group.js.map +1 -0
- package/dist/cli/register-setup-group.d.ts +5 -0
- package/dist/cli/register-setup-group.js +495 -0
- package/dist/cli/register-setup-group.js.map +1 -0
- package/dist/cli/remove/index.d.ts +0 -14
- package/dist/cli/remove/index.js +2 -115
- package/dist/cli/remove/index.js.map +1 -1
- package/dist/cli/remove/mutate.d.ts +0 -2
- package/dist/cli/remove/mutate.js +1 -19
- package/dist/cli/remove/mutate.js.map +1 -1
- package/dist/cli/remove/register.d.ts +5 -0
- package/dist/cli/remove/register.js +25 -0
- package/dist/cli/remove/register.js.map +1 -0
- package/dist/cli/shell-quote.d.ts +7 -0
- package/dist/cli/shell-quote.js +17 -0
- package/dist/cli/shell-quote.js.map +1 -0
- package/dist/cli/uninstall/index.d.ts +4 -2
- package/dist/cli/uninstall/index.js +15 -7
- package/dist/cli/uninstall/index.js.map +1 -1
- package/dist/cli/uninstall/register.d.ts +5 -0
- package/dist/cli/uninstall/register.js +171 -0
- package/dist/cli/uninstall/register.js.map +1 -0
- package/dist/cli/uninstall/snapshot.d.ts +15 -0
- package/dist/cli/uninstall/snapshot.js +38 -0
- package/dist/cli/uninstall/snapshot.js.map +1 -1
- package/dist/cli/validate/checks.d.ts +0 -77
- package/dist/cli/validate/checks.js +3 -1049
- package/dist/cli/validate/checks.js.map +1 -1
- package/dist/cli/validate/index.js +19 -15
- package/dist/cli/validate/index.js.map +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/io/claude-mcp.d.ts +1 -1
- package/dist/io/claude-mcp.js +27 -14
- package/dist/io/claude-mcp.js.map +1 -1
- package/dist/io/harness-lock.js +2 -2
- package/dist/io/harness-lock.js.map +1 -1
- package/dist/io/lock.d.ts +0 -26
- package/dist/io/lock.js +10 -27
- package/dist/io/lock.js.map +1 -1
- package/dist/io/merge-settings.js +6 -4
- package/dist/io/merge-settings.js.map +1 -1
- package/dist/io/project-name.d.ts +22 -39
- package/dist/io/project-name.js +25 -42
- package/dist/io/project-name.js.map +1 -1
- package/dist/io/read-regular-file.d.ts +103 -40
- package/dist/io/read-regular-file.js +196 -35
- package/dist/io/read-regular-file.js.map +1 -1
- package/dist/io/restart-hints.js +3 -6
- package/dist/io/restart-hints.js.map +1 -1
- package/dist/io/version-compare.d.ts +1 -3
- package/dist/io/version-compare.js +1 -3
- package/dist/io/version-compare.js.map +1 -1
- package/dist/io/write-regular-file.d.ts +30 -0
- package/dist/io/write-regular-file.js +85 -0
- package/dist/io/write-regular-file.js.map +1 -0
- package/dist/overrides/index.d.ts +1 -0
- package/dist/overrides/index.js +1 -0
- package/dist/overrides/index.js.map +1 -1
- package/dist/overrides/merge-layers.d.ts +43 -0
- package/dist/overrides/merge-layers.js +76 -0
- package/dist/overrides/merge-layers.js.map +1 -0
- package/dist/overrides/merge.d.ts +16 -0
- package/dist/overrides/merge.js +21 -8
- package/dist/overrides/merge.js.map +1 -1
- package/dist/policy-packs/builtin/branch-protection-runtime.d.ts +4 -69
- package/dist/policy-packs/builtin/branch-protection-runtime.js +12 -84
- package/dist/policy-packs/builtin/branch-protection-runtime.js.map +1 -1
- package/dist/policy-packs/builtin/branch-protection.d.ts +7 -30
- package/dist/policy-packs/builtin/branch-protection.js +56 -89
- package/dist/policy-packs/builtin/branch-protection.js.map +1 -1
- package/dist/policy-packs/config-check.d.ts +7 -5
- package/dist/policy-packs/config-check.js +2 -2
- package/dist/policy-packs/config-check.js.map +1 -1
- package/dist/policy-packs/expand.d.ts +1 -3
- package/dist/policy-packs/expand.js +5 -42
- package/dist/policy-packs/expand.js.map +1 -1
- package/dist/policy-packs/index.d.ts +3 -3
- package/dist/policy-packs/index.js +2 -2
- package/dist/policy-packs/index.js.map +1 -1
- package/dist/policy-packs/registry.d.ts +9 -38
- package/dist/policy-packs/registry.js +5 -65
- package/dist/policy-packs/registry.js.map +1 -1
- package/dist/policy-packs/runtime.d.ts +0 -4
- package/dist/policy-packs/runtime.js +9 -22
- package/dist/policy-packs/runtime.js.map +1 -1
- package/dist/policy-packs/types.d.ts +0 -19
- package/dist/policy-packs/ux-compare.d.ts +1 -11
- package/dist/policy-packs/ux-compare.js +6 -42
- package/dist/policy-packs/ux-compare.js.map +1 -1
- package/dist/policy-packs/ux-drift-check.d.ts +5 -5
- package/dist/policy-packs/ux-drift-check.js +17 -22
- package/dist/policy-packs/ux-drift-check.js.map +1 -1
- package/dist/policy-packs/version-check.d.ts +5 -26
- package/dist/policy-packs/version-check.js +19 -74
- package/dist/policy-packs/version-check.js.map +1 -1
- package/dist/probes/memory.d.ts +1 -1
- package/dist/probes/memory.js +1 -1
- package/dist/probes/memory.js.map +1 -1
- package/dist/runtime/agent-facing.d.ts +9 -0
- package/dist/runtime/agent-facing.js +28 -14
- package/dist/runtime/agent-facing.js.map +1 -1
- package/dist/runtime/bounded-text.d.ts +15 -0
- package/dist/runtime/bounded-text.js +27 -0
- package/dist/runtime/bounded-text.js.map +1 -0
- package/dist/runtime/git-branch.d.ts +125 -0
- package/dist/runtime/git-branch.js +381 -0
- package/dist/runtime/git-branch.js.map +1 -0
- package/dist/runtime/hermetic-spawn-guard.d.ts +2 -2
- package/dist/runtime/hermetic-spawn-guard.js +24 -34
- package/dist/runtime/hermetic-spawn-guard.js.map +1 -1
- package/dist/runtime/home-dir.js +3 -2
- package/dist/runtime/home-dir.js.map +1 -1
- package/dist/runtime/tool-name-aliases.d.ts +0 -6
- package/dist/runtime/tool-name-aliases.js +5 -18
- package/dist/runtime/tool-name-aliases.js.map +1 -1
- package/dist/schema/grounding.d.ts +7 -54
- package/dist/schema/grounding.js +10 -12
- package/dist/schema/grounding.js.map +1 -1
- package/dist/schema/hooks.d.ts +39 -136
- package/dist/schema/hooks.js +3 -6
- package/dist/schema/hooks.js.map +1 -1
- package/dist/schema/index.d.ts +114 -3828
- package/dist/schema/index.js +41 -80
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/memory.d.ts +54 -131
- package/dist/schema/memory.js +2 -2
- package/dist/schema/memory.js.map +1 -1
- package/dist/schema/policy-packs.d.ts +3 -45
- package/dist/schema/policy-packs.js +7 -13
- package/dist/schema/policy-packs.js.map +1 -1
- package/dist/schema/policy-ux.d.ts +7 -0
- package/dist/schema/policy-ux.js +18 -0
- package/dist/schema/policy-ux.js.map +1 -0
- package/dist/schema/removed-keys.d.ts +185 -0
- package/dist/schema/removed-keys.js +531 -0
- package/dist/schema/removed-keys.js.map +1 -0
- package/dist/schema/tools.d.ts +30 -268
- package/dist/schema/tools.js +4 -4
- package/dist/schema/tools.js.map +1 -1
- package/package.json +5 -16
- package/dist/cli/approve/branch-protection.d.ts +0 -69
- package/dist/cli/approve/branch-protection.js +0 -144
- package/dist/cli/approve/branch-protection.js.map +0 -1
- package/dist/cli/approve/risk.d.ts +0 -112
- package/dist/cli/approve/risk.js +0 -197
- package/dist/cli/approve/risk.js.map +0 -1
- package/dist/cli/approve/stdin-report.d.ts +0 -57
- package/dist/cli/approve/stdin-report.js +0 -145
- package/dist/cli/approve/stdin-report.js.map +0 -1
- package/dist/cli/approve/understanding.d.ts +0 -410
- package/dist/cli/approve/understanding.js +0 -996
- package/dist/cli/approve/understanding.js.map +0 -1
- package/dist/cli/audit.d.ts +0 -80
- package/dist/cli/audit.js +0 -252
- package/dist/cli/audit.js.map +0 -1
- package/dist/cli/delegate/index.d.ts +0 -76
- package/dist/cli/delegate/index.js +0 -443
- package/dist/cli/delegate/index.js.map +0 -1
- package/dist/cli/doctor/auto-approve-mode.d.ts +0 -37
- package/dist/cli/doctor/auto-approve-mode.js +0 -80
- package/dist/cli/doctor/auto-approve-mode.js.map +0 -1
- package/dist/cli/doctor/bypass-without-auto-approve.d.ts +0 -38
- package/dist/cli/doctor/bypass-without-auto-approve.js +0 -95
- package/dist/cli/doctor/bypass-without-auto-approve.js.map +0 -1
- package/dist/cli/doctor/codex-config-drift.d.ts +0 -28
- package/dist/cli/doctor/codex-config-drift.js +0 -240
- package/dist/cli/doctor/codex-config-drift.js.map +0 -1
- package/dist/cli/doctor/rogue-ledger.d.ts +0 -53
- package/dist/cli/doctor/rogue-ledger.js +0 -153
- package/dist/cli/doctor/rogue-ledger.js.map +0 -1
- package/dist/cli/doctor/session-start-preflight-setup-version.d.ts +0 -83
- package/dist/cli/doctor/session-start-preflight-setup-version.js +0 -114
- package/dist/cli/doctor/session-start-preflight-setup-version.js.map +0 -1
- package/dist/cli/doctor/settings-drift.d.ts +0 -25
- package/dist/cli/doctor/settings-drift.js +0 -213
- package/dist/cli/doctor/settings-drift.js.map +0 -1
- package/dist/cli/doctor/toolchain-parity.d.ts +0 -63
- package/dist/cli/doctor/toolchain-parity.js +0 -154
- package/dist/cli/doctor/toolchain-parity.js.map +0 -1
- package/dist/cli/doctor/ug-auto-approvals.d.ts +0 -40
- package/dist/cli/doctor/ug-auto-approvals.js +0 -91
- package/dist/cli/doctor/ug-auto-approvals.js.map +0 -1
- package/dist/cli/doctor/ug-delegations.d.ts +0 -26
- package/dist/cli/doctor/ug-delegations.js +0 -121
- package/dist/cli/doctor/ug-delegations.js.map +0 -1
- package/dist/cli/doctor/ug-inflight.d.ts +0 -35
- package/dist/cli/doctor/ug-inflight.js +0 -57
- package/dist/cli/doctor/ug-inflight.js.map +0 -1
- package/dist/cli/doctor/understanding-mode-env.d.ts +0 -51
- package/dist/cli/doctor/understanding-mode-env.js +0 -98
- package/dist/cli/doctor/understanding-mode-env.js.map +0 -1
- package/dist/cli/dry-run.d.ts +0 -46
- package/dist/cli/dry-run.js +0 -250
- package/dist/cli/dry-run.js.map +0 -1
- package/dist/cli/event-input.d.ts +0 -28
- package/dist/cli/event-input.js +0 -73
- package/dist/cli/event-input.js.map +0 -1
- package/dist/cli/explain-action.d.ts +0 -20
- package/dist/cli/explain-action.js +0 -27
- package/dist/cli/explain-action.js.map +0 -1
- package/dist/cli/explain-policy.d.ts +0 -135
- package/dist/cli/explain-policy.js +0 -266
- package/dist/cli/explain-policy.js.map +0 -1
- package/dist/cli/explain.d.ts +0 -31
- package/dist/cli/explain.js +0 -159
- package/dist/cli/explain.js.map +0 -1
- package/dist/cli/gc/index.d.ts +0 -63
- package/dist/cli/gc/index.js +0 -566
- package/dist/cli/gc/index.js.map +0 -1
- package/dist/cli/pack/approve-escape.d.ts +0 -19
- package/dist/cli/pack/approve-escape.js +0 -190
- package/dist/cli/pack/approve-escape.js.map +0 -1
- package/dist/cli/pack/auto-approve-path.d.ts +0 -146
- package/dist/cli/pack/auto-approve-path.js +0 -462
- package/dist/cli/pack/auto-approve-path.js.map +0 -1
- package/dist/cli/pack/hook-codex-post-tool-use.d.ts +0 -25
- package/dist/cli/pack/hook-codex-post-tool-use.js +0 -160
- package/dist/cli/pack/hook-codex-post-tool-use.js.map +0 -1
- package/dist/cli/pack/hook-codex-pre-tool-use.d.ts +0 -48
- package/dist/cli/pack/hook-codex-pre-tool-use.js +0 -474
- package/dist/cli/pack/hook-codex-pre-tool-use.js.map +0 -1
- package/dist/cli/pack/hook-codex-stop.d.ts +0 -35
- package/dist/cli/pack/hook-codex-stop.js +0 -329
- package/dist/cli/pack/hook-codex-stop.js.map +0 -1
- package/dist/cli/pack/hook-codex-user-prompt-submit.d.ts +0 -24
- package/dist/cli/pack/hook-codex-user-prompt-submit.js +0 -93
- package/dist/cli/pack/hook-codex-user-prompt-submit.js.map +0 -1
- package/dist/cli/pack/hook-post-merge-gate-record.d.ts +0 -37
- package/dist/cli/pack/hook-post-merge-gate-record.js +0 -190
- package/dist/cli/pack/hook-post-merge-gate-record.js.map +0 -1
- package/dist/cli/pack/hook-post-merge-gate.d.ts +0 -34
- package/dist/cli/pack/hook-post-merge-gate.js +0 -277
- package/dist/cli/pack/hook-post-merge-gate.js.map +0 -1
- package/dist/cli/pack/hook-post-tool-use.d.ts +0 -45
- package/dist/cli/pack/hook-post-tool-use.js +0 -137
- package/dist/cli/pack/hook-post-tool-use.js.map +0 -1
- package/dist/cli/pack/hook-pre-tool-use.d.ts +0 -92
- package/dist/cli/pack/hook-pre-tool-use.js +0 -1328
- package/dist/cli/pack/hook-pre-tool-use.js.map +0 -1
- package/dist/cli/pack/hook-runtime-reality.d.ts +0 -63
- package/dist/cli/pack/hook-runtime-reality.js +0 -210
- package/dist/cli/pack/hook-runtime-reality.js.map +0 -1
- package/dist/cli/pack/hook-solution-acceptance-writeguard.d.ts +0 -32
- package/dist/cli/pack/hook-solution-acceptance-writeguard.js +0 -337
- package/dist/cli/pack/hook-solution-acceptance-writeguard.js.map +0 -1
- package/dist/cli/pack/hook-solution-acceptance.d.ts +0 -157
- package/dist/cli/pack/hook-solution-acceptance.js +0 -530
- package/dist/cli/pack/hook-solution-acceptance.js.map +0 -1
- package/dist/cli/pack/hook-stay-in-scope.d.ts +0 -37
- package/dist/cli/pack/hook-stay-in-scope.js +0 -128
- package/dist/cli/pack/hook-stay-in-scope.js.map +0 -1
- package/dist/cli/pack/hook-subagent-start.d.ts +0 -23
- package/dist/cli/pack/hook-subagent-start.js +0 -88
- package/dist/cli/pack/hook-subagent-start.js.map +0 -1
- package/dist/cli/pack/hook-subagent-stop.d.ts +0 -19
- package/dist/cli/pack/hook-subagent-stop.js +0 -41
- package/dist/cli/pack/hook-subagent-stop.js.map +0 -1
- package/dist/cli/pack/hook-track-active-claim.d.ts +0 -27
- package/dist/cli/pack/hook-track-active-claim.js +0 -275
- package/dist/cli/pack/hook-track-active-claim.js.map +0 -1
- package/dist/cli/pack/transcript-report-scan.d.ts +0 -71
- package/dist/cli/pack/transcript-report-scan.js +0 -359
- package/dist/cli/pack/transcript-report-scan.js.map +0 -1
- package/dist/cli/pack/understanding-report-schema-hint.d.ts +0 -26
- package/dist/cli/pack/understanding-report-schema-hint.js +0 -120
- package/dist/cli/pack/understanding-report-schema-hint.js.map +0 -1
- package/dist/cli/pack/upgrade.d.ts +0 -32
- package/dist/cli/pack/upgrade.js +0 -273
- package/dist/cli/pack/upgrade.js.map +0 -1
- package/dist/cli/pause/index.d.ts +0 -113
- package/dist/cli/pause/index.js +0 -251
- package/dist/cli/pause/index.js.map +0 -1
- package/dist/cli/pause-check.d.ts +0 -22
- package/dist/cli/pause-check.js +0 -54
- package/dist/cli/pause-check.js.map +0 -1
- package/dist/cli/policy/intercept.d.ts +0 -233
- package/dist/cli/policy/intercept.js +0 -1020
- package/dist/cli/policy/intercept.js.map +0 -1
- package/dist/cli/policy/risk-envelope-enrichment.d.ts +0 -40
- package/dist/cli/policy/risk-envelope-enrichment.js +0 -108
- package/dist/cli/policy/risk-envelope-enrichment.js.map +0 -1
- package/dist/cli/record/index.d.ts +0 -81
- package/dist/cli/record/index.js +0 -348
- package/dist/cli/record/index.js.map +0 -1
- package/dist/cli/resolve-env.d.ts +0 -32
- package/dist/cli/resolve-env.js +0 -47
- package/dist/cli/resolve-env.js.map +0 -1
- package/dist/cli/session-export/index.d.ts +0 -46
- package/dist/cli/session-export/index.js +0 -169
- package/dist/cli/session-export/index.js.map +0 -1
- package/dist/cli/session-export/redact.d.ts +0 -22
- package/dist/cli/session-export/redact.js +0 -47
- package/dist/cli/session-export/redact.js.map +0 -1
- package/dist/cli/session-export/transcript.d.ts +0 -24
- package/dist/cli/session-export/transcript.js +0 -164
- package/dist/cli/session-export/transcript.js.map +0 -1
- package/dist/cli/session-start/branch-check.d.ts +0 -18
- package/dist/cli/session-start/branch-check.js +0 -140
- package/dist/cli/session-start/branch-check.js.map +0 -1
- package/dist/cli/session-start/index.d.ts +0 -121
- package/dist/cli/session-start/index.js +0 -591
- package/dist/cli/session-start/index.js.map +0 -1
- package/dist/cli/session-start/shared-options.d.ts +0 -103
- package/dist/cli/session-start/shared-options.js +0 -107
- package/dist/cli/session-start/shared-options.js.map +0 -1
- package/dist/cli/session-start/stale-base-check.d.ts +0 -46
- package/dist/cli/session-start/stale-base-check.js +0 -352
- package/dist/cli/session-start/stale-base-check.js.map +0 -1
- package/dist/cli/session-start/toolchain-parity.d.ts +0 -267
- package/dist/cli/session-start/toolchain-parity.js +0 -797
- package/dist/cli/session-start/toolchain-parity.js.map +0 -1
- package/dist/cli/smoke/assertions.d.ts +0 -46
- package/dist/cli/smoke/assertions.js +0 -170
- package/dist/cli/smoke/assertions.js.map +0 -1
- package/dist/cli/smoke/index.d.ts +0 -76
- package/dist/cli/smoke/index.js +0 -245
- package/dist/cli/smoke/index.js.map +0 -1
- package/dist/cli/smoke/runner.d.ts +0 -55
- package/dist/cli/smoke/runner.js +0 -134
- package/dist/cli/smoke/runner.js.map +0 -1
- package/dist/cli/smoke/stream-parser.d.ts +0 -65
- package/dist/cli/smoke/stream-parser.js +0 -115
- package/dist/cli/smoke/stream-parser.js.map +0 -1
- package/dist/cli/test-risk.d.ts +0 -26
- package/dist/cli/test-risk.js +0 -34
- package/dist/cli/test-risk.js.map +0 -1
- package/dist/io/display-path.d.ts +0 -11
- package/dist/io/display-path.js +0 -29
- package/dist/io/display-path.js.map +0 -1
- package/dist/io/duration.d.ts +0 -5
- package/dist/io/duration.js +0 -50
- package/dist/io/duration.js.map +0 -1
- package/dist/io/extract.d.ts +0 -79
- package/dist/io/extract.js +0 -226
- package/dist/io/extract.js.map +0 -1
- package/dist/io/ledger-record.d.ts +0 -83
- package/dist/io/ledger-record.js +0 -301
- package/dist/io/ledger-record.js.map +0 -1
- package/dist/io/read-json-dir-entries.d.ts +0 -36
- package/dist/io/read-json-dir-entries.js +0 -48
- package/dist/io/read-json-dir-entries.js.map +0 -1
- package/dist/io/safe-json-parse.d.ts +0 -5
- package/dist/io/safe-json-parse.js +0 -21
- package/dist/io/safe-json-parse.js.map +0 -1
- package/dist/policies/index.d.ts +0 -5
- package/dist/policies/index.js +0 -6
- package/dist/policies/index.js.map +0 -1
- package/dist/policies/ledger-client.d.ts +0 -113
- package/dist/policies/ledger-client.js +0 -500
- package/dist/policies/ledger-client.js.map +0 -1
- package/dist/policies/producers.d.ts +0 -12
- package/dist/policies/producers.js +0 -61
- package/dist/policies/producers.js.map +0 -1
- package/dist/policies/requires.d.ts +0 -75
- package/dist/policies/requires.js +0 -240
- package/dist/policies/requires.js.map +0 -1
- package/dist/policies/timestamp.d.ts +0 -14
- package/dist/policies/timestamp.js +0 -36
- package/dist/policies/timestamp.js.map +0 -1
- package/dist/policy-packs/builtin/permission-profiles.d.ts +0 -11
- package/dist/policy-packs/builtin/permission-profiles.js +0 -74
- package/dist/policy-packs/builtin/permission-profiles.js.map +0 -1
- package/dist/policy-packs/builtin/post-merge-gate-runtime.d.ts +0 -286
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js +0 -397
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js.map +0 -1
- package/dist/policy-packs/builtin/post-merge-gate.d.ts +0 -56
- package/dist/policy-packs/builtin/post-merge-gate.js +0 -347
- package/dist/policy-packs/builtin/post-merge-gate.js.map +0 -1
- package/dist/policy-packs/builtin/solution-acceptance-reconnect.d.ts +0 -50
- package/dist/policy-packs/builtin/solution-acceptance-reconnect.js +0 -151
- package/dist/policy-packs/builtin/solution-acceptance-reconnect.js.map +0 -1
- package/dist/policy-packs/builtin/solution-acceptance-runtime.d.ts +0 -323
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js +0 -672
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js.map +0 -1
- package/dist/policy-packs/builtin/solution-acceptance.d.ts +0 -45
- package/dist/policy-packs/builtin/solution-acceptance.js +0 -226
- package/dist/policy-packs/builtin/solution-acceptance.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/active-claim.d.ts +0 -25
- package/dist/policy-packs/builtin/understanding-before-execution/active-claim.js +0 -94
- package/dist/policy-packs/builtin/understanding-before-execution/active-claim.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve-default.d.ts +0 -35
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve-default.js +0 -86
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve-default.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.d.ts +0 -210
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js +0 -361
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.d.ts +0 -304
- package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js +0 -734
- package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.d.ts +0 -36
- package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.js +0 -73
- package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +0 -19
- package/dist/policy-packs/builtin/understanding-before-execution/index.js +0 -83
- package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/inflight-records.d.ts +0 -135
- package/dist/policy-packs/builtin/understanding-before-execution/inflight-records.js +0 -618
- package/dist/policy-packs/builtin/understanding-before-execution/inflight-records.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/ledger.d.ts +0 -25
- package/dist/policy-packs/builtin/understanding-before-execution/ledger.js +0 -56
- package/dist/policy-packs/builtin/understanding-before-execution/ledger.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/lifecycle.d.ts +0 -20
- package/dist/policy-packs/builtin/understanding-before-execution/lifecycle.js +0 -93
- package/dist/policy-packs/builtin/understanding-before-execution/lifecycle.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/markers.d.ts +0 -126
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js +0 -245
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.d.ts +0 -29
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js +0 -82
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/permission-mode-observations.d.ts +0 -71
- package/dist/policy-packs/builtin/understanding-before-execution/permission-mode-observations.js +0 -175
- package/dist/policy-packs/builtin/understanding-before-execution/permission-mode-observations.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.d.ts +0 -620
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js +0 -1047
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.d.ts +0 -128
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js +0 -213
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/stay-in-scope-config.d.ts +0 -129
- package/dist/policy-packs/builtin/understanding-before-execution/stay-in-scope-config.js +0 -166
- package/dist/policy-packs/builtin/understanding-before-execution/stay-in-scope-config.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.d.ts +0 -164
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js +0 -275
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution-runtime.d.ts +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution-runtime.js +0 -10
- package/dist/policy-packs/builtin/understanding-before-execution-runtime.js.map +0 -1
- package/dist/policy-packs/builtin/understanding-before-execution.d.ts +0 -526
- package/dist/policy-packs/builtin/understanding-before-execution.js +0 -1074
- package/dist/policy-packs/builtin/understanding-before-execution.js.map +0 -1
- package/dist/policy-packs/permission-translator.d.ts +0 -9
- package/dist/policy-packs/permission-translator.js +0 -76
- package/dist/policy-packs/permission-translator.js.map +0 -1
- package/dist/runtime/action-envelope.d.ts +0 -64
- package/dist/runtime/action-envelope.js +0 -46
- package/dist/runtime/action-envelope.js.map +0 -1
- package/dist/runtime/approval-signing.d.ts +0 -111
- package/dist/runtime/approval-signing.js +0 -384
- package/dist/runtime/approval-signing.js.map +0 -1
- package/dist/runtime/bash-match-facts.d.ts +0 -60
- package/dist/runtime/bash-match-facts.js +0 -196
- package/dist/runtime/bash-match-facts.js.map +0 -1
- package/dist/runtime/bash-match-registry.d.ts +0 -112
- package/dist/runtime/bash-match-registry.js +0 -406
- package/dist/runtime/bash-match-registry.js.map +0 -1
- package/dist/runtime/bash-prefix-parse.d.ts +0 -31
- package/dist/runtime/bash-prefix-parse.js +0 -576
- package/dist/runtime/bash-prefix-parse.js.map +0 -1
- package/dist/runtime/command-normalize.d.ts +0 -658
- package/dist/runtime/command-normalize.js +0 -2410
- package/dist/runtime/command-normalize.js.map +0 -1
- package/dist/runtime/deletion-target-resolve.d.ts +0 -28
- package/dist/runtime/deletion-target-resolve.js +0 -1078
- package/dist/runtime/deletion-target-resolve.js.map +0 -1
- package/dist/runtime/destructive-shell-floor.d.ts +0 -19
- package/dist/runtime/destructive-shell-floor.js +0 -611
- package/dist/runtime/destructive-shell-floor.js.map +0 -1
- package/dist/runtime/environment-resolver.d.ts +0 -36
- package/dist/runtime/environment-resolver.js +0 -138
- package/dist/runtime/environment-resolver.js.map +0 -1
- package/dist/runtime/git-context.d.ts +0 -201
- package/dist/runtime/git-context.js +0 -422
- package/dist/runtime/git-context.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -12
- package/dist/runtime/index.js +0 -13
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/intercept.d.ts +0 -494
- package/dist/runtime/intercept.js +0 -1313
- package/dist/runtime/intercept.js.map +0 -1
- package/dist/runtime/kube-context.d.ts +0 -16
- package/dist/runtime/kube-context.js +0 -63
- package/dist/runtime/kube-context.js.map +0 -1
- package/dist/runtime/kubectl-target-parse.d.ts +0 -31
- package/dist/runtime/kubectl-target-parse.js +0 -249
- package/dist/runtime/kubectl-target-parse.js.map +0 -1
- package/dist/runtime/ledger-add.d.ts +0 -16
- package/dist/runtime/ledger-add.js +0 -150
- package/dist/runtime/ledger-add.js.map +0 -1
- package/dist/runtime/ledger-writer.d.ts +0 -27
- package/dist/runtime/ledger-writer.js +0 -46
- package/dist/runtime/ledger-writer.js.map +0 -1
- package/dist/runtime/pause-sentinel.d.ts +0 -60
- package/dist/runtime/pause-sentinel.js +0 -156
- package/dist/runtime/pause-sentinel.js.map +0 -1
- package/dist/runtime/pending-approval.d.ts +0 -23
- package/dist/runtime/pending-approval.js +0 -67
- package/dist/runtime/pending-approval.js.map +0 -1
- package/dist/runtime/read-only-bash.d.ts +0 -141
- package/dist/runtime/read-only-bash.js +0 -2204
- package/dist/runtime/read-only-bash.js.map +0 -1
- package/dist/runtime/recovery-git-commit.d.ts +0 -22
- package/dist/runtime/recovery-git-commit.js +0 -284
- package/dist/runtime/recovery-git-commit.js.map +0 -1
- package/dist/runtime/reject-malformed-session-id.d.ts +0 -8
- package/dist/runtime/reject-malformed-session-id.js +0 -16
- package/dist/runtime/reject-malformed-session-id.js.map +0 -1
- package/dist/runtime/risk-classifier.d.ts +0 -38
- package/dist/runtime/risk-classifier.js +0 -311
- package/dist/runtime/risk-classifier.js.map +0 -1
- package/dist/runtime/session-id.d.ts +0 -113
- package/dist/runtime/session-id.js +0 -193
- package/dist/runtime/session-id.js.map +0 -1
- package/dist/runtime/shell-word.d.ts +0 -62
- package/dist/runtime/shell-word.js +0 -410
- package/dist/runtime/shell-word.js.map +0 -1
- package/dist/runtime/task-providers/agent-tasks.d.ts +0 -103
- package/dist/runtime/task-providers/agent-tasks.js +0 -245
- package/dist/runtime/task-providers/agent-tasks.js.map +0 -1
- package/dist/runtime/when-eval.d.ts +0 -62
- package/dist/runtime/when-eval.js +0 -212
- package/dist/runtime/when-eval.js.map +0 -1
- package/dist/runtime/workflow-policies.d.ts +0 -207
- package/dist/runtime/workflow-policies.js +0 -596
- package/dist/runtime/workflow-policies.js.map +0 -1
- package/dist/schema/audit.d.ts +0 -71
- package/dist/schema/audit.js +0 -32
- package/dist/schema/audit.js.map +0 -1
- package/dist/schema/doctor.d.ts +0 -25
- package/dist/schema/doctor.js +0 -23
- package/dist/schema/doctor.js.map +0 -1
- package/dist/schema/environments.d.ts +0 -215
- package/dist/schema/environments.js +0 -101
- package/dist/schema/environments.js.map +0 -1
- package/dist/schema/extract.d.ts +0 -9
- package/dist/schema/extract.js +0 -86
- package/dist/schema/extract.js.map +0 -1
- package/dist/schema/permission-profiles.d.ts +0 -2292
- package/dist/schema/permission-profiles.js +0 -60
- package/dist/schema/permission-profiles.js.map +0 -1
- package/dist/schema/policies.d.ts +0 -974
- package/dist/schema/policies.js +0 -298
- package/dist/schema/policies.js.map +0 -1
- package/dist/schema/requires.d.ts +0 -131
- package/dist/schema/requires.js +0 -88
- package/dist/schema/requires.js.map +0 -1
- package/dist/schema/risk.d.ts +0 -144
- package/dist/schema/risk.js +0 -194
- package/dist/schema/risk.js.map +0 -1
- package/dist/schema/session-start-preflight.d.ts +0 -10
- package/dist/schema/session-start-preflight.js +0 -106
- package/dist/schema/session-start-preflight.js.map +0 -1
- package/dist/schema/stale-base-check.d.ts +0 -18
- package/dist/schema/stale-base-check.js +0 -37
- package/dist/schema/stale-base-check.js.map +0 -1
- package/dist/schema/toolchain-parity.d.ts +0 -21
- package/dist/schema/toolchain-parity.js +0 -48
- package/dist/schema/toolchain-parity.js.map +0 -1
- package/dist/schema/workflows.d.ts +0 -519
- package/dist/schema/workflows.js +0 -81
- package/dist/schema/workflows.js.map +0 -1
- package/scripts/runtime-reality-docker-probe.mjs +0 -71
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
// Signed in-flight records for Agent-tool subagents (slice 1 of the
|
|
2
|
-
// subagent-gate work, docs/decisions/2026-08-27-ug-auto-mode-approval.md
|
|
3
|
-
// "Invariants", "Threat model", "Delegation marker shape").
|
|
4
|
-
//
|
|
5
|
-
// THE PROBLEM THIS CLOSES. An Agent-tool subagent shares its parent's
|
|
6
|
-
// `session_id`; it has no way to call `harness approve understanding`
|
|
7
|
-
// itself. The understanding gate's own boundary-expiry mechanism
|
|
8
|
-
// (`applyPostToolUseExpiry`) deletes the parent's session marker the
|
|
9
|
-
// moment the parent crosses a task boundary, even while a subagent it
|
|
10
|
-
// spawned is still mid-flight — stranding that subagent with no
|
|
11
|
-
// approval it can present. An in-flight record is what lets a
|
|
12
|
-
// subagent keep the approval its parent held at the moment the
|
|
13
|
-
// subagent STARTED, independent of what happens to the parent's own
|
|
14
|
-
// marker afterwards.
|
|
15
|
-
//
|
|
16
|
-
// WHY ITS OWN DIRECTORY, NOT `.approvals/`. Exactly the delegation
|
|
17
|
-
// precedent (`delegation-markers.ts`'s module header): a record is
|
|
18
|
-
// evidence that a parent was once approved, not itself an approval a
|
|
19
|
-
// human granted, so it stays out of every `.approvals/` scan (the
|
|
20
|
-
// doctor `approvedBy`-prefix listing, `checkApprovalMarker`'s own
|
|
21
|
-
// directory) and out of `.delegations/` (a different artifact kind,
|
|
22
|
-
// scoped to `claude -p` children, not Agent-tool subagents). A record
|
|
23
|
-
// copied onto either of those directories fails signature verification
|
|
24
|
-
// there on markerId mismatch, mirroring the delegation module's own
|
|
25
|
-
// two-way argument.
|
|
26
|
-
//
|
|
27
|
-
// CONTAINMENT: an authority artifact is read only when every directory
|
|
28
|
-
// segment this reader owns is a plain directory according to `lstat`.
|
|
29
|
-
// A symlinked or non-directory root reads as absent/fail-closed; following
|
|
30
|
-
// a link out of an authority directory never opens the gate. This applies
|
|
31
|
-
// to approval markers, delegations, adoption ledgers, and in-flight records.
|
|
32
|
-
//
|
|
33
|
-
// WHY EVERY BINDING TRAVELS INSIDE `approvedBy`. `signMarker` signs
|
|
34
|
-
// exactly the tuple `(markerId, approvedAt, approvedBy,
|
|
35
|
-
// reportContentHash)` plus, when present, the optional `claimTaskId`
|
|
36
|
-
// (see `canonicalPayload`); any other new signed field is a `SIGNING_ALG` bump.
|
|
37
|
-
// So the one thing this record signs beyond the marker id and the
|
|
38
|
-
// issue timestamp — which parent authority actually matched — rides in
|
|
39
|
-
// `approvedBy` as `inflight:<agentType>:parent=<task|session>`, the
|
|
40
|
-
// same shape choice `delegation-markers.ts` and the auto-approval path
|
|
41
|
-
// already made for their own extra bindings.
|
|
42
|
-
//
|
|
43
|
-
// SIGNATURE SCOPE, DELIBERATELY NARROW. The signed tuple binds
|
|
44
|
-
// `markerId` (which is itself `inflight:<sessionId>:<agentId>`),
|
|
45
|
-
// `approvedAt`, `approvedBy`, and a `null` report hash; it does NOT
|
|
46
|
-
// cover the `sessionId`/`agentId` fields stored in the body for
|
|
47
|
-
// convenience. A verifier that only recomputed the signature could
|
|
48
|
-
// therefore be fooled by a record left in place with its own body
|
|
49
|
-
// fields edited to claim a different agent id than the path it lives
|
|
50
|
-
// at — the signature over `inflight:<sessionId>:<agentId>` would still
|
|
51
|
-
// verify because `markerId` is derived from the REQUESTED ids, not
|
|
52
|
-
// from the body. `verifyInflightRecord` closes that gap with an
|
|
53
|
-
// explicit equality check between the body's own `sessionId`/`agentId`
|
|
54
|
-
// and the ids the caller is asking about, independent of the signature
|
|
55
|
-
// check: a record copied onto a different id's path recomputes the
|
|
56
|
-
// SAME signature (the markerId is derived from the requested ids, which
|
|
57
|
-
// still match its new path), so this equality check is the only thing
|
|
58
|
-
// that catches that shape of forgery.
|
|
59
|
-
//
|
|
60
|
-
// UNSIGNED CONVENIENCE FIELDS ARE NEVER LOAD-BEARING ON THEIR OWN. The
|
|
61
|
-
// body also carries `startedAt`, `agentType` and `parentSource` outside
|
|
62
|
-
// the signed tuple, for display and for readers (`listInflightRecords`,
|
|
63
|
-
// `harness gc`) that intentionally skip signature verification because
|
|
64
|
-
// they are deciding retention, not trust. `verifyInflightRecord` treats
|
|
65
|
-
// every one of those unsigned fields as untrustworthy on its own: it
|
|
66
|
-
// requires `startedAt` to equal the SIGNED `approvedAt` byte-for-byte
|
|
67
|
-
// (the writer always sets them to the same instant), and it requires
|
|
68
|
-
// `agentType`/`parentSource` to equal the values parsed back out of the
|
|
69
|
-
// SIGNED `approvedBy` string. Either disagreement is `forged`, never a
|
|
70
|
-
// silent fallback to the signed value — an editable field that could
|
|
71
|
-
// diverge from its signed twin without consequence would be exactly the
|
|
72
|
-
// same hole as trusting the unsigned field outright. Staleness itself is
|
|
73
|
-
// therefore computed from `approvedAt` (signed), not `startedAt`
|
|
74
|
-
// (unsigned): reviving an expired record by rewriting its unsigned
|
|
75
|
-
// timestamp is closed by verification failing outright, not merely by
|
|
76
|
-
// picking "the right" field to trust.
|
|
77
|
-
import * as fs from "node:fs";
|
|
78
|
-
import * as path from "node:path";
|
|
79
|
-
import { atomicWriteFile } from "../../../io/atomic-write.js";
|
|
80
|
-
import { readRegularFileRejectingSymlink } from "../../../io/read-regular-file.js";
|
|
81
|
-
import { safeJsonParse } from "../../../io/safe-json-parse.js";
|
|
82
|
-
import { signMarker, verifyMarkerSignature } from "../../../runtime/approval-signing.js";
|
|
83
|
-
import { rejectMalformedSessionId } from "../../../runtime/reject-malformed-session-id.js";
|
|
84
|
-
/** Directory holding in-flight records, a sibling of `.approvals/` and `.delegations/` under `generatedDir`. */
|
|
85
|
-
export const INFLIGHT_RECORD_DIRNAME = ".inflight";
|
|
86
|
-
/** Default staleness window: a record older than this is treated as dead weight even though nothing ever cleared it. */
|
|
87
|
-
export const DEFAULT_INFLIGHT_STALE_AFTER_MS = 24 * 60 * 60 * 1000;
|
|
88
|
-
/** Prefix of the signed markerId, mirroring `delegation-<child-sid>`. */
|
|
89
|
-
const INFLIGHT_MARKER_ID_PREFIX = "inflight:";
|
|
90
|
-
/**
|
|
91
|
-
* An agent id is a value Claude Code hands the hook, never one the
|
|
92
|
-
* repository's own path-traversal-sensitive session ids need to share
|
|
93
|
-
* a shape with, but it lands in `path.join` the same way, so it gets
|
|
94
|
-
* its own narrow allowlist rather than reusing
|
|
95
|
-
* `rejectMalformedSessionId`'s looser "no `/`, `\`, `..`" rule: 1..128
|
|
96
|
-
* characters, first character alphanumeric (so it can never literally
|
|
97
|
-
* be `.` or `..`), every other character one of
|
|
98
|
-
* `[A-Za-z0-9._-]` (no control characters, no path separators).
|
|
99
|
-
*/
|
|
100
|
-
const AGENT_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
101
|
-
/** Rejects an agent id outside the allowlist above. Throws; never returns a value. */
|
|
102
|
-
export function rejectMalformedAgentId(agentId) {
|
|
103
|
-
if (agentId.length === 0) {
|
|
104
|
-
throw new Error("agentId is empty");
|
|
105
|
-
}
|
|
106
|
-
if (agentId.length > 128) {
|
|
107
|
-
throw new Error(`agentId exceeds 128 characters (got ${agentId.length})`);
|
|
108
|
-
}
|
|
109
|
-
if (!AGENT_ID_RE.test(agentId)) {
|
|
110
|
-
throw new Error(`agentId must start with an alphanumeric character and contain only letters, digits, ".", "_", or "-": ${JSON.stringify(agentId)}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* The signed markerId for a record: `inflight:<sessionId>:<agentId>`.
|
|
115
|
-
* Binding both ids into the signed payload is what stops a validly
|
|
116
|
-
* signed record from being copied onto another agent id, or another
|
|
117
|
-
* session, and still verifying.
|
|
118
|
-
*/
|
|
119
|
-
export function inflightMarkerIdFor(sessionId, agentId) {
|
|
120
|
-
return `${INFLIGHT_MARKER_ID_PREFIX}${sessionId}:${agentId}`;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Filesystem path of a subagent's in-flight record:
|
|
124
|
-
* `<generatedDir>/.inflight/<sessionId>/<agentId>`. Validates both ids
|
|
125
|
-
* before they reach `path.join`, the same defensive posture every
|
|
126
|
-
* other marker path function in this pack takes.
|
|
127
|
-
*/
|
|
128
|
-
export function inflightRecordPathFor(generatedDir, sessionId, agentId) {
|
|
129
|
-
rejectMalformedSessionId(sessionId);
|
|
130
|
-
rejectMalformedAgentId(agentId);
|
|
131
|
-
return path.join(generatedDir, INFLIGHT_RECORD_DIRNAME, sessionId, agentId);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* `agentType` is a Claude-Code-supplied label (e.g. `general-purpose`)
|
|
135
|
-
* that rides inside the signed `approvedBy` string as a `:`-delimited
|
|
136
|
-
* segment, so it gets the narrowest allowlist that keeps it from ever
|
|
137
|
-
* introducing a `:` (which `parseInflightApprovedBy` relies on to find
|
|
138
|
-
* the `:parent=` boundary) or a control character: 1..64 characters,
|
|
139
|
-
* first character alphanumeric, every other character one of
|
|
140
|
-
* `[A-Za-z0-9._-]`.
|
|
141
|
-
*/
|
|
142
|
-
const AGENT_TYPE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
143
|
-
/**
|
|
144
|
-
* Clock-skew tolerance for a record's signed `approvedAt`: an approval
|
|
145
|
-
* timestamp more than this far in the future cannot come from a clock
|
|
146
|
-
* this process trusts, so it is never matched — but unlike a forgery it
|
|
147
|
-
* is not evidence of tampering (a clock can simply be wrong), so it is
|
|
148
|
-
* reported as `stale`, the same bucket `harness gc` and the doctor
|
|
149
|
-
* listing already sweep on the aged side of the window.
|
|
150
|
-
*/
|
|
151
|
-
const INFLIGHT_FUTURE_SKEW_MS = 5 * 60 * 1000;
|
|
152
|
-
/** The exact shape `writeInflightRecord` signs into `approvedBy`. */
|
|
153
|
-
const INFLIGHT_APPROVED_BY_RE = /^inflight:([A-Za-z0-9][A-Za-z0-9._-]{0,63}):parent=(task|session)$/;
|
|
154
|
-
/**
|
|
155
|
-
* Parse a signed `approvedBy` string back into the bindings it carries.
|
|
156
|
-
* `null` on anything that does not match the exact shape
|
|
157
|
-
* `writeInflightRecord` produces — this is the reader half of "every
|
|
158
|
-
* binding travels inside `approvedBy`" (see the module header): a
|
|
159
|
-
* value the writer could not have produced is never trusted as a source
|
|
160
|
-
* of bindings, even though its bytes passed HMAC verification (a valid
|
|
161
|
-
* signature only proves the bytes were signed by this key, not that
|
|
162
|
-
* they match the shape a caller can safely destructure).
|
|
163
|
-
*/
|
|
164
|
-
function parseInflightApprovedBy(approvedBy) {
|
|
165
|
-
const match = INFLIGHT_APPROVED_BY_RE.exec(approvedBy);
|
|
166
|
-
if (match === null)
|
|
167
|
-
return null;
|
|
168
|
-
const [, agentType, parentSource] = match;
|
|
169
|
-
return { agentType: agentType, parentSource: parentSource };
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Write a signed in-flight record, but only when `parent` names a
|
|
173
|
-
* MATCHED operator approval — a record is a copy of authority the
|
|
174
|
-
* parent already had, never a new grant, so an unmatched parent
|
|
175
|
-
* refuses outright with nothing written: the guard below is the entire
|
|
176
|
-
* enforcement point, not a redundant belt-and-suspenders check on top
|
|
177
|
-
* of some other gate. Atomic and mode 0600, like every other marker
|
|
178
|
-
* write in this pack.
|
|
179
|
-
*/
|
|
180
|
-
export function writeInflightRecord(opts) {
|
|
181
|
-
if (!opts.parent.matched || opts.parent.source === null) {
|
|
182
|
-
return {
|
|
183
|
-
ok: false,
|
|
184
|
-
reason: "parent_not_approved",
|
|
185
|
-
detail: "refusing to write an in-flight record: the parent has no matched operator approval",
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
if (!AGENT_TYPE_RE.test(opts.agentType)) {
|
|
189
|
-
return {
|
|
190
|
-
ok: false,
|
|
191
|
-
reason: "malformed_agent_type",
|
|
192
|
-
detail: `agentType must be 1-64 characters, first character alphanumeric, every other character one of letters, digits, ".", "_", or "-": ${JSON.stringify(opts.agentType)}`,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
let filePath;
|
|
196
|
-
try {
|
|
197
|
-
filePath = inflightRecordPathFor(opts.generatedDir, opts.sessionId, opts.agentId);
|
|
198
|
-
}
|
|
199
|
-
catch (err) {
|
|
200
|
-
return {
|
|
201
|
-
ok: false,
|
|
202
|
-
reason: "invalid-input",
|
|
203
|
-
detail: err instanceof Error ? err.message : String(err),
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
const parentSource = opts.parent.source;
|
|
207
|
-
const startedAt = (opts.now ?? new Date()).toISOString();
|
|
208
|
-
const markerId = inflightMarkerIdFor(opts.sessionId, opts.agentId);
|
|
209
|
-
const signed = signMarker(opts.generatedDir, markerId, {
|
|
210
|
-
approvedAt: startedAt,
|
|
211
|
-
approvedBy: `inflight:${opts.agentType}:parent=${parentSource}`,
|
|
212
|
-
reportContentHash: null,
|
|
213
|
-
});
|
|
214
|
-
const body = {
|
|
215
|
-
sessionId: opts.sessionId,
|
|
216
|
-
agentId: opts.agentId,
|
|
217
|
-
agentType: opts.agentType,
|
|
218
|
-
startedAt,
|
|
219
|
-
parentSource,
|
|
220
|
-
parentDetail: opts.parent.detail,
|
|
221
|
-
...signed,
|
|
222
|
-
};
|
|
223
|
-
try {
|
|
224
|
-
atomicWriteFile(filePath, `${JSON.stringify(body, null, 2)}\n`, { mode: 0o600 });
|
|
225
|
-
}
|
|
226
|
-
catch (err) {
|
|
227
|
-
return {
|
|
228
|
-
ok: false,
|
|
229
|
-
reason: "write-failed",
|
|
230
|
-
detail: err instanceof Error ? err.message : String(err),
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
return { ok: true, filePath };
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Consult the in-flight record for `(sessionId, agentId)`. Checks, in
|
|
237
|
-
* order: the `.inflight/` root and the session directory are real
|
|
238
|
-
* directories, not symlinks (module header, "CONTAINMENT"); the
|
|
239
|
-
* requested `agentId` names an EXACT directory entry, not merely a path
|
|
240
|
-
* that resolves (guards a case-insensitive filesystem); the file is
|
|
241
|
-
* present and JSON-readable; its signature verifies against
|
|
242
|
-
* `inflight:<sessionId>:<agentId>` RECOMPUTED FROM THE REQUESTED ids
|
|
243
|
-
* (never from anything stored in the body); its own `sessionId`/`agentId`
|
|
244
|
-
* fields agree with those requested ids (the check the signature alone
|
|
245
|
-
* cannot make, see the module header); it is not older than the
|
|
246
|
-
* staleness window.
|
|
247
|
-
*
|
|
248
|
-
* Fail-closed shape mirrors `verifyDelegation`: every refusal names a
|
|
249
|
-
* distinct reason, `forged` and `stale` are reachable only from the
|
|
250
|
-
* branches documented above, and there is no branch that turns a
|
|
251
|
-
* missing, malformed, moved, or aged record into `matched: true`.
|
|
252
|
-
*/
|
|
253
|
-
export function verifyInflightRecord(generatedDir, sessionId, agentId, opts = {}) {
|
|
254
|
-
let filePath;
|
|
255
|
-
try {
|
|
256
|
-
filePath = inflightRecordPathFor(generatedDir, sessionId, agentId);
|
|
257
|
-
}
|
|
258
|
-
catch (err) {
|
|
259
|
-
return {
|
|
260
|
-
matched: false,
|
|
261
|
-
forged: false,
|
|
262
|
-
stale: false,
|
|
263
|
-
detail: `invalid sessionId/agentId for in-flight record: ${err instanceof Error ? err.message : String(err)}`,
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
// lstat the root and the session directory before ever reading the
|
|
267
|
-
// leaf, mirroring `listInflightRecords`' own guard: a `readdirSync` or
|
|
268
|
-
// `readFileSync` reached only by following a symlink out of
|
|
269
|
-
// `.inflight/` would let a linked root or session directory smuggle a
|
|
270
|
-
// record from elsewhere on disk. Absent, a symlink, or not a directory
|
|
271
|
-
// all read as "no record" here, never `forged`: none of them is
|
|
272
|
-
// evidence of a tampered signature, only that the expected containment
|
|
273
|
-
// does not hold.
|
|
274
|
-
const rootDir = path.join(generatedDir, INFLIGHT_RECORD_DIRNAME);
|
|
275
|
-
const sessionDir = path.join(rootDir, sessionId);
|
|
276
|
-
for (const dir of [rootDir, sessionDir]) {
|
|
277
|
-
let dirStat;
|
|
278
|
-
try {
|
|
279
|
-
dirStat = fs.lstatSync(dir);
|
|
280
|
-
}
|
|
281
|
-
catch {
|
|
282
|
-
return { matched: false, forged: false, stale: false, detail: `no in-flight record at ${filePath}` };
|
|
283
|
-
}
|
|
284
|
-
if (!dirStat.isDirectory()) {
|
|
285
|
-
return {
|
|
286
|
-
matched: false,
|
|
287
|
-
forged: false,
|
|
288
|
-
stale: false,
|
|
289
|
-
detail: `no in-flight record at ${filePath} (${dir} is not a plain directory)`,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
// The requested agentId must name an EXACT entry in the session
|
|
294
|
-
// directory, not merely a path `path.join` can resolve to. On a
|
|
295
|
-
// case-insensitive filesystem the read below would happily open a
|
|
296
|
-
// differently-cased sibling's record; its signature — recomputed from
|
|
297
|
-
// the REQUESTED, case-variant id — would then fail to verify and be
|
|
298
|
-
// classified forged, even though nothing was tampered with. A
|
|
299
|
-
// case-variant request simply names no record; `readdirSync` lists
|
|
300
|
-
// literal entry names regardless of the filesystem's own case
|
|
301
|
-
// sensitivity, so this is the one check that can tell the two apart.
|
|
302
|
-
//
|
|
303
|
-
// ONLY the agentId segment gets this exact-entry check. The sessionId
|
|
304
|
-
// segment (the `sessionDir` lstat above) inherits whatever the
|
|
305
|
-
// underlying filesystem does with `path.join` + `lstatSync`: on a
|
|
306
|
-
// case-insensitive volume a case-variant sessionId still resolves to
|
|
307
|
-
// the same directory, so the lstat passes, and the record is read and
|
|
308
|
-
// signature-checked against the REQUESTED (case-variant) sessionId —
|
|
309
|
-
// which the SIGNED body never matches, so it comes back `forged`, not
|
|
310
|
-
// "no record". This is the same fail-closed outcome the module header
|
|
311
|
-
// argues for generally; it is merely a less precise diagnostic than
|
|
312
|
-
// the agentId case gets (see the ADR's "TTL, cwd, and subagents"
|
|
313
|
-
// section for the write side that never produces one anyway: session
|
|
314
|
-
// ids are runtime-generated UUIDs, not operator-chosen strings, so a
|
|
315
|
-
// case collision is not a realistic write-time input).
|
|
316
|
-
let sessionEntries;
|
|
317
|
-
try {
|
|
318
|
-
sessionEntries = fs.readdirSync(sessionDir);
|
|
319
|
-
}
|
|
320
|
-
catch {
|
|
321
|
-
return { matched: false, forged: false, stale: false, detail: `no in-flight record at ${filePath}` };
|
|
322
|
-
}
|
|
323
|
-
if (!sessionEntries.includes(agentId)) {
|
|
324
|
-
return {
|
|
325
|
-
matched: false,
|
|
326
|
-
forged: false,
|
|
327
|
-
stale: false,
|
|
328
|
-
detail: `no in-flight record at ${filePath} (no exact entry named ${JSON.stringify(agentId)} in ${sessionDir})`,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
const read = readRegularFileRejectingSymlink(filePath);
|
|
332
|
-
if (read.kind === "missing") {
|
|
333
|
-
return { matched: false, forged: false, stale: false, detail: `no in-flight record at ${filePath}` };
|
|
334
|
-
}
|
|
335
|
-
if (read.kind === "symlink") {
|
|
336
|
-
return {
|
|
337
|
-
matched: false,
|
|
338
|
-
forged: false,
|
|
339
|
-
stale: false,
|
|
340
|
-
detail: `in-flight record is a symlink, refusing for safety: ${filePath}`,
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
if (read.kind === "not-regular") {
|
|
344
|
-
return {
|
|
345
|
-
matched: false,
|
|
346
|
-
forged: false,
|
|
347
|
-
stale: false,
|
|
348
|
-
detail: `in-flight record path is not a regular file: ${filePath}`,
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
if (read.kind === "unreadable") {
|
|
352
|
-
return {
|
|
353
|
-
matched: false,
|
|
354
|
-
forged: false,
|
|
355
|
-
stale: false,
|
|
356
|
-
detail: `in-flight record at ${filePath} exists but could not be read (I/O error); treating as absent since its signature cannot be verified`,
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
const parsed = safeJsonParse(read.content);
|
|
360
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
361
|
-
return {
|
|
362
|
-
matched: false,
|
|
363
|
-
forged: false,
|
|
364
|
-
stale: false,
|
|
365
|
-
detail: `unparsable in-flight record body at ${filePath}`,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
const body = parsed;
|
|
369
|
-
const markerId = inflightMarkerIdFor(sessionId, agentId);
|
|
370
|
-
const verification = verifyMarkerSignature(generatedDir, markerId, body);
|
|
371
|
-
if (!verification.ok) {
|
|
372
|
-
if (verification.kind === "key-unavailable") {
|
|
373
|
-
// Fail-closed I/O problem, not evidence of tampering — same
|
|
374
|
-
// distinction `verifyDelegation` draws for its own `unreadable`.
|
|
375
|
-
return {
|
|
376
|
-
matched: false,
|
|
377
|
-
forged: false,
|
|
378
|
-
stale: false,
|
|
379
|
-
detail: `in-flight record at ${filePath} could not be verified: ${verification.reason}`,
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
return {
|
|
383
|
-
matched: false,
|
|
384
|
-
forged: true,
|
|
385
|
-
stale: false,
|
|
386
|
-
detail: `forged/unsigned in-flight record rejected: ${verification.reason} (${filePath})`,
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
const bodySessionId = typeof body["sessionId"] === "string" ? body["sessionId"] : undefined;
|
|
390
|
-
const bodyAgentId = typeof body["agentId"] === "string" ? body["agentId"] : undefined;
|
|
391
|
-
if (bodySessionId !== sessionId || bodyAgentId !== agentId) {
|
|
392
|
-
return {
|
|
393
|
-
matched: false,
|
|
394
|
-
forged: true,
|
|
395
|
-
stale: false,
|
|
396
|
-
detail: `in-flight record at ${filePath} disagrees with its own path (body sessionId=${JSON.stringify(bodySessionId)}, agentId=${JSON.stringify(bodyAgentId)}, expected ${sessionId}/${agentId})`,
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
// `verifyMarkerSignature` already rejected a non-string/empty
|
|
400
|
-
// `approvedAt` before returning `ok: true`, so this cast is safe; the
|
|
401
|
-
// finite-instant check below still guards against a signed-but-garbage
|
|
402
|
-
// value (e.g. a non-date string that happens to be non-empty).
|
|
403
|
-
const approvedAt = body["approvedAt"];
|
|
404
|
-
const approvedAtMs = Date.parse(approvedAt);
|
|
405
|
-
if (!Number.isFinite(approvedAtMs)) {
|
|
406
|
-
return {
|
|
407
|
-
matched: false,
|
|
408
|
-
forged: true,
|
|
409
|
-
stale: false,
|
|
410
|
-
detail: `in-flight record at ${filePath} has a signed approvedAt that is not a valid instant: ${JSON.stringify(approvedAt)}`,
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
// The unsigned `startedAt` convenience field must agree with the
|
|
414
|
-
// SIGNED `approvedAt` byte-for-byte (the writer always sets them to
|
|
415
|
-
// the same instant). Divergence means the unsigned copy was edited
|
|
416
|
-
// after signing — the shape that would revive an aged, genuinely
|
|
417
|
-
// stale record by rewriting only its unsigned timestamp.
|
|
418
|
-
const startedAt = typeof body["startedAt"] === "string" ? body["startedAt"] : undefined;
|
|
419
|
-
if (startedAt !== approvedAt) {
|
|
420
|
-
return {
|
|
421
|
-
matched: false,
|
|
422
|
-
forged: true,
|
|
423
|
-
stale: false,
|
|
424
|
-
detail: `in-flight record at ${filePath} has an unsigned startedAt that disagrees with its signed approvedAt (startedAt=${JSON.stringify(startedAt)}, approvedAt=${JSON.stringify(approvedAt)})`,
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
// `approvedBy` is likewise guaranteed a non-empty string by
|
|
428
|
-
// `verifyMarkerSignature`. Its parsed bindings must agree with the
|
|
429
|
-
// unsigned `agentType`/`parentSource` fields the body carries for
|
|
430
|
-
// display — an attacker who could edit only the unsigned pair (the
|
|
431
|
-
// signed `approvedBy` unchanged) would otherwise reach the success
|
|
432
|
-
// detail below with a body/approvedBy that disagree.
|
|
433
|
-
const approvedBy = body["approvedBy"];
|
|
434
|
-
const bindings = parseInflightApprovedBy(approvedBy);
|
|
435
|
-
const bodyAgentType = typeof body["agentType"] === "string" ? body["agentType"] : undefined;
|
|
436
|
-
const bodyParentSource = typeof body["parentSource"] === "string" ? body["parentSource"] : undefined;
|
|
437
|
-
if (bindings === null || bindings.agentType !== bodyAgentType || bindings.parentSource !== bodyParentSource) {
|
|
438
|
-
return {
|
|
439
|
-
matched: false,
|
|
440
|
-
forged: true,
|
|
441
|
-
stale: false,
|
|
442
|
-
detail: `in-flight record at ${filePath} has an approvedBy binding that disagrees with its own body (approvedBy=${JSON.stringify(approvedBy)}, body agentType=${JSON.stringify(bodyAgentType)}, parentSource=${JSON.stringify(bodyParentSource)})`,
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
const nowMs = (opts.now ?? new Date()).getTime();
|
|
446
|
-
const staleAfterMs = opts.staleAfterMs ?? DEFAULT_INFLIGHT_STALE_AFTER_MS;
|
|
447
|
-
// A clock this process trusts would never see its own signed approval
|
|
448
|
-
// land more than a few minutes in the future; treat it like staleness
|
|
449
|
-
// (not a forgery) since a clock skew is not evidence of tampering.
|
|
450
|
-
if (approvedAtMs - nowMs > INFLIGHT_FUTURE_SKEW_MS) {
|
|
451
|
-
return {
|
|
452
|
-
matched: false,
|
|
453
|
-
forged: false,
|
|
454
|
-
stale: true,
|
|
455
|
-
detail: `in-flight record at ${filePath} is dated more than ${INFLIGHT_FUTURE_SKEW_MS / 60_000} minutes in the future: approved at ${approvedAt}`,
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
// `nowMs - approvedAtMs > staleAfterMs`, not the reverse: swapping the
|
|
459
|
-
// comparison would mark a fresh record stale and a genuinely stale one
|
|
460
|
-
// fresh.
|
|
461
|
-
if (nowMs - approvedAtMs > staleAfterMs) {
|
|
462
|
-
return {
|
|
463
|
-
matched: false,
|
|
464
|
-
forged: false,
|
|
465
|
-
stale: true,
|
|
466
|
-
detail: `in-flight record at ${filePath} is stale: approved at ${approvedAt}`,
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
return {
|
|
470
|
-
matched: true,
|
|
471
|
-
forged: false,
|
|
472
|
-
stale: false,
|
|
473
|
-
detail: `in-flight record matched: agent ${agentId} (${bindings.agentType}), parent=${bindings.parentSource}, approved at ${approvedAt}`,
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Remove a subagent's in-flight record, then best-effort remove its
|
|
478
|
-
* now-possibly-empty session directory. Never throws when the record,
|
|
479
|
-
* or the session directory, is already gone — mirrors
|
|
480
|
-
* `clearApprovalMarker` / `clearTaskApprovalMarker`.
|
|
481
|
-
*/
|
|
482
|
-
export function clearInflightRecord(generatedDir, sessionId, agentId) {
|
|
483
|
-
let filePath;
|
|
484
|
-
try {
|
|
485
|
-
filePath = inflightRecordPathFor(generatedDir, sessionId, agentId);
|
|
486
|
-
}
|
|
487
|
-
catch {
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
try {
|
|
491
|
-
fs.rmSync(filePath);
|
|
492
|
-
}
|
|
493
|
-
catch {
|
|
494
|
-
/* already gone */
|
|
495
|
-
}
|
|
496
|
-
try {
|
|
497
|
-
fs.rmdirSync(path.dirname(filePath));
|
|
498
|
-
}
|
|
499
|
-
catch {
|
|
500
|
-
/* not empty, or already gone */
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Read-only audit listing of every in-flight record on disk, mirroring
|
|
505
|
-
* `buildUgDelegations`'s own shape: no signature check (this is
|
|
506
|
-
* evidence for `harness doctor` and `harness gc`, not a trust
|
|
507
|
-
* decision), tolerant of a missing `.inflight/` directory (empty
|
|
508
|
-
* result rather than an error), and an entry gc/doctor cannot make
|
|
509
|
-
* sense of is `skipped` rather than silently dropped.
|
|
510
|
-
*
|
|
511
|
-
* lstat the root itself first, not a bare `readdirSync`-then-catch: a
|
|
512
|
-
* `readdirSync` on a symlinked `.inflight/` would happily follow it and
|
|
513
|
-
* list whatever real directory it points at, the same trap
|
|
514
|
-
* `sweepInflightRecords` in `src/cli/gc/index.ts` already guards
|
|
515
|
-
* against one level up. A symlinked or non-directory root reads as
|
|
516
|
-
* absent here too, for the same reason `buildUgInflight` already lstats
|
|
517
|
-
* before calling this function: it must not report on records reached
|
|
518
|
-
* only by following a link out of `.inflight/`.
|
|
519
|
-
*/
|
|
520
|
-
export function listInflightRecords(generatedDir, now, staleAfterMs) {
|
|
521
|
-
const dir = path.join(generatedDir, INFLIGHT_RECORD_DIRNAME);
|
|
522
|
-
const nowMs = (now ?? new Date()).getTime();
|
|
523
|
-
const effectiveStaleAfterMs = staleAfterMs ?? DEFAULT_INFLIGHT_STALE_AFTER_MS;
|
|
524
|
-
let rootStat;
|
|
525
|
-
try {
|
|
526
|
-
rootStat = fs.lstatSync(dir);
|
|
527
|
-
}
|
|
528
|
-
catch {
|
|
529
|
-
return { total: 0, stale: 0, sessions: [], skipped: [] };
|
|
530
|
-
}
|
|
531
|
-
if (!rootStat.isDirectory()) {
|
|
532
|
-
return { total: 0, stale: 0, sessions: [], skipped: [] };
|
|
533
|
-
}
|
|
534
|
-
let sessionDirents;
|
|
535
|
-
try {
|
|
536
|
-
sessionDirents = fs.readdirSync(dir, { withFileTypes: true });
|
|
537
|
-
}
|
|
538
|
-
catch {
|
|
539
|
-
return { total: 0, stale: 0, sessions: [], skipped: [] };
|
|
540
|
-
}
|
|
541
|
-
let total = 0;
|
|
542
|
-
let stale = 0;
|
|
543
|
-
const sessions = [];
|
|
544
|
-
const skipped = [];
|
|
545
|
-
for (const sessionDirent of sessionDirents) {
|
|
546
|
-
const sessionPath = path.join(dir, sessionDirent.name);
|
|
547
|
-
if (!sessionDirent.isDirectory()) {
|
|
548
|
-
skipped.push(sessionPath);
|
|
549
|
-
continue;
|
|
550
|
-
}
|
|
551
|
-
try {
|
|
552
|
-
rejectMalformedSessionId(sessionDirent.name);
|
|
553
|
-
}
|
|
554
|
-
catch {
|
|
555
|
-
skipped.push(sessionPath);
|
|
556
|
-
continue;
|
|
557
|
-
}
|
|
558
|
-
let agentDirents;
|
|
559
|
-
try {
|
|
560
|
-
agentDirents = fs.readdirSync(sessionPath, { withFileTypes: true });
|
|
561
|
-
}
|
|
562
|
-
catch {
|
|
563
|
-
skipped.push(sessionPath);
|
|
564
|
-
continue;
|
|
565
|
-
}
|
|
566
|
-
const agentIds = [];
|
|
567
|
-
for (const agentDirent of agentDirents) {
|
|
568
|
-
const full = path.join(sessionPath, agentDirent.name);
|
|
569
|
-
if (!agentDirent.isFile()) {
|
|
570
|
-
skipped.push(full);
|
|
571
|
-
continue;
|
|
572
|
-
}
|
|
573
|
-
try {
|
|
574
|
-
rejectMalformedAgentId(agentDirent.name);
|
|
575
|
-
}
|
|
576
|
-
catch {
|
|
577
|
-
skipped.push(full);
|
|
578
|
-
continue;
|
|
579
|
-
}
|
|
580
|
-
const read = readRegularFileRejectingSymlink(full);
|
|
581
|
-
if (read.kind !== "ok") {
|
|
582
|
-
skipped.push(full);
|
|
583
|
-
continue;
|
|
584
|
-
}
|
|
585
|
-
const parsed = safeJsonParse(read.content);
|
|
586
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
587
|
-
skipped.push(full);
|
|
588
|
-
continue;
|
|
589
|
-
}
|
|
590
|
-
const body = parsed;
|
|
591
|
-
// No signature check here (audit listing, not a trust decision —
|
|
592
|
-
// see the function doc), so this reads the SAME `approvedAt`
|
|
593
|
-
// field `verifyInflightRecord` trusts only once it has verified
|
|
594
|
-
// the signature: an unsigned `startedAt` copy is never consulted,
|
|
595
|
-
// by either reader, for a staleness decision.
|
|
596
|
-
const approvedAt = typeof body["approvedAt"] === "string" ? body["approvedAt"] : undefined;
|
|
597
|
-
const approvedAtMs = approvedAt !== undefined ? Date.parse(approvedAt) : NaN;
|
|
598
|
-
if (approvedAt === undefined || !Number.isFinite(approvedAtMs)) {
|
|
599
|
-
skipped.push(full);
|
|
600
|
-
continue;
|
|
601
|
-
}
|
|
602
|
-
total += 1;
|
|
603
|
-
agentIds.push(agentDirent.name);
|
|
604
|
-
// Aged past the window, or dated implausibly far in the future
|
|
605
|
-
// (clock skew, or a tampered field this listing does not verify):
|
|
606
|
-
// both count as `stale` here, mirroring `verifyInflightRecord`'s
|
|
607
|
-
// own future-skew handling.
|
|
608
|
-
if (nowMs - approvedAtMs > effectiveStaleAfterMs || approvedAtMs - nowMs > INFLIGHT_FUTURE_SKEW_MS) {
|
|
609
|
-
stale += 1;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
if (agentIds.length > 0) {
|
|
613
|
-
sessions.push({ sessionId: sessionDirent.name, agentIds });
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
return { total, stale, sessions, skipped };
|
|
617
|
-
}
|
|
618
|
-
//# sourceMappingURL=inflight-records.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inflight-records.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/inflight-records.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,yEAAyE;AACzE,4DAA4D;AAC5D,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,iEAAiE;AACjE,qEAAqE;AACrE,sEAAsE;AACtE,gEAAgE;AAChE,8DAA8D;AAC9D,+DAA+D;AAC/D,oEAAoE;AACpE,qBAAqB;AACrB,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,qEAAqE;AACrE,kEAAkE;AAClE,kEAAkE;AAClE,oEAAoE;AACpE,sEAAsE;AACtE,uEAAuE;AACvE,oEAAoE;AACpE,oBAAoB;AACpB,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,EAAE;A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AC;gBAC/D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YACD,KAAK,IAAI,CAAC,CAAC;YACX,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAChC,+DAA+D;YAC/D,kEAAkE;YAClE,iEAAiE;YACjE,4BAA4B;YAC5B,IAAI,KAAK,GAAG,YAAY,GAAG,qBAAqB,IAAI,YAAY,GAAG,KAAK,GAAG,uBAAuB,EAAE,CAAC;gBACnG,KAAK,IAAI,CAAC,CAAC;YACb,CAAC;QACH,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type LedgerEntry } from "../../../policies/index.js";
|
|
2
|
-
export declare const APPROVED_LEDGER_TAG_PREFIX = "understanding-approved:";
|
|
3
|
-
/** Build the per-session ledger tag the pack searches for. */
|
|
4
|
-
export declare function approvedLedgerTagFor(sessionId: string): string;
|
|
5
|
-
/**
|
|
6
|
-
* Phase 6 #6 — substring-pollution defence shared by every PreToolUse
|
|
7
|
-
* blocker (Claude Code + Codex). Drops policy_decision rows so a
|
|
8
|
-
* `understanding-approved:<sess>` substring inside an audit row's
|
|
9
|
-
* JSON-encoded `reason` cannot accidentally satisfy the gate.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isPolicyDecisionRow(e: LedgerEntry): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Match a ledger fetch against the per-session approval tag. Kept for
|
|
14
|
-
* the audit / forensics path only: a ledger entry tagged
|
|
15
|
-
* `understanding-approved:<sid>` is no longer a sufficient signal to
|
|
16
|
-
* unblock the gate (agent-tasks/88ca4bb3: the agent has the same MCP
|
|
17
|
-
* surface and could self-write the row). Use `checkApprovalMarker`
|
|
18
|
-
* for the gate decision; this helper now serves `harness audit` /
|
|
19
|
-
* `harness explain --trace` style read paths that surface the
|
|
20
|
-
* historic ledger trail without granting approval power.
|
|
21
|
-
*/
|
|
22
|
-
export declare function matchLedgerEntries(entries: LedgerEntry[], sessionId: string): {
|
|
23
|
-
matched: boolean;
|
|
24
|
-
detail: string;
|
|
25
|
-
};
|