repo-harness 0.33.2 → 0.34.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 (54) hide show
  1. package/AGENTS.md +6 -6
  2. package/CLAUDE.md +6 -6
  3. package/README.md +2 -2
  4. package/assets/reference-configs/agentic-development-flow.md +4 -4
  5. package/assets/reference-configs/herdr-notify.md +1 -1
  6. package/assets/reference-configs/hook-operations.md +79 -58
  7. package/assets/reference-configs/host-invariants.md +1 -1
  8. package/assets/released-managed-values.v1.json +5 -1
  9. package/assets/skill-version.json +2 -2
  10. package/assets/skills/repo-harness-issue-flow/references/orchestrator.md +5 -7
  11. package/assets/skills/repo-harness-test/references/running.md +1 -1
  12. package/assets/templates/helpers/capability-resolver.ts +1 -1
  13. package/dist/hook-entry.js +3000 -1635
  14. package/dist/oar-review-host.js +0 -2
  15. package/package.json +1 -1
  16. package/scripts/check-ci.sh +23 -4
  17. package/scripts/check-ledger-enforcement.ts +298 -0
  18. package/scripts/maintenance-triage.sh +74 -34
  19. package/scripts/release-owner-steps.sh +1 -1
  20. package/src/cli/commands/global-runtime.ts +53 -42
  21. package/src/cli/hook/agent-notice.ts +95 -30
  22. package/src/cli/hook/handler-contract.ts +2 -2
  23. package/src/cli/hook/handler-registry.ts +5 -2
  24. package/src/cli/hook/hook-protocol.ts +3 -2
  25. package/src/cli/hook/mutation-bash.ts +6 -364
  26. package/src/cli/hook/mutation-guard.ts +53 -165
  27. package/src/cli/hook/route-registry.ts +1 -1
  28. package/src/cli/hook/safety-hook.ts +1001 -0
  29. package/src/cli/hook/session-context.ts +3 -3
  30. package/src/cli/hook/shell-words.ts +455 -0
  31. package/src/cli/hook-entry.ts +4 -0
  32. package/src/cli/index.ts +1 -1
  33. package/src/cli/installer/repository-excludes.ts +185 -0
  34. package/src/cli/installer/uninstall.ts +24 -17
  35. package/src/core/board/seat-routing.ts +7 -12
  36. package/src/core/board/seats-settings.ts +7 -4
  37. package/src/core/ci/rules.ts +10 -1
  38. package/src/core/ci/test-budget.ts +60 -0
  39. package/src/core/host-config/plan.ts +125 -0
  40. package/src/core/host-config/types.ts +146 -0
  41. package/src/core/publication/merge-readiness.ts +87 -1
  42. package/src/core/setup/types.ts +1 -1
  43. package/src/core/workflow/policy-schema.ts +1 -1
  44. package/src/effects/adoption/gitignore-plan.ts +3 -2
  45. package/src/effects/architecture/archctx-provider.ts +55 -9
  46. package/src/effects/board/seats-configuration.ts +1 -1
  47. package/src/effects/configuration/global-configuration.ts +3 -0
  48. package/src/effects/host-config/gate.ts +294 -0
  49. package/src/effects/host-config/store.ts +202 -0
  50. package/src/effects/process-runner.ts +16 -8
  51. package/src/effects/publication/merge-executor.ts +9 -1
  52. package/src/effects/publication/merge-readiness.ts +168 -23
  53. package/src/effects/state/resolve-effective-state.ts +11 -26
  54. package/src/cli/hook/mutation-protected-gate.ts +0 -958
package/AGENTS.md CHANGED
@@ -9,7 +9,7 @@
9
9
  - Create task worktrees only at `/tmp/<repo>-wt-<slug>` (Windows: `os.tmpdir()`) with `rh worktrees start --issue <number>`, or `git worktree add` with that path. Never create one beside the main checkout (`../`). Commit or push before a reboot or a tmp cleanup. Closeout and sweep remove only merged, clean and unowned worktrees; to keep one, give it an unmerged commit, keep it dirty, or mark or lock it.
10
10
  - For non-trivial work, follow the global Progressive Due Diligence rule (P1 map, P2 trace, P3 decision) before design decisions or code edits.
11
11
  - Keep root CLAUDE.md and AGENTS.md as standalone regular files; repeat shared rules in both and keep host-specific guidance separate.
12
- - Read the current request and repo-local agent context, work on a branch, make bounded commits, verify once, then report the PR outcome. Finish the main task first. Fix a small problem found on the way directly; for a large problem, open a GitHub issue before you work on it.
12
+ - Read the current request and repo-local agent context, work on a branch, make bounded commits, verify once, then report the PR outcome. Verify the live checkout, declared revision and real entrypoint before relying on an issue, snapshot or agent report. Verify the actual observer configuration and emitted evidence before claiming that a mechanism runs or catches a problem. Keep changes within approved scope and preserve private operations state. Do not treat an advisory, a capacity limit or a healthy startup as delivery acceptance. Finish the main task first. Fix a small problem found on the way directly; for a large problem, open a GitHub issue before you work on it.
13
13
  - Read `tasks/lessons.md` at session start and apply its active lessons. Current repo state and evidence override a lesson.
14
14
  - Ordinary tasks use the PR description: goal, scope, changes, verification, risk and rollback. No plan, contract, review, notes or approval artifact is mandatory. Record a one-time decision in the issue.
15
15
  - GitHub operations (PRs, reviews, merges, labels, releases, comments) go only through the gh/git CLI or the GitHub API. Never use simulated browser clicks on github.com: the account can be banned.
@@ -17,7 +17,7 @@
17
17
 
18
18
  ## Code Optimization Principles
19
19
  - Identify observable conditions, controllable inputs, the invariant and the actual pressure point before changing structure.
20
- - Keep one source of truth for each datum; other representations are deterministic projections with drift checks.
20
+ - Keep one source of truth for each datum and reuse its existing parser or resolver. Other representations are deterministic projections with drift checks. Change authoring sources and their projections together. Dry-run and apply use the same operation model. Keep ownership, identity, authorization and freshness distinct. Shape validation and persistence do not establish authority.
21
21
  - Do not add steady-state compatibility code, dual authority, semantic fallbacks, aliases or shadow parsers; one-shot migrations fail closed and remove the retired path.
22
22
  - Share components only for observed reuse or a cross-module invariant. Use an existing workspace only for independently meaningful consumers; do not convert this single-package repo without that boundary.
23
23
  - Prefer platform/standard-library features, then installed dependencies, and the smallest direct implementation; shrink obsolete code before adding layers. The repository is yours by default: refactor duplication, blocking structure and older model-written code instead of adding to it; keep behavior unless the task changes it, state the refactor in the PR, and route a refactor into another seat's files through the orchestrator.
@@ -29,13 +29,13 @@
29
29
  - For a bug fix, prefer a focused failing regression before the fix. Run only the reproducer during RED. Record a reproduction gap when the environment cannot produce it; ordinary tasks do not require RED artifacts.
30
30
  - A diff's size, a new test file, a new agent or a rebase does not by itself require a full run.
31
31
  - Use `bun run test:files <affected tests> --timeout 60000 --max-concurrency 1`; extend existing coverage before creating a new test file.
32
- - Test budget per PR: added test lines divided by added product lines must not exceed 2:1, and the PR adds at most one test file. A PR that adds no product lines records the exception for any added test. Measure with `git diff --numstat main...HEAD -- tests` and `git diff --numstat main...HEAD -- src scripts`; above either cap, add a `Test budget exception` PR section with the counts and why an existing test cannot cover the behavior.
32
+ - Read `.ai/harness/policy.json#rules` for enabled rules and their parameters; `src/core/ci/rules.ts` defines their meaning and repair steps.
33
33
  - Select tests by observable risk and owning runtime boundary, including error/recovery paths when affected.
34
34
  - Mechanical prose changes need link/scope validation, not new product tests; do not test incidental formatting or that deleted files stay deleted.
35
- - Reviewers consume the recorded command, result, revision and environment; they do not rerun passing checks to claim ownership.
35
+ - Reviewers consume the recorded command, result, revision and environment; they do not rerun passing checks to claim ownership. Bind assertions to explicit run IDs and revisions. Select evidence by those IDs.
36
36
  - Changed inputs or a new uncovered failure justify affected delta checks; an old pass is only historical evidence for its old subject.
37
- - Run the full suite daily; a failure opens an automatic repair task and appears in the daily report.
38
- - Isolate mutable HOME, repositories and process state; use real synchronization signals and preserve complete failure output.
37
+ - Report each independent check failure so the first failed lane does not hide later faults. Run the full suite daily; a failure opens an automatic repair task and appears in the daily report.
38
+ - Isolate mutable HOME, repositories and process state. Use real synchronization signals instead of sleeps or longer timeouts. Preserve complete failure output.
39
39
  - Report failed, timed-out, incomplete or omitted coverage explicitly; do not manufacture receipts, waiver files or pre-fix logs.
40
40
  - Never modify or delete test assertions just to make tests pass; justify every necessary test change item by item in the PR description. Remove a redundant test only when the PR names the retained test that covers the same behavior.
41
41
  - Before you write or change tests, load the `repo-harness-test` skill (`assets/skills/repo-harness-test/SKILL.md`).
package/CLAUDE.md CHANGED
@@ -9,7 +9,7 @@
9
9
  - Create task worktrees only at `/tmp/<repo>-wt-<slug>` (Windows: `os.tmpdir()`) with `rh worktrees start --issue <number>`, or `git worktree add` with that path. Never create one beside the main checkout (`../`). Commit or push before a reboot or a tmp cleanup. Closeout and sweep remove only merged, clean and unowned worktrees; to keep one, give it an unmerged commit, keep it dirty, or mark or lock it.
10
10
  - For non-trivial work, follow the global Progressive Due Diligence rule (P1 map, P2 trace, P3 decision) before design decisions or code edits.
11
11
  - Keep root CLAUDE.md and AGENTS.md as standalone regular files; repeat shared rules in both and keep host-specific guidance separate.
12
- - Read the current request and repo-local agent context, work on a branch, make bounded commits, verify once, then report the PR outcome. Finish the main task first. Fix a small problem found on the way directly; for a large problem, open a GitHub issue before you work on it.
12
+ - Read the current request and repo-local agent context, work on a branch, make bounded commits, verify once, then report the PR outcome. Verify the live checkout, declared revision and real entrypoint before relying on an issue, snapshot or agent report. Verify the actual observer configuration and emitted evidence before claiming that a mechanism runs or catches a problem. Keep changes within approved scope and preserve private operations state. Do not treat an advisory, a capacity limit or a healthy startup as delivery acceptance. Finish the main task first. Fix a small problem found on the way directly; for a large problem, open a GitHub issue before you work on it.
13
13
  - Read `tasks/lessons.md` at session start and apply its active lessons. Current repo state and evidence override a lesson.
14
14
  - Ordinary tasks use the PR description: goal, scope, changes, verification, risk and rollback. No plan, contract, review, notes or approval artifact is mandatory. Record a one-time decision in the issue.
15
15
  - GitHub operations (PRs, reviews, merges, labels, releases, comments) go only through the gh/git CLI or the GitHub API. Never use simulated browser clicks on github.com: the account can be banned.
@@ -17,7 +17,7 @@
17
17
 
18
18
  ## Code Optimization Principles
19
19
  - Identify observable conditions, controllable inputs, the invariant and the actual pressure point before changing structure.
20
- - Keep one source of truth for each datum; other representations are deterministic projections with drift checks.
20
+ - Keep one source of truth for each datum and reuse its existing parser or resolver. Other representations are deterministic projections with drift checks. Change authoring sources and their projections together. Dry-run and apply use the same operation model. Keep ownership, identity, authorization and freshness distinct. Shape validation and persistence do not establish authority.
21
21
  - Do not add steady-state compatibility code, dual authority, semantic fallbacks, aliases or shadow parsers; one-shot migrations fail closed and remove the retired path.
22
22
  - Share components only for observed reuse or a cross-module invariant. Use an existing workspace only for independently meaningful consumers; do not convert this single-package repo without that boundary.
23
23
  - Prefer platform/standard-library features, then installed dependencies, and the smallest direct implementation; shrink obsolete code before adding layers. The repository is yours by default: refactor duplication, blocking structure and older model-written code instead of adding to it; keep behavior unless the task changes it, state the refactor in the PR, and route a refactor into another seat's files through the orchestrator.
@@ -29,13 +29,13 @@
29
29
  - For a bug fix, prefer a focused failing regression before the fix. Run only the reproducer during RED. Record a reproduction gap when the environment cannot produce it; ordinary tasks do not require RED artifacts.
30
30
  - A diff's size, a new test file, a new agent or a rebase does not by itself require a full run.
31
31
  - Use `bun run test:files <affected tests> --timeout 60000 --max-concurrency 1`; extend existing coverage before creating a new test file.
32
- - Test budget per PR: added test lines divided by added product lines must not exceed 2:1, and the PR adds at most one test file. A PR that adds no product lines records the exception for any added test. Measure with `git diff --numstat main...HEAD -- tests` and `git diff --numstat main...HEAD -- src scripts`; above either cap, add a `Test budget exception` PR section with the counts and why an existing test cannot cover the behavior.
32
+ - Read `.ai/harness/policy.json#rules` for enabled rules and their parameters; `src/core/ci/rules.ts` defines their meaning and repair steps.
33
33
  - Select tests by observable risk and owning runtime boundary, including error/recovery paths when affected.
34
34
  - Mechanical prose changes need link/scope validation, not new product tests; do not test incidental formatting or that deleted files stay deleted.
35
- - Reviewers consume the recorded command, result, revision and environment; they do not rerun passing checks to claim ownership.
35
+ - Reviewers consume the recorded command, result, revision and environment; they do not rerun passing checks to claim ownership. Bind assertions to explicit run IDs and revisions. Select evidence by those IDs.
36
36
  - Changed inputs or a new uncovered failure justify affected delta checks; an old pass is only historical evidence for its old subject.
37
- - Run the full suite daily; a failure opens an automatic repair task and appears in the daily report.
38
- - Isolate mutable HOME, repositories and process state; use real synchronization signals and preserve complete failure output.
37
+ - Report each independent check failure so the first failed lane does not hide later faults. Run the full suite daily; a failure opens an automatic repair task and appears in the daily report.
38
+ - Isolate mutable HOME, repositories and process state. Use real synchronization signals instead of sleeps or longer timeouts. Preserve complete failure output.
39
39
  - Report failed, timed-out, incomplete or omitted coverage explicitly; do not manufacture receipts, waiver files or pre-fix logs.
40
40
  - Never modify or delete test assertions just to make tests pass; justify every necessary test change item by item in the PR description. Remove a redundant test only when the PR names the retained test that covers the same behavior.
41
41
  - Before you write or change tests, load the `repo-harness-test` skill (`assets/skills/repo-harness-test/SKILL.md`).
package/README.md CHANGED
@@ -177,7 +177,7 @@ sequenceDiagram
177
177
  | --- | --- |
178
178
  | **Session continuity** | The branch names the issue; the issue and PR carry scope and the next step, so any agent resumes without the original chat. |
179
179
  | **Typed hook runtime** | 6 public routes (Claude 5, Codex 5), each bound to exactly one in-process handler. |
180
- | **Edit-boundary guards** | `RepoScopeGuard`, `ExternalReferenceGuard`, `OpsPrivateGuard`, `EditScopeGuard`, `ApplyPatchScopeGuard`. |
180
+ | **Safety hook** | `CredentialGuard` (I1), `UserFileGuard` (I2), `RecursiveDeleteGuard`, `EditScopeGuard`, `ApplyPatchScopeGuard`. |
181
181
  | **Progressive context** | Root context plus per-capability contracts, backed by ArchContext and CodeGraph. |
182
182
  | **Acceptance review** | A persistent, sandboxed reviewer in a linked checkout, up to three repair rounds per PR. |
183
183
  | **Operator console** | A loopback-only local web board for tasks, repos, agents, skills, hooks and architecture. |
@@ -331,6 +331,6 @@ None of these are bundled dependencies; see
331
331
 
332
332
  ## Release & license
333
333
 
334
- - npm: `repo-harness@0.33.2` · workflow stamp `repo-harness@0.33.2+template@0.33.2`
334
+ - npm: `repo-harness@0.34.0` · workflow stamp `repo-harness@0.34.0+template@0.34.0`
335
335
  - History: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
336
336
  - License: MIT — see [`LICENSE`](LICENSE)
@@ -68,10 +68,10 @@ Manual probe: to see what named test files do on one runner for a branch head, d
68
68
  - Seen: <N>×
69
69
  ```
70
70
 
71
- - For a repeat, copy the `Name` and `Mistake pattern` text exactly. Maintenance triage groups entries by `Mistake pattern`. `Seen` is the cumulative event count of the theme, up to and including this entry. Do not edit `Seen` on older entries.
71
+ - `Mistake pattern` is the immutable theme key: lowercase words joined by `-`. For a repeat, copy the key exactly; `Name` can change. Maintenance triage and the `LedgerEnforcement` check group entries by the key. `Seen` is the cumulative event count of the theme, up to and including this entry. Do not edit `Seen` on older entries.
72
72
  - A new correction event adds 1 to the last valid cumulative `Seen` value of the theme. A change of format, classification or enforcement adds nothing.
73
- - A merge of one cumulative series keeps the maximum `Seen` value and every `Triggered by correction` reference of the entries it replaces. Add the consolidating PR to that list; never substitute it for the earlier references. Maintenance triage reads the ledger history and fails an entry whose only reference is a consolidation commit.
74
- - A merge of different themes is a reclassification. A person checks the events of the themes for overlap and sets `Seen` from that check.
73
+ - A theme key never leaves the ledger. A rename changes only `Name`. A split keeps the key and its maximum `Seen` on the existing theme and starts a new key for the other part.
74
+ - A merge of one cumulative series keeps its key, the maximum `Seen` value, the `Promoted` and `Enforced by` values and every `Triggered by correction` reference of the entries it replaces. Add the consolidating PR to that list; never substitute it for the earlier references. Maintenance triage reads the ledger history and fails an entry whose only reference is a consolidation commit.
75
75
  - A history migration sets the start value of `Seen` from the history evidence, not from the number of references.
76
76
  - `Enforced by` names the file that fails when the mistake comes back. For an architecture or type fix, name the file that makes the mistake impossible. `judgment` means that no file catches the mistake.
77
77
  - `Missed by` names the check layer that should have caught the mistake before merge. `unknown` means that the evidence does not show the missed layer; the entry's `Why` says which evidence is missing. `none` means that no layer applies and that this was checked.
@@ -83,7 +83,7 @@ Manual probe: to see what named test files do on one runner for a branch head, d
83
83
  4. A test.
84
84
  If no level works, write `Enforced by: judgment`.
85
85
  - A new check or test must fail on the real commit that had the mistake and pass after the fix. Put both results in the PR.
86
- - At `Seen: 3×` with `Enforced by: judgment`, promote the prevention rule into root `AGENTS.md` and root `CLAUDE.md` in the same PR. Add `- Promoted: <PR>` to that entry. A rule with a structural enforcer does not go into the root files.
86
+ - At `Seen: 3×` with `Enforced by: judgment`, promote the prevention rule into root `AGENTS.md` and root `CLAUDE.md` in the same PR. Add `- Promoted: <PR>` to that entry. A consolidated entry lists every `Promoted` reference of the entries it replaces, separated by `, `. A rule with a structural enforcer does not go into the root files.
87
87
  - When the mistake can no longer occur, delete its text rule from the agent instruction files. Keep its ledger entries.
88
88
  - Each retro advances the watermark to the last reviewed commit, also when it finds no lesson. If an earlier retro PR is still open, update that PR. Do not open a second retro PR.
89
89
  - Every change to `tasks/lessons.md` goes through a PR and merges only after GO. GO is an explicit go-ahead from the repository owner (Aimpact for repo-harness) for one reviewed head SHA. Task-level publication authorization does not replace it. Merge with `gh pr merge <pr> --squash --match-head-commit <reviewed-sha>`. Lessons are not task logs. Ordinary tasks record a one-time decision in the issue or PR. A correction in a task can add an entry; that entry follows the same PR and GO rule.
@@ -82,7 +82,7 @@ On Pi, review seats pass `--exclude-tools edit,write`. Direct edit/write tools a
82
82
 
83
83
  Routing selects the first eligible seat with a known account state, or a Pi seat without an account (the DeepSeek `worker-light`). A Pi seat on `magpie/codex/` has the `chatgpt` account. It selects an unknown account only when no such seat is eligible. A window at or above `routing.exhausted_at_or_above_used` percent used (default 95, range 50–100) is `exhausted`; a provider-reported `rate_limit_reached_type` is exhausted at any value. Exhausted accounts are excluded. The one exception is `routing.codex_credit_mode` (`off`, `review` or `all`; default `off`): while the ChatGPT account is exhausted and reports credits at or above `routing.codex_credit_floor` (default 0), `review` admits the gatekeeper, the gatekeeper fallback and a ChatGPT-bound reviewer (not `gatekeeper-deep`), and `all` admits every ChatGPT-bound seat. Their route and seat lines say `on credits`; the `chatgpt` account line stays `exhausted`. Only the owner sets `codex_credit_mode`, on the console Seats page; a seat does not write it, and a joint decision does not cover it. Claude in saving mode or exhausted stays reserved for the advisor and orchestrator. An important non-frontend route that holds a Claude-account seat then uses a configured Pi `worker-light`; a null or non-Pi `worker-light` gives a `none` route. An important route without a Claude-account seat is read as stored. Frontend waits for Claude. `rh seats argv <seat> --repository-id <id> --owner-exception <url>` lifts the Claude reservation refusal (`seat_quota_reserved`) for one launch. The URL must name an owner decision on an issue or PR of the checkout's origin repository; the seat label `repo-harness.owner-exception` and the `--json` launch record keep it. The exception changes no model, tool or permission, does not lift an exhausted account, and a launch that is not reserved refuses it. `routing.unavailable_pi_providers` (default empty) lists Pi model prefixes that the owner marks unavailable, for example `magpie/anthropic`. A prefix matches a seat model only at a `/` boundary. While the list is non-empty, a Pi seat with a null model is unavailable too, because Pi then picks its own default provider. Routing skips each unavailable seat, the route, gatekeeper, reviewer and advisor lines of `rh quota` give the reason, and its launch refuses with `seat_provider_unavailable`. For a null model the reason says to give the seat an explicit model or to empty the list. `tight` is a display state only. When Claude is reserved, the explorer line uses `routing.low_quota_explorer` (default `haiku` high). Pass its model when you call the explorer. Otherwise the line says `default`.
84
84
 
85
- `routing.claude_saving_below_remaining` defaults to 20. Claude saving mode applies when weekly remaining quota is below that percent. `routing.claude_hyper_at_or_above_remaining` defaults to 50. Claude hyper mode applies when weekly remaining quota is at or above that percent and saving does not apply; otherwise its mode is normal. Only in Claude hyper does the advisor take its config entry; in normal, saving, exhausted and unknown it uses `opus` high, and the `advisor:` line of `rh quota` names it. Claude hyper routes workers as normal and does not change the orchestrator entry. `routing.codex_hyper_at_or_above_remaining` defaults to 50. Codex hyper mode applies when weekly remaining quota is at or above that percent; otherwise its mode is normal. A missing weekly reading gives an unknown mode. Quota modes are derived, never stored; the credit mode is the one stored owner choice. Codex hyper uses the code constant `gpt-6-astra` high for Codex seats, except `gatekeeper-deep`, which keeps its configured model and effort in hyper. Reserved Claude advisor and orchestrator seats use `opus` high. There is no Codex advisor fallback. A Pi seat on `magpie/codex/` gets the Codex hyper model as `magpie/codex/gpt-6-astra` with the hyper effort; the `gatekeeper-deep` exemption holds for a Pi `magpie/codex/` seat too. Other Pi seats, tools, fleet and class lists stay as configured. An absent seats section uses defaults. Run `rh update` for the one-shot migration of stored sections. The decoder refuses old keys before and after migration; a POST writes the full section.
85
+ `routing.claude_saving_below_remaining` defaults to 20. Claude saving mode applies when weekly remaining quota is below that percent. `routing.claude_hyper_at_or_above_remaining` defaults to 50. Claude hyper mode applies when weekly remaining quota is at or above that percent and saving does not apply; otherwise its mode is normal. Only in Claude hyper does the advisor take its config entry; in normal, saving, exhausted and unknown it uses `opus` high, and the `advisor:` line of `rh quota` names it. Claude hyper routes workers as normal and does not change the orchestrator entry. Codex seats and Pi seats on `magpie/codex/` keep their configured model and effort at every quota level. A Codex or Pi advisor keeps its own configured model and effort too. A missing weekly reading gives an unknown mode. Quota modes are derived, never stored; the credit mode is the one stored owner choice. Reserved Claude advisor and orchestrator seats use `opus` high. Other Pi seats, tools, fleet and class lists stay as configured. An absent seats section uses defaults. Run `rh update` for the one-shot migration of stored sections. The decoder refuses old keys before and after migration; a POST writes the full section.
86
86
 
87
87
  With `--repository-id`, the argv labels its own terminal before the agent starts: it runs `rh seats label`, which sets the seat labels on `HC_TERMINAL_ID`, and then starts the agent. The board finds seats only by these labels; a terminal without them leaves the execution axis `unavailable` (`no_seat_terminals`). When the label fails, the agent does not start and the terminal shows the error. Each start prints the new `terminal`. `<repository-id>` is the GitHub numeric repository id (`gh api repos/<owner>/<repo> --jq .id`). Leave out `--issue` and `--pr` for the orchestrator and the advisor.
88
88
 
@@ -37,9 +37,9 @@ Other documents link here. They do not copy this table.
37
37
  | Route | Matcher | Host | Typed handler | Responsibility |
38
38
  | --- | --- | --- | --- | --- |
39
39
  | `SessionStart.default` | all sessions | Claude, Codex | `session-context` | Emit the Effective State section first, then the edit-guard-scope, architecture-debt and pending-plan sections under one budget. |
40
- | `PreToolUse.edit` | `Edit\|Write` | Claude, Codex | `mutation-guard` | Block an `Edit`, `Write` or Codex `apply_patch` target outside the repository, under `_ref/` or `_ops/`, or without a parseable target path. Bash writes skip it; see [Edit guard coverage](#edit-guard-coverage). |
40
+ | `PreToolUse.edit` | `Edit\|Write` | Claude, Codex | `mutation-guard` | Safety hook: block an `Edit`, `Write` or Codex `apply_patch` removal or overwrite of an existing user file outside the worktree and temp roots (I2), or input without a parseable target path. See [Safety hook coverage](#safety-hook-coverage). |
41
41
  | `PreToolUse.subagent` | `Agent` | Claude | `return-channel` | Append the return-channel contract and standing orders to a Claude `Agent` prompt. |
42
- | `PreToolUse.bash` | `Bash` | Claude | `bash-mutation-guard` | Deny a literal write destination under `_ops/`, `_ref/` or outside the repository, and whole-repository recursion (`git clean -x`, `find -delete`, `rm -r` of the root). A command that names `_ops` or `_ref` runs only as simple read-only commands; any other shell form is denied. |
42
+ | `PreToolUse.bash` | `Bash` | Claude | `bash-mutation-guard` | Safety hook: deny a credential read (I1), a removal or overwrite of an existing user file outside the worktree and temp roots (I2), and whole-repository recursion (`git clean -x`, `find -delete`, `rm -r` of the root). |
43
43
  | `UserPromptSubmit.inbox` | all prompts | Claude, Codex | `agent-notice` | Deliver architecture debt on Codex; Claude emits nothing. |
44
44
  | `SubagentStart.context` | subagent start | Codex | `subagent-context` | Record the native role and model observation. Add the bounded child context and standing orders. |
45
45
  | `Stop.default` | session stop | Claude, Codex | `stop` | Publish the evidence checkpoint and render handoff and resume. Report protected path changes. Claude can get architecture debt. |
@@ -187,68 +187,88 @@ When a hook blocks work:
187
187
  and elapsed time of each hook event.
188
188
  4. Use the external runbook for extended examples and historical failure modes.
189
189
 
190
- Edit guards:
191
-
192
- - `RepoScopeGuard`: the target path is not a canonical path inside the
193
- repository.
194
- - `ExternalReferenceGuard`: the target is under `_ref/`.
195
- - `OpsPrivateGuard`: the target is under `_ops/`. A repository can list
196
- directories strictly below `_ops/` in `operations.agent_writable_private_dirs`
197
- of `.ai/harness/policy.json`, for example `["_ops/dispatch"]`. Edit, Write and
198
- apply_patch writes below a listed directory pass. Bash writes there stay
199
- denied, because Bash targets come from text. The guard denies a listed target
200
- unless it is written as its canonical repository path: a root alias, another
201
- letter case, a `.` or `..` segment, or an existing symlink that resolves
202
- inside the repository changes the spelling. It also denies a glob character
203
- and a dangling symlink at or below the listed directory. A symlink that
204
- resolves outside the repository follows the ordinary external-path rule for
205
- Edit and Write. An invalid entry denies every `_ops/`
206
- write and the reason names the entry. Stop still reports these changes.
190
+ Safety hook guards:
191
+
192
+ - `CredentialGuard` (I1): a call prints or sends a credential store: an SSH
193
+ private key or the `.ssh` directory, `auth.json`, `*credentials*.json`, a
194
+ `.env*` file other than `.env.example`, `.env.sample` or `.env.template`, a
195
+ keychain dump (`security dump-keychain`, `security find-*-password -w` or
196
+ `-g`), or the whole environment (`env` with no command, `printenv` with no
197
+ name). The hook judges the file operands that each program reads, after
198
+ quote removal and brace expansion. A glob counts when it can match a
199
+ credential name in its directory. A curl `@file`, `field=@file` or
200
+ `field=<file` value is a send. Programs that read no file content (`ls`,
201
+ `stat`, `test`, `chmod`, `rm`, `mv`, `cd`, `echo`, `source`, `ssh-add` and
202
+ similar), a grep pattern (also `-e` and `--regexp`), a `cp` destination, a git
203
+ path filter (`git status`, `ls-files`, `log` without `-p`), an `--env-file`
204
+ value and an `ssh -i` identity pass. Secret redaction stays as the second
205
+ layer.
206
+ - `UserFileGuard` (I2): a call removes or overwrites an existing file outside
207
+ the worktree, the managed worktree root (`/tmp` on POSIX unless
208
+ `REPO_HARNESS_WORKTREE_ROOT` moves it), the system temp directory and the
209
+ host agent's own memory and plan directories (Claude
210
+ `~/.claude/projects/*/memory` and `~/.claude/plans`, Codex
211
+ `~/.codex/memories`; the rest of `~/.claude`, `~/.codex` and `~/.pi` stays
212
+ protected), and the install ledger in `~/.repo-harness/install-state.json` does not record the
213
+ file, or a directory tree above it, as rh-created. A create or an append
214
+ passes everywhere. A removal (`rm`, `unlink`, `shred`, `truncate`, each `mv`
215
+ operand, `sed -i`, `find -delete`) whose target is not known before the
216
+ command runs is refused; an overwrite with an unknown target passes. A
217
+ target with a glob or a parameter is judged by its literal directory before
218
+ the first such character (a leading `$HOME` or `~` is literal): inside an
219
+ allowed root it passes, and an existing directory outside them takes the
220
+ outside rule. The hook checks every simple command, also after `then`, `do`, `else`, `&&`,
221
+ `||`, `;`, `|`, a newline and inside a subshell. A `cd` narrows the working
222
+ directory only when `&&` follows it, `||` does not come before it and its
223
+ directory exists; after any other `cd` the working directory is not known. A target resolves as the kernel
224
+ resolves it: each symlink before the `..` after it, and the existing child
225
+ that a `cp` or redirect into a directory writes. In a
226
+ Claude session whose `permission_mode` is not `bypassPermissions` or
227
+ `dontAsk`, the hook returns the host's ask decision and the user answers
228
+ locally. A bypass or `dontAsk` session (the owner's own bypass sessions
229
+ included), a payload without a mode, Codex and the Pi bridge get the deny;
230
+ the bridge renders an ask as a block. The deny names every allowed root and
231
+ the step the user can take: the exact `! <command>` line for a one-line Bash
232
+ command, or the target path that the user can edit themselves. The prompt,
233
+ stderr and the failure record get the reason and fix after secret
234
+ redaction; a command that holds a secret shows its redacted form, or no
235
+ command when the redaction leaves a secret.
236
+ - `RecursiveDeleteGuard`: `rm -r`, `find -delete` or `find -exec` with a program
237
+ that is not a reader, or `git clean -x`/`-X` starts at the repository root, an
238
+ ancestor of it, or a start that is not known.
207
239
  - `ApplyPatchScopeGuard`: Codex `apply_patch` input has no parseable target
208
240
  path.
209
241
  - `EditScopeGuard`: an `Edit` or `Write` call has no `tool_input.file_path`.
210
242
 
211
- ### Edit guard coverage
243
+ ### Safety hook coverage
212
244
 
213
245
  `PreToolUse.edit` matches `Edit|Write`. On Codex it also reads `apply_patch`
214
- input. Claude also has a separate `PreToolUse.bash` tripwire in both install
215
- profiles. Codex shell tools have no Bash route. The tripwire is not a complete
216
- shell parser. Bash writes get no `[CapabilityOwner]` line. #764 and #766 removed
246
+ input: `Add File` and `Move to` create or replace a file, `Update File` and
247
+ `Delete File` need an existing file. Claude and Pi also run the safety hook on
248
+ `PreToolUse.bash` in both install profiles. Codex shell tools have no Bash
249
+ route. Bash writes get no `[CapabilityOwner]` line. #764 and #766 removed
217
250
  `PostToolUse.bash` after each call paid about 5 seconds. That route stays absent.
218
251
 
219
- The Bash handler checks command strings without Effective State, Git or owner
220
- resolution. Only a suspicious literal destination runs the shared path guard.
221
- It recognizes `>` and `>>`, `tee -a`, single-file `sed -i`, `rm`, `mv`, `cp`
222
- destinations, and literal Python `open`/`Path` and Node file-write calls in
223
- `-c`/`-e` source or a heredoc. Read operands and quoted shell examples do not
224
- count as writes. A literal `cd DIR &&` changes the target base. Other `cd` forms
225
- leave subsequent relative targets unchecked. A glob below a literal
226
- protected directory also triggers the check.
227
-
228
- A known `_ops/`, `_ref/` or outside-repository destination gets exit 2 and the
229
- same guard diagnostic and failure record as an edit. Bash uses a repository-only
230
- boundary; Edit/Write retains its verified external absolute-path allowance.
231
- `/dev/null`, `/dev/stdout`, `/dev/stderr`, `/dev/tty` and numeric `/dev/fd/N`
232
- targets are output streams and pass.
233
-
234
- Missing absolute host `cwd`, commands above 64 KiB, variable expansion,
235
- grouping, unsupported options, indirect scripts, code generators, `eval`,
236
- `sh -c`, `git checkout`, `find` and `xargs` can skip the tripwire. Symlink aliases
237
- without a protected or external path token can also skip it. Interpreter checks
238
- recognize literal call text; they do not evaluate Python or JavaScript control
239
- flow. The unparsed remainder passes. A handler failure exits 1 and does not block.
240
- More than one heredoc on a line or an unresolved delimiter leaves the remaining
241
- command unchecked. Earlier parsed targets still get checked. This is a tripwire,
242
- not proof that an allowed command cannot write private files.
243
-
244
- The `edit-guard-scope` SessionStart section tells the Agent this limit on every
245
- host, also when Effective State is unavailable: Claude Bash has only a literal
246
- tripwire; use the edit tools to change
247
- repository files, and use Bash to run commands.
248
-
249
- Stop reports a change under `_ops/` or `_ref/` after the fact. The guard denies
250
- every `Edit`, `Write` and `apply_patch` target there, so a change there came from
251
- Bash, a script or the person. The report cannot tell which one. It does not block.
252
+ The Bash handler reads the command line without Effective State, Git or owner
253
+ resolution. It is a shell word reader, not a shell interpreter. It reads quotes,
254
+ substitution bodies, heredocs, redirects and `cd` before each simple command.
255
+ It recognizes `>`, `>|` and `&>` redirects, `rm`, `unlink`, `shred`, `truncate`,
256
+ `mv`, `cp`, `ln -f`, `tee` without `-a`, `sed -i`, `dd of=`, `find -delete`, and
257
+ literal Python `open`/`Path`/`os.remove` and Node file-write or unlink calls in
258
+ `-c`/`-e` source or a heredoc. `$HOME` and `~` resolve to the home directory;
259
+ other parameters, `~user` and `~-` are not known. A glob removes entries below
260
+ its literal directory, so that directory decides. Paths under `/dev/` pass.
261
+
262
+ The threat model is accidents. A target built at run time for an overwrite, a
263
+ script or binary that writes, `xargs`, `eval` and `sh -c` can skip the hook. A
264
+ handler failure on the Bash route exits 1 and does not block.
265
+
266
+ The `edit-guard-scope` SessionStart section tells the Agent this scope on every
267
+ host, also when Effective State is unavailable.
268
+
269
+ Stop reports a change under `_ops/` or `_ref/` after the fact. Agent edits,
270
+ Bash, scripts and the person can all change these directories. The report
271
+ cannot tell which one. It does not block.
252
272
 
253
273
  - Stop walks `_ops/` and `_ref/` with `lstat`. It does not follow symbolic links.
254
274
  It records the size and mtime of each entry in the Git-ignored
@@ -391,8 +411,9 @@ Git-ignored` line and one human `systemMessage`. This line takes the place of
391
411
  the notice text, because no marker can deduplicate that text. Claude Stop and
392
412
  Codex UserPromptSubmit keep only the stderr diagnostic of a failed marker write.
393
413
  Without a marker, the line would repeat at each turn, and each Claude Stop line
394
- starts one more turn. Run `rh update`; it writes the runtime-state
395
- block to the user-level Git excludes file.
414
+ starts one more turn. Run `rh init` to register the repository, then
415
+ `rh update`; it writes the runtime-state block to the repository's
416
+ `.git/info/exclude`.
396
417
 
397
418
  | Point | Hosts | When |
398
419
  | --- | --- | --- |
@@ -50,7 +50,7 @@ Both the opt-in probe and hook child remove inherited repository-selecting Git v
50
50
 
51
51
  The bridge starts this package's `dist/hook-entry.js` with Bun. It removes inherited `HOOK_*`, `REPO_HARNESS_SOURCE_ROOT`, `REPO_HARNESS_HELPER_SOURCE_PATH` and `REPO_HARNESS_TARGET_REPO_ROOT`, then sets `HOOK_HOST=pi`. Other configuration variables, including `REPO_HARNESS_HOME`, pass through as they do for Claude and Codex. Every route has a 30-second deadline. Input is limited to 16 MiB and stdout to 1 MiB. The bridge accepts one protocol-1 object. A block, nonzero hook exit, malformed response, timeout or child failure blocks the mapped mutation. The bridge does not retry. Hook stdout stays inside the bridge; Pi stdout receives no hook log.
52
52
 
53
- Pi's `powershell` tool on Windows is out of scope and is not mapped to the Bash guard. The extension also does not cover `!`/`!!` user shell commands, writes from other extensions, or third-party MCP writes. Bash coverage is the existing literal-write tripwire; unparsed shell commands can bypass it. This is not an OS sandbox. Later Pi extensions can mutate tool arguments; this integration does not establish a final gate after all extensions. If a hook returns `permission.updatedInput`, the extension blocks with `PI_HOST_UPDATED_INPUT_UNSUPPORTED`. Input mutation remains an open problem.
53
+ Pi's `powershell` tool on Windows is out of scope and is not mapped to the Bash guard. The extension also does not cover `!`/`!!` user shell commands, writes from other extensions, or third-party MCP writes. Bash coverage is the safety hook's shell word reader; a script or a target built at run time can bypass it. This is not an OS sandbox. Later Pi extensions can mutate tool arguments; this integration does not establish a final gate after all extensions. If a hook returns `permission.updatedInput`, the extension blocks with `PI_HOST_UPDATED_INPUT_UNSUPPORTED`. Input mutation remains an open problem.
54
54
 
55
55
  The resolver is a private SDK file. An upstream public export is still needed. When Pi exports it, replace the private import and remove that path in one change. `tests/pi-extension.test.ts` uses the real SDK, real tools and a scripted provider fixture. It proves the covered boundary without making a real-provider acceptance claim.
56
56
 
@@ -97,7 +97,8 @@
97
97
  "v0.31.0",
98
98
  "v0.32.0",
99
99
  "v0.33.0",
100
- "v0.33.1"
100
+ "v0.33.1",
101
+ "v0.33.2"
101
102
  ],
102
103
  "packageScripts": {
103
104
  "check:architecture-sync": [
@@ -338,6 +339,9 @@
338
339
  "sha256:fd30d8e8c95f5d49710080b4e10b949c2fe5dbbccc6aa489f76fdbc6a60cda81",
339
340
  "sha256:fe457138234cbaece11699df62e7df032466f48e18ca6a00ccc530ed7c4e7e12"
340
341
  ],
342
+ "change-assessment": [
343
+ "sha256:24140a32ae76ee7ca5b8719dfac4e308e401922ce006c529aecab7e4041af9f3"
344
+ ],
341
345
  "changelog-versioning": [
342
346
  "sha256:00120466c9e9851e613b7d1511cb95fae0222e5ac3abe6fb456a6c2df48027e1",
343
347
  "sha256:05e057a715f58bb4257c3a08fbe812998ef249edd2812a101f39870e0837e2bf",
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.33.2",
3
- "templateVersion": "0.33.2",
2
+ "version": "0.34.0",
3
+ "templateVersion": "0.34.0",
4
4
  "skillName": "repo-harness",
5
5
  "contractId": "tasks-first-harness-v1",
6
6
  "compatibility": {
@@ -297,7 +297,7 @@ module is in the title so that a list view shows the write scopes.
297
297
  Before each dispatch wave, run `rh quota`. It prints the account
298
298
  states, one mode line per account and one route line per task class. For
299
299
  example: `claude mode: saving (5% left < 20%)` and
300
- `codex mode: hyper (68% left >= 50%)`. Launch each task on the seat its
300
+ `codex mode: normal (68% left)`. Launch each task on the seat its
301
301
  route line names with `rh seats argv <seat>`; state the boundary
302
302
  in the task. A `none` route waits, or it changes through the seats
303
303
  configuration: the owner sets the seat order and each fallback there, and
@@ -319,12 +319,10 @@ every other Claude mode it uses `opus` high. Claude hyper changes no worker
319
319
  route and not the orchestrator entry. The `advisor:` line of
320
320
  `rh quota` names the advisor model. A seat that runs takes a new
321
321
  model only at a tier-2 reset (`/clear`), where `seats reset` starts it again
322
- from its argv; see Seat reset in herdr-notify. Codex hyper mode applies
323
- when weekly remaining quota is at or above
324
- `routing.codex_hyper_at_or_above_remaining` (default 50). Quota modes are
325
- derived, never stored. Codex hyper seats use `gpt-6-astra` high, except `gatekeeper-deep`, which
326
- keeps its configured model and effort. A Pi seat on `magpie/codex/` takes the
327
- same hyper model as `magpie/codex/gpt-6-astra` with that effort.
322
+ from its argv; see Seat reset in herdr-notify. Codex seats and Pi seats on
323
+ `magpie/codex/` keep their configured model and effort at every quota level.
324
+ A Codex or Pi advisor keeps its own configured model and effort too. Quota
325
+ modes are derived, never stored.
328
326
 
329
327
  Claude in saving mode or exhausted is reserved for the advisor and
330
328
  orchestrator; both use `opus` high. An important non-frontend route that
@@ -39,7 +39,7 @@ and keeps going after a failure, then prints `[ci] failed test files (N):`.
39
39
 
40
40
  ## The gate lanes
41
41
 
42
- `scripts/check-ci.sh [affected|all|governance|functional|architecture]` defaults to `affected`.
42
+ `scripts/check-ci.sh [affected|all|governance|functional|architecture]` defaults to `affected`. `ledger --base <ref>` runs LedgerEnforcement on `tasks/lessons.md`.
43
43
  PR checks select affected tests. Daily CI selects `governance`, `architecture`
44
44
  and `functional` as separate jobs. The release gate selects `all`, which runs
45
45
  all three.
@@ -1720,7 +1720,7 @@ export type PolicyKeyTree = {
1720
1720
  export const WORKFLOW_POLICY_KEYS = {
1721
1721
  tasks: { research_dir: true },
1722
1722
  external_sources: {},
1723
- operations: { agent_writable_private_dirs: true, deploy_sql: {} },
1723
+ operations: { deploy_sql: {} },
1724
1724
  context: { map_file: true, capability_source: true },
1725
1725
  harness: { runs_dir: true },
1726
1726
  information_lifecycle: {