@nurix/etna 0.15.6 → 0.15.8

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 (88) hide show
  1. package/bin/etna.js +64 -13
  2. package/data/harness-index.json +7 -5
  3. package/data/harnesses/code/CLAUDE.md +3 -7
  4. package/data/harnesses/code/agents/harness-manager.md +4 -4
  5. package/data/harnesses/code/agents/maintenance.md +1 -1
  6. package/data/harnesses/code/harness.json +4 -3
  7. package/data/harnesses/code/hooks/hooks.json +3 -17
  8. package/data/harnesses/code/hooks/prompt-recall.js +157 -0
  9. package/data/harnesses/code/hooks/session-reflect.js +283 -0
  10. package/data/harnesses/code/skills/distiller/SKILL.md +62 -60
  11. package/data/harnesses/code/skills/distiller/references/docs-mode.md +21 -21
  12. package/data/harnesses/code/skills/distiller/references/method.md +41 -41
  13. package/data/harnesses/code/skills/documentation/references/templates.md +20 -27
  14. package/data/harnesses/code-fable/CLAUDE.md +138 -0
  15. package/data/harnesses/code-fable/agents/brainstorm.md +35 -0
  16. package/data/harnesses/code-fable/agents/change-review.md +249 -0
  17. package/data/harnesses/code-fable/agents/harness-manager.md +193 -0
  18. package/data/harnesses/code-fable/agents/maintenance.md +123 -0
  19. package/data/harnesses/code-fable/agents/performance-review.md +218 -0
  20. package/data/harnesses/code-fable/agents/spec-mode.md +56 -0
  21. package/data/harnesses/code-fable/harness.json +7 -0
  22. package/data/harnesses/code-fable/hooks/hooks.json +27 -0
  23. package/data/harnesses/code-fable/hooks/lib/redact.js +37 -0
  24. package/data/harnesses/code-fable/hooks/prompt-recall.js +157 -0
  25. package/data/harnesses/code-fable/hooks/session-reflect.js +283 -0
  26. package/data/harnesses/code-fable/rules/general.md +96 -0
  27. package/data/harnesses/code-fable/rules/nomenclature.md +34 -0
  28. package/data/harnesses/code-fable/skills/boundary/SKILL.md +262 -0
  29. package/data/harnesses/code-fable/skills/boundary/references/boundary-taxonomy.md +734 -0
  30. package/data/harnesses/code-fable/skills/brainstorm/README.md +136 -0
  31. package/data/harnesses/code-fable/skills/brainstorm/SKILL.md +135 -0
  32. package/data/harnesses/code-fable/skills/brainstorm/harvest.md +26 -0
  33. package/data/harnesses/code-fable/skills/brainstorm/templates/backlog.md +39 -0
  34. package/data/harnesses/code-fable/skills/brainstorm/templates/build.md +37 -0
  35. package/data/harnesses/code-fable/skills/brainstorm/templates/decisions.md +29 -0
  36. package/data/harnesses/code-fable/skills/brainstorm/templates/doctrine.md +31 -0
  37. package/data/harnesses/code-fable/skills/brainstorm/templates/domain-model.md +25 -0
  38. package/data/harnesses/code-fable/skills/brainstorm/templates/glossary.md +19 -0
  39. package/data/harnesses/code-fable/skills/brainstorm/templates/milestones.md +43 -0
  40. package/data/harnesses/code-fable/skills/brainstorm/templates/non-goals.md +21 -0
  41. package/data/harnesses/code-fable/skills/brainstorm/templates/plan-doc.md +61 -0
  42. package/data/harnesses/code-fable/skills/brainstorm/templates/questions.md +35 -0
  43. package/data/harnesses/code-fable/skills/brainstorm/templates/references.md +28 -0
  44. package/data/harnesses/code-fable/skills/brainstorm/templates/rejected.md +29 -0
  45. package/data/harnesses/code-fable/skills/brainstorm/templates/state.md +8 -0
  46. package/data/harnesses/code-fable/skills/brainstorm/templates/tech.md +23 -0
  47. package/data/harnesses/code-fable/skills/brainstorm/templates/thesis.md +21 -0
  48. package/data/harnesses/code-fable/skills/distiller/SKILL.md +219 -0
  49. package/data/harnesses/code-fable/skills/distiller/references/docs-mode.md +526 -0
  50. package/data/harnesses/code-fable/skills/distiller/references/method.md +166 -0
  51. package/data/harnesses/code-fable/skills/documentation/SKILL.md +127 -0
  52. package/data/harnesses/code-fable/skills/documentation/references/examples.md +193 -0
  53. package/data/harnesses/code-fable/skills/documentation/references/style-guide.md +288 -0
  54. package/data/harnesses/code-fable/skills/documentation/references/templates.md +942 -0
  55. package/data/harnesses/code-fable/skills/workflow-mapper/SKILL.md +430 -0
  56. package/data/harnesses/code-fable/skills/workflow-mapper/references/patterns.md +214 -0
  57. package/data/harnesses/discover/CLAUDE.md +180 -0
  58. package/data/harnesses/{re → discover}/agents/api.md +3 -3
  59. package/data/harnesses/{re → discover}/agents/codebase.md +3 -3
  60. package/data/harnesses/{re → discover}/agents/community.md +3 -3
  61. package/data/harnesses/{re → discover}/agents/deployed-client-bundle.md +21 -15
  62. package/data/harnesses/{re → discover}/agents/distribution-artifacts.md +13 -12
  63. package/data/harnesses/{re → discover}/agents/docs.md +3 -3
  64. package/data/harnesses/{re → discover}/agents/infra-backend-fingerprint.md +3 -3
  65. package/data/harnesses/{re → discover}/agents/packages.md +3 -3
  66. package/data/harnesses/{re → discover}/agents/session.md +29 -11
  67. package/data/harnesses/{re → discover}/agents/website.md +3 -3
  68. package/data/harnesses/{re → discover}/agents/wire-capture.md +14 -10
  69. package/data/harnesses/discover/harness.json +7 -0
  70. package/data/harnesses/{re/rules/re-discovery.md → discover/rules/discovery.md} +86 -17
  71. package/data/harnesses/{re/rules/re-evaluation.md → discover/rules/evaluation.md} +40 -4
  72. package/data/harnesses/discover/rules/ingestion.md +551 -0
  73. package/data/harnesses/discover/rules/self-correction.md +177 -0
  74. package/data/harnesses/discover/rules/tradecraft.md +532 -0
  75. package/data/harnesses/hr/CLAUDE.md +91 -0
  76. package/data/harnesses/hr/harness.json +7 -0
  77. package/data/harnesses/hr/skills/interview-eval/SKILL.md +118 -0
  78. package/data/harnesses/hr/skills/interview-eval/TEMPLATE.md +124 -0
  79. package/data/harnesses/hr/skills/interview-eval/extract_session.py +418 -0
  80. package/data/harnesses/hr/skills/interview-eval/rubric.md +219 -0
  81. package/data/harnesses/kb-agi/harness.json +1 -0
  82. package/package.json +1 -1
  83. package/data/harnesses/code/hooks/post-commit.js +0 -136
  84. package/data/harnesses/code/hooks/post-tool-failure.js +0 -136
  85. package/data/harnesses/code/hooks/session-stop.js +0 -207
  86. package/data/harnesses/re/CLAUDE.md +0 -146
  87. package/data/harnesses/re/harness.json +0 -6
  88. package/data/harnesses/re/rules/re-ingestion.md +0 -327
@@ -0,0 +1,942 @@
1
+ # Documentation Templates
2
+
3
+ Templates for all documentation needs.
4
+
5
+ ---
6
+
7
+ ## 1. docs/README.md (Documentation Root)
8
+
9
+ Use for: the entry point for all documentation in a repo. Created during baseline audit.
10
+
11
+ ```
12
+ # {Project Name} Documentation
13
+
14
+ Technical documentation for {project description}.
15
+
16
+ > For documentation organization, authority map, and folder rules, see **[structure.md](structure.md)**.
17
+
18
+ ---
19
+
20
+ ## Quick Links
21
+
22
+ | Document | Description |
23
+ | --------------------------------- | ------------------------------------ |
24
+ | [Structure](structure.md) | Documentation entry point and rules |
25
+ | [Setup](operations/setup.md) | Installation and configuration guide |
26
+
27
+ ---
28
+
29
+ ## Architecture
30
+
31
+ System design, patterns, and technical decisions.
32
+
33
+ - [system-design.md](architecture/system-design.md) - High-level system architecture
34
+ {list all architecture docs}
35
+
36
+ ---
37
+
38
+ ## Features
39
+
40
+ Living reference docs for implemented features (how things currently work).
41
+
42
+ - [feature-name.md](features/feature-name.md) - Feature description
43
+ {list all feature docs}
44
+
45
+ ---
46
+
47
+ ## Operations
48
+
49
+ How to run, develop, and deploy.
50
+
51
+ - [setup.md](operations/setup.md) - Installation and configuration guide
52
+ {list all operations docs}
53
+
54
+ ---
55
+
56
+ ## History
57
+
58
+ Everything frozen or append-only.
59
+
60
+ - [CHANGELOG.md](history/CHANGELOG.md) - Master changelog index
61
+ - [changelog/](history/changelog/) - Individual changelog entries
62
+ - [plans/](history/plans/) - Historical implementation plans
63
+ - [backlog.md](history/backlog.md) - Tracked work items and technical debt
64
+
65
+ ---
66
+
67
+ ## Contributing
68
+
69
+ See [CLAUDE.md](../CLAUDE.md) for documentation guidelines.
70
+ ```
71
+
72
+ ---
73
+
74
+ ## 2. docs/structure.md (Authority Map)
75
+
76
+ Use for: defining which folder owns which topic and how docs are maintained.
77
+
78
+ ```
79
+ ---
80
+ harness-version: 12
81
+ ---
82
+
83
+ # Documentation Structure
84
+
85
+ > This file is the entry point for understanding the docs folder.
86
+ > `harness-version` above is the repo's single baseline/version sentinel — the `harness-manager` agent owns it and stamps the installed design epoch on every reconcile.
87
+
88
+ ## Authority Map
89
+
90
+ Each topic has one canonical location. Read from here, not from plans or changelogs.
91
+
92
+ | Topic | Authority | Key Files |
93
+ | ----- | --------- | --------- |
94
+ | System architecture + steering | `docs/architecture/` | domain-model, glossary, non-goals, references, adr/ |
95
+ | Feature behavior | `docs/features/` (or `docs/modules/{m}/features/`) | {key files} |
96
+ | Cross-module contracts | `docs/boundaries/` | one file per boundary (maintained by the `boundary` skill) |
97
+ | Declared modules (bounded contexts) | `docs/modules/{m}/` | `features/` + `pillars/` |
98
+ | Setup & development | `docs/operations/` | {key files} |
99
+ | Historical plans | `docs/history/plans/` | YYYY-MM-DD-name.md |
100
+ | Change records | `docs/history/changelog/` | Individual entries |
101
+ | Backlog | `docs/history/` | backlog.md |
102
+
103
+ ## Document Lifecycle
104
+
105
+ Plan (Status: Draft) → Implementation → Feature Doc or Architecture Update → Changelog Entry
106
+
107
+ - Plans freeze at completion — never updated to reflect current code
108
+ - Changelogs summarize + link to feature docs — no duplicated schemas
109
+ - Feature docs are the living reference — updated when code changes
110
+
111
+ ## Folder Rules
112
+
113
+ - `docs/features/`: Living reference for implemented features. Each spec includes YAML frontmatter with `owns`, `touches`, `depends_on` fields declaring code ownership.
114
+ - `docs/architecture/`: System-wide patterns and the cross-module steering layer (domain model, glossary, non-goals, references, ADRs). Update when cross-cutting concerns change.
115
+ - `docs/boundaries/`: Horizontal typed application boundaries — one file per cross-module contract. Generated/maintained by the `boundary` skill; read before touching a shape it defines.
116
+ - `docs/modules/{m}/`: Vertical bounded contexts, **declared** (not inferred from layout) and tied to code by their `owns` globs. Each owns `features/` + module-local `pillars/` (doctrine, lazy). There is no repo-wide `docs/pillars/`. Worth declaring at ≥2 genuine bounded contexts; a single-context app stays flat under `docs/features/`.
117
+ - `docs/operations/`: How-to procedures for setup, development, and deployment. Update when workflows change.
118
+ - `docs/history/plans/`: Historical. Must have `Status:` field. Never modify after completion.
119
+ - `docs/history/changelog/`: Historical. Append-only.
120
+ - `docs/history/backlog.md`: Tracked work items. Append new items under appropriate priority.
121
+
122
+ ## Health Log
123
+
124
+ <!-- Updated by maintenance agent -->
125
+ | Date | Review Summary |
126
+ | ---- | -------------- |
127
+ | {today} | Initial baseline — v{harness-version} structure established |
128
+ ```
129
+
130
+ ---
131
+
132
+ ## 3. Feature Ownership Frontmatter
133
+
134
+ Use for: every feature doc in `docs/features/`. Declares which source files this doc is authoritative for.
135
+
136
+ ```yaml
137
+ ---
138
+ owns:
139
+ - src/feature-name/**
140
+ - app/feature-name/**
141
+ touches:
142
+ - src/shared/utils/feature-helper.js
143
+ depends_on:
144
+ - docs/architecture/system-design.md
145
+ anchors:
146
+ - "qmd query: feature-name persistence shape"
147
+ ---
148
+ ```
149
+
150
+ - `owns`: Glob patterns for files this feature doc is the canonical reference for
151
+ - `touches`: Files this feature interacts with but doesn't own
152
+ - `depends_on`: Other docs that must be read for full context
153
+ - `anchors` (optional): A list of qmd queries (or `#docid`s) that re-resolve to the code/facts this doc abstracts as they move; anchors are retrieval context plus a drift tripwire, never a contract — an anchor that returns nothing IS the drift signal, nothing auto-rewrites from an anchor result, and the doc's prose stays the human-owned abstraction. They detect **doc-area drift** (the subject moving or vanishing from the corpus), not a pure code rename — the query also matches the doc's own prose, so a rename that leaves the text unchanged won't shift the result; code-symbol drift is the maintenance named-referent check's job, and anchors complement it rather than replace it. Resolved via `qmd query --format json -c <collection>` against this repo's collections; absent qmd ⇒ anchors are inert (no error). Never required on any doc. The feature and boundary templates ship the exemplar, but `anchors:` may appear on any living doc the maintenance anchor-drift check globs — `docs/features/`, `docs/boundaries/`, `docs/architecture/`, and `docs/operations/` — so the convention and the check stay one mental model.
154
+
155
+ ---
156
+
157
+ ## 4. Scaffold Files (create if missing)
158
+
159
+ These standard files must exist after every baseline. Create them with these scaffolds if the repo doesn't already have them.
160
+
161
+ ### docs/history/CHANGELOG.md
162
+
163
+ ```
164
+ # Changelog
165
+
166
+ All notable changes to {Project Name} will be documented in this file.
167
+
168
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
169
+
170
+ ---
171
+
172
+ ## [Unreleased]
173
+
174
+ {entries added here as work proceeds}
175
+
176
+ ---
177
+
178
+ ## Links
179
+
180
+ - [Setup Guide](../operations/setup.md)
181
+ - [Architecture](../architecture/)
182
+
183
+ ---
184
+
185
+ ## How to Update This Changelog
186
+
187
+ 1. Create a dated change file in `docs/history/changelog/`:
188
+ `docs/history/changelog/YYYY-MM-DD-feature-name.md`
189
+
190
+ 2. Update this CHANGELOG.md with a high-level summary linking to the detail file
191
+
192
+ 3. Follow Keep a Changelog categories:
193
+ - **Added** for new features
194
+ - **Changed** for changes in existing functionality
195
+ - **Deprecated** for soon-to-be removed features
196
+ - **Removed** for now removed features
197
+ - **Fixed** for bug fixes
198
+ - **Security** for security improvements
199
+ ```
200
+
201
+ ### docs/history/backlog.md
202
+
203
+ ```
204
+ # Backlog
205
+
206
+ Tracked work items, technical debt, and planned improvements. Append new items under the appropriate priority.
207
+
208
+ ---
209
+
210
+ ## Format
211
+
212
+ - **[P0]** Description — discovered by [plan-name or agent-name]
213
+
214
+ ---
215
+
216
+ ## P0 — Critical
217
+
218
+ {items here}
219
+
220
+ ## P1 — High
221
+
222
+ {items here}
223
+
224
+ ## P2 — Medium
225
+
226
+ {items here}
227
+
228
+ ## P3 — Low
229
+
230
+ {items here}
231
+ ```
232
+
233
+ ### docs/memory/index.md
234
+
235
+ ```
236
+ ---
237
+ type: cross-session-learnings
238
+ description: Shared knowledge accumulated across agent sessions. All agents should consult and update this file.
239
+ ---
240
+
241
+ # Cross-Session Learnings
242
+
243
+ ## Documentation Baseline
244
+
245
+ - **Baselined:** {today}
246
+ - **Structure:** v{harness-version} (architecture, features, operations, history, memory; + boundaries/, modules/, tests/ when present)
247
+ - **Spec version:** v{harness-version}
248
+ <!-- v{harness-version} resolves to the installed design epoch — read it from `.claude/harness.json` (`epoch`) / `docs/structure.md` frontmatter (`harness-version`); never hardcode a literal version here. -->
249
+
250
+ ## Knowledge Tiers
251
+
252
+ Memory is a gradient — volume falls, signal rises, one hop down each tier. Tiers describe themselves here even before they fill:
253
+
254
+ - **Inbox** (`docs/memory/inbox/`) — per-actor queue of session lessons, written by the `session-reflect` hook at session end and consumed by the distiller on digestion. Transient by design, rarely read directly.
255
+ - **Fact-cards** (`docs/memory/facts/`) — distilled, provenance-linked atomic facts, written by the distiller (`facts` mode) from inbox entries and resurfaced at prompt time by the `prompt-recall` hook.
256
+ - **This index** — the curated read tier: the learnings list below, distilled from the colder tiers and hand-appended.
257
+
258
+ ## Learnings
259
+
260
+ {Agents append learnings here as they discover gotchas, patterns, and architecture notes}
261
+ ```
262
+
263
+ ### docs/memory/main.md
264
+
265
+ ```
266
+ ---
267
+ type: project-memory
268
+ owner: main-agent
269
+ description: Project-wide patterns and conventions confirmed in this codebase. Project facts only — user-centric facts go in ~/.claude/.
270
+ ---
271
+
272
+ # Main Agent — Project Memory
273
+
274
+ Append entries below, oldest at bottom. Format:
275
+
276
+ ## YYYY-MM-DD — {topic}
277
+
278
+ {1-3 line fact, with file paths or references where relevant}
279
+
280
+ ---
281
+
282
+ ## {today} — Baseline
283
+
284
+ Memory file initialized during documentation baseline.
285
+ ```
286
+
287
+ > The per-actor memory **inbox** (`docs/memory/inbox/`) is *not* a baseline scaffold — the `session-reflect` hook creates it mechanically on the first reflected session. See **§12 Memory inbox entry** for its format.
288
+
289
+ ---
290
+
291
+ ## 5. Boundary File (docs/boundaries/{boundary}.md)
292
+
293
+ > **This skill does not generate boundaries.** Typed-boundary generation is owned by the **`boundary`** skill (`generate` mode), which detects the stack + IA and applies its boundary taxonomy (`references/boundary-taxonomy.md`) to emit typed files. The baseline does **not** scaffold `docs/boundaries/` — `/boundary generate` runs right after the baseline ("baseline boundaries"). This section is the generic **boundary-file template** plus the guidance for *recognizing* what deserves a boundary.
294
+
295
+ ### What deserves a boundary
296
+
297
+ A boundary is a **horizontal, cross-module contract** where the failure is silent and crosses module boundaries — the developer in module A has no reason to know module B will break. No import error, no runtime exception — just wrong behavior.
298
+
299
+ Test: "If an agent edits this while working on a single feature, could it silently break something in a different feature?" If yes, it's a boundary.
300
+
301
+ **Include:**
302
+
303
+ - **Shared state shapes** — Redux store slices, persisted state, global context. Any shape that multiple modules read. Document every key, its type, and what reads it. Call out which slices are persisted and how rehydration handles shape changes (e.g., new fields become `undefined` for existing users).
304
+ - **Entity registration checklists** — When adding a new entity/resource type requires touching N files across N modules to avoid silent data loss. List every file and what breaks if skipped.
305
+ - **Cross-entity references by value** — When entity A stores entity B's identifier (slug, name, ID) as a plain value with no referential integrity. Document which fields reference what, and that renaming the target never propagates to the source.
306
+ - **Format contracts** — When two systems produce identifiers in different formats (e.g., server returns `[a-z0-9]+`, client generates `[a-z0-9_]+`). Document both formats, where each is used, and what breaks on mismatch (e.g., lookup by key returns `undefined`, key-splitting logic produces wrong matches).
307
+ - **Cross-module string coupling** — Action types, event names, status enums, or document type strings referenced by raw string literal instead of imported constant. List every file that hard-codes the string and what breaks if the source is renamed.
308
+ - **Pipeline ordering dependencies** — Multi-step pipelines where Step N assumes Step N-1 has already written data to shared state. Document the implicit dependency and what happens if ordering changes (silent quality degradation vs. hard failure vs. hang).
309
+ - **Completion signal contracts** — When modules communicate via return values, status fields, or Redux state transitions. Document the expected shape/type (e.g., `Promise<boolean>`, status enum values) and what happens if the contract changes (e.g., returning `undefined` instead of `true` causes permanent "failed" status).
310
+ - **Host/plugin contracts** — Config objects consumed by a framework/host where some fields are validated and others aren't. Document which fields are unvalidated and what breaks silently if they change.
311
+ - **Persistence shape safety** — How the persistence layer handles schema evolution. Document what happens when you add, remove, or rename a field in persisted state (e.g., no migration → stale data, new fields default to `undefined`).
312
+
313
+ **Exclude:**
314
+
315
+ - Module-internal architecture (well-encapsulated, no cross-module blast radius)
316
+ - Authentication/authorization flows (behind adapters, feature code doesn't touch them)
317
+ - Hook taxonomies and API reference (useful docs, but not boundaries — they don't cause cascading failures)
318
+ - Networking details (WebSocket, HTTP client setup) — unless the event routing has cross-module string coupling
319
+ - Feature folder conventions and code style (conventions, not breakage vectors)
320
+ - Anything where failure produces an import error, a clear runtime exception, or a visible UI error — those are self-diagnosing and don't need a boundary
321
+
322
+ ### How to research a boundary
323
+
324
+ When mapping a boundary (the `boundary` skill's `generate`/`create` job — this guidance is shared), investigate:
325
+
326
+ 1. **Shared state consumers** — For each Redux slice/context, find all files that read from it. Flag any file reading a slice it doesn't own (cross-module dependency).
327
+ 2. **String-coupled actions** — Grep for Redux action type strings referenced as raw strings rather than imported constants. These are invisible breakage points.
328
+ 3. **Entity lifecycle** — For each entity type, trace the full lifecycle: creation → change tracking → save payload → API → server. Identify every file that must be touched to support a new entity type.
329
+ 4. **Identifier format mismatches** — Compare how identifiers are generated (server vs. client) and how they're used as keys. Look for format divergence.
330
+ 5. **Pipeline data dependencies** — For multi-step processes, check what each step reads from shared state and what previous step wrote it. Test: "If I reorder these steps, does it fail loudly or silently?"
331
+ 6. **Persistence rehydration** — Check what reconciler is used, whether transforms exist, and what happens to existing users when a persisted shape changes.
332
+
333
+ ### Generic boundary-file template
334
+
335
+ One file per boundary in `docs/boundaries/`. The `boundary` skill emits typed files using its boundary taxonomy; this is the generic fallback shape.
336
+
337
+ ```markdown
338
+ ---
339
+ anchors: # optional — see §3 frontmatter reference
340
+ - "qmd query: store slice rehydration fallback"
341
+ ---
342
+
343
+ # {Boundary Name}
344
+
345
+ [BOUNDARY: {type} · {severity}] <!-- type from the Application Boundary Scale; severity CRITICAL | HIGH | MED | LOW -->
346
+
347
+ **Bounds:** {module A} ↔ {module B} <!-- which modules sit on each side -->
348
+
349
+ ## Shape
350
+ <!-- `transcribe`: a synthesized contract with no single code home (composed store tree, API envelope, the IA entity model, tenancy) — written inline, canonical here.
351
+ `point`: a self-locating shape (DB schema, route table) — a `file:line` pointer + invariants. Never copy a self-locating shape; it rots on the next change.
352
+ greenfield/pre-code `point` (contract decided, no code yet — e.g. boundary generate after a brainstorm): there's no file:line to point at, so instead (a) record the decided conventions inline here, (b) add a `planned <path>` line naming where the canonical source will land (e.g. `planned packages/api/src/db/schema.ts`), and (c) mark this row `point*` in the README index. Converts to (or gains) a real file:line pointer when the module lands. README index footnote: "* point-mode boundary whose pointer lands at implementation". -->
353
+
354
+ ## Invariants
355
+ <!-- The rules that must hold across the boundary. -->
356
+
357
+ ## Blast radius
358
+ <!-- What breaks, and where, if an invariant is violated. -->
359
+
360
+ ## Safe-change checklist
361
+ <!-- Ordered steps to change this contract without silent breakage. Mark steps that fail silently if skipped. -->
362
+ ```
363
+
364
+ ---
365
+
366
+ ## 6. Feature Documentation (docs/features/{feature}.md)
367
+
368
+ Use for: every feature in `docs/features/`. The same file persists from design (Status: Draft) through implementation to live reference (Status: Active). Sections fill in as the feature matures — no template swap.
369
+
370
+ The four research-derived sections (**Affected Modules**, **Conventions to Follow**, **Current Behavior**, **Ownership Conflicts**) map 1:1 to spec-mode's return shape. The orchestrator drops spec-mode's findings into those slots without restructuring.
371
+
372
+ ```yaml
373
+ ---
374
+ owns:
375
+ - src/feature-name/** # projected at Draft, confirmed at Active
376
+ touches:
377
+ - src/shared/state/feature.js
378
+ depends_on:
379
+ - docs/features/related-feature.md
380
+ anchors: # optional — see §3 frontmatter reference
381
+ - "qmd query: wire envelope invariants"
382
+ ---
383
+ ```
384
+
385
+ ```
386
+ # {Feature Name}
387
+
388
+ **Status:** Draft | Active <!-- Draft: in design or in flight. Active: implemented and maintained. -->
389
+ **Plan:** [history/plans/YYYY-MM-DD-feature-name.md](../history/plans/YYYY-MM-DD-feature-name.md) <!-- added once a plan exists -->
390
+
391
+ ## Goal
392
+
393
+ One sentence. What this feature accomplishes, in user-facing terms.
394
+
395
+ ## Goals & Non-Goals
396
+
397
+ **In scope**
398
+ - Bullet 1
399
+ - Bullet 2
400
+
401
+ **Out of scope**
402
+ - Bullet 1
403
+
404
+ ## Background
405
+
406
+ Why this feature exists. The user need, the business trigger, the constraint that pushed it above the line. One paragraph.
407
+
408
+ (For Product-level work, also include: problem statement, key hypotheses, open questions.)
409
+
410
+ ## Approach
411
+
412
+ High-level shape of the solution. ASCII diagram if it helps. Implementation specifics belong in the plan.
413
+
414
+ ## Affected Modules
415
+
416
+ (From spec-mode research) Files, routes, components, slices this feature involves. Group by module.
417
+
418
+ | Module | Path | Role in this feature |
419
+ |--------|------|----------------------|
420
+
421
+ ## Conventions to Follow
422
+
423
+ (From spec-mode research) Naming patterns, structural patterns, doc-fit heuristics confirmed for the area being touched. Cite the source file(s) where the convention is established.
424
+
425
+ ## Current Behavior
426
+
427
+ (From spec-mode research) How the relevant part of the system works *today*, before this feature lands. Without this baseline the design intent is hard to evaluate.
428
+
429
+ ## Ownership Conflicts
430
+
431
+ (From spec-mode research) Existing feature docs whose `owns` or `touches` overlap with the projected scope. Resolve per row before the plan starts — leave nothing unresolved.
432
+
433
+ | Conflicting doc | Overlapping path(s) | Resolution |
434
+ |-----------------|---------------------|------------|
435
+
436
+ ## Architecture
437
+
438
+ [ASCII diagram. Fill once implementation lands. See style-guide.md for box-drawing patterns.]
439
+
440
+ ## Key Functions
441
+
442
+ ### `functionName(param1, param2)`
443
+ **Goal:** What it accomplishes
444
+ **Input:**
445
+ - `param1` (type) - Description
446
+ - `param2` (type) - Description
447
+ **Output:** Return type and shape
448
+ **Side Effects:** DB writes, API calls, state updates
449
+
450
+ ### `hookName(config)`
451
+ **Goal:** What it provides
452
+ **Returns:** `{ data, loading, error }`
453
+ **Triggers:** On mount, on change, manual
454
+
455
+ ## State
456
+
457
+ **Frontend (at persistence):**
458
+ {
459
+ "data": [],
460
+ "changes": { "added": [], "updated": [], "removed": [] }
461
+ // "cache": {} // UNUSED: Deprecated
462
+ }
463
+
464
+ **Storage:** localStorage `app_state`
465
+
466
+ **Backend:**
467
+ model Resource {
468
+ id String @id
469
+ data Json
470
+ // oldField String? // UNUSED: Legacy
471
+ }
472
+
473
+ **API Shape:**
474
+ { "status": 1, "data": {...} }
475
+
476
+ ## Redux (if applicable)
477
+
478
+ **Slice:** `sliceName`
479
+
480
+ **Actions:**
481
+ - `setData(payload)` - Replace all data
482
+ - `upsertItem(item)` - Add or update single item
483
+
484
+ **Selectors:**
485
+ - `selectAll(state)` → `Array<Item>`
486
+ - `selectById(state, id)` → `Item | undefined`
487
+
488
+ ## Files
489
+
490
+ - `src/path/to/main.js` - Core logic
491
+ - `src/path/to/hooks.js` - React hooks
492
+
493
+ ## Open Questions
494
+
495
+ - Question — who decides, by when
496
+ - (Resolved questions: fold the resolution into Background.)
497
+
498
+ ## Risks
499
+
500
+ - Risk — likelihood / impact / mitigation
501
+ ```
502
+
503
+ ### Section evolution
504
+
505
+ Sections fill in across the feature's lifecycle. No template swap — they accumulate in place.
506
+
507
+ | When | Sections written | Source |
508
+ |------|------------------|--------|
509
+ | Status: Draft (design) | Goal, Goals & Non-Goals, Background, Approach, Open Questions, Risks | User interview |
510
+ | Status: Draft (research) | Affected Modules, Conventions to Follow, Current Behavior, Ownership Conflicts | spec-mode agent |
511
+ | Status: Draft → Active (implementation lands) | Architecture, Key Functions, State, Redux, Files; frontmatter `owns`/`touches` confirmed against real code | Main agent (from actual code) |
512
+
513
+ Resolved Open Questions can be summarized into Background; unresolved ones stay visible.
514
+
515
+ ---
516
+
517
+ ## 7. Changelog
518
+
519
+ Use for: recording code changes with function-level detail.
520
+
521
+ ```
522
+ # YYYY-MM-DD - [Title]
523
+
524
+ ## Summary
525
+
526
+ Brief description of what changed and why.
527
+
528
+ ## Changes
529
+
530
+ ### Added
531
+ - `newFunction(params)` in `path/to/file.js`
532
+ - Purpose: What it does
533
+ - Used by: Where it's called
534
+
535
+ ### Modified
536
+ - `existingFunction()` in `path/to/file.js`
537
+ - Changed: What's different
538
+ - Reason: Why it changed
539
+ - Migration: What callers must do
540
+
541
+ ### Removed
542
+ - `oldFunction()` from `path/to/file.js`
543
+ - Replaced by: `newFunction()`
544
+
545
+ ## Breaking Changes
546
+
547
+ ⚠️ **[Change description]**
548
+ - Old: Previous behavior
549
+ - New: Current behavior
550
+ - Impact: What breaks
551
+ - Migration: How to fix
552
+
553
+ ## Migration Steps
554
+
555
+ - [ ] Step 1
556
+ - [ ] Step 2
557
+
558
+ ## Files Changed
559
+
560
+ - `src/path/file1.js` - Core changes
561
+ - `src/path/file2.js` - Supporting updates
562
+ ```
563
+
564
+ ---
565
+
566
+ ## 8. Plan (docs/history/plans/YYYY-MM-DD-feature-name.md)
567
+
568
+ Use for: every implementation plan. Plans are created here directly with `Status: Draft`, flip to `Status: In Progress` when work starts, and freeze at `Status: Complete` or `Status: Abandoned`. Once frozen, never edit — write a new dated plan if scope changes.
569
+
570
+ The `boundary` skill (`check` mode) parses the **Proposed Changes** sections to check boundary impact. Keep that structure stable — section headings and bullet shape are load-bearing for the parser.
571
+
572
+ ```
573
+ # {Feature Name}
574
+
575
+ **Status:** Draft | In Progress | Complete | Abandoned
576
+ **Spec:** [docs/features/{feature}.md](../../features/{feature}.md)
577
+ **Started:** YYYY-MM-DD
578
+ **Completed:** YYYY-MM-DD <!-- fill when status flips to Complete -->
579
+
580
+ ## Background
581
+
582
+ Why this work is happening *now*. Link to the spec for *what* we're building; this section is the motivation and the trigger. One paragraph.
583
+
584
+ ## Proposed Changes
585
+
586
+ ### New Files
587
+
588
+ - `src/path/new-file.js` — purpose
589
+
590
+ ### Modified Files
591
+
592
+ - `src/path/existing.js` — what changes and why
593
+
594
+ ### New Entities / State
595
+
596
+ - `entities.foo` — new Redux slice / DB table / persisted shape
597
+ - Persisted state addition: `state.bar.baz` (default `null` for existing users on rehydrate)
598
+
599
+ ### API Changes
600
+
601
+ - `POST /api/foo` — new route, request `{...}`, response `{status, data}`
602
+ - `PUT /api/bar` — request shape changes; see Migration
603
+
604
+ ### Cross-Module Contracts Affected
605
+
606
+ - List which boundaries (from `docs/boundaries/`) this plan touches by name
607
+ - "None" is a valid answer and means the `boundary` check will pass cleanly
608
+
609
+ ## Implementation Steps
610
+
611
+ 1. Concrete, ordered, testable
612
+ 2. Each step ends with something verifiable
613
+ 3. ...
614
+
615
+ ## Done Criteria
616
+
617
+ - [ ] Implementation complete and verified
618
+ - [ ] Affected docs updated (use `docs/routing.md` to find them)
619
+ - [ ] Changelog entry created in `docs/history/changelog/`
620
+ - [ ] Plan marked `Status: Complete`, **Completed:** date filled
621
+
622
+ ## Open Questions
623
+
624
+ - Question — who decides, by when
625
+
626
+ ## Risks
627
+
628
+ - Risk — likelihood / impact / mitigation
629
+ ```
630
+
631
+ ---
632
+
633
+ ## 9. Protected Files
634
+
635
+ Use for: documenting critical files that need approval before modification.
636
+
637
+ ```
638
+ # Protected Files
639
+
640
+ Critical files requiring approval before modification.
641
+
642
+ ## File List
643
+
644
+ # Category 1 - Description
645
+ path/to/critical/file1.js
646
+ path/to/critical/file2.js
647
+
648
+ # Category 2 - Description
649
+ path/to/another/file.js
650
+
651
+ ## Risk Summary
652
+
653
+ | Category | Risk if Broken |
654
+ |------------|-----------------|
655
+ | Category 1 | Specific impact |
656
+ | Category 2 | Specific impact |
657
+
658
+ ## Critical Logic
659
+
660
+ ### Category 1: [Name]
661
+
662
+ **Purpose:** What these files do
663
+
664
+ **Key Functions:**
665
+
666
+ | Function | Input | Output | Purpose |
667
+ |------------|-------|--------|----------------|
668
+ | `func1()` | Type | Type | What it does |
669
+ | `func2()` | Type | Type | What it does |
670
+
671
+ **Critical Behavior:**
672
+ - Important point 1
673
+ - Important point 2
674
+ ```
675
+
676
+ ---
677
+
678
+ ## 10. Architecture Decision Record (ADR)
679
+
680
+ Use for: capturing a single, point-in-time architectural decision with its context, alternatives considered, and consequences. Lives in `docs/architecture/adr/`.
681
+
682
+ ### When to write an ADR
683
+
684
+ Write an ADR when **all three** apply:
685
+
686
+ 1. The decision is architectural — affects system shape, contracts, or substrate choice, not internal implementation
687
+ 2. Alternatives were genuinely considered and rejected
688
+ 3. Future maintainers will ask "why did we do it this way?"
689
+
690
+ Don't write an ADR for:
691
+
692
+ - Standing principles or style preferences (those are stances, not decisions — put them in `docs/architecture/`)
693
+ - Routine implementation choices with no rejected alternatives
694
+ - Anything you'd be happy reversing without ceremony
695
+
696
+ ### Lifecycle
697
+
698
+ `Proposed` → `Accepted` → `Deprecated` → `Superseded by ADR-NNN`
699
+
700
+ ADRs are **immutable after acceptance**. If the decision changes, write a new ADR that supersedes it. Update only the old ADR's `status` frontmatter field — never its body.
701
+
702
+ ### Naming
703
+
704
+ `ADR-NNN-short-title.md` — three-digit zero-padded number, kebab-case title. Numbers are assigned sequentially across the project and never reused.
705
+
706
+ ### Structure
707
+
708
+ Three sections are required: **Decision**, **Context**, **Consequences**. Everything else is optional — include only when warranted. Decision-first: readers should see the answer in the first paragraph.
709
+
710
+ ### Template
711
+
712
+ ```markdown
713
+ ---
714
+ title: "ADR-NNN: Short title in sentence case"
715
+ status: Accepted # Proposed | Accepted | Deprecated | Superseded by ADR-NNN
716
+ date: YYYY-MM-DD
717
+ decision-owner: Name
718
+ reviewers: [] # optional
719
+ supersedes: # optional, e.g., ADR-005
720
+ tags: [adr]
721
+ ---
722
+
723
+ # ADR-NNN: Short Title
724
+
725
+ ## Decision
726
+
727
+ [One paragraph, active voice. "We will…" Lead with the answer.]
728
+
729
+ ## Context
730
+
731
+ [The forces in play. What is the problem? Why does it need a decision now? Technical, political, social, and project-local pressures.]
732
+
733
+ ## Consequences
734
+
735
+ **Positive:**
736
+ - [What becomes easier]
737
+
738
+ **Negative:**
739
+ - [What becomes harder, what we accept reluctantly]
740
+
741
+ **Risks:**
742
+ - [Second-order effects you can already see, with mitigations if known]
743
+
744
+ <!-- Optional sections below. Include only when warranted by the decision's weight. -->
745
+
746
+ ## Decision Drivers
747
+
748
+ [Hard non-negotiables vs. strong levers. Include when alternatives exist and the criteria aren't self-evident from Context.]
749
+
750
+ ## Options Considered
751
+
752
+ | Option | Pros | Cons | Outcome |
753
+ |---|---|---|---|
754
+ | **Option A** | … | … | **CHOSEN** |
755
+ | Option B | … | … | Eliminated — [reason] |
756
+
757
+ ## Deep Comparison
758
+
759
+ [Honest framing of the strongest alternative(s). Include when the table doesn't make the reasoning obvious. State the *real* reason each was rejected — not a strawman.]
760
+
761
+ ## Architecture in Detail
762
+
763
+ [Diagrams, code shape, layer responsibilities. Include when the decision implies non-trivial structure that readers need to understand alongside the *why*.]
764
+
765
+ ## Implementation Plan
766
+
767
+ | Phase | Scope | Duration |
768
+ |---|---|---|
769
+ | 1 | … | … |
770
+
771
+ ## Open Questions
772
+
773
+ 1. **[Question]** — *Default*: [stated default until resolved].
774
+
775
+ ## Acknowledgements
776
+
777
+ [Credit reviewers; name what they corrected. Include when reviewers materially shaped the doc.]
778
+
779
+ ## References
780
+
781
+ - [External link or cross-reference]
782
+ ```
783
+
784
+ ### Rules
785
+
786
+ - One decision per ADR. If you find yourself describing two decisions, split into two ADRs.
787
+ - Decision-first. The first paragraph after the heading is the answer; readers should not need to scroll.
788
+ - No section numbering (`§5.1.1`). Use markdown headings only — inserting a section shouldn't renumber everything.
789
+ - Frontmatter `status` is the single source of truth for lifecycle. Don't also write "Status: Accepted" in the body.
790
+ - When superseding, set the old ADR's `status: "Superseded by ADR-NNN"` and the new ADR's `supersedes: ADR-OLD`.
791
+ - The body is frozen at `Accepted`. Corrections to facts that were wrong at the time get a new ADR; typos and formatting fixes are fine.
792
+
793
+ ---
794
+
795
+ ## 11. Project Root README
796
+
797
+ Use for: the human-facing entry point at the repository root (`/README.md`) — what visitors and new contributors land on. Distinct from `docs/README.md` (the agent/doc index — see §1). The two coexist; don't merge them.
798
+
799
+ ### Strategy
800
+
801
+ The root README answers, in order:
802
+
803
+ 1. **What is this?** — one to two sentences, no marketing claims
804
+ 2. **What do I get if I install it?** — capability families
805
+ 3. **What's it built on?** — terse stack list with versions
806
+ 4. **How do I run it?** — the three or four scripts that matter
807
+ 5. **How is it laid out?** — directory tree, one-liner per significant folder
808
+ 6. **How do I extend it?** — numbered contribution checklist
809
+ 7. **What state is it in?** — pre-publish, beta, stable, internal
810
+
811
+ Skip any section that doesn't apply. Don't pad to fill the template.
812
+
813
+ ### Writing rules
814
+
815
+ - **Sentence-case headings.** "Getting started", not "Getting Started".
816
+ - **Concrete over abstract.** Real versions, real paths, real commands. No "leverages cutting-edge…".
817
+ - **The tagline answers "what is this?"** — not "why is it great?". Two sentences max.
818
+ - **Tables for enumeration** (routes, commands, endpoints). **Bullets for families and categories.**
819
+ - **Directory tree as a code block**, not a nested markdown list.
820
+ - **Numbered checklist** for "how to add a thing" — readers should be able to follow it top-to-bottom without re-reading.
821
+ - **Point to `docs/` for depth.** The root README links into deep docs; it doesn't host them.
822
+ - **Detect the package manager from the lockfile** (`pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, otherwise npm) and write commands accordingly. Don't hardcode `npm` if the repo uses pnpm.
823
+
824
+ ### Template
825
+
826
+ ```markdown
827
+ # {package-name}
828
+
829
+ {One- to two-sentence positioning. What it is and what scope it covers. No superlatives, no value claims.}
830
+
831
+ ## What's in the box
832
+
833
+ - **{Family 1}** — {what's in it; a few specific items, comma-listed.}
834
+ - **{Family 2}** — {what's in it.}
835
+ - **{Family 3}** — {what's in it.}
836
+
837
+ The full surface lives in [`{path/to/public-index}`]({path/to/public-index}). ← optional pointer for libraries
838
+
839
+ ## Stack
840
+
841
+ - {Framework} {version} · {Language} {version}
842
+ - {Build tool} {version}
843
+ - {Other load-bearing deps}
844
+
845
+ ## Getting started
846
+
847
+ \`\`\`bash
848
+ {pm} install
849
+ {pm} run dev # what it does (port, URL)
850
+ {pm} run build # what it does
851
+ {pm} run preview # what it does (omit if not applicable)
852
+ \`\`\`
853
+
854
+ {Optional one-liner about first-run behavior — e.g., "Dev server lands on /playground."}
855
+
856
+ ## {Runtime entry point} ← optional; e.g., "The playground", "CLI", "API endpoints"
857
+
858
+ {Brief description of the dev/runtime surface.}
859
+
860
+ | {Thing} | {What it shows / does} |
861
+ | -------------------- | -------------------------- |
862
+ | `{route or command}` | {description} |
863
+
864
+ ## Layout
865
+
866
+ \`\`\`
867
+ src/
868
+ ├── {entry-file} # {purpose}
869
+ ├── {folder}/ # {purpose}
870
+ │ └── ...
871
+ └── {folder}/ # {purpose}
872
+ \`\`\`
873
+
874
+ ## Adding a {primary unit}
875
+
876
+ 1. {Drop the source under the right family/folder.}
877
+ 2. {Re-export from the public surface.}
878
+ 3. {Wire into the playground / example app / test harness so reviewers can see it render.}
879
+ 4. {Document any divergence from upstream in `docs/{...}`.}
880
+
881
+ ## Styling ← optional; replace with whichever cross-cutting concern matters most
882
+
883
+ {Configuration notes that affect every consumer — design tokens, conventions, opt-outs.}
884
+
885
+ ## Status
886
+
887
+ {Pre-publish, beta, stable, internal-only. State what's stable and what's still moving — readers should know whether the API can be relied on.}
888
+
889
+ ## License
890
+
891
+ {License name — scope. e.g., "UNLICENSED — internal use only", "MIT".}
892
+ ```
893
+
894
+ ### Baseline scaffolding behavior
895
+
896
+ The baseline audit **does** scaffold the project root README when missing. The risk this template guards against — template-shaped placeholders that look abandoned — is mitigated by the writing rules above: fill every section with concrete details from the repo (real package manager from the lockfile, real scripts, real layout, real status). Skip sections that genuinely don't apply rather than leaving stubs.
897
+
898
+ **Never overwrite an existing root README** during a baseline. If one is present — even sparse or outdated — leave it untouched. Treat updates to a pre-existing root README as a separate, explicit request.
899
+
900
+ ---
901
+
902
+ ## 12. Memory inbox entry (docs/memory/inbox/{actor}.md)
903
+
904
+ Use for: the capture tier of the knowledge gradient — the durable lessons of each session (corrections, root-caused failures, decisions with rationale, discovered constraints), reflected by the `session-reflect` hook at session end. It is the raw input to distillation: `distiller facts` digests entries into fact-cards and **consumes** them, so the file holds exactly what is undigested.
905
+
906
+ ### File grain
907
+
908
+ One file **per actor**: `docs/memory/inbox/{actor}.md`. `actor` is `git config user.name` lowercased and kebab-slugged; fall back to `$USER`, then `agent`. Two actors write to different files, so the inbox is **append-only without merge conflicts** — no shared file to contend over, no lock, no last-writer-wins.
909
+
910
+ ### File header
911
+
912
+ Written once, on the first entry:
913
+
914
+ ```
915
+ # Memory inbox — {actor}
916
+ Session lessons awaiting distillation — appended by the session-reflect hook, consumed by `distiller facts`.
917
+ ```
918
+
919
+ ### Entry shape
920
+
921
+ One block per reflected session, at most 6 bullets. Each bullet is one complete, self-contained sentence tagged `[project]` (true of the repo or its tooling) or `[user]` (true of the user) — the tag routes it at distillation: project facts → `docs/memory/facts/`, user facts → user-level memory.
922
+
923
+ ```
924
+ ## YYYY-MM-DD HH:MM · session <id> · {repo}@{branch}
925
+ - [project] <one self-contained sentence, names and identifiers spelled out>
926
+ - [user] <one self-contained sentence>
927
+ ```
928
+
929
+ ### Examples
930
+
931
+ ```
932
+ ## 2026-06-08 22:26 · session bc06c4fc · etna@dev
933
+ - [project] The read_network_requests Chrome CDP tool only captures after its first call — arm it, trigger traffic, then read.
934
+ - [user] jane-doe prefers minimal fixes over defensive machinery; fail loudly instead of engineering around a problem.
935
+ ```
936
+
937
+ ### Rules
938
+
939
+ - **Hooks append, the distiller consumes.** A digested entry block is deleted by `distiller facts`; nothing else edits or reorders the file. A human may hand-append a lesson in the same shape — it rides the same queue.
940
+ - **Sessions are deduped by id.** The reflect hook skips a session whose id already appears in the file (SessionEnd re-fires on resume).
941
+ - **Secrets are redacted on write.** The privacy filter replaces secret shapes with `[redacted:{kind}]` (e.g. `[redacted:api-key]`, `[redacted:bearer]`, `[redacted:pem]`) before any line is appended — never paste a raw token in by hand either.
942
+ - **Don't curate here.** Promotion to fact-cards and `docs/memory/main.md` happens at distillation; the inbox stays a transient queue.