@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,311 +0,0 @@
|
|
|
1
|
-
// Phase 7 #3 — Risk Classifier.
|
|
2
|
-
//
|
|
3
|
-
// Assigns an Action Envelope a risk profile by regex-matching the
|
|
4
|
-
// manifest's `risk.classifiers[]` against the action. The first Risk
|
|
5
|
-
// Gate stage that reads the `risk:` schema vocabulary shipped in
|
|
6
|
-
// Phase 7 #1.
|
|
7
|
-
//
|
|
8
|
-
// STATUS: consumed by `harness policy intercept` (Phase 7 #5) and by the
|
|
9
|
-
// `harness test-risk` debug verb (Phase 7 #3). See docs/risk-gate.md and
|
|
10
|
-
// docs/ROADMAP.md.
|
|
11
|
-
//
|
|
12
|
-
// "Unknown is not safe": an envelope no pattern matches yields a
|
|
13
|
-
// profile with `classified: false` and `severity: null`, deliberately
|
|
14
|
-
// NOT a low/zero-risk profile. The Phase 7 #5 policy evaluator must
|
|
15
|
-
// treat an unclassified action as risk-bearing rather than allow it by
|
|
16
|
-
// default; this module's job is only to report the unclassified state
|
|
17
|
-
// honestly.
|
|
18
|
-
//
|
|
19
|
-
// The built-in exceptions are floors, not overrides, and each composes
|
|
20
|
-
// under the same highest-severity-wins rule as an operator pattern:
|
|
21
|
-
// harness's own benign meta-commands (see BENIGN_HARNESS_COMMAND below),
|
|
22
|
-
// the read-only-command / kubectl / sed / curl-SHAPE `low` floors (the
|
|
23
|
-
// last added task fdaad781, decision D-026 -- see `isReadOnlyCurlCommand`
|
|
24
|
-
// in read-only-bash.ts for why it is a SHAPE floor, not the per-flag
|
|
25
|
-
// list decision D-013 removed), and (since task 2929c5b7) the
|
|
26
|
-
// DESTRUCTIVE floor (`destructive-shell-floor.ts`),
|
|
27
|
-
// which recognizes `dd of=`, `truncate -s`, `shred`, `mkfs`, `find
|
|
28
|
-
// -delete` and friends in the binary so an install that never adopts the
|
|
29
|
-
// new `dangerous-shell` template patterns still classifies them.
|
|
30
|
-
//
|
|
31
|
-
// Design source: lava-ice-logs/2026-04-30/harness-risk-gate-extension.md
|
|
32
|
-
// (design phase B).
|
|
33
|
-
import { RiskSeveritySchema } from "../schema/index.js";
|
|
34
|
-
import { expandToolNameAliases, extractShellCommand } from "./tool-name-aliases.js";
|
|
35
|
-
import { isReadOnlyBashCommand, isReadOnlyCurlCommand, isReadOnlyKubectlCommand, isReadOnlySedCommand, } from "./read-only-bash.js";
|
|
36
|
-
import { classifyDestructiveShellFloor } from "./destructive-shell-floor.js";
|
|
37
|
-
// Ordered severity scale: a value's index here is the comparison key
|
|
38
|
-
// for "highest matched severity wins". Sourced from the schema enum so
|
|
39
|
-
// a future reordering there flows through unchanged.
|
|
40
|
-
const SEVERITY_ORDER = RiskSeveritySchema.options;
|
|
41
|
-
// Categories that mean the action does not cleanly undo itself. When a
|
|
42
|
-
// matched pattern carries any of these the profile is `reversible:
|
|
43
|
-
// false`. `destructive` and `data_loss` are included alongside the
|
|
44
|
-
// explicit `irreversible_action`: a regex classifier cannot prove an
|
|
45
|
-
// action is safely undoable, and the Risk Gate exists to err toward
|
|
46
|
-
// caution. A genuinely destructive-but-reversible action simply should
|
|
47
|
-
// not be tagged `destructive` by its classifier author.
|
|
48
|
-
const IRREVERSIBLE_CATEGORIES = new Set(["irreversible_action", "data_loss", "destructive"]);
|
|
49
|
-
// Built-in benign-harness-command floor.
|
|
50
|
-
//
|
|
51
|
-
// harness's own read-only and gate-producer subcommands are benign: they
|
|
52
|
-
// read state, record evidence, or print diagnostics, and several
|
|
53
|
-
// (`harness preflight`, `harness session-start`) are REQUIRED by other
|
|
54
|
-
// harness gates (require-preflight-evidence et al). Leaving them
|
|
55
|
-
// unclassified lets the "unknown is not safe" fail-close treat them as
|
|
56
|
-
// risk-bearing, so a `when: { risk.severity_at_least: critical,
|
|
57
|
-
// environment.name: production }` policy HARD-DENIES `harness preflight`
|
|
58
|
-
// the moment a session resolves to production (a main / release branch)
|
|
59
|
-
// — deadlocking against the very gate that demands it. So we recognize
|
|
60
|
-
// these as a `low`-severity floor.
|
|
61
|
-
//
|
|
62
|
-
// Floor, not override: the contribution composes with operator
|
|
63
|
-
// classifiers under the same highest-severity-wins rule, so
|
|
64
|
-
// `harness preflight && rm -rf /var` still classifies `critical` (the
|
|
65
|
-
// dangerous-shell tail wins) and an operator pattern can only RAISE the
|
|
66
|
-
// severity, never sink below this floor. Mutating subcommands (`apply`,
|
|
67
|
-
// `init`, `add`, `adopt`, `remove`, `pack`, `uninstall`, `migrate-home`,
|
|
68
|
-
// `smoke`, `gate`, `pause`, `resume`) are deliberately excluded — they
|
|
69
|
-
// stay classifiable. Anchored at the command head, so `cd /x && harness
|
|
70
|
-
// preflight` does NOT match and stays unclassified (fail-safe = denied):
|
|
71
|
-
// a benign prefix must not launder a non-harness command.
|
|
72
|
-
const BENIGN_HARNESS_SUBCOMMANDS = [
|
|
73
|
-
"preflight",
|
|
74
|
-
"session-start",
|
|
75
|
-
"approve",
|
|
76
|
-
"doctor",
|
|
77
|
-
"validate",
|
|
78
|
-
"describe",
|
|
79
|
-
"list",
|
|
80
|
-
"diff",
|
|
81
|
-
"explain",
|
|
82
|
-
"explain-action",
|
|
83
|
-
"explain-policy",
|
|
84
|
-
"test-risk",
|
|
85
|
-
"resolve-env",
|
|
86
|
-
"audit",
|
|
87
|
-
"session-export",
|
|
88
|
-
"dry-run",
|
|
89
|
-
"export",
|
|
90
|
-
"help",
|
|
91
|
-
];
|
|
92
|
-
const BENIGN_HARNESS_COMMAND = new RegExp(`^\\s*harness\\s+(?:${BENIGN_HARNESS_SUBCOMMANDS.join("|")})\\b`);
|
|
93
|
-
// Hot-path ReDoS guard (Phase 7 #6). As of Phase 7 #5/#6 the classifier
|
|
94
|
-
// runs operator-authored regexes against tool input on EVERY PreToolUse
|
|
95
|
-
// call inside `harness policy intercept`. Catastrophic-backtracking cost
|
|
96
|
-
// scales with input length, so the match subject is capped before any
|
|
97
|
-
// pattern runs. This bounds the input-length-driven blow-up — the common
|
|
98
|
-
// failure mode for a tool call that pipes a large blob through Bash.
|
|
99
|
-
//
|
|
100
|
-
// It is a mitigation, not a complete fix: harness does NOT screen the
|
|
101
|
-
// classifier patterns themselves for catastrophic backtracking. A
|
|
102
|
-
// manifest is operator-trusted config — the same contract already stated
|
|
103
|
-
// for `environments.resolvers[].kube_context_patterns` in
|
|
104
|
-
// docs/risk-gate.md. A pathological *pattern* is a self-inflicted hazard.
|
|
105
|
-
//
|
|
106
|
-
// 16 KiB comfortably covers any real shell command or serialized tool
|
|
107
|
-
// input. A genuinely dangerous command longer than the cap still does
|
|
108
|
-
// not slip the gate: its head (where `rm -rf` / `terraform destroy` /
|
|
109
|
-
// `kubectl delete` live) is within the cap, and an action that ends up
|
|
110
|
-
// unclassified is treated as risk-bearing by the `when:` evaluator.
|
|
111
|
-
const MAX_SUBJECT_LENGTH = 16 * 1024;
|
|
112
|
-
/**
|
|
113
|
-
* The string a classifier's patterns are regex-matched against. For a
|
|
114
|
-
* shell-class tool (or any tool whose input carries a `command` / `cmd`
|
|
115
|
-
* field) it is that command. For other tools it is the serialized raw
|
|
116
|
-
* input — blunt, but it keeps non-shell classifiers usable in the MVP.
|
|
117
|
-
*
|
|
118
|
-
* The result is capped at `MAX_SUBJECT_LENGTH` (ReDoS guard, see above).
|
|
119
|
-
*/
|
|
120
|
-
function subjectFor(envelope) {
|
|
121
|
-
const subject = rawSubjectFor(envelope);
|
|
122
|
-
return subject.length > MAX_SUBJECT_LENGTH
|
|
123
|
-
? subject.slice(0, MAX_SUBJECT_LENGTH)
|
|
124
|
-
: subject;
|
|
125
|
-
}
|
|
126
|
-
function rawSubjectFor(envelope) {
|
|
127
|
-
const command = extractShellCommand({ raw_input: envelope.raw_input });
|
|
128
|
-
if (command !== null)
|
|
129
|
-
return command;
|
|
130
|
-
const raw = envelope.raw_input;
|
|
131
|
-
if (raw === null || raw === undefined)
|
|
132
|
-
return "";
|
|
133
|
-
if (typeof raw === "string")
|
|
134
|
-
return raw;
|
|
135
|
-
try {
|
|
136
|
-
return JSON.stringify(raw);
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
return "";
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/** A classifier applies when its `tool` is an alias of the envelope's tool. */
|
|
143
|
-
function classifierApplies(classifier, envelope) {
|
|
144
|
-
return expandToolNameAliases(envelope.tool).includes(classifier.tool);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Classify an Action Envelope against the manifest's risk classifiers.
|
|
148
|
-
*
|
|
149
|
-
* Pure: envelope + classifiers in, profile out, no I/O. Multiple
|
|
150
|
-
* matching patterns compose — highest severity wins, categories union,
|
|
151
|
-
* one `reasons` line per hit. An envelope no pattern matches yields the
|
|
152
|
-
* honest unclassified profile (`classified: false`, `severity: null`).
|
|
153
|
-
*/
|
|
154
|
-
export function classifyRisk(envelope, classifiers) {
|
|
155
|
-
const applicable = classifiers.filter((c) => classifierApplies(c, envelope));
|
|
156
|
-
const subject = subjectFor(envelope);
|
|
157
|
-
const categories = new Set();
|
|
158
|
-
const reasons = [];
|
|
159
|
-
let severityIdx = -1;
|
|
160
|
-
for (const classifier of applicable) {
|
|
161
|
-
for (const pat of classifier.patterns) {
|
|
162
|
-
let re;
|
|
163
|
-
try {
|
|
164
|
-
re = new RegExp(pat.pattern);
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
// The schema regex-validates patterns at parse time; this guard
|
|
168
|
-
// only covers a manifest that bypassed `harness validate`.
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
if (!re.test(subject))
|
|
172
|
-
continue;
|
|
173
|
-
for (const cat of pat.categories)
|
|
174
|
-
categories.add(cat);
|
|
175
|
-
const idx = SEVERITY_ORDER.indexOf(pat.severity);
|
|
176
|
-
if (idx > severityIdx)
|
|
177
|
-
severityIdx = idx;
|
|
178
|
-
reasons.push(`classifier "${classifier.name}" pattern /${pat.pattern}/ matched: ` +
|
|
179
|
-
`severity ${pat.severity}, categories [${pat.categories.join(", ")}]`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
// Built-in floors. Folded in AFTER the operator loop so they compose by
|
|
183
|
-
// the same highest-severity-wins rule: the benign ones only raise an
|
|
184
|
-
// otherwise-unclassified action up to `low`, and never sink an operator
|
|
185
|
-
// match (a dangerous tail in `harness preflight && rm -rf /var` keeps
|
|
186
|
-
// the higher severity, and a chained command is not read-only); the
|
|
187
|
-
// destructive one raises to `high`/`critical` and is evaluated first,
|
|
188
|
-
// so a recognized mutating head never also takes a benign floor. All
|
|
189
|
-
// of them are gated on a real shell command so a non-shell tool whose
|
|
190
|
-
// serialized input happens to look benign cannot match.
|
|
191
|
-
const shellCommand = extractShellCommand({ raw_input: envelope.raw_input });
|
|
192
|
-
if (shellCommand !== null) {
|
|
193
|
-
// Built-in DESTRUCTIVE floor (task 2929c5b7), evaluated before the
|
|
194
|
-
// benign floors below so a recognized mutating head keeps them from
|
|
195
|
-
// firing at all. It ships in the binary rather than only as a
|
|
196
|
-
// `dangerous-shell` template pattern because `harness init` writes a
|
|
197
|
-
// manifest once and never rewrites it: an install carrying the
|
|
198
|
-
// original four patterns would otherwise take `when-eval.ts`'s
|
|
199
|
-
// loosened `severity_at_least: critical` fallback on upgrade WITHOUT
|
|
200
|
-
// the compensating classification. See
|
|
201
|
-
// `destructive-shell-floor.ts`'s module header and docs/risk-gate.md.
|
|
202
|
-
//
|
|
203
|
-
// Same composition rule as every other floor: highest severity wins,
|
|
204
|
-
// categories union. An operator pattern can raise above it; nothing
|
|
205
|
-
// sinks below it.
|
|
206
|
-
//
|
|
207
|
-
// Pass the UNCAPPED shellCommand for the same reason the read-only
|
|
208
|
-
// floor does (see below): the floor's scan is linear-time, and a
|
|
209
|
-
// destructive tail past the 16 KiB `subject` cap must not be
|
|
210
|
-
// laundered by a long benign head.
|
|
211
|
-
for (const hit of classifyDestructiveShellFloor(shellCommand)) {
|
|
212
|
-
const idx = SEVERITY_ORDER.indexOf(hit.severity);
|
|
213
|
-
if (idx > severityIdx)
|
|
214
|
-
severityIdx = idx;
|
|
215
|
-
for (const cat of hit.categories)
|
|
216
|
-
categories.add(cat);
|
|
217
|
-
reasons.push(`${hit.reason} (severity ${hit.severity})`);
|
|
218
|
-
}
|
|
219
|
-
const lowIdx = SEVERITY_ORDER.indexOf("low");
|
|
220
|
-
if (lowIdx > severityIdx) {
|
|
221
|
-
if (BENIGN_HARNESS_COMMAND.test(subject)) {
|
|
222
|
-
// harness's own benign meta-commands (head-anchored; see
|
|
223
|
-
// BENIGN_HARNESS_COMMAND). Broader than the read-only floor: it
|
|
224
|
-
// also floors gate-PRODUCER commands like `harness preflight`
|
|
225
|
-
// and `harness approve`, which the understanding-gate read-only
|
|
226
|
-
// classifier deliberately excludes.
|
|
227
|
-
severityIdx = lowIdx;
|
|
228
|
-
reasons.push("built-in: benign harness meta-command recognized (severity low)");
|
|
229
|
-
}
|
|
230
|
-
else if (isReadOnlyBashCommand(shellCommand)) {
|
|
231
|
-
// Any provably read-only command (`git status`, `grep`, `cat`,
|
|
232
|
-
// ...). Without this floor, "unknown is not safe" treats it as
|
|
233
|
-
// risk-bearing and a prod-scoped `risk.severity_at_least` policy
|
|
234
|
-
// denies harmless reads on a main / release branch (the recurring
|
|
235
|
-
// release-cut false-positive). The shared classifier already
|
|
236
|
-
// rejects any chaining / redirection / substitution, so a metachar
|
|
237
|
-
// command can never reach this floor.
|
|
238
|
-
//
|
|
239
|
-
// Pass the UNCAPPED shellCommand, not the 16 KiB-capped `subject`:
|
|
240
|
-
// isReadOnlyBashCommand scans the whole string for write
|
|
241
|
-
// metacharacters, so a tail truncated by the cap (e.g. a hidden
|
|
242
|
-
// `; rm -rf /` past 16 KiB) must not be able to launder a write
|
|
243
|
-
// behind a read-only head. The classifier's checks are linear-time,
|
|
244
|
-
// so the uncapped scan carries no ReDoS risk.
|
|
245
|
-
severityIdx = lowIdx;
|
|
246
|
-
reasons.push("built-in: provably read-only command recognized (severity low)");
|
|
247
|
-
}
|
|
248
|
-
else if (isReadOnlyKubectlCommand(shellCommand)) {
|
|
249
|
-
// Kubectl read-verb floor (task da823721), narrower than the
|
|
250
|
-
// general read-only floor above and NOT folded into
|
|
251
|
-
// `isReadOnlyBashCommand` itself: it changes only the Risk
|
|
252
|
-
// Classifier's behavior. The understanding-gate PreToolUse
|
|
253
|
-
// blocker and the solution-acceptance write-guard both consume
|
|
254
|
-
// `isReadOnlyBashCommand` directly and keep treating every
|
|
255
|
-
// kubectl invocation as non-read-only, unchanged by this floor.
|
|
256
|
-
// See docs/risk-gate.md's kubectl read-only floor decision for
|
|
257
|
-
// the secrets exclusion and the full blast-radius reasoning.
|
|
258
|
-
severityIdx = lowIdx;
|
|
259
|
-
reasons.push("built-in: provably read-only kubectl verb recognized (severity low)");
|
|
260
|
-
}
|
|
261
|
-
else if (isReadOnlySedCommand(shellCommand)) {
|
|
262
|
-
// `sed` read-verb floor (task 2929c5b7). Same placement decision
|
|
263
|
-
// as the kubectl floor directly above and for the same measured
|
|
264
|
-
// reason: it is NOT folded into `isReadOnlyBashCommand`, because
|
|
265
|
-
// the understanding-gate PreToolUse blocker and the
|
|
266
|
-
// solution-acceptance write-guard consume that predicate
|
|
267
|
-
// directly and short-circuit on it, so a `sed` recognition there
|
|
268
|
-
// would let `sed 's/a/b/w <verdict-dir>/marker.json' f` past the
|
|
269
|
-
// write-guard. See `isReadOnlySedCommand`'s own docstring for
|
|
270
|
-
// the allowlist and the script scan (sed's `w` command, `s///w`
|
|
271
|
-
// flag, `-f SCRIPTFILE` and GNU `e` all forfeit).
|
|
272
|
-
severityIdx = lowIdx;
|
|
273
|
-
reasons.push("built-in: provably read-only sed invocation recognized (severity low)");
|
|
274
|
-
}
|
|
275
|
-
else if (isReadOnlyCurlCommand(shellCommand)) {
|
|
276
|
-
// curl read-only SHAPE floor (task fdaad781, decision D-026,
|
|
277
|
-
// round 2 hardening: mandatory `-q`, dropped `-L`/`-k`),
|
|
278
|
-
// superseding D-013's two leaked flag lists. See
|
|
279
|
-
// `isReadOnlyCurlCommand`'s docstring in `read-only-bash.ts`
|
|
280
|
-
// and docs/risk-gate.md's "curl read-only SHAPE floor" section
|
|
281
|
-
// for the grammar, the residuals, and the operator escape hatch.
|
|
282
|
-
severityIdx = lowIdx;
|
|
283
|
-
reasons.push("built-in: provably read-only curl invocation recognized (severity low)");
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (severityIdx === -1) {
|
|
288
|
-
return {
|
|
289
|
-
classified: false,
|
|
290
|
-
severity: null,
|
|
291
|
-
categories: [],
|
|
292
|
-
reversible: null,
|
|
293
|
-
confidence: "low",
|
|
294
|
-
reasons: [
|
|
295
|
-
applicable.length === 0
|
|
296
|
-
? `no risk classifier is declared for tool "${envelope.tool}"`
|
|
297
|
-
: `no classifier pattern matched the action for tool "${envelope.tool}"`,
|
|
298
|
-
],
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
const sortedCategories = [...categories].sort();
|
|
302
|
-
return {
|
|
303
|
-
classified: true,
|
|
304
|
-
severity: SEVERITY_ORDER[severityIdx],
|
|
305
|
-
categories: sortedCategories,
|
|
306
|
-
reversible: !sortedCategories.some((c) => IRREVERSIBLE_CATEGORIES.has(c)),
|
|
307
|
-
confidence: "high",
|
|
308
|
-
reasons,
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
//# sourceMappingURL=risk-classifier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"risk-classifier.js","sourceRoot":"","sources":["../../src/runtime/risk-classifier.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,EAAE;AACF,kEAAkE;AAClE,qEAAqE;AACrE,iEAAiE;AACjE,cAAc;AACd,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,mBAAmB;AACnB,EAAE;AACF,iEAAiE;AACjE,sEAAsE;AACtE,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,YAAY;AACZ,EAAE;AACF,uEAAuE;AACvE,oEAAoE;AACpE,yEAAyE;AACzE,uEAAuE;AACvE,0EAA0E;AAC1E,qEAAqE;AACrE,8DAA8D;AAC9D,oDAAoD;AACpD,mEAAmE;AACnE,yEAAyE;AACzE,iEAAiE;AACjE,EAAE;AACF,yEAAyE;AACzE,oBAAoB;AAOpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE7E,qEAAqE;AACrE,uEAAuE;AACvE,qDAAqD;AACrD,MAAM,cAAc,GAA4B,kBAAkB,CAAC,OAAO,CAAC;AAE3E,uEAAuE;AACvE,mEAAmE;AACnE,mEAAmE;AACnE,qEAAqE;AACrE,oEAAoE;AACpE,uEAAuE;AACvE,wDAAwD;AACxD,MAAM,uBAAuB,GAA8B,IAAI,GAAG,CAChE,CAAC,qBAAqB,EAAE,WAAW,EAAE,aAAa,CAAC,CACpD,CAAC;AAEF,yCAAyC;AACzC,EAAE;AACF,yEAAyE;AACzE,iEAAiE;AACjE,uEAAuE;AACvE,iEAAiE;AACjE,uEAAuE;AACvE,gEAAgE;AAChE,yEAAyE;AACzE,wEAAwE;AACxE,uEAAuE;AAC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G,CAAC,CAAC,CAAC,CAAC;QACzE,UAAU,EAAE,MAAM;QAClB,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve the active grounding session id (WRITE path).
|
|
3
|
-
*
|
|
4
|
-
* Empty strings are treated as "not provided" — both for the explicit
|
|
5
|
-
* argument and for the env var, since `--session ''` from a forgetful
|
|
6
|
-
* shell expansion or `CLAUDE_SESSION_ID=` from a stale exec env should
|
|
7
|
-
* fall through to the next tier rather than be honoured as a literal
|
|
8
|
-
* empty session.
|
|
9
|
-
*/
|
|
10
|
-
export declare function resolveSessionId(explicit?: string): string;
|
|
11
|
-
export interface DiscoverSessionOptions {
|
|
12
|
-
/** Override the Claude Code projects root (tests). */
|
|
13
|
-
projectsRoot?: string;
|
|
14
|
-
/** Override `$HOME` used to derive the projects root (tests). */
|
|
15
|
-
homeDir?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Discover the current Claude Code session id from the most recently
|
|
19
|
-
* modified transcript JSONL under `~/.claude/projects/<project>/`.
|
|
20
|
-
*
|
|
21
|
-
* Claude Code appends to the active session's transcript live, so the
|
|
22
|
-
* newest-mtime `<uuid>.jsonl` across all project dirs is the running
|
|
23
|
-
* session. Returns `null` when the projects root is absent or holds no
|
|
24
|
-
* transcript files — callers fall through to their own default.
|
|
25
|
-
*/
|
|
26
|
-
export declare function discoverNewestSessionId(opts?: DiscoverSessionOptions): string | null;
|
|
27
|
-
export interface ResolveReadSessionOptions extends DiscoverSessionOptions {
|
|
28
|
-
/**
|
|
29
|
-
* Test seam — override the transcript-discovery tier wholesale. The
|
|
30
|
-
* default scans the real `~/.claude/projects` via
|
|
31
|
-
* `discoverNewestSessionId`.
|
|
32
|
-
*/
|
|
33
|
-
discover?: (opts: DiscoverSessionOptions) => string | null;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Resolve the session id for the READ path (`audit`,
|
|
37
|
-
* `explain --trace/--last`).
|
|
38
|
-
*
|
|
39
|
-
* Precedence:
|
|
40
|
-
* 1. explicit value (the `--session` flag)
|
|
41
|
-
* 2. `$CLAUDE_CODE_SESSION_ID` env (the var Claude Code actually exports)
|
|
42
|
-
* 3. `$CLAUDE_SESSION_ID` env (legacy fallback)
|
|
43
|
-
* 4. newest Claude Code transcript (the live session)
|
|
44
|
-
* 5. literal `"default"`
|
|
45
|
-
*
|
|
46
|
-
* The WRITE path keeps `resolveSessionId`: it always has
|
|
47
|
-
* `event.session_id`, so it never reaches the discovery tier, and a
|
|
48
|
-
* per-hook-event filesystem scan would be wasteful.
|
|
49
|
-
*/
|
|
50
|
-
export declare function resolveReadSessionId(explicit?: string, opts?: ResolveReadSessionOptions): string;
|
|
51
|
-
/** Session-id source for the `harness approve` verbs. */
|
|
52
|
-
export type ApprovalSessionSource = "flag" | "env-claude-code" | "env-claude" | "env-codex" | "pending-approval" | "newest-report";
|
|
53
|
-
export interface ResolveApprovalSessionIdOptions {
|
|
54
|
-
/** Explicit --session flag value. Empty string is treated as absent. */
|
|
55
|
-
session?: string;
|
|
56
|
-
/** Path to the harness.generated/ directory; used to read .pending-approval. */
|
|
57
|
-
generatedDir: string;
|
|
58
|
-
/**
|
|
59
|
-
* Optional 6th-tier callback. When provided and reached, it is called
|
|
60
|
-
* once and should return the session id plus the file path of the
|
|
61
|
-
* freshest qualifying persisted report, or null when none qualifies.
|
|
62
|
-
* Only `approve understanding` supplies this; `approve risk` and
|
|
63
|
-
* `approve branch-protection` omit it (they produce no persisted reports).
|
|
64
|
-
*/
|
|
65
|
-
newestReportFallback?: () => {
|
|
66
|
-
sessionId: string;
|
|
67
|
-
filePath: string;
|
|
68
|
-
} | null;
|
|
69
|
-
/**
|
|
70
|
-
* Test seam: override the .pending-approval reader. Defaults to
|
|
71
|
-
* `readPendingApproval` from pending-approval.ts. Verb-level tests use
|
|
72
|
-
* real tmp directories and do not need this; unit tests for the resolver
|
|
73
|
-
* itself use it to avoid creating directories.
|
|
74
|
-
*/
|
|
75
|
-
readPending?: (dir: string) => string | null;
|
|
76
|
-
}
|
|
77
|
-
export interface ResolveApprovalSessionIdResult {
|
|
78
|
-
/**
|
|
79
|
-
* The resolved session id, or an empty string when no tier matched.
|
|
80
|
-
* Callers MUST check for the empty string and throw a verb-specific
|
|
81
|
-
* error. The empty-string path is intentional: it lets callers produce
|
|
82
|
-
* messages that name their own gate hook, approve subcommand, and
|
|
83
|
-
* recovery steps without the resolver needing to know about them.
|
|
84
|
-
*/
|
|
85
|
-
sessionId: string;
|
|
86
|
-
/**
|
|
87
|
-
* Where the session id came from. When `sessionId` is empty this field
|
|
88
|
-
* is meaningless (callers throw before returning it to the operator).
|
|
89
|
-
*/
|
|
90
|
-
sessionSource: ApprovalSessionSource;
|
|
91
|
-
/**
|
|
92
|
-
* Set only when `sessionSource === "newest-report"`. The absolute path
|
|
93
|
-
* of the persisted report whose `sessionId` field was adopted. Surfaced
|
|
94
|
-
* in the `approve understanding` CLI warning so the operator can verify
|
|
95
|
-
* the report belongs to their live session.
|
|
96
|
-
*/
|
|
97
|
-
newestReportPath?: string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Shared session-id resolver for the `harness approve` verbs.
|
|
101
|
-
*
|
|
102
|
-
* Precedence:
|
|
103
|
-
* 1. explicit --session flag
|
|
104
|
-
* 2. $CLAUDE_CODE_SESSION_ID (the var Claude Code exports into the agent shell)
|
|
105
|
-
* 3. $CLAUDE_SESSION_ID (legacy / docs name; kept for older operator recipes)
|
|
106
|
-
* 4. $CODEX_SESSION_ID (set inside a live Codex session)
|
|
107
|
-
* 5. .pending-approval staging file (written by the gate hook or preflight)
|
|
108
|
-
* 6. newestReportFallback() result -- only understanding.ts uses this tier
|
|
109
|
-
*
|
|
110
|
-
* Returns `{ sessionId: "" }` when no tier resolves. The caller is
|
|
111
|
-
* responsible for throwing a verb-specific HarnessExitError in that case.
|
|
112
|
-
*/
|
|
113
|
-
export declare function resolveApprovalSessionId(opts: ResolveApprovalSessionIdOptions): ResolveApprovalSessionIdResult;
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
// Phase 5 #2 — shared sessionId resolver.
|
|
2
|
-
//
|
|
3
|
-
// Three Phase 4 verbs (`audit`, `explain --trace`, `policy intercept`)
|
|
4
|
-
// previously defaulted to the literal string `"default"` when no
|
|
5
|
-
// session was given. Real Claude Code sessions are UUIDs that arrive
|
|
6
|
-
// via the hook event's `session_id`. When the user later runs
|
|
7
|
-
// `harness audit` or `harness explain --trace` without `--session`, the
|
|
8
|
-
// read path looked at `"default"` and silently returned an empty
|
|
9
|
-
// audit/trace even though the writes had landed correctly under the
|
|
10
|
-
// real UUID.
|
|
11
|
-
//
|
|
12
|
-
// `resolveSessionId` lifts the precedence chain into one place for the
|
|
13
|
-
// WRITE path (`policy intercept`), which always carries a concrete
|
|
14
|
-
// `event.session_id`:
|
|
15
|
-
// 1. explicit value (the runtime's `event.session_id`)
|
|
16
|
-
// 2. `$CLAUDE_CODE_SESSION_ID` env (the var Claude Code actually exports)
|
|
17
|
-
// 3. `$CLAUDE_SESSION_ID` env (legacy fallback)
|
|
18
|
-
// 4. literal `"default"`
|
|
19
|
-
//
|
|
20
|
-
// The READ path (`audit`, `explain --trace/--last`) needs more. The
|
|
21
|
-
// Phase 5 #2 fix assumed `$CLAUDE_SESSION_ID` is exported into the
|
|
22
|
-
// session's shell environment — it is not (Claude Code does not put it
|
|
23
|
-
// in the Bash tool env), so tier 2 is inert in practice and the readers
|
|
24
|
-
// still fell through to `"default"`. `resolveReadSessionId` adds a
|
|
25
|
-
// transcript-discovery tier: when no explicit id and no env, it reads
|
|
26
|
-
// the active session id off the newest Claude Code transcript JSONL.
|
|
27
|
-
// That is the programmatic form of the heuristic `harness approve`'s
|
|
28
|
-
// own help text recommends to humans.
|
|
29
|
-
//
|
|
30
|
-
// Both resolvers also accept `$CLAUDE_CODE_SESSION_ID` as a higher-priority
|
|
31
|
-
// env tier than the legacy `$CLAUDE_SESSION_ID`, mirroring the
|
|
32
|
-
// `harness approve` verbs (`src/cli/approve/{risk,understanding}.ts`).
|
|
33
|
-
import * as fs from "node:fs";
|
|
34
|
-
import * as os from "node:os";
|
|
35
|
-
import * as path from "node:path";
|
|
36
|
-
import { readPendingApproval } from "./pending-approval.js";
|
|
37
|
-
const FALLBACK = "default";
|
|
38
|
-
/**
|
|
39
|
-
* Resolve the active grounding session id (WRITE path).
|
|
40
|
-
*
|
|
41
|
-
* Empty strings are treated as "not provided" — both for the explicit
|
|
42
|
-
* argument and for the env var, since `--session ''` from a forgetful
|
|
43
|
-
* shell expansion or `CLAUDE_SESSION_ID=` from a stale exec env should
|
|
44
|
-
* fall through to the next tier rather than be honoured as a literal
|
|
45
|
-
* empty session.
|
|
46
|
-
*/
|
|
47
|
-
export function resolveSessionId(explicit) {
|
|
48
|
-
if (typeof explicit === "string" && explicit.length > 0)
|
|
49
|
-
return explicit;
|
|
50
|
-
const envCode = process.env.CLAUDE_CODE_SESSION_ID;
|
|
51
|
-
if (typeof envCode === "string" && envCode.length > 0)
|
|
52
|
-
return envCode;
|
|
53
|
-
const env = process.env.CLAUDE_SESSION_ID;
|
|
54
|
-
if (typeof env === "string" && env.length > 0)
|
|
55
|
-
return env;
|
|
56
|
-
return FALLBACK;
|
|
57
|
-
}
|
|
58
|
-
// Claude Code names each session's transcript `<uuid>.jsonl`. Anchored
|
|
59
|
-
// so sibling files (memory dirs, `.pending-approval`, etc.) are ignored.
|
|
60
|
-
const SESSION_TRANSCRIPT_RE = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i;
|
|
61
|
-
/**
|
|
62
|
-
* Discover the current Claude Code session id from the most recently
|
|
63
|
-
* modified transcript JSONL under `~/.claude/projects/<project>/`.
|
|
64
|
-
*
|
|
65
|
-
* Claude Code appends to the active session's transcript live, so the
|
|
66
|
-
* newest-mtime `<uuid>.jsonl` across all project dirs is the running
|
|
67
|
-
* session. Returns `null` when the projects root is absent or holds no
|
|
68
|
-
* transcript files — callers fall through to their own default.
|
|
69
|
-
*/
|
|
70
|
-
export function discoverNewestSessionId(opts = {}) {
|
|
71
|
-
const projectsRoot = opts.projectsRoot ??
|
|
72
|
-
path.join(opts.homeDir ?? os.homedir(), ".claude", "projects");
|
|
73
|
-
let projectDirs;
|
|
74
|
-
try {
|
|
75
|
-
projectDirs = fs.readdirSync(projectsRoot);
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
let newest = null;
|
|
81
|
-
for (const dir of projectDirs) {
|
|
82
|
-
const projectPath = path.join(projectsRoot, dir);
|
|
83
|
-
let files;
|
|
84
|
-
try {
|
|
85
|
-
files = fs.readdirSync(projectPath);
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
continue; // not a directory, or unreadable — skip
|
|
89
|
-
}
|
|
90
|
-
for (const file of files) {
|
|
91
|
-
const match = SESSION_TRANSCRIPT_RE.exec(file);
|
|
92
|
-
if (!match)
|
|
93
|
-
continue;
|
|
94
|
-
let mtimeMs;
|
|
95
|
-
try {
|
|
96
|
-
mtimeMs = fs.statSync(path.join(projectPath, file)).mtimeMs;
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (newest === null || mtimeMs > newest.mtimeMs) {
|
|
102
|
-
newest = { id: match[1], mtimeMs };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return newest === null ? null : newest.id;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Resolve the session id for the READ path (`audit`,
|
|
110
|
-
* `explain --trace/--last`).
|
|
111
|
-
*
|
|
112
|
-
* Precedence:
|
|
113
|
-
* 1. explicit value (the `--session` flag)
|
|
114
|
-
* 2. `$CLAUDE_CODE_SESSION_ID` env (the var Claude Code actually exports)
|
|
115
|
-
* 3. `$CLAUDE_SESSION_ID` env (legacy fallback)
|
|
116
|
-
* 4. newest Claude Code transcript (the live session)
|
|
117
|
-
* 5. literal `"default"`
|
|
118
|
-
*
|
|
119
|
-
* The WRITE path keeps `resolveSessionId`: it always has
|
|
120
|
-
* `event.session_id`, so it never reaches the discovery tier, and a
|
|
121
|
-
* per-hook-event filesystem scan would be wasteful.
|
|
122
|
-
*/
|
|
123
|
-
export function resolveReadSessionId(explicit, opts = {}) {
|
|
124
|
-
if (typeof explicit === "string" && explicit.length > 0)
|
|
125
|
-
return explicit;
|
|
126
|
-
const envCode = process.env.CLAUDE_CODE_SESSION_ID;
|
|
127
|
-
if (typeof envCode === "string" && envCode.length > 0)
|
|
128
|
-
return envCode;
|
|
129
|
-
const env = process.env.CLAUDE_SESSION_ID;
|
|
130
|
-
if (typeof env === "string" && env.length > 0)
|
|
131
|
-
return env;
|
|
132
|
-
const discover = opts.discover ?? discoverNewestSessionId;
|
|
133
|
-
const discovered = discover({
|
|
134
|
-
...(opts.projectsRoot !== undefined && { projectsRoot: opts.projectsRoot }),
|
|
135
|
-
...(opts.homeDir !== undefined && { homeDir: opts.homeDir }),
|
|
136
|
-
});
|
|
137
|
-
if (typeof discovered === "string" && discovered.length > 0)
|
|
138
|
-
return discovered;
|
|
139
|
-
return FALLBACK;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Shared session-id resolver for the `harness approve` verbs.
|
|
143
|
-
*
|
|
144
|
-
* Precedence:
|
|
145
|
-
* 1. explicit --session flag
|
|
146
|
-
* 2. $CLAUDE_CODE_SESSION_ID (the var Claude Code exports into the agent shell)
|
|
147
|
-
* 3. $CLAUDE_SESSION_ID (legacy / docs name; kept for older operator recipes)
|
|
148
|
-
* 4. $CODEX_SESSION_ID (set inside a live Codex session)
|
|
149
|
-
* 5. .pending-approval staging file (written by the gate hook or preflight)
|
|
150
|
-
* 6. newestReportFallback() result -- only understanding.ts uses this tier
|
|
151
|
-
*
|
|
152
|
-
* Returns `{ sessionId: "" }` when no tier resolves. The caller is
|
|
153
|
-
* responsible for throwing a verb-specific HarnessExitError in that case.
|
|
154
|
-
*/
|
|
155
|
-
export function resolveApprovalSessionId(opts) {
|
|
156
|
-
const readPending = opts.readPending ?? readPendingApproval;
|
|
157
|
-
if (typeof opts.session === "string" && opts.session.length > 0) {
|
|
158
|
-
return { sessionId: opts.session, sessionSource: "flag" };
|
|
159
|
-
}
|
|
160
|
-
if (typeof process.env.CLAUDE_CODE_SESSION_ID === "string" &&
|
|
161
|
-
process.env.CLAUDE_CODE_SESSION_ID.length > 0) {
|
|
162
|
-
return {
|
|
163
|
-
sessionId: process.env.CLAUDE_CODE_SESSION_ID,
|
|
164
|
-
sessionSource: "env-claude-code",
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
if (typeof process.env.CLAUDE_SESSION_ID === "string" &&
|
|
168
|
-
process.env.CLAUDE_SESSION_ID.length > 0) {
|
|
169
|
-
return { sessionId: process.env.CLAUDE_SESSION_ID, sessionSource: "env-claude" };
|
|
170
|
-
}
|
|
171
|
-
if (typeof process.env.CODEX_SESSION_ID === "string" &&
|
|
172
|
-
process.env.CODEX_SESSION_ID.length > 0) {
|
|
173
|
-
return { sessionId: process.env.CODEX_SESSION_ID, sessionSource: "env-codex" };
|
|
174
|
-
}
|
|
175
|
-
const staged = readPending(opts.generatedDir);
|
|
176
|
-
if (staged !== null) {
|
|
177
|
-
return { sessionId: staged, sessionSource: "pending-approval" };
|
|
178
|
-
}
|
|
179
|
-
if (opts.newestReportFallback !== undefined) {
|
|
180
|
-
const newest = opts.newestReportFallback();
|
|
181
|
-
if (newest !== null) {
|
|
182
|
-
return {
|
|
183
|
-
sessionId: newest.sessionId,
|
|
184
|
-
sessionSource: "newest-report",
|
|
185
|
-
newestReportPath: newest.filePath,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Nothing resolved. Callers check sessionId === "" and throw their own
|
|
190
|
-
// verb-specific error messages.
|
|
191
|
-
return { sessionId: "", sessionSource: "flag" };
|
|
192
|
-
}
|
|
193
|
-
//# sourceMappingURL=session-id.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-id.js","sourceRoot":"","sources":["../../src/runtime/session-id.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,uEAAuE;AACvE,iEAAiE;AACjE,qEAAqE;AACrE,8DAA8D;AAC9D,wEAAwE;AACxE,iEAAiE;AACjE,oEAAoE;AACpE,aAAa;AACb,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,sBAAsB;AACtB,yDAAyD;AACzD,4EAA4E;AAC5E,kDAAkD;AAClD,2BAA2B;AAC3B,EAAE;AACF,oEAAoE;AACpE,mEAAmE;AACnE,uEAAuE;AACvE,wEAAwE;AACxE,mEAAmE;AACnE,sEAAsE;AACtE,qEAAqE;AACrE,qEAAqE;AACrE,sCAAsC;AACtC,EAAE;AACF,4EAA4E;AAC5E,+DAA+D;AAC/D,uEAAuE;AAEvE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,QAAQ,GAAG,SAAS,CAAC;AAE3B;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACzE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IACnD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACtE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IA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