@nurix/etna 0.18.0 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +6 -5
  2. package/data/harness-index.json +1 -5
  3. package/data/harnesses/code/CLAUDE.md +8 -19
  4. package/data/harnesses/code/agents/brainstorm.md +3 -3
  5. package/data/harnesses/code/agents/change-review.md +13 -10
  6. package/data/harnesses/code/agents/harness-manager.md +15 -15
  7. package/data/harnesses/code/agents/maintenance.md +10 -3
  8. package/data/harnesses/code/agents/performance-review.md +5 -0
  9. package/data/harnesses/code/harness.json +1 -1
  10. package/data/harnesses/code/rules/general.md +40 -36
  11. package/data/harnesses/code/skills/boundary/SKILL.md +15 -42
  12. package/data/harnesses/code/skills/boundary/references/boundary-taxonomy.md +366 -304
  13. package/data/harnesses/code/skills/brainstorm/README.md +9 -9
  14. package/data/harnesses/code/skills/brainstorm/SKILL.md +15 -15
  15. package/data/harnesses/code/skills/brainstorm/harvest.md +3 -3
  16. package/data/harnesses/code/skills/brainstorm/templates/backlog.md +2 -2
  17. package/data/harnesses/code/skills/brainstorm/templates/build.md +6 -6
  18. package/data/harnesses/code/skills/brainstorm/templates/decisions.md +3 -3
  19. package/data/harnesses/code/skills/brainstorm/templates/doctrine.md +2 -2
  20. package/data/harnesses/code/skills/brainstorm/templates/domain-model.md +2 -2
  21. package/data/harnesses/code/skills/brainstorm/templates/glossary.md +2 -1
  22. package/data/harnesses/code/skills/brainstorm/templates/non-goals.md +3 -7
  23. package/data/harnesses/code/skills/brainstorm/templates/questions.md +6 -5
  24. package/data/harnesses/code/skills/brainstorm/templates/state.md +1 -8
  25. package/data/harnesses/code/skills/brainstorm/templates/tech.md +6 -6
  26. package/data/harnesses/code/skills/brainstorm/templates/thesis.md +2 -2
  27. package/data/harnesses/code/skills/distiller/SKILL.md +48 -177
  28. package/data/harnesses/code/skills/distiller/references/docs-mode.md +116 -343
  29. package/data/harnesses/code/skills/distiller/references/method.md +37 -109
  30. package/data/harnesses/code/skills/documentation/SKILL.md +9 -6
  31. package/data/harnesses/code/skills/documentation/references/examples.md +30 -61
  32. package/data/harnesses/code/skills/documentation/references/style-guide.md +59 -62
  33. package/data/harnesses/code/skills/documentation/references/templates.md +26 -34
  34. package/data/harnesses/code/skills/workflow-mapper/SKILL.md +32 -11
  35. package/data/harnesses/code/skills/workflow-mapper/references/patterns.md +1 -1
  36. package/data/harnesses/discover/CLAUDE.md +60 -113
  37. package/data/harnesses/discover/agents/api.md +11 -28
  38. package/data/harnesses/discover/agents/codebase.md +12 -30
  39. package/data/harnesses/discover/agents/community.md +9 -21
  40. package/data/harnesses/discover/agents/deployed-client-bundle.md +16 -67
  41. package/data/harnesses/discover/agents/distribution-artifacts.md +21 -59
  42. package/data/harnesses/discover/agents/docs.md +11 -20
  43. package/data/harnesses/discover/agents/infra-backend-fingerprint.md +28 -68
  44. package/data/harnesses/discover/agents/packages.md +12 -28
  45. package/data/harnesses/discover/agents/session.md +18 -50
  46. package/data/harnesses/discover/agents/website.md +9 -19
  47. package/data/harnesses/discover/agents/wire-capture.md +22 -72
  48. package/data/harnesses/discover/harness.json +1 -1
  49. package/data/harnesses/discover/rules/cartography-coverage.md +94 -0
  50. package/data/harnesses/discover/rules/cartography-flows.md +99 -0
  51. package/data/harnesses/discover/rules/cartography-ia.md +88 -0
  52. package/data/harnesses/discover/rules/cartography.md +109 -0
  53. package/data/harnesses/discover/rules/discovery.md +73 -182
  54. package/data/harnesses/discover/rules/evaluation.md +92 -98
  55. package/data/harnesses/discover/rules/ingestion.md +123 -322
  56. package/data/harnesses/discover/rules/self-correction.md +94 -107
  57. package/data/harnesses/discover/rules/tradecraft.md +201 -172
  58. package/data/harnesses/hr/CLAUDE.md +21 -51
  59. package/data/harnesses/hr/harness.json +1 -1
  60. package/data/harnesses/hr/skills/interview-eval/SKILL.md +23 -11
  61. package/data/harnesses/hr/skills/interview-eval/TEMPLATE.md +49 -29
  62. package/data/harnesses/hr/skills/interview-eval/rubric.md +30 -30
  63. package/data/harnesses/kb-agi/CLAUDE.md +8 -8
  64. package/data/harnesses/kb-agi/agents/kb-agi-init.md +31 -22
  65. package/data/harnesses/kb-agi/agents/kb-catch-stale.md +1 -1
  66. package/data/harnesses/kb-agi/agents/kb-find-gaps.md +1 -1
  67. package/data/harnesses/kb-agi/agents/kb-fix-links.md +1 -1
  68. package/data/harnesses/kb-agi/agents/kb-refresh-summaries.md +2 -2
  69. package/data/harnesses/kb-agi/agents/kb-sync-metadata.md +2 -2
  70. package/data/harnesses/kb-agi/harness.json +1 -1
  71. package/package.json +1 -1
  72. package/data/harnesses/code-fable/.prettierignore +0 -12
  73. package/data/harnesses/code-fable/.prettierrc.json +0 -3
  74. package/data/harnesses/code-fable/.vscode/settings.json +0 -10
  75. package/data/harnesses/code-fable/CLAUDE.md +0 -135
  76. package/data/harnesses/code-fable/agents/brainstorm.md +0 -35
  77. package/data/harnesses/code-fable/agents/change-review.md +0 -248
  78. package/data/harnesses/code-fable/agents/harness-manager.md +0 -181
  79. package/data/harnesses/code-fable/agents/maintenance.md +0 -115
  80. package/data/harnesses/code-fable/agents/performance-review.md +0 -218
  81. package/data/harnesses/code-fable/agents/spec-mode.md +0 -56
  82. package/data/harnesses/code-fable/harness.json +0 -12
  83. package/data/harnesses/code-fable/hooks/hooks.json +0 -27
  84. package/data/harnesses/code-fable/hooks/lib/redact.mjs +0 -35
  85. package/data/harnesses/code-fable/hooks/prompt-recall.mjs +0 -155
  86. package/data/harnesses/code-fable/hooks/session-reflect.mjs +0 -285
  87. package/data/harnesses/code-fable/rules/general.md +0 -79
  88. package/data/harnesses/code-fable/rules/nomenclature.md +0 -30
  89. package/data/harnesses/code-fable/rules/typescript.md +0 -19
  90. package/data/harnesses/code-fable/skills/boundary/SKILL.md +0 -76
  91. package/data/harnesses/code-fable/skills/boundary/references/boundary-taxonomy.md +0 -734
  92. package/data/harnesses/code-fable/skills/brainstorm/README.md +0 -136
  93. package/data/harnesses/code-fable/skills/brainstorm/SKILL.md +0 -135
  94. package/data/harnesses/code-fable/skills/brainstorm/harvest.md +0 -26
  95. package/data/harnesses/code-fable/skills/brainstorm/templates/backlog.md +0 -39
  96. package/data/harnesses/code-fable/skills/brainstorm/templates/build.md +0 -37
  97. package/data/harnesses/code-fable/skills/brainstorm/templates/decisions.md +0 -29
  98. package/data/harnesses/code-fable/skills/brainstorm/templates/doctrine.md +0 -31
  99. package/data/harnesses/code-fable/skills/brainstorm/templates/domain-model.md +0 -25
  100. package/data/harnesses/code-fable/skills/brainstorm/templates/glossary.md +0 -19
  101. package/data/harnesses/code-fable/skills/brainstorm/templates/milestones.md +0 -43
  102. package/data/harnesses/code-fable/skills/brainstorm/templates/non-goals.md +0 -21
  103. package/data/harnesses/code-fable/skills/brainstorm/templates/plan-doc.md +0 -61
  104. package/data/harnesses/code-fable/skills/brainstorm/templates/questions.md +0 -35
  105. package/data/harnesses/code-fable/skills/brainstorm/templates/references.md +0 -28
  106. package/data/harnesses/code-fable/skills/brainstorm/templates/rejected.md +0 -29
  107. package/data/harnesses/code-fable/skills/brainstorm/templates/state.md +0 -8
  108. package/data/harnesses/code-fable/skills/brainstorm/templates/tech.md +0 -23
  109. package/data/harnesses/code-fable/skills/brainstorm/templates/thesis.md +0 -21
  110. package/data/harnesses/code-fable/skills/distiller/SKILL.md +0 -219
  111. package/data/harnesses/code-fable/skills/distiller/references/docs-mode.md +0 -526
  112. package/data/harnesses/code-fable/skills/distiller/references/method.md +0 -166
  113. package/data/harnesses/code-fable/skills/documentation/SKILL.md +0 -125
  114. package/data/harnesses/code-fable/skills/documentation/references/examples.md +0 -193
  115. package/data/harnesses/code-fable/skills/documentation/references/style-guide.md +0 -288
  116. package/data/harnesses/code-fable/skills/documentation/references/templates.md +0 -865
  117. package/data/harnesses/code-fable/skills/workflow-mapper/SKILL.md +0 -430
  118. package/data/harnesses/code-fable/skills/workflow-mapper/references/patterns.md +0 -214
@@ -1,248 +0,0 @@
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. Glob `./docs/{features,modules/*/features}/**/*.md` and read `owns` frontmatter to map churn to owning feature docs.
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
- - `files_changed`: number of files in the commit
70
- - `insertions`: sum of added lines across all files
71
- - `deletions`: sum of removed lines across all files
72
- - `directories`: unique top-level directories touched (e.g., `src/components/Button.jsx` → `src/components`)
73
-
74
- Build a registry of objects:
75
-
76
- ```
77
- { hash, date, author, message, files[], files_changed, insertions, deletions, directories[] }
78
- ```
79
-
80
- ## Step 3: Batch & Dispatch Sub-Agents
81
-
82
- Split the commit registry into batches of `batch_size` commits each.
83
-
84
- Spawn **haiku** sub-agents via the Task tool with `subagent_type: "general-purpose"` and `model: "haiku"`. Launch up to 5 batches in parallel.
85
-
86
- 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:
87
-
88
- **Generic Module Taxonomy fallback:**
89
- ```
90
- 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`.
91
- ```
92
-
93
- **Generic Feature Taxonomy fallback:**
94
- ```
95
- Infer the product area from the commit message and file paths. Use descriptive labels like `auth`, `editor`, `deploy`, `ui`, `infra`, `docs`, `dx`, `other`.
96
- ```
97
-
98
- Each sub-agent receives this prompt template (fill in `{COMMITS_JSON}`, `{BATCH_NUMBER}`, `{MODULE_TAXONOMY}`, and `{FEATURE_TAXONOMY}`):
99
-
100
- ````
101
- You are a commit classifier. Classify each commit below into a pipe-delimited row.
102
-
103
- ## Output Format
104
-
105
- Return ONLY pipe-delimited rows, one per commit. No headers. No explanation. No markdown fences.
106
-
107
- Fields: hash|date|author|message|module|feature|impact_type|severity|breaking|files_changed|insertions|deletions|directories|summary
108
-
109
- ## Field Definitions
110
-
111
- - **hash**: Use the provided short hash exactly as given
112
- - **date**: Use the provided date exactly as given
113
- - **author**: Use the provided author exactly as given
114
- - **message**: Use the provided first-line message exactly as given. If it contains pipe characters, replace them with dashes.
115
- - **module**: Classify based on changed file paths (see Module Taxonomy below)
116
- - **feature**: Classify based on what product area is affected (see Feature Taxonomy below)
117
- - **impact_type**: One of: feature, enhancement, bugfix, refactor, style, docs, config, infra, revert
118
- - **severity**: high (new features, breaking changes, major refactors), medium (enhancements, non-trivial fixes), low (typos, style, docs, config tweaks)
119
- - **breaking**: "yes" if the commit changes APIs, data models, or contracts in backward-incompatible ways. Otherwise "no".
120
- - **files_changed**: Use the provided pre-computed value exactly as given
121
- - **insertions**: Use the provided pre-computed value exactly as given
122
- - **deletions**: Use the provided pre-computed value exactly as given
123
- - **directories**: Use the provided pre-computed value exactly as given (comma-separated)
124
- - **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.
125
-
126
- ## Module Taxonomy
127
-
128
- {MODULE_TAXONOMY}
129
-
130
- ## Feature Taxonomy
131
-
132
- {FEATURE_TAXONOMY}
133
-
134
- 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.
135
-
136
- ## Commits to Classify (Batch {BATCH_NUMBER})
137
-
138
- ```json
139
- {COMMITS_JSON}
140
- ```
141
-
142
- Each object has: hash, date, author, message, files (array of changed file paths), files_changed (int), insertions (int), deletions (int), directories (comma-separated string).
143
-
144
- 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.
145
- ````
146
-
147
- If you have more batches than can fit in 5 parallel launches, wait for the first wave to complete, then launch the next wave.
148
-
149
- ## Step 4: Assemble CSV
150
-
151
- 1. Collect all sub-agent outputs
152
- 2. Split each output into lines, trimming whitespace and blank lines
153
- 3. Validate each row has exactly 14 pipe-delimited fields
154
- 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.
155
- 5. If an entire batch failed, retry it once with the same prompt. On second failure, fallback-classify all commits in that batch.
156
- 6. Prepend the header row: `hash|date|author|message|module|feature|impact_type|severity|breaking|files_changed|insertions|deletions|directories|summary`
157
- 7. Sort data rows by date ascending, then by hash
158
- 8. Write to the output file at project root using the Write tool
159
-
160
- ## Step 5: Classification Summary
161
-
162
- After writing the CSV, compute and display these statistics by parsing the CSV:
163
-
164
- - **Author breakdown** — commits per author (descending), breaking changes per author, lines changed per author
165
- - **Module distribution** — commit count, files changed, and lines changed per module (descending)
166
- - **Feature distribution** — commit count per feature (descending)
167
- - **Severity distribution** — count of high / medium / low
168
- - **Velocity snapshot** — total commits, files changed, insertions, deletions in the period; top 5 directories by commit count; top 5 directories by lines changed
169
- - **Breaking changes** — list all rows where breaking=yes, showing hash, author, message, module
170
-
171
- Report the output file path and total row count.
172
-
173
- ### Fallback Classification
174
-
175
- When a commit cannot be classified by a sub-agent, use these defaults:
176
-
177
- ```
178
- {hash}|{date}|{author}|{message}|unknown|other|unknown|low|no|{files_changed}|{insertions}|{deletions}|{directories}|Could not classify commit
179
- ```
180
-
181
- ---
182
-
183
- # Phase 2 — Velocity analysis
184
-
185
- 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).
186
-
187
- ## Step 6: Velocity Heatmap
188
-
189
- Compute commits-per-directory over rolling windows:
190
-
191
- - **1 week** — what's hot right now
192
- - **1 month** — current rhythm
193
- - **3 months** — quarter-level pattern
194
-
195
- Aggregate by the top-level directories the CSV's `directories` field already carries (computed generically in Phase 1, Step 2). Report:
196
-
197
- | Directory | Commits 1w | Commits 1m | Commits 3m | Trend |
198
- |-----------|-----------:|-----------:|-----------:|-------|
199
-
200
- Trend column: ↑ rising, ↓ falling, → steady, ↑↑ sharply rising, ↓↓ sharply falling.
201
-
202
- ## Step 7: Risk Zones
203
-
204
- For each module with high churn (top quartile in 1m window), check how contract-heavy and how covered it is:
205
-
206
- - 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.
207
- - Is the module's `owns` doc up to date? (cross-reference with the maintenance agent's last drift check if available)
208
- - Does the module appear in `docs/routing.md`?
209
-
210
- Flag risk zones: high churn × contract-heavy × low doc coverage. These are where silent breakage is most likely.
211
-
212
- ## Step 8: Stabilization Signals
213
-
214
- Identify modules where 1-week and 1-month velocity are both decreasing. Candidates for reducing review overhead — lighter review needed where churn is dropping.
215
-
216
- ## Step 9: Team Distribution
217
-
218
- Per module, list which authors made the most commits in the 3-month window. Surface concentration risks:
219
-
220
- - One author > 70% of commits in a critical module → bus-factor flag
221
- - One author owns all changes touching a contract-heavy surface → review-coverage flag
222
-
223
- ## Step 10: Report & Track
224
-
225
- ### Report format
226
-
227
- - **Velocity heatmap** (table above)
228
- - **Risk zones**: top 5 high-churn modules that own contract-heavy surfaces, with the specific contracts at risk named
229
- - **Stabilization signals**: modules where review overhead can decrease
230
- - **Concentration risks**: bus-factor and review-coverage flags
231
- - **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"
232
-
233
- ### Update tracking
234
-
235
- 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.
236
- 2. Append items to `docs/history/backlog.md`:
237
- - `- **[P1]** High churn in contract-heavy directory \`{dir}/\` with no doc coverage — discovered by change-review`
238
- 3. Report summary to the user
239
-
240
- ## Rules
241
-
242
- - Never modify source code — read-only except for writing the output CSV, `docs/memory/change-review.md`, and `docs/history/backlog.md`
243
- - Use `model: "haiku"` and `subagent_type: "general-purpose"` for all classification sub-agents to minimize cost
244
- - Always report progress: "Dispatching batch 1-5 of 12..." etc.
245
- - If git commands fail (bad branch, bad date range), stop and report the error clearly
246
- - Pipe characters in commit messages must be replaced with dashes before writing to CSV
247
- - Risk-zone identification judges contract-heaviness from the code itself (Step 7) — no persisted boundary docs exist or are needed
248
- - A clean report (no risk zones) is valid for a low-churn, well-covered project
@@ -1,181 +0,0 @@
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`; if absent or behind the installed version, converge `docs/` to the installed shape and stamp the new version. 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, broken `owns` globs, 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 epoch** — read it 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 epoch is the target.
41
- 3. Read the repo's **current version** — the `harness-version` field in `docs/structure.md` frontmatter. 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 ⇒ reconcile forward.
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
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 with ownership 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 (routing, memory, frontmatter `depends_on`, 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
- | no `harness-version` in `structure.md` | stamp it (Step 5) |
92
-
93
- Only fold what is present. `log()` what you skipped and why.
94
-
95
- ### Step 3 — Present the reconcile plan
96
-
97
- 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).
98
-
99
- ### Step 4 — Execute
100
-
101
- Create the folder structure; move/fold/merge/delete per the plan; add `Status:` to plan files; add ownership frontmatter to feature docs (call the `documentation` skill's **frontmatter derivation** for `owns`/`touches`/`depends_on`); 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:
102
-
103
- - `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**).
104
-
105
- 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.
106
-
107
- ### Step 5 — Stamp the version
108
-
109
- Write `harness-version: <installed epoch>` into `docs/structure.md` frontmatter. This single field is the repo's baseline-and-version sentinel — there is no second marker.
110
-
111
- ### Step 5b — Register the qmd retrieval lens (optional, skip-if-absent)
112
-
113
- 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).
114
-
115
- 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:
116
-
117
- 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`.
118
- - `qmd collection add docs/features --name {repo}-features`
119
- - `qmd collection add docs/architecture --name {repo}-architecture`
120
- - `qmd collection add docs/operations --name {repo}-operations`
121
- - `qmd collection add docs/memory/facts --name {repo}-facts`
122
- - `qmd collection add docs/modules --name {repo}-modules`
123
- 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:
124
- - `qmd context add qmd://{repo}-features/ "Feature abstractions — how each works + why it was built"`
125
- - `qmd context add qmd://{repo}-facts/ "Distilled recent decisions/observations, provenance-linked"`
126
- - `qmd context add qmd://{repo}-modules/ "Module-local features + pillars (the module's why)"`
127
- 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.
128
-
129
- This augments routing; it never supersedes the Step 6 ownership resolution.
130
-
131
- ### Step 6 — Module proposal
132
-
133
- 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 feature `owns` globs already name.
134
-
135
- - Propose the derived contexts as candidate modules. For each, partition existing flat feature docs by `owns`-glob overlap.
136
- - **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 `owns` globs, **layout-blind** — a workspace is not a module (one workspace may hold several contexts; one context may span workspaces).
137
-
138
- 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.
139
-
140
- Re-running you is safe — the structure work is already done (idempotent), so a second pass is just the module proposal.
141
-
142
- **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:
143
-
144
- > - `docs/x.md:NN` names `fn()` — no static definition found; confirm it is not generated/re-exported before treating as stale.
145
-
146
- 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).
147
-
148
- 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.
149
-
150
- ### Step 7 — Verify
151
-
152
- Confirm all mandated files exist; `structure.md` carries the current `harness-version`; no dead links in `docs/structure.md`; every plan has a `Status:`; feature docs have ownership frontmatter; no dissolved-version artifacts remain; no docs outside the canonical structure.
153
-
154
- ---
155
-
156
- ## Health audit (on demand)
157
-
158
- Conformance, not fidelity. Report a table; fix nothing destructively without asking.
159
-
160
- - **Version currency** — `harness-version` present in `structure.md` and equal to installed? If behind/absent → recommend Reconcile. (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.)
161
- - **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.
162
- - **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`+`epoch` 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 (epoch reconcile + published-version); the digest is provenance, and the seed for any future published-digest drift check.
163
- - **Scaffold completeness** — every mandated file present.
164
- - **Dissolved-version residue** — any `operations/guardrails.md`, repo-wide `docs/pillars/`, `architecture/overview.md`, a persisted `docs/boundaries/` tree, or other old-shape artifact lingering.
165
- - **Module declaration coverage** — do the repo's bounded contexts have declared module homes where the author intended them? (Surface gaps; never auto-declare.)
166
- - **`docs/tests/` ownership** — present-with-content, or absent. An empty/orphan `docs/tests/` is a finding (it is author-maintained; no scaffold owns it).
167
-
168
- ## Rules
169
-
170
- - **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.
171
- - **One sentinel.** `docs/structure.md` `harness-version` is the only baseline/version marker. Do not reintroduce a `docs/memory/index.md` "is-baselined" check.
172
- - **Modules are declared, layout-blind.** Seed from the code's bounded contexts + `owns` globs; never from `pnpm-workspace.yaml`/workspace walls. Propose, don't force.
173
- - **You orchestrate docs; the `documentation` skill supplies templates.** It is a library — you never expect it to baseline.
174
- - **Never overwrite an existing root `README.md`.** It is human-authored.
175
- - **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.
176
- - **Health reports; it does not remediate content.** Content fidelity is `maintenance`'s job.
177
- - **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.
178
-
179
- ## Strategy memory
180
-
181
- 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}`.
@@ -1,115 +0,0 @@
1
- ---
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.
4
- tools: Read, Glob, Grep, Edit, Write, Bash
5
- model: inherit
6
- ---
7
-
8
- # Maintenance Agent
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.
11
-
12
- Out of scope (handled by the `boundary` skill, which derives contracts dynamically from source):
13
- - **Pre-implementation impact analysis** (checking a plan against cross-cutting contracts before coding) → `boundary` skill, `check` mode
14
- - **Diff-scoped contract analysis** (what could a change break across module edges) → `boundary` skill, `scan` mode
15
-
16
- ## Before Starting
17
-
18
- 1. If `./docs/memory/maintenance.md` exists, read it for last review state, ownership snapshots, high-churn paths, and known failure modes.
19
- 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.
20
- 3. If `./docs/routing.md` exists, read it for the current file-pattern-to-doc mapping.
21
-
22
- ## Step 1: Build Ownership Map
23
-
24
- 1. Read `docs/structure.md` for the authority map
25
- 2. Glob `docs/{features,modules/*/features}/**/*.md` and extract YAML frontmatter (`owns`, `touches`, `depends_on`)
26
- 3. Build a map: glob pattern → owning doc
27
-
28
- **Architecture-first fallback.** If that glob yields **no `owns` frontmatter at all** (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. Feature-`owns` stays primary the moment any appears — this is a fallback, not a replacement.
29
-
30
- ## Step 2: Validate Ownership
31
-
32
- For each doc with `owns` frontmatter:
33
- - Verify the glob patterns match existing files
34
- - Report deleted paths, empty globs, orphaned ownership
35
-
36
- For each code symbol or path a doc explicitly **names** (function/export/route/type):
37
- - Verify it resolves in the code, independent of git-churn — Step 3's churn gate is blind to churn-free false claims
38
- - 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`)
39
- - On codegen/reflection/DI/barrel stacks where static resolution is unreliable, skip — yielding nothing is correct
40
-
41
- 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:
42
- - 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`.
43
- - 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.
44
-
45
- ## Step 3: Detect Doc Drift
46
-
47
- Run `git log --since="2 weeks ago" --name-only --pretty=format:"%h %s"` to find changed source files.
48
-
49
- For each changed file:
50
- - Match against `owns` patterns from every feature doc — flat and module-local alike (`docs/{features,modules/*/features}/**/*.md`) → identify the owning doc
51
- - If no owner exists → flag as unowned
52
- - If owner exists → compare last modified dates (`git log -1 --format="%ci" -- <path>`), flag docs where code changed more recently (14-day threshold)
53
-
54
- ## Step 4: Check Routing Table Drift
55
-
56
- If `./docs/routing.md` exists:
57
-
58
- 1. For each row, verify the file pattern matches existing files and referenced docs/agents exist
59
- 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
60
- 3. Fix drift directly, or backlog if unclear
61
-
62
- Also flag **unowned paths** — top-level source directories with no owning feature doc (no `owns` glob covers them).
63
-
64
- 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`).
65
-
66
- ## Step 5: Check Architecture & Backlog
67
-
68
- **Architecture drift:** Grep `docs/architecture/` for file path references. Verify referenced paths still exist. Remove or update stale references.
69
-
70
- **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 `owns` globs in `structure.md` / feature frontmatter; do not assume `src/`) against the union of all `owns` patterns from both flat and module-local feature docs (`docs/{features,modules/*/features}/**/*.md`). Report directories with no feature doc ownership.
71
-
72
- **Backlog health:** Read `docs/history/backlog.md`. Report items older than 30 days. Count pending by priority.
73
-
74
- ## Step 6: Remediate
75
-
76
- For each stale doc:
77
- - If drift is clear (renamed function, new export, changed props) → update the doc directly
78
- - If drift is ambiguous (major refactor, unclear intent) → backlog it
79
-
80
- For unowned code paths:
81
- - Append: `- **[P2]** No feature doc owns \`{dir}/\` — discovered by maintenance` (`{dir}` = the actual unowned source directory)
82
-
83
- **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.)
84
-
85
- ## Step 7: Report & Update Tracking
86
-
87
- 1. Update `docs/structure.md` Health Log with today's date and summary
88
- 2. Update `docs/memory/maintenance.md` with last review date, stale docs fixed, unowned paths, backlog items created
89
- 3. Report findings: stale docs, broken ownership, unowned code, architecture drift, backlog health
90
- 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.
91
- 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∩`owns` 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.
92
-
93
- ## Step 8: Refresh Index (Optional)
94
-
95
- 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.
96
-
97
- ## Step 9: Check Anchor Drift (Optional)
98
-
99
- If `qmd` is absent (`command -v qmd` finds nothing), **skip this whole step silently** — it's never required.
100
-
101
- 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.
102
-
103
- 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.
104
-
105
- ---
106
-
107
- ## Rules
108
-
109
- - Never delete feature docs — only update or flag for review
110
- - Never modify `docs/history/plans/` or `docs/history/changelog/` (frozen records)
111
- - Preserve existing doc structure and formatting when updating
112
- - When in doubt, create a backlog item rather than making a wrong update
113
- - Be specific: include file paths, line numbers, and what changed
114
- - Respect known-exceptions in `docs/memory/maintenance.md` — don't re-flag suppressed findings
115
- - A clean report is valid — do not invent issues