repo-harness 0.19.0 → 0.19.2

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 (108) hide show
  1. package/AGENTS.md +14 -38
  2. package/CLAUDE.md +14 -38
  3. package/README.es.md +2 -2
  4. package/README.fr.md +2 -2
  5. package/README.ja.md +2 -2
  6. package/README.md +7 -2
  7. package/README.zh-CN.md +2 -2
  8. package/agents/fleet/gatekeeper.md +3 -3
  9. package/assets/AGENTS.md +8 -8
  10. package/assets/CLAUDE.md +8 -8
  11. package/assets/hooks/lib/workflow-state.sh +4 -1
  12. package/assets/reference-configs/agentic-development-flow.md +1 -0
  13. package/assets/reference-configs/external-tooling.md +79 -11
  14. package/assets/reference-configs/hook-operations.md +46 -0
  15. package/assets/reference-configs/release-deploy.md +7 -0
  16. package/assets/reference-configs/sprint-contracts.md +191 -19
  17. package/assets/skill-commands/manifest.json +41 -1
  18. package/assets/skill-commands/repo-harness-architecture/SKILL.md +53 -4
  19. package/assets/skill-version.json +2 -2
  20. package/assets/skills/auto-campaign/SKILL.md +75 -0
  21. package/assets/skills/auto-campaign/references/execution.md +93 -0
  22. package/assets/skills/auto-campaign/references/standard.json +36 -0
  23. package/assets/skills/auto-campaign/scripts/prepare-grant.ts +39 -0
  24. package/assets/skills/repo-harness-test/SKILL.md +32 -0
  25. package/assets/skills/repo-harness-test/references/authoring.md +124 -0
  26. package/assets/skills/repo-harness-test/references/refactor-evidence.md +67 -0
  27. package/assets/skills/repo-harness-test/references/running.md +94 -0
  28. package/assets/skills/repo-harness-test/references/verification-plan.md +72 -0
  29. package/assets/templates/contract.template.md +21 -36
  30. package/assets/templates/helpers/architecture-event.ts +1 -3
  31. package/assets/templates/helpers/check-agent-tooling.sh +7 -3
  32. package/assets/templates/helpers/check-architecture-sync.sh +40 -20
  33. package/assets/templates/helpers/check-task-sync.sh +5 -0
  34. package/assets/templates/helpers/contract-worktree.sh +8 -2
  35. package/assets/templates/helpers/ensure-task-workflow.sh +0 -5
  36. package/assets/templates/helpers/evidence-gc.ts +198 -0
  37. package/assets/templates/helpers/install-agent-fleet.sh +11 -0
  38. package/assets/templates/helpers/verify-sprint.sh +6 -3
  39. package/assets/templates/review.template.md +11 -6
  40. package/assets/workflow-contract.v1.json +2 -0
  41. package/dist/hook-entry.js +12317 -11162
  42. package/dist/operator-ui/assets/index-B8ckyb8w.js +9 -0
  43. package/dist/operator-ui/assets/index-BpvUpmy-.css +1 -0
  44. package/dist/operator-ui/index.html +2 -2
  45. package/package.json +1 -1
  46. package/scripts/architecture-event.ts +1 -3
  47. package/scripts/axr5-archctx-clean-room.ts +4 -6
  48. package/scripts/axr6-stop-host-cycle.ts +2 -4
  49. package/scripts/check-agent-tooling.sh +7 -3
  50. package/scripts/check-architecture-sync.sh +40 -20
  51. package/scripts/check-ci.sh +6 -0
  52. package/scripts/check-tarball-install-smoke.sh +7 -4
  53. package/scripts/check-task-sync.sh +5 -0
  54. package/scripts/ci-documentation-consumers.ts +168 -0
  55. package/scripts/contract-worktree.sh +8 -2
  56. package/scripts/ensure-task-workflow.sh +0 -5
  57. package/scripts/evidence-gc.ts +198 -0
  58. package/scripts/install-agent-fleet.sh +11 -0
  59. package/scripts/lib/ci-run-tests.sh +170 -18
  60. package/scripts/lib/project-init-lib.sh +0 -5
  61. package/scripts/replay-ci-coverage.ts +34 -0
  62. package/scripts/run-harness-profile-benchmark.ts +2 -1
  63. package/scripts/select-ci-coverage.ts +83 -0
  64. package/scripts/verify-sprint.sh +6 -3
  65. package/src/cli/commands/architecture-configuration.ts +19 -0
  66. package/src/cli/commands/architecture-projection.ts +11 -3
  67. package/src/cli/commands/fleet.ts +13 -0
  68. package/src/cli/commands/global-runtime.ts +9 -0
  69. package/src/cli/commands/init.ts +60 -8
  70. package/src/cli/commands/refactor-recommendation-configuration.ts +13 -0
  71. package/src/cli/commands/refactor.ts +12 -0
  72. package/src/cli/commands/run.ts +2 -1
  73. package/src/cli/hook/session-context-budget.ts +1 -0
  74. package/src/cli/hook/session-context.ts +52 -1
  75. package/src/cli/hook/stop-handler.ts +27 -4
  76. package/src/cli/index.ts +1 -1
  77. package/src/cli/installer/install-profile.ts +3 -3
  78. package/src/cli/installer/uninstall.ts +3 -3
  79. package/src/core/adoption/standard-plan.ts +15 -0
  80. package/src/core/engineers/AGENTS.md +1 -1
  81. package/src/core/engineers/CLAUDE.md +1 -1
  82. package/src/core/operator/fleet-snapshot.ts +7 -3
  83. package/src/core/operator/task-diff.ts +55 -0
  84. package/src/effects/architecture/archctx-provider.ts +13 -30
  85. package/src/effects/architecture/projection-config.ts +33 -0
  86. package/src/effects/architecture/projection-orchestrator.ts +2 -2
  87. package/src/effects/automation/campaign-runtime.ts +12 -0
  88. package/src/effects/automation/campaign-worker.ts +24 -5
  89. package/src/effects/automation/issue-batch-observer.ts +1 -1
  90. package/src/effects/configuration/global-configuration.ts +18 -0
  91. package/src/effects/evidence/checkpoint-store.ts +7 -1
  92. package/src/effects/external-sources/refresh.ts +1 -1
  93. package/src/effects/operator/server.ts +73 -0
  94. package/src/effects/operator/task-diff-worker.ts +7 -0
  95. package/src/effects/operator/task-diff.ts +122 -0
  96. package/src/effects/refactor/recommendation-settings.ts +13 -0
  97. package/src/effects/refactor/recommendations.ts +128 -0
  98. package/src/effects/repo-registry.ts +45 -0
  99. package/src/effects/run-summary-retention.ts +204 -0
  100. package/src/effects/runtime/helper-runner.ts +3 -0
  101. package/src/operator-web/App.tsx +57 -11
  102. package/src/operator-web/TaskDiff.tsx +56 -0
  103. package/src/operator-web/fixture.ts +2 -1
  104. package/src/operator-web/i18n.ts +42 -4
  105. package/src/operator-web/styles.css +11 -0
  106. package/src/operator-web/types.ts +4 -2
  107. package/dist/operator-ui/assets/index-Bo3Q_Lye.css +0 -1
  108. package/dist/operator-ui/assets/index-D3I9okzi.js +0 -9
package/AGENTS.md CHANGED
@@ -58,16 +58,19 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
58
58
 
59
59
  ## Required Checks
60
60
 
61
- Verification is risk-scoped. The active task contract's JSON `Verification Plan`
62
- owns executable checks; `exit_criteria` owns artifact requirements. Run focused
63
- tests for every changed behavior. The following repository-integrity checks are required for
64
- substantive repository changes; `check:hooks` and `check:helpers` catch a
65
- projection edited without its authoring source in `scripts/`, so that drift fails
66
- here instead of only in `scripts/check-ci.sh governance`:
61
+ Follow [Testing Policy and Artifact Standards](docs/reference-configs/sprint-contracts.md#testing-policy-and-artifact-standards)
62
+ for test selection, new test/file admission, full-suite justification, evidence
63
+ reuse and test-document creation. The contract's JSON `Verification Plan` is
64
+ its sole executable authority; `exit_criteria` owns artifact requirements.
65
+
66
+ The following repository-integrity checks remain required for substantive
67
+ repository changes. Projection checks protect the authoring sources in
68
+ `scripts/`, `assets/hooks/` and `assets/reference-configs/`:
67
69
 
68
70
  ```bash
69
71
  bun run check:hooks
70
72
  bun run check:helpers
73
+ bun run check:reference-configs
71
74
  bash scripts/check-deploy-sql-order.sh
72
75
  bash scripts/check-architecture-sync.sh
73
76
  bash scripts/check-task-sync.sh
@@ -76,37 +79,10 @@ bun scripts/inspect-project-state.ts --repo . --format text
76
79
  bun src/cli/index.ts init --repo . --dry-run
77
80
  ```
78
81
 
79
- Use focused regression tests and the repository-integrity checks above by
80
- default, including small code and test changes. Run the full
81
- `bun test --timeout 60000` suite only when the active contract or release gate
82
- explicitly requires it, or observed cross-module impact cannot be covered by
83
- named focused checks. A code/test path, diff size, review depth, or changed
84
- verification script alone is not sufficient justification. Before an expensive
85
- run, state the uncovered risk, why narrower checks are insufficient, and the
86
- expected cost. When authoring a contract, apply these same conditions before
87
- adding a full-suite criterion; copying an unconditional command is not a risk
88
- assessment.
89
-
90
- Freeze the implementation before final acceptance. Execute required expensive
91
- criteria through `verify-sprint --prepare-acceptance`; declare each executable
92
- check once in the JSON `Verification Plan`, including phase, cost, evidence
93
- policy, necessity, and environment inputs. Unchanged retries consume recorded
94
- execution evidence. Expensive input drift requires an explicit new plan or
95
- rerun reason; a cache miss never grants permission to rerun. Reviewers consume that evidence rather than
96
- independently rerunning the suite. Do not list the same test coverage twice in
97
- the final contract; focused development runs are separate from final acceptance.
98
- Record changed paths, checks run or reused, and why that coverage is sufficient.
99
- CI and explicit release gates retain their required checks.
100
-
101
- After a passing full suite, a subsequent bounded change does not automatically
102
- require another full run. Retain the baseline run identity, inspect the actual
103
- delta, and run its regression/affected checks. The parent updates the contract's
104
- final criteria to that delta coverage when the full-suite trigger no longer
105
- applies, recording the baseline and coverage rationale in Acceptance Notes.
106
- Do not waive an explicit user/release requirement. An old full-suite pass remains
107
- baseline evidence for its original subject, never a full-suite pass for the new
108
- subject. Repeat the full suite only for an uncovered integration risk or an
109
- explicit requirement for that new subject; a cache miss alone is not a trigger.
82
+ Run focused coverage for changed behavior. Existing CI/release gates retain
83
+ their checks. Apply the linked policy before declaring an expensive/full run
84
+ or a new test document; reviewers consume canonical evidence rather than
85
+ independently repeating it.
110
86
 
111
87
  <!-- BEGIN ARCHITECTURE CONTRACT -->
112
88
  ## Architecture Contract
@@ -130,7 +106,7 @@ explicit requirement for that new subject; a cache miss alone is not a trigger.
130
106
  - Verification: Use root required checks plus local commands recorded in this capability contract.
131
107
  - Latest snapshot: `(none yet)`
132
108
  - Semantic diagram source: `docs/architecture/modules/runtime-harness/automation-budget.md`
133
- - Pending architecture request: `docs/architecture/requests/runtime-harness-automation-budget.md`
109
+ - Pending architecture request: `(none)`
134
110
 
135
111
  ## Active Workstreams
136
112
 
package/CLAUDE.md CHANGED
@@ -58,16 +58,19 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
58
58
 
59
59
  ## Required Checks
60
60
 
61
- Verification is risk-scoped. The active task contract's JSON `Verification Plan`
62
- owns executable checks; `exit_criteria` owns artifact requirements. Run focused
63
- tests for every changed behavior. The following repository-integrity checks are required for
64
- substantive repository changes; `check:hooks` and `check:helpers` catch a
65
- projection edited without its authoring source in `scripts/`, so that drift fails
66
- here instead of only in `scripts/check-ci.sh governance`:
61
+ Follow [Testing Policy and Artifact Standards](docs/reference-configs/sprint-contracts.md#testing-policy-and-artifact-standards)
62
+ for test selection, new test/file admission, full-suite justification, evidence
63
+ reuse and test-document creation. The contract's JSON `Verification Plan` is
64
+ its sole executable authority; `exit_criteria` owns artifact requirements.
65
+
66
+ The following repository-integrity checks remain required for substantive
67
+ repository changes. Projection checks protect the authoring sources in
68
+ `scripts/`, `assets/hooks/` and `assets/reference-configs/`:
67
69
 
68
70
  ```bash
69
71
  bun run check:hooks
70
72
  bun run check:helpers
73
+ bun run check:reference-configs
71
74
  bash scripts/check-deploy-sql-order.sh
72
75
  bash scripts/check-architecture-sync.sh
73
76
  bash scripts/check-task-sync.sh
@@ -76,37 +79,10 @@ bun scripts/inspect-project-state.ts --repo . --format text
76
79
  bun src/cli/index.ts init --repo . --dry-run
77
80
  ```
78
81
 
79
- Use focused regression tests and the repository-integrity checks above by
80
- default, including small code and test changes. Run the full
81
- `bun test --timeout 60000` suite only when the active contract or release gate
82
- explicitly requires it, or observed cross-module impact cannot be covered by
83
- named focused checks. A code/test path, diff size, review depth, or changed
84
- verification script alone is not sufficient justification. Before an expensive
85
- run, state the uncovered risk, why narrower checks are insufficient, and the
86
- expected cost. When authoring a contract, apply these same conditions before
87
- adding a full-suite criterion; copying an unconditional command is not a risk
88
- assessment.
89
-
90
- Freeze the implementation before final acceptance. Execute required expensive
91
- criteria through `verify-sprint --prepare-acceptance`; declare each executable
92
- check once in the JSON `Verification Plan`, including phase, cost, evidence
93
- policy, necessity, and environment inputs. Unchanged retries consume recorded
94
- execution evidence. Expensive input drift requires an explicit new plan or
95
- rerun reason; a cache miss never grants permission to rerun. Reviewers consume that evidence rather than
96
- independently rerunning the suite. Do not list the same test coverage twice in
97
- the final contract; focused development runs are separate from final acceptance.
98
- Record changed paths, checks run or reused, and why that coverage is sufficient.
99
- CI and explicit release gates retain their required checks.
100
-
101
- After a passing full suite, a subsequent bounded change does not automatically
102
- require another full run. Retain the baseline run identity, inspect the actual
103
- delta, and run its regression/affected checks. The parent updates the contract's
104
- final criteria to that delta coverage when the full-suite trigger no longer
105
- applies, recording the baseline and coverage rationale in Acceptance Notes.
106
- Do not waive an explicit user/release requirement. An old full-suite pass remains
107
- baseline evidence for its original subject, never a full-suite pass for the new
108
- subject. Repeat the full suite only for an uncovered integration risk or an
109
- explicit requirement for that new subject; a cache miss alone is not a trigger.
82
+ Run focused coverage for changed behavior. Existing CI/release gates retain
83
+ their checks. Apply the linked policy before declaring an expensive/full run
84
+ or a new test document; reviewers consume canonical evidence rather than
85
+ independently repeating it.
110
86
 
111
87
  <!-- BEGIN ARCHITECTURE CONTRACT -->
112
88
  ## Architecture Contract
@@ -130,7 +106,7 @@ explicit requirement for that new subject; a cache miss alone is not a trigger.
130
106
  - Verification: Use root required checks plus local commands recorded in this capability contract.
131
107
  - Latest snapshot: `(none yet)`
132
108
  - Semantic diagram source: `docs/architecture/modules/runtime-harness/automation-budget.md`
133
- - Pending architecture request: `docs/architecture/requests/runtime-harness-automation-budget.md`
109
+ - Pending architecture request: `(none)`
134
110
 
135
111
  ## Active Workstreams
136
112
 
package/README.es.md CHANGED
@@ -702,8 +702,8 @@ repositorio adopte la misma política.
702
702
 
703
703
  ## Versión actual
704
704
 
705
- - Paquete npm: `repo-harness@0.19.0`
706
- - Sello de workflow generado: `repo-harness@0.19.0+template@0.19.0`
705
+ - Paquete npm: `repo-harness@0.19.2`
706
+ - Sello de workflow generado: `repo-harness@0.19.2+template@0.19.2`
707
707
  - Repositorio de GitHub: `Ancienttwo/repo-harness`
708
708
  - Notas de versión e historial: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
709
709
 
package/README.fr.md CHANGED
@@ -697,8 +697,8 @@ adopte la même policy.
697
697
 
698
698
  ## Release actuelle
699
699
 
700
- - Package npm : `repo-harness@0.19.0`
701
- - Generated workflow stamp : `repo-harness@0.19.0+template@0.19.0`
700
+ - Package npm : `repo-harness@0.19.2`
701
+ - Generated workflow stamp : `repo-harness@0.19.2+template@0.19.2`
702
702
  - Dépôt GitHub : `Ancienttwo/repo-harness`
703
703
  - Notes et historique de release : [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
704
704
 
package/README.ja.md CHANGED
@@ -694,8 +694,8 @@ commit script や hooks に組み込まないでください。
694
694
 
695
695
  ## 現在の Release
696
696
 
697
- - npm package:`repo-harness@0.19.0`
698
- - Generated workflow stamp:`repo-harness@0.19.0+template@0.19.0`
697
+ - npm package:`repo-harness@0.19.2`
698
+ - Generated workflow stamp:`repo-harness@0.19.2+template@0.19.2`
699
699
  - GitHub repository:`Ancienttwo/repo-harness`
700
700
  - Release notes and history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
701
701
 
package/README.md CHANGED
@@ -120,6 +120,11 @@ bun test
120
120
 
121
121
  ### Success looks like this
122
122
 
123
+ Successful init enables automatic architecture document projection and proactive
124
+ Stop-hook refactor recommendations when those preferences are unset. Explicit
125
+ disabled choices are preserved. Suggestions present evidence for a user decision;
126
+ they do not authorize a refactor. Dry-run does not write these preferences.
127
+
123
128
  Apply ends with `=== Migration Report ===`, naming where generated hook behavior
124
129
  comes from, the user-level `~/.claude/settings.json` and `~/.codex/hooks.json`
125
130
  adapter target, the repo-local surfaces created or refreshed, the
@@ -660,8 +665,8 @@ repo-harness commit scripts or hooks unless that repo adopts the same policy.
660
665
 
661
666
  ## Current Release
662
667
 
663
- - npm package: `repo-harness@0.19.0`
664
- - Generated workflow stamp: `repo-harness@0.19.0+template@0.19.0`
668
+ - npm package: `repo-harness@0.19.2`
669
+ - Generated workflow stamp: `repo-harness@0.19.2+template@0.19.2`
665
670
  - GitHub repository: `Ancienttwo/repo-harness`
666
671
  - Release notes and history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
667
672
 
package/README.zh-CN.md CHANGED
@@ -630,8 +630,8 @@ commit script 或 hook,除非目标仓库采用同样的 policy。
630
630
 
631
631
  ## 当前 Release
632
632
 
633
- - npm package:`repo-harness@0.19.0`
634
- - Generated workflow stamp:`repo-harness@0.19.0+template@0.19.0`
633
+ - npm package:`repo-harness@0.19.2`
634
+ - Generated workflow stamp:`repo-harness@0.19.2+template@0.19.2`
635
635
  - GitHub repository:`Ancienttwo/repo-harness`
636
636
  - Release notes 和 history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
637
637
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: gatekeeper
3
- description: Read-only acceptance and ship gate on Opus at high effort. Use after execution workers deliver work: it reviews the diff against the goal, runs the project's real verification, and returns PASS/FAIL/BLOCKED with evidence and a ship recommendation. It never edits, commits, pushes, opens or merges PRs, or decides to ship; fixes and terminal actions stay with the orchestrator.
3
+ description: Read-only acceptance and ship gate on Opus at high effort. Use after execution workers deliver work: it reviews the diff against the goal, validates the project's verification evidence, and returns PASS/FAIL/BLOCKED with evidence and a ship recommendation. It never edits, commits, pushes, opens or merges PRs, or decides to ship; fixes and terminal actions stay with the orchestrator.
4
4
  tools: ["Read", "Grep", "Glob", "Bash"]
5
5
  model: opus
6
6
  effort: high
@@ -10,8 +10,8 @@ You are the read-only acceptance and ship gate. Execution workers deliver work;
10
10
 
11
11
  - **Verdict first.** Your opening line is exactly one of `VERDICT: PASS`, `VERDICT: FAIL`, `VERDICT: BLOCKED`. PASS means every gate is clean and you state the recommended next action without performing it. FAIL means blocking findings and nothing touched. BLOCKED means a precondition prevents judgment, such as no verification command, auth failure, merge conflict, moved HEAD, or missing goal manifest.
12
12
  - **Worktree safety.** Start with `git status --short --branch -uall` and record `git rev-parse HEAD`. Modified, staged, and untracked files are user work. Never switch branch, stash, reset, clean, discard, stage, or commit them. If HEAD moves or unknown commits appear during review, stop and return BLOCKED.
13
- - **Acceptance gates.** Scope: every changed file traces to the stated goal. Verification: run the project's real commands and report their actual output. Hard stops include unknown identifiers, version skew, stale generated output, surprise dependencies, hardcoded secrets, sleeps standing in for a completion signal, near-duplicates of an existing canonical helper, special-case branches or one-off mode flags bolted into shared flows the goal does not cover, and pass-through wrappers or `any`/cast churn that obscure an existing contract without the goal requiring it.
13
+ - **Acceptance gates.** Scope: every changed file traces to the stated goal. Verification: follow the repository's testing policy. For contract acceptance, validate canonical subject-bound execution evidence and report check IDs, dispositions and run references; do not rerun checks already covered by valid evidence. Return missing, stale or failed evidence to the execution owner, and uncovered risk to the parent for revised coverage. For review without canonical contract evidence, use the project's scoped verification commands and report actual results. Hard stops include unknown identifiers, version skew, stale generated output, surprise dependencies, hardcoded secrets, sleeps standing in for a completion signal, near-duplicates of an existing canonical helper, special-case branches or one-off mode flags bolted into shared flows the goal does not cover, and pass-through wrappers or `any`/cast churn that obscure an existing contract without the goal requiring it.
14
14
  - **Decomposition is recommendation only.** Given a goal manifest, map changes to goals and propose file-granular commit or PR groups. A file entangling goals is a FAIL finding. Unmapped changes are user work and remain untouched. The orchestrator performs any approved split or ship action.
15
- - **Evidence before claim.** A test, CI result, or ship state counts only if checked in this turn. Before recommending merge, re-read PR and CI status; before recommending push, check local versus remote sync. Never recommend merge on red or stale evidence.
15
+ - **Evidence before claim.** A test, CI result, or ship state counts only if its evidence and applicability are checked in this turn; checking evidence does not require rerunning its producer. Before recommending merge, re-read PR and CI status; before recommending push, check local versus remote sync. Never recommend merge on red or stale evidence.
16
16
  - **FAIL returns findings, not fixes.** Each finding is `[CRITICAL|HIGH|MEDIUM] file:line — problem — concrete fix instruction — class(safe_auto|gated_auto|manual)`. You do not edit or patch through any tool.
17
17
  - **Sign-off.** Report files changed, scope fit, hard stops, verification command and result, then the recommendation. Lead with the verdict and keep it compact.
package/assets/AGENTS.md CHANGED
@@ -31,21 +31,21 @@ Owns the workflow-engine-contract-assets capability boundary declared in .archco
31
31
  <!-- BEGIN ARCHITECTURE CONTRACT -->
32
32
  ## Architecture Contract
33
33
 
34
- - Functional block: `assets/templates`
34
+ - Functional block: `.ai/harness/policy.json`
35
35
  - Capability ID: `workflow-engine-contract-assets`
36
- - Matched prefix: `assets/templates`
36
+ - Matched prefix: `.ai/harness/policy.json`
37
37
  - Architecture domain: `workflow-engine`
38
38
  - Architecture capability: `contract-assets`
39
39
  - Architecture module: `docs/architecture/modules/workflow-engine/contract-assets.md`
40
- - Last architecture event: 2026-08-05T00:46:13+0800
41
- - Last changed path: `tasks/workstreams/workflow-engine/contract-assets/github-issues-158-159.md`
42
- - Severity: medium
43
- - Change type: workstream-sync
40
+ - Last architecture event: 2026-09-12T11:46:22+0800
41
+ - Last changed path: `.ai/harness/policy.json`
42
+ - Severity: high
43
+ - Change type: workflow-surface
44
44
  - Module responsibility: Keep this block aligned with the local boundary described by surrounding human-owned context.
45
- - Entrypoints: `assets/templates`
45
+ - Entrypoints: `.ai/harness/policy.json`
46
46
  - Allowed dependencies: Follow root `AGENTS.md` / `CLAUDE.md` and this local contract.
47
47
  - Forbidden dependencies: Do not cross sibling app/service/package boundaries without an architecture snapshot or explicit plan.
48
- - Runtime path: `assets/templates`
48
+ - Runtime path: `.ai/harness/policy.json`
49
49
  - LSP/tooling profile: `typescript-lsp`
50
50
  - Verification: Use root required checks plus local commands recorded in this capability contract.
51
51
  - Latest snapshot: `(none yet)`
package/assets/CLAUDE.md CHANGED
@@ -31,21 +31,21 @@ Owns the workflow-engine-contract-assets capability boundary declared in .archco
31
31
  <!-- BEGIN ARCHITECTURE CONTRACT -->
32
32
  ## Architecture Contract
33
33
 
34
- - Functional block: `assets/templates`
34
+ - Functional block: `.ai/harness/policy.json`
35
35
  - Capability ID: `workflow-engine-contract-assets`
36
- - Matched prefix: `assets/templates`
36
+ - Matched prefix: `.ai/harness/policy.json`
37
37
  - Architecture domain: `workflow-engine`
38
38
  - Architecture capability: `contract-assets`
39
39
  - Architecture module: `docs/architecture/modules/workflow-engine/contract-assets.md`
40
- - Last architecture event: 2026-08-05T00:46:13+0800
41
- - Last changed path: `tasks/workstreams/workflow-engine/contract-assets/github-issues-158-159.md`
42
- - Severity: medium
43
- - Change type: workstream-sync
40
+ - Last architecture event: 2026-09-12T11:46:22+0800
41
+ - Last changed path: `.ai/harness/policy.json`
42
+ - Severity: high
43
+ - Change type: workflow-surface
44
44
  - Module responsibility: Keep this block aligned with the local boundary described by surrounding human-owned context.
45
- - Entrypoints: `assets/templates`
45
+ - Entrypoints: `.ai/harness/policy.json`
46
46
  - Allowed dependencies: Follow root `AGENTS.md` / `CLAUDE.md` and this local contract.
47
47
  - Forbidden dependencies: Do not cross sibling app/service/package boundaries without an architecture snapshot or explicit plan.
48
- - Runtime path: `assets/templates`
48
+ - Runtime path: `.ai/harness/policy.json`
49
49
  - LSP/tooling profile: `typescript-lsp`
50
50
  - Verification: Use root required checks plus local commands recorded in this capability contract.
51
51
  - Latest snapshot: `(none yet)`
@@ -1352,8 +1352,11 @@ workflow_write_run_summary() {
1352
1352
  return 0
1353
1353
  fi
1354
1354
 
1355
+ # Same field set as the jq branch above: run-summary retention identifies this
1356
+ # record by its shape, so a short fallback would make every jq-less host's
1357
+ # summaries permanently unreclaimable.
1355
1358
  cat > "$output_file" <<EOF_RUN
1356
- {"generated_at":"$(workflow_json_escape "$(date '+%Y-%m-%dT%H:%M:%S%z')")","run_id":"$(workflow_json_escape "$run_id")","reason":"$(workflow_json_escape "$reason")","checks_file":"$(workflow_json_escape "$(workflow_checks_file)")","handoff_file":"$(workflow_json_escape "$(workflow_handoff_file)")"}
1359
+ {"generated_at":"$(workflow_json_escape "$(date '+%Y-%m-%dT%H:%M:%S%z')")","run_id":"$(workflow_json_escape "$run_id")","reason":"$(workflow_json_escape "$reason")","active_plan":"$(workflow_json_escape "${active_plan:-}")","active_contract":"$(workflow_json_escape "${active_contract:-}")","active_review":"$(workflow_json_escape "${active_review:-}")","active_notes":"$(workflow_json_escape "${active_notes:-}")","checks_file":"$(workflow_json_escape "$(workflow_checks_file)")","handoff_file":"$(workflow_json_escape "$(workflow_handoff_file)")","policy_file":"$(workflow_json_escape "$(workflow_policy_file)")","context_map_file":"$(workflow_json_escape "$(workflow_context_map_file)")"}
1357
1360
  EOF_RUN
1358
1361
  }
1359
1362
 
@@ -53,6 +53,7 @@ cross-review/merge-gate rows.
53
53
  | Check deploy and ops config | `repo-harness-check` (deploy-readiness reference) | Read-only deploy/_ops readiness check without publishing |
54
54
  | Fix broken current harness behavior | `repo-harness-setup` (repair mode) | Task sync, hook routing, handoff, context, policy, or helper drift |
55
55
  | Verify readiness | `repo-harness-check` | Workflow gates, task sync, inspector, migration dry-run, and readiness yellow flags |
56
+ | Write, run, refactor, or document repo-harness source tests | `repo-harness-test` | Routing plus repo-specific technique only; `sprint-contracts.md` keeps the testing policy, and no mode runs a test or writes acceptance evidence |
56
57
  | Independent outside review | `repo-harness-cross-review` | Claude host uses direct Codex; Codex host uses OpenAI's official `codex@openai-codex` plugin app-server mode; installed on both hosts for full; never produces a merge-gate receipt |
57
58
  | Generate an upper-layer PRD | `repo-harness-product` (PRD mode) | `$geju` direction pass, Claude-first `claude -p --model opus` drafting, Codex fallback only when needed, PRD in `plans/prds/*.prd.md`; geju thesis/falsifier are pre-contract only and freeze into a delegated contract's `## Why`/`## Falsifier` |
58
59
  | Plan and run a program-level sprint | `repo-harness-product` (Sprint mode) | Upper-layer PRD in `plans/prds/`, sprint backlog in `plans/sprints/`; each row expands through `$think` before plan -> contract -> worktree |
@@ -930,17 +930,51 @@ spawns a daemon or external process. Bun older than 1.3 has no `Bun.YAML`; that
930
930
  fails closed with upgrade guidance and only when `capability_source` is
931
931
  `archcontext`.
932
932
 
933
- Architecture projection is a separate authority. When
934
- `architecture.projection_provider=archctx`, repo-harness resolves the exact
935
- version from the consumer dependency tree, executes only that package's declared
936
- `bin.archctx`, performs a JSON capability handshake, and rejects PATH-only,
937
- escaping, or mismatched installations. The advisory
938
- global-tool detector below does not satisfy projection readiness; use
939
- `repo-harness architecture-projection status --json`. The provider remains
940
- disabled by default until the release pin is cut over.
941
-
942
- When enabled, PostEdit writes only `change_observed` v2 journal records. Stop
943
- coalesces all eligible records into one durable projection job, excludes
933
+ Architecture projection execution is user-level configuration in
934
+ `~/.repo-harness/config.json#architecture`. `repo-harness install` and
935
+ `repo-harness update` initialize it once with `projection_provider: "archctx"`,
936
+ `projection_apply: "automatic"`, `projection_failure_gate: "advisory"`, and
937
+ `projection_timeout_ms: 120000`. Repeated setup preserves an explicit global
938
+ choice, including disabled. Malformed or partial settings fail closed without
939
+ rewriting the file; unrelated user settings are preserved. The exact provider
940
+ version is owned by the packaged release contract, not a configurable repo pin.
941
+
942
+ `repo-harness init` remains a repository-only transaction. Standard/self-host adoption
943
+ removes retired `architecture.projection_*` execution keys from repo policy and
944
+ reports global provider readiness, without writing user configuration or
945
+ inventing the project's model. Minimal adoption does not author a policy.
946
+ Runtime does not read or merge retired repo execution settings. Capability
947
+ identity, model files, documentation ownership and project freshness gates
948
+ remain repository-local. Missing model/adoption evidence still blocks apply;
949
+ global automatic mode does not authorize ownership adoption or semantic acceptance.
950
+
951
+ Use `repo-harness architecture-projection policy --json` to inspect the global
952
+ source path, initialization state and effective execution settings without a
953
+ provider process. `repo-harness architecture-projection status --json` adds the
954
+ exact package capability handshake and project apply readiness. The running
955
+ repo-harness package owns the `archctx` executable and exact dependency version;
956
+ its dependency tree is refreshed by the global update transaction. A target
957
+ repository's `node_modules/archctx` never overrides that runtime dependency.
958
+ Source-checkout execution uses that checkout's repo-harness dependencies, and
959
+ candidate verification may explicitly select the candidate package root.
960
+ Missing or mismatching runtime dependencies still fail closed with no target-repo
961
+ fallback. Project model, ownership and snapshot checks remain repository-local.
962
+
963
+ SessionStart also gives the Agent read-only model coverage guidance under this
964
+ global provider setting; no per-repo execution toggle is needed. It observes empty
965
+ capability models, missing declared module documents, and tracked package roots
966
+ with no capability match or a shared ancestor capability. These are bounded
967
+ inspection prompts, not inferred semantic nodes. The Agent uses the
968
+ `repo-harness-architecture` skill to inspect source evidence and decide boundaries
969
+ within the authorized task, then creates nodes through archctx ChangeSets and
970
+ runs the existing projection. An intentional umbrella is valid. Hooks do not
971
+ write model YAML, and unrelated coverage findings remain advice. The manifest
972
+ inventory is limited to Git-tracked `package.json` paths; this is not a complete
973
+ semantic coverage audit for every language or untracked source tree. Inspection
974
+ errors become SessionStart provider diagnostics instead of invented model facts.
975
+
976
+ When enabled, Stop observes the Git changed set and coalesces eligible paths
977
+ into one durable projection job, excludes
944
978
  ArchContext-owned `docs/architecture/**` and declared agent-context targets,
945
979
  and acknowledges the source records only after a typed projection receipt is
946
980
  durable. Process, timeout, stale-snapshot, invalid-result, and refresh failures
@@ -1125,3 +1159,37 @@ repo-harness run check-brain-manifest
1125
1159
  repo-harness run sync-brain-docs --all
1126
1160
  repo-harness run sync-brain-docs --check
1127
1161
  ```
1162
+
1163
+
1164
+ ## Proactive refactor recommendations
1165
+
1166
+ `~/.repo-harness/config.json#refactor_recommendations` contains `{ "enabled": true }`
1167
+ by default. Global install/update initializes the setting once and preserves an
1168
+ explicit disabled choice. Repositories do not need another enable switch.
1169
+
1170
+ At normal Stop, repo-harness observes ArchContext structural candidates when a
1171
+ project model is present. It uses the packaged exact provider contract and
1172
+ existing lifecycle readback; it does not require or change execution activation.
1173
+ Only complete, non-truncated code facts with unambiguous ownership produce a
1174
+ recommendation. The observer never creates an index or model on the user's behalf.
1175
+
1176
+ The Agent receives at most three candidates and is instructed to explain the
1177
+ measured evidence, inferred benefit and risk, then ask the user whether to
1178
+ proceed, defer or decline. No author, recommendation record/acceptance,
1179
+ Work Package, program or code edit is triggered by observation. User approval
1180
+ uses the normal approved-plan workflow and its existing execution gates.
1181
+
1182
+ Observation gets at most ten seconds within Stop's existing twenty-second
1183
+ shared work budget, with a five-minute scan cooldown. A delivery ledger retains up to 4096
1184
+ recommendation identity/fingerprint pairs without eviction. At capacity, automatic
1185
+ delivery pauses with an explicit diagnostic; existing identities remain suppressed.
1186
+ The explicit CLI still permits observation without consuming delivery history. The one-shot
1187
+ Stop continuation ends after presenting the choice; waiting for an answer does
1188
+ not hold Stop in a loop. State and the last observation are stored in the ignored
1189
+ `.ai/harness/runs/refactor-recommendations.json`; they are delivery evidence,
1190
+ not user approval or upstream recommendation status.
1191
+
1192
+ `repo-harness refactor recommendations --repo <root> --json` explicitly reads
1193
+ current opportunities through the same observer, without consuming Stop's
1194
+ delivery history or requiring `refactor discover`'s author activation. It returns
1195
+ readiness/error status when evidence is unavailable; it never invents a candidate.
@@ -129,6 +129,52 @@ contains the generated operator-helper projection. Keep the two declared asset
129
129
  manifests aligned with `bun run sync:hooks`, and validate the typed route
130
130
  registry with `bun test` and `repo-harness init --repo . --dry-run`.
131
131
 
132
+ ## Evidence Retention
133
+
134
+ `.ai/harness/runs/` holds four record shapes from five writers, and only one of
135
+ them is disposable history:
136
+
137
+ | File | Writer | Retention owner |
138
+ | --- | --- | --- |
139
+ | `${runId}.json` carrying the four resolved projection paths | Stop (`stop-handler.ts`) and `workflow_write_run_summary` in `assets/hooks/lib/workflow-state.sh` | `run-summary-retention.ts`, at the end of every Stop: newest `RUN_SUMMARY_RETENTION_COUNT` |
140
+ | `${runId}-${contractSlug}.json` (`schema: repo-harness-run-trace.v1`) | `verify-sprint.sh` | none; a checks projection reads it back at acceptance finalization |
141
+ | `verification-${executionId}.json` / `.log` | `verification-execution.ts` | none; immutable, bound by sha256 in the evidence ledger |
142
+ | `hook-events.jsonl` | hook telemetry | `hook-event-log.ts`, on rotation: 8 MB segments, 256 MB or 32 archived segments |
143
+ | ad-hoc `*.json` reports | operator scripts | none; each report owns its own file |
144
+
145
+ Evidence checkpoints under `.ai/harness/evidence/checkpoints/` are owned by
146
+ `checkpoint-store.ts`, which keeps only the checkpoint the published marker
147
+ names and prunes inside every successful publish.
148
+
149
+ The three unowned rows are not leaks. Operator reports own their own files; the
150
+ other two are durable evidence. A frozen acceptance
151
+ snapshot shares Stop's `run-` prefix, and a missing verification record makes
152
+ `readValidRunResult` report an absent baseline, which fails a
153
+ `baseline_with_delta` criterion permanently because a rerun only mints a new
154
+ execution id. Retention therefore never reasons about what to keep: it deletes
155
+ only records with Stop's own run-summary shape -- a `run_id` plus
156
+ `checks_file`, `handoff_file`, `policy_file`, and `context_map_file`, every one
157
+ a pointer the next Stop recomputes -- and leaves every other shape to its owner.
158
+ The shape, not `reason`: that field is free-form operator text.
159
+
160
+ Checkpoint retention was added in 0.19.0. A repository upgraded from an earlier
161
+ version carries a checkpoint per Stop, each one a whole-ledger snapshot -- on a
162
+ long-running repository that reaches multiple gigabytes. The next successful Stop
163
+ after the upgrade prunes the entire backlog on its own, so no action is normally
164
+ required.
165
+
166
+ Run `repo-harness run evidence-gc` when that Stop will not come:
167
+
168
+ ```bash
169
+ repo-harness run evidence-gc --repo . --dry-run # report reclaimable bytes
170
+ repo-harness run evidence-gc --repo . # apply the same policies now
171
+ ```
172
+
173
+ It applies the two policies above and never defines its own. Use it for a
174
+ repository whose ledger was reset (publication skips quietly with no ledger), one
175
+ that no longer runs the harness, or when the space is needed before the next
176
+ Stop. It exits non-zero and names every entry it could not reclaim.
177
+
132
178
  ## Verification Checklist
133
179
 
134
180
  After handler or workflow-contract changes, run:
@@ -12,6 +12,13 @@ This repo keeps deployment contract surfaces under `deploy/` and private runtime
12
12
  state under ignored `_ops/`. Detailed release patterns, Cloudflare examples, and
13
13
  rollback playbooks belong in the external runbook.
14
14
 
15
+ Tests whose cost is a real package install or a real external program are gated
16
+ behind `REPO_HARNESS_TEST_EXPENSIVE` and are therefore not part of the hosted
17
+ `scripts/check-ci.sh functional` lane. The release gate is the lane that owns
18
+ them: `bun run check:release` (and a bare local `bash scripts/check-ci.sh`) runs
19
+ the `all` lane, which exports that variable before the suite, while
20
+ `prepublishOnly` stays a fast pre-publish check that never runs tests.
21
+
15
22
  ## Webapp Release Shape
16
23
 
17
24
  - For a SaaS webapp with public SEO/SSR plus authenticated workspace, prefer one