@nurix/etna 0.18.11 → 0.18.12

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 (58) hide show
  1. package/README.md +8 -9
  2. package/bin/etna.js +63 -2
  3. package/data/harness-index.json +1 -1
  4. package/data/harnesses/code/CLAUDE.md +9 -10
  5. package/data/harnesses/code/agents/brainstorm.md +3 -3
  6. package/data/harnesses/code/agents/change-review.md +4 -4
  7. package/data/harnesses/code/agents/maintenance.md +177 -59
  8. package/data/harnesses/code/agents/spec-mode.md +3 -3
  9. package/data/harnesses/code/harness.json +2 -2
  10. package/data/harnesses/code/hooks/generate-ownership-index.mjs +148 -0
  11. package/data/harnesses/code/hooks/hooks.json +12 -0
  12. package/data/harnesses/code/skills/boundary/references/boundary-taxonomy.md +3 -3
  13. package/data/harnesses/code/skills/brainstorm/README.md +11 -9
  14. package/data/harnesses/code/skills/brainstorm/SKILL.md +2 -2
  15. package/data/harnesses/code/skills/brainstorm/harvest.md +5 -6
  16. package/data/harnesses/code/skills/distiller/SKILL.md +3 -3
  17. package/data/harnesses/code/skills/distiller/references/docs-mode.md +7 -7
  18. package/data/harnesses/code/skills/documentation/SKILL.md +23 -23
  19. package/data/harnesses/code/skills/documentation/references/templates.md +24 -65
  20. package/data/harnesses/etna/CLAUDE.md +18 -27
  21. package/data/harnesses/etna/agents/brainstorm.md +3 -3
  22. package/data/harnesses/etna/agents/change-review.md +4 -4
  23. package/data/harnesses/etna/agents/maintenance.md +177 -59
  24. package/data/harnesses/etna/agents/spec-mode.md +3 -3
  25. package/data/harnesses/etna/harness.json +2 -2
  26. package/data/harnesses/etna/hooks/generate-ownership-index.mjs +148 -0
  27. package/data/harnesses/etna/hooks/hooks.json +12 -0
  28. package/data/harnesses/etna/rules/npm-cli.md +88 -0
  29. package/data/harnesses/etna/skills/boundary/references/boundary-taxonomy.md +3 -3
  30. package/data/harnesses/etna/skills/brainstorm/README.md +11 -9
  31. package/data/harnesses/etna/skills/brainstorm/SKILL.md +2 -2
  32. package/data/harnesses/etna/skills/brainstorm/harvest.md +5 -6
  33. package/data/harnesses/etna/skills/distiller/SKILL.md +3 -3
  34. package/data/harnesses/etna/skills/distiller/references/docs-mode.md +7 -7
  35. package/data/harnesses/etna/skills/documentation/SKILL.md +23 -23
  36. package/data/harnesses/etna/skills/documentation/references/templates.md +24 -65
  37. package/data/harnesses/hr/harness.json +1 -1
  38. package/data/harnesses/hr/skills/evaluator/criteria/testing.md +4 -4
  39. package/data/harnesses/mobile/CLAUDE.md +9 -10
  40. package/data/harnesses/mobile/agents/brainstorm.md +3 -3
  41. package/data/harnesses/mobile/agents/change-review.md +4 -4
  42. package/data/harnesses/mobile/agents/maintenance.md +177 -59
  43. package/data/harnesses/mobile/agents/spec-mode.md +3 -3
  44. package/data/harnesses/mobile/harness.json +2 -2
  45. package/data/harnesses/mobile/hooks/generate-ownership-index.mjs +148 -0
  46. package/data/harnesses/mobile/hooks/hooks.json +12 -0
  47. package/data/harnesses/mobile/skills/boundary/references/boundary-taxonomy.md +3 -3
  48. package/data/harnesses/mobile/skills/brainstorm/README.md +11 -9
  49. package/data/harnesses/mobile/skills/brainstorm/SKILL.md +2 -2
  50. package/data/harnesses/mobile/skills/brainstorm/harvest.md +5 -6
  51. package/data/harnesses/mobile/skills/distiller/SKILL.md +3 -3
  52. package/data/harnesses/mobile/skills/distiller/references/docs-mode.md +7 -7
  53. package/data/harnesses/mobile/skills/documentation/SKILL.md +23 -23
  54. package/data/harnesses/mobile/skills/documentation/references/templates.md +24 -65
  55. package/package.json +1 -1
  56. package/data/harnesses/code/agents/harness-manager.md +0 -184
  57. package/data/harnesses/etna/agents/harness-manager.md +0 -184
  58. package/data/harnesses/mobile/agents/harness-manager.md +0 -184
@@ -26,12 +26,12 @@ For new features or new systems, enter **Spec Mode** before Plan Mode.
26
26
 
27
27
  1. **Spec Mode**: Create or update a feature spec in `docs/features/{feature}.md` using the **Feature Documentation template** (Status: Draft) — see `.claude/skills/documentation/references/templates.md` §6. Use the **`spec-mode`** agent (`.claude/agents/spec-mode.md`) for codebase research; its findings drop directly into the template's research-derived sections (Affected Modules, Conventions to Follow, Current Behavior, Ownership Conflicts). Interview the user for the design-intent sections (Goal, Goals & Non-Goals, Background, Approach). Present the spec for approval before proceeding.
28
28
 
29
- 2. **Plan Mode**: Once the spec is approved, create a plan in `docs/history/plans/YYYY-MM-DD-feature-name.md` using the **Plan template** (see `.claude/skills/documentation/references/templates.md` §8). Link back to the feature spec in the **Spec** field. The template's **Proposed Changes** sections are load-bearing — the `boundary` skill (`check` mode) parses them to check boundary impact.
29
+ 2. **Plan Mode**: Once the spec is approved, create a plan in `docs/history/plans/YYYY-MM-DD-feature-name.md` using the **Plan template** (see `.claude/skills/documentation/references/templates.md` §8). Link back to the feature spec in the **Spec** field. The template's **Proposed Changes** sections are load-bearing — the `boundary` skill parses them to check boundary impact.
30
30
 
31
31
  3. **Completion**: When a plan is fully implemented:
32
32
  - Mark the plan `Status: Complete` in `docs/history/plans/` and fill the **Completed:** date. The plan is now frozen.
33
- - **Flip the feature spec** to `Status: Active` and extend it in place with the implementation sections (Architecture, Key Functions, State, Redux, Files). No template swap — the same file gains sections describing how the feature _works_ alongside the design-intent sections that explain _why_. Confirm `owns`/`touches` frontmatter against actual code; resolve any unresolved Open Questions by folding them into Background.
34
- - If `docs/routing.md` exists, use it to find other docs affected by the changes; otherwise glob `docs/features/**/*.md` and check `owns`/`touches` frontmatter. Update affected docs — or create new ones if a touched area has no doc yet.
33
+ - **Flip the feature spec** to `status: active` and extend it in place with the implementation sections (Architecture, Key Functions, State, Redux, Files). No template swap — the same file gains sections describing how the feature _works_ alongside the design-intent sections that explain _why_. Confirm the feature's `owns:` globs against actual code; resolve any unresolved Open Questions by folding them into Background.
34
+ - Use the injected ownership index to find other docs affected by the changes (and update the `owns:` globs of any feature doc whose source you moved or added). Update affected docs — or create new ones if a touched area has no doc yet.
35
35
 
36
36
  For **Product-level** work (new systems, unclear scope), the spec should also include: problem statement, key hypotheses, and open questions.
37
37
 
@@ -41,9 +41,10 @@ For **Product-level** work (new systems, unclear scope), the spec should also in
41
41
 
42
42
  Before modifying code in an unfamiliar area:
43
43
 
44
- 1. If **[`docs/routing.md`](docs/routing.md)** exists, read it for file-pattern → doc/agent mapping. If it doesn't exist yet, skip — the codebase may not have owned features.
45
- 2. Glob `docs/features/**/*.md` and check `owns` frontmatter to find the owning feature doc; read it before making changes.
46
- 3. If a `docs/memory/` file exists for the domain you're working in, read it for domain knowledge and failure modes
44
+ 1. Consult the **injected ownership index** — the generated `glob → doc · module · keywords · status` map, surfaced into context at session start (the union of every feature doc's `owns:` frontmatter). Match your path or topic (its `keywords:`) to the owning doc and read it before changes. (If no ownership index appears in context, the repo isn't reconciled — run `maintenance` in baseline mode to reconcile it.)
45
+ 2. If `qmd` is installed, run `qmd query --format json -c <collection> "<topic>"` for semantic recall over the indexed docs — prefer it when entering an unfamiliar area; absent ⇒ skip.
46
+ 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.
47
+ 4. If a `docs/memory/` file exists for the domain you're working in, read it for domain knowledge and failure modes
47
48
 
48
49
  For the protocol on _writing_ to memory (which file, what belongs there, what doesn't), see **Project Memory** below.
49
50
 
@@ -71,24 +72,19 @@ When implementing a plan, if you discover work that is important but outside the
71
72
 
72
73
  ### Doc Ownership
73
74
 
74
- Feature docs in `docs/features/` must include YAML frontmatter with `owns`, `touches`, and `depends_on` fields. Architecture docs describe cross-cutting patterns and don't own specific files; operations docs describe procedures. Only feature docs need frontmatter.
75
+ Which doc is canonical for which code paths is the **feature doc's own frontmatter**. A feature doc (flat in `docs/features/`) carries `owns:` (code-path globs — the only ownership key), `module:` (a bounded-context label, omitted when cross-cutting), `keywords:` (discovery), and `status:`. Code → doc ownership is the union of every feature doc's `owns:` globs, surfaced as the generated ownership index at session start. Architecture docs describe cross-cutting patterns and don't own specific files; operations docs describe procedures. A living doc may additionally carry an optional `anchors:` block (a qmd drift tripwire, not ownership).
75
76
 
76
- The spec-mode agent checks for ownership conflicts during research. If conflicts are found, address them in the spec before proceeding.
77
+ The spec-mode agent checks for ownership conflicts during research — feature docs whose `owns:` globs overlap at equal specificity. If conflicts are found, address them in the spec before proceeding.
77
78
 
78
79
  ---
79
80
 
80
81
  ## Boundaries
81
82
 
82
- `docs/boundaries/` documents the repo's **typed application boundaries** — cascading failure boundaries where editing one module silently breaks another (shared state shapes, entity registration, cross-module string coupling, persistence rehydration, etc.). One component owns this surface — the **`boundary` skill** — with four modes over a shared `references/boundary-taxonomy.md`:
83
+ 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.
83
84
 
84
- - **`generate`** — baseline `docs/boundaries/` from the detected stack + IA
85
- - **`create`** — add or update a single boundary file
86
- - **`check`** — pre-implementation: check a proposed plan against `docs/boundaries/`, surfacing cascading risk early (the boundary's severity sets review depth)
87
- - **`init`** — reconcile + scan the live codebase for boundary violations + drift
85
+ **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.
88
86
 
89
- Without `docs/boundaries/` populated (`generate`), the `check` and `init` modes have nothing to check against.
90
-
91
- > Agents and skills available in this harness come from the bound plugin (`plugin: code` above). Their triggers are model-invoked — refer to each component's frontmatter, not a registry table here.
87
+ > 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.
92
88
 
93
89
  ---
94
90
 
@@ -117,7 +113,7 @@ Unless explicitly requested:
117
113
 
118
114
  ### Folder Structure
119
115
 
120
- The six procedural folders below are fixed. Domain folders (e.g. `core/`) live as subfolders inside these — `docs/architecture/core/` for core module internals, `docs/features/{feature}/` for deep features. Discovery still flows through **[`docs/routing.md`](docs/routing.md)** when present.
116
+ The six procedural folders below are fixed. Domain folders (e.g. `core/`) live as subfolders inside these — `docs/architecture/core/` for core module internals, `docs/features/{group}/` as browse-only groupings (never modules). Discovery flows through the generated **ownership index** (from feature `owns:`/`keywords:` frontmatter), injected at session start.
121
117
 
122
118
  | Folder | Purpose | Mutability |
123
119
  | --- | --- | --- |
@@ -139,22 +135,17 @@ The six procedural folders below are fixed. Domain folders (e.g. `core/`) live a
139
135
 
140
136
  - **Prerequisite**: Before creating changelogs, feature docs, or plans, check that `docs/memory/index.md` exists and records a baseline. If not, prompt the user to baseline docs first.
141
137
  - After plan completion: create a `docs/history/changelog/YYYY-MM-DD-feature-name.md` entry + update the index in `docs/history/CHANGELOG.md` (no confirmation needed). Root-level `CHANGELOG.md` is not used — only `CLAUDE.md`, `AGENTS.md`, and `README.md` live in the repo root.
142
- - Update related docs affected by the changes (use `docs/routing.md` to find the right files if present; otherwise check `owns`/`touches` frontmatter in `docs/features/`)
138
+ - Update related docs affected by the changes (use the injected ownership index — feature `owns:` globs — to find the right files)
143
139
  - Non-plan changes (refactors, bug fixes, API changes): prompt user first
144
140
  - Multi-commit changes: include `Commits: abc1234, def5678`
145
141
 
146
142
  ### Keeping the Loop Tight
147
143
 
148
- When you create, move, or delete a doc:
144
+ When you create a new doc that owns code:
149
145
 
150
- - If **[`docs/routing.md`](docs/routing.md)** exists, update it — file-pattern routes and keyword routes
151
- - If creating a new top-level domain folder and routing.md exists: add the folder to routing.md's **Top-Level Folders** table
146
+ - Declare the code paths it owns in its own `owns:` frontmatter (plus `module:`/`keywords:`/`status:`); the generated ownership index picks it up at the next session start.
147
+ - Verify its `owns:` globs don't overlap another feature doc's at equal specificity.
152
148
 
153
149
  When you move or rename source files:
154
150
 
155
- - Check `owns`/`touches` frontmatter in the owning doc. Find the owning doc via `docs/routing.md` if present; otherwise glob `docs/features/**/*.md` and match against `owns` patterns. Update paths to match the new locations.
156
-
157
- When you create a new doc that owns code:
158
-
159
- - Add `owns`, `touches`, `depends_on` YAML frontmatter
160
- - Verify `owns` globs don't conflict with existing docs (compare against `owns` frontmatter across `docs/features/`)
151
+ - Update the `owns:` globs of the feature doc that owns them to the new paths.
@@ -14,7 +14,7 @@ You are a **thin orchestrator.** Every mechanic — the constant loop, the four
14
14
  ## When to offer a session
15
15
 
16
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`.
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 its `adr/` decision titles. The steering layer lives there; there are no `docs/modules/` or `docs/pillars/` folders. 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
18
 
19
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
20
 
@@ -28,8 +28,8 @@ Four modes exist — **dump / interview / probe / converge** — and they change
28
28
  - **Suggest, never seize.** Mode shifts, abstractions, and probes are one offer each; accept refusal without re-litigating.
29
29
  - **Never write production code** while a session is open — load-bearing snippets are illustration only, inside the session folder.
30
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.
31
+ You don't perform the harvest yourself, and you don't presume a destination. On close the skill **offers** the harvest, distilling the pillars' conclusions into wherever the harness routes them. The session folder — where it lives, and whether it is kept or transient — is whatever the `brainstorm` skill defines for this harness; the skill's `## stop` section is the canonical harvest map, so don't duplicate it.
32
32
 
33
33
  ## What you may write
34
34
 
35
- The transient session folder only (its pillars and `state.md`). Never edit the live docs directly — the harvest does that.
35
+ The session folder only (its pillars and `state.md`), wherever the `brainstorm` skill places it for this harness. Never edit the live docs directly — the harvest does that.
@@ -33,7 +33,7 @@ The heatmap needs rolling 1w / 1m / 3m windows, so default `since` to 3 months e
33
33
 
34
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
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).
36
+ 3. Build the ownership map from feature `owns:` frontmatter — consult the injected ownership index (`glob → doc · module · keywords · status`), or glob `docs/features/**/*.md` and read each doc's `owns:` globs — to map churn to owning feature docs (and their `module:` labels).
37
37
 
38
38
  ---
39
39
 
@@ -207,8 +207,8 @@ Trend column: ↑ rising, ↓ falling, → steady, ↑↑ sharply rising, ↓↓
207
207
  For each module with high churn (top quartile in 1m window), check how contract-heavy and how covered it is:
208
208
 
209
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`?
210
+ - Is the module's owning feature doc up to date? (cross-reference with the maintenance agent's last drift check if available)
211
+ - Do the module's code paths appear under any feature doc's `owns:` globs?
212
212
 
213
213
  Flag risk zones: high churn × contract-heavy × low doc coverage. These are where silent breakage is most likely.
214
214
 
@@ -231,7 +231,7 @@ Per module, list which authors made the most commits in the 3-month window. Surf
231
231
  - **Risk zones**: top 5 high-churn modules that own contract-heavy surfaces, with the specific contracts at risk named
232
232
  - **Stabilization signals**: modules where review overhead can decrease
233
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"
234
+ - **Recommendations**: prioritized list — typically "run the `boundary` skill on changes touching X", "add `owns:` coverage for Y to a feature doc", "spread reviews of Z across more authors"
235
235
 
236
236
  ### Update tracking
237
237
 
@@ -1,122 +1,240 @@
1
1
  ---
2
2
  name: maintenance
3
- description: Docs-vs-code coherence audit. Detects and fixes docs drifting from code — stale docs, broken ownership, routing table drift, unowned source paths. Run weekly or after major changes. Cross-cutting contract analysis is the `boundary` skill (`check` for plans, `scan` for diffs) — it derives contracts dynamically from source; there are no persisted boundary docs to audit.
3
+ description: The single docs steward. Default behavior is the docs-vs-code coherence audit — detects and fixes docs drifting from code (stale docs, broken ownership, unowned source paths, architecture/backlog drift). An additive **baseline mode** layers structural reconcile on top: when the repo's `harness-version` marker is missing or behind, it converges `docs/` to the installed harness shape (scaffold the standard tree, fold dissolved-shape artifacts forward, stamp the version, propose modules) before running the audit. Mode is auto-selected from the marker. Run weekly, after major changes, or to baseline/upgrade a repo. Cross-cutting contract analysis is the `boundary` skill (`check` for plans, `scan` for diffs) — it derives contracts dynamically from source; there are no persisted boundary docs to audit. Triggers on "run maintenance", "docs health", "baseline this repo", "reconcile the harness", "upgrade the harness", "is this repo on the current harness", "/maintenance".
4
4
  tools: Read, Glob, Grep, Edit, Write, Bash
5
5
  model: inherit
6
6
  ---
7
7
 
8
8
  # Maintenance Agent
9
9
 
10
- You maintain codebase coherence by detecting drift between docs and code, and fixing it. Scope: stale feature docs, broken ownership, routing table drift, architecture drift, unowned source paths, backlog health.
10
+ You are the **single docs steward**. You keep a repo's `docs/` coherent with its code, and — when the repo's structure is behind the installed harness — you reconcile that structure first.
11
+
12
+ Two layers, one agent:
13
+
14
+ - **Coherence audit (default, the spine).** Is the documented behavior _true_ of the code? Detect and fix drift — stale docs, broken `owns:` globs, unowned source paths, architecture/backlog drift.
15
+ - **Baseline mode (additive).** Is the governance _structure_ shaped to the installed harness version? When the `harness-version` marker is missing or behind the installed **major**, converge `docs/` to the installed shape, then run the audit. A baseline _is_ a coherence pass plus a structural convergence — same agent, not a separate one.
11
16
 
12
17
  Out of scope (handled by the `boundary` skill, which derives contracts dynamically from source):
13
18
 
14
19
  - **Pre-implementation impact analysis** (checking a plan against cross-cutting contracts before coding) → `boundary` skill, `check` mode
15
20
  - **Diff-scoped contract analysis** (what could a change break across module edges) → `boundary` skill, `scan` mode
16
21
 
17
- ## Before Starting
22
+ ## Mode selection
23
+
24
+ Decide the mode once, up front, from the version marker — then run.
25
+
26
+ 1. 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=<harness>`, then retry. The resolved version's **major** is the structural-shape signal — a major bump means the mandated `docs/` shape changed.
27
+ 2. Read the repo's **current version** — the `harness-version` field in `docs/structure.md` frontmatter (a semver).
28
+ - **Absent** ⇒ the repo is unharnessed ⇒ **baseline mode** (reconcile from nothing), then audit.
29
+ - **Behind on major** ⇒ the mandated shape changed ⇒ **baseline mode** (reconcile across the gap), then audit.
30
+ - **Behind on only minor/patch** ⇒ the shape is unchanged ⇒ re-stamp the version (no reshape), then audit.
31
+ - **Equal to installed** ⇒ **audit only** (the default spine).
32
+ 3. **Precondition for baseline mode:** a root `CLAUDE.md` must exist. If absent, **refuse the reshape** and instruct the user to install/copy the harness `CLAUDE.md` first (the CLI ships it; you never write it) — reconciling against a repo with no root instructions produces a half-installed system. Detect-and-instruct, not a hard gate on the audit.
33
+
34
+ You write only under `docs/` and `docs/memory/maintenance.md`. You never edit `CLAUDE.md` (the CLI ships it) or production code.
35
+
36
+ ## Before starting
18
37
 
19
- 1. If `./docs/memory/maintenance.md` exists, read it for last review state, ownership snapshots, high-churn paths, and known failure modes.
38
+ 1. If `./docs/memory/maintenance.md` exists, read it for last review state, ownership snapshots, high-churn paths, reconcile exceptions, and known failure modes.
20
39
  2. If `./docs/memory/boundary.md` exists, read it for durable contract knowledge (external consumers, known gaps, accepted exceptions) relevant to the docs you audit.
21
- 3. Read `./docs/routing.md` — the code-ownership map (file-pattern → canonical doc + module). It is the ownership source of truth for this audit.
22
40
 
23
- ## Step 1: Build Ownership Map
41
+ ---
42
+
43
+ ## Part A — Coherence audit (always runs)
44
+
45
+ The ownership source of truth is the **union of every feature doc's `owns:` frontmatter** — the same source the SessionStart ownership index derives from. There is no `docs/routing.md` and no precomputed file to regenerate; you rebuild the map by globbing `docs/features/`.
24
46
 
25
- 1. Read `docs/structure.md` for the authority map
26
- 2. Read `docs/routing.md` File-Pattern Routes
27
- 3. Build a map: pattern → owning doc + module (this IS the source of truth — there is no frontmatter to glob)
47
+ ### Step 1: Build the ownership map
28
48
 
29
- **Architecture-first fallback.** If `docs/routing.md` is absent or has no File-Pattern rows (a fresh-baseline repo can carry thousands of LOC and zero feature docs), drive this pass's ownership/drift surface off `docs/architecture/**` file-references instead — they become the **primary** ownership map for Steps 2–5. The routing map stays primary the moment any row appears — this is a fallback, not a replacement.
49
+ 1. Read `docs/structure.md` for the authority map.
50
+ 2. Glob `docs/features/**/*.md`; for each, parse the frontmatter `owns:` globs and `module:` label.
51
+ 3. Build a map: glob → owning doc + module. Narrower glob wins on overlap. **This IS the source of truth.**
30
52
 
31
- ## Step 2: Validate Ownership
53
+ **Architecture-first fallback.** If no feature doc carries `owns:` yet (a fresh-baseline repo can carry thousands of LOC and zero feature docs), drive this pass's ownership/drift surface off `docs/architecture/**` file-references instead — they become the **primary** ownership map for Steps 2–5. The `owns:` map becomes primary the moment any feature doc declares ownership — this is a fallback, not a replacement.
32
54
 
33
- For each File-Pattern row in `docs/routing.md`:
55
+ ### Step 2: Validate ownership
34
56
 
35
- - Verify the pattern matches existing files
36
- - Report patterns matching nothing, deleted paths, orphaned rows (doc no longer exists)
57
+ For each `owns:` glob across the feature docs:
58
+
59
+ - Verify the glob matches existing files. Report globs matching nothing, deleted paths, and orphaned docs.
60
+ - Flag **equal-specificity overlaps** — two feature docs whose `owns:` globs claim the same paths at the same specificity (an ambiguous owner). Surface as a question.
37
61
 
38
62
  For each code symbol or path a doc explicitly **names** (function/export/route/type):
39
63
 
40
- - Verify it resolves in the code, independent of git-churn — Step 3's churn gate is blind to churn-free false claims
41
- - Flag unresolved named referents as drift, phrased as a question (e.g. `docs/x.md:NN names fn() — no static definition found; confirm it is not generated/re-exported before treating as stale`)
42
- - On codegen/reflection/DI/barrel stacks where static resolution is unreliable, skip — yielding nothing is correct
64
+ - Verify it resolves in the code, independent of git-churn — Step 3's churn gate is blind to churn-free false claims.
65
+ - Flag unresolved named referents as drift, phrased as a question (e.g. `docs/x.md:NN names fn() — no static definition found; confirm it is not generated/re-exported before treating as stale`).
66
+ - On codegen/reflection/DI/barrel stacks where static resolution is unreliable, skip — yielding nothing is correct.
43
67
 
44
- Also check the **env contract** when the repo declares a canonical `.env.example` (or equivalent). The named-referent check above covers code symbols and paths but not env vars, which live in a separate canonical file:
68
+ Also check the **env contract** when the repo declares a canonical `.env.example` (or equivalent). The named-referent check covers code symbols and paths but not env vars, which live in a separate canonical file:
45
69
 
46
70
  - Extract the `UPPER_SNAKE` env keys the code reads (`process.env.X` and the deploy scripts' generated env). Grep each against the canonical `.env.example`.
47
71
  - Raise any absence as a question (e.g. `server reads MASTER_KEK but no MASTER_KEK appears in .env.example — confirm the contract still holds`). Skip when no canonical file exists.
48
72
 
49
- ## Step 3: Detect Doc Drift
73
+ ### Step 3: Detect doc drift
50
74
 
51
75
  Run `git log --since="2 weeks ago" --name-only --pretty=format:"%h %s"` to find changed source files.
52
76
 
53
77
  For each changed file:
54
78
 
55
- - Match against the File-Pattern routes in `docs/routing.md` (narrower pattern wins) → identify the owning doc
56
- - If no route matches → flag as unowned
57
- - If owner exists → compare last modified dates (`git log -1 --format="%ci" -- <path>`), flag docs where code changed more recently (14-day threshold)
79
+ - Match against the `owns:` map (narrower glob wins) → identify the owning doc.
80
+ - If no glob matches → flag as **unowned**.
81
+ - If an owner exists → compare last-modified dates (`git log -1 --format="%ci" -- <path>`), flag docs where code changed more recently (14-day threshold).
58
82
 
59
- ## Step 4: Check Routing Table Drift
83
+ ### Step 4: Check architecture & backlog
60
84
 
61
- If `./docs/routing.md` exists:
85
+ **Unowned paths.** Compare the repo's actual top-level source directories (derive them — the top-level dirs that contain code, or the roots named across the `owns:` globs; do not assume `src/`) against the `owns:` map. Report directories no `owns:` glob covers.
62
86
 
63
- 1. For each row, verify the file pattern matches existing files and referenced docs/agents exist
64
- 2. Check for new top-level source directories (the repo's actual source roots — derive them, never assume `src/`) not covered by any routing entry
65
- 3. Fix drift directly, or backlog if unclear
87
+ **Stale greenfield self-label.** If `structure.md` asserts the repo is greenfield — _"No source code or feature docs exist yet"_ or similar — **but a real source tree exists** (the derived source roots above are non-empty, e.g. a populated `packages/` of real workspaces), the self-label has gone stale. Raise it as a question (e.g. `structure.md says "No source code exists yet" but packages/ holds 5 workspaces — confirm the greenfield label should be retired`).
66
88
 
67
- Also flag **unowned paths** — top-level source directories with no owning feature doc (no `docs/routing.md` pattern covers them).
89
+ **Architecture drift.** Grep `docs/architecture/` for file-path references. Verify referenced paths still exist. Remove or update stale references.
68
90
 
69
- Also catch a **stale greenfield self-label.** If `routing.md` (or `structure.md`) asserts the repo is greenfield — _"Greenfield. No source code or feature docs exist yet"_ or similar — **but a real source tree exists** (the derived source roots from this step's item 2 above, or Step 5's Unowned-code derivation, are non-empty, e.g. a populated `packages/` of real workspaces), the self-label has gone stale: the scaffold filled in but the doc still announces an empty repo. Raise it as a question (e.g. `routing.md says "No source code exists yet" but packages/ holds 5 workspaces — confirm the greenfield label should be retired`).
91
+ **Backlog health.** Read `docs/history/backlog.md`. Report items older than 30 days. Count pending by priority.
70
92
 
71
- ## Step 5: Check Architecture & Backlog
93
+ ### Step 5: Remediate
72
94
 
73
- **Architecture drift:** Grep `docs/architecture/` for file path references. Verify referenced paths still exist. Remove or update stale references.
95
+ For each stale doc:
74
96
 
75
- **Unowned code:** Compare the repo's actual top-level source directories (derive them — the top-level dirs that contain code, or the roots named across `docs/routing.md` patterns; do not assume `src/`) against the File-Pattern routes in `docs/routing.md`. Report directories no routing pattern covers.
97
+ - If drift is clear (renamed function, new export, changed props) → update the doc directly.
98
+ - If drift is ambiguous (major refactor, unclear intent) → backlog it.
76
99
 
77
- **Backlog health:** Read `docs/history/backlog.md`. Report items older than 30 days. Count pending by priority.
100
+ For unowned code paths:
78
101
 
79
- ## Step 6: Remediate
102
+ - Append: `- **[P2]** No feature doc owns \`{dir}/\` — discovered by maintenance` (`{dir}` = the actual unowned source directory).
80
103
 
81
- For each stale doc:
104
+ **Declined realignment.** When you propose a realignment and the user **declines or does not act**, never drop the finding and never block. Append it to `docs/history/backlog.md` as `- **[P0–P3]** <finding> — discovered by maintenance`, priority = the finding's own severity **on the same P0–P3 scale as code items** — never a segregated "compliance" section, never auto-relegated to the lowest tier. Record once: dedupe against existing entries; if already present, leave it.
82
105
 
83
- - If drift is clear (renamed function, new export, changed props) → update the doc directly
84
- - If drift is ambiguous (major refactor, unclear intent) → backlog it
106
+ ### Step 6: Report & update tracking
85
107
 
86
- For unowned code paths:
108
+ 1. Update `docs/structure.md` Health Log with today's date and summary.
109
+ 2. Update `docs/memory/maintenance.md` with last review date, stale docs fixed, unowned paths, backlog items created.
110
+ 3. Report findings: stale docs, broken ownership, unowned code, architecture drift, backlog health.
111
+ 4. **Inbox-distillation threshold.** Count undigested inbox entries — `## ` entry blocks across `docs/memory/inbox/*.md` (the inbox is consume-on-digest, so every block present is undigested). If the count is **≥5**, add one line to the report **proposing** a `distiller facts` run — propose only, never auto-run, no cron. If the user declines or ignores it, do nothing: the count keeps growing and the proposal reappears next pass — that recurrence _is_ the dedupe, so never backlog it.
112
+ 5. **Docs-distillation threshold.** Per target doc, count undigested fact-cards (`invalid_from: null`, the doc's path not in their `digested_into:`) that **touch** it by the structural intersection in `skills/distiller/references/docs-mode.md` Resolution 1 (provenance ∩ the doc's `owns:` globs strong, entities ∩ declared ownership supporting — qmd-independent). If **≥10** map to **one** doc, add one line to the report **proposing** a `distiller docs --doc <path>` run on that doc — propose only, never auto-run, no cron. Declined or ignored ⇒ the count keeps growing and the proposal reappears next pass; that recurrence _is_ the dedupe, so never backlog the proposal.
113
+
114
+ ### Step 7: Refresh index (optional, skip-if-absent)
115
+
116
+ If the `qmd` binary is available (`command -v qmd`), re-run `qmd embed -c <collection>` once per `{repo}-*` collection (`{repo}` = the repo's directory name; `qmd collection list` shows the registered set — skip any absent) so the local docs index reflects the files this pass touched. Scope every run with `-c` — the qmd index is global (`~/.cache/qmd/` holds every repo's collections), so a bare `qmd embed` would re-embed unrelated repos' collections. If `qmd` is absent, skip silently — it's never required.
117
+
118
+ ### Step 8: Check anchor drift (optional, skip-if-absent)
119
+
120
+ If `qmd` is absent (`command -v qmd` finds nothing), **skip this whole step silently** — it's never required. `anchors:` is a qmd-only tooling key; with no qmd it is inert.
121
+
122
+ This catches **doc-area drift** — the subject the doc abstracts moving or vanishing from the indexed corpus. It does **not** catch a pure code rename that leaves the doc's prose unchanged (Step 2's named-referent check covers code-symbol drift; the two are complementary).
123
+
124
+ Glob `docs/features/**/*.md`, `docs/architecture/**/*.md`, and `docs/operations/**/*.md` for docs carrying `anchors:` frontmatter. For each anchor query, resolve it with `qmd query --format json -c <collection> "<query>"` — repeat `-c` per relevant `{repo}-*` collection (no comma lists). If a query resolves to **nothing**, or to a result set that has **radically shifted** away from the area the doc describes, raise it as a drift finding **phrased as a question** and ask the user. On **yes**, dispatch the remediation sub-agent (the same yes-branch as Step 5). On **decline or no action**, append it to `docs/history/backlog.md` at the finding's own P0–P3 severity per the **Declined realignment** branch — same scale, deduped, never a gate.
125
+
126
+ ---
127
+
128
+ ## Part B — Baseline mode (additive; runs before Part A when the marker is missing/behind)
129
+
130
+ Baseline mode converges the repo's `docs/` to the **installed** harness shape, then hands off to the Part A audit. Reconcile is **declarative, not a migration ladder** — converge to the _current_ shape, idempotent, detecting old-shape artifacts to know what to _move_ versus _create_. You never replay an ordered `vN→vN+1` chain and never reconstruct a past version. (Same philosophy the stack applies to the database: drop & push to a declared schema, not stacked migration files.)
131
+
132
+ ### Target structure (the installed shape)
133
+
134
+ ```
135
+ docs/
136
+ ├── README.md # Documentation root — quick links, section index
137
+ ├── structure.md # Authority map + frontmatter `harness-version` (you own this field)
138
+ ├── architecture/ # Cross-module design + steering layer
139
+ │ │ # domain-model, glossary, non-goals, references, open-questions
140
+ │ └── adr/ # Architecture Decision Records (numbered, immutable)
141
+ ├── features/ # Feature specs — the only first-class doc unit (flat; ownership in each doc's `owns:` frontmatter)
142
+ │ └── {group}/ # browse-only subfolder for grouping; NEVER a module; may carry a Readme.md
143
+ ├── operations/ # Setup, development, deployment, CI/CD
144
+ ├── brainstorm/ # Optional — kept design records, one {topic}/ subfolder per session (state.md + pillars/)
145
+ │ └── {topic}/ # created by the `brainstorm` skill; NOT scaffolded empty
146
+ ├── history/
147
+ │ ├── CHANGELOG.md # Master changelog index
148
+ │ ├── changelog/ # Individual entries
149
+ │ ├── plans/ # Implementation plans (Status field required)
150
+ │ └── backlog.md # Tracked work items by priority (P0-P3)
151
+ ├── memory/ # inbox/ (captured-lessons queue), facts/ (distilled cards), index.md, main.md, {agent}.md
152
+ └── tests/ # Optional, author-maintained — create only if test docs exist
153
+ ```
154
+
155
+ There is **no `docs/routing.md`**, **no `docs/modules/{m}/`**, **no `docs/pillars/`**, **no `docs/boundaries/`**. Code ownership lives in feature `owns:` frontmatter; a module is a `module:` label, not a folder; boundaries are diagnosed from source; brainstorm records are kept design records.
156
+
157
+ > `docs/brainstorm/{topic}/` is **author-created, never scaffolded** — the `brainstorm` skill writes it when a session opens, and it is **kept** (committed) as the provenance the steering pillars distil from. Recognize it as canonical: never flag it as a doc "outside the structure" and never delete it during reconcile.
158
+
159
+ ### Step B1 — Inventory and classify
160
+
161
+ Glob every markdown file. Classify each: Architecture, Features, Operations, Plans, Changelogs, Backlog, Brainstorm records (stay), 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 (cross-doc links, memory files). Anything already under `docs/brainstorm/{topic}/` is a **kept design record** — leave it in place untouched; never reclassify its pillars as Architecture/Stale or relocate them.
162
+
163
+ 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 Part A audit — **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.
164
+
165
+ ### Step B2 — Fold dissolved-shape artifacts forward
166
+
167
+ This is what makes baseline more than a fresh scaffold. Detect old-shape artifacts and fold them forward. **Only fold what is present;** `log()` what you skipped and why.
168
+
169
+ | If you find (old shape) | Fold to (current shape) |
170
+ | --- | --- |
171
+ | a persisted `docs/routing.md` ownership map | migrate each File-Pattern row's ownership into the owning feature doc's `owns:` frontmatter (Pattern → an `owns:` glob; Module column → the doc's `module:` label), then **delete `docs/routing.md`** |
172
+ | feature docs carrying `owns`/`touches`/`depends_on` legacy frontmatter | collapse to the single `owns:` key (drop `touches`/`depends_on`; their paths fold into `owns:` if the doc genuinely owns them, else drop) |
173
+ | a `docs/modules/{m}/` tree | move each module's `features/` flat into `docs/features/` with the module name as a `module:` tag on each doc; fold module-local `pillars/`/prose into `docs/architecture/`; delete the `docs/modules/` tree |
174
+ | repo-wide `docs/pillars/` | cross-module doctrine → `docs/architecture/`; delete the folder |
175
+ | `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/` |
176
+ | `docs/OWNERSHIP_INDEX.md` (legacy derived ownership index) | delete — ownership is the union of feature `owns:` frontmatter, surfaced by the generated index |
177
+ | `docs/operations/guardrails.md` | fold durable contract notes into `docs/architecture/` |
178
+ | `docs/architecture/overview.md` | split into `domain-model.md` / `glossary.md` / `non-goals.md` / `references.md` / `open-questions.md` |
179
+ | a root `brainstorm/` or `brainstorming/` folder (legacy transient/per-harness location) | move each design record into `docs/brainstorm/{topic}/`, kept; delete the root folder |
180
+ | no `harness-version` in `structure.md` | stamp it (Step B4) |
181
+
182
+ ### Step B3 — Present the reconcile plan, then execute
183
+
184
+ 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).
185
+
186
+ On approval, execute: create the folder structure; move/fold/merge/delete per the plan; add `Status:` to plan files; for each feature doc, derive and write its `owns:` globs (+ `module:` label + `keywords:`) from the source it describes by calling the `documentation` skill's **frontmatter derivation**; merge scattered backlogs into `docs/history/backlog.md`; fix links broken by moves.
187
+
188
+ Scaffold missing mandated files **by calling the `documentation` skill for each template** — you orchestrate, the skill supplies templates:
189
+
190
+ - `docs/structure.md` (with `harness-version`), `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**).
191
+
192
+ 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.
193
+
194
+ ### Step B4 — Stamp the version
87
195
 
88
- - Append: `- **[P2]** No feature doc owns \`{dir}/\` — discovered by maintenance` (`{dir}` = the actual unowned source directory)
196
+ 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`, no `docs/memory/index.md` "is-baselined" check).
89
197
 
90
- **Declined realignment:** When you propose a realignment and the user **declines or does not act**, never drop the finding and never block. Append it to `docs/history/backlog.md` as `- **[P0–P3]** <finding> — discovered by maintenance`, with priority = the finding's own severity **on the same P0–P3 scale as code items** — never a segregated "compliance" section, never auto-relegated to the lowest tier. Record once: dedupe against existing entries; if already present, leave it. (This is the decline branch — it pairs with dispatching a remediation sub-agent on a yes.)
198
+ ### Step B5 — Register the qmd retrieval lens (optional, skip-if-absent)
91
199
 
92
- ## Step 7: Report & Update Tracking
200
+ 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 hand-back: _"qmd not installed — semantic retrieval unavailable; the generated ownership index + `keywords:` discovery are active."_ The index is a **local rebuildable lens** — data stays in git; never commit index artifacts, and never use `qmd init` (the default global index keeps the repo clean).
93
201
 
94
- 1. Update `docs/structure.md` Health Log with today's date and summary
95
- 2. Update `docs/memory/maintenance.md` with last review date, stale docs fixed, unowned paths, backlog items created
96
- 3. Report findings: stale docs, broken ownership, unowned code, architecture drift, backlog health
97
- 4. **Inbox-distillation threshold.** Count undigested inbox entries — `## ` entry blocks across `docs/memory/inbox/*.md` (the inbox is consume-on-digest, so every block present is undigested). If the count is **≥5**, add one line to the report **proposing** a `distiller` `facts` run — propose only, never auto-run, no cron. If the user declines or ignores it, do nothing: the count keeps growing and the proposal reappears next pass — that recurrence _is_ the dedupe, so never backlog it.
98
- 5. **Docs-distillation threshold.** Per target doc, count undigested fact-cards (`invalid_from: null`, the doc's path not in their `digested_into:`) that **touch** it by the structural intersection in `skills/distiller/references/docs-mode.md` Resolution 1 (provenance ∩ the doc's `routing.md` patterns strong, entities ∩ declared-ownership supporting — qmd-independent). If **≥10** map to **one** doc, add one line to the report **proposing** a `distiller docs --doc <path>` run on that doc — propose only, never auto-run, no cron. Declined or ignored ⇒ the count keeps growing and the proposal reappears next pass; that recurrence _is_ the dedupe, so never backlog the proposal.
202
+ If the binary exists, register the docs subtrees once the tree is scaffolded. **Do not register one collection rooted at `docs/`** — qmd hard-codes the `**/*.md` pattern and has no exclude flag, so a `docs/`-root collection would sweep the consumable inbox queue at `docs/memory/inbox/` into the index (the inbox's entries are deleted on digestion, leaving dangling index entries). Register **per indexable subtree** (skip absent ones; `{repo}` = the repo's directory name; an existing name/path no-ops — treat as success):
99
203
 
100
- ## Step 8: Refresh Index (Optional)
204
+ - `qmd collection add docs/features --name {repo}-features`
205
+ - `qmd collection add docs/architecture --name {repo}-architecture`
206
+ - `qmd collection add docs/operations --name {repo}-operations`
207
+ - `qmd collection add docs/memory/facts --name {repo}-facts` (never `docs/memory` as a whole)
101
208
 
102
- If the `qmd` binary is available (`command -v qmd`), re-run `qmd embed -c <collection>` once per `{repo}-*` collection (`{repo}` = the repo's directory name; `qmd collection list` shows the set harness-manager registered — skip any absent) so the local docs index reflects the files this pass touched. Scope every run with `-c` — the qmd index is global (`~/.cache/qmd/` holds every repo's collections), so a bare `qmd embed` would re-embed unrelated repos' collections. If `qmd` is absent, skip silently — it's never required.
209
+ Then `qmd context add` per registered collection and `qmd embed -c <name>` per collection (always scope with `-c`; a bare `qmd embed` re-embeds every repo's collections). This augments discovery; it never supersedes the `owns:`-glob ownership resolution.
103
210
 
104
- ## Step 9: Check Anchor Drift (Optional)
211
+ ### Step B6 — Module proposal
105
212
 
106
- If `qmd` is absent (`command -v qmd` finds nothing), **skip this whole step silently** — it's never required.
213
+ Modules are **labels, 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/` already names.
107
214
 
108
- This catches **doc-area drift** — the subject the doc abstracts moving or vanishing from the indexed corpus. It does **not** catch a pure code rename that leaves the doc's prose unchanged: the anchor query semantically matches the doc's own text, so the result set doesn't shift. Code-symbol drift is Step 2's named-referent check, not this one — the two are complementary, not redundant.
215
+ - Propose the derived contexts as candidate `module:` labels. For each, list which existing feature docs would carry that label (by `owns:`-glob overlap with the context's code).
216
+ - **Propose — don't force.** Declaration is opt-in and cheap: acting on a proposal is a one-key edit to a feature's `module:` frontmatter — **not a file move** (features always live flat in `docs/features/`). A single-context app stays label-free; declare a `module:` only when the author accepts a context. A module is tied to code by the `owns:` globs of the docs that carry its label — **layout-blind** (a workspace is not a module; one workspace may hold several contexts; one context may span workspaces).
109
217
 
110
- Glob `docs/{features,modules/*/features}/**/*.md`, `docs/architecture/**/*.md`, and `docs/operations/**/*.md` for docs carrying `anchors:` frontmatter. For each anchor query on such a doc, resolve it with `qmd query --format json -c <collection> "<query>"` — repeat `-c` per relevant `{repo}-*` collection (no comma lists; the collection set is what `qmd collection list` shows). If a query resolves to **nothing**, or to a result set that has **radically shifted** away from the area the doc describes, raise it as a drift finding **phrased as a question** — e.g. `docs/x.md anchors "<query>" — resolves to nothing; confirm the area moved before treating the doc as stale` — and ask the user. On **yes**, dispatch the remediation sub-agent (the same yes-branch as Step 6). On **decline or no action**, append it to `docs/history/backlog.md` at the finding's own P0–P3 severity per the **Declined realignment** branch in Step 6 — same scale, deduped, never a gate.
218
+ Re-running you is safe — the structure work is idempotent, so a second pass is just the audit plus the module proposal.
111
219
 
112
220
  ---
113
221
 
114
222
  ## Rules
115
223
 
116
- - Never delete feature docs — only update or flag for review
117
- - Never modify `docs/history/plans/` or `docs/history/changelog/` (frozen records)
118
- - Preserve existing doc structure and formatting when updating
119
- - When in doubt, create a backlog item rather than making a wrong update
120
- - Be specific: include file paths, line numbers, and what changed
121
- - Respect known-exceptions in `docs/memory/maintenance.md` — don't re-flag suppressed findings
122
- - A clean report is valid — do not invent issues
224
+ - **Never delete feature docs** — only update or flag for review.
225
+ - **Never modify `docs/history/plans/` or `docs/history/changelog/`** (frozen records).
226
+ - **Preserve existing doc structure and formatting** when updating.
227
+ - **When in doubt, create a backlog item** rather than making a wrong update.
228
+ - **Be specific:** include file paths, line numbers, and what changed.
229
+ - **Respect known-exceptions** in `docs/memory/maintenance.md` — don't re-flag suppressed findings.
230
+ - **A clean report is valid** — do not invent issues.
231
+ - **Declarative, idempotent.** Re-running baseline mode on a current repo is a no-op. Converge to the current shape; never replay a version ladder; never reconstruct a past shape.
232
+ - **One sentinel.** `docs/structure.md` `harness-version` is the only baseline/version marker.
233
+ - **Modules are labels, layout-blind.** Seed from the code's bounded contexts; never from `pnpm-workspace.yaml`/workspace walls. Propose, don't force; acting is a `module:` tag, never a folder.
234
+ - **You orchestrate docs; the `documentation` skill supplies templates.** It is a library — never expect it to baseline.
235
+ - **Never overwrite an existing root `README.md`.** It is human-authored.
236
+ - **Stay in `docs/` (+ the root `README.md` scaffold) and `docs/memory/maintenance.md`.** You never edit `CLAUDE.md` (the CLI ships it) or production code.
237
+
238
+ ## Strategy memory
239
+
240
+ After a run you may append to `docs/memory/maintenance.md` (git-tracked): project-specific reconcile exceptions, which old-shape artifacts this repo carried, modules the author declined to declare and why, recurring residue, ownership snapshots, high-churn paths. Never user preferences (those are `~/.claude/`); never a transcription of doc content. Date each entry `## YYYY-MM-DD — {topic}`.
@@ -21,7 +21,7 @@ First, understand the documentation landscape:
21
21
  2. If `./docs/features/README.md` exists, read it to see existing feature specs and where the new spec fits; otherwise glob the feature docs directly
22
22
  3. If `./docs/memory/spec-mode.md` exists, read it for feature doc inventory, ownership conflict zones, and lessons from previous research
23
23
  4. Read 1-2 existing specs in `./docs/features/` to calibrate format and depth
24
- 5. Read `./docs/routing.md` (File-Pattern Routes) to build the ownership map — pattern → canonical doc + module. This is the source of truth for what code paths are already owned (feature docs carry no ownership frontmatter).
24
+ 5. Consult the **injected ownership index** (the generated `glob → doc · module · keywords · status` map — the union of every feature doc's `owns:` frontmatter) to build the ownership map. This is the source of truth for what code paths are already owned. If the index isn't present in context, glob `docs/features/**/*.md` and read each doc's `owns:` frontmatter directly.
25
25
 
26
26
  This tells you what already exists, what's adjacent, how detailed the spec should be, and what code paths are already owned.
27
27
 
@@ -32,7 +32,7 @@ This tells you what already exists, what's adjacent, how detailed the spec shoul
32
32
  3. **Affected modules** — Identify what files, routes, components, and data flows are relevant
33
33
  4. **Current state** — Understand how the system works today in the area being specified
34
34
  5. **Dependencies** — Map what this feature touches and what depends on it
35
- 6. **Ownership conflicts** — Compare the new feature's intended code paths against existing `docs/routing.md` patterns. Report overlaps.
35
+ 6. **Ownership conflicts** — Compare the new feature's intended code paths against existing feature docs' `owns:` globs. Report overlaps (two docs claiming the same paths at equal specificity).
36
36
 
37
37
  ## What You Return
38
38
 
@@ -43,7 +43,7 @@ Structure your findings as:
43
43
  - **Affected modules**: Files, routes, components that will be involved
44
44
  - **Current behavior**: How the relevant part of the system works today
45
45
  - **Conventions**: Naming, structure, and patterns to follow based on existing code
46
- - **Ownership conflicts**: Existing feature docs whose `docs/routing.md` patterns overlap with the proposed feature. Include the conflicting paths and the owning doc name.
46
+ - **Ownership conflicts**: Existing feature docs whose `owns:` globs overlap with the proposed feature. Include the conflicting paths and the owning doc name.
47
47
  - **Risks or concerns**: Anything the spec should address or call out
48
48
 
49
49
  Use the documentation skill's style guide and conventions when structuring your findings — imperative voice, ASCII diagrams for flows, function signatures over implementations, concise.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "harness": "etna",
3
3
  "name": "etna",
4
- "version": "0.1.1",
4
+ "version": "1.0.1",
5
5
  "files": [
6
6
  ".prettierrc.json",
7
7
  ".prettierignore",
8
8
  ".vscode/settings.json"
9
9
  ],
10
- "digest": "085aa22986b2"
10
+ "digest": "5699e31e9981"
11
11
  }