@nurix/etna 0.20.29 → 0.20.31

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 (75) hide show
  1. package/data/harness-index.json +1 -1
  2. package/data/harnesses/code/CLAUDE.md +4 -4
  3. package/data/harnesses/code/agents/bookkeeper.md +2 -2
  4. package/data/harnesses/code/agents/change-review.md +3 -3
  5. package/data/harnesses/code/agents/lld-mode.md +3 -3
  6. package/data/harnesses/code/agents/maintenance.md +22 -19
  7. package/data/harnesses/code/agents/polygraph-finder.md +3 -3
  8. package/data/harnesses/code/agents/polygraph.md +4 -4
  9. package/data/harnesses/code/agents/retro.md +1 -1
  10. package/data/harnesses/code/codex/agents/bookkeeper.toml +7 -3
  11. package/data/harnesses/code/codex/agents/change-review.toml +3 -3
  12. package/data/harnesses/code/codex/agents/lld-mode.toml +3 -3
  13. package/data/harnesses/code/codex/agents/maintenance.toml +60 -37
  14. package/data/harnesses/code/codex/agents/polygraph-finder.toml +6 -2
  15. package/data/harnesses/code/codex/agents/polygraph.toml +4 -4
  16. package/data/harnesses/code/codex/agents/retro.toml +1 -1
  17. package/data/harnesses/code/docs/structure.md +15 -15
  18. package/data/harnesses/code/harness.json +2 -2
  19. package/data/harnesses/code/hooks/lib/ownership.mjs +12 -13
  20. package/data/harnesses/code/hooks/lib/sweep.mjs +1 -1
  21. package/data/harnesses/code/hooks/mount.mjs +17 -3
  22. package/data/harnesses/code/skills/documentation/SKILL.md +17 -27
  23. package/data/harnesses/code/skills/documentation/references/frontmatter.md +56 -62
  24. package/data/harnesses/code/skills/documentation/references/style-guide.md +2 -2
  25. package/data/harnesses/code/skills/documentation/scripts/doc-lint.mjs +1 -1
  26. package/data/harnesses/code/skills/documentation/templates/Readme.md +1 -1
  27. package/data/harnesses/code/skills/documentation/templates/docs-readme.md +1 -1
  28. package/data/harnesses/code/skills/documentation/templates/doctrine.md +2 -2
  29. package/data/harnesses/code/skills/documentation/templates/feature.md +3 -4
  30. package/data/harnesses/code/skills/documentation/templates/package.md +2 -3
  31. package/data/harnesses/code/skills/documentation/templates/root-readme.md +1 -1
  32. package/data/harnesses/code/skills/documentation/templates/system.md +2 -4
  33. package/data/harnesses/code/skills/documentation/templates/ux-behavior.md +4 -4
  34. package/data/harnesses/delivery/agents/lld-mode.md +3 -3
  35. package/data/harnesses/delivery/agents/maintenance.md +22 -19
  36. package/data/harnesses/delivery/agents/retro.md +1 -1
  37. package/data/harnesses/delivery/codex/agents/lld-mode.toml +3 -3
  38. package/data/harnesses/delivery/codex/agents/maintenance.toml +60 -37
  39. package/data/harnesses/delivery/codex/agents/retro.toml +1 -1
  40. package/data/harnesses/delivery/harness.json +2 -2
  41. package/data/harnesses/delivery/skills/documentation/SKILL.md +17 -27
  42. package/data/harnesses/delivery/skills/documentation/references/frontmatter.md +56 -62
  43. package/data/harnesses/delivery/skills/documentation/references/style-guide.md +2 -2
  44. package/data/harnesses/delivery/skills/documentation/scripts/doc-lint.mjs +1 -1
  45. package/data/harnesses/delivery/skills/documentation/templates/Readme.md +1 -1
  46. package/data/harnesses/delivery/skills/documentation/templates/docs-readme.md +1 -1
  47. package/data/harnesses/delivery/skills/documentation/templates/doctrine.md +2 -2
  48. package/data/harnesses/delivery/skills/documentation/templates/feature.md +3 -4
  49. package/data/harnesses/delivery/skills/documentation/templates/package.md +2 -3
  50. package/data/harnesses/delivery/skills/documentation/templates/root-readme.md +1 -1
  51. package/data/harnesses/delivery/skills/documentation/templates/system.md +2 -4
  52. package/data/harnesses/delivery/skills/documentation/templates/ux-behavior.md +4 -4
  53. package/data/harnesses/etna/agents/change-review.md +3 -3
  54. package/data/harnesses/etna/agents/lld-mode.md +3 -3
  55. package/data/harnesses/etna/agents/maintenance.md +22 -19
  56. package/data/harnesses/etna/agents/retro.md +1 -1
  57. package/data/harnesses/etna/codex/agents/change-review.toml +3 -3
  58. package/data/harnesses/etna/codex/agents/lld-mode.toml +3 -3
  59. package/data/harnesses/etna/codex/agents/maintenance.toml +60 -37
  60. package/data/harnesses/etna/codex/agents/retro.toml +1 -1
  61. package/data/harnesses/etna/harness.json +2 -2
  62. package/data/harnesses/etna/skills/documentation/SKILL.md +17 -27
  63. package/data/harnesses/etna/skills/documentation/references/frontmatter.md +56 -62
  64. package/data/harnesses/etna/skills/documentation/references/style-guide.md +2 -2
  65. package/data/harnesses/etna/skills/documentation/scripts/doc-lint.mjs +1 -1
  66. package/data/harnesses/etna/skills/documentation/templates/Readme.md +1 -1
  67. package/data/harnesses/etna/skills/documentation/templates/docs-readme.md +1 -1
  68. package/data/harnesses/etna/skills/documentation/templates/doctrine.md +2 -2
  69. package/data/harnesses/etna/skills/documentation/templates/feature.md +3 -4
  70. package/data/harnesses/etna/skills/documentation/templates/package.md +2 -3
  71. package/data/harnesses/etna/skills/documentation/templates/root-readme.md +1 -1
  72. package/data/harnesses/etna/skills/documentation/templates/system.md +2 -4
  73. package/data/harnesses/etna/skills/documentation/templates/ux-behavior.md +4 -4
  74. package/lib/install/mount.mjs +17 -3
  75. package/package.json +2 -2
@@ -1,90 +1,84 @@
1
- # Frontmatter Derivation — the doc graph
1
+ # Frontmatter — documents in the knowledge graph
2
2
 
3
- Load when: creating a doc that declares an edge (a feature, package or system doc, a UX doc, a behavioral checklist), updating one whose scope moved, or running a baseline/reconcile pass over many docs.
3
+ Load when: creating a document that carries frontmatter, updating one whose subject moved, or running a baseline or reconcile pass over many documents.
4
4
 
5
- **A docs tree is a graph, and every edge in it is declared in frontmatter.** Two kinds of edge exist: **doc → code** (`owns:`), and **doc → doc** (`verifies:`, `applies:`). The SessionStart hook reads them all and injects the generated indexes; there is no hand-maintained map of either kind.
5
+ This reference states how a document joins the knowledge graph, and it is kept in step with the machine that reads it: the knowledge layer (`docs/architecture/systems/knowledge-layer.md` in a repository that carries it; § Documents and code). Where this reference and that design disagree, the design is the authority and this file is the defect.
6
6
 
7
- ## The one rule that keeps the graph honest
7
+ ## The model
8
8
 
9
- **An edge is declared once, at the consuming end. Every inverse is generated, never authored.**
9
+ A document names the product objects it designs. Every other edge between a document and the code is either authored on the code's side or computed, never typed into the document.
10
10
 
11
- A parent that hand-lists its children is a second thing to forget, and the moment the two directions can disagree nothing says which is right — you have doubled the staleness surface rather than halving it. So a checklist names the feature it verifies; the feature never lists its checklists. A feature names the architecture doc it obeys; the architecture doc never lists its consumers. Both inverses are derived on demand and injected, exactly as the ownership index already is.
11
+ ### Principles
12
12
 
13
- The consuming end is also the end that **knows**. A checklist author knows what they are verifying; an architecture doc has no idea who will obey it next year.
13
+ 1. **Objects as the document's edge:** a document's frontmatter carries `objects:`, the product objects it designs, by their register names. That is its one edge into the graph and its discovery terms.
14
+ 2. **The header pointer as the code's edge:** a source file's path header names the document that holds its fuller account (the root instruction file's § File Structure). The pointer is authored on the code's side, a move carries it, and a new file without one is a lint.
15
+ 3. **Computed ownership:** the object closure (document → objects → tables → their write, read and refusal sites → files) reaches files nobody listed. Where the header pointer and the closure disagree, the graph prints both. Which document speaks for a path is a query, answered per path on demand.
16
+ 4. **Nothing recomputable stored:** a list of files, a list of consumers, or a list of governing documents typed into frontmatter is a copy of something the graph computes. It is stale the day the code moves, and it fails the stability test (`style-guide.md` § Shape — the model first, the detail after).
17
+ 5. **One declaration, at the consuming end:** the edges a person must author (`objects:`, `verifies:`) are declared once, by the document that knows. Every inverse is generated, never authored.
14
18
 
15
- ## When to run
19
+ ## Keys by genre
16
20
 
17
- - **Baseline / reconcile** — for every owning doc whose code paths aren't yet declared in its `owns:` frontmatter (the `maintenance` agent (baseline mode) calls this)
18
- - **New owning doc** — when creating one via the [Feature](../templates/feature.md), [Package](../templates/package.md) or [System](../templates/system.md) template, project its `owns:` globs
19
- - **Doc update** — when the documented scope changes, update the doc's `owns:` globs
21
+ | Genre | Keys |
22
+ | --- | --- |
23
+ | Feature | `type`, `status`, `objects`, `module` (optional) · transitional `owns` |
24
+ | System | `type`, `status`, `objects` · transitional `owns` |
25
+ | Package | `type`, `status`, `objects` · transitional `owns` |
26
+ | Doctrine | `type`, `status`, `objects` |
27
+ | UX | `type`, `status`, `objects` · transitional `owns` when it speaks for a surface's components |
28
+ | Behavioral checklist | `type: checklist`, `verifies` |
29
+ | Acceptance criteria | `type`, `status` |
30
+ | Every other genre | `type`, plus its template's own keys |
20
31
 
21
- ## Which genres own code
32
+ Tooling keys sit beside these on any genre: `rev:` (a generator's generation stamp), `slug:` (the identity key on generated documents, minted once, and in the repository the filename), and `last-reviewed:` (stamped on a substantive review, the `maintenance` agent's staleness signal). Sessions preserve them on edits and never narrate or inject them. The `maintenance` agent stamps `type:` where it is missing.
22
33
 
23
- **Three do, and no others: `feature`, `package`, `system`.** They layer by glob specificity over the same tree, which is what lets a repo be documented at three altitudes without subtracting anything by hand:
34
+ ## Keys
24
35
 
25
- | Genre | Claims | Wins because |
26
- | --- | --- | --- |
27
- | `package` (`docs/architecture/packages/`) | `packages/{name}/**` — the whole tree, one glob | Nothing; it is the **residual** owner and loses every narrower claim, keeping what no one else takes |
28
- | `system` (`docs/architecture/systems/`) | the subtrees and exact files one machine is made of | Its globs are narrower than the package glob — specificity |
29
- | `feature` (`docs/features/`) | one capability's or one surface's globs | Same — specificity over the package glob |
30
-
31
- Every other genre owns no code and carries no `owns:`. That includes the cross-cutting doctrine in `docs/architecture/` (and `docs/architecture/common/`), which describes patterns rather than regions — a surface declares it is bound by one through `applies:`, and the doctrine never claims the surface back. Checklists, acceptance docs, ADs, operations procedures, research and brainstorm records own nothing.
32
-
33
- ## How to derive the frontmatter
34
-
35
- An owning doc's frontmatter is `objects:` (required — the product objects it designs, by their graph names; its discovery terms and its traced edge into the knowledge graph), `owns:` (required until the graph computes ownership from traces), `module:` (optional — feature docs only; a package is already a bounded unit and a system spans contexts by definition), and `status:` (required). An optional `last-reviewed:` date (stamped whenever the doc is substantively reviewed or updated) gives the `maintenance` agent a staleness signal to rank its audits by — it is tooling metadata, never narrated in the body. `type:` (required — the genre, enum = the template names) and `rev:` (generator-written generation stamp) are the same class: external tooling reads them, sessions **preserve them on edits** and never narrate or inject them. The `maintenance` agent stamps `type:` on docs that predate the key. `slug:` completes the set on generated docs: the identity key, minted once at creation and never re-derived from a display name — in the repo the filename is the slug, and the `maintenance` agent re-aligns the two when they diverge.
36
-
37
- **1. `owns:`** (the path scope)
36
+ ### `objects:`
38
37
 
39
- `owns:` names the **regions whose truth this doc holds** — the directories where a change must be reconciled against this document before it ships. It is an authority claim a human makes, not an inventory of what the feature touches.
38
+ - **Values:** the product objects the document designs, by the names the object register uses (`docs/dna/objects/<group>.yaml`, the product-dna skill's). Where a repository has no register yet, the names its product model and its documents already use.
39
+ - **Meaning:** designs, not mentions. A feature that reads a session designs no session; the document that decides what a session is does.
40
+ - **Discovery:** there is no `keywords:` key. An object's name and its register aliases are its discovery terms.
41
+ - **Doctrine:** a doctrine document names the cross-cutting objects it governs (principal, credential, session). The surfaces bound by it are the documents that design or touch the same objects, which the closure computes.
40
42
 
41
- **A file the doc merely references is not a file the doc owns.** Reaching across a boundary into a shared module is a fact about the code, and it belongs to whoever owns that module's region. Transcribing those reach edges as `owns:` entries is how an index stops being a routing table and becomes a hand-maintained import graph: rows then track the dependency graph rather than the feature count, and the shared upstream file ends up filed under whichever downstream feature happened to name it first — a consumer recorded as the authority.
43
+ ### `status:`
42
44
 
43
- Prefer one region glob over many file globs. Ten paths say nothing about which is the entry point; one region says where the doc's writ runs.
45
+ - **Values:** `active`, `draft` or `deprecated`. It steers a reader toward live documents.
44
46
 
45
- | The doc governs | Glob |
46
- | -------------------------------------------- | ------------------------------------ |
47
- | A feature's own directory | `src/feature/**` |
48
- | A feature split across two directories | One glob each |
49
- | A single entry-point file, and nothing beside it | The exact file path |
50
- | A whole workspace package, residually | `packages/{name}/**` — one glob, on the package doc |
51
- | A machine spanning packages | One glob or exact path per subtree it is made of, on the system doc |
52
- | A shared file several features import | **Nothing — leave it unowned** |
47
+ ### `module:`
53
48
 
54
- **An unowned shared file is the system working, not a gap.** A shared module's authority is the contract it exposes, not any one consumer, so a library-references file or a common utility legitimately has no owning doc. Claiming it would make the index bigger and the routing less certain at once.
49
+ - **Values:** one bounded-context label on a feature document, or omitted for a cross-cutting feature. A label, not a folder. Package and system documents omit it.
55
50
 
56
- Glob each pattern against the codebase. At `status: active`, drop any that match nothing; at `status: draft`, projected globs may match nothing yet — confirm them against real code when the doc flips to `active`.
51
+ ### `verifies:`
57
52
 
58
- **2. `module:`** (feature docs only)
53
+ - **Values:** on a behavioral checklist, the repo-relative path of the feature or UX document whose promises it proves. One is the norm.
54
+ - **Authorship:** a checklist knows what it proves, and nothing in the code says so. A checklist with no `verifies:` is an orphan: nothing implicates it when its subject changes.
59
55
 
60
- The single bounded-context label this feature belongs to, or omit it for a cross-cutting feature that belongs to no single context. A module is a label, not a folder — features sharing a `module:` value are what ties that module to code (a filter over the generated ownership index). Package and system docs omit it entirely.
56
+ ### `owns:` — transitional
61
57
 
62
- **3. `objects:` & `status:`**
58
+ - **Reason for the key:** the harness's ownership scan (`.claude/hooks/lib/ownership.mjs`) keys on `owns:` until it switches to the header pointers and the object closure, which is the knowledge layer's recorded gap. Until then the key keeps the session's ownership index and the doc-debt detectors working.
59
+ - **Form:** region globs only, one per region the document speaks for: `packages/{name}/**` on a package document, the machine's subtrees on a system document, a feature's own directory on a feature document. Never a list of individual files, and never a shared file several features import.
60
+ - **Growth:** none. A new document carries the region glob its genre needs and nothing more; an edit never adds file-level entries.
61
+ - **Retirement:** removed from every document in the same change that switches the scan, and this section with it.
63
62
 
64
- `objects:` names the product objects the document designs — the discovery terms topic→doc lookup rides, and the edge the knowledge graph renders each object's documents from. There is no `keywords:` key: an object's name is its discovery term. `status:` is `active`, `draft`, or `deprecated` — it steers the model toward live docs and away from draft/deprecated ones.
63
+ ## Retired keys
65
64
 
66
- ## The doc → doc edges
67
-
68
- A prose link is not an edge. It states that one doc mentions another; it never states **why**, so nothing can be derived from it — not who consumes a doctrine, not what to re-read before an edit, not what falls stale when a surface moves. A tree can carry hundreds of prose links and still have no graph. These two keys carry the relationships that matter; everything else stays prose.
69
-
70
- **`verifies:`** — on a behavioral checklist (`docs/tests/{feature}.md`), the feature or UX doc(s) whose promises it proves. One value is the norm; several when a checklist spans a capability that two docs decide. A checklist carrying no `verifies:` is an orphan by construction: nothing implicates it when its subject changes, so it rots silently and the rot is undetectable.
71
-
72
- **`applies:`** — on a feature or UX doc, the architecture docs it obeys. Not "docs I read" and not "docs I mention" — **obligation**: a doctrine this surface is bound by, such that a change to the doctrine implicates this doc. The narrow reading is the load-bearing one; a key that collects everything consulted degrades into a bibliography and stops meaning anything. A feature bound by nothing cross-cutting omits the key.
73
-
74
- Cross-cutting *contracts* remain diagnosed by the `boundary` skill from source, never persisted — `applies:` records which doctrine a surface answers to, not which code it touches.
65
+ | Key | Retired because | What replaces it |
66
+ | --- | --- | --- |
67
+ | `applies:` | A list of governing documents is a hand-kept copy of a relationship the graph computes through the objects both documents name, and it drifts the way any copy does | The objects the doctrine and the surface share, computed; for people, the document's Scope section names its governing doctrine and what each settles |
68
+ | `keywords:` | An object's name and aliases are its discovery terms | `objects:` |
69
+ | A file-level `owns:` list | The header pointers and the object closure compute it | Region globs only, until the scan switches (above) |
75
70
 
76
- ## What is not frontmatter, deliberately
71
+ An edit to a document that carries a retired key removes the key in the same edit.
77
72
 
78
- **`Pinned:` stays a section-level line inside a checklist**, naming the suite tests that guard that section. It is already typed and already resolved mechanically by the `maintenance` agent. Hoisting it into frontmatter would flatten per-section detail into a doc-level list and duplicate what the sections already say — the exact double-declaration the one rule above forbids.
73
+ ## Not frontmatter, deliberately
79
74
 
80
- That edge has a property the others lack, and it is worth naming: **a `Pinned:` reference terminates.** A test file exists or it does not, so the edge is falsifiable by a resolver sweep with no judgement. An `owns:` glob is only falsifiable at the dangling end — a glob that resolves says nothing about whether the doc still describes what the code does. Terminal edges get resolver sweeps; non-terminal edges need a human or an agent to read both ends. Do not build a checker that pretends otherwise.
75
+ - **`Pinned:`** stays a section-level line inside a checklist, naming the suite tests that guard that section. It is typed and resolved mechanically; hoisting it would flatten per-section detail into a document-level list.
76
+ - **Terminal and non-terminal edges:** a `Pinned:` reference terminates (a test file exists or it does not), so a resolver sweep checks it with no judgment. An `objects:` value is checked against the register by the graph's index-time lints. Whether a document still describes what its objects do needs a person or an agent to read both ends; no checker pretends otherwise.
81
77
 
82
78
  ## Rules
83
79
 
84
- - One canonical doc per path. A doc's `owns:` globs must not overlap another doc's at equal specificity — the narrower glob wins; equal-specificity overlap is an ownership conflict to resolve. Overlap at **unequal** specificity is the layering working as designed: a package doc's `packages/{name}/**` is meant to be outranked, and what survives every narrower claim is exactly what that doc describes.
85
- - Use glob patterns for directories, explicit paths for individual files. At `active`, never list paths that don't exist in the codebase; a `draft`'s projected paths are confirmed at `active`.
86
- - When a doc covers a deep feature with sub-specs (e.g., `editor/`), each sub-spec owns its own globs — don't duplicate a path across siblings.
87
- - For baseline/reconcile with many docs, use parallel sub-agents to read source and propose `owns:` globs.
88
- - **Never author an inverse.** No doc lists its verifiers, its consumers, or its dependents — those are generated. A hand-written "consumed by" table is a defect to delete, not a convention to follow.
89
- - **Every edge value is a repo-relative doc path** (`docs/architecture/common/security.md`), never a bare filename and never a display title — the resolver is a path lookup, and a title changes without the file moving.
90
- - **A dangling edge is a block, not a warning.** `verifies:` or `applies:` naming a doc that does not exist is a typo or a deletion; either way the graph is lying. Resolve at authoring time.
80
+ - **Inverses never authored:** no document lists its verifiers, its consumers, its governing doctrine's other surfaces, or the files that point at it. A hand-written "consumed by" table is a defect to delete.
81
+ - **Edge values:** `verifies:` values are repo-relative document paths, never a bare filename or a display title.
82
+ - **Dangling edges block:** a `verifies:` naming a document that does not exist, or an `objects:` value no register or product model knows, is a typo or a deletion. Resolve it at authoring time.
83
+ - **Index-time lints the graph prints:** a header pointing at a document that does not exist, a document no file points at, an object no document designs. They never fail a refresh; a session that sees one resolves it or files it.
84
+ - **Baseline and reconcile:** the `maintenance` agent stamps `type:` and `objects:`, reduces any file-level `owns:` list to its region globs, removes retired keys, and reports source files whose header names no document. Many documents ⇒ parallel sub-agents, one document each.
@@ -34,8 +34,8 @@ Every genre takes the same shape (principle 2) and the same labels (principle 5)
34
34
  | Operations procedure, migration runbook | Truth, record | The exact commands, in order, with their expected output | Nothing. The detail is the point |
35
35
  | Record (plan, changelog entry, journal, memory) | Record | Its template's fields, as of the moment it describes | Nothing. Its prose follows § Voice and § Labels; the dates and the journey are its own |
36
36
 
37
- - **Owning documents:** feature, package and system are the three genres that carry `owns:`. They take principles 5 and 6 in full, their sections are fixed (§ Owning documents — the body and the footer), and `doc-lint` reads them.
38
- - **Doctrine:** the same shape and labels as an owning document, with no `owns:` and no mechanism. Its model layer may argue in paragraphs; below the model it is bullets like every other explaining document.
37
+ - **Owning documents:** feature, package and system are the three genres that speak for code: source files name them in their headers, and the ownership scan resolves paths to them (`frontmatter.md`). They take principles 5 and 6 in full, their sections are fixed (§ Owning documents — the body and the footer), and `doc-lint` reads them.
38
+ - **Doctrine:** the same shape and labels as an owning document, speaking for no code and describing no mechanism. Its model layer may argue in paragraphs; below the model it is bullets like every other explaining document.
39
39
  - **Reference documents and procedures:** the one place a signature, a shape, a variable table, a command list or a file path is the content. They keep the detail the owning genres hand to the graph (§ Reference documents).
40
40
  - **Indexes:** a folder's `Readme.md` describes directories, never files; the root README follows `templates/root-readme.md`. Both take § Labels.
41
41
 
@@ -159,7 +159,7 @@ function lintFile(path, findings) {
159
159
  }
160
160
  if (scope === 'truth' && !isFolderIndex && /(^|\/)docs\/features\/[^/]+\.md$/.test(path)) {
161
161
  const fm = text.startsWith('---') ? text.slice(0, text.indexOf('\n---', 3)) : '';
162
- for (const key of ['owns:', 'status:', 'type:'])
162
+ for (const key of ['objects:', 'status:', 'type:'])
163
163
  if (!fm.includes(key)) findings.push({ path, n: 1, severity: 'block', id: 'feature-frontmatter', message: `feature doc missing \`${key}\` frontmatter` });
164
164
  }
165
165
 
@@ -38,4 +38,4 @@ One file per template. Every template is either a **truth document** (states cur
38
38
 
39
39
  **Baseline scaffolds** — files that must exist after every baseline (`docs/structure.md` is not among them: it is harness-owned, shipped whole by the installer and overwritten on every refresh, and has no template); the `maintenance` agent (baseline mode) creates any that are missing: [docs-readme.md](docs-readme.md), [changelog-index.md](changelog-index.md), [backlog.md](backlog.md), [memory-main.md](memory-main.md), [setup.md](setup.md) (when the repo has a lockfile and a runnable root script; never overwriting an existing first-run procedure), and [root-readme.md](root-readme.md) (never overwriting an existing root README).
40
40
 
41
- **Ownership.** Three genres carry code — **feature**, **package**, **system** — and each is the canonical reference for the code paths in its **`owns:` frontmatter**, the only ownership key. To find what a doc owns, read its `owns:` globs; to find the doc for a path, match the path against the injected ownership index (the union of every owning doc's globs), narrower glob wins. That is what layers them: a package doc claims `packages/{name}/**` and is the tree's **residual** owner, while a system doc claims the narrower subtrees of one machine and a feature doc claims one surface — both win those paths by specificity, and the package doc keeps everything neither claims. Two docs may never claim a path at **equal** specificity. Every other genre here owns no code, including the cross-cutting doctrine in `docs/architecture/common/`. See [`../references/frontmatter.md`](../references/frontmatter.md) for turning code into `owns:` globs.
41
+ **Ownership.** Three genres speak for code — **feature**, **package**, **system**. A document names the objects it designs in `objects:`; a source file names the document that speaks for it in its path header; which document speaks for a path is computed from those headers and the object closure, and answered per path by the ownership index (`references/frontmatter.md`). Until the harness's ownership scan switches to that computation, it reads a transitional `owns:` region glob on each of the three genres: `packages/{name}/**` on a package document (the residual owner), a machine's subtrees on a system document, a feature's own directory on a feature document; the narrower glob wins.
@@ -21,7 +21,7 @@ The design layer — [architecture/](architecture/): {what the folder holds —
21
21
 
22
22
  ## Features
23
23
 
24
- [features/](features/) — one living reference per feature (how it works today), flat, named `{feature}.md`; each carries `owns:` for the code it speaks for. Find a feature by its name or by the ownership index, never by a row here.
24
+ [features/](features/) — one living reference per feature (how it works today), flat, named `{feature}.md`; each names the objects it designs in `objects:`, and the source files it speaks for name it in their headers. Find a feature by its name or by the ownership index, never by a row here.
25
25
 
26
26
  ## Tests
27
27
 
@@ -1,6 +1,6 @@
1
1
  # Doctrine Documentation (docs/architecture/common/{concern}.md)
2
2
 
3
- Truth document. Use for **one concern the platform handles everywhere**: authentication, authorization, storage, the API protocol, credentials, telemetry. One file per concern, named for the concern. A doctrine document owns no code and carries no `owns:`. A surface declares that it is bound by one through its own `applies:`.
3
+ Truth document. Use for **one concern the platform handles everywhere**: authentication, authorization, storage, the API protocol, credentials, telemetry. One file per concern, named for the concern. A doctrine document speaks for no code: no source header names it, and it carries no `owns:`. The surfaces bound by it are the documents that design or touch the objects it governs, computed through those objects, and each names it in its Scope.
4
4
 
5
5
  **A doctrine document states the design and nothing beneath it** (`references/style-guide.md` § Shape — the model first, the detail after). It is the most stable document in the tree, because it says why the platform is shaped the way it is, and that changes far less often than the code. It explains no mechanism: no function, file, column, cookie attribute, header value or per-route error code, since each of those fails the stability test. The code graph answers what the code does. This document answers why, and which principles any new code in the concern must keep.
6
6
 
@@ -77,5 +77,5 @@ Code cannot reveal what it does not yet do, so decided-but-unbuilt intent is one
77
77
  | --- | --- |
78
78
  | A tour of the code that implements the concern | The code graph |
79
79
  | The catalog of routes, error codes or variables | An API reference or environment registry |
80
- | The one feature that happens to use the concern most | That feature's own document, which `applies:` this one |
80
+ | The one feature that happens to use the concern most | That feature's own document, which names this doctrine in its Scope |
81
81
  | The story of how the concern got this way | A decision record (`decisions/`) for the why, and the changelog for the when |
@@ -8,7 +8,7 @@ Truth document. Use for every feature in `docs/features/`: something a person po
8
8
  - **Each bullet is a bold label, then one or two third-person sentences** saying what happens: "**Organization user:** user lands in their existing organization", never "you land…".
9
9
  - **Flows carry the journey; Decisions carry the reasons; Promises run deepest.**
10
10
 
11
- Every computable fact (columns, vocabularies, foreign keys, writers, routes, guards, files) is the code graph's (`docs/architecture/systems/knowledge-layer.md`), and a hand-typed copy is the defect this genre removes. Code is named only where a person types or sees it (a page, a command, a flag, an environment variable) or at a cross-cutting seam the graph would not lead a reader to.
11
+ The frontmatter names the objects the feature designs; which files it speaks for is computed from the source headers and the object closure, never listed (`references/frontmatter.md`). Every computable fact (columns, vocabularies, foreign keys, writers, routes, guards, files) is the code graph's (`docs/architecture/systems/knowledge-layer.md`), and a hand-typed copy is the defect this genre removes. Code is named only where a person types or sees it (a page, a command, a flag, an environment variable) or at a cross-cutting seam the graph would not lead a reader to.
12
12
 
13
13
  **A feature document runs deepest toward its end.** Scope and Flows are the model and the journey. **Promises** goes as deep as the behaviour does: every state the surface can be in, every edge case, what a refusal tells the person, and the exact wording wherever the wording itself is promised. That depth is earned because a person or a test checks it and the code cannot state it as intent. It still stops before mechanism. A promise reads "a removed membership shows a panel, not a redirect", never which route answers it.
14
14
 
@@ -32,9 +32,8 @@ Nothing else. `doc-lint` blocks the retired mechanism sections (`mechanism-secti
32
32
  type: feature # required tooling key — preserve, never narrate
33
33
  status: active # required — active | draft | deprecated
34
34
  objects: [device, credential grant] # required — the product objects this document designs, by their graph names
35
- owns: ["packages/studio/src/server/routes/devices.ts"] # required until the graph computes ownership — the code this document speaks for; narrower glob wins
36
35
  module: identity # optional — one bounded-context label
37
- applies: [docs/architecture/common/security.md] # optional — doctrine this surface is BOUND by
36
+ owns: ["packages/studio/src/server/devices/**"] # transitional — one region glob, read only by the ownership scan until it switches to header pointers (references/frontmatter.md)
38
37
  ---
39
38
  ```
40
39
 
@@ -90,6 +89,6 @@ No tables, routes or symbol rosters — those are the graph's.
90
89
  | When | What is written |
91
90
  | --- | --- |
92
91
  | `status: draft` (design) | goal, Scope, Decisions, Promises (with gaps named), For the agent; the LLD research goes to the plan |
93
- | `status: active` | Flows written from the shipped surface; `owns:` confirmed against real code |
92
+ | `status: active` | Flows written from the shipped surface; `objects:` confirmed against the register, and each owned source file's header names this document |
94
93
 
95
94
  A feature whose code is gone is deleted, or `status: deprecated` with its footer pointing at what replaced it.
@@ -6,7 +6,7 @@ Truth document. Use for: **one workspace package** — one unit of distribution:
6
6
 
7
7
  **A package document's deepest layer is its public contract** (`references/style-guide.md` § Shape — the model first, the detail after): the commands and flags a person types, the exports another package imports, what is installed and where. For a CLI the flags *are* the promise, so they belong in Usage. It stops before internal layout, build steps and which file holds what.
8
8
 
9
- **A package document is the residual owner of its own tree.** Its `owns:` is the whole package glob — the broadest claim on those paths, so it loses to every narrower system or feature claim. The one enumerable fact it declares is the ownership table: which subtrees other documents claim.
9
+ **A package document is the residual owner of its own tree.** Every file in the package whose header names no narrower document is its to speak for, so it loses to every system or feature document a header names. Until the ownership scan switches to header pointers, its transitional `owns:` is the whole package glob. The one enumerable fact it declares is the ownership table: which subtrees other documents speak for.
10
10
 
11
11
  **Sharp, bulleted, labelled with noun phrases** (`references/style-guide.md` § Labels). Every section after the goal line is bullets under a noun-phrase heading, each bullet a bold noun-phrase label followed by one or two sentences.
12
12
 
@@ -29,8 +29,7 @@ Nothing else. The feature template's lint rules apply. Forty to a hundred and tw
29
29
  type: package
30
30
  status: active
31
31
  objects: [nustack cli, device credential] # required — the objects this package designs or ships
32
- owns: ["packages/{name}/**"] # required until the graph computes ownership — the residual claim
33
- applies: [docs/architecture/common/api.md] # optional
32
+ owns: ["packages/{name}/**"] # transitional — the residual region glob, read only by the ownership scan until it switches to header pointers
34
33
  ---
35
34
  ```
36
35
 
@@ -37,7 +37,7 @@ Sections come in this order; 1 to 3 are the outward-facing first screen, 4 onwar
37
37
  - **Relative links into the repo only.** Never an absolute repo URL. Never an external site as the home of a canonical doc.
38
38
  - **Link folders and mandated scaffolds, never rosters.** The allowed targets are folders, `docs/README.md`, `docs/structure.md`, `docs/operations/setup.md`, `docs/history/CHANGELOG.md`, `docs/history/backlog.md`, `CLAUDE.md` and the owning docs in the Map. A procedure is named only where a Destinations row needs it. Every heading and table header is a noun phrase (`../references/style-guide.md` § Labels). Never list individual feature docs: the ownership index finds them.
39
39
  - **No tree.** The Map stops at top-level units and never lists files. Mark paths that look primary but are not, for example "`legacy/`: reference only, never edited".
40
- - **The Map is a coarse view of the ownership index, not a rival to it.** The Owning doc column names the doc that the index's `owns:` globs resolve to. When the two disagree the index wins, and the Map row is fixed in the same change.
40
+ - **The Map is a coarse view of the ownership index, not a rival to it.** The Owning doc column names the doc the index resolves for that path. When the two disagree the index wins, and the Map row is fixed in the same change.
41
41
  - **No version numbers and no dates.** Name the file that pins a version (`.nvmrc`, `packageManager`, `rust-toolchain.toml`). Write in the present tense, with no "coming soon" and no "as of".
42
42
  - **State rules, don't argue them.** One line each. The reasoning lives in the linked doc, and agent process rules stay in `CLAUDE.md`.
43
43
  - **Commands come from the repo.** Detect the package manager from the lockfile (`pnpm-lock.yaml` gives pnpm, `yarn.lock` gives yarn, otherwise npm). Use only scripts that exist, each with a trailing comment saying what it does.
@@ -6,7 +6,7 @@ Truth document. Use for: **one machine that spans packages**, which a person can
6
6
 
7
7
  **A system document's deepest layer is the machine's behaviour across packages** (`references/style-guide.md` § Shape — the model first, the detail after): the order it runs in, the sequence and state diagrams at role level, the invariant that holds at each place where parts meet, and what re-drives a stall. That layer is earned because no single file shows a cross-package flow. It stops before per-function steps, tables, columns and routes.
8
8
 
9
- **A system document's globs win by specificity.** Its `owns:` names the subtrees and exact files the machine is made of, narrower than the package glob. Two documents never claim a path at equal specificity; every glob matches a file on disk at `status: active`.
9
+ **A system document speaks for the files the machine is made of.** Their headers name it, which outranks the package document's residual claim. Until the ownership scan switches to header pointers, its transitional `owns:` names the machine's subtrees as region globs, narrower than the package glob; every glob matches a file on disk at `status: active`.
10
10
 
11
11
  **Sharp, bulleted, labelled with noun phrases** (`references/style-guide.md` § Labels). The opening paragraph defines the machine; everything after it is bullets under noun-phrase headings, each bullet a bold noun-phrase label followed by one or two sentences.
12
12
 
@@ -28,10 +28,8 @@ Nothing else. The lint rules of the feature template apply. Sixty to a hundred a
28
28
  type: system # required tooling key
29
29
  status: active # required — draft = the machine as a whole does not run
30
30
  objects: [run, run ledger, settlement] # required — the objects this machine owns or moves
31
- owns: # required until the graph computes ownership — narrower than the package glob
31
+ owns: # transitional — region globs, one per subtree; read only by the ownership scan until it switches to header pointers (references/frontmatter.md)
32
32
  - packages/{pkg}/src/{machine}/**
33
- applies: # optional — decisions and doctrine this machine is BOUND by
34
- - docs/architecture/decisions/AD-0NN-{slug}.md
35
33
  ---
36
34
  ```
37
35
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Truth document.** States what a person sees and can do on a surface, and what the surface promises never to do. Present tense, like every truth document.
4
4
 
5
- **`type: ux`**, plus `applies:` — the architecture docs this surface is bound by (the state vocabulary, the routing doctrine, the information architecture it answers to). Same key and same narrow reading as a feature doc's: obligation, not a reading list.
5
+ **`type: ux`**, plus `status:` and `objects:` — the objects the surface presents (`references/frontmatter.md`). The doctrine it answers to (the state vocabulary, the routing doctrine, the information architecture) is named in its Purpose for people and computed through shared objects for tooling.
6
6
 
7
7
  **Why this genre exists.** A feature doc (LLD) states what a feature is, how its data flows, and which contracts it honours — all of which stay plausibly true through a rewrite of the surface. Nothing else in the repo states what a person *observes*. So a change to the wire lands, the interface absorbs it, and the absorption reads as maintenance: no test fails, no lint fires, no document is contradicted. This document is the thing a silent change contradicts.
8
8
 
@@ -12,12 +12,12 @@
12
12
 
13
13
  | The behavior is… | Where it lives |
14
14
  | --- | --- |
15
- | One surface's — a panel, an editor, a dialog | `docs/features/{surface}-ux.md`, with `owns:` over that surface's component paths |
15
+ | One surface's — a panel, an editor, a dialog | `docs/features/{surface}-ux.md`; its component files' headers name it |
16
16
  | Cross-cutting — routing, information architecture, the state vocabulary every surface obeys, presentation of streams | `docs/architecture/` — owns no code, like every architecture doc |
17
17
 
18
- **Ownership: take the component globs only where they are unclaimed.** A surface's components are frequently already owned — by the page's LLD, by the feature behind one panel — and claiming them again is an ownership conflict, not protection. So: unclaimed globs go in `owns:`; otherwise the doc declares `owns: []` and is named in each owning LLD's **coordinated edits** row, phrased as *different axes, not a conflict* — the LLD owns the code, this document owns what a person observes.
18
+ **Ownership: a component file names one document in its header.** A surface's components are frequently already spoken for — by the page's feature document, by the feature behind one panel — and a file's header names exactly one document. Where the header already names the feature document, this document is named in that feature document's **coordinated edits** row instead, phrased as *different promises over the same files*, and the object closure links the two through the objects both name. Where no document speaks for the component yet, its header names this one.
19
19
 
20
- That matters because a doc nothing implicates is a doc that rots, and a surface rewritten under an unimplicated document is the failure this genre exists to prevent. The coordinated-edit row is the weaker of the two bindings; prefer real ownership wherever the globs are free.
20
+ That matters because a doc nothing implicates is a doc that rots, and a surface rewritten under an unimplicated document is the failure this genre exists to prevent. The coordinated-edit row is the weaker of the two bindings; prefer the header pointer wherever no document speaks for the component yet.
21
21
 
22
22
  ---
23
23
 
@@ -204,7 +204,7 @@ function removeEmptyParents(projectDir, rel) {
204
204
  }
205
205
  }
206
206
 
207
- // Writes the manifest's mounted files that differ on disk, then deletes owned names the manifest omits.
207
+ // Fetches the manifest's mounted files that differ on disk, writes them deepest path first, then deletes owned names the manifest omits.
208
208
  async function mountFromManifest({ projectDir, manifest, origin, cacheDir, fetchImpl, timeoutMs, priorOwned }) {
209
209
  const all = mountedEntries(manifest);
210
210
  const entries = admittedEntries(projectDir, all);
@@ -216,14 +216,28 @@ async function mountFromManifest({ projectDir, manifest, origin, cacheDir, fetch
216
216
  const dest = join(projectDir, entry.path);
217
217
  return !(existsSync(dest) && sha256Of(readFileSync(dest)) === entry.sha256);
218
218
  });
219
+ // Booby trap: every live session in the checkout runs these hooks while the mount rewrites them.
220
+ // Writing as each fetch lands let `hooks/compliance.mjs` arrive seconds before a new `hooks/lib/`
221
+ // module it imports, and every hook call in that window died with ERR_MODULE_NOT_FOUND (3.20.1
222
+ // rollout, 2026-10-05). Fetch everything, then write locally, imports (deeper paths) before importers.
223
+ const fetched = [];
219
224
  await eachLimited(stale, async (entry) => {
220
225
  try {
221
- writeAtomic(join(projectDir, entry.path), await readObject({ origin, entry, cacheDir, fetchImpl, timeoutMs }));
222
- written.push(entry.path);
226
+ fetched.push({ entry, bytes: await readObject({ origin, entry, cacheDir, fetchImpl, timeoutMs }) });
223
227
  } catch {
224
228
  failed.push(entry.path);
225
229
  }
226
230
  });
231
+ const depth = (path) => path.split('/').length;
232
+ fetched.sort((a, b) => depth(b.entry.path) - depth(a.entry.path) || a.entry.path.localeCompare(b.entry.path));
233
+ for (const { entry, bytes } of fetched) {
234
+ try {
235
+ writeAtomic(join(projectDir, entry.path), bytes);
236
+ written.push(entry.path);
237
+ } catch {
238
+ failed.push(entry.path);
239
+ }
240
+ }
227
241
  for (const rel of prunableFiles(projectDir, unionOwned(manifest.owned, priorOwned))) {
228
242
  if (listed.has(rel)) continue;
229
243
  rmSync(join(projectDir, rel), { force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nurix/etna",
3
- "version": "0.20.29",
3
+ "version": "0.20.31",
4
4
  "description": "Bootstrap a project with a Nurix harness — writes the committed contract (CLAUDE.md, AGENTS.md, .claude/harness.json, settings.json, the mount hook) and mounts the harness itself, gitignored, from a bundled payload; sessions keep it current from the CDN.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -46,5 +46,5 @@
46
46
  "agent",
47
47
  "plugin"
48
48
  ],
49
- "etnaFingerprint": "46abe9f3c2dd"
49
+ "etnaFingerprint": "1ced34191650"
50
50
  }