@lannguyensi/harness 0.27.0 → 0.28.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +17 -12
  3. package/dist/cli/apply/apply.js +12 -2
  4. package/dist/cli/apply/apply.js.map +1 -1
  5. package/dist/cli/doctor/format.js +32 -1
  6. package/dist/cli/doctor/format.js.map +1 -1
  7. package/dist/cli/doctor/index.d.ts +1 -1
  8. package/dist/cli/doctor/index.js +63 -0
  9. package/dist/cli/doctor/index.js.map +1 -1
  10. package/dist/cli/doctor/types.d.ts +56 -0
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/init/composer.js +1 -1
  13. package/dist/cli/init/composer.js.map +1 -1
  14. package/dist/cli/init/dependencies.js +10 -9
  15. package/dist/cli/init/dependencies.js.map +1 -1
  16. package/dist/cli/init/profiles.d.ts +2 -2
  17. package/dist/cli/init/profiles.js +2 -2
  18. package/dist/cli/init/templates.d.ts +1 -1
  19. package/dist/cli/init/templates.js +1 -1
  20. package/dist/cli/pack/hook-codex-pre-tool-use.js +6 -3
  21. package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
  22. package/dist/cli/pack/hook-pre-tool-use.js +27 -3
  23. package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
  24. package/dist/cli/pack/read-only-bash.d.ts +13 -0
  25. package/dist/cli/pack/read-only-bash.js +177 -0
  26. package/dist/cli/pack/read-only-bash.js.map +1 -0
  27. package/dist/cli/pack/understanding-report-schema-hint.d.ts +1 -1
  28. package/dist/cli/pack/understanding-report-schema-hint.js +7 -1
  29. package/dist/cli/pack/understanding-report-schema-hint.js.map +1 -1
  30. package/dist/cli/validate/checks.d.ts +1 -1
  31. package/dist/cli/validate/checks.js +31 -27
  32. package/dist/cli/validate/checks.js.map +1 -1
  33. package/dist/io/version-compare.d.ts +16 -5
  34. package/dist/io/version-compare.js +16 -5
  35. package/dist/io/version-compare.js.map +1 -1
  36. package/dist/policy-packs/builtin/branch-protection.d.ts +38 -0
  37. package/dist/policy-packs/builtin/branch-protection.js +17 -0
  38. package/dist/policy-packs/builtin/branch-protection.js.map +1 -1
  39. package/dist/policy-packs/builtin/understanding-before-execution.d.ts +147 -0
  40. package/dist/policy-packs/builtin/understanding-before-execution.js +72 -10
  41. package/dist/policy-packs/builtin/understanding-before-execution.js.map +1 -1
  42. package/dist/policy-packs/config-check.d.ts +31 -0
  43. package/dist/policy-packs/config-check.js +58 -0
  44. package/dist/policy-packs/config-check.js.map +1 -0
  45. package/dist/policy-packs/expand.js +5 -4
  46. package/dist/policy-packs/expand.js.map +1 -1
  47. package/dist/policy-packs/index.d.ts +4 -1
  48. package/dist/policy-packs/index.js +4 -1
  49. package/dist/policy-packs/index.js.map +1 -1
  50. package/dist/policy-packs/registry.d.ts +20 -0
  51. package/dist/policy-packs/registry.js +39 -2
  52. package/dist/policy-packs/registry.js.map +1 -1
  53. package/dist/policy-packs/source-check.d.ts +28 -0
  54. package/dist/policy-packs/source-check.js +49 -0
  55. package/dist/policy-packs/source-check.js.map +1 -0
  56. package/dist/policy-packs/version-check.d.ts +37 -0
  57. package/dist/policy-packs/version-check.js +89 -0
  58. package/dist/policy-packs/version-check.js.map +1 -0
  59. package/dist/probes/memory.d.ts +1 -1
  60. package/dist/schema/hooks.js +6 -1
  61. package/dist/schema/hooks.js.map +1 -1
  62. package/dist/schema/index.d.ts +9 -0
  63. package/dist/schema/memory.js +6 -1
  64. package/dist/schema/memory.js.map +1 -1
  65. package/dist/schema/policy-packs.d.ts +8 -0
  66. package/dist/schema/policy-packs.js +17 -0
  67. package/dist/schema/policy-packs.js.map +1 -1
  68. package/dist/schema/tools.js +11 -2
  69. package/dist/schema/tools.js.map +1 -1
  70. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  export declare const MINIMAL_TEMPLATE = "# ~/.harness/harness.yaml (legacy: ~/.claude/harness.yaml)\n#\n# Bootstrapped by `harness init --template minimal`.\n#\n# This is the empty-but-valid manifest. Run `harness validate` to confirm it\n# parses, then add entries under the five top-level keys:\n#\n# grounding: evidence-ledger + claim-gate config (see docs/ARCHITECTURE.md \u00A72)\n# tools: mcp / cli / skills / builtin inventory (\u00A73)\n# memory: directories, retention, scopes (\u00A74)\n# hooks: event-bound shell commands (\u00A75)\n# policies: named rules that bind hooks to triggers (\u00A76)\n#\n# Phase 2 verbs to add entries safely: `harness add mcp <name> ...`,\n# `harness add cli`, `harness add hook`, `harness add skill`.\n# Per-machine overrides live at ~/.harness/machines/<discriminator>.harness.overrides.yaml\n# (ARCHITECTURE.md \u00A78) for paths that vary per host.\n#\n# Docs: https://github.com/LanNguyenSi/harness\n\nversion: 1\n";
2
- export declare const FULL_TEMPLATE = "# ~/.harness/harness.yaml (legacy: ~/.claude/harness.yaml)\n#\n# Bootstrapped by `harness init --template full`. The reference manifest:\n# every example policy from docs/examples/full-manifest.yaml wired through\n# the generic `harness policy intercept` engine, so no external shell\n# scripts under ~/.claude/hooks/ are required.\n#\n# Canonical source for the policy + policy_packs sections is\n# docs/examples/full-manifest.yaml. A parity vitest\n# (tests/cli/init-full-template-parity.test.ts) fails the build if the\n# two diverge on policy names or load-bearing fields.\n#\n# What you still need on PATH (the wizard offers to `npm i -g` these on\n# init): agent-tasks-mcp-bridge, grounding-mcp, memory-router-*,\n# understanding-gate-claude-*.\n\nversion: 1\n\ngrounding:\n session:\n auto_start: true\n id_format: \"gs-{repo}-{rand:8}\"\n evidence_ledger:\n path: ~/.evidence-ledger/ledger.db\n retention_days: 90\n policies_source: ~/.claude/harness.d/policies/claim-gate.yaml\n\ntools:\n mcp:\n # codebase-oracle (the Pandora RAG MCP server) is intentionally NOT\n # in the Full default. It is published as\n # `@lannguyensi/codebase-oracle` and works fine standalone, but it\n # is an opinionated workflow add-on (multi-repo semantic search)\n # rather than infrastructure harness itself assumes. Operators who\n # want it wire it explicitly:\n # npm i -g @lannguyensi/codebase-oracle\n # harness add mcp codebase-oracle --command codebase-oracle,mcp\n # Set ORACLE_SCAN_ROOT (absolute path; tilde is not expanded by the\n # MCP env block) and OPENAI_API_KEY (or switch providers via\n # ORACLE_LLM_PROVIDER) before the first call.\n - name: agent-tasks\n # Zero-setup entry: `@agent-tasks/mcp-bridge` exposes the\n # `agent-tasks-mcp-bridge` binary on PATH. The bridge owns token\n # storage and defaults to the hosted backend; override with\n # `AGENT_TASKS_BASE_URL` / `AGENT_TASKS_TOKEN` for self-hosted.\n # `min_version` floor: 0.6.0 added the `--version` short-circuit\n # the doctor probe needs (PR agent-tasks/240, release-cut PR 241).\n # Bump the floor whenever a fix you depend on lands; loose floors\n # are fine, the point is the drift signal not pinning a specific cut.\n command: [agent-tasks-mcp-bridge]\n min_version: \"0.6.0\"\n health:\n verb: projects_list\n timeout_ms: 5000\n enabled: true\n - name: grounding-mcp\n # Published bin from `@lannguyensi/grounding-mcp`. No env is set:\n # the bundled default resolves to `~/.evidence-ledger/ledger.db`\n # via os.homedir() at startup. Passing a literal tilde in env\n # bypasses shell expansion and creates rogue cwd-relative DB files\n # (see agent-tasks/42d224a6 incident). `min_version` floor: 0.2.0\n # added the `--version` short-circuit the doctor probe needs (PR\n # agent-grounding/76, release-cut PR 77).\n command: [grounding-mcp]\n min_version: \"0.2.0\"\n health:\n verb: ledger_status\n timeout_ms: 5000\n enabled: true\n\n cli:\n - name: gh\n binary: gh\n required: true\n\n skills:\n enabled:\n - simplify\n - init\n - review\n - security-review\n source_dirs:\n - ~/.claude/skills\n\n builtin:\n known: [Read, Edit, Write, Bash, Agent, Skill, TaskCreate, Glob, Grep]\n\nmemory:\n directories:\n - path: ~/.claude/projects/{project}/memory\n scope: project\n router:\n # Published bin from `@lannguyensi/memory-router`.\n # `min_version` floor: 0.3.0 added the `--version` short-circuit\n # the doctor probe needs (PR agent-memory/40, release-cut PR 41).\n command: [memory-router-user-prompt-submit]\n min_version: \"0.3.0\"\n enabled: true\n retention:\n staleness_days: 180\n broken_refs: warn\n scopes:\n default: project\n allowed: [project, user]\n\n# All PreToolUse hooks share the generic `harness policy intercept` CLI\n# entrypoint. The engine reads the tool event on stdin, evaluates whichever\n# policy below has a matching trigger (`match` + optional `bash_match`),\n# and emits Claude Code's deny envelope when the required ledger tag is\n# absent. No external shell scripts are required.\n#\n# The `git-preflight` SessionStart hook is the producer side of the\n# `preflight-before-*` policies: `harness session-start preflight` runs\n# agent-preflight against the session cwd and, on a ready:true result,\n# records `preflight:${REPO}` to the evidence ledger. It needs the\n# `preflight` binary on PATH (`npm i -g @lannguyensi/agent-preflight`); when\n# that is absent the hook logs to stderr and exits 0, so the session is\n# never broken \u2014 the preflight gates just stay closed until a tag is\n# produced some other way.\nhooks:\n - name: git-preflight\n event: SessionStart\n command: harness session-start preflight\n blocking: false\n # 70s budget gives the wrapped preflight (default 60s) headroom plus\n # ledger-write time. Was 30s through v0.17.4, but a healthy preflight\n # on a medium-size repo takes ~28s and the old 25s wrapper ceiling\n # blew through it. Bumped together with DEFAULT_PREFLIGHT_TIMEOUT_MS\n # (agent-tasks/7265599e).\n budget_ms: 70000\n # Floor at agent-preflight 0.2.0, the release that makes secret\n # detection git-aware and diff-scoped: a gitignored+untracked .env,\n # a .md doc, a non-git dir, or a secret in a tracked file the branch\n # never touched is a non-blocking warn, not a hard fail. Pre-0.2.0\n # installs hard-fail preflight on the normal correct state (a\n # gitignored .env holding real credentials), so this SessionStart\n # producer never writes a preflight: tag and the preflight-before-*\n # policies stay closed forever on any repo with a local .env. (0.1.1\n # had already fixed the wrapper-script \"tool not installed\" false\n # positive.) version_command points at the source-of-truth preflight\n # binary, not at the `harness session-start preflight` wrapper.\n min_version: \"0.2.0\"\n version_command: [\"preflight\", \"--version\"]\n\n - name: require-review-evidence\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_merge\"\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n # Tool-agnostic parallel of require-review-evidence for operators on the\n # gh-cli workflow (`gh pr merge`) instead of agent-tasks MCP. Same generic\n # `harness policy intercept` entrypoint; the matching review-before-merge-bash\n # policy below picks up the trigger. A PolicyTrigger can only AND-match one\n # surface (MCP tool-name OR Bash command), so two parallel definitions are\n # the minimum-scope way to cover both PR surfaces without bumping the schema.\n - name: require-review-evidence-bash\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr merge\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n - name: require-dogfood-evidence\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*(npm publish\\b|git( -C \\S+)* tag v)'\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n - name: require-preflight-evidence\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* (status|log|diff|branch)\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 1000\n\n - name: require-review-subagent-evidence\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_create\"\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n # Bash-surface parallel of require-review-subagent-evidence for operators\n # who open PRs with `gh pr create` instead of agent-tasks MCP. The matching\n # review-subagent-before-pr-create-bash policy below tags by branch\n # (`review-subagent:${BRANCH}`) because no task UUID is in `gh pr create`\n # arguments; the working branch is the closest stable handle for \"the\n # PR-in-progress\" at this point in the cycle.\n - name: require-review-subagent-evidence-bash\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr create\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n - name: require-preflight-push-evidence\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* push\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 1000\n\n # risk-gate (Phase 7 #6): the Risk Gate enforcement hook. The\n # gate-prod-destructive policies below reference it. Same generic\n # `harness policy intercept` entrypoint as every other policy hook;\n # the interceptor builds the Action Envelope, classifies risk against\n # `risk.classifiers[]`, resolves the environment against\n # `environments.resolvers[]`, and evaluates the policies' `when:`.\n - name: risk-gate\n event: PreToolUse\n match: \"Bash\"\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\npolicies:\n - name: review-before-merge\n description: Block PR merges unless a ledger entry tagged review:<pr-number> exists for this session.\n trigger:\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_merge\"\n extract:\n PR_NUMBER: \"toolArgs.prNumber\"\n requires:\n ledger_tag: \"review:${PR_NUMBER}\"\n hook: require-review-evidence\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review:${PR_NUMBER} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: Spawn a review subagent against the PR diff, capture its verdict, then persist a ledger entry tagged with the PR number. The content should be self-contained enough for an auditor to read without re-opening the chat.\n ux:\n cannot: \"You cannot merge PR #${PR_NUMBER} yet.\"\n required:\n - \"a recorded review of PR #${PR_NUMBER}\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review:${PR_NUMBER} \u2014 <verdict + key findings + nits>\" }'\n\n # Bash-surface parallel of review-before-merge for operators on the gh-cli\n # workflow. Two scope notes:\n # 1. Tag shape: `review:${BRANCH}` instead of `review:${PR_NUMBER}`. The\n # `gh pr merge` invocation can target the PR by number, by URL, or by\n # the current branch (default), and PR_NUMBER is not extractable from\n # `tool_input.command` with today's JSONPath-only extract DSL. BRANCH\n # is the stable identifier the producer can record at review time.\n # 2. This sits ALONGSIDE review-before-merge \u2014 not as a replacement. An\n # operator using both surfaces (e.g. agent-tasks MCP for most repos\n # + gh-cli for a quick hotfix) will have both gates active, each with\n # its own tag shape, which is semantically honest.\n - name: review-before-merge-bash\n description: Block `gh pr merge` unless a ledger entry tagged review:<branch> exists for this session.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr merge\\b'\n requires:\n ledger_tag: \"review:${BRANCH}\"\n hook: require-review-evidence-bash\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review:${BRANCH} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: Spawn a review subagent against the branch diff, capture its verdict, then persist a ledger entry tagged with the branch name. Mirror of the review-before-merge producer for the gh-cli surface.\n ux:\n cannot: \"You cannot merge the PR for branch ${BRANCH} via `gh pr merge` yet.\"\n required:\n - \"a recorded review of the PR for branch ${BRANCH}\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review:${BRANCH} \u2014 <verdict + key findings + nits>\" }'\n\n - name: dogfood-before-release\n description: Block npm publish / git tag v* without a recent dogfood ledger entry.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*(npm publish\\b|git( -C \\S+)* tag v)'\n requires:\n ledger_tag: \"dogfood:${SESSION_ID}\"\n within: 24h\n hook: require-dogfood-evidence\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"dogfood:${SESSION_ID} \u2014 <end-to-end smoke summary against the live system>\", source:\"manual smoke test\"}'\n description: Before tagging or publishing, run the release path end-to-end against the live system (not just unit tests) and persist the result as a session-tagged ledger entry. Document what you exercised (install, CLI happy path, MCP handshake, etc.) so a future auditor can tell whether the smoke covered the change.\n ux:\n cannot: \"You cannot publish a release yet.\"\n required:\n - \"an end-to-end dogfood run in this session\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"dogfood:${SESSION_ID} \u2014 <end-to-end smoke summary>\" }'\n\n - name: two-reviewers-required\n description: At least two distinct reviewer ledger entries must exist for the PR.\n trigger:\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_merge\"\n extract:\n PR_NUMBER: \"toolArgs.prNumber\"\n requires:\n ledger_tag: \"review:${PR_NUMBER}\"\n count:\n min: 2\n hook: require-review-evidence\n enforcement: warn\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review:${PR_NUMBER} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review (reviewer 2)\"}'\n description: Same shape as review-before-merge but TWO DISTINCT reviewer entries must exist before the gate is satisfied (count.min 2). Distinguish reviewers by source so the count is honest. Warn-level enforcement, so the agent CAN merge with one reviewer but should consider spawning a second for load-bearing changes.\n\n - name: preflight-before-investigation\n description: Block investigative git reads (status/log/diff/branch) when agent-preflight has not run recently with ready:true for the current repo.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* (status|log|diff|branch)\\b'\n requires:\n ledger_tag: \"preflight:${REPO}\"\n within: 1h\n hook: require-preflight-evidence\n enforcement: block\n producers:\n - kind: bash\n command: harness session-start preflight\n description: Runs agent-preflight against the current cwd; on ready:true, records preflight:${REPO} to the ledger. Standard producer.\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"preflight:${REPO}\", source:\"manual\"}'\n description: Direct ledger write. Use when the Bash hook is locked down (e.g. understanding-gate active) or when the standard producer is unavailable.\n ux:\n cannot: \"You cannot investigate this repository yet.\"\n required:\n - \"verified repository preflight\"\n run:\n - \"harness preflight\"\n\n - name: review-subagent-before-pr-create\n description: Block agent-tasks PR creation unless a review-subagent ledger entry tagged for this task already exists. Forces the rigorous review BEFORE the PR opens, not after.\n trigger:\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_create\"\n extract:\n TASK_ID: \"toolArgs.taskId\"\n requires:\n ledger_tag: \"review-subagent:${TASK_ID}\"\n hook: require-review-subagent-evidence\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review-subagent:${TASK_ID} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: After running a review subagent against the staged diff, persist its verdict + load-bearing findings as a ledger entry tagged with the task UUID. The content should be self-contained enough to audit later without re-reading the chat.\n ux:\n cannot: \"You cannot open a pull request for task ${TASK_ID} yet.\"\n required:\n - \"a completed review-subagent pass on this task\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review-subagent:${TASK_ID} \u2014 <verdict + key findings + nits>\" }'\n\n # Bash-surface parallel of review-subagent-before-pr-create. Tag shape is\n # `review-subagent:${BRANCH}` because TASK_ID is an agent-tasks-only\n # concept; for the gh-cli workflow the working branch is the closest stable\n # handle for \"the PR-in-progress\" at this point. Same rationale as\n # review-before-merge-bash: sits alongside the MCP variant, not as a\n # replacement.\n - name: review-subagent-before-pr-create-bash\n description: Block `gh pr create` unless a review-subagent ledger entry tagged review-subagent:<branch> exists for this session. Forces the rigorous review BEFORE the PR opens.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr create\\b'\n requires:\n ledger_tag: \"review-subagent:${BRANCH}\"\n hook: require-review-subagent-evidence-bash\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review-subagent:${BRANCH} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: After running a review subagent against the staged diff for the working branch, persist its verdict + load-bearing findings as a ledger entry tagged with the branch name. Mirror of the review-subagent-before-pr-create producer for the gh-cli surface.\n ux:\n cannot: \"You cannot open a pull request for branch ${BRANCH} via `gh pr create` yet.\"\n required:\n - \"a completed review-subagent pass on branch ${BRANCH}\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review-subagent:${BRANCH} \u2014 <verdict + key findings + nits>\" }'\n\n - name: preflight-before-push\n description: Block git push unless a fresh preflight ledger entry exists for the current branch. Catches the stale-checkout class of incident at the last reversible step.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* push\\b'\n requires:\n ledger_tag: \"preflight:${BRANCH}\"\n within: 10m\n # at_head:true lets a preflight at the current HEAD satisfy the\n # gate at any age (the standard producer writes head:<sha> into\n # the tag content). The 10m window remains the freshness ceiling\n # for the head-mismatch case (operator switched branch, preflight\n # predates HEAD shift, runtime couldn't resolve a sha).\n at_head: true\n hook: require-preflight-push-evidence\n enforcement: block\n producers:\n - kind: bash\n command: harness session-start preflight\n description: Runs agent-preflight against the current cwd; on ready:true, records preflight:${BRANCH} ready:true confidence:<n> head:<sha> to the ledger. Standard producer.\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"preflight:${BRANCH} head:<full-sha> \u2014 <summary of what is on the branch + smoke results>\", source:\"manual\"}'\n description: Direct ledger write. Include head:<full-sha> if you want the entry to count under at_head; the branch is the WIP review surface and the content should summarise what is staged + the smoke evidence so a reviewer can audit later without re-reading the chat.\n ux:\n cannot: \"You cannot push branch ${BRANCH} yet.\"\n required:\n - \"a preflight for ${BRANCH} at the current HEAD (any age) OR any preflight within the last 10 minutes. Re-run `harness preflight` if you committed since the last preflight AND it has been more than 10 minutes.\"\n run:\n - \"harness preflight\"\n\n # Phase 7 Risk Gate \u2014 the canonical built-in worked example. These two\n # policies, with the dangerous-shell classifier and production-signals\n # resolver below, are the Risk Gate's default stance: a destructive\n # shell action whose target environment resolves to production is\n # gated before the runtime fires it. Both fire ONLY when the\n # environment resolves to production (a main / release branch, a\n # prod-looking DATABASE_URL, or a prod kube context); on an ordinary\n # feature branch the environment is unknown and neither fires. Ordered\n # deny-first so a critical action (which also matches the high\n # threshold) gets the hard-deny envelope. See docs/risk-gate.md.\n - name: gate-prod-destructive\n description: Deny critical-severity destructive shell actions against a production target.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n when:\n risk.severity_at_least: critical\n environment.name: production\n requires:\n ledger_tag: \"risk-override:${SESSION_ID}\"\n hook: risk-gate\n enforcement: block\n ux:\n cannot: \"You cannot run this critical destructive action against production.\"\n required:\n - \"a deliberate operator override: a critical production mutation has no benign reading\"\n run:\n - \"Choose a non-destructive alternative, or run the command yourself outside the agent.\"\n - \"Operator override (deliberate): record a risk-override:${SESSION_ID} entry in the evidence ledger.\"\n - name: gate-prod-destructive-approval\n description: Require operator approval for high-severity destructive shell actions against a production target.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n when:\n risk.severity_at_least: high\n environment.name: production\n requires:\n ledger_tag: \"risk-approved:${SESSION_ID}\"\n hook: risk-gate\n enforcement: require_approval\n ux:\n cannot: \"You cannot run this destructive production action yet.\"\n required:\n - \"operator approval of this Risk Gate decision\"\n run:\n - \"harness approve risk\"\n\n# Full inherits the Solo/Team understanding-gate stack: the Stop hook\n# persists each Understanding Report and the PreToolUse pre-tool-use\n# blocker refuses Edit/Write/Bash until the report is approved. Drop\n# this block if you want the reference policies above without the\n# baseline gate.\npolicy_packs:\n - name: understanding-before-execution\n source: builtin\n enabled: true\n description: Force agents to expose their task interpretation and wait for explicit human approval before any write-capable tool fires.\n config:\n mode: grill_me\n # Producers (agent-tasks/25bced52): rendered into the gate's deny\n # envelope by the same engine as policy producers. Constraint at\n # this layer: at-least-one `ask`. Post-v0.14.0 the gate signal\n # is a filesystem marker and the mcp ledger_add path no longer\n # satisfies the gate; the canonical unblock surface is the\n # operator-approval prompt.\n producers:\n - kind: ask\n command: harness approve understanding\n description: \"Bare command, no pipes or chaining. The hook recognises it via isEscapeCommand and emits permissionDecision:ask; the operator's go on that prompt IS the gate approval. Golden path.\"\n - kind: bash\n command: harness approve understanding\n description: Same command from any un-hooked terminal (operator only, not reachable from inside the gated session). Writes the canonical marker at harness.generated/.approvals/${SESSION_ID}.\n # ux (agent-tasks/e48e3b45): replaces the legacy engine-vocabulary\n # deny envelope with the plain-language { cannot, required, run }\n # shape. Engine details (the BLOCK reason naming session id /\n # marker / report state) still land in stderr for operator audit;\n # the agent only sees this.\n ux:\n cannot: \"You cannot use write-capable tools yet.\"\n required:\n - \"an approved Understanding Report for this session\"\n run:\n - \"Write an Understanding Report covering: Current Understanding, Intended Outcome, Derived Todos, Acceptance Criteria, Assumptions, Open Questions, Out Of Scope, Risks, Verification Plan\"\n - \"Run `harness approve understanding` and approve the prompt\"\n # approval_lifecycle (agent-tasks/d8ee60ca + harness/f54e0ecb,\n # v0.18.0+): expire the approval marker on task-completion\n # boundaries so a multi-task session re-prompts for an\n # Understanding Report between tasks. Without this the legacy\n # \"one approval per session\" contract lets a stale interpretation\n # drive the next task's edits.\n #\n # Full ships both boundary kinds: the agent-tasks MCP verbs for\n # operators on that workflow, plus a Bash regex list for hybrid\n # operators who also use gh-cli for PR mechanics. `max_age` is\n # the safety net. Operators who prefer the legacy per-session\n # behaviour opt out with `approval_lifecycle: { mode: session }`.\n # Operators on other task systems override the matchers.\n approval_lifecycle:\n expire_on_tool_match:\n - mcp__agent-tasks__task_finish\n - mcp__agent-tasks__task_abandon\n - mcp__agent-tasks__pull_requests_merge\n - mcp__agent-tasks__tasks_transition\n expire_on_bash_match:\n - '^gh pr (merge|close)\\b'\n - '^git push origin (master|main)\\b'\n max_age: 4h\n\n # branch-protection (agent-tasks/2fdc5bbe, default-enabled since v0.17.2):\n # blocks Write/Edit (claude-code) or apply_patch (codex) on protected\n # branches (default: master, main, develop). Complements\n # preflight-before-push, which fires at the LAST reversible step;\n # branch-protection fires at the FIRST source mutation, catching the\n # \"forgot to branch off master\" pattern earlier in the cycle.\n #\n # Two satisfying signals: a fresh `branch:non-protected:<branch>` tag\n # from the SessionStart producer (`harness session-start branch-check`),\n # or a `branch-protection-ack:<reason>` override the operator writes\n # via mcp__agent-grounding__ledger_add for deliberate protected-branch\n # edits (version bumps, CI workflow patches, hotfixes).\n #\n # Fails closed (any load / parse / ledger error refuses). Disable by\n # setting `enabled: false` or removing this entry if your workflow\n # routinely edits master directly. Override the protected list via\n # `config.protected_branches`. Full reference:\n # docs/policy-packs/branch-protection.md.\n - name: branch-protection\n source: builtin\n enabled: true\n description: Block Write/Edit on protected branches (master, main, develop) at the first source mutation.\n config:\n # ux (agent-tasks/9806d4f8): replaces the legacy\n # \"branch-protection: refusing ...\" envelope with the\n # plain-language { cannot, required, run } shape. Engine details\n # (the BLOCK reason naming session id / freshness window) stay\n # on stderr for operator audit.\n ux:\n cannot: \"You cannot edit files on protected branch ${BRANCH} yet.\"\n required:\n - \"a checkout of a non-protected branch (current `${BRANCH}` is protected)\"\n run:\n - \"git checkout -b feat/<your-task>\"\n - \"harness session-start branch-check\"\n\n# Phase 7 Risk Gate vocabulary. The dangerous-shell classifier and\n# production-signals resolver feed the gate-prod-destructive policies\n# above: `harness policy intercept` builds the Action Envelope,\n# classifies the action against `risk.classifiers[]`, resolves the\n# target environment against `environments.resolvers[]`, and evaluates\n# each policy's `when:` clauses against the result. Full design and the\n# decision model: docs/risk-gate.md.\nrisk:\n classifiers:\n - name: dangerous-shell\n tool: Bash\n patterns:\n - pattern: 'rm\\s+-rf\\s+(/|/var|/data|/mnt|~)'\n categories: [destructive, data_loss]\n severity: critical\n - pattern: 'DROP\\s+TABLE|TRUNCATE\\s+TABLE|DELETE\\s+FROM'\n categories: [destructive, data_loss]\n severity: high\n - pattern: 'kubectl\\s+delete\\s+(namespace|deployment|statefulset|pvc)'\n categories: [destructive, infrastructure_change]\n severity: high\n - pattern: 'terraform\\s+destroy'\n categories: [destructive, infrastructure_change]\n severity: critical\n\nenvironments:\n resolvers:\n - name: production-signals\n environment: production\n signals:\n branch_patterns: [main, \"release/*\"]\n env_var_patterns:\n - var: DATABASE_URL\n patterns: [prod, production]\n kube_context_patterns: [\".*prod.*\"]\n kube_namespace_patterns: [prod, production]\n";
2
+ export declare const FULL_TEMPLATE = "# ~/.harness/harness.yaml (legacy: ~/.claude/harness.yaml)\n#\n# Bootstrapped by `harness init --template full`. The reference manifest:\n# every example policy from docs/examples/full-manifest.yaml wired through\n# the generic `harness policy intercept` engine, so no external shell\n# scripts under ~/.claude/hooks/ are required.\n#\n# Canonical source for the policy + policy_packs sections is\n# docs/examples/full-manifest.yaml. A parity vitest\n# (tests/cli/init-full-template-parity.test.ts) fails the build if the\n# two diverge on policy names or load-bearing fields.\n#\n# What you still need on PATH (the wizard offers to `npm i -g` these on\n# init): agent-tasks-mcp-bridge, grounding-mcp, memory-router-*,\n# understanding-gate-claude-*.\n\nversion: 1\n\ngrounding:\n session:\n auto_start: true\n id_format: \"gs-{repo}-{rand:8}\"\n evidence_ledger:\n path: ~/.evidence-ledger/ledger.db\n retention_days: 90\n policies_source: ~/.claude/harness.d/policies/claim-gate.yaml\n\ntools:\n mcp:\n # codebase-oracle (the Pandora RAG MCP server) is intentionally NOT\n # in the Full default. It is published as\n # `@lannguyensi/codebase-oracle` and works fine standalone, but it\n # is an opinionated workflow add-on (multi-repo semantic search)\n # rather than infrastructure harness itself assumes. Operators who\n # want it wire it explicitly:\n # npm i -g @lannguyensi/codebase-oracle\n # harness add mcp codebase-oracle --command codebase-oracle,mcp\n # Set ORACLE_SCAN_ROOT (absolute path; tilde is not expanded by the\n # MCP env block) and OPENAI_API_KEY (or switch providers via\n # ORACLE_LLM_PROVIDER) before the first call.\n - name: agent-tasks\n # Zero-setup entry: `@agent-tasks/mcp-bridge` exposes the\n # `agent-tasks-mcp-bridge` binary on PATH. The bridge owns token\n # storage and defaults to the hosted backend; override with\n # `AGENT_TASKS_BASE_URL` / `AGENT_TASKS_TOKEN` for self-hosted.\n # `min_version` floor: 0.6.0 added the `--version` short-circuit\n # the doctor probe needs (PR agent-tasks/240, release-cut PR 241).\n # Bump the floor whenever a fix you depend on lands; loose floors\n # are fine, the point is the drift signal not pinning a specific cut.\n command: [agent-tasks-mcp-bridge]\n min_version: \"0.6.0\"\n health:\n verb: projects_list\n timeout_ms: 5000\n enabled: true\n - name: grounding-mcp\n # Published bin from `@lannguyensi/grounding-mcp`. No env is set:\n # the bundled default resolves to `~/.evidence-ledger/ledger.db`\n # via os.homedir() at startup. Passing a literal tilde in env\n # bypasses shell expansion and creates rogue cwd-relative DB files\n # (see agent-tasks/42d224a6 incident). `min_version` floor: 0.2.0\n # added the `--version` short-circuit the doctor probe needs (PR\n # agent-grounding/76, release-cut PR 77).\n command: [grounding-mcp]\n min_version: \"0.2.0\"\n health:\n verb: ledger_status\n timeout_ms: 5000\n enabled: true\n\n cli:\n - name: gh\n binary: gh\n required: true\n\n skills:\n enabled:\n - simplify\n - init\n - review\n - security-review\n source_dirs:\n - ~/.claude/skills\n\n builtin:\n known: [Read, Edit, Write, Bash, Agent, Skill, TaskCreate, Glob, Grep]\n\nmemory:\n directories:\n - path: ~/.claude/projects/{project}/memory\n scope: project\n router:\n # Published bin from `@lannguyensi/memory-router`.\n # `min_version` floor: 0.3.0 added the `--version` short-circuit\n # the doctor probe needs (PR agent-memory/40, release-cut PR 41).\n command: [memory-router-user-prompt-submit]\n min_version: \"0.3.0\"\n enabled: true\n retention:\n staleness_days: 180\n broken_refs: warn\n scopes:\n default: project\n allowed: [project, user]\n\n# All PreToolUse hooks share the generic `harness policy intercept` CLI\n# entrypoint. The engine reads the tool event on stdin, evaluates whichever\n# policy below has a matching trigger (`match` + optional `bash_match`),\n# and emits Claude Code's deny envelope when the required ledger tag is\n# absent. No external shell scripts are required.\n#\n# The `git-preflight` SessionStart hook is the producer side of the\n# `preflight-before-*` policies: `harness session-start preflight` runs\n# agent-preflight against the session cwd and, on a ready:true result,\n# records `preflight:${REPO}` to the evidence ledger. It needs the\n# `preflight` binary on PATH (`npm i -g @lannguyensi/agent-preflight`); when\n# that is absent the hook logs to stderr and exits 0, so the session is\n# never broken \u2014 the preflight gates just stay closed until a tag is\n# produced some other way.\nhooks:\n - name: git-preflight\n event: SessionStart\n command: harness session-start preflight\n blocking: false\n # 70s budget gives the wrapped preflight (default 60s) headroom plus\n # ledger-write time. Was 30s through v0.17.4, but a healthy preflight\n # on a medium-size repo takes ~28s and the old 25s wrapper ceiling\n # blew through it. Bumped together with DEFAULT_PREFLIGHT_TIMEOUT_MS\n # (agent-tasks/7265599e).\n budget_ms: 70000\n # Floor at agent-preflight 0.2.0, the release that makes secret\n # detection git-aware and diff-scoped: a gitignored+untracked .env,\n # a .md doc, a non-git dir, or a secret in a tracked file the branch\n # never touched is a non-blocking warn, not a hard fail. Pre-0.2.0\n # installs hard-fail preflight on the normal correct state (a\n # gitignored .env holding real credentials), so this SessionStart\n # producer never writes a preflight: tag and the preflight-before-*\n # policies stay closed forever on any repo with a local .env. (0.1.1\n # had already fixed the wrapper-script \"tool not installed\" false\n # positive.) version_command points at the source-of-truth preflight\n # binary, not at the `harness session-start preflight` wrapper.\n min_version: \"0.2.0\"\n version_command: [\"preflight\", \"--version\"]\n\n - name: require-review-evidence\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_merge\"\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n # Tool-agnostic parallel of require-review-evidence for operators on the\n # gh-cli workflow (`gh pr merge`) instead of agent-tasks MCP. Same generic\n # `harness policy intercept` entrypoint; the matching review-before-merge-bash\n # policy below picks up the trigger. A PolicyTrigger can only AND-match one\n # surface (MCP tool-name OR Bash command), so two parallel definitions are\n # the minimum-scope way to cover both PR surfaces without bumping the schema.\n - name: require-review-evidence-bash\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr merge\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n - name: require-dogfood-evidence\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*(npm publish\\b|git( -C \\S+)* tag v)'\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n - name: require-preflight-evidence\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* (status|log|diff|branch)\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 1000\n\n - name: require-review-subagent-evidence\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_create\"\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n # Bash-surface parallel of require-review-subagent-evidence for operators\n # who open PRs with `gh pr create` instead of agent-tasks MCP. The matching\n # review-subagent-before-pr-create-bash policy below tags by branch\n # (`review-subagent:${BRANCH}`) because no task UUID is in `gh pr create`\n # arguments; the working branch is the closest stable handle for \"the\n # PR-in-progress\" at this point in the cycle.\n - name: require-review-subagent-evidence-bash\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr create\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\n - name: require-preflight-push-evidence\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* push\\b'\n command: harness policy intercept\n blocking: hard\n budget_ms: 1000\n\n # risk-gate (Phase 7 #6): the Risk Gate enforcement hook. The\n # gate-prod-destructive policies below reference it. Same generic\n # `harness policy intercept` entrypoint as every other policy hook;\n # the interceptor builds the Action Envelope, classifies risk against\n # `risk.classifiers[]`, resolves the environment against\n # `environments.resolvers[]`, and evaluates the policies' `when:`.\n - name: risk-gate\n event: PreToolUse\n match: \"Bash\"\n command: harness policy intercept\n blocking: hard\n budget_ms: 2000\n\npolicies:\n - name: review-before-merge\n description: Block PR merges unless a ledger entry tagged review:<pr-number> exists for this session.\n trigger:\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_merge\"\n extract:\n PR_NUMBER: \"toolArgs.prNumber\"\n requires:\n ledger_tag: \"review:${PR_NUMBER}\"\n hook: require-review-evidence\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review:${PR_NUMBER} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: Spawn a review subagent against the PR diff, capture its verdict, then persist a ledger entry tagged with the PR number. The content should be self-contained enough for an auditor to read without re-opening the chat.\n ux:\n cannot: \"You cannot merge PR #${PR_NUMBER} yet.\"\n required:\n - \"a recorded review of PR #${PR_NUMBER}\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review:${PR_NUMBER} \u2014 <verdict + key findings + nits>\" }'\n\n # Bash-surface parallel of review-before-merge for operators on the gh-cli\n # workflow. Two scope notes:\n # 1. Tag shape: `review:${BRANCH}` instead of `review:${PR_NUMBER}`. The\n # `gh pr merge` invocation can target the PR by number, by URL, or by\n # the current branch (default), and PR_NUMBER is not extractable from\n # `tool_input.command` with today's JSONPath-only extract DSL. BRANCH\n # is the stable identifier the producer can record at review time.\n # 2. This sits ALONGSIDE review-before-merge \u2014 not as a replacement. An\n # operator using both surfaces (e.g. agent-tasks MCP for most repos\n # + gh-cli for a quick hotfix) will have both gates active, each with\n # its own tag shape, which is semantically honest.\n - name: review-before-merge-bash\n description: Block `gh pr merge` unless a ledger entry tagged review:<branch> exists for this session.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr merge\\b'\n requires:\n ledger_tag: \"review:${BRANCH}\"\n hook: require-review-evidence-bash\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review:${BRANCH} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: Spawn a review subagent against the branch diff, capture its verdict, then persist a ledger entry tagged with the branch name. Mirror of the review-before-merge producer for the gh-cli surface.\n ux:\n cannot: \"You cannot merge the PR for branch ${BRANCH} via `gh pr merge` yet.\"\n required:\n - \"a recorded review of the PR for branch ${BRANCH}\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review:${BRANCH} \u2014 <verdict + key findings + nits>\" }'\n\n - name: dogfood-before-release\n description: Block npm publish / git tag v* without a recent dogfood ledger entry.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*(npm publish\\b|git( -C \\S+)* tag v)'\n requires:\n ledger_tag: \"dogfood:${SESSION_ID}\"\n within: 24h\n hook: require-dogfood-evidence\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"dogfood:${SESSION_ID} \u2014 <end-to-end smoke summary against the live system>\", source:\"manual smoke test\"}'\n description: Before tagging or publishing, run the release path end-to-end against the live system (not just unit tests) and persist the result as a session-tagged ledger entry. Document what you exercised (install, CLI happy path, MCP handshake, etc.) so a future auditor can tell whether the smoke covered the change.\n ux:\n cannot: \"You cannot publish a release yet.\"\n required:\n - \"an end-to-end dogfood run in this session\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"dogfood:${SESSION_ID} \u2014 <end-to-end smoke summary>\" }'\n\n - name: two-reviewers-required\n description: At least two distinct reviewer ledger entries must exist for the PR.\n trigger:\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_merge\"\n extract:\n PR_NUMBER: \"toolArgs.prNumber\"\n requires:\n ledger_tag: \"review:${PR_NUMBER}\"\n count:\n min: 2\n hook: require-review-evidence\n enforcement: warn\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review:${PR_NUMBER} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review (reviewer 2)\"}'\n description: Same shape as review-before-merge but TWO DISTINCT reviewer entries must exist before the gate is satisfied (count.min 2). Distinguish reviewers by source so the count is honest. Warn-level enforcement, so the agent CAN merge with one reviewer but should consider spawning a second for load-bearing changes.\n\n - name: preflight-before-investigation\n description: Block investigative git reads (status/log/diff/branch) when agent-preflight has not run recently with ready:true for the current repo.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* (status|log|diff|branch)\\b'\n requires:\n ledger_tag: \"preflight:${REPO}\"\n within: 1h\n hook: require-preflight-evidence\n enforcement: block\n producers:\n - kind: bash\n command: harness session-start preflight\n description: Runs agent-preflight against the current cwd; on ready:true, records preflight:${REPO} to the ledger. Standard producer.\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"preflight:${REPO}\", source:\"manual\"}'\n description: Direct ledger write. Use when the Bash hook is locked down (e.g. understanding-gate active) or when the standard producer is unavailable.\n ux:\n cannot: \"You cannot investigate this repository yet.\"\n required:\n - \"verified repository preflight\"\n run:\n - \"harness preflight\"\n\n - name: review-subagent-before-pr-create\n description: Block agent-tasks PR creation unless a review-subagent ledger entry tagged for this task already exists. Forces the rigorous review BEFORE the PR opens, not after.\n trigger:\n event: PreToolUse\n match: \"mcp__agent-tasks__pull_requests_create\"\n extract:\n TASK_ID: \"toolArgs.taskId\"\n requires:\n ledger_tag: \"review-subagent:${TASK_ID}\"\n hook: require-review-subagent-evidence\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review-subagent:${TASK_ID} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: After running a review subagent against the staged diff, persist its verdict + load-bearing findings as a ledger entry tagged with the task UUID. The content should be self-contained enough to audit later without re-reading the chat.\n ux:\n cannot: \"You cannot open a pull request for task ${TASK_ID} yet.\"\n required:\n - \"a completed review-subagent pass on this task\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review-subagent:${TASK_ID} \u2014 <verdict + key findings + nits>\" }'\n\n # Bash-surface parallel of review-subagent-before-pr-create. Tag shape is\n # `review-subagent:${BRANCH}` because TASK_ID is an agent-tasks-only\n # concept; for the gh-cli workflow the working branch is the closest stable\n # handle for \"the PR-in-progress\" at this point. Same rationale as\n # review-before-merge-bash: sits alongside the MCP variant, not as a\n # replacement.\n - name: review-subagent-before-pr-create-bash\n description: Block `gh pr create` unless a review-subagent ledger entry tagged review-subagent:<branch> exists for this session. Forces the rigorous review BEFORE the PR opens.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*gh pr create\\b'\n requires:\n ledger_tag: \"review-subagent:${BRANCH}\"\n hook: require-review-subagent-evidence-bash\n enforcement: block\n producers:\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"review-subagent:${BRANCH} \u2014 <verdict + key findings + nits>\", source:\"Agent(general-purpose) review\"}'\n description: After running a review subagent against the staged diff for the working branch, persist its verdict + load-bearing findings as a ledger entry tagged with the branch name. Mirror of the review-subagent-before-pr-create producer for the gh-cli surface.\n ux:\n cannot: \"You cannot open a pull request for branch ${BRANCH} via `gh pr create` yet.\"\n required:\n - \"a completed review-subagent pass on branch ${BRANCH}\"\n run:\n - 'mcp__agent-grounding__ledger_add { sessionId: \"${SESSION_ID}\", type: \"fact\", content: \"review-subagent:${BRANCH} \u2014 <verdict + key findings + nits>\" }'\n\n - name: preflight-before-push\n description: Block git push unless a fresh preflight ledger entry exists for the current branch. Catches the stale-checkout class of incident at the last reversible step.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n bash_match: '(^|\\n|;|\\||&&|\\()\\s*(\\w+=\\S+\\s+)*git( -C \\S+)* push\\b'\n requires:\n ledger_tag: \"preflight:${BRANCH}\"\n within: 10m\n # at_head:true lets a preflight at the current HEAD satisfy the\n # gate at any age (the standard producer writes head:<sha> into\n # the tag content). The 10m window remains the freshness ceiling\n # for the head-mismatch case (operator switched branch, preflight\n # predates HEAD shift, runtime couldn't resolve a sha).\n at_head: true\n hook: require-preflight-push-evidence\n enforcement: block\n producers:\n - kind: bash\n command: harness session-start preflight\n description: Runs agent-preflight against the current cwd; on ready:true, records preflight:${BRANCH} ready:true confidence:<n> head:<sha> to the ledger. Standard producer.\n - kind: mcp\n verb: mcp__agent-grounding__ledger_add\n example: '{sessionId:\"${SESSION_ID}\", type:\"fact\", content:\"preflight:${BRANCH} head:<full-sha> \u2014 <summary of what is on the branch + smoke results>\", source:\"manual\"}'\n description: Direct ledger write. Include head:<full-sha> if you want the entry to count under at_head; the branch is the WIP review surface and the content should summarise what is staged + the smoke evidence so a reviewer can audit later without re-reading the chat.\n ux:\n cannot: \"You cannot push branch ${BRANCH} yet.\"\n required:\n - \"a preflight for ${BRANCH} at the current HEAD (any age) OR any preflight within the last 10 minutes. Re-run `harness preflight` if you committed since the last preflight AND it has been more than 10 minutes.\"\n run:\n - \"harness preflight\"\n\n # Phase 7 Risk Gate \u2014 the canonical built-in worked example. These two\n # policies, with the dangerous-shell classifier and production-signals\n # resolver below, are the Risk Gate's default stance: a destructive\n # shell action whose target environment resolves to production is\n # gated before the runtime fires it. Both fire ONLY when the\n # environment resolves to production (a main / release branch, a\n # prod-looking DATABASE_URL, or a prod kube context); on an ordinary\n # feature branch the environment is unknown and neither fires. Ordered\n # deny-first so a critical action (which also matches the high\n # threshold) gets the hard-deny envelope. See docs/risk-gate.md.\n - name: gate-prod-destructive\n description: Deny critical-severity destructive shell actions against a production target.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n when:\n risk.severity_at_least: critical\n environment.name: production\n requires:\n ledger_tag: \"risk-override:${SESSION_ID}\"\n hook: risk-gate\n enforcement: block\n ux:\n cannot: \"You cannot run this critical destructive action against production.\"\n required:\n - \"a deliberate operator override: a critical production mutation has no benign reading\"\n run:\n - \"Choose a non-destructive alternative, or run the command yourself outside the agent.\"\n - \"Operator override (deliberate): record a risk-override:${SESSION_ID} entry in the evidence ledger.\"\n - name: gate-prod-destructive-approval\n description: Require operator approval for high-severity destructive shell actions against a production target.\n trigger:\n event: PreToolUse\n match: \"Bash\"\n when:\n risk.severity_at_least: high\n environment.name: production\n requires:\n ledger_tag: \"risk-approved:${SESSION_ID}\"\n hook: risk-gate\n enforcement: require_approval\n ux:\n cannot: \"You cannot run this destructive production action yet.\"\n required:\n - \"operator approval of this Risk Gate decision\"\n run:\n - \"harness approve risk\"\n\n# Full inherits the Solo/Team understanding-gate stack: the Stop hook\n# persists each Understanding Report and the PreToolUse pre-tool-use\n# blocker refuses Edit/Write/Bash until the report is approved. Drop\n# this block if you want the reference policies above without the\n# baseline gate.\npolicy_packs:\n - name: understanding-before-execution\n source: builtin\n enabled: true\n description: Force agents to expose their task interpretation and wait for explicit human approval before any write-capable tool fires.\n config:\n mode: grill_me\n # Producers (agent-tasks/25bced52): rendered into the gate's deny\n # envelope by the same engine as policy producers. Constraint at\n # this layer: at-least-one `ask`. Post-v0.14.0 the gate signal\n # is a filesystem marker and the mcp ledger_add path no longer\n # satisfies the gate; the canonical unblock surface is the\n # operator-approval prompt.\n producers:\n - kind: ask\n command: harness approve understanding\n description: \"Bare command, no pipes or chaining. The hook recognises it via isEscapeCommand and emits permissionDecision:ask; the operator's go on that prompt IS the gate approval. Golden path.\"\n - kind: bash\n command: harness approve understanding\n description: Same command from any un-hooked terminal (operator only, not reachable from inside the gated session). Writes the canonical marker at harness.generated/.approvals/${SESSION_ID}.\n # ux (agent-tasks/e48e3b45): replaces the legacy engine-vocabulary\n # deny envelope with the plain-language { cannot, required, run }\n # shape. Engine details (the BLOCK reason naming session id /\n # marker / report state) still land in stderr for operator audit;\n # the agent only sees this.\n ux:\n cannot: \"You cannot use write-capable tools yet.\"\n required:\n - \"an approved Understanding Report for this session\"\n run:\n - \"Write an Understanding Report covering: Current Understanding, Intended Outcome, Derived Todos, Acceptance Criteria, Assumptions, Open Questions, Out Of Scope, Risks, Verification Plan, Prior Art (state what you searched for an existing solution and what you found, with an explicit adopt-or-build judgment)\"\n - \"Run `harness approve understanding` and approve the prompt\"\n # approval_lifecycle (agent-tasks/d8ee60ca + harness/f54e0ecb,\n # v0.18.0+): expire the approval marker on task-completion\n # boundaries so a multi-task session re-prompts for an\n # Understanding Report between tasks. Without this the legacy\n # \"one approval per session\" contract lets a stale interpretation\n # drive the next task's edits.\n #\n # Full ships both boundary kinds: the agent-tasks MCP verbs for\n # operators on that workflow, plus a Bash regex list for hybrid\n # operators who also use gh-cli for PR mechanics. `max_age` is\n # the safety net. Operators who prefer the legacy per-session\n # behaviour opt out with `approval_lifecycle: { mode: session }`.\n # Operators on other task systems override the matchers.\n approval_lifecycle:\n expire_on_tool_match:\n - mcp__agent-tasks__task_finish\n - mcp__agent-tasks__task_abandon\n - mcp__agent-tasks__pull_requests_merge\n - mcp__agent-tasks__tasks_transition\n expire_on_bash_match:\n - '^gh pr (merge|close)\\b'\n - '^git push origin (master|main)\\b'\n max_age: 4h\n\n # branch-protection (agent-tasks/2fdc5bbe, default-enabled since v0.17.2):\n # blocks Write/Edit (claude-code) or apply_patch (codex) on protected\n # branches (default: master, main, develop). Complements\n # preflight-before-push, which fires at the LAST reversible step;\n # branch-protection fires at the FIRST source mutation, catching the\n # \"forgot to branch off master\" pattern earlier in the cycle.\n #\n # Two satisfying signals: a fresh `branch:non-protected:<branch>` tag\n # from the SessionStart producer (`harness session-start branch-check`),\n # or a `branch-protection-ack:<reason>` override the operator writes\n # via mcp__agent-grounding__ledger_add for deliberate protected-branch\n # edits (version bumps, CI workflow patches, hotfixes).\n #\n # Fails closed (any load / parse / ledger error refuses). Disable by\n # setting `enabled: false` or removing this entry if your workflow\n # routinely edits master directly. Override the protected list via\n # `config.protected_branches`. Full reference:\n # docs/policy-packs/branch-protection.md.\n - name: branch-protection\n source: builtin\n enabled: true\n description: Block Write/Edit on protected branches (master, main, develop) at the first source mutation.\n config:\n # ux (agent-tasks/9806d4f8): replaces the legacy\n # \"branch-protection: refusing ...\" envelope with the\n # plain-language { cannot, required, run } shape. Engine details\n # (the BLOCK reason naming session id / freshness window) stay\n # on stderr for operator audit.\n ux:\n cannot: \"You cannot edit files on protected branch ${BRANCH} yet.\"\n required:\n - \"a checkout of a non-protected branch (current `${BRANCH}` is protected)\"\n run:\n - \"git checkout -b feat/<your-task>\"\n - \"harness session-start branch-check\"\n\n# Phase 7 Risk Gate vocabulary. The dangerous-shell classifier and\n# production-signals resolver feed the gate-prod-destructive policies\n# above: `harness policy intercept` builds the Action Envelope,\n# classifies the action against `risk.classifiers[]`, resolves the\n# target environment against `environments.resolvers[]`, and evaluates\n# each policy's `when:` clauses against the result. Full design and the\n# decision model: docs/risk-gate.md.\nrisk:\n classifiers:\n - name: dangerous-shell\n tool: Bash\n patterns:\n - pattern: 'rm\\s+-rf\\s+(/|/var|/data|/mnt|~)'\n categories: [destructive, data_loss]\n severity: critical\n - pattern: 'DROP\\s+TABLE|TRUNCATE\\s+TABLE|DELETE\\s+FROM'\n categories: [destructive, data_loss]\n severity: high\n - pattern: 'kubectl\\s+delete\\s+(namespace|deployment|statefulset|pvc)'\n categories: [destructive, infrastructure_change]\n severity: high\n - pattern: 'terraform\\s+destroy'\n categories: [destructive, infrastructure_change]\n severity: critical\n\nenvironments:\n resolvers:\n - name: production-signals\n environment: production\n signals:\n branch_patterns: [main, \"release/*\"]\n env_var_patterns:\n - var: DATABASE_URL\n patterns: [prod, production]\n kube_context_patterns: [\".*prod.*\"]\n kube_namespace_patterns: [prod, production]\n";
3
3
  export type TemplateName = "minimal" | "full" | "solo" | "team";
4
4
  export declare function getTemplate(name: TemplateName): string;
@@ -534,7 +534,7 @@ policy_packs:
534
534
  required:
535
535
  - "an approved Understanding Report for this session"
536
536
  run:
537
- - "Write an Understanding Report covering: Current Understanding, Intended Outcome, Derived Todos, Acceptance Criteria, Assumptions, Open Questions, Out Of Scope, Risks, Verification Plan"
537
+ - "Write an Understanding Report covering: Current Understanding, Intended Outcome, Derived Todos, Acceptance Criteria, Assumptions, Open Questions, Out Of Scope, Risks, Verification Plan, Prior Art (state what you searched for an existing solution and what you found, with an explicit adopt-or-build judgment)"
538
538
  - "Run \`harness approve understanding\` and approve the prompt"
539
539
  # approval_lifecycle (agent-tasks/d8ee60ca + harness/f54e0ecb,
540
540
  # v0.18.0+): expire the approval marker on task-completion
@@ -105,14 +105,17 @@ export async function runPackHookCodexPreToolUseCli(opts = {}) {
105
105
  const stderr = opts.stderr ?? process.stderr;
106
106
  const packName = opts.pack ?? PACK_NAME;
107
107
  // Read stdin defensively. Bad JSON falls through to allow (matches
108
- // Claude blocker's failure mode).
108
+ // Claude blocker's failure mode) but emits a stderr diagnostic so
109
+ // the degradation is loud — a silently-allowing gate manufactures
110
+ // false confidence, which is the worst direction for a governance
111
+ // hook to fail in.
109
112
  const raw = await readStdin(stdin);
110
113
  let event = {};
111
114
  try {
112
115
  event = JSON.parse(raw.trim() || "{}");
113
116
  }
114
- catch {
115
- /* allow on malformed input */
117
+ catch (err) {
118
+ stderr.write(`harness pack hook (codex): malformed event JSON on stdin (${err.message}), allowing.\n`);
116
119
  }
117
120
  const sessionId = pickString(event.session_id) ??
118
121
  process.env["CODEX_SESSION_ID"] ??
@@ -1 +1 @@
1
- {"version":3,"file":"hook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AI;QACb,aAAa,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QAClE,UAAU;KACX,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"hook-codex-pre-tool-use.js","sourceRoot":"","sources":["../../../src/cli/pack/hook-codex-pre-tool-use.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,4BAA4B;AAC5B,EAAE;AACF,+DAA+D;AAC/D,wEAAwE;AACxE,+DAA+D;AAC/D,0CAA0C;AAC1C,mEAAmE;AACnE,sCAAsC;AACtC,qEAAqE;AACrE,oEAAoE;AACpE,sEAAsE;AACtE,0DAA0D;AAC1D,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,qEAAqE;AAErE,OAAO,EAAE,gBAAgB,EAAoB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,GAEnB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAgD,MAAM,uBAAuB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,MAAM,SAAS,GAAG,gCAAgC,CAAC;AACnD,MAAM,UAAU,GAAG,CAAC,CAAC;AAyCrB,KAAK,UAAU,SAAS,CAAC,MAA6B;IACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,IAAI,GAAG,EAAE,CAAC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;IACvI,MAAM,UAAU,GAAG,QAAQ;QACzB,CAAC,CAAC,mCAAmC,MAAM,MAAM,WAAW,EAAE;QAC9D,CAAC,CAAC,mCAAmC,MAAM,WAAW,QAAQ,KAAK,WAAW,EAAE,CAAC;IACnF,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QAClE,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -24,6 +24,7 @@ import { queryLedgerByTag, } from "../../policies/index.js";
24
24
  import { renderProducers } from "../../policies/producers.js";
25
25
  import { checkActiveClaimApprovalMarker, checkApprovalMarker, checkPersistedReport, defaultReportsDir, matchLedgerEntries, parseApprovalLifecycle, } from "../../policy-packs/builtin/understanding-before-execution-runtime.js";
26
26
  import { resolveGeneratedDir, writePendingApproval, } from "../../runtime/pending-approval.js";
27
+ import { isReadOnlyBashCommand } from "./read-only-bash.js";
27
28
  import { PolicyUxSchema, ProducerSchema, } from "../../schema/index.js";
28
29
  import { renderAgentFacing } from "../../runtime/agent-facing.js";
29
30
  import { z } from "zod";
@@ -199,14 +200,17 @@ export async function runPackHookPreToolUseCli(opts = {}) {
199
200
  const stderr = opts.stderr ?? process.stderr;
200
201
  const packName = opts.pack ?? PACK_NAME;
201
202
  // Read stdin defensively. Bad JSON falls through to allow (matches
202
- // policy intercept's failure mode).
203
+ // policy intercept's failure mode) but emits a stderr diagnostic so
204
+ // the degradation is loud — a silently-allowing gate manufactures
205
+ // false confidence, which is the worst direction for a governance
206
+ // hook to fail in.
203
207
  const raw = await readStdin(stdin);
204
208
  let event = {};
205
209
  try {
206
210
  event = JSON.parse(raw.trim() || "{}");
207
211
  }
208
- catch {
209
- /* allow on malformed input */
212
+ catch (err) {
213
+ stderr.write(`harness pack hook: malformed event JSON on stdin (${err.message}), allowing.\n`);
210
214
  }
211
215
  const sessionId = (typeof event.session_id === "string" ? event.session_id : undefined) ??
212
216
  process.env.CLAUDE_SESSION_ID ??
@@ -397,6 +401,26 @@ export async function runPackHookPreToolUseCli(opts = {}) {
397
401
  /* best-effort; the ask / block below proceeds regardless */
398
402
  }
399
403
  }
404
+ // Exception: read-only Bash commands. The pack hook matcher
405
+ // necessarily covers `Bash` as a whole, but commands like
406
+ // `git status`, `gh pr view`, `ls`, `cat` mutate nothing. Blocking
407
+ // them behind a full Understanding Report cycle trains the agent
408
+ // and operator to experience the gate as noise, which erodes its
409
+ // credibility on the writes that actually matter. Pass the
410
+ // classifier on Bash commands only; Edit and Write stay
411
+ // hard-blocked regardless (the matcher's other arms reach the
412
+ // same final block path below). Unclassifiable Bash falls through
413
+ // to the block (fail-closed).
414
+ if (toolName === "Bash" && isReadOnlyBashCommand(commandStr)) {
415
+ const diagnostic = `harness pack hook: read-only Bash command, allowing without an approved report (\`${commandStr.trim()}\`)`;
416
+ stderr.write(`${diagnostic}\n`);
417
+ return {
418
+ exitCode: 0,
419
+ blocked: false,
420
+ approvalCheck: { approved: true, source: "none", detail: diagnostic },
421
+ diagnostic,
422
+ };
423
+ }
400
424
  // Exception: the operator-approval command itself. Hard-denying
401
425
  // `harness approve understanding` is a catch-22: it is the very command
402
426
  // that records the operator's go, and a Bash `deny` gives no prompt to
@@ -1 +1 @@
1
- {"version":3,"file":"hook-pre-tool-use.js","sourceRoot":"","sources":["../../../src/cli/pack/hook-pre-tool-use.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,EAAE;AACF,yDAAyD;AACzD,wEAAwE;AACxE,qEAAqE;AACrE,kEAAkE;AAClE,yEAAyE;AACzE,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,EAAE;AACF,iEAAiE;AACjE,wEAAwE;A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AAS,CAAC,QAAQ,EAAE,mDAAmD,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,CAAC,IAAI,CACtH,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QAClE,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Classify a Bash command string. `true` means the command is
3
+ * provably read-only and the understanding-gate can allow it without
4
+ * an approved report. `false` means the command is either a write or
5
+ * unclassifiable; the gate must block (fail-closed).
6
+ *
7
+ * The classifier inspects the command as a raw shell string. It does
8
+ * NOT shell-parse or evaluate the command — that would introduce its
9
+ * own attack surface. Instead it rejects any string that contains
10
+ * shell metacharacters that could hide a write, then looks at the
11
+ * first one or two tokens.
12
+ */
13
+ export declare function isReadOnlyBashCommand(command: string): boolean;
@@ -0,0 +1,177 @@
1
+ // Read-only Bash command classifier for the understanding-gate
2
+ // PreToolUse blocker.
3
+ //
4
+ // The pack's hook matcher `Edit|Write|Bash` is too broad on its own:
5
+ // `Bash` covers commands like `git status`, `gh pr view`, `ls`, `cat`
6
+ // that mutate nothing. Hard-blocking them behind a full Understanding
7
+ // Report cycle trains the agent and operator to experience the gate
8
+ // as noise, which erodes its credibility on the writes that actually
9
+ // matter. A gate scoped exactly to what it must stop is a credible
10
+ // gate.
11
+ //
12
+ // Design contract:
13
+ // - The allowlist is intentionally conservative. Anything not on it
14
+ // is treated as a write (block). Better to occasionally annoy a
15
+ // read-only command we haven't enumerated than to let a write slip.
16
+ // - Any shell chaining (`;`, `&&`, `||`, `|`), redirection (`>`,
17
+ // `>>`, `<`), or command substitution (backticks, `$()`) makes the
18
+ // whole composition unclassifiable. Even if every individual piece
19
+ // would be read-only, a chained or substituted command can hide
20
+ // writes inside its construction. Refuse the whole thing.
21
+ // - The classifier never short-circuits write detection: if a command
22
+ // is on the allowlist but a write indicator is also present, the
23
+ // write indicator wins. The shell-metachar check above accomplishes
24
+ // this without a separate write-binary deny list (the meta-chars
25
+ // are how a write would be smuggled into a "read-only" command in
26
+ // the first place).
27
+ //
28
+ // This module is the canonical home for the classification. The
29
+ // harness pack hook is the superset blocker today, so the classifier
30
+ // lives here rather than in the @lannguyensi/understanding-gate
31
+ // package. If the package adds a parallel classifier in the future,
32
+ // it should mirror this allowlist verbatim, not diverge.
33
+ /**
34
+ * Single-token read-only binaries. Each accepts arguments without
35
+ * changing classification: `ls -la /tmp` is still read-only.
36
+ */
37
+ const SIMPLE_READ_ONLY_BINS = new Set([
38
+ "ls", "cat", "pwd", "which", "type", "command",
39
+ "grep", "rg", "wc",
40
+ "head", "tail", "file", "stat", "tree", "du", "df",
41
+ "ps", "whoami", "id", "date", "echo", "env", "printenv",
42
+ "true", "false", "uptime", "hostname", "uname", "tty",
43
+ "basename", "dirname", "realpath", "readlink",
44
+ "less", "more", "cmp", "diff", "comm",
45
+ "sort", "uniq", "cut", "tr", "tac", "rev",
46
+ ]);
47
+ /**
48
+ * `find` flags that make `find` itself a write tool, regardless of
49
+ * shell metacharacters. `find` is the one binary in the canonical
50
+ * read-only set whose own arguments can mutate the filesystem
51
+ * (`-delete`) or shell out to a write command (`-exec`, `-execdir`,
52
+ * `-ok`, `-okdir`). It also has output-write flags (`-fprint`,
53
+ * `-fprintf`, `-fprint0`, `-fls`) that would land outside any
54
+ * redirection guard. Any of these tokens anywhere in the argv
55
+ * forfeits the read-only classification, so `find` is treated as a
56
+ * special case rather than included in `SIMPLE_READ_ONLY_BINS`.
57
+ */
58
+ const FIND_WRITE_FLAGS = new Set([
59
+ "-delete",
60
+ "-exec", "-execdir", "-ok", "-okdir",
61
+ "-fprint", "-fprintf", "-fprint0", "-fls",
62
+ ]);
63
+ /**
64
+ * `less` and `more` can shell out via interactive `!cmd`. The agent
65
+ * shell is non-interactive, so the escape is not reachable in
66
+ * practice today; the entry stays in the simple-read-only set with
67
+ * a documented caveat in case a future runtime PTYs the agent.
68
+ */
69
+ /**
70
+ * `git` subcommands that do not mutate the working tree, index, or
71
+ * any ref. `git fetch` is included because it only writes to the
72
+ * remote-tracking branches, never touches local refs or the working
73
+ * tree; same for `git ls-remote`. `git config` is excluded: with
74
+ * arguments it can set values.
75
+ */
76
+ const GIT_READ_ONLY_SUBS = new Set([
77
+ "status", "log", "diff", "show", "branch", "tag",
78
+ "fetch", "remote", "ls-files", "ls-remote", "ls-tree",
79
+ "rev-parse", "rev-list", "describe", "blame", "shortlog",
80
+ "reflog", "cat-file", "check-ref-format", "for-each-ref",
81
+ "name-rev", "merge-base", "show-ref",
82
+ ]);
83
+ /**
84
+ * `gh` (GitHub CLI) noun + verb pairs that read state without writing.
85
+ * `gh pr view`, `gh pr checks`, `gh run view`, `gh workflow list`, etc.
86
+ */
87
+ const GH_READ_ONLY_VERBS = new Set([
88
+ "view", "list", "diff", "checks", "status",
89
+ ]);
90
+ const GH_READ_ONLY_NOUNS = new Set([
91
+ "pr", "issue", "run", "workflow", "release",
92
+ "repo", "label", "secret", "variable",
93
+ ]);
94
+ /**
95
+ * `harness` subcommands that only inspect manifest or harness state.
96
+ * `harness preflight` and `harness approve` are excluded: preflight
97
+ * writes a ledger row, approve writes the approval marker. Both are
98
+ * legitimate, but if the gate is currently blocking, classifying them
99
+ * as read-only would let them bypass it silently. Operator-approval
100
+ * commands have their own escape path in `isEscapeCommand`.
101
+ */
102
+ const HARNESS_READ_ONLY_SUBS = new Set([
103
+ "doctor", "validate", "audit", "diff", "list", "version",
104
+ "show", "status", "pause",
105
+ ]);
106
+ /**
107
+ * Common single-flag read-only invocations: `<bin> --version`,
108
+ * `<bin> -v`, `<bin> --help`, `<bin> -h`. Token count must be 2 and
109
+ * the second token must be one of these flags. Restricts to a
110
+ * known-safe shape so a binary like `rm` cannot be smuggled past as
111
+ * `rm --version`.
112
+ */
113
+ const VERSION_OR_HELP_FLAGS = new Set([
114
+ "--version", "-V", "-v", "--help", "-h",
115
+ ]);
116
+ /**
117
+ * Classify a Bash command string. `true` means the command is
118
+ * provably read-only and the understanding-gate can allow it without
119
+ * an approved report. `false` means the command is either a write or
120
+ * unclassifiable; the gate must block (fail-closed).
121
+ *
122
+ * The classifier inspects the command as a raw shell string. It does
123
+ * NOT shell-parse or evaluate the command — that would introduce its
124
+ * own attack surface. Instead it rejects any string that contains
125
+ * shell metacharacters that could hide a write, then looks at the
126
+ * first one or two tokens.
127
+ */
128
+ export function isReadOnlyBashCommand(command) {
129
+ const trimmed = command.trim();
130
+ if (trimmed === "")
131
+ return false;
132
+ // Reject any shell chaining, redirection, or command substitution.
133
+ // These make the command unclassifiable even when every visible
134
+ // piece would otherwise be read-only.
135
+ if (/[;&|<>]/.test(trimmed))
136
+ return false;
137
+ if (trimmed.includes("\n"))
138
+ return false;
139
+ if (trimmed.includes("`"))
140
+ return false;
141
+ if (trimmed.includes("$("))
142
+ return false;
143
+ const tokens = trimmed.split(/\s+/);
144
+ const bin = tokens[0] ?? "";
145
+ const sub = tokens[1] ?? "";
146
+ if (SIMPLE_READ_ONLY_BINS.has(bin))
147
+ return true;
148
+ // `find` is read-only ONLY when none of its argv tokens are write
149
+ // flags. Scan the whole argv: `-delete` / `-exec` / `-execdir` /
150
+ // `-ok` / `-okdir` mutate the filesystem; `-fprint*` and `-fls`
151
+ // write to operator-supplied paths without going through shell
152
+ // redirection. If any such flag appears, fall through to block.
153
+ if (bin === "find") {
154
+ return !tokens.slice(1).some((t) => FIND_WRITE_FLAGS.has(t));
155
+ }
156
+ // `<bin> --version` / `<bin> --help` shape. Checked BEFORE the
157
+ // per-binary branches so that `git --version`, `gh --version`,
158
+ // `harness --version` all pass through this shape rather than
159
+ // falling into the per-binary subcommand allowlists (which
160
+ // intentionally don't list `--version` since it's not a
161
+ // subcommand). Must be exactly two tokens to keep the surface
162
+ // tight: `<bin> --version <thing>` could exfiltrate or mis-route.
163
+ if (tokens.length === 2 && VERSION_OR_HELP_FLAGS.has(sub))
164
+ return true;
165
+ if (bin === "git")
166
+ return GIT_READ_ONLY_SUBS.has(sub);
167
+ if (bin === "gh") {
168
+ if (!GH_READ_ONLY_NOUNS.has(sub))
169
+ return false;
170
+ const verb = tokens[2] ?? "";
171
+ return GH_READ_ONLY_VERBS.has(verb);
172
+ }
173
+ if (bin === "harness")
174
+ return HARNESS_READ_ONLY_SUBS.has(sub);
175
+ return false;
176
+ }
177
+ //# sourceMappingURL=read-only-bash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-only-bash.js","sourceRoot":"","sources":["../../../src/cli/pack/read-only-bash.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,sBAAsB;AACtB,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,sEAAsE;AACtE,oEAAoE;AACpE,qEAAqE;AACrE,mEAAmE;AACnE,QAAQ;AACR,EAAE;AACF,mBAAmB;AACnB,oEAAoE;AACpE,kEAAkE;AAClE,sEAAsE;AACtE,iEAAiE;AACjE,qEAAqE;AACrE,qEAAqE;AACrE,kEAAkE;AAClE,4DAA4D;AAC5D,sEAAsE;AACtE,mEAAmE;AACnE,sEAAsE;AACtE,mEAAmE;AACnE,oEAAoE;AACpE,sBAAsB;AACtB,EAAE;AACF,gEAAgE;AAChE,qEAAqE;AACrE,gEAAgE;AAChE,oEAAoE;AACpE,yDAAyD;AAEzD;;;GAGG;AACH,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS;IAC9C,MAAM,EAAE,IAAI,EAAE,IAAI;IAClB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;IAClD,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UA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AgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,+DAA+D;IAC/D,+DAA+D;IAC/D,8DAA8D;IAC9D,2DAA2D;IAC3D,wDAAwD;IACxD,8DAA8D;IAC9D,kEAAkE;IAClE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAEvE,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEtD,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7B,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAE9D,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare const UNDERSTANDING_REPORT_REQUIRED_SECTIONS: readonly ["Current Understanding (paragraph)", "Intended Outcome (paragraph)", "Derived Todos (list)", "Acceptance Criteria (list)", "Assumptions (list)", "Open Questions (list)", "Out Of Scope (list)", "Risks (list)", "Verification Plan (list)"];
1
+ export declare const UNDERSTANDING_REPORT_REQUIRED_SECTIONS: readonly ["Current Understanding (paragraph)", "Intended Outcome (paragraph)", "Derived Todos (list)", "Acceptance Criteria (list)", "Assumptions (list)", "Open Questions (list)", "Out Of Scope (list)", "Risks (list)", "Verification Plan (list)", "Prior Art (list)"];
2
2
  /**
3
3
  * Render a compact, agent-readable hint listing the canonical sections
4
4
  * the `@lannguyensi/understanding-gate` parser expects. Suitable for
@@ -26,6 +26,12 @@ export const UNDERSTANDING_REPORT_REQUIRED_SECTIONS = [
26
26
  "Out Of Scope (list)",
27
27
  "Risks (list)",
28
28
  "Verification Plan (list)",
29
+ // Section 10 (agent-grounding 0.4.0): state what was searched for an
30
+ // existing solution and what was found, with an explicit
31
+ // adopt-or-build judgment. Required by the Stop-capture parser in
32
+ // grill_me / full mode; relaxed in fast_confirm. See harness task
33
+ // 798d7173 / agent-grounding PR #85.
34
+ "Prior Art (list)",
29
35
  ];
30
36
  /**
31
37
  * Render a compact, agent-readable hint listing the canonical sections
@@ -47,7 +53,7 @@ export function renderReportSchemaHint() {
47
53
  // one pair implied exhaustiveness. The bullets below show the canonical
48
54
  // names; the parser's alias-tolerance is a quiet bonus, not something
49
55
  // the agent needs to choose between.
50
- const intro = "Report format (parsed by `@lannguyensi/understanding-gate`): markdown with these nine sections, any heading level (#, ##, ###), names case-insensitive. Missing any section produces a parse-error under `.understanding-gate/parse-errors/` and the audit trail is empty even though the gate-approval marker still gets written.";
56
+ const intro = "Report format (parsed by `@lannguyensi/understanding-gate`): markdown with these ten sections, any heading level (#, ##, ###), names case-insensitive. Missing any section produces a parse-error under `.understanding-gate/parse-errors/` and the audit trail is empty even though the gate-approval marker still gets written.";
51
57
  const bullets = UNDERSTANDING_REPORT_REQUIRED_SECTIONS.map((s) => ` - ${s}`).join("\n");
52
58
  return `${intro}\n${bullets}`;
53
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"understanding-report-schema-hint.js","sourceRoot":"","sources":["../../../src/cli/pack/understanding-report-schema-hint.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wEAAwE;AACxE,EAAE;AACF,kEAAkE;AAClE,qEAAqE;AACrE,sEAAsE;AACtE,wEAAwE;AACxE,uEAAuE;AACvE,+CAA+C;AAC/C,EAAE;AACF,kEAAkE;AAClE,wDAAwD;AACxD,qEAAqE;AACrE,qEAAqE;AACrE,qEAAqE;AACrE,oEAAoE;AACpE,oEAAoE;AACpE,mEAAmE;AAEnE,MAAM,CAAC,MAAM,sCAAsC,GAAG;IACpD,mCAAmC;IACnC,8BAA8B;IAC9B,sBAAsB;IACtB,4BAA4B;IAC5B,oBAAoB;IACpB,uBAAuB;IACvB,qBAAqB;IACrB,cAAc;IACd,0BAA0B;CAClB,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB;IACpC,uEAAuE;IACvE,wEAAwE;IACxE,+DAA+D;IAC/D,yEAAyE;IACzE,oEAAoE;IACpE,wEAAwE;IACxE,sEAAsE;IACtE,qCAAqC;IACrC,MAAM,KAAK,GACT,oUAAoU,CAAC;IACvU,MAAM,OAAO,GAAG,sCAAsC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,OAAO,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"understanding-report-schema-hint.js","sourceRoot":"","sources":["../../../src/cli/pack/understanding-report-schema-hint.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wEAAwE;AACxE,EAAE;AACF,kEAAkE;AAClE,qEAAqE;AACrE,sEAAsE;AACtE,wEAAwE;AACxE,uEAAuE;AACvE,+CAA+C;AAC/C,EAAE;AACF,kEAAkE;AAClE,wDAAwD;AACxD,qEAAqE;AACrE,qEAAqE;AACrE,qEAAqE;AACrE,oEAAoE;AACpE,oEAAoE;AACpE,mEAAmE;AAEnE,MAAM,CAAC,MAAM,sCAAsC,GAAG;IACpD,mCAAmC;IACnC,8BAA8B;IAC9B,sBAAsB;IACtB,4BAA4B;IAC5B,oBAAoB;IACpB,uBAAuB;IACvB,qBAAqB;IACrB,cAAc;IACd,0BAA0B;IAC1B,qEAAqE;IACrE,yDAAyD;IACzD,kEAAkE;IAClE,kEAAkE;IAClE,qCAAqC;IACrC,kBAAkB;CACV,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB;IACpC,uEAAuE;IACvE,wEAAwE;IACxE,+DAA+D;IAC/D,yEAAyE;IACzE,oEAAoE;IACpE,wEAAwE;IACxE,sEAAsE;IACtE,qCAAqC;IACrC,MAAM,KAAK,GACT,mUAAmU,CAAC;IACtU,MAAM,OAAO,GAAG,sCAAsC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,OAAO,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC;AAChC,CAAC"}
@@ -5,7 +5,7 @@ export interface CheckOptions {
5
5
  homeDir?: string;
6
6
  pathEnv?: string;
7
7
  builtinRuntimeProbe?: () => string[];
8
- versionProbe?: (cmd: string[]) => string | null;
8
+ versionProbe?: (cmd: readonly string[]) => string | null;
9
9
  }
10
10
  declare function isRootedPath(p: string): boolean;
11
11
  declare function firstToken(command: string): string;