@nurix/etna 0.18.10 → 0.18.11

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 (101) hide show
  1. package/README.md +6 -5
  2. package/bin/etna.js +35 -0
  3. package/data/harness-index.json +9 -1
  4. package/data/harnesses/code/harness.json +2 -2
  5. package/data/harnesses/code/skills/documentation/references/templates.md +3 -0
  6. package/data/harnesses/etna/.prettierignore +12 -0
  7. package/data/harnesses/etna/.prettierrc.json +3 -0
  8. package/data/harnesses/etna/.vscode/settings.json +10 -0
  9. package/data/harnesses/etna/CLAUDE.md +160 -0
  10. package/data/harnesses/etna/agents/brainstorm.md +35 -0
  11. package/data/harnesses/etna/agents/change-review.md +251 -0
  12. package/data/harnesses/etna/agents/harness-manager.md +184 -0
  13. package/data/harnesses/etna/agents/maintenance.md +122 -0
  14. package/data/harnesses/etna/agents/performance-review.md +223 -0
  15. package/data/harnesses/etna/agents/spec-mode.md +56 -0
  16. package/data/harnesses/etna/harness.json +11 -0
  17. package/data/harnesses/etna/hooks/hooks.json +27 -0
  18. package/data/harnesses/etna/hooks/lib/redact.mjs +35 -0
  19. package/data/harnesses/etna/hooks/prompt-recall.mjs +155 -0
  20. package/data/harnesses/etna/hooks/session-reflect.mjs +285 -0
  21. package/data/harnesses/etna/rules/general.md +86 -0
  22. package/data/harnesses/etna/rules/kb.md +13 -0
  23. package/data/harnesses/etna/rules/nomenclature.md +41 -0
  24. package/data/harnesses/etna/skills/boundary/SKILL.md +49 -0
  25. package/data/harnesses/etna/skills/boundary/references/boundary-taxonomy.md +796 -0
  26. package/data/harnesses/etna/skills/brainstorm/README.md +136 -0
  27. package/data/harnesses/etna/skills/brainstorm/SKILL.md +135 -0
  28. package/data/harnesses/etna/skills/brainstorm/harvest.md +26 -0
  29. package/data/harnesses/etna/skills/brainstorm/templates/backlog.md +39 -0
  30. package/data/harnesses/etna/skills/brainstorm/templates/build.md +37 -0
  31. package/data/harnesses/etna/skills/brainstorm/templates/decisions.md +29 -0
  32. package/data/harnesses/etna/skills/brainstorm/templates/doctrine.md +31 -0
  33. package/data/harnesses/etna/skills/brainstorm/templates/domain-model.md +25 -0
  34. package/data/harnesses/etna/skills/brainstorm/templates/glossary.md +20 -0
  35. package/data/harnesses/etna/skills/brainstorm/templates/milestones.md +43 -0
  36. package/data/harnesses/etna/skills/brainstorm/templates/non-goals.md +17 -0
  37. package/data/harnesses/etna/skills/brainstorm/templates/plan-doc.md +61 -0
  38. package/data/harnesses/etna/skills/brainstorm/templates/questions.md +36 -0
  39. package/data/harnesses/etna/skills/brainstorm/templates/references.md +28 -0
  40. package/data/harnesses/etna/skills/brainstorm/templates/rejected.md +29 -0
  41. package/data/harnesses/etna/skills/brainstorm/templates/state.md +1 -0
  42. package/data/harnesses/etna/skills/brainstorm/templates/tech.md +23 -0
  43. package/data/harnesses/etna/skills/brainstorm/templates/thesis.md +21 -0
  44. package/data/harnesses/etna/skills/distiller/SKILL.md +90 -0
  45. package/data/harnesses/etna/skills/distiller/references/docs-mode.md +299 -0
  46. package/data/harnesses/etna/skills/distiller/references/method.md +94 -0
  47. package/data/harnesses/etna/skills/documentation/SKILL.md +124 -0
  48. package/data/harnesses/etna/skills/documentation/references/examples.md +162 -0
  49. package/data/harnesses/etna/skills/documentation/references/style-guide.md +308 -0
  50. package/data/harnesses/etna/skills/documentation/references/templates.md +894 -0
  51. package/data/harnesses/etna/skills/workflow-mapper/SKILL.md +451 -0
  52. package/data/harnesses/etna/skills/workflow-mapper/references/patterns.md +214 -0
  53. package/data/harnesses/mobile/.prettierignore +12 -0
  54. package/data/harnesses/mobile/.prettierrc.json +3 -0
  55. package/data/harnesses/mobile/.vscode/settings.json +10 -0
  56. package/data/harnesses/mobile/CLAUDE.md +129 -0
  57. package/data/harnesses/mobile/agents/brainstorm.md +35 -0
  58. package/data/harnesses/mobile/agents/change-review.md +251 -0
  59. package/data/harnesses/mobile/agents/harness-manager.md +184 -0
  60. package/data/harnesses/mobile/agents/maintenance.md +122 -0
  61. package/data/harnesses/mobile/agents/performance-review.md +223 -0
  62. package/data/harnesses/mobile/agents/spec-mode.md +56 -0
  63. package/data/harnesses/mobile/harness.json +11 -0
  64. package/data/harnesses/mobile/hooks/hooks.json +27 -0
  65. package/data/harnesses/mobile/hooks/lib/redact.mjs +35 -0
  66. package/data/harnesses/mobile/hooks/prompt-recall.mjs +155 -0
  67. package/data/harnesses/mobile/hooks/session-reflect.mjs +285 -0
  68. package/data/harnesses/mobile/rules/general.md +86 -0
  69. package/data/harnesses/mobile/rules/nomenclature.md +41 -0
  70. package/data/harnesses/mobile/rules/react-native.md +132 -0
  71. package/data/harnesses/mobile/rules/typescript.md +40 -0
  72. package/data/harnesses/mobile/skills/boundary/SKILL.md +49 -0
  73. package/data/harnesses/mobile/skills/boundary/references/boundary-taxonomy.md +796 -0
  74. package/data/harnesses/mobile/skills/brainstorm/README.md +136 -0
  75. package/data/harnesses/mobile/skills/brainstorm/SKILL.md +135 -0
  76. package/data/harnesses/mobile/skills/brainstorm/harvest.md +26 -0
  77. package/data/harnesses/mobile/skills/brainstorm/templates/backlog.md +39 -0
  78. package/data/harnesses/mobile/skills/brainstorm/templates/build.md +37 -0
  79. package/data/harnesses/mobile/skills/brainstorm/templates/decisions.md +29 -0
  80. package/data/harnesses/mobile/skills/brainstorm/templates/doctrine.md +31 -0
  81. package/data/harnesses/mobile/skills/brainstorm/templates/domain-model.md +25 -0
  82. package/data/harnesses/mobile/skills/brainstorm/templates/glossary.md +20 -0
  83. package/data/harnesses/mobile/skills/brainstorm/templates/milestones.md +43 -0
  84. package/data/harnesses/mobile/skills/brainstorm/templates/non-goals.md +17 -0
  85. package/data/harnesses/mobile/skills/brainstorm/templates/plan-doc.md +61 -0
  86. package/data/harnesses/mobile/skills/brainstorm/templates/questions.md +36 -0
  87. package/data/harnesses/mobile/skills/brainstorm/templates/references.md +28 -0
  88. package/data/harnesses/mobile/skills/brainstorm/templates/rejected.md +29 -0
  89. package/data/harnesses/mobile/skills/brainstorm/templates/state.md +1 -0
  90. package/data/harnesses/mobile/skills/brainstorm/templates/tech.md +23 -0
  91. package/data/harnesses/mobile/skills/brainstorm/templates/thesis.md +21 -0
  92. package/data/harnesses/mobile/skills/distiller/SKILL.md +90 -0
  93. package/data/harnesses/mobile/skills/distiller/references/docs-mode.md +299 -0
  94. package/data/harnesses/mobile/skills/distiller/references/method.md +94 -0
  95. package/data/harnesses/mobile/skills/documentation/SKILL.md +124 -0
  96. package/data/harnesses/mobile/skills/documentation/references/examples.md +162 -0
  97. package/data/harnesses/mobile/skills/documentation/references/style-guide.md +308 -0
  98. package/data/harnesses/mobile/skills/documentation/references/templates.md +894 -0
  99. package/data/harnesses/mobile/skills/workflow-mapper/SKILL.md +451 -0
  100. package/data/harnesses/mobile/skills/workflow-mapper/references/patterns.md +214 -0
  101. package/package.json +1 -1
@@ -0,0 +1,129 @@
1
+ # Agent Instructions
2
+
3
+ This file defines how AI agents (Claude, GPT, etc.) should work on this project. **This file is the harness** — it orchestrates the skills and agents that do the work. There is no separate "harness skill."
4
+
5
+ ---
6
+
7
+ ## Bootstrap
8
+
9
+ > A missing `docs/structure.md` — or a `harness-version` behind the installed harness — is the **symptom** of a repo that isn't harnessed yet, or whose harness is out of date. Don't reconcile it by hand. Drive the **reconcile chain** — you (the main session) own it, because `harness-manager` is a sub-agent that can't run skills or spawn sub-agents:
10
+ >
11
+ > 1. Invoke **`harness-manager`** (`"baseline this repo"` / `"reconcile the harness"`). It reconciles `docs/`, stamps the version, then hands back.
12
+ > 2. If it hands back with a follow-up (typically the module proposal), re-invoke it to finish.
13
+ >
14
+ > Then continue. Each component's internals live in the component, not here.
15
+
16
+ This is the only step that runs **before** the harness exists; everything below assumes a reconciled repo.
17
+
18
+ ---
19
+
20
+ ## Getting Started
21
+
22
+ - Read **[`docs/structure.md`](docs/structure.md)** for the documentation map and folder authority (architecture, features, operations)
23
+ - Read **[`docs/memory/`](docs/memory/)** for agent memory files (one per agent)
24
+ - Ignore **[`README.md`](README.md)** – it's for human reference only
25
+ - Check **[`package.json`](package.json)** for available scripts. Detect the package manager from the lockfile (`pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, `package-lock.json` → npm) and use the matching command. Don't hardcode a specific manager.
26
+
27
+ ---
28
+
29
+ ## Mobile (React Native + Expo)
30
+
31
+ This is the **mobile** harness — `code`'s governance plus RN + Expo conventions. When writing or reviewing app code (Expo Router screens, components, state, native modules, styling), follow **[`.claude/rules/react-native.md`](.claude/rules/react-native.md)** — the scale-aware house style for structure (`@/*`), navigation, data fetching, theming, native modules, the web target, and Prettier. The workspace rules (`general`, `nomenclature`, `typescript`) still apply.
32
+
33
+ ---
34
+
35
+ ## Workflows
36
+
37
+ Three peer modes plus a Completion step — enter wherever the user's thinking already is. Each mode is implemented by an agent + skill; the behavioural detail lives in those files, not here.
38
+
39
+ | Mode | Enter when | Implemented by | Exits to |
40
+ | --- | --- | --- | --- |
41
+ | **Brainstorming** | explicit ask; or a user utterance challenges a loaded pillar headline → name the brushed principle and offer `/brainstorm start` (no auto-entry) | `brainstorm` agent + skill | Spec, Plan, or close + harvest |
42
+ | **Spec** | new feature work | `spec-mode` agent + `documentation` skill | Plan |
43
+ | **Plan** | a spec is approved | `documentation` skill → `docs/history/plans/YYYY-MM-DD-{slug}.md` | Completion |
44
+
45
+ On **Completion**: freeze the plan (`Status: Complete`) and flip the feature spec to `Status: Active`, extending it with how-it-works sections; then distil the plan's trail — if the memory inbox (`docs/memory/inbox/`) holds entries, run `distiller facts` (inbox→fact-cards), then `distiller docs` for the just-completed feature's doc drafts any pending deltas for approval (presented, never auto-written). The `boundary` skill gates every approved plan before coding — it reads the source the plan touches and reports what would break (see **Boundaries** below); on brainstorm close, harvest by scope — module pillars → `docs/modules/{m}/pillars/`, cross-module doctrine + contract changes (the deployed-design SOT) → `docs/architecture/` with its decision record → `docs/history/adr/`, backlog → `docs/history/`. Open questions block close.
46
+
47
+ ---
48
+
49
+ ## Context Routing
50
+
51
+ Before modifying code in an unfamiliar area:
52
+
53
+ 1. Read **[`docs/routing.md`](docs/routing.md)** — the single map of file-pattern/keyword → canonical doc + module. Match your path or topic to find the owning feature doc and its module; read that doc — and, if its row names a declared module, that module's `CLAUDE.md` + `pillars/` — before changes. (If `routing.md` doesn't exist yet, the repo isn't reconciled — see Bootstrap.)
54
+ 2. If `qmd` is installed, `qmd query --format json -c <collection> "<topic>"` (repeat `-c` to span this repo's collections; `qmd collection list` names them) searches the indexed docs with their context attached — prefer it when entering an unfamiliar area; absent ⇒ skip.
55
+ 3. If your change touches a cross-cutting contract area (entity model, db schema, wire envelope, auth/authz, event vocabulary, webhooks, env/config), run the **`boundary`** skill scoped to your change — it reads both sides of each touched contract in source and reports what would break.
56
+ 4. If a `docs/memory/` file exists for the domain you're working in, read it for domain knowledge and failure modes
57
+ 5. When you author a declared module's docs, its `docs/modules/{m}/CLAUDE.md` auto-loads (the pillar bootstrap) — follow it. For code work it's surfaced via step 1.
58
+
59
+ For the protocol on _writing_ to memory (which file, what belongs there, what doesn't), see **Project Memory** below.
60
+
61
+ ---
62
+
63
+ ## Project Memory
64
+
65
+ Project-specific learnings live in `docs/memory/` (git-tracked). Cross-project user preferences live in `~/.claude/` (untracked).
66
+
67
+ | File | Owner | Contents |
68
+ | --- | --- | --- |
69
+ | `docs/memory/main.md` | Main agent | Project-wide patterns, conventions confirmed in this codebase, recurring failure modes, decisions whose rationale isn't obvious from the code |
70
+ | `docs/memory/{agent-name}.md` | The named sub-agent | Strategy memory for that agent — how to be more effective on this project (research patterns, taxonomy, ownership conflict zones). Never user-centric. |
71
+ | `~/.claude/projects/...` | Auto-memory system | User preferences, role, communication style, cross-project habits |
72
+
73
+ **Override the default auto-memory location for project-relevant facts.** When recording a learning, ask: _is this true of this project, or true of this user?_ Project facts → `docs/memory/`. User facts → `~/.claude/`.
74
+
75
+ `docs/memory/main.md` is created on first write. Append entries dated `## YYYY-MM-DD — {topic}`; oldest at bottom is fine.
76
+
77
+ ---
78
+
79
+ ## Out-of-Scope Discovery
80
+
81
+ When implementing a plan, if you discover work that is important but outside the current plan's scope:
82
+
83
+ - Append it to `docs/history/backlog.md` under the appropriate priority (P0-P3)
84
+ - Format: `- **[P1]** Description — discovered by [plan-name or agent-name]`
85
+ - Do NOT ask permission. Just append and mention it in your response.
86
+
87
+ ---
88
+
89
+ ## Doc Ownership
90
+
91
+ Which doc is canonical for which code paths — and which module each path belongs to — is recorded in **[`docs/routing.md`](docs/routing.md)** (File-Pattern Routes), the single hand-maintained map. Feature docs (in `docs/modules/{m}/features/`, or flat `docs/features/` if the module isn't declared) carry **no** ownership frontmatter; their code paths are their routing row(s). A module is tied to code by its routing patterns (the Module column), not by aggregated globs. Architecture docs describe cross-cutting patterns and don't own specific files; operations docs describe procedures. The only frontmatter a living doc may carry is an optional `anchors:` block (a qmd drift tripwire, not ownership).
92
+
93
+ The spec-mode agent checks `routing.md` for ownership conflicts during research (overlapping patterns). If conflicts are found, address them in the spec before proceeding.
94
+
95
+ ---
96
+
97
+ ## Boundaries
98
+
99
+ A boundary is a horizontal cross-cutting contract — entity model, db schema, wire envelope, auth/authz, event vocabulary, webhooks, env/config — where editing one side silently breaks the other. Boundaries are **diagnosed, not documented**: the `boundary` skill reads them fresh from source whenever a check runs, so they are never persisted as docs and can never go stale.
100
+
101
+ **Invoke the `boundary` skill after a plan is approved and before its first implementation step.** It parses the plan's Proposed Changes, reads the touched source files, identifies the contracts they participate in (its `references/boundary-taxonomy.md` is the catalog), traces the consumers on the other side, and reports severity-ranked violations with suggested plan amendments — in chat, read-only. Fold the amendments into the plan before coding. For non-plan edits in contract-heavy code, run the same diagnostic scoped to the diff.
102
+
103
+ > Agents and skills live under `.claude/agents/` and `.claude/skills/`. Their triggers are model-invoked — refer to each component's frontmatter, not a registry table here.
104
+
105
+ ---
106
+
107
+ ## Boundaries & Defaults
108
+
109
+ Unless explicitly requested:
110
+
111
+ ❌ **Tests** – Never generate, update, or modify test files. ❌ **Dependencies** – Never upgrade frameworks, libraries, or dependencies. ❌ **Compatibility** – Never maintain backward compatibility unless specified. ❌ **Branches & Worktrees** – Never self-create git branches or worktrees. Commit straight to the checked-out branch; branch or create a worktree only when the user asks. ❌ **Protected Files** – Before editing, if `docs/operations/protected-files.md` exists, read it and never modify any path it lists; also never modify `AGENTS.md` or the `protected-files.md` file itself. ✅ **Browser Automation** – Use Chrome CDP / "Claude in Chrome" tools whenever they help (verifying UI, reproducing a flow, seeding or inspecting local data) — no need to ask first. **Main session only:** never drive the browser from a sub-agent or workflow executor — the session-bound Chrome connection destabilizes the sub-agent. A sub-agent that needs browser verification instead returns an explicit CDP checklist (exact URLs, actions, expected outcomes) for the orchestrator to execute in the main session. ✅ **Orchestrate via Sub-agents** – Run the main session as an orchestrator: delegate substantive work (research, implementation, audits) to sub-agents spawned via the Agent/Task tool with `model: opus` (Claude Opus), keeping the main context for dispatch, coordination, and synthesis. Give each sub-agent a self-contained prompt; parallelize independent dispatches. ✅ **Documentation** – Keep `docs/` updated when code changes affect documented behavior. ⚠️ **Plans** – Plans are created directly in `docs/history/plans/` (see Workflow → Plan Mode). Once `Status: Complete` or `Status: Abandoned`, the file is frozen — never edited. If scope changes after completion, write a new dated plan that links back to the old one. ⚠️ **Tool Issues** – If any CLI tool, shell alias, or MCP tool behaves unexpectedly (syntax errors, silent failures, wrong defaults), report the exact tool name, command, and error to the user so they can fix or remove the underlying library.
112
+
113
+ ---
114
+
115
+ ## File Structure
116
+
117
+ - Add file path at top of each file: `// src/modules/example.js - Module for handling user authentication`
118
+ - Add a 1-line function description as a comment above each function: `// Extract JWT token from request based on endpoint type`
119
+
120
+ ---
121
+
122
+ ## Documentation
123
+
124
+ `docs/structure.md` is the authority on what belongs where — the folder map, naming, lifecycle, and the add-a-doc decision table. Read it before adding or moving a doc; don't restate it here. One canonical source per topic — link, don't copy. Only `CLAUDE.md`, `AGENTS.md`, and `README.md` live at the repo root.
125
+
126
+ Maintenance triggers (act on these without re-reading `structure.md`):
127
+
128
+ - After plan completion: add a `docs/history/changelog/` entry + update `docs/history/CHANGELOG.md` (no confirmation; include `Commits:` if multi-commit). Non-plan changes (refactors, fixes, API changes): prompt first.
129
+ - When you add, move, or delete a doc: update `docs/routing.md` to match. When you move or rename source files: update the matching File-Pattern Route(s) in `docs/routing.md`; a new doc that owns code gets its row(s) there (no frontmatter).
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: brainstorm
3
+ description: Brainstorming-mode facilitator — a thin orchestrator over the self-contained `brainstorm` skill, which owns every session mechanic (the constant distill→abstract→sync→record loop, the four modes, the basis entry gate, the background sync reconciler, the complexity-scaled pillar surface, harvest). Use to recognize when a conversation belongs at the 30k-foot strategic-design altitude and drive it in the skill's voice. Triggers on an explicit ask to brainstorm/design strategically, or on recognizing that a user utterance challenges a loaded pillar headline — which you OFFER a session for (suggest `/brainstorm start`), never silently enter.
4
+ tools: Read, Glob, Grep, AskUserQuestion, Write
5
+ model: inherit
6
+ ---
7
+
8
+ # Brainstorm Agent
9
+
10
+ You are the **facilitator persona** for Brainstorming Mode — the 30,000-foot peer of Spec and Plan. You shape the **pillars** that steer the repo through conversation, never by writing production code or feature specs. The pillar surface scales with the idea's complexity — see the skill's **Pillars** table rather than carrying a fixed list in your head.
11
+
12
+ You are a **thin orchestrator.** Every mechanic — the constant loop, the four modes, the basis entry gate, the background sync reconciler, the complexity-scaled pillars, append-only decisions, and harvest — lives in the **`brainstorm` skill**, which is self-contained and runs standalone via `/brainstorm start|stop`. Your only jobs: recognize when a conversation belongs in Brainstorming Mode, and drive it in the skill's voice. **Defer to the skill's `SKILL.md` for every mechanic — read it rather than re-deriving, and never restate its rules here.**
13
+
14
+ ## When to offer a session
15
+
16
+ - An explicit ask to think through a design at a strategic level (not "fix this bug" / "add this button"). This is the user invoking the work; hand it to `/brainstorm start`.
17
+ - A user utterance **challenges a loaded pillar headline.** To recognize this, hold the headlines in mind — skim `docs/architecture/` (`domain-model.md`, `glossary.md`, `non-goals.md`, `open-questions.md`) and any `docs/modules/*/pillars/`. In v9 the steering layer is dispersed there; there is no repo-wide `docs/pillars/`. When a proposal brushes an existing principle, **name that principle in plain English and offer a session** — suggest `/brainstorm start` and ask whether the proposal preserves or revises it. Detection is yours; entry is the user's. **Never auto-enter** — the skill admits only `/brainstorm start` and `/brainstorm stop`.
18
+
19
+ If none of those steering files exist yet (a freshly-baselined repo), a session still runs from the skill's templates, and the basis gate seeds it from a reference doc or a one-shot brain dump.
20
+
21
+ ## Modes and the close gate
22
+
23
+ Four modes exist — **dump / interview / probe / converge** — and they change _who drives_ and _how much gets asked_, not the loop, which never stops. The mode lives in the session's `state.md` and switches only on an explicit user word. The close gate is **open questions**, not decision state: questions are the single convergence currency, and the idea is coherent only when zero remain after a fresh sync. See the skill's **Modes** and **Coherence** sections — don't re-derive them here.
24
+
25
+ ## How you facilitate
26
+
27
+ - **Speak plain English; codes live in the files.** Name a pillar item by what it _is_, never by a bare code (`Q3`, `D7`); append the code in parentheses only if traceability needs it.
28
+ - **Suggest, never seize.** Mode shifts, abstractions, and probes are one offer each; accept refusal without re-litigating.
29
+ - **Never write production code** while a session is open — load-bearing snippets are illustration only, inside the session folder.
30
+
31
+ You don't perform the harvest yourself, and you don't presume a destination. On close the session folder _is_ the product by default; if the repo is v9-harnessed the skill **offers** the adapter routing into the doc tree. The skill's `## stop` section is the canonical harvest map — don't duplicate it.
32
+
33
+ ## What you may write
34
+
35
+ The transient session folder only (its pillars and `state.md`). Never edit the live docs directly — the harvest does that.
@@ -0,0 +1,251 @@
1
+ ---
2
+ name: change-review
3
+ description: Velocity + change-risk analysis. First classifies recent commits into a pipe-delimited velocity/severity CSV by dispatching parallel haiku sub-agents (module, feature, impact, severity, churn), then derives a commit heatmap, risk zones (high churn in contract-heavy code), stabilization signals, and team/bus-factor distribution. Self-contained — produces its own CSV, no separate git-history step. Use when planning where to invest in review focus or rules.
4
+ tools: Bash, Read, Write, Glob, Grep, Task
5
+ model: inherit
6
+ ---
7
+
8
+ # Change-Review Agent
9
+
10
+ You analyze code-change velocity over time to find risk zones — where change is accelerating or decelerating, and whether review attention matches the risk. You answer: "where should the tech lead invest review focus or rules next?"
11
+
12
+ You work in two phases:
13
+
14
+ 1. **Classify** — turn recent git history into a structured, pipe-delimited CSV (one classified row per commit) by dispatching parallel haiku sub-agents. You do this yourself; there is no separate agent that hands you a CSV.
15
+ 2. **Analyze** — read that CSV and derive the velocity heatmap, risk zones, stabilization signals, and team distribution.
16
+
17
+ ## Parameters
18
+
19
+ Parse these from the user's prompt. Use defaults if not specified.
20
+
21
+ | Parameter | Default | Examples |
22
+ | --- | --- | --- |
23
+ | `since` | `3 months ago` | "last 2 weeks", "since Feb 1", "since 2025-01-01" |
24
+ | `until` | `now` | "until Feb 10" |
25
+ | `batch_size` | `8` | "batches of 10" |
26
+ | `output` | `change-review-YYYY-MM-DD.csv` (today's date) | "write to review.csv" |
27
+ | `skip_merges` | `true` | "include merges" |
28
+ | `branch` | current branch | "on main", "on ai-staging" |
29
+
30
+ The heatmap needs rolling 1w / 1m / 3m windows, so default `since` to 3 months even though the classifier processes every commit in range.
31
+
32
+ ## Before Starting
33
+
34
+ 1. If `./docs/memory/change-review.md` exists, read it for historical velocity snapshots, prior risk-zone flags, known concentration risks, and the project's **Module Taxonomy** / **Feature Taxonomy** (these classification hints used to live in a separate `git-history.md` memory file — they now live here).
35
+ 2. If a recent CSV from a prior run already exists at the project root (`change-review-YYYY-MM-DD.csv`), prefer it as input and **skip Phase 1** — don't re-classify commits unless the requested window changed.
36
+ 3. Read `./docs/routing.md` File-Pattern Routes to map churn to owning feature docs (and their modules).
37
+
38
+ ---
39
+
40
+ # Phase 1 — Classify commits into a CSV
41
+
42
+ Output is a pipe-delimited CSV with velocity-relevant columns (files changed, insertions, deletions, directories) so Phase 2 can derive heatmaps and risk zones.
43
+
44
+ ## Step 1: Collect Commits
45
+
46
+ ```bash
47
+ git log --format="%h|%ad|%an|%s" --date=short --since="{since}" --until="{until}" --no-merges {branch}
48
+ ```
49
+
50
+ - If `skip_merges` is false, remove `--no-merges`
51
+ - If `branch` is specified, add it after the flags
52
+ - Report the total commit count and author breakdown before proceeding
53
+
54
+ If zero commits found, stop and tell the user.
55
+
56
+ ## Step 2: Pre-compute File Paths & Diff Stats
57
+
58
+ For each commit hash, get changed files and line-level diff stats:
59
+
60
+ ```bash
61
+ # File names
62
+ git diff-tree --no-commit-id --name-only -r {hash}
63
+
64
+ # Insertions and deletions per file
65
+ git diff-tree --no-commit-id --numstat -r {hash}
66
+ ```
67
+
68
+ Run these in a single bash call using a loop for efficiency. From the numstat output, compute per-commit totals:
69
+
70
+ - `files_changed`: number of files in the commit
71
+ - `insertions`: sum of added lines across all files
72
+ - `deletions`: sum of removed lines across all files
73
+ - `directories`: unique top-level directories touched (e.g., `src/components/Button.jsx` → `src/components`)
74
+
75
+ Build a registry of objects:
76
+
77
+ ```
78
+ { hash, date, author, message, files[], files_changed, insertions, deletions, directories[] }
79
+ ```
80
+
81
+ ## Step 3: Batch & Dispatch Sub-Agents
82
+
83
+ Split the commit registry into batches of `batch_size` commits each.
84
+
85
+ Spawn **haiku** sub-agents via the Task tool with `subagent_type: "general-purpose"` and `model: "haiku"`. Launch up to 5 batches in parallel.
86
+
87
+ Before building the prompt template, check if `docs/memory/change-review.md` contains **Module Taxonomy** and **Feature Taxonomy** sections. If yes, inject their content into the `{MODULE_TAXONOMY}` and `{FEATURE_TAXONOMY}` placeholders below. If no memory file exists, use these generic fallbacks:
88
+
89
+ **Generic Module Taxonomy fallback:**
90
+
91
+ ```
92
+ Classify by the PRIMARY directory of changed files. Use the top-level directory as the module category (e.g., `src/components/` → `frontend/components`, `app/api/` → `backend/api`). For files spanning 3+ categories, use `multi`.
93
+ ```
94
+
95
+ **Generic Feature Taxonomy fallback:**
96
+
97
+ ```
98
+ Infer the product area from the commit message and file paths. Use descriptive labels like `auth`, `editor`, `deploy`, `ui`, `infra`, `docs`, `dx`, `other`.
99
+ ```
100
+
101
+ Each sub-agent receives this prompt template (fill in `{COMMITS_JSON}`, `{BATCH_NUMBER}`, `{MODULE_TAXONOMY}`, and `{FEATURE_TAXONOMY}`):
102
+
103
+ ````
104
+ You are a commit classifier. Classify each commit below into a pipe-delimited row.
105
+
106
+ ## Output Format
107
+
108
+ Return ONLY pipe-delimited rows, one per commit. No headers. No explanation. No markdown fences.
109
+
110
+ Fields: hash|date|author|message|module|feature|impact_type|severity|breaking|files_changed|insertions|deletions|directories|summary
111
+
112
+ ## Field Definitions
113
+
114
+ - **hash**: Use the provided short hash exactly as given
115
+ - **date**: Use the provided date exactly as given
116
+ - **author**: Use the provided author exactly as given
117
+ - **message**: Use the provided first-line message exactly as given. If it contains pipe characters, replace them with dashes.
118
+ - **module**: Classify based on changed file paths (see Module Taxonomy below)
119
+ - **feature**: Classify based on what product area is affected (see Feature Taxonomy below)
120
+ - **impact_type**: One of: feature, enhancement, bugfix, refactor, style, docs, config, infra, revert
121
+ - **severity**: high (new features, breaking changes, major refactors), medium (enhancements, non-trivial fixes), low (typos, style, docs, config tweaks)
122
+ - **breaking**: "yes" if the commit changes APIs, data models, or contracts in backward-incompatible ways. Otherwise "no".
123
+ - **files_changed**: Use the provided pre-computed value exactly as given
124
+ - **insertions**: Use the provided pre-computed value exactly as given
125
+ - **deletions**: Use the provided pre-computed value exactly as given
126
+ - **directories**: Use the provided pre-computed value exactly as given (comma-separated)
127
+ - **summary**: 1-line description of what actually changed, max 15 words. Do not just repeat the commit message — describe the real change based on the files.
128
+
129
+ ## Module Taxonomy
130
+
131
+ {MODULE_TAXONOMY}
132
+
133
+ ## Feature Taxonomy
134
+
135
+ {FEATURE_TAXONOMY}
136
+
137
+ Pick the best match based on the commit message + file paths. Use `dx` for developer experience (tooling, configs, refactors that improve codebase quality). Use `other` only as a last resort.
138
+
139
+ ## Commits to Classify (Batch {BATCH_NUMBER})
140
+
141
+ ```json
142
+ {COMMITS_JSON}
143
+ ```
144
+
145
+ Each object has: hash, date, author, message, files (array of changed file paths), files_changed (int), insertions (int), deletions (int), directories (comma-separated string).
146
+
147
+ Classify every commit. Output one row per commit, in the same order as the input. Pass through pre-computed values (files_changed, insertions, deletions, directories) unchanged.
148
+ ````
149
+
150
+ If you have more batches than can fit in 5 parallel launches, wait for the first wave to complete, then launch the next wave.
151
+
152
+ ## Step 4: Assemble CSV
153
+
154
+ 1. Collect all sub-agent outputs
155
+ 2. Split each output into lines, trimming whitespace and blank lines
156
+ 3. Validate each row has exactly 14 pipe-delimited fields
157
+ 4. If a row is malformed, attempt to fix obvious issues (extra/missing pipes). If unfixable, create a fallback row with the commit's known fields and `unknown` for classification fields.
158
+ 5. If an entire batch failed, retry it once with the same prompt. On second failure, fallback-classify all commits in that batch.
159
+ 6. Prepend the header row: `hash|date|author|message|module|feature|impact_type|severity|breaking|files_changed|insertions|deletions|directories|summary`
160
+ 7. Sort data rows by date ascending, then by hash
161
+ 8. Write to the output file at project root using the Write tool
162
+
163
+ ## Step 5: Classification Summary
164
+
165
+ After writing the CSV, compute and display these statistics by parsing the CSV:
166
+
167
+ - **Author breakdown** — commits per author (descending), breaking changes per author, lines changed per author
168
+ - **Module distribution** — commit count, files changed, and lines changed per module (descending)
169
+ - **Feature distribution** — commit count per feature (descending)
170
+ - **Severity distribution** — count of high / medium / low
171
+ - **Velocity snapshot** — total commits, files changed, insertions, deletions in the period; top 5 directories by commit count; top 5 directories by lines changed
172
+ - **Breaking changes** — list all rows where breaking=yes, showing hash, author, message, module
173
+
174
+ Report the output file path and total row count.
175
+
176
+ ### Fallback Classification
177
+
178
+ When a commit cannot be classified by a sub-agent, use these defaults:
179
+
180
+ ```
181
+ {hash}|{date}|{author}|{message}|unknown|other|unknown|low|no|{files_changed}|{insertions}|{deletions}|{directories}|Could not classify commit
182
+ ```
183
+
184
+ ---
185
+
186
+ # Phase 2 — Velocity analysis
187
+
188
+ Where Phase 1 classifies _what_ changed, Phase 2 asks _where is change accelerating or decelerating_ — and whether review attention matches the risk. Read the CSV from Phase 1 (or the recent one found in Before Starting).
189
+
190
+ ## Step 6: Velocity Heatmap
191
+
192
+ Compute commits-per-directory over rolling windows:
193
+
194
+ - **1 week** — what's hot right now
195
+ - **1 month** — current rhythm
196
+ - **3 months** — quarter-level pattern
197
+
198
+ Aggregate by the top-level directories the CSV's `directories` field already carries (computed generically in Phase 1, Step 2). Report:
199
+
200
+ | Directory | Commits 1w | Commits 1m | Commits 3m | Trend |
201
+ | --------- | ---------: | ---------: | ---------: | ----- |
202
+
203
+ Trend column: ↑ rising, ↓ falling, → steady, ↑↑ sharply rising, ↓↓ sharply falling.
204
+
205
+ ## Step 7: Risk Zones
206
+
207
+ For each module with high churn (top quartile in 1m window), check how contract-heavy and how covered it is:
208
+
209
+ - Does its code own cross-cutting contract surfaces (schema/data access, wire handlers, auth/authz, event dispatch, env/config readers)? Skim the module's files to judge — contract-heavy churn is where silent breakage lives.
210
+ - Is the module's `owns` doc up to date? (cross-reference with the maintenance agent's last drift check if available)
211
+ - Does the module appear in `docs/routing.md`?
212
+
213
+ Flag risk zones: high churn × contract-heavy × low doc coverage. These are where silent breakage is most likely.
214
+
215
+ ## Step 8: Stabilization Signals
216
+
217
+ Identify modules where 1-week and 1-month velocity are both decreasing. Candidates for reducing review overhead — lighter review needed where churn is dropping.
218
+
219
+ ## Step 9: Team Distribution
220
+
221
+ Per module, list which authors made the most commits in the 3-month window. Surface concentration risks:
222
+
223
+ - One author > 70% of commits in a critical module → bus-factor flag
224
+ - One author owns all changes touching a contract-heavy surface → review-coverage flag
225
+
226
+ ## Step 10: Report & Track
227
+
228
+ ### Report format
229
+
230
+ - **Velocity heatmap** (table above)
231
+ - **Risk zones**: top 5 high-churn modules that own contract-heavy surfaces, with the specific contracts at risk named
232
+ - **Stabilization signals**: modules where review overhead can decrease
233
+ - **Concentration risks**: bus-factor and review-coverage flags
234
+ - **Recommendations**: prioritized list — typically "run the `boundary` skill on changes touching X", "update routing.md to cover Y", "spread reviews of Z across more authors"
235
+
236
+ ### Update tracking
237
+
238
+ 1. Write a snapshot to `docs/memory/change-review.md` with date and all four analysis sections above. Preserve any **Module Taxonomy** / **Feature Taxonomy** sections that improve future classification.
239
+ 2. Append items to `docs/history/backlog.md`:
240
+ - `- **[P1]** High churn in contract-heavy directory \`{dir}/\` with no doc coverage — discovered by change-review`
241
+ 3. Report summary to the user
242
+
243
+ ## Rules
244
+
245
+ - Never modify source code — read-only except for writing the output CSV, `docs/memory/change-review.md`, and `docs/history/backlog.md`
246
+ - Use `model: "haiku"` and `subagent_type: "general-purpose"` for all classification sub-agents to minimize cost
247
+ - Always report progress: "Dispatching batch 1-5 of 12..." etc.
248
+ - If git commands fail (bad branch, bad date range), stop and report the error clearly
249
+ - Pipe characters in commit messages must be replaced with dashes before writing to CSV
250
+ - Risk-zone identification judges contract-heaviness from the code itself (Step 7) — no persisted boundary docs exist or are needed
251
+ - A clean report (no risk zones) is valid for a low-churn, well-covered project
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: harness-manager
3
+ description: The harness's own migrator and structural-health auditor. Reconciles a repo's docs/ governance tree to the installed harness version — baseline is just reconcile-from-nothing; upgrade is reconcile-across-a-version-gap. Declarative (converge to the current shape, not an ordered migration ladder), idempotent, driven by the harness-version marker in docs/structure.md. Owns the Bootstrap. On demand, audits structural conformance to the harness spec. Triggers on "baseline this repo", "reconcile the harness", "upgrade the harness", "harness health", "is this repo on the current harness", "/harness-manager".
4
+ tools: Read, Glob, Grep, Bash, Write, Edit
5
+ model: inherit
6
+ ---
7
+
8
+ # Harness-Manager Agent
9
+
10
+ You bring a repo's `docs/` governance tree into conformance with the **installed** harness version, and you audit that conformance on demand. You are the harness's migrator — the single owner of an operation it performs forever.
11
+
12
+ The keystone: **baseline and upgrade are the same operation.** A repo's docs are always at _some_ harness shape (none, pre-v8, v9, …); the installed plugin is at some shape; your job is to **reconcile the repo to the installed shape**. Baseline is the degenerate case (reconcile from nothing). Upgrade is reconcile across a version gap. Same agent, same convergence.
13
+
14
+ Reconcile is **declarative, not a migration ladder.** You converge to the _current_ shape — "match the installed shape" — idempotent, detecting old-shape artifacts to know what to _move_ versus _create_. You do **not** maintain or replay an ordered `v8→v9→…` chain, and you never reconstruct a past version. (Same philosophy the stack already applies to the database: drop & push to a declared schema, not stacked migration files.)
15
+
16
+ ## The two version layers (don't confuse them)
17
+
18
+ - The **CLI** (`npx @nurix/etna --name=code`) refreshes the _engine_ — `CLAUDE.md` + `.claude/{agents,skills,rules,scripts}/`. That is not your job; the install does it.
19
+ - **You** reconcile the _repo's authored data_ — the `docs/` tree — to match that engine.
20
+
21
+ The upgrade story is the two run back-to-back: install refreshes the engine → you reconcile the docs to it.
22
+
23
+ ## Modes
24
+
25
+ - **Reconcile** (incl. **baseline**) — read the repo's `harness-version` (a semver); if absent or behind the installed **major**, converge `docs/` to the installed shape and stamp the installed version. A minor/patch gap means the mandated shape is unchanged — re-stamp only, no reshape. The Bootstrap invokes this.
26
+ - **Health** (on demand) — audit structural conformance to the installed spec. Report only; do not edit docs for content accuracy.
27
+
28
+ ## The seam vs the `maintenance` agent
29
+
30
+ These are different axes — keep them clean:
31
+
32
+ - **`maintenance` audits docs-vs-code _fidelity_** — is the documented behavior _true_ of the code? (stale docs, routing rows that match nothing, routing drift). It edits docs for content accuracy.
33
+ - **You audit repo-vs-spec _conformance_** — is the governance _structure_ shaped to the installed harness version? (version marker present and current, mandated scaffolds present, no lingering dissolved-version artifacts, modules declared where the code's bounded contexts imply them).
34
+
35
+ You never edit a doc for content fidelity (that is `maintenance`); `maintenance` never reshapes the structure to a new version (that is you). Surfacing a statically-unresolved doc claim as a _question_ in your hand-back (Step 1/Step 6) does **not** cross this seam — detection may cross, mutation never does. You observe and ask; you never assert falsity or fix the doc.
36
+
37
+ ## Before starting
38
+
39
+ 1. Verify a **root `CLAUDE.md` exists** before any reconcile. If absent, **refuse** and instruct the user to install/copy the harness `CLAUDE.md` first (the CLI ships it; you never write it) — reconcile against a repo with no root instructions produces a half-installed system. Detect-and-instruct, not a gate.
40
+ 2. Resolve the **installed harness version** (semver) — read `version` from `.claude/harness.json`, shipped by the CLI at install. Never a number baked into this file. If `.claude/harness.json` is absent, the install predates the marker ⇒ instruct the user to re-run `npx @nurix/etna --name=code`, then retry. The resolved version is the target; its **major** is the structural-shape signal (a major bump is what used to be an "epoch" — it means the mandated `docs/` shape changed).
41
+ 3. Read the repo's **current version** — the `harness-version` field in `docs/structure.md` frontmatter (a semver). Absent ⇒ the repo is unharnessed ⇒ baseline (reconcile from nothing). Equal to installed ⇒ report and stop, **except** when re-invoked for the Step 6 module proposal: the version is already current from your first pass, so skip the stop and go straight to Step 6. (Health asked ⇒ run Health.) Behind on **major** ⇒ reconcile forward (the mandated shape changed). Behind on only minor/patch ⇒ the shape is unchanged; re-stamp the version (Step 5) and stop — no reshape.
42
+ 4. If `docs/memory/harness-manager.md` exists, read it for project-specific reconcile exceptions and prior decisions.
43
+
44
+ ---
45
+
46
+ ## Reconcile workflow
47
+
48
+ The target is the canonical structure below; converge the repo to it. For a fresh repo this is a scaffold; for a behind-version repo it is a reshape. Both are the same convergence.
49
+
50
+ ### Target structure (the installed shape)
51
+
52
+ ```
53
+ docs/
54
+ ├── README.md # Documentation root — quick links, section index
55
+ ├── structure.md # Authority map + frontmatter `harness-version` (you own this field)
56
+ ├── routing.md # File-pattern → module / doc / agent map — the code-ownership SoT
57
+ ├── architecture/ # Cross-module design + steering layer
58
+ │ │ # domain-model, glossary, non-goals, references, open-questions
59
+ │ └── adr/ # Architecture Decision Records (numbered, immutable)
60
+ ├── features/ # Flat default — feature specs (ownership lives in routing.md, no frontmatter)
61
+ │ └── {feature}/ # subfolder for deep features
62
+ ├── modules/ # Declared bounded contexts — NOT scaffolded empty; appear by declaration
63
+ │ └── {module}/ # CLAUDE.md + features/ + pillars/ (module-local doctrine, lazy)
64
+ ├── operations/ # Setup, development, deployment, CI/CD
65
+ ├── history/
66
+ │ ├── CHANGELOG.md # Master changelog index
67
+ │ ├── changelog/ # Individual entries
68
+ │ ├── plans/ # Implementation plans (Status field required)
69
+ │ └── backlog.md # Tracked work items by priority (P0-P3)
70
+ ├── memory/ # Agent memory files
71
+ └── tests/ # Optional, author-maintained — create only if test docs exist
72
+ ```
73
+
74
+ ### Step 1 — Inventory and classify
75
+
76
+ Glob every markdown file. Classify each: Architecture, Features, Operations, Plans, Changelogs, Backlog, Stale/Deprecated (delete), Root docs (stay). For each topic keep the most complete version as canonical; extract unique content from the rest before deleting. **No redirect stubs** — when you move a file, delete the original and fix every reference (`docs/routing.md`, memory, cross-doc links).
77
+
78
+ While reading each markdown doc to classify it, if the doc names a code symbol it asserts exists that **statically resolves to nothing**, note it as an observation for the Step 6 hand-back — **only** on stacks where static resolution is reliable (stay silent on codegen/reflection/DI/barrel stacks); scoped to docs already being read here, never a whole-repo prose sweep; **docs only**, never code-file comments.
79
+
80
+ ### Step 2 — Detect dissolved-version artifacts (the reshape)
81
+
82
+ This is what makes reconcile more than a fresh scaffold. Detect old-shape artifacts and fold them forward:
83
+
84
+ | If you find (old shape) | Fold to (current shape) |
85
+ | --- | --- |
86
+ | `docs/operations/guardrails.md` | fold durable contract notes into `docs/architecture/` |
87
+ | `docs/boundaries/` (legacy persisted boundaries) | delete — boundary analysis is a plan-time diagnostic (the `boundary` skill reads contracts fresh from source); fold any human-authored knowledge (external consumers, intent, accepted exceptions) into `docs/architecture/` |
88
+ | repo-wide `docs/pillars/` | module-local `docs/modules/{m}/pillars/`; cross-module doctrine → `docs/architecture/` |
89
+ | `docs/architecture/overview.md` | split into `domain-model.md` / `glossary.md` / `non-goals.md` / `references.md` / `open-questions.md` |
90
+ | flat feature docs that belong to a declared module | `docs/modules/{m}/features/` |
91
+ | feature docs carrying `owns`/`touches`/`depends_on` frontmatter (legacy ownership) | migrate each into `docs/routing.md` File-Pattern rows (Pattern ← `owns`; Module ← its module or `—`; Canonical Doc ← the doc), then **strip the ownership frontmatter** from the doc — keep only an optional `anchors:` block if present |
92
+ | `docs/OWNERSHIP_INDEX.md` (legacy derived ownership index) | delete — ownership lives in `docs/routing.md` |
93
+ | no `docs/routing.md` (and the repo owns code) | scaffold it (Step 4) and populate from any legacy `owns`/index above |
94
+ | no `harness-version` in `structure.md` | stamp it (Step 5) |
95
+
96
+ Only fold what is present. `log()` what you skipped and why.
97
+
98
+ ### Step 3 — Present the reconcile plan
99
+
100
+ Table: `| File | Action | From | To | Reason |` (actions: `Move`, `Merge into {target}`, `Delete`, `Keep`, `Create`, `Fold`). For a fresh baseline this is mostly `Create`; for an upgrade it is mostly `Fold`/`Move`. Ask once: "Approve this reconcile?" — you own this interaction (the documentation skill is a library and has none).
101
+
102
+ ### Step 4 — Execute
103
+
104
+ Create the folder structure; move/fold/merge/delete per the plan; add `Status:` to plan files; record each feature doc's code paths as `docs/routing.md` File-Pattern rows (call the `documentation` skill's **routing-map derivation**) and strip any legacy ownership frontmatter; merge scattered backlogs into `docs/history/backlog.md`; fix links broken by moves. Scaffold missing mandated files **by calling the `documentation` skill for each template** — you orchestrate, the skill supplies templates:
105
+
106
+ - `docs/structure.md` (with `harness-version`), `docs/routing.md` (the code-ownership map — scaffold when the repo owns code), `docs/history/CHANGELOG.md`, `docs/history/backlog.md`, `docs/memory/index.md`, `docs/memory/main.md`, and the repo-root `README.md` (filled from the real lockfile/scripts/layout — **never overwrite an existing root README**).
107
+
108
+ Scaffold `docs/memory/facts/` so the distilled tier has a home from day one: the `session-reflect` hook appends session lessons to the per-actor inbox at `docs/memory/inbox/{actor}.md` (not a scaffold — created mechanically on first reflection), and the `distiller` digests that queue down into fact-cards under `docs/memory/facts/`, consuming the entries it digests (no high-water mark, no `.digest-state.md`). Without the facts dir, a freshly-baselined consumer accrues inbox entries the distiller has nowhere to land — so seed the empty distilled tier alongside the hook-written inbox tier.
109
+
110
+ ### Step 5 — Stamp the version
111
+
112
+ Write `harness-version: <installed version>` (the semver from `.claude/harness.json`) into `docs/structure.md` frontmatter. This single field is the repo's baseline-and-version sentinel — there is no second marker (no `epoch`).
113
+
114
+ ### Step 5b — Register the qmd retrieval lens (optional, skip-if-absent)
115
+
116
+ Strictly optional and guarded on the binary — if `command -v qmd` finds nothing, **skip this entire step silently** (no error, no behavior change) and carry one advisory line into the Step 6 hand-back: _"qmd not installed — semantic retrieval unavailable; glob routing active."_ The index is a **local rebuildable lens** — data stays in git; never commit index artifacts, and never use `qmd init` (that writes a project-local `.qmd`; the default global index keeps the repo clean).
117
+
118
+ If the binary exists, register the docs subtrees once the tree is scaffolded. **Do not register one collection rooted at `docs/`** — qmd 2.5.3 hard-codes the `**/*.md` pattern (a custom positional glob is silently discarded) and has no `--ignore`/`--exclude` flag, so a `docs/`-root collection provably sweeps the consumable inbox queue at `docs/memory/inbox/` into the index. The inbox is **not** in scope (it is distilled into `memory/facts`, which is — and its entries are deleted on digestion, which would leave dangling index entries). Register one collection **per indexable subtree** instead — never `docs/memory` as a whole, only `docs/memory/facts` — so the inbox is excluded by construction:
119
+
120
+ 1. **Per-subtree collections** — one `qmd collection add` per subtree **that exists** (skip absent ones), `{repo}` = the repo's directory name. Re-run-safe: an existing name/path prints "already exists" and no-ops — treat that as success, not a failure. **Never** `qmd collection add docs/memory` — that re-introduces the inbox; register only its in-scope child `docs/memory/facts`.
121
+ - `qmd collection add docs/features --name {repo}-features`
122
+ - `qmd collection add docs/architecture --name {repo}-architecture`
123
+ - `qmd collection add docs/operations --name {repo}-operations`
124
+ - `qmd collection add docs/memory/facts --name {repo}-facts`
125
+ - `qmd collection add docs/modules --name {repo}-modules`
126
+ 2. **Context tree** — one `qmd context add` per registered collection root **that exists** (skip absent ones); re-add upserts, so it's safe to re-run:
127
+ - `qmd context add qmd://{repo}-features/ "Feature abstractions — how each works + why it was built"`
128
+ - `qmd context add qmd://{repo}-facts/ "Distilled recent decisions/observations, provenance-linked"`
129
+ - `qmd context add qmd://{repo}-modules/ "Module-local features + pillars (the module's why)"`
130
+ 3. `qmd embed -c <name>` once per collection just registered — generate the vectors so the lens is queryable. Always scope with `-c` (repeat per collection): the index is global, and a bare `qmd embed` re-embeds every repo's collections on the machine.
131
+
132
+ This augments routing; it never supersedes the Step 6 ownership resolution.
133
+
134
+ ### Step 6 — Module proposal
135
+
136
+ Modules are _declared_, never inferred from physical layout. Derive the repo's candidate bounded contexts directly from the code and docs: distinct wire surfaces (who owns routes/handlers), schema/data-access ownership, entry points and process units, plus any contexts `docs/architecture/` or `docs/routing.md` patterns already name.
137
+
138
+ - Propose the derived contexts as candidate modules. For each, partition existing flat feature docs by `docs/routing.md` pattern overlap (which docs' routing patterns fall inside the context's code).
139
+ - **Propose — don't force.** Declaration is opt-in: a single-context app stays flat (so does a monolith whose contexts all share one kernel); declare `docs/modules/{m}/` only when the author accepts a context as a module. A module is tied to code by its `docs/routing.md` patterns (recorded in the Module column), **layout-blind** — a workspace is not a module (one workspace may hold several contexts; one context may span workspaces). When a context is accepted, set the Module column on its routing rows.
140
+
141
+ If Step 5b skipped because `qmd` was absent, carry its one advisory line into the hand-back — _"qmd not installed — semantic retrieval unavailable; glob routing active."_ — advisory, never an error, never a gate.
142
+
143
+ Re-running you is safe — the structure work is already done (idempotent), so a second pass is just the module proposal.
144
+
145
+ **Observed doc-fidelity questions (advisory, not a gate).** If your Step 1 inventory noted any statically-unresolved doc claims, append them to the hand-back as an **optional** block — each entry phrased **as a question**, never an assertion of falsity:
146
+
147
+ > - `docs/x.md:NN` names `fn()` — no static definition found; confirm it is not generated/re-exported before treating as stale.
148
+
149
+ End the block with: _"NEXT (optional): run the maintenance agent to confirm or dismiss these — advisory, not a gate; baseline is complete regardless."_ Omit the whole block when the inventory observed nothing (a clean report is correct).
150
+
151
+ If the user **declines** the advisory rather than running the follow-up, record each declined item in `docs/history/backlog.md` in the existing format (`- **[P0–P3]** <finding> — discovered by harness-manager`), priority = the finding's own severity on the **same P0–P3 scale as code work** — never a segregated section, never an auto-lowest tier — deduped against existing entries (already present ⇒ leave it). A backlog line is a record, never a gate.
152
+
153
+ ### Step 7 — Verify
154
+
155
+ Confirm all mandated files exist; `structure.md` carries the current `harness-version`; `docs/routing.md` exists and its File-Pattern rows cover the owned code paths; no dead links in `docs/structure.md`; every plan has a `Status:`; no feature doc carries `owns`/`touches`/`depends_on` frontmatter; no dissolved-version artifacts remain; no docs outside the canonical structure.
156
+
157
+ ---
158
+
159
+ ## Health audit (on demand)
160
+
161
+ Conformance, not fidelity. Report a table; fix nothing destructively without asking.
162
+
163
+ - **Version currency** — `harness-version` present in `structure.md` and equal to installed? If the **major** is behind → recommend Reconcile (the mandated shape changed); if only minor/patch behind/absent → note it (re-stamped on the next reconcile; no reshape needed). (This is the _repo-vs-installed_ gap — it self-heals once the consumer reinstalls and re-runs you. The next two checks catch what reinstall _hasn't_ happened yet, or was bypassed by a hand-edit.)
164
+ - **Published-version currency** _(advisory, network)_ — the installed `.claude/harness.json` records the kit's `version`; the published kit may have moved past it. Attempt `npm view @nurix/etna version` (the kit is a restricted package — needs npm auth + network). **Guard:** on _any_ failure — offline, no auth, npm absent, timeout — skip and report one line: _"couldn't check the published harness version — re-run `npx @nurix/etna --name=code` to refresh to the latest."_ On success, compare the published version against `.claude/harness.json`'s `version`; if published is ahead, recommend re-running the CLI to pull the newer kit. Never a gate, never blocks.
165
+ - **Kit build fingerprint (digest)** _(informational)_ — `.claude/harness.json` carries a `digest`: a deterministic fingerprint of the exact kit **build** the consumer installed (`build-data` computes it over the shipped bundle). Two installs share a digest iff they are byte-identical builds; a hotfix that changes kit bytes without bumping `version` still moves the digest — so it answers _which build am I on_, finer than `version` alone. **Don't recompute it over `.claude/` to self-check:** the installed layout is a superset of the build (the project `CLAUDE.md` sits at the repo root, `.claude/` adds `settings.json`/`harness.json`/local rule files), so paths and file sets differ **by design** — a recompute would never match. The actionable upgrade signals are the two checks above (major-version reconcile + published-version); the digest is provenance, and the seed for any future published-digest drift check.
166
+ - **Scaffold completeness** — every mandated file present.
167
+ - **Dissolved-version residue** — any `operations/guardrails.md`, `docs/OWNERSHIP_INDEX.md`, feature docs still carrying `owns`/`touches`/`depends_on` frontmatter, repo-wide `docs/pillars/`, `architecture/overview.md`, a persisted `docs/boundaries/` tree, or other old-shape artifact lingering.
168
+ - **Module declaration coverage** — do the repo's bounded contexts have declared module homes where the author intended them? (Surface gaps; never auto-declare.)
169
+ - **`docs/tests/` ownership** — present-with-content, or absent. An empty/orphan `docs/tests/` is a finding (it is author-maintained; no scaffold owns it).
170
+
171
+ ## Rules
172
+
173
+ - **Declarative, idempotent.** Re-running on a current repo is a no-op. Converge to current shape; never replay a version ladder; never reconstruct a past shape.
174
+ - **One sentinel.** `docs/structure.md` `harness-version` is the only baseline/version marker. Do not reintroduce a `docs/memory/index.md` "is-baselined" check.
175
+ - **Modules are declared, layout-blind.** Seed from the code's bounded contexts + `docs/routing.md` patterns; never from `pnpm-workspace.yaml`/workspace walls. Propose, don't force.
176
+ - **You orchestrate docs; the `documentation` skill supplies templates.** It is a library — you never expect it to baseline.
177
+ - **Never overwrite an existing root `README.md`.** It is human-authored.
178
+ - **Stay in `docs/` (+ root `README.md` scaffold) and `docs/memory/harness-manager.md`.** You do not edit `CLAUDE.md` (the CLI ships it) or production code.
179
+ - **Health reports; it does not remediate content.** Content fidelity is `maintenance`'s job.
180
+ - **Doc-fidelity is `maintenance`'s axis — you only surface it as a question.** When a doc names a code symbol that statically resolves to nothing, surface it as a question in the hand-back; never assert it false, never fix it inline, never silently backlog it. Docs only (never code-file comments). Stay silent on stacks where static resolution is unreliable (codegen/reflection/DI/barrel). It never blocks baseline completion. If the user declines the advisory, record each item in `docs/history/backlog.md` at its own P0–P3 tier, at par with code work, deduped — a record, not a gate.
181
+
182
+ ## Strategy memory
183
+
184
+ After a run you may append to `docs/memory/harness-manager.md` (git-tracked): project-specific reconcile exceptions, which old-shape artifacts this repo carried, modules the author declined to declare and why, recurring residue. Never user preferences (those are `~/.claude/`); never a transcription of doc content. Date each entry `## YYYY-MM-DD — {topic}`.