repo-harness 0.3.0 → 0.4.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 (89) hide show
  1. package/AGENTS.md +5 -4
  2. package/CLAUDE.md +5 -4
  3. package/README.es.md +5 -5
  4. package/README.fr.md +5 -5
  5. package/README.ja.md +5 -5
  6. package/README.md +41 -35
  7. package/README.zh-CN.md +36 -31
  8. package/assets/hooks/lib/workflow-state.sh +28 -4
  9. package/assets/hooks/post-edit-guard.sh +9 -9
  10. package/assets/hooks/prompt-guard.sh +8 -6
  11. package/assets/hooks/session-start-context.sh +49 -0
  12. package/assets/partials/04-project-structure.partial.md +1 -1
  13. package/assets/partials/05-workflow.partial.md +2 -2
  14. package/assets/partials/07-footer.partial.md +1 -1
  15. package/assets/partials/08-orchestration.partial.md +2 -2
  16. package/assets/partials-agents/02-operating-mode.partial.md +1 -1
  17. package/assets/partials-agents/03-orchestration.partial.md +2 -2
  18. package/assets/partials-agents/04-task-protocol.partial.md +3 -3
  19. package/assets/partials-agents/08-deep-docs.partial.md +1 -1
  20. package/assets/reference-configs/agentic-development-flow.md +1 -1
  21. package/assets/reference-configs/harness-overview.md +3 -1
  22. package/assets/reference-configs/heartbeat-triage.md +57 -0
  23. package/assets/reference-configs/hook-operations.md +1 -1
  24. package/assets/reference-configs/sprint-contracts.md +11 -0
  25. package/assets/skill-commands/repo-harness-architecture/SKILL.md +2 -0
  26. package/assets/skill-version.json +6 -2
  27. package/assets/templates/contract.template.md +18 -0
  28. package/assets/templates/helpers/architecture-event.ts +354 -1
  29. package/assets/templates/helpers/architecture-queue.sh +647 -0
  30. package/assets/templates/helpers/archive-architecture-request.sh +11 -8
  31. package/assets/templates/helpers/capability-resolver.ts +34 -3
  32. package/assets/templates/helpers/capture-plan.sh +1 -1
  33. package/assets/templates/helpers/check-architecture-sync.sh +287 -0
  34. package/assets/templates/helpers/check-skill-version.ts +24 -5
  35. package/assets/templates/helpers/check-task-sync.sh +5 -2
  36. package/assets/templates/helpers/check-task-workflow.sh +4 -3
  37. package/assets/templates/helpers/codex-handoff-resume.sh +4 -4
  38. package/assets/templates/helpers/contract-run.ts +402 -0
  39. package/assets/templates/helpers/contract-worktree.sh +20 -0
  40. package/assets/templates/helpers/ensure-task-workflow.sh +45 -29
  41. package/assets/templates/helpers/heartbeat-triage.sh +317 -0
  42. package/assets/templates/helpers/inspect-project-state.ts +2 -2
  43. package/assets/templates/helpers/migrate-workflow-docs.ts +60 -31
  44. package/assets/templates/helpers/new-plan.sh +1 -1
  45. package/assets/templates/helpers/plan-to-todo.sh +19 -1
  46. package/assets/templates/helpers/workflow-contract.ts +1 -1
  47. package/assets/templates/implementation-notes.template.md +1 -1
  48. package/assets/templates/plan.template.md +1 -1
  49. package/assets/workflow-contract.v1.json +47 -10
  50. package/docs/reference-configs/agentic-development-flow.md +1 -1
  51. package/docs/reference-configs/harness-overview.md +3 -1
  52. package/docs/reference-configs/heartbeat-triage.md +57 -0
  53. package/docs/reference-configs/hook-operations.md +1 -1
  54. package/docs/reference-configs/loop-engine-cutover-gate.md +39 -0
  55. package/docs/reference-configs/loop-engine-nl-decision-table.md +137 -0
  56. package/docs/reference-configs/sprint-contracts.md +11 -0
  57. package/package.json +2 -1
  58. package/scripts/architecture-event.ts +354 -1
  59. package/scripts/architecture-queue.sh +647 -0
  60. package/scripts/archive-architecture-request.sh +11 -8
  61. package/scripts/capability-resolver.ts +34 -3
  62. package/scripts/capture-plan.sh +1 -1
  63. package/scripts/check-architecture-sync.sh +287 -0
  64. package/scripts/check-npm-release.sh +1 -0
  65. package/scripts/check-skill-version.ts +24 -5
  66. package/scripts/check-task-sync.sh +5 -2
  67. package/scripts/check-task-workflow.sh +4 -3
  68. package/scripts/codex-handoff-resume.sh +4 -4
  69. package/scripts/contract-run.ts +402 -0
  70. package/scripts/contract-worktree.sh +20 -0
  71. package/scripts/create-project-dirs.sh +8 -21
  72. package/scripts/ensure-task-workflow.sh +45 -29
  73. package/scripts/heartbeat-triage.sh +317 -0
  74. package/scripts/hook-dispatch-diet-report.ts +234 -0
  75. package/scripts/init-project.sh +7 -27
  76. package/scripts/inspect-project-state.ts +2 -2
  77. package/scripts/lib/project-init-lib.sh +60 -14
  78. package/scripts/loop-engine-cutover-gate.ts +324 -0
  79. package/scripts/migrate-project-template.sh +34 -35
  80. package/scripts/migrate-workflow-docs.ts +60 -31
  81. package/scripts/new-plan.sh +1 -1
  82. package/scripts/plan-to-todo.sh +19 -1
  83. package/scripts/route-nl-vs-ts-eval.ts +679 -0
  84. package/scripts/workflow-contract.ts +1 -1
  85. package/src/cli/commands/status.ts +1 -1
  86. package/src/cli/hook/state-snapshot.ts +388 -0
  87. package/src/cli/hook-entry.ts +8 -0
  88. package/assets/templates/helpers/architecture-drift.sh +0 -482
  89. package/scripts/architecture-drift.sh +0 -482
package/AGENTS.md CHANGED
@@ -10,7 +10,7 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
10
10
  - `.ai/context/capabilities.json` for the capability registry and longest-prefix context boundaries
11
11
  - `tasks/workstreams/` for capability long-running workstreams that project durable progress into local contracts
12
12
  - `tasks/lessons.md` for correction-derived rules
13
- - `tasks/research.md` for deep repo knowledge
13
+ - `docs/researches/` for deep repo knowledge
14
14
  - `tasks/notes/` for task-local implementation decisions, deviations, tradeoffs, and open questions
15
15
  - `plans/` for timestamped plans, with `plans/archive/` for history
16
16
  - `.ai/harness/workflow-contract.json` for the installed workflow contract manifest
@@ -26,11 +26,11 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
26
26
  - Treat hook execution as central-first: trusted repos run `~/.repo-harness/hooks/` (bash shim) or the packaged CLI copy; this self-host repo pins `"hook_source": "repo"` in `.ai/harness/policy.json` so `.ai/hooks/` stays the live development runtime, with `assets/hooks/` as the product source mirrored on install. User-level `~/.claude/settings.json` and `~/.codex/hooks.json` are the host adapters.
27
27
  - Keep the umbrella hierarchy explicit: architecture owns stable truth, capability contracts own local agent context, `tasks/workstreams/<domain>/<capability>/` owns durable progress, and `tasks/todo.md` owns only deferred medium/long-term goals with tradeoff and revisit trigger.
28
28
  - Treat `.ai/context/capabilities.json` as the source of truth for capability prefixes; `agent-context-blocks.txt` and nested agent files are compatibility inputs only.
29
- - Keep architecture drift handling split: `architecture-drift.sh` writes architecture requests/events, `workstream-sync.sh` maintains durable capability workstreams, and `context-contract-sync.sh` only updates controlled local `CLAUDE.md`/`AGENTS.md` architecture blocks.
29
+ - Keep architecture drift handling split: `architecture-queue.sh` writes architecture requests/events, `workstream-sync.sh` maintains durable capability workstreams, and `context-contract-sync.sh` only updates controlled local `CLAUDE.md`/`AGENTS.md` architecture blocks.
30
30
  - Keep `assets/workflow-contract.v1.json` and `.ai/harness/workflow-contract.json` in sync.
31
31
  - Keep `CLAUDE.md` and `AGENTS.md` short; put detailed guidance in `docs/reference-configs/`.
32
32
  - Treat Codex auto-compact as a fallback only; use `.ai/harness/handoff/current.md` and `.ai/harness/handoff/resume.md` for long-task rollover.
33
- - Treat `_ref/` as an occasional ignored external reference checkout cache, not a commit surface or daily workflow. Agents may read or refresh it for comparison; when it influences a decision, cite the source repo plus commit/tag and path in `tasks/notes/` or `tasks/research.md`.
33
+ - Treat `_ref/` as an occasional ignored external reference checkout cache, not a commit surface or daily workflow. Agents may read or refresh it for comparison; when it influences a decision, cite the source repo plus commit/tag and path in `tasks/notes/` or `docs/researches/`.
34
34
  - Treat `deploy/` as the trackable deployment and operations surface for runbooks, submission materials, release checklists, helper scripts, ordered SQL files under `deploy/sql/`, and env examples.
35
35
  - Treat `_ops/` as ignored local operations state for secrets, real env files, provider state, artifacts, logs, and scratch files; do not commit or agent-edit `_ops/*`.
36
36
  - Treat contract-level task execution as worktree-first: `scripts/plan-to-todo.sh --plan <approved-plan>` starts `scripts/contract-worktree.sh start --plan <approved-plan>` when policy enables it, and completed blocks finish through Waza `/check` plus `scripts/contract-worktree.sh finish`.
@@ -50,6 +50,7 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
50
50
  ```bash
51
51
  bun test
52
52
  bash scripts/check-deploy-sql-order.sh
53
+ bash scripts/check-architecture-sync.sh
53
54
  bash scripts/check-task-sync.sh
54
55
  bash scripts/check-task-workflow.sh --strict
55
56
  bun scripts/inspect-project-state.ts --repo . --format text
@@ -79,7 +80,7 @@ bash scripts/migrate-project-template.sh --repo . --dry-run
79
80
  - Latest snapshot: `(none yet)`
80
81
  - Semantic diagram source: `docs/architecture/modules/runtime-harness/hook-adapters.md`
81
82
  - Latest human diagram: `(none yet)`
82
- - Pending architecture request: `docs/architecture/requests/20260529-094446-ai-hooks-ai-hooks-session-start-context-sh.md`
83
+ - Pending architecture request: `(none)`
83
84
 
84
85
  ## Active Workstreams
85
86
 
package/CLAUDE.md CHANGED
@@ -10,7 +10,7 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
10
10
  - `.ai/context/capabilities.json` for the capability registry and longest-prefix context boundaries
11
11
  - `tasks/workstreams/` for capability long-running workstreams that project durable progress into local contracts
12
12
  - `tasks/lessons.md` for correction-derived rules
13
- - `tasks/research.md` for deep repo knowledge
13
+ - `docs/researches/` for deep repo knowledge
14
14
  - `tasks/notes/` for task-local implementation decisions, deviations, tradeoffs, and open questions
15
15
  - `plans/` for timestamped plans, with `plans/archive/` for history
16
16
  - `.ai/harness/workflow-contract.json` for the installed workflow contract manifest
@@ -26,11 +26,11 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
26
26
  - Treat hook execution as central-first: trusted repos run `~/.repo-harness/hooks/` (bash shim) or the packaged CLI copy; this self-host repo pins `"hook_source": "repo"` in `.ai/harness/policy.json` so `.ai/hooks/` stays the live development runtime, with `assets/hooks/` as the product source mirrored on install. User-level `~/.claude/settings.json` and `~/.codex/hooks.json` are the host adapters.
27
27
  - Keep the umbrella hierarchy explicit: architecture owns stable truth, capability contracts own local agent context, `tasks/workstreams/<domain>/<capability>/` owns durable progress, and `tasks/todo.md` owns only deferred medium/long-term goals with tradeoff and revisit trigger.
28
28
  - Treat `.ai/context/capabilities.json` as the source of truth for capability prefixes; `agent-context-blocks.txt` and nested agent files are compatibility inputs only.
29
- - Keep architecture drift handling split: `architecture-drift.sh` writes architecture requests/events, `workstream-sync.sh` maintains durable capability workstreams, and `context-contract-sync.sh` only updates controlled local `CLAUDE.md`/`AGENTS.md` architecture blocks.
29
+ - Keep architecture drift handling split: `architecture-queue.sh` writes architecture requests/events, `workstream-sync.sh` maintains durable capability workstreams, and `context-contract-sync.sh` only updates controlled local `CLAUDE.md`/`AGENTS.md` architecture blocks.
30
30
  - Keep `assets/workflow-contract.v1.json` and `.ai/harness/workflow-contract.json` in sync.
31
31
  - Keep `CLAUDE.md` and `AGENTS.md` short; put detailed guidance in `docs/reference-configs/`.
32
32
  - Treat Codex auto-compact as a fallback only; use `.ai/harness/handoff/current.md` and `.ai/harness/handoff/resume.md` for long-task rollover.
33
- - Treat `_ref/` as an occasional ignored external reference checkout cache, not a commit surface or daily workflow. Agents may read or refresh it for comparison; when it influences a decision, cite the source repo plus commit/tag and path in `tasks/notes/` or `tasks/research.md`.
33
+ - Treat `_ref/` as an occasional ignored external reference checkout cache, not a commit surface or daily workflow. Agents may read or refresh it for comparison; when it influences a decision, cite the source repo plus commit/tag and path in `tasks/notes/` or `docs/researches/`.
34
34
  - Treat `deploy/` as the trackable deployment and operations surface for runbooks, submission materials, release checklists, helper scripts, ordered SQL files under `deploy/sql/`, and env examples.
35
35
  - Treat `_ops/` as ignored local operations state for secrets, real env files, provider state, artifacts, logs, and scratch files; do not commit or agent-edit `_ops/*`.
36
36
  - Treat contract-level task execution as worktree-first: `scripts/plan-to-todo.sh --plan <approved-plan>` starts `scripts/contract-worktree.sh start --plan <approved-plan>` when policy enables it, and completed blocks finish through Waza `/check` plus `scripts/contract-worktree.sh finish`.
@@ -50,6 +50,7 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
50
50
  ```bash
51
51
  bun test
52
52
  bash scripts/check-deploy-sql-order.sh
53
+ bash scripts/check-architecture-sync.sh
53
54
  bash scripts/check-task-sync.sh
54
55
  bash scripts/check-task-workflow.sh --strict
55
56
  bun scripts/inspect-project-state.ts --repo . --format text
@@ -79,7 +80,7 @@ bash scripts/migrate-project-template.sh --repo . --dry-run
79
80
  - Latest snapshot: `(none yet)`
80
81
  - Semantic diagram source: `docs/architecture/modules/runtime-harness/hook-adapters.md`
81
82
  - Latest human diagram: `(none yet)`
82
- - Pending architecture request: `docs/architecture/requests/20260529-094446-ai-hooks-ai-hooks-session-start-context-sh.md`
83
+ - Pending architecture request: `(none)`
83
84
 
84
85
  ## Active Workstreams
85
86
 
package/README.es.md CHANGED
@@ -186,8 +186,8 @@ adoptar este workflow.
186
186
  npx -y repo-harness init
187
187
  ```
188
188
 
189
- La npm package release line es ahora `0.3.x`; el workflow compatibility model line
190
- generado se rastrea por separado como `5.x`. `repo-harness init` es el bootstrap
189
+ La npm package release line y el generated workflow stamp usan ahora la misma
190
+ línea `0.4.x`. `repo-harness init` es el bootstrap
191
191
  global y `repo-harness update` es el refresco repo-local. `repo-harness init`
192
192
  configura el CLI, los hook adapters de nivel usuario, Waza, Mermaid, el brain
193
193
  root y CodeGraph MCP; el viejo camino Claude plugin `scripts/setup-plugins.sh`
@@ -325,12 +325,12 @@ Guards habituales:
325
325
 
326
326
  ## Release actual
327
327
 
328
- - npm package: `repo-harness@0.3.0`
329
- - Generated workflow compatibility: `5.2.3`
328
+ - npm package: `repo-harness@0.4.0`
329
+ - Generated workflow stamp: `repo-harness@0.4.0+template@0.4.0`
330
330
  - GitHub repository: `Ancienttwo/repo-harness`
331
331
  - Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
332
332
 
333
- ## Current Model (5.2.3)
333
+ ## Current Model
334
334
 
335
335
  - El question flow usa **12 grouped decision points**, infiriendo primero los harness defaults.
336
336
  - El plan menu está por capas: los **Core Plans (A-F)** primero, los **Custom Presets (G-K)** solo cuando hace falta.
package/README.fr.md CHANGED
@@ -190,8 +190,8 @@ de ce workflow.
190
190
  npx -y repo-harness init
191
191
  ```
192
192
 
193
- La release line du package npm est désormais `0.3.x` ; la generated workflow
194
- compatibility model line est suivie séparément en `5.x`. `repo-harness init`
193
+ La release line du package npm et le generated workflow stamp utilisent
194
+ désormais la même ligne `0.4.x`. `repo-harness init`
195
195
  sert au bootstrap global et `repo-harness update` sert au rafraîchissement
196
196
  repo-local. `repo-harness init` configure le CLI, les hook adapters de niveau
197
197
  utilisateur, Waza, Mermaid, le brain root et CodeGraph MCP ; l'ancien chemin
@@ -329,12 +329,12 @@ Guards courants :
329
329
 
330
330
  ## Release actuelle
331
331
 
332
- - npm package : `repo-harness@0.3.0`
333
- - Generated workflow compatibility : `5.2.3`
332
+ - npm package : `repo-harness@0.4.0`
333
+ - Generated workflow stamp : `repo-harness@0.4.0+template@0.4.0`
334
334
  - GitHub repository : `Ancienttwo/repo-harness`
335
335
  - Release history : [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
336
336
 
337
- ## Current Model (5.2.3)
337
+ ## Current Model
338
338
 
339
339
  - Le question flow utilise **12 grouped decision points**, en inférant d'abord les harness defaults.
340
340
  - Le plan menu est hiérarchisé : **Core Plans (A-F)** en priorité, **Custom Presets (G-K)** uniquement quand c'est nécessaire.
package/README.ja.md CHANGED
@@ -159,8 +159,8 @@ flowchart TD
159
159
  npx -y repo-harness init
160
160
  ```
161
161
 
162
- npm package release line は現在 `0.3.x` です。生成される workflow compatibility model line
163
- 別途 `5.x` として追跡されます。`repo-harness init` は global bootstrap、`repo-harness update` は
162
+ npm package generated workflow stamp は現在同じ `0.4.x` release line を使います。
163
+ `repo-harness init` は global bootstrap、`repo-harness update` は
164
164
  repo-local refresh です。`repo-harness init` は CLI、user-level hook adapters、Waza、Mermaid、
165
165
  brain root、CodeGraph MCP を設定し、退役した `scripts/setup-plugins.sh` の Claude plugin path は使いません。
166
166
 
@@ -293,12 +293,12 @@ hook がブロックしたときは、まず terminal の構造化された出
293
293
 
294
294
  ## 現在の Release
295
295
 
296
- - npm package:`repo-harness@0.3.0`
297
- - Generated workflow compatibility:`5.2.3`
296
+ - npm package:`repo-harness@0.4.0`
297
+ - Generated workflow stamp:`repo-harness@0.4.0+template@0.4.0`
298
298
  - GitHub repository:`Ancienttwo/repo-harness`
299
299
  - Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
300
300
 
301
- ## Current Model (5.2.3)
301
+ ## Current Model
302
302
 
303
303
  - Question flow は **12 grouped decision points** を使い、まず harness defaults を推論します。
304
304
  - Plan menu は階層化されています。**Core Plans (A-F)** を優先し、**Custom Presets (G-K)** は必要なときだけ現れます。
package/README.md CHANGED
@@ -34,28 +34,25 @@ This repository now dogfoods its own tasks-first contract. It is both:
34
34
  read a 1KB capability contract or query the index instead of spending thousands of
35
35
  tokens rediscovering structure.
36
36
 
37
- ## What's New in 0.3.0
38
-
39
- - **Sprint program layer.** `repo-harness-sprint`, `tasks/sprints/`, sprint
40
- templates, active sprint markers, and `scripts/sprint-backlog.sh` now capture
41
- program-level PRDs and ordered backlogs without turning `tasks/todo.md` into
42
- an active execution checklist.
43
- - **Central-first hook runtime.** User-level Claude/Codex adapters dispatch into
44
- `repo-harness-hook`; central packaged hooks are the default runtime, while
45
- this self-host repo can still pin `"hook_source": "repo"` for live hook
46
- development.
47
- - **Prompt decisions moved to TypeScript.** Prompt-text intent classification is
48
- Unicode-aware in `src/cli/hook/prompt-intents.ts`, the shell hook receives one
49
- verdict JSON line, and prompt-layer plan/spec/contract gates are advisory.
50
- - **Edit-layer enforcement.** Implementation writes are enforced at
51
- `pre-edit-guard.sh`, where the guard can key off path, active plan state, and
52
- repo files instead of natural-language guesses.
53
- - **Cheaper always-on hooks.** `trace-event.sh` and `context-pressure-hook.sh`
54
- are merged into `post-tool-observer.sh`: one dispatch, one stdin parse, one
55
- trace file, and sampled context-budget probes.
56
- - **Legacy surface cleanup.** The retired `repo-harness-skill`,
57
- `project-initializer`, `PROJECT_INITIALIZER_*` fallbacks, duplicate shell
58
- classifier table, orphan version checker, and split observer hooks are gone.
37
+ ## What's New in 0.4.0
38
+
39
+ - **Loop-engine evidence surfaces.** `repo-harness-hook state-snapshot --json`,
40
+ the NL decision-table reference, route A/B evals, and the cutover gate make
41
+ prompt-routing experiments measurable while keeping the TypeScript classifier
42
+ authoritative until evidence says otherwise.
43
+ - **Architecture queue gate.** `scripts/architecture-queue.sh`,
44
+ `scripts/check-architecture-sync.sh`, and the expanded architecture event
45
+ helper replace the retired append-only drift script with a derived request
46
+ index that can gate stale architecture state.
47
+ - **Contract delegation pilot.** Contract templates now include
48
+ `budget`, `permission_scope`, and `roles`, and `scripts/contract-run.ts`
49
+ can run explicit worker/verifier child commands against contract exit
50
+ criteria.
51
+ - **Heartbeat triage.** `scripts/heartbeat-triage.sh` records scheduled
52
+ workflow checks, sprint-next signals, and architecture request state into the
53
+ repo-local triage inbox.
54
+ - **Workflow asset sync.** New helpers, docs, tests, and generated-repo assets
55
+ keep the self-host runtime and installed template copies aligned.
59
56
 
60
57
  ## What repo-harness Does
61
58
 
@@ -118,7 +115,10 @@ The diagram below assumes the harness is already installed in the repo. It shows
118
115
  the normal lifecycle from a program sprint backlog down to one contract task:
119
116
  draft or select the task, project it into execution files, check out the
120
117
  contract worktree when policy requires it, implement under hooks, verify, review,
121
- complete the sprint task when applicable, and close out.
118
+ complete the sprint task when applicable, and close out. The 0.4.0 loop-system
119
+ surfaces add scheduled heartbeat discovery, state-snapshot/eval evidence for
120
+ routing changes, architecture queue freshness, and optional contract-run
121
+ delegation without changing the file-backed authority model.
122
122
 
123
123
  ```mermaid
124
124
  flowchart TD
@@ -126,10 +126,12 @@ flowchart TD
126
126
  Sprint -->|yes| SprintDoc["Sprint PRD + backlog<br/>tasks/sprints/*.sprint.md"]
127
127
  SprintDoc --> NextTask["Select next sprint task<br/>sprint-backlog.sh next"]
128
128
  Sprint -->|no| UserTask["User task or planning prompt"]
129
+ Heartbeat["Heartbeat triage<br/>scripts/heartbeat-triage.sh<br/>.ai/harness/triage/"] --> UserTask
129
130
  NextTask --> UserTask
130
131
 
131
132
  UserTask --> Discovery["Due diligence<br/>P1 map, P2 trace, P3 decision"]
132
- Discovery --> PlanDraft["Draft plan<br/>plans/plan-*.md"]
133
+ Discovery --> LoopEvidence["Loop evidence when routing changes<br/>state-snapshot --json<br/>route-nl-vs-ts / cutover gate"]
134
+ LoopEvidence --> PlanDraft["Draft plan<br/>plans/plan-*.md"]
133
135
  PlanDraft --> PlanReview{"Plan ready for execution?"}
134
136
  PlanReview -->|no| Refine["Refine plan, scope, evidence contract"]
135
137
  Refine --> PlanDraft
@@ -142,18 +144,23 @@ flowchart TD
142
144
  Project --> ReviewFile["Review file<br/>tasks/reviews/YYYYMMDD-HHMM-task-slug.review.md"]
143
145
  Project --> Notes["Task notes<br/>tasks/notes/YYYYMMDD-HHMM-task-slug.notes.md"]
144
146
 
145
- Contract --> WorktreePolicy{"Contract worktree required?"}
147
+ Contract --> Delegation["Delegation contract<br/>budget / permission_scope / roles"]
148
+ Delegation --> Delegate{"Use contract-run delegation?"}
149
+ Delegate -->|yes| ContractRun["Worker/verifier child run<br/>scripts/contract-run.ts"]
150
+ Delegate -->|no| WorktreePolicy{"Contract worktree required?"}
146
151
  WorktreePolicy -->|yes| Checkout["Checkout isolated worktree<br/>contract-worktree.sh start --plan<br/>branch codex/task-slug"]
147
152
  WorktreePolicy -->|no| CurrentTree["Use current worktree<br/>small or explicitly allowed slice"]
148
153
  Checkout --> Implement
149
154
  CurrentTree --> Implement
155
+ ContractRun --> Changes
150
156
 
151
157
  Implement["Edit and run commands"] --> PreHooks["Pre-edit guards<br/>PlanStatusGuard, ContractScopeGuard, WorktreeGuard"]
152
158
  PreHooks -->|blocked| ScopeFix["Fix plan, contract, worktree, or scope"]
153
159
  ScopeFix --> Implement
154
160
  PreHooks -->|allowed| Changes["Code, docs, tests, or config changes"]
155
161
  Changes --> PostHooks["Post-edit and post-bash hooks<br/>trace, drift request, handoff, check evidence"]
156
- PostHooks --> Verify["Run verification<br/>tests plus repo workflow checks"]
162
+ PostHooks --> ArchQueue["Architecture queue<br/>architecture-queue.sh record/reindex<br/>check-architecture-sync.sh"]
163
+ ArchQueue --> Verify["Run verification<br/>tests plus repo workflow checks"]
157
164
 
158
165
  Verify --> Checks["Structured evidence<br/>.ai/harness/checks/latest.json<br/>.ai/harness/runs/*.json"]
159
166
  Checks --> CheckReview["Evaluator review<br/>Waza /check -> review file"]
@@ -201,13 +208,12 @@ npx -y repo-harness update
201
208
  repository to install or refresh workflow files, hook assets, host adapters,
202
209
  skill aliases, and repo-local verification surfaces from the current npm package.
203
210
 
204
- The npm package release line is now `0.3.x`; generated workflow compatibility is
205
- tracked separately as the `5.x` model line. The `0.3.0` package keeps first-run
211
+ The npm package and generated workflow stamp now share the `0.4.x` release line.
212
+ The `0.4.0` package keeps first-run
206
213
  global bootstrap (`repo-harness init`) separate from repo-local refresh
207
- (`repo-harness update`), adds the sprint program layer, moves hook execution to
208
- central-first runtime resolution, moves prompt decisions into TypeScript,
209
- enforces implementation writes at the edit boundary, and merges always-on hook
210
- observers into one cheaper path.
214
+ (`repo-harness update`) while adding the loop-engine state snapshot, architecture
215
+ queue gate, contract delegation pilot, heartbeat triage helper, and generated
216
+ asset sync for those workflow surfaces.
211
217
  These sit on top of the renamed `repo-harness` CLI, user-level hook
212
218
  adapter bootstrap, AI-native scaffold overlays, the typed prompt-guard decision
213
219
  engine, plan-stem task artifact naming, `REPO_HARNESS_*` runtime aliases, Waza
@@ -358,12 +364,12 @@ Most common guards:
358
364
 
359
365
  ## Current Release
360
366
 
361
- - npm package: `repo-harness@0.3.0`
362
- - Generated workflow compatibility: `5.2.3`
367
+ - npm package: `repo-harness@0.4.0`
368
+ - Generated workflow stamp: `repo-harness@0.4.0+template@0.4.0`
363
369
  - GitHub repository: `Ancienttwo/repo-harness`
364
370
  - Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
365
371
 
366
- ## Current Model (5.2.3)
372
+ ## Current Model
367
373
 
368
374
  - Question flow uses **12 grouped decision points** with harness defaults inferred first.
369
375
  - Plan menu is tiered:
package/README.zh-CN.md CHANGED
@@ -23,25 +23,21 @@ repo-local workflow 的自托管样例。
23
23
  做渐进式上下文加载:一份小而稳定的 root context(约 12KB),加上只在改到对应文件时才加载的
24
24
  capability 块。agent 读一份 1KB 的 capability 合约或查索引,而不是花上千 token 重新摸清结构。
25
25
 
26
- ## 0.3.0 新特性
27
-
28
- - **Sprint program layer。** `repo-harness-sprint`、`tasks/sprints/`、sprint
29
- templateactive sprint marker`scripts/sprint-backlog.sh` 现在承接 program
30
- PRD 与有序 backlog,不再把 `tasks/todo.md` 当成活跃执行 checklist。
31
- - **Central-first hook runtime。** User-level Claude/Codex adapters 进入
32
- `repo-harness-hook`;默认跑 central packaged hooks,本仓库自托管开发时仍可通过
33
- `"hook_source": "repo"` 钉回 repo `.ai/hooks`。
34
- - **Prompt decision 进入 TypeScript。** Prompt-text intent classifier
35
- `src/cli/hook/prompt-intents.ts` 里处理 Unicode,shell hook 只接收一行 verdict
36
- JSON,prompt 层的 plan/spec/contract gate 退为 advisory。
37
- - **Edit-layer enforcement。** 真正的实现写入由 `pre-edit-guard.sh` 拦截,依据路径、
38
- active plan state 和仓库文件判断,不再靠自然语言猜测。
39
- - **Always-on hooks 更轻。** `trace-event.sh` `context-pressure-hook.sh` 合并为
40
- `post-tool-observer.sh`:一次 dispatch、一次 stdin parse、一份 trace 文件,并抽样跑
41
- context-budget probes。
42
- - **Legacy surface 清理。** 已退休的 `repo-harness-skill`、`project-initializer`、
43
- `PROJECT_INITIALIZER_*` fallbacks、重复 shell classifier table、孤立 version checker
44
- 和拆分 observer hooks 都已移除。
26
+ ## 0.4.0 新特性
27
+
28
+ - **Loop-engine 证据面。** `repo-harness-hook state-snapshot --json`、NL
29
+ decision-tableroute A/B evalcutover gate 让 prompt-routing 实验可度量;
30
+ 在证据达标前,TypeScript classifier 仍是权威路径。
31
+ - **Architecture queue gate。** `scripts/architecture-queue.sh`、
32
+ `scripts/check-architecture-sync.sh` 和扩展后的 architecture event helper
33
+ 取代已退休的 append-only drift 脚本,用派生 request index 检查 stale 架构状态。
34
+ - **Contract delegation pilot。** Contract template 新增 `budget`、
35
+ `permission_scope`、`roles`,`scripts/contract-run.ts` 可用显式
36
+ worker/verifier child commands 按 contract exit criteria 执行试点。
37
+ - **Heartbeat triage。** `scripts/heartbeat-triage.sh` 把定时 workflow checks、
38
+ sprint-next 信号和 architecture request 状态写入 repo-local triage inbox。
39
+ - **Workflow asset sync。** helpers、docs、tests 和 generated-repo assets
40
+ 保持 self-host runtime 与安装模板副本同步。
45
41
 
46
42
  ## 产品做什么
47
43
 
@@ -90,7 +86,9 @@ classifier/state-machine 层不再散落在 shell 条件分支里。
90
86
  下面这张图假设目标仓库已经安装 harness。它展示的是从 program sprint backlog
91
87
  到单个 contract task 的正常闭环:先选择或形成任务,再投射到执行文件,需要时
92
88
  checkout 隔离 worktree,在 hooks 保护下实现,然后验证、review、external acceptance,
93
- 必要时标记 sprint task 完成,最后 closeout。
89
+ 必要时标记 sprint task 完成,最后 closeout。0.4.0 的 loop-system surface
90
+ 新增 heartbeat 定时发现、state-snapshot/eval 证据、architecture queue freshness,
91
+ 以及可选的 contract-run 委派,但 source of truth 仍然是 repo 内文件合约。
94
92
 
95
93
  ```mermaid
96
94
  flowchart TD
@@ -98,10 +96,12 @@ flowchart TD
98
96
  Sprint -->|是| SprintDoc["Sprint PRD + backlog<br/>tasks/sprints/*.sprint.md"]
99
97
  SprintDoc --> NextTask["选择下一个 sprint task<br/>sprint-backlog.sh next"]
100
98
  Sprint -->|否| UserTask["用户任务或 planning prompt"]
99
+ Heartbeat["Heartbeat triage<br/>scripts/heartbeat-triage.sh<br/>.ai/harness/triage/"] --> UserTask
101
100
  NextTask --> UserTask
102
101
 
103
102
  UserTask --> Discovery["前置调查<br/>P1 map, P2 trace, P3 decision"]
104
- Discovery --> PlanDraft["Draft plan<br/>plans/plan-*.md"]
103
+ Discovery --> LoopEvidence["路由变更时的 loop evidence<br/>state-snapshot --json<br/>route-nl-vs-ts / cutover gate"]
104
+ LoopEvidence --> PlanDraft["Draft plan<br/>plans/plan-*.md"]
105
105
  PlanDraft --> PlanReview{"Plan 是否可执行?"}
106
106
  PlanReview -->|否| Refine["收敛 scope 和 evidence contract"]
107
107
  Refine --> PlanDraft
@@ -114,18 +114,23 @@ flowchart TD
114
114
  Project --> ReviewFile["Review file<br/>tasks/reviews/YYYYMMDD-HHMM-task-slug.review.md"]
115
115
  Project --> Notes["Task notes<br/>tasks/notes/YYYYMMDD-HHMM-task-slug.notes.md"]
116
116
 
117
- Contract --> WorktreePolicy{"是否需要 contract worktree?"}
117
+ Contract --> Delegation["Delegation contract<br/>budget / permission_scope / roles"]
118
+ Delegation --> Delegate{"是否使用 contract-run 委派?"}
119
+ Delegate -->|是| ContractRun["Worker/verifier child run<br/>scripts/contract-run.ts"]
120
+ Delegate -->|否| WorktreePolicy{"是否需要 contract worktree?"}
118
121
  WorktreePolicy -->|是| Checkout["Checkout 隔离 worktree<br/>contract-worktree.sh start --plan<br/>branch codex/task-slug"]
119
122
  WorktreePolicy -->|否| CurrentTree["使用当前 worktree<br/>小任务或明确允许的 slice"]
120
123
  Checkout --> Implement
121
124
  CurrentTree --> Implement
125
+ ContractRun --> Changes
122
126
 
123
127
  Implement["编辑和运行命令"] --> PreHooks["Pre-edit guards<br/>PlanStatusGuard, ContractScopeGuard, WorktreeGuard"]
124
128
  PreHooks -->|blocked| ScopeFix["修正 plan、contract、worktree 或 scope"]
125
129
  ScopeFix --> Implement
126
130
  PreHooks -->|allowed| Changes["代码、文档、测试或配置改动"]
127
131
  Changes --> PostHooks["Post-edit / post-bash hooks<br/>trace, drift request, handoff, check evidence"]
128
- PostHooks --> Verify["运行验证<br/>tests plus repo workflow checks"]
132
+ PostHooks --> ArchQueue["Architecture queue<br/>architecture-queue.sh record/reindex<br/>check-architecture-sync.sh"]
133
+ ArchQueue --> Verify["运行验证<br/>tests plus repo workflow checks"]
129
134
 
130
135
  Verify --> Checks["结构化 evidence<br/>.ai/harness/checks/latest.json<br/>.ai/harness/runs/*.json"]
131
136
  Checks --> CheckReview["Evaluator review<br/>Waza /check -> review file"]
@@ -171,11 +176,11 @@ npx -y repo-harness update
171
176
  安装或刷新 workflow files、hook assets、host adapters、skill aliases 和
172
177
  repo-local verification surfaces。
173
178
 
174
- npm package release line 现在是 `0.3.x`;生成的 workflow compatibility model line
175
- 单独以 `5.x` 追踪。`repo-harness@0.3.0` 继续把首次全局引导(`repo-harness init`)
176
- 和 repo-local 刷新(`repo-harness update`)拆开,新增 sprint program layer,把 hook
177
- 执行切到 central-first runtime resolution,把 prompt decision 移进 TypeScript,在
178
- edit boundary 执行实现写入门,并把 always-on hook observers 合并为更轻的一条路径。
179
+ npm package generated workflow stamp 现在共用 `0.4.x` release line
180
+ `repo-harness@0.4.0` 继续把首次全局引导(`repo-harness init`)
181
+ 和 repo-local 刷新(`repo-harness update`)拆开,同时新增 loop-engine state
182
+ snapshot、architecture queue gate、contract delegation pilot、heartbeat triage
183
+ helper,以及这些 workflow surfaces generated asset sync。
179
184
  这些能力叠加在改名后的 CLI、user-level hook adapter bootstrap、AI-native scaffold overlays、
180
185
  typed prompt-guard decision engine、plan-stem task artifact 命名、`REPO_HARNESS_*`
181
186
  runtime aliases、Waza runtime skill sync,以及 maintainer 发布 npm 前使用的 release gate 之上。
@@ -314,12 +319,12 @@ hook block 工作时,先看 terminal 里的结构化输出。核心字段是
314
319
 
315
320
  ## 当前 Release
316
321
 
317
- - npm package:`repo-harness@0.3.0`
318
- - Generated workflow compatibility:`5.2.3`
322
+ - npm package:`repo-harness@0.4.0`
323
+ - Generated workflow stamp:`repo-harness@0.4.0+template@0.4.0`
319
324
  - GitHub repository:`Ancienttwo/repo-harness`
320
325
  - Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
321
326
 
322
- ## Current Model (5.2.3)
327
+ ## Current Model
323
328
 
324
329
  - Question flow 使用 **12 grouped decision points**,先推断 harness defaults。
325
330
  - Plan menu 分层:**Core Plans (A-F)** 优先,**Custom Presets (G-K)** 只在需要时出现。
@@ -889,18 +889,42 @@ workflow_pending_orchestration_summary() {
889
889
  printf '\n'
890
890
  }
891
891
 
892
+ latest_research_report() {
893
+ local research_dir="${1:-docs/researches}"
894
+ local file mtime latest_file="" latest_mtime=0
895
+
896
+ [[ -d "$research_dir" ]] || return 1
897
+
898
+ while IFS= read -r -d '' file; do
899
+ case "$(basename "$file")" in
900
+ README.md)
901
+ continue
902
+ ;;
903
+ esac
904
+
905
+ mtime="$(workflow_read_file_mtime "$file" || true)"
906
+ if [[ -n "$mtime" && "$mtime" -gt "$latest_mtime" ]]; then
907
+ latest_mtime="$mtime"
908
+ latest_file="$file"
909
+ fi
910
+ done < <(find "$research_dir" -type f -name '*.md' -print0 2>/dev/null)
911
+
912
+ [[ -n "$latest_file" ]] || return 1
913
+ printf '%s' "$latest_file"
914
+ }
915
+
892
916
  has_research_for_new_plan() {
893
- local research_file="tasks/research.md"
894
- local latest_plan research_mtime plan_mtime
917
+ local latest_plan latest_report research_mtime plan_mtime
895
918
 
896
- [[ -f "$research_file" ]] || return 1
919
+ latest_report="$(latest_research_report || true)"
920
+ [[ -n "$latest_report" ]] || return 1
897
921
 
898
922
  latest_plan="$(get_latest_plan || true)"
899
923
  if [[ -z "$latest_plan" ]]; then
900
924
  return 0
901
925
  fi
902
926
 
903
- research_mtime="$(workflow_read_file_mtime "$research_file" || true)"
927
+ research_mtime="$(workflow_read_file_mtime "$latest_report" || true)"
904
928
  plan_mtime="$(workflow_read_file_mtime "$latest_plan" || true)"
905
929
 
906
930
  [[ -n "$research_mtime" && -n "$plan_mtime" && "$research_mtime" -gt "$plan_mtime" ]]
@@ -29,22 +29,22 @@ run_continuous_contract_verification() {
29
29
  fi
30
30
  }
31
31
 
32
- run_architecture_drift_sync() {
33
- local drift_output status
32
+ run_architecture_queue_sync() {
33
+ local queue_output status
34
34
 
35
- [[ -x "scripts/architecture-drift.sh" ]] || return 0
35
+ [[ -x "scripts/architecture-queue.sh" ]] || return 0
36
36
 
37
- if drift_output="$(bash "scripts/architecture-drift.sh" record --file "$FILE_PATH" 2>&1)"; then
37
+ if queue_output="$(bash "scripts/architecture-queue.sh" record --file "$FILE_PATH" 2>&1)"; then
38
38
  :
39
39
  else
40
40
  status=$?
41
- [[ -n "$drift_output" ]] && printf '%s\n' "$drift_output"
42
- echo "[SyncChain] WARN: architecture-drift failed for $FILE_PATH (exit $status)"
41
+ [[ -n "$queue_output" ]] && printf '%s\n' "$queue_output"
42
+ echo "[SyncChain] WARN: architecture-queue failed for $FILE_PATH (exit $status)"
43
43
  return 0
44
44
  fi
45
- [[ -n "$drift_output" ]] && printf '%s\n' "$drift_output"
45
+ [[ -n "$queue_output" ]] && printf '%s\n' "$queue_output"
46
46
 
47
- if printf '%s\n' "$drift_output" | grep -q '^\[ArchitectureDrift\] Request:'; then
47
+ if printf '%s\n' "$queue_output" | grep -q '^\[ArchitectureDrift\] Request:'; then
48
48
  if [[ -x "scripts/context-contract-sync.sh" ]]; then
49
49
  if bash "scripts/context-contract-sync.sh" sync-latest; then
50
50
  :
@@ -154,7 +154,7 @@ if [[ -x "$SCRIPT_DIR/anti-simplification.sh" ]]; then
154
154
  bash "$SCRIPT_DIR/anti-simplification.sh" "$FILE_PATH" </dev/null || true
155
155
  fi
156
156
 
157
- run_architecture_drift_sync
157
+ run_architecture_queue_sync
158
158
 
159
159
  run_brain_doc_sync
160
160
 
@@ -847,8 +847,10 @@ emit_workflow_file_guards() {
847
847
  echo "[LessonGuard] tasks/lessons.md has updates. Review prevention rules before coding."
848
848
  fi
849
849
 
850
- if [ -f "tasks/research.md" ] && has_changes "tasks/research.md"; then
851
- echo "[ResearchGuard] tasks/research.md updated. Review research deeply before planning or implementation."
850
+ local changed_research
851
+ changed_research="$(has_changes_glob '^docs/researches/.*\.md$' || true)"
852
+ if [ -n "$changed_research" ]; then
853
+ echo "[ResearchGuard] ${changed_research} updated. Review research deeply before planning or implementation."
852
854
  fi
853
855
 
854
856
  local changed_plan
@@ -896,11 +898,11 @@ if [ "$plan_start_intent" -eq 1 ]; then
896
898
  latest_plan="$(get_latest_plan || true)"
897
899
  if [[ -n "$latest_plan" ]]; then
898
900
  plan_research_ready=0
899
- echo "[ResearchGate] Advisory: tasks/research.md is missing or older than $latest_plan; skipping automatic Draft plan creation."
900
- echo "[ResearchGate] Update tasks/research.md with fresh findings before creating the next plan."
901
+ echo "[ResearchGate] Advisory: docs/researches/*.md is missing or older than $latest_plan; skipping automatic Draft plan creation."
902
+ echo "[ResearchGate] Add or update a docs/researches/ report with fresh findings before creating the next plan."
901
903
  else
902
- echo "[ResearchGate] WARNING: tasks/research.md does not exist yet. Consider creating it with current findings before drafting the plan."
903
- echo " 首次创建计划:建议先写 tasks/research.md,但不阻塞。"
904
+ echo "[ResearchGate] WARNING: no docs/researches/*.md report exists yet. Consider creating one with current findings before drafting the plan."
905
+ echo " 首次创建计划:建议先写 docs/researches/<date-topic>.md,但不阻塞。"
904
906
  fi
905
907
  fi
906
908
  fi
@@ -158,6 +158,46 @@ ${pending_lines}
158
158
  EOF_CONTEXT
159
159
  }
160
160
 
161
+ architecture_queue_pending() {
162
+ local requests_dir="docs/architecture/requests"
163
+ local pending_count="0"
164
+ local oldest_epoch="" oldest_days="unknown"
165
+ local now_epoch request detected detected_date detected_epoch
166
+
167
+ [[ -d "$requests_dir" ]] || return 1
168
+
169
+ now_epoch="$(date '+%s' 2>/dev/null || true)"
170
+ while IFS= read -r request; do
171
+ [[ -f "$request" ]] || continue
172
+ grep -Eq '^> \*\*Status\*\*:[[:space:]]*Pending[[:space:]]*$' "$request" || continue
173
+ pending_count=$((pending_count + 1))
174
+ detected="$(awk '/^> \*\*Detected\*\*:/ {sub(/^.*> \*\*Detected\*\*:[[:space:]]*/, ""); print; exit}' "$request" | xargs || true)"
175
+ detected_date="${detected%%T*}"
176
+ detected_epoch=""
177
+ if [[ "$detected_date" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
178
+ detected_epoch="$(date -j -f '%Y-%m-%d' "$detected_date" '+%s' 2>/dev/null || date -d "$detected_date" '+%s' 2>/dev/null || true)"
179
+ fi
180
+ if [[ -n "$detected_epoch" && ( -z "$oldest_epoch" || "$detected_epoch" -lt "$oldest_epoch" ) ]]; then
181
+ oldest_epoch="$detected_epoch"
182
+ fi
183
+ done < <(find "$requests_dir" -maxdepth 1 -type f -name '*.md' | sort)
184
+
185
+ [[ "$pending_count" -gt 0 ]] || return 1
186
+ if [[ -n "$now_epoch" && -n "$oldest_epoch" && "$now_epoch" -ge "$oldest_epoch" ]]; then
187
+ oldest_days="$(( (now_epoch - oldest_epoch) / 86400 ))d"
188
+ fi
189
+
190
+ cat <<EOF_CONTEXT
191
+ # Architecture Queue
192
+
193
+ ${pending_count} capabilities have pending architecture drift (oldest ${oldest_days}). Run:
194
+
195
+ \`\`\`bash
196
+ bash scripts/architecture-queue.sh status
197
+ \`\`\`
198
+ EOF_CONTEXT
199
+ }
200
+
161
201
  pending_plan_capture_context() {
162
202
  local active_plan summary draft_path prompt_slug kind source_ref capture_source source_arg
163
203
 
@@ -335,6 +375,15 @@ if [[ -n "$pending_context" ]]; then
335
375
  fi
336
376
  fi
337
377
 
378
+ architecture_context="$(architecture_queue_pending || true)"
379
+ if [[ -n "$architecture_context" ]]; then
380
+ if [[ -n "$context" ]]; then
381
+ context="${context}"$'\n'"${architecture_context}"
382
+ else
383
+ context="$architecture_context"
384
+ fi
385
+ fi
386
+
338
387
  pending_capture_context="$(pending_plan_capture_context || true)"
339
388
  if [[ -n "$pending_capture_context" ]]; then
340
389
  if [[ -n "$context" ]]; then
@@ -41,7 +41,7 @@
41
41
  - Keep stable product truth in `docs/spec.md`.
42
42
  - Keep sprint done definitions in `tasks/contracts/`, `tasks/reviews/`, and task-local implementation notes in `tasks/notes/`.
43
43
  - Keep resumable state in `.ai/harness/handoff/current.md`.
44
- - Treat `_ref/` as an occasional ignored external reference checkout cache; read or refresh it for comparison, but keep it out of commits and cite repo+commit/tag+path in `tasks/notes/` or `tasks/research.md` when it influences a decision.
44
+ - Treat `_ref/` as an occasional ignored external reference checkout cache; read or refresh it for comparison, but keep it out of commits and cite repo+commit/tag+path in `tasks/notes/` or `docs/researches/` when it influences a decision.
45
45
  - Treat `deploy/` as the trackable deployment and operations surface for runbooks, submission materials, release checklists, helper scripts, ordered SQL files under `deploy/sql/`, and env examples.
46
46
  - Treat `_ops/` as ignored local operations state for secrets, real env files, provider state, artifacts, logs, and scratch files; do not commit or agent-edit `_ops/*`.
47
47
  - Treat contract-level execution as worktree-first: `scripts/plan-to-todo.sh --plan <approved-plan>` starts a linked `codex/<slug>` worktree when policy enables it, and `scripts/contract-worktree.sh finish` merges back only after Waza `/check` and sprint verification pass.