hotdocs 0.1.0a1__py3-none-any.whl

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 (113) hide show
  1. hotdocs/__init__.py +3 -0
  2. hotdocs/__main__.py +5 -0
  3. hotdocs/_entry.py +46 -0
  4. hotdocs/_tool/AUTHORING.md +185 -0
  5. hotdocs/_tool/QUICKSTART.md +308 -0
  6. hotdocs/_tool/SPEC_GUIDELINES.md +815 -0
  7. hotdocs/_tool/agent-skills/README.md +10 -0
  8. hotdocs/_tool/agent-skills/hotdocs-asset-kind/SKILL.md +121 -0
  9. hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-001.md +14 -0
  10. hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-002.md +14 -0
  11. hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-003.md +10 -0
  12. hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-004.md +18 -0
  13. hotdocs/_tool/examples/slugify/specs/components/slugify/component.md +51 -0
  14. hotdocs/_tool/examples/slugify/specs/components/slugify/constraints.md +3 -0
  15. hotdocs/_tool/examples/slugify/specs/components/slugify/interface/library.md +10 -0
  16. hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-001.md +5 -0
  17. hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-002.md +7 -0
  18. hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-003.md +5 -0
  19. hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-004.md +6 -0
  20. hotdocs/_tool/examples/slugify/specs/product/slugs.md +22 -0
  21. hotdocs/_tool/gen/README.md +24 -0
  22. hotdocs/_tool/gen/agentic-generator/.provenance.json +379 -0
  23. hotdocs/_tool/gen/agentic-generator/agentic_generator.py +427 -0
  24. hotdocs/_tool/gen/cache-manager/.provenance.json +458 -0
  25. hotdocs/_tool/gen/cache-manager/cache_manager.py +254 -0
  26. hotdocs/_tool/gen/capability-scenario-verifier/.provenance.json +469 -0
  27. hotdocs/_tool/gen/capability-scenario-verifier/capability_scenario_verifier.py +534 -0
  28. hotdocs/_tool/gen/citation-checker/.provenance.json +370 -0
  29. hotdocs/_tool/gen/citation-checker/citation_checker.py +219 -0
  30. hotdocs/_tool/gen/component-gate-runner/.provenance.json +375 -0
  31. hotdocs/_tool/gen/component-gate-runner/component_gate_runner.py +556 -0
  32. hotdocs/_tool/gen/corpus-graph-builder/.provenance.json +381 -0
  33. hotdocs/_tool/gen/corpus-graph-builder/corpus_graph_builder/__init__.py +192 -0
  34. hotdocs/_tool/gen/corpus-graph-builder/corpus_graph_builder/cli.py +51 -0
  35. hotdocs/_tool/gen/corpus-loader/.provenance.json +331 -0
  36. hotdocs/_tool/gen/corpus-loader/corpus_loader.py +249 -0
  37. hotdocs/_tool/gen/decision-drift-detector/.provenance.json +382 -0
  38. hotdocs/_tool/gen/decision-drift-detector/decision_drift_detector.py +338 -0
  39. hotdocs/_tool/gen/docs-site-renderer/.provenance.json +381 -0
  40. hotdocs/_tool/gen/docs-site-renderer/docs_site_renderer/__init__.py +188 -0
  41. hotdocs/_tool/gen/docs-site-renderer/docs_site_renderer/cli.py +69 -0
  42. hotdocs/_tool/gen/docs-site-renderer/static/app.js +111 -0
  43. hotdocs/_tool/gen/generation-loop/.provenance.json +341 -0
  44. hotdocs/_tool/gen/generation-loop/generation_loop.py +287 -0
  45. hotdocs/_tool/gen/generator/.provenance.json +600 -0
  46. hotdocs/_tool/gen/generator/generator.py +469 -0
  47. hotdocs/_tool/gen/graph-query-engine/.provenance.json +385 -0
  48. hotdocs/_tool/gen/graph-query-engine/graph_query_engine.py +230 -0
  49. hotdocs/_tool/gen/hotdocs-cli/.provenance.json +371 -0
  50. hotdocs/_tool/gen/hotdocs-cli/hotdocs_cli.py +339 -0
  51. hotdocs/_tool/gen/hotdocs-init/.provenance.json +342 -0
  52. hotdocs/_tool/gen/hotdocs-init/hotdocs_init.py +463 -0
  53. hotdocs/_tool/gen/impact-analyzer/.provenance.json +418 -0
  54. hotdocs/_tool/gen/impact-analyzer/impact_analyzer.py +350 -0
  55. hotdocs/_tool/gen/kind-javascript/.provenance.json +482 -0
  56. hotdocs/_tool/gen/kind-javascript/kind_javascript.py +371 -0
  57. hotdocs/_tool/gen/kind-python/.provenance.json +433 -0
  58. hotdocs/_tool/gen/kind-python/kind_python.py +371 -0
  59. hotdocs/_tool/gen/license-scanner/.provenance.json +508 -0
  60. hotdocs/_tool/gen/license-scanner/license_scanner.py +388 -0
  61. hotdocs/_tool/gen/llm-endpoint/.provenance.json +494 -0
  62. hotdocs/_tool/gen/llm-endpoint/llm_endpoint.py +638 -0
  63. hotdocs/_tool/gen/llm-tool-endpoint/.provenance.json +409 -0
  64. hotdocs/_tool/gen/llm-tool-endpoint/llm_tool_endpoint.py +465 -0
  65. hotdocs/_tool/gen/provenance-checker/.provenance.json +495 -0
  66. hotdocs/_tool/gen/provenance-checker/provenance_checker.py +492 -0
  67. hotdocs/_tool/gen/provenance-tracker/.provenance.json +354 -0
  68. hotdocs/_tool/gen/provenance-tracker/provenance_tracker.py +423 -0
  69. hotdocs/_tool/gen/provenance-tracker-ui/.provenance.json +376 -0
  70. hotdocs/_tool/gen/provenance-tracker-ui/provenance_tracker_ui.py +309 -0
  71. hotdocs/_tool/gen/provenance-tracker-ui/static/app.js +23 -0
  72. hotdocs/_tool/gen/provenance-writer/.provenance.json +602 -0
  73. hotdocs/_tool/gen/provenance-writer/provenance_writer.py +315 -0
  74. hotdocs/_tool/gen/review-packet-builder/.provenance.json +378 -0
  75. hotdocs/_tool/gen/review-packet-builder/review_packet_builder.py +299 -0
  76. hotdocs/_tool/gen/secret-scanner/.provenance.json +558 -0
  77. hotdocs/_tool/gen/secret-scanner/secret_scanner.py +553 -0
  78. hotdocs/_tool/gen/size-checker/.provenance.json +393 -0
  79. hotdocs/_tool/gen/size-checker/size_checker.py +248 -0
  80. hotdocs/_tool/gen/spec-bundle-assembler/.provenance.json +573 -0
  81. hotdocs/_tool/gen/spec-bundle-assembler/spec_bundle_assembler.py +472 -0
  82. hotdocs/_tool/gen/spec-completeness-assistant/.provenance.json +357 -0
  83. hotdocs/_tool/gen/spec-completeness-assistant/spec_completeness_assistant.py +412 -0
  84. hotdocs/_tool/gen/spec-linter/.provenance.json +741 -0
  85. hotdocs/_tool/gen/spec-linter/spec_linter.py +894 -0
  86. hotdocs/_tool/gen/spec-reviewer/.provenance.json +342 -0
  87. hotdocs/_tool/gen/spec-reviewer/spec_reviewer.py +527 -0
  88. hotdocs/_tool/gen/spec-scaffolder/.provenance.json +397 -0
  89. hotdocs/_tool/gen/spec-scaffolder/spec_scaffolder.py +535 -0
  90. hotdocs/_tool/gen/surface-checker/.provenance.json +334 -0
  91. hotdocs/_tool/gen/surface-checker/surface_checker.py +322 -0
  92. hotdocs/_tool/gen/test-author/.provenance.json +506 -0
  93. hotdocs/_tool/gen/test-author/test_author.py +465 -0
  94. hotdocs/_tool/gen/test-probe/.provenance.json +379 -0
  95. hotdocs/_tool/gen/test-probe/test_probe.py +424 -0
  96. hotdocs/_tool/gen/verifier-orchestrator/.provenance.json +655 -0
  97. hotdocs/_tool/gen/verifier-orchestrator/verifier_orchestrator.py +878 -0
  98. hotdocs/_tool/pipeline/README.md +26 -0
  99. hotdocs/_tool/pipeline/criterion-compiler/.sealed-provenance.json +17 -0
  100. hotdocs/_tool/pipeline/criterion-compiler/criterion_compiler.py +529 -0
  101. hotdocs/_tool/pyproject.toml +38 -0
  102. hotdocs/_tool/requirements.txt +6 -0
  103. hotdocs/_tool/specs/architecture/asset-kind-javascript.md +106 -0
  104. hotdocs/_tool/specs/architecture/asset-kind-python.md +115 -0
  105. hotdocs/_tool/specs/architecture/asset-kinds.md +240 -0
  106. hotdocs/_tool/specs/architecture/cli-conventions.md +47 -0
  107. hotdocs/_tool/specs/architecture/step-phrase-grammar.md +84 -0
  108. hotdocs-0.1.0a1.dist-info/METADATA +140 -0
  109. hotdocs-0.1.0a1.dist-info/RECORD +113 -0
  110. hotdocs-0.1.0a1.dist-info/WHEEL +5 -0
  111. hotdocs-0.1.0a1.dist-info/entry_points.txt +2 -0
  112. hotdocs-0.1.0a1.dist-info/licenses/LICENSE +190 -0
  113. hotdocs-0.1.0a1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,815 @@
1
+ # Spec Guidelines
2
+
3
+ This document is the rulebook. Every authoring agent, generation agent, and
4
+ linter invocation in this repository follows it. It states **what** is
5
+ required; it does not re-derive **why** — the rationale and the decision
6
+ history live in `notes/initial-ideas.md` (`D1`–`D14`, informal brainstorm,
7
+ its own frozen historical numbering) and `specs/decisions/` (the formal
8
+ ADRs — `D1`–`D75` renumbered at the 2026-10 baseline reset, `D76` onward
9
+ recorded as made; a bare
10
+ `D<N>` citation below refers to `specs/decisions/D<N>.md` unless the
11
+ surrounding text names `initial-ideas.md` explicitly) and are cited here
12
+ by number for traceability, not repeated.
13
+
14
+ Keywords **MUST**, **MUST NOT**, **SHOULD**, **SHOULD NOT**, and **MAY** are
15
+ used per RFC 2119. This document is itself a spec of the methodology, so it
16
+ follows its own rule: no open questions, no ambiguity a linter couldn't catch.
17
+
18
+ ---
19
+
20
+ ## 1. Repository layout
21
+
22
+ ```
23
+ specs/
24
+ product/ # capabilities (P-id) + capability end-to-end scenarios
25
+ architecture/ # component decomposition, dependency graph ownership
26
+ vars/ # env/config parameter declarations (VAR-id) — never values
27
+ components/
28
+ <component>/
29
+ component.md # root: frontmatter + Purpose/Rationale/Scope/
30
+ # Definitions/Open questions/Change log +
31
+ # pointers to the below (Rationale optional, D21)
32
+ requirements/
33
+ R-<comp>-NNN.md # one Behavior requirement each
34
+ interface/
35
+ cli.md # CLI contract
36
+ library.md # library/function contract
37
+ data/
38
+ <TypeName>.md # one schema/type each
39
+ guarantees/
40
+ G-<comp>-NNN.md # one behavioral/non-functional guarantee each,
41
+ # that a *dependent* may rely on (D2) — optional,
42
+ # like cli.md/library.md
43
+ acceptance/
44
+ AC-<comp>-NNN.md # one acceptance criterion each
45
+ constraints.md # non-functional requirements (stays one file —
46
+ # see §3.4; no `Covers:`-style reference ever
47
+ # addresses one constraint individually)
48
+ decisions/ # ADR-style, append-only, immutable once ratified
49
+ glossary.md # canonical vocabulary
50
+ SPEC_GUIDELINES.md # this file
51
+ gen/ # generated code
52
+ pipeline/ # workflow definitions, frozen prompts, model pins, toggles
53
+ verification/ # generated tests, contract checks, corpus-graph.json
54
+ tools/ # hand-written repo-maintenance/authoring scripts —
55
+ # outside the spec-driven pipeline entirely (not
56
+ # generated, not gated, never read by any rule in
57
+ # this document). Scaffolding convenience only.
58
+ notes/ # brainstorming — non-normative, not read by the pipeline
59
+ .hotdocs/ # LOCAL ONLY, gitignored — provenance-tracking records
60
+ attempts/ # (provenance-tracker, D19) one record per per-component
61
+ # generation+verification attempt, full detail —
62
+ # what D3's retired best-of-k loop used to fold
63
+ # into one provenance manifest, now the only place
64
+ # a blocked attempt's detail survives at all
65
+ calls/ # (llm-endpoint, D20) one record per model call,
66
+ # caller-agnostic, transport-level only
67
+ # All of the above: never committed, never read by
68
+ # any gate's pass/fail decision — purely observability.
69
+ ```
70
+
71
+ - `specs/` **MUST NOT** contain executable code of any kind, generated or
72
+ hand-written. (D4)
73
+ - `gen/` and `verification/` **MUST** be committed on every branch. Large
74
+ generated binary assets **MUST** go through Git LFS rather than a plain blob
75
+ commit. (D6)
76
+ - A component's real code under `gen/<slug>/` (`<slug>` per
77
+ `glossary.md`'s "Component id / component slug" entry) **MUST** be
78
+ either a flat `<slug_with_underscores>.py` module or a
79
+ `<slug_with_underscores>/` package (with `__init__.py`) directly
80
+ under `gen/<slug>/` — never nested deeper (e.g. a `src/` layout) and
81
+ never a separately-installed distribution. This is load-bearing, not
82
+ stylistic: `spec-bundle-assembler`'s `dependency_usage`
83
+ (`R-ASSEMBLE-011`, `D37`) only ever looks in those two exact
84
+ locations, and silently (by design, fail-to-empty) returns nothing
85
+ for a dependency it can't find there — found only once a real
86
+ generated candidate chose a `src/` layout instead (`D46`).
87
+ - Nothing under `gen/` or `verification/` is hand-edited, with exactly two
88
+ declared exemptions — see §8.
89
+ - `.hotdocs/` **MUST** be gitignored and **MUST NOT** be read by any gate's
90
+ pass/fail decision — it is observability data about past `hotdocs generate`
91
+ attempts, never an input to any check. This is a correctness boundary, not
92
+ just a storage convention: letting a gate's decision depend on local,
93
+ uncommitted history would break every determinism/purity requirement
94
+ elsewhere in this document (e.g. `impact-analyzer`'s R-IMPACT-006).
95
+ - `tools/` is committed (unlike `.hotdocs/`) but otherwise occupies the
96
+ same "outside the methodology" position: a script here **MUST NOT** be
97
+ invoked by any gate, and **MUST NOT** write to
98
+ `specs/`/`gen/`/`verification/` on a human's behalf without the human
99
+ reviewing the result before committing — it may *create* new, empty
100
+ scaffolding (directory structure, placeholder frontmatter), never
101
+ author normative content. The distinction that matters: a scaffolding
102
+ script removes mechanical friction; it does not do the spec-authoring
103
+ work D1 reserves for a human or an assist agent.
104
+ - A `README.md` anywhere under `specs/` is non-normative scaffolding, not a
105
+ governed spec — the linter and every other tool in this document **MUST**
106
+ skip it. The governed set under a component directory is exactly:
107
+ `component.md`; every file under `requirements/`, `interface/` (including
108
+ `interface/data/`), and `acceptance/`; and `constraints.md`. Elsewhere: any
109
+ other named `.md` file directly under `specs/product/`,
110
+ `specs/architecture/`, `specs/vars/`, or `specs/decisions/`; and
111
+ `specs/glossary.md`. (Found while bootstrapping `spec-linter` — nothing
112
+ previously said how to tell a real spec from a placeholder sitting in the
113
+ same directory.)
114
+ - **Why one file per unit, not one file per document type (`D1`).** A
115
+ component's individually-addressed units — each requirement, each
116
+ acceptance criterion, each interface section — get their own file;
117
+ narrative/frontmatter does not. This replaced an earlier four-flat-files
118
+ design (`spec.md` / `interface.md` / `acceptance.md` / `constraints.md`)
119
+ once it became clear
120
+ the flat-file version was both harder to hash precisely for blast-radius
121
+ purposes (D2's "interface change vs. internal change" distinction needed
122
+ section-level parsing to approximate) and inconsistent with itself (every
123
+ `R-id` and every `AC-id` was already independently addressed by other
124
+ specs — `realizes`, `uses_var`, `Covers:` — while living in a shared file
125
+ with no file-level boundary to hash against). One file per unit makes
126
+ content hashing *exact* rather than approximated, and removes a whole
127
+ class of block-boundary parsing bugs (the kind that caused a real,
128
+ caught-in-testing bug in `spec-linter`'s own bootstrap).
129
+
130
+ ---
131
+
132
+ ## 2. Universal frontmatter
133
+
134
+ Frontmatter lives in exactly one place per component: **`component.md`**,
135
+ the root file. Every other file in a component — each `requirements/R-*.md`,
136
+ each `interface/cli.md` / `interface/library.md` / `interface/data/*.md`,
137
+ each `acceptance/AC-*.md`, and `constraints.md` — carries **no frontmatter
138
+ at all**. A unit file's identity is its filename and its position in the
139
+ directory tree; there is nothing left for frontmatter to declare. (This
140
+ replaced an earlier, less uniform rule — "only `spec.md` carries the full
141
+ field set, the other three carry `id`/`title`/`status`/`owners`" — once the
142
+ component was split into one-file-per-unit: there's no longer a meaningful
143
+ "this sub-file's own id/status" to track separately from the root's.)
144
+
145
+ A product capability (`specs/product/<name>.md`), an architecture doc
146
+ (`specs/architecture/<name>.md`), a var declaration (`specs/vars/<name>.md`),
147
+ and a decision record (`specs/decisions/<id>.md`) each remain one flat file
148
+ and carry the full field set below, same as `component.md` does for a
149
+ component (minus the component-only fields, naturally — a product capability
150
+ has no `sealed`, for instance). `specs/glossary.md` has no frontmatter at
151
+ all, same as before.
152
+
153
+ "Required" below is one of: **always** (every instance of this field is
154
+ mandatory), **never** (optional everywhere), or a stated **condition**
155
+ (mandatory only when the condition holds, forbidden otherwise — not merely
156
+ optional).
157
+
158
+ | Field | Required | Meaning |
159
+ | --- | --- | --- |
160
+ | `id` | always | Stable identifier for the whole spec document (`component.md`, a product capability, etc.). A unit file's own id is its filename (e.g. `R-FOO-001.md`), not a frontmatter field — there is no unit-level frontmatter to hold one. |
161
+ | `title` | always | Human-readable name. |
162
+ | `status` | always | `draft` \| `ratified` \| `deprecated`. |
163
+ | `owners` | always | Who (human or team) is accountable for this spec. |
164
+ | `depends_on` | never (optional) | List of spec ids this one requires. Forms the dependency graph (D2). **(component `component.md` only)** |
165
+ | `realizes` | condition: required unless `sealed: true` | List of `P-<id>`s this component contributes to. (D8) **(component `component.md` only)** |
166
+ | `uses_var` | never (optional) | List of `VAR-<id>`s this component reads from `specs/vars/`. (D12) **(component `component.md` only)** |
167
+ | `assets` | never (optional) | List of `<kind>:<path>` strings: a component's non-Python generated files, each at `gen/<slug>/<path>`. See `specs/architecture/asset-kinds.md`. (D343) **(component `component.md` only)** |
168
+ | `depends_on_guarantees` | never (optional) | List of `G-<comp>-NNN` ids — a **strictly opt-in narrowing** of which of a dependency's `interface/guarantees/` entries this component actually relies on. (D2) **(component `component.md` only)** |
169
+ | `supersedes` | never (optional) | Prior spec id this one replaces. |
170
+ | `builds_on` | never (optional) | List of prior `D<N>`s this decision's reasoning depends on, without replacing any of them. **(decision record only)** |
171
+ | `model_pin` | never (optional); **inapplicable when `sealed: true`** | Per-spec override of the repo-wide canonical model. **MUST** be omitted (not filled with a placeholder) on a sealed component — there is no generation to pin. **(component `component.md` only)** |
172
+ | `sealed` | never (optional), default `false` | Legacy-perimeter escape hatch — and, per the `criterion-compiler` precedent, also the correct mechanism for a *permanently* hand-maintained trust anchor, not only temporary legacy debt. See §8. (D1/D8) **(component `component.md` only)** |
173
+ | `source_path` | condition: required when `sealed: true`, forbidden otherwise | Where the actual, hand-maintained code lives. **MUST NOT** point under `gen/`. **(component `component.md` only)** |
174
+ | `last_ratified_commit` | condition: required when `status: ratified` | Commit hash of the ratifying merge. |
175
+
176
+ **Rules:**
177
+ - A spec **MUST NOT** be `status: ratified` while it has any non-empty `Open
178
+ questions` section.
179
+ - `depends_on` **MUST** form an acyclic graph across the whole corpus.
180
+ - Every `depends_on`, `realizes`, and `uses_var` reference **MUST** resolve to
181
+ a real, existing spec id. Dangling references are a hard lint failure.
182
+ - Every `depends_on_guarantees` entry **MUST** resolve to a real `G-<comp>-NNN`
183
+ id, **and** that id's owning component **MUST** already be listed in this
184
+ component's own `depends_on` — referencing a guarantee of a component you
185
+ don't even depend on is meaningless, not just unresolved. (D2)
186
+ - `sealed: true` **MUST** carry a `source_path`; `sealed: false` or absent
187
+ **MUST NOT** carry one.
188
+ - A `specs/vars/` declaration's own fields (`required`/`optional`, `type`,
189
+ `description`, `sensitivity`, `example`/`default`) live in the document
190
+ **body**, as bullets, not in frontmatter — its frontmatter is just `id` /
191
+ `title` / `status` / `owners`. (A var declaration is a single flat file,
192
+ not split into units — there's exactly one thing in it to address.)
193
+ - Every `assets` entry **MUST** be `<kind>:<path>` with a relative, `/`-separated
194
+ `path` free of `..` and not ending in `.py`, and `<kind>` **MUST** have a
195
+ definition with all seven sections (`specs/architecture/asset-kinds.md`).
196
+ - A unit file under `requirements/`, `interface/`, or `acceptance/`, or
197
+ `constraints.md`, **MUST NOT** carry any frontmatter block at all. Finding
198
+ one is a hard lint failure — the same structural guarantee that used to
199
+ rely on a convention ("only `spec.md` has the full set") now holds by
200
+ construction instead.
201
+
202
+ ---
203
+
204
+ ## 3. Document types
205
+
206
+ ### 3.1 Product capability (`specs/product/<name>.md`)
207
+
208
+ Declares a capability with a stable `P-<id>`. Body: Purpose, Scope, and one or
209
+ more Given/When/Then capability scenarios (§5 format) exercised **black-box
210
+ against the whole assembled system** — never against one component in
211
+ isolation. (D8)
212
+
213
+ ### 3.2 Architecture (`specs/architecture/<name>.md`)
214
+
215
+ The only place the component decomposition itself is declared and changed.
216
+ Splitting or merging components is **not** a normal spec change — it **MUST**
217
+ go through this area, as its own reviewed operation, distinct from an ordinary
218
+ component spec edit. (D2)
219
+
220
+ ### 3.3 Var declaration (`specs/vars/<name>.md`)
221
+
222
+ Declares one configuration parameter. Fields: `name`, `required` \|
223
+ `optional`, `type` (`string` \| `url` \| `connection-string` \| `secret-ref` \|
224
+ `integer` \| `enum` \| …), `description`, `sensitivity` (`secret` \|
225
+ `non-secret`). (D12)
226
+
227
+ - There **MUST NOT** be a `value` field anywhere in this schema. Not a
228
+ convention — the field does not exist.
229
+ - A declaration with `sensitivity: secret` **MUST NOT** carry an `example` or
230
+ `default` field.
231
+ - A component that reads this variable **MUST** reference it via `uses_var`,
232
+ never redefine its meaning locally.
233
+
234
+ ### 3.4 Component (`specs/components/<name>/`)
235
+
236
+ One root file plus three unit directories plus one flat file:
237
+
238
+ **`component.md`** — the root. Carries the frontmatter (§2) and this fixed
239
+ section order:
240
+
241
+ | Section | Rule |
242
+ | --- | --- |
243
+ | Purpose | One paragraph: what this unit does and why it exists — **dependent-safe** (D21): no decision citations (`D<N>`), no historical justification, no cross-references to how this design was arrived at. This is the one section a *dependent* may see as part of its own context (`notes/backlog.md`'s "context" idea, once built) — everything that would make it internal rationale instead of a clean description belongs in Rationale, not here. |
244
+ | Rationale | Everything Purpose used to carry that isn't dependent-safe: decision citations, historical justification, cross-references to the discussion that produced this design. **Internal only** — never included in anything assembled for a dependent. Optional: a component whose Purpose genuinely needs no supporting history MAY omit this section entirely, rather than leave it empty for form's sake. |
245
+ | Scope | Explicit in-scope / out-of-scope bullets. |
246
+ | Definitions | Only deltas from `glossary.md`. |
247
+ | Behavior | Pointer: "See `requirements/`." |
248
+ | Interfaces | Pointer: "See `interface/`." |
249
+ | Data | Pointer: "See `interface/data/`." |
250
+ | Acceptance criteria | Pointer: "See `acceptance/`." |
251
+ | Non-functional constraints | Pointer: "See `constraints.md`." |
252
+ | Open questions | **MUST** be empty when `status: ratified`. |
253
+ | Change log | Human-readable history. |
254
+
255
+ **`requirements/R-<comp>-NNN.md`** — one normative requirement per file,
256
+ using RFC 2119 keywords. The filename *is* the requirement's id — no
257
+ frontmatter, no separate id field to keep in sync with it.
258
+
259
+ - Every `R-id` **MUST** be traceable forward to ≥1 acceptance criterion and
260
+ backward to a rationale or decision record.
261
+ - A spec is not "done" until an authoring/generation agent can execute it with
262
+ zero clarifying questions. An agent that must ask one **MUST** surface it as
263
+ a tracked assumption or an open question, never silently guess.
264
+
265
+ **`interface/`** — the public contract (types, endpoints, events, CLI,
266
+ *and* behavioral guarantees — D2 extended "the contract" to include the
267
+ last of these, not just type signatures), split by kind:
268
+ - `interface/cli.md` — the CLI contract, if any.
269
+ - `interface/library.md` — the library/function contract, if any.
270
+ - `interface/data/<TypeName>.md` — one schema/type per file.
271
+ - `interface/guarantees/G-<comp>-NNN.md` — one behavioral/non-functional
272
+ guarantee per file, that a *dependent* is entitled to rely on
273
+ (consistency, ordering, idempotency, error-handling semantics, latency
274
+ bounds). Like a requirement, each uses RFC 2119 keywords and its
275
+ filename is its id. **Not** a place for internal implementation
276
+ rationale — that stays in `requirements/`/`constraints.md`. (D2)
277
+
278
+ A component need not have all four — e.g. a purely-library component may
279
+ have no `cli.md`, and most components have no `guarantees/` at all (nothing
280
+ externally relied upon beyond ordinary types). The generated interface
281
+ **MUST** match this content exactly; any divergence is a hard drift-check
282
+ failure.
283
+
284
+ When a dependent needs one more fact than an existing boundary like
285
+ this one currently exposes, see `notes/narrow-exception-pattern.md` —
286
+ the move is almost always a new, narrowly-named field or mechanism
287
+ alongside the original, never a loosened definition of what the
288
+ original already means.
289
+
290
+ **`acceptance/AC-<comp>-NNN.md`** — one acceptance criterion per file. See
291
+ §5 for its internal format. The filename is the criterion's id.
292
+
293
+ **`constraints.md`** — stays one flat file, non-functional requirements
294
+ (perf, security, compatibility), each with a measurable target and a
295
+ measurement method. Deliberately **not** split like the three directories
296
+ above: nothing elsewhere in the corpus addresses one individual constraint
297
+ by id the way `Covers:`/`realizes`/`uses_var` address a requirement,
298
+ criterion, or interface section — there's no reference-granularity reason to
299
+ pay the extra-file cost here.
300
+
301
+ ### 3.5 Decision record (`specs/decisions/<id>.md`)
302
+
303
+ ADR-style. Append-only. Once a decision record is ratified it is
304
+ immutable — a change in direction is a new, superseding record
305
+ (`supersedes` field), never an edit to the old one, with one narrow,
306
+ sanctioned exception: the superseded record's own `status` field
307
+ flips to `deprecated` as part of that same change. A decision record
308
+ MUST cover exactly one topic, and every `D<N>` citation MUST point to
309
+ the specific decision responsible for the specific fact stated, never
310
+ assumed correct because it merely resolves. See `specs/decisions/
311
+ README.md` for the full guidelines — frontmatter shape,
312
+ `supersedes`/`builds_on` semantics, citation discipline, and the
313
+ grep-based drift check — this section states the normative rules in
314
+ brief, not a second copy of the reasoning.
315
+
316
+ ### 3.6 Glossary (`specs/glossary.md`)
317
+
318
+ Single file, no frontmatter, no per-spec entry limit. (D14)
319
+
320
+ - Specs **MUST** use glossary terms as defined; a component's `Definitions`
321
+ section may only add deltas, never silently redefine a glossary term.
322
+ - **MUST NOT** be sharded by a size rule. The only legitimate split is a
323
+ deliberate `architecture/`-level bounded-context decision (two subsystems
324
+ that genuinely don't share vocabulary) — never a routine response to word
325
+ count.
326
+
327
+ **When to promote a fact here** (the judgment call §4's component-sizing
328
+ trigger makes for size, made explicit for shared vocabulary): a
329
+ convention, naming formula, file-path pattern, or callable contract
330
+ **MUST** be promoted to the glossary as soon as a second component's
331
+ spec states it, relies on it, or would need to independently guess it
332
+ — never left to live only in one component's own text (where a
333
+ dependent's `SpecBundle` never sees it, `R-ASSEMBLE-002`) or only in
334
+ real `gen/` code (where no spec ever sees it at all). §10's "single
335
+ source of truth for computed facts" is the sibling discipline for
336
+ *calculations*; this is the same discipline for *shared vocabulary and
337
+ contracts* — a convention is not "computed," but it is exactly as
338
+ unsafe to let two components independently reinvent.
339
+
340
+ Before writing a requirement that describes how your component uses
341
+ or constructs a fact belonging to *another* component's contract —
342
+ not your own component's purely internal behavior — check whether
343
+ `glossary.md` already names it. If it doesn't, and a second real
344
+ consumer now exists (this requirement, plus whichever component you
345
+ found the convention in originally), promote it there as part of the
346
+ same change, not as a follow-up. See `notes/audit-before-you-build.md`
347
+ for the analogous habit already established for *data that already
348
+ exists but isn't yet being read*; this is the same habit for
349
+ *conventions that already exist but aren't yet written down*.
350
+
351
+ A glossary entry is a line starting `- **<Term>**` (a list item whose
352
+ bolded text is the entry's header), its definition following on that
353
+ line and any continuation lines until the next such item (`D241`).
354
+ A citation of an existing glossary entry **MUST** quote its bolded
355
+ header exactly (e.g. `` the glossary's "Criterion test filename" ``)
356
+ — `R-CITE-003` mechanically checks this resolves to a real entry,
357
+ the same way `R-CITE-001` already does for `D<N>` citations and
358
+ `R-CITE-002` already does for section-heading pointers. That check
359
+ catches citation drift (a renamed or removed term, a typo) once a
360
+ term is cited; it cannot detect a fact that should have been
361
+ promoted but wasn't — that half stays a judgment call, which is why
362
+ this paragraph, not a linter rule alone, is the actual fix.
363
+
364
+ ---
365
+
366
+ ## 4. Component sizing
367
+
368
+ A component **MUST** be split when its full public behavior cannot be
369
+ captured by *complete*, agent-checkable acceptance criteria (§5's three
370
+ `kind`s all count toward completeness — a component is not oversized merely
371
+ because some of its behavior is legitimately judgment-based). This is the
372
+ non-negotiable trigger. (D2)
373
+
374
+ Below that bar, size caps are linter-enforced:
375
+
376
+ | Dimension | Warn above | Hard fail above |
377
+ | --- | --- | --- |
378
+ | Generated code per component (`D79`) | 800 LOC | 1500 LOC |
379
+ | Component docs (`component.md` + everything under `requirements/`, `interface/`, `acceptance/` + `constraints.md`) — `component_doc_words` (`D79`). Deliberately **not** called "spec bundle": this is every doc under the component's own directory, broader than the `SpecBundle` type `spec-bundle-assembler` actually builds, which excludes `acceptance/` entirely (`R-ASSEMBLE-001`). The two used to share a name despite measuring different things — renamed to stop that collision, not to change what's counted. | 2000 words | 4000 words |
380
+ | Requirements (`R-id`s) per component (`D79`) | 20 | 40 |
381
+ | Public interface surface elements (`D79`) | 10 | 20 |
382
+ | `depends_on` count (fan-out) (`D79`) | 7 | — (warn only) |
383
+ | Dependents count (fan-in) (`D79`) | 10 | — (warn only) |
384
+ | Guarantees (`G-id`s) per component (D17) | 5 | 10 |
385
+ | Acceptance criteria (`AC-id`s) per component (D17) | 25 | 50 |
386
+ | **Per-file** words, for any single file under `requirements/` or `acceptance/` (D17) — distinct from the component-docs row above, which is a whole-bundle aggregate | 250 | 500 |
387
+ | **`Purpose` section** words (D22) — checks the "one paragraph" rule above mechanically; distinct from both rows above, scoped to one section, not a file or the bundle | 80 | 150 |
388
+
389
+ The last three rows are a first pass (D17), calibrated against this
390
+ corpus's own content at the time they were added rather than an a
391
+ priori judgment — expect them to be revisited as more components
392
+ exercise them. `guarantee_count` in particular had no cap at all
393
+ before: the interface-surface-elements row deliberately excludes
394
+ `interface/guarantees/` (a promise, not a callable surface element),
395
+ which meant an unbounded number of guarantee files could previously
396
+ accumulate with zero signal.
397
+
398
+ **How each dimension is measured** (`D211`), per component directory
399
+ `specs/components/<c>/`:
400
+
401
+ - `generated_code_loc`: lines of every `*.py` file under `gen/<c>/`,
402
+ recursively, that are neither blank nor, once stripped, start with `#`.
403
+ - `component_doc_words`: the `component_size` view's `word_count`.
404
+ - `requirement_count`, `guarantee_count`, `acceptance_count`: the number
405
+ of `R-*.md`, `interface/guarantees/G-*.md` and `AC-*.md` files.
406
+ - `interface_surface`: one per non-blank line of the first fenced block
407
+ in `interface/cli.md` (a line ending in `\` joins the next), plus one
408
+ per line of the first fenced block in `interface/library.md` matching
409
+ `^\w+\(.*\)\s*(->|:)` after the same joining, plus one per file in
410
+ `interface/data/`. Guarantees never count.
411
+ - `fan_out`: entries in `depends_on`. `fan_in`: components whose
412
+ `depends_on` names this one.
413
+ - Per-file words (`R-SIZE-003`, `requirements/` and `acceptance/` files)
414
+ and `Purpose` words: the number of whitespace-separated tokens
415
+ (Python's `str.split()`) of the file's text after any frontmatter, or of
416
+ the `Purpose` section's text between its heading line and the next
417
+ `##` heading. Code blocks and headings count like any other text.
418
+ (`D231`)
419
+
420
+ Components are a **flat namespace** — no nesting. `architecture/` is the only
421
+ place subsystem grouping is expressed.
422
+
423
+ **A decomposition signal, not just a cap to satisfy.** A single dimension
424
+ running high can be an accepted shape on its own — a thin coordinator
425
+ legitimately has wide fan-out with little owned logic of its own (see
426
+ `specs/architecture/pipeline-decomposition.md`'s note on
427
+ `merge-orchestrator`). But when **two or more independent dimensions**
428
+ above crowd their ceilings **for the same component at the same time**,
429
+ treat that as a sign the component owns a cross-cutting concern that has
430
+ outgrown its placement, not as evidence the caps themselves are
431
+ miscalibrated. This is enforced directly, not just described here: `spec-
432
+ linter`'s `R-SIZE-002` (`D15`) emits a distinct finding whenever it fires.
433
+ Two shapes of this have shown up in practice so far, not just one: a thin
434
+ coordinator crowding fan-out together with component-doc words
435
+ (`merge-orchestrator`, resolved by `D14`), and a self-contained component
436
+ with no fan-out at all crowding component-doc words together with its own
437
+ requirement/acceptance/generated-code counts instead (`spec-linter`
438
+ itself, after `D17` added those dimensions — fan-out is irrelevant there;
439
+ the signal is still real). Fan-out measures how many neighbors a
440
+ component calls; the count/words dimensions measure how much it owns
441
+ directly. A thin coordinator runs fan-out high without the others; a
442
+ dense, isolated component can crowd several of the others with zero
443
+ fan-out. Either combination means the component isn't just one simple
444
+ shape (thin-and-wide, or fat-but-isolated) — it's carrying more than one
445
+ dimension's worth of cost at once.
446
+
447
+ The fix is not automatically a bigger cap, but it is also not
448
+ automatically a split — the signal means "look closely," not "extract
449
+ something." Start by asking whether a structural precedent for a split
450
+ already exists elsewhere in the corpus: `D14` extracted
451
+ `capability-scenario-verifier` out of `merge-orchestrator` once both caps
452
+ crowded at once, because that logic was already the cross-component
453
+ analog of `verifier-orchestrator`'s existing per-component dispatch — the
454
+ split mirrored a pattern already present, it wasn't invented from
455
+ scratch. The dimension that should actually move is component-doc
456
+ words — but don't assume fan-out's own fate either way without
457
+ checking: `D14`'s extraction left it flat (`merge-orchestrator` had its
458
+ own independent reasons to keep calling several of
459
+ `capability-scenario-verifier`'s own dependencies directly), while
460
+ `D76` — the same kind of extraction, applied to `merge-orchestrator` a
461
+ second time, for `component-gate-runner` — saw it actually drop (every
462
+ dependency the new component encapsulated had no other caller). Whether
463
+ fan-out drops depends on whether the coordinator had a second reason to
464
+ call the extracted dependencies directly, not on the extraction pattern
465
+ itself. See `notes/component-sizing-playbook.md` for both worked
466
+ cases.
467
+
468
+ Sometimes the honest conclusion is that no precedent exists and no split
469
+ is warranted: `spec-linter` crowding `generated_code_loc`,
470
+ `requirement_count`, and `component_doc_words` together (`D77`) reflects
471
+ one cohesive component with many genuinely independent, correlated rules —
472
+ not a hidden second responsibility with some other component's shape to
473
+ borrow. Splitting a single-pass structural linter into sub-checkers for
474
+ no architectural reason would be the wrong response to this signal, not
475
+ the right one; treat the signal as a prompt to check for a real
476
+ precedent, not a mandate to always act on it. If fan-out was the *only*
477
+ dimension crowding, that's a different, already-accepted case —
478
+ D2's "thin coordinator" shape, not this signal at all.
479
+
480
+ See `notes/component-sizing-playbook.md` for the worked decision
481
+ procedure and tightening toolbox this principle compresses — a
482
+ step-by-step guide grounded in this corpus's own real cases (`D14`,
483
+ `D17`, `D29`), not abstract advice.
484
+
485
+ ---
486
+
487
+ ## 5. Acceptance criteria
488
+
489
+ Each file under a component's `acceptance/` directory (or, for a product
490
+ capability, each capability scenario inline in its one file) is a **Given/
491
+ When/Then block**, written in Gherkin syntax, with a required `Covers:` tag
492
+ (`@covers:<id>`) and a required `kind`. `Covers:` takes an `R-<id>` for a
493
+ component criterion, or a `P-<id>` for a product capability's own
494
+ capability scenario (D8) — product-level scenarios have no component `R-id` to
495
+ reference, only their own capability id:
496
+
497
+ | `kind` | How it's checked | Use when |
498
+ | --- | --- | --- |
499
+ | `compiled` | Deterministically compiled to test scaffolding — no model involved. Default. | The criterion is expressible in Given/When/Then and concerns runtime behavior of generated code. |
500
+ | `generated-test` | An agent writes test code from freeform prose; executed thereafter like any other test. | Runtime behavior that resists the Given/When/Then grammar. |
501
+ | `llm-judge` | An agent evaluates the criterion directly against an artifact — no code produced. | Qualities that are not runtime behavior at all (spec hardening, absence of contradiction, clarity). |
502
+
503
+ Rules:
504
+ - Every criterion, of any `kind`, **MUST** carry a `Covers:` tag referencing a
505
+ real `R-<id>` (component) or `P-<id>` (product capability) — never a
506
+ dangling reference.
507
+ An acceptance file's tag is its first `Covers:` followed by the id;
508
+ any later `Covers:` in the file is prose or an example, never a
509
+ reference (`D232`). A capability scenario's is the `Covers:` line
510
+ directly under its `### CS-...` heading. The `kind` is the line
511
+ `Kind: <kind>` (capital K, one of the three values below) that
512
+ follows the tag, never a frontmatter field (`D234`).
513
+ - Prefer `compiled`, then `generated-test`; reach for `llm-judge` only when no
514
+ test could capture the criterion even in principle. (D5)
515
+ - Generated test code **MUST** live under `verification/`, never under
516
+ `specs/`. (D4)
517
+ - A `generated-test` criterion's mutation score **MUST** meet 80% (general) or
518
+ 90% (freeform-derived) or the merge fails. (D80)
519
+ - An `llm-judge` criterion **MUST** emit structured rationale alongside its
520
+ verdict, for audit — the rationale is never itself a review gate.
521
+ - A component with an `interface/cli.md` **MUST** have a requirement that
522
+ cites `interface/cli.md` by that path and pins its argument parsing:
523
+ each flag's accepted forms (`--flag=value` and/or `--flag value`), what
524
+ a flag given with no value does, how a wrong subcommand or unknown
525
+ argument is handled, which flags pass through to the library call,
526
+ and every exit code. At least one criterion **MUST** cover it,
527
+ exercising each of those cases. A documented CLI with no such
528
+ requirement is untested code that mutation testing will find anyway,
529
+ one survivor at a time. (`R-LINT-031`, D162) Its finding is reported
530
+ on the component's `interface/cli.md`, at line 1.
531
+ - Every behavior a criterion checks **MUST** be stated in a requirement
532
+ or the interface: the generator never sees `acceptance/`, and
533
+ implements only what its bundle states. (D298)
534
+ - Every fact a criterion's test needs (a value, file layout, reply
535
+ format, error category, flag or grammar form) **MUST** appear in that
536
+ criterion, the one requirement it covers, or the component's interface
537
+ with its `Implements:` documents: nothing else reaches its test
538
+ author. A rule several criteria share belongs in the interface or a
539
+ `specs/architecture/` document. `hotdocs spec check` reports
540
+ violations. (D298, D300)
541
+ - A criterion **SHOULD** name concrete inputs and exact expected outputs,
542
+ and the exception class or exit code of every failure it expects.
543
+
544
+ See `notes/determinism-trust-playbook.md` for how this `kind` split
545
+ drives caching/trust design elsewhere in the pipeline (only `llm-judge`
546
+ is ever a genuine trust decision; `compiled`/`generated-test` are
547
+ always cheaply re-derivable), and `notes/structured-judgment-output.md`
548
+ for the `{result, rationale}` pattern this rationale rule is one
549
+ instance of.
550
+
551
+ ---
552
+
553
+ ## 6. Verification gates
554
+
555
+ **No component automates this sequence end to end (`D87`).** A developer
556
+ drives it directly:
557
+
558
+ 1. **Spec lint** — structure, frontmatter, RFC 2119 usage, no open questions in
559
+ ratified specs, glossary conformance, acyclic dependency graph, full
560
+ traceability closure (every `R-id`, `realizes`, `uses_var`, `depends_on`,
561
+ `depends_on_guarantees` reference resolves), size caps. Run directly;
562
+ nothing gates `hotdocs generate`/`hotdocs verify` on it, but there is
563
+ no reason to attempt either against a spec that won't lint clean.
564
+ 2. **`hotdocs generate <component-id> --model=<model-id> [--seed=...]
565
+ [--retry-feedback=...]`** (`component-gate-runner`, `D86`/`D91`/`D93`)
566
+ — one component at a time, run by a developer in `depends_on` order
567
+ across a multi-component change. Checks provenance first (skip real
568
+ work on a hit); on a miss, the pinned model, cold, no prior code,
569
+ from the spec bundle (`component.md` + `requirements/` + `interface/`
570
+ + `constraints.md` + depended-upon components' `interface/` +
571
+ referenced `specs/vars/` declarations + `glossary` — deliberately
572
+ excluding `acceptance/`, so the model doesn't overfit to its own
573
+ tests); per-criterion verification (compiled / generated-test /
574
+ llm-judge, per §5, contract/property tests from `interface/`, the
575
+ interface-drift check); license and secret scans, unconditional
576
+ (D7/D12); provenance written last; the attempt recorded via
577
+ `provenance-tracker`'s `write_attempt_record` regardless of outcome.
578
+ Exactly one generation attempt per call — no automatic retry
579
+ (D1/D3: the best-of-k retry this step used to run was retired).
580
+ `--retry-feedback` (the immediately preceding attempt's failing
581
+ requirements against this same component) MAY be supplied against an
582
+ unchanged spec — this folds into the generation cache key
583
+ (`R-GEN-005`), so it is already a fresh attempt, with no separate
584
+ retry mechanism needed — but only if a human explicitly supplies it
585
+ (D3); nothing computes or injects it automatically.
586
+ 3. **`hotdocs verify [--changed=...] [--model=<model-id>] [--format=...]`**
587
+ (`provenance-tracker`, `D88`/`D93`) — for every component in scope
588
+ (a single id's blast radius via `impact-analyzer`, or the whole
589
+ corpus), a pure, read-only check against `provenance-checker`; this
590
+ never triggers `component-gate-runner` itself — generating new code
591
+ is `hotdocs generate`'s own deliberate action, never a side effect
592
+ of checking readiness. Then, for every product capability whose
593
+ realizing components are now all current: `capability-scenario-verifier`
594
+ (`D89`) checks its own provenance and, on a miss, runs that
595
+ capability's scenarios against the real, fully assembled `gen/`
596
+ output — not a prediction, the actual regenerated system — then
597
+ writes its own provenance, keyed on the realizing set's actual
598
+ current content (deliberately not their `spec_bundle_hash`es, so an
599
+ undeclared upstream change still invalidates it). Unlike the
600
+ component half, this is check-then-run, not pure read: capability-
601
+ scenario verification never produces new source code, only exercises
602
+ what already exists, so `hotdocs verify` triggering it costs a
603
+ developer nothing they wouldn't expect from a command named
604
+ "verify." `--model` is required only if some capability in scope
605
+ actually needs a fresh run. This is the backstop for cross-component
606
+ behavioral risk that no amount of interface-level diffing can rule
607
+ out in principle (D2) — not a redundant check: `interface/guarantees/`
608
+ (D2) makes *foreseen* behavioral dependencies explicit and
609
+ propagating, this gate catches what wasn't foreseen. `hotdocs
610
+ verify` then reports one ready/not-ready verdict across everything
611
+ it just checked — this is the confirmation a human reads before
612
+ committing; it does not enforce anything itself (`D87`), the same
613
+ posture `.hotdocs/`'s own non-gating rule already states. **Running
614
+ it is nonetheless a stated MUST before any commit of a regenerated
615
+ component** (`D99`) — scoped to the full blast radius of every
616
+ component actually changed (`--changed=<id>...`, letting
617
+ `impact-analyzer` compute the transitive set, never hand-picked),
618
+ not just the one component a developer happened to just regenerate
619
+ in isolation. This is workflow discipline, not a new automated gate
620
+ — no component checks that a developer actually did this before a
621
+ commit lands, the same absence of enforcement `D87` already
622
+ describes — but it is no longer merely optional good practice.
623
+ 4. **Non-functional gates** where feasible (benchmarks, size budgets).
624
+ 5. **Review** — `review-packet-builder` assembles the same picture
625
+ `hotdocs verify` checked (spec diff, changed requirements,
626
+ regenerated components, verification results, residual risk,
627
+ license/secret flags, provenance-hit status, capability-scenario
628
+ results, any new/changed `sealed`/override declarations) into a
629
+ static, reviewable artifact, reading `provenance-tracker`'s own
630
+ aggregate (`D90`) rather than recomputing anything. A human reviews
631
+ this and the spec diff. **No human review of generated code is
632
+ required, of any kind.** (D5)
633
+ 6. **Commit** — only after step 3's blast-radius-wide `hotdocs verify`
634
+ reports `ready: true` (`D99`): `specs/`, `gen/`, and `verification/`
635
+ (including `corpus-graph.json`) update atomically, by the developer,
636
+ in one squashed commit — ordinary version control, not a
637
+ component's own action.
638
+
639
+ A component whose spec bundle exactly matches an already-verified prior
640
+ state **MUST** be treated as a provenance hit (`provenance-checker`,
641
+ `D29`) — its committed `.provenance.json` has a matching
642
+ `spec_bundle_hash` and `gate_versions` — and `hotdocs generate` restores
643
+ the matching artifacts, skipping regeneration and re-verification. The
644
+ non-spec-driven-change lane still re-runs asynchronously afterward as an
645
+ environment-drift safety net. (D11) This is distinct from
646
+ `cache-manager`'s own, narrower per-gate cache (cache key:
647
+ `spec_bundle_hash`, `artifact/gate-inputs hash`, `gate_version`,
648
+ `model_pin`), which only ever decides whether a model gets called
649
+ again, never whether verification is skipped (D13).
650
+
651
+ A gate's `gate_version` **MUST** bump whenever its underlying detection logic
652
+ changes (e.g. the license scanner's signature database), so neither a
653
+ cache hit nor a provenance hit ever papers over a genuinely changed risk. (D81)
654
+
655
+ **Responding to a real defect found through this process is always three
656
+ steps, never one** (D36/D104): (1) diagnose the actual root cause —
657
+ never accept a surface symptom (a crash, a wrong assertion) as the
658
+ explanation; a rejected candidate is never hand-patched, the spec is
659
+ fixed and the candidate regenerated through the real pipeline instead
660
+ (D36). (2) Fix it in the spec, and add a structural safeguard that
661
+ would catch a recurrence of the same class of mistake early and
662
+ legibly — not just resolve the one instance found. (3) Scrub the
663
+ existing, already-committed corpus for other live instances of the
664
+ identical defect, not only the one that happened to surface first.
665
+ Skipping straight to "this one test now passes" without the other two
666
+ steps is exactly how the same defect reappears later, found the hard
667
+ way again.
668
+
669
+ ---
670
+
671
+ ## 7. Provenance
672
+
673
+ Every generated artifact carries `.provenance.json` alongside it (in
674
+ `gen/<component>/` and `verification/<component>/`), committed under the same
675
+ discipline as the artifact itself:
676
+
677
+ ```
678
+ spec_bundle_hash content hash of every spec file that fed generation
679
+ model_pin model id + version
680
+ prompt_version id of the frozen prompt template used
681
+ retry_feedback R-id list the landing attempt was given (R-GEN-012),
682
+ null if it was blind
683
+ generation mode (single or agentic), generator_version,
684
+ transcript_sha256, turns, tool_calls, isolation —
685
+ hashes and counts only, never a transcript (D312)
686
+ attempts attempts recorded for this component so far
687
+ attempt_history one entry per attempt of the landing run: number,
688
+ outcome, retry_feedback, error_category,
689
+ failed_requirements, transcript_sha256 (D310)
690
+ pipeline_version version of the generation pipeline itself
691
+ gate_versions per-gate version map (compiler, license_scanner,
692
+ mutation_harness, secret_scanner, ...)
693
+ provenance_hit bool — if true, the fields below are copied from the
694
+ matching prior commit (via provenance-checker,
695
+ D29), not freshly computed. Renamed from cache_hit,
696
+ which never actually meant cache-manager had an
697
+ entry — that's a per-gate concern, e.g.
698
+ GenerationResult's own cache_hit field.
699
+ generated_at
700
+ verification_run_id
701
+ verification_report the VerificationReport (verifier-orchestrator)
702
+ license_scan result (license-scanner)
703
+ secret_scan result (secret-scanner) — missing from an earlier draft
704
+ of this schema even though gate_versions already
705
+ expected a secret_scanner entry; found while specifying
706
+ provenance-writer, which is what actually assembles
707
+ this file from every other component's output
708
+ assets the VerificationReport's assets: per declared asset,
709
+ kind, path, definition/adapter SHA-256, versions,
710
+ lockfile_sha256; [] when none (D343)
711
+ ```
712
+
713
+ This is the evidence trail for incident debugging (is this a spec bug or a
714
+ generation bug?) and doubles as an SBOM/SLSA-style attestation.
715
+
716
+ A **sealed** component (§8) has no generation to record, so it carries a
717
+ different file instead, `.sealed-provenance.json` at its `source_path`
718
+ (`D170`). It names the component's `owners`, a hash of the source files
719
+ it describes, the verifier version, and the outcome of the
720
+ characterization-test run against exactly that source. It is validated
721
+ field by field and fails closed: a manifest that is missing, malformed,
722
+ for different source, or for different owners is no evidence at all, so
723
+ the component is not ready until `hotdocs generate` re-runs its
724
+ characterization tests and rewrites it. Its schema is
725
+ `provenance-writer`'s `interface/data/SealedProvenance.md`.
726
+
727
+ Before designing any new mechanism to record or prove a fact happened,
728
+ check whether this manifest (or the commit ledger it rides on) already
729
+ carries it — see `notes/audit-before-you-build.md`.
730
+
731
+ ---
732
+
733
+ ## 8. Exemptions from cold regen
734
+
735
+ Exactly two, both declared and tracked — never silent:
736
+
737
+ **Sealed components** (component granularity). `sealed: true` + `source_path`.
738
+ The component's spec says only "matches existing behavior; do not
739
+ regenerate." Its code lives at `source_path`, **MUST NOT** be under `gen/`.
740
+ Exempt from `realizes` and the cold-regen invariant. **MUST** have
741
+ characterization tests in `verification/<component>/` the normal way —
742
+ wrapping legacy code in traceability doesn't require rewriting it. Its
743
+ ownership and its last verification are recorded in a sealed provenance
744
+ manifest at `source_path` (§7).
745
+
746
+ **Pinned overrides** (file granularity). Declared in
747
+ `gen/<component>/.overrides.json` — exempted file paths, rationale, owner.
748
+ **MUST** have characterization tests meeting the same bar as a sealed
749
+ component. Visible in the review packet and the corpus graph. Used only when
750
+ a human-authored override is genuinely needed (e.g. a non-functional hot spot
751
+ agents are weak at) — not a general escape from generation.
752
+
753
+ Nothing else is exempt. Hand-edits to `gen/` outside these two declared
754
+ mechanisms are a hard CI failure.
755
+
756
+ ---
757
+
758
+ ## 9. Secrets
759
+
760
+ Unconditional, not a scope question:
761
+
762
+ - Secrets **MUST NOT** appear anywhere in `specs/`, `gen/`, or `verification/`.
763
+ - An automated secret-pattern scan runs pre-merge-gate and, where tooling
764
+ allows, as early as pre-commit/pre-push.
765
+ - Config *contracts* (name, type, required/optional, description) belong in
766
+ `specs/vars/`. Config *values*, and infra-as-code/provisioning, are **out of
767
+ scope** for this methodology — conventionally managed, outside `specs/`.
768
+
769
+ ---
770
+
771
+ ## 10. Single source of truth for computed facts
772
+
773
+ Any atomic fact more than one component could need — a word count, a
774
+ graph relationship, a verification verdict, a provenance field — MUST
775
+ have exactly one canonical definition in the corpus. A second
776
+ component needing the same fact MUST read or query that definition,
777
+ never recompute it independently, however small the computation looks.
778
+ This corpus has already been caught by exactly this gap once
779
+ (`component_size`, `D13`): two independently-written algorithms for the
780
+ same word count, one of them never actually run, silently diverging
781
+ from the other it was supposed to match.
782
+
783
+ - **Before specifying a new computation, check whether it already
784
+ exists** — a shared view (`specs/architecture/graph-query-engine.md`'s
785
+ "Query surface"), an already-written manifest
786
+ (`provenance-writer`'s `.provenance.json`), or another component's
787
+ already-computed result. See `notes/audit-before-you-build.md` for
788
+ the concrete places to check, in order.
789
+ - **When a second component needs a fact one component's spec already
790
+ defines, promote the definition to shared, explicit infrastructure**
791
+ rather than let two components each maintain their own copy — the
792
+ same rule that has grown `graph-query-engine.md`'s shared views from
793
+ two to six so far, each time a second real consumer appeared.
794
+ - **A requirement that claims a specific implementation mechanism
795
+ (`"implemented as queries over X"`, `"MUST reuse Y's exact
796
+ algorithm"`) is a claim about running code, not a description to take
797
+ on faith.** Verify it actually runs, against real data, before
798
+ treating it as settled — `component_size`'s SQL was wrong in three
799
+ separate ways that reading it never would have caught, only running
800
+ it did. An unverified claim like this is itself a single-source-of-
801
+ truth violation in waiting: the spec describes one mechanism, the
802
+ code silently does another, and nothing but careful reading connects
803
+ the two until something breaks.
804
+ - **This is a design-time discipline, not a runtime cache-hit question**
805
+ — don't confuse it with `notes/determinism-trust-playbook.md`'s
806
+ three bands, which classify whether a *result* is safe to reuse
807
+ across calls. This section is about whether a *computation itself*
808
+ has one definition or two.
809
+
810
+ ## 11. What this document does not cover
811
+
812
+ Implementation details — the actual linter, the generation pipeline's code,
813
+ prompt templates, the corpus-graph renderer — live under `pipeline/` and
814
+ `verification/` and are not specified here. This document is the contract
815
+ those implementations must satisfy, not the implementation itself.