@cassiomc1/forgeloop 1.0.0 → 1.1.0

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 (95) hide show
  1. package/.cursor/rules/project-loop.mdc +3 -2
  2. package/.github/copilot-instructions.md +1 -0
  3. package/AGENTS.md +2 -1
  4. package/CLAUDE.md +1 -0
  5. package/DOCS_INDEX.md +36 -0
  6. package/ENG/design-code-eng.md +31 -0
  7. package/ENG/documentation-quality-eng.md +400 -0
  8. package/EXECUTION_STATE.md +23 -13
  9. package/GUIDE_ROUTER.md +23 -8
  10. package/LOOP_ENGINEERING.md +77 -12
  11. package/PROTOCOL_INTEGRATION.md +9 -6
  12. package/README.md +82 -39
  13. package/docs/ARTIFACT_REFERENCE.md +442 -0
  14. package/docs/CLI_REFERENCE.md +892 -0
  15. package/docs/CROSS_HARNESS_CONTINUITY.md +198 -0
  16. package/docs/DOCUMENTATION_GUIDE.md +161 -0
  17. package/docs/GETTING_STARTED.md +348 -0
  18. package/docs/RECIPES.md +250 -0
  19. package/docs/TROUBLESHOOTING.md +345 -0
  20. package/docs/assets/forgeloop-flow.svg +1 -1
  21. package/docs/forgeloop-flow.mmd +1 -1
  22. package/package.json +13 -2
  23. package/schemas/task-descriptor.schema.json +56 -0
  24. package/schemas/work-state.schema.json +18 -1
  25. package/scripts/CI_VALIDATORS.md +7 -0
  26. package/src/cli.js +280 -388
  27. package/src/commands/advance.js +5 -2
  28. package/src/commands/audit.js +11 -1
  29. package/src/commands/clear-continuity.js +5 -2
  30. package/src/commands/clear-state.js +5 -2
  31. package/src/commands/complete.js +9 -1
  32. package/src/commands/continuity.js +5 -2
  33. package/src/commands/inspect.js +10 -2
  34. package/src/commands/next.js +5 -2
  35. package/src/commands/preflight.js +9 -1
  36. package/src/commands/prepare-completion.js +5 -2
  37. package/src/commands/reconcile-continuity.js +5 -2
  38. package/src/commands/record-check.js +7 -1
  39. package/src/commands/record-continuity.js +21 -14
  40. package/src/commands/record-terminal-result.js +7 -1
  41. package/src/commands/route.js +22 -18
  42. package/src/commands/run-check.js +52 -44
  43. package/src/commands/status.js +18 -12
  44. package/src/commands/task-create.js +94 -0
  45. package/src/commands/task-list.js +48 -0
  46. package/src/commands/task-migrate.js +34 -0
  47. package/src/commands/task-scope.js +75 -0
  48. package/src/commands/task-show.js +81 -0
  49. package/src/commands/task-unlock.js +35 -0
  50. package/src/commands/validate-protocol.js +37 -20
  51. package/src/commands/validate-state.js +24 -18
  52. package/src/config/guides.json +42 -0
  53. package/src/core/activation.js +8 -4
  54. package/src/core/artifact-registry.js +166 -0
  55. package/src/core/audit.js +65 -12
  56. package/src/core/bundles.js +76 -50
  57. package/src/core/cli-command-definitions.js +611 -0
  58. package/src/core/cli-metadata.js +23 -0
  59. package/src/core/completion-artifacts.js +161 -74
  60. package/src/core/completion.js +134 -76
  61. package/src/core/continuity.js +20 -13
  62. package/src/core/contract.js +6 -3
  63. package/src/core/error-codes.js +197 -0
  64. package/src/core/events.js +19 -14
  65. package/src/core/execution.js +38 -6
  66. package/src/core/gate-artifact.js +12 -9
  67. package/src/core/gates.js +4 -2
  68. package/src/core/guide-metadata.js +7 -11
  69. package/src/core/guide-registry.js +29 -0
  70. package/src/core/inspect.js +7 -4
  71. package/src/core/native-adapters.js +6 -0
  72. package/src/core/phase.js +85 -33
  73. package/src/core/preflight-consistency.js +24 -14
  74. package/src/core/preflight-loaders.js +16 -11
  75. package/src/core/preflight.js +44 -25
  76. package/src/core/protocol.js +2 -11
  77. package/src/core/receipt.js +1 -1
  78. package/src/core/report.js +2 -2
  79. package/src/core/repository.js +46 -12
  80. package/src/core/resumability.js +6 -4
  81. package/src/core/route-artifact.js +9 -5
  82. package/src/core/router.js +11 -7
  83. package/src/core/schema-validation.js +1 -0
  84. package/src/core/task-command.js +41 -0
  85. package/src/core/task-context.js +126 -0
  86. package/src/core/task-descriptor.js +81 -0
  87. package/src/core/task-discovery.js +116 -0
  88. package/src/core/task-identity.js +76 -0
  89. package/src/core/task-lock.js +209 -0
  90. package/src/core/task-migration-validation.js +140 -0
  91. package/src/core/task-migration.js +361 -0
  92. package/src/core/task-paths.js +96 -0
  93. package/src/core/task-scope.js +179 -0
  94. package/src/core/templates.js +3 -9
  95. package/src/core/work-state.js +24 -13
@@ -0,0 +1,198 @@
1
+ # Cross-Harness Execution Continuity
2
+
3
+ This guide explains how to resume and transfer ForgeLoop tasks across different AI harnesses, IDEs, terminals, and agent runtimes without losing lifecycle state or re-explaining context.
4
+
5
+ ---
6
+
7
+ ## 1. Core Invariants
8
+
9
+ 1. **Harness identity $\neq$ Task identity**
10
+ 2. **Session identity $\neq$ Task identity**
11
+
12
+ Switching between execution environments (for example Codex $\rightarrow$ Claude Code, Claude Code $\rightarrow$ Cursor, or terminal A $\rightarrow$ terminal B) **does not create a new ForgeLoop task**.
13
+
14
+ ```text
15
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
16
+ │ Harness A │ │ Harness B │ │ Developer │
17
+ │ (Claude Code)│ │ (Cursor) │ │ (Terminal) │
18
+ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘
19
+ │ │ │
20
+ └───────────────┬──────┴──────────────────────┘
21
+
22
+ ┌───────────────────────────────────────────────┐
23
+ │ ForgeLoop Task │
24
+ │ .forgeloop/task-state/<taskKey>/work-state.json│
25
+ │ .forgeloop/task-state/<taskKey>/continuity.json│
26
+ │ Hash-chained Event Log │
27
+ └───────────────────────────────────────────────┘
28
+ ```
29
+
30
+ When a new harness starts in a repository where an active task exists, it must discover the existing task, reconcile continuity when present, inspect the checkout, and proceed from the recorded state rather than overwriting the contract.
31
+
32
+ Key continuity invariants:
33
+
34
+ - **Continuity is optional**: A missing `continuity.json` file does not invalidate an otherwise resumable task.
35
+ - **Continuity is non-authoritative**: It provides operational resume hints, not lifecycle truth.
36
+ - **Continuity is not evidence**: It cannot satisfy contract verification requirements.
37
+ - **Task identity survives harness changes**: Work state remains the single source of lifecycle truth.
38
+ - **Stale continuity cannot authorize transitions**: Forward lifecycle progression requires valid work-state checkpoints.
39
+
40
+ ---
41
+
42
+ ## 2. Source-of-Truth Hierarchy
43
+
44
+ | Layer | File / Source | Responsibility | Trust Level |
45
+ | --- | --- | --- | --- |
46
+ | **Task Descriptor** | `.forgeloop/task-state/<taskKey>/task.json` | Task ID, write claims, and task registration | Descriptor authority |
47
+ | **Lifecycle Checkpoint** | `.forgeloop/task-state/<taskKey>/work-state.json` | Current phase, cycle, active guides, preflight binding | Canonical lifecycle truth |
48
+ | **Operational Continuity** | `.forgeloop/task-state/<taskKey>/continuity.json` | Active focus, remaining items, known issues, inspect-first paths | Operational context only (non-evidence) |
49
+ | **Implementation Truth** | Git checkout / filesystem | Actual source code and files | Ground truth for changes |
50
+ | **Task Intent** | `.forgeloop/task-state/<taskKey>/contract.json` | Objectives, constraints, deliverables, verification requirements | Contract authority |
51
+ | **Execution Guidance** | `.forgeloop/task-state/<taskKey>/routing-result.json` | Deterministically selected engineering guides | Guidance |
52
+ | **Verification Provenance** | `.forgeloop/task-state/<taskKey>/executions/*.json` | Attested process execution records | Verification truth |
53
+ | **Next Action** | `forgeloop next` | Deterministic computation of the valid next command | Control authority |
54
+
55
+ > [!IMPORTANT]
56
+ > `continuity.json` provides operational resume context to make transitions smooth. It is **never verification evidence** and **never grants authority**.
57
+
58
+ ---
59
+
60
+ ## 3. Cross-Harness Workflow
61
+
62
+ ```text
63
+ HARNESS A (Finishing / Pausing)
64
+
65
+ ├── Commits or edits code in checkout
66
+ ├── Updates work-state via ForgeLoop CLI
67
+ └── Records operational handoff: `forgeloop record-continuity --task <id>`
68
+
69
+
70
+ Shared Checkout (.forgeloop/task-state/<taskKey>/)
71
+
72
+
73
+ HARNESS B (Starting / Taking Over)
74
+
75
+ ├── 1. Discovers tasks: `forgeloop task-list --json`
76
+ ├── 2. Inspects state: `forgeloop status --task <id> --json`
77
+ ├── 3. Reads continuity: `forgeloop continuity --task <id> --json`
78
+ ├── 4. Reconciles continuity: `forgeloop reconcile-continuity --task <id> --json`
79
+ ├── 5. Inspects modified files: `forgeloop inspect --task <id> --json`
80
+ └── 6. Asks for next action: `forgeloop next --task <id> --json`
81
+
82
+
83
+ Continues execution without duplicating planning
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 4. Harness A — Recording Handoff Context
89
+
90
+ Before pausing, exiting, or transferring control, Harness A records its work in progress:
91
+
92
+ ```bash
93
+ forgeloop record-continuity \
94
+ --task auth-feature \
95
+ --focus-id auth-refresh \
96
+ --focus-summary "Implement refresh-token rotation" \
97
+ --remaining "tests:Add refresh token expiration tests" \
98
+ --remaining "docs:Document token rotation in API guide" \
99
+ --known-issue "rotation:Old token revocation requires redis TTL sync" \
100
+ --changed-area src/auth \
101
+ --changed-area tests/auth \
102
+ --inspect-first src/auth/refresh-token.js \
103
+ --resume-note "Access-token validation is done; continue with refresh-token rotation in src/auth/refresh-token.js."
104
+ ```
105
+
106
+ ### Options Breakdown
107
+
108
+ - `--task <id>`: Target task identifier (or set `FORGELOOP_TASK`).
109
+ - `--focus-id <id>`: Short identifier for the active sub-task.
110
+ - `--focus-summary <text>`: Concise summary of what is currently being worked on.
111
+ - `--remaining <id:summary>`: Remaining work items (repeatable).
112
+ - `--known-issue <id:summary>`: Discovered blockers or edge cases to address (repeatable).
113
+ - `--changed-area <path>`: Directories or file trees modified during this session (repeatable).
114
+ - `--inspect-first <path>`: Recommended starting file for the next harness to read first.
115
+ - `--resume-note <text>`: Operational note explaining immediate context to the next actor.
116
+
117
+ ---
118
+
119
+ ## 5. Harness B — Resuming the Task
120
+
121
+ When Harness B starts in the repository:
122
+
123
+ ### Step 1: Select and Check Task Status
124
+
125
+ If multiple tasks are active, select the target task explicitly using `--task` or `FORGELOOP_TASK`:
126
+
127
+ ```bash
128
+ export FORGELOOP_TASK="auth-feature"
129
+
130
+ forgeloop status --json
131
+ ```
132
+
133
+ Or with explicit flag:
134
+
135
+ ```bash
136
+ forgeloop status --task auth-feature --json
137
+ ```
138
+
139
+ Verify that the task exists and observe the current lifecycle phase (e.g. `EXECUTING` or `VERIFYING`). If multiple tasks exist and no selector is provided, ForgeLoop returns `E_TASK_AMBIGUOUS`.
140
+
141
+ ### Step 2: Read Continuity Context
142
+
143
+ ```bash
144
+ forgeloop continuity --task auth-feature --json
145
+ ```
146
+
147
+ Examine the handoff note, focus ID, remaining items, and inspect-first recommendations.
148
+
149
+ ### Step 3: Reconcile Continuity with Work State
150
+
151
+ ```bash
152
+ forgeloop reconcile-continuity --task auth-feature --json
153
+ ```
154
+
155
+ Reconciliation validates that `continuity.json` matches the current `work-state.json` fingerprint and was not corrupted by external changes.
156
+
157
+ ### Step 4: Inspect Checkout Changes
158
+
159
+ ```bash
160
+ forgeloop inspect --task auth-feature --json
161
+ ```
162
+
163
+ Review modified and newly created files against the contract deliverables and task claims.
164
+
165
+ ### Step 5: Query Next Lifecycle Action
166
+
167
+ ```bash
168
+ forgeloop next --task auth-feature --json
169
+ ```
170
+
171
+ Follow the deterministic action returned by ForgeLoop (e.g. `CONTINUE_IMPLEMENTATION`, `ENTER_VERIFYING`, or `RECORD_CHECK`).
172
+
173
+ ---
174
+
175
+ ## 6. Stale, Inconsistent, or Missing Handoffs
176
+
177
+ ForgeLoop handles edge cases deterministically:
178
+
179
+ | Scenario | Condition | Protocol Behavior | Recommended Action |
180
+ | --- | --- | --- | --- |
181
+ | **Fresh Handoff** | Matching state fingerprint & clean checkout | `VALID` | Continue directly via `forgeloop next` |
182
+ | **Checkout Drift** | State fresh, but files modified out-of-band | `CONTINUITY_RECONCILED` | Run `reconcile-continuity`, inspect diff, continue |
183
+ | **Stale Continuity** | Continuity references older work-state | `STALE_CONTINUITY` | Reconcile or clear continuity (`clear-continuity`), rely on `work-state.json` |
184
+ | **Missing Continuity** | `work-state.json` exists, `continuity.json` absent | `VALID_STATE` | Normal resume from `work-state.json` (continuity is optional) |
185
+ | **Multiple Active Tasks** | No `--task` or `FORGELOOP_TASK` supplied | `E_TASK_AMBIGUOUS` | List tasks with `task-list` and supply `--task` |
186
+ | **Different Task ID** | Contract / state ID mismatch | `TASK_MISMATCH` | Do not merge contexts; complete or clear previous state |
187
+ | **Malformed State** | Corrupted JSON or invalid hash chain | `INVALID` | Fails closed; inspect errors via `forgeloop doctor --json` |
188
+
189
+ ---
190
+
191
+ ## 7. Discovery Adapter Integration
192
+
193
+ Every discovery adapter (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules/project-loop.mdc`, `.github/copilot-instructions.md`) reinforces this invariant:
194
+
195
+ > Before creating or activating new lifecycle state:
196
+ > Discover task namespaces with ForgeLoop; if exactly one active task is healthy it may be selected implicitly; if multiple active tasks exist, select with `--task` or `FORGELOOP_TASK`.
197
+ > Inspect the existing task, reconcile continuity when present, inspect the checkout, and run `forgeloop next`.
198
+ > A change of harness, model, provider, IDE, process, terminal, or session does not create a new task.
@@ -0,0 +1,161 @@
1
+ # ForgeLoop Documentation Guide
2
+
3
+ This guide explains how to maintain, write, and safely modify ForgeLoop documentation.
4
+
5
+ ---
6
+
7
+ ## 1. Canonical Ownership Model
8
+
9
+ ForgeLoop strictly separates normative protocol definitions from operational documentation to avoid contradictory rules.
10
+
11
+ | Area | Location | Responsibility | Rule |
12
+ | --- | --- | --- | --- |
13
+ | **Normative Protocol** | Root (`LOOP_ENGINEERING.md`, `PROTOCOL_INTEGRATION.md`, `LOOP_SYSTEM_DESIGN.md`, `THREAT_MODEL.md`, `EXECUTION_STATE.md`) | Canonical authority for protocol rules, schemas, state transitions, and security | Never duplicate normative rules in sub-documents; link back to root files. |
14
+ | **Operational & Reference** | `docs/` (`GETTING_STARTED.md`, `CROSS_HARNESS_CONTINUITY.md`, `CLI_REFERENCE.md`, `ARTIFACT_REFERENCE.md`, `TROUBLESHOOTING.md`, `RECIPES.md`) | Tutorials, command reference, handoff workflows, and troubleshooting | Explains how to operate the system. Links to normative sources for formal specifications. |
15
+ | **Domain Engineering** | `ENG/` (`clean-code-eng.md`, `design-code-eng.md`, `test-code-eng.md`, etc.) | Domain-specific implementation and quality standards | Frontmatter must adhere to `validate_loop_system.py` standards. |
16
+ | **Consumer Documentation Quality** | [`ENG/documentation-quality-eng.md`](../ENG/documentation-quality-eng.md) | Quality standards for documentation work in projects using ForgeLoop | Governs client/consumer project documentation tasks via guide routing. |
17
+ | **Visual Architecture** | `docs/forgeloop-flow.mmd` | Canonical architecture diagram source | Rendered SVG committed at `docs/assets/forgeloop-flow.svg`. |
18
+ | **Documentation Index** | `DOCS_INDEX.md` | Single repository index and ownership map | Updated whenever documentation structure changes. |
19
+
20
+ ---
21
+
22
+ ## 2. Documentation Source-of-Truth Rules
23
+
24
+ When updating documentation, always derive content from its authoritative source:
25
+
26
+ ```text
27
+ CLI syntax truth -> CLI registry / parser (src/cli.js, src/core/cli-command-definitions.js, src/core/cli-metadata.js)
28
+ Artifact shape truth -> JSON schemas (schemas/*.schema.json, src/core/artifact-registry.js)
29
+ Lifecycle truth -> protocol / state machine (src/core/protocol.js)
30
+ Reason-code truth -> exported protocol constants (src/core/error-codes.js, src/core/protocol.js)
31
+ Guide registry truth -> canonical guide registry (src/config/guides.json)
32
+ Package contents truth -> package.json + package tests (tests/package.test.js)
33
+ Documentation routing -> DOCS_INDEX.md
34
+ ```
35
+
36
+ Operational documentation must explain canonical behavior, not redefine it.
37
+
38
+ ---
39
+
40
+ ## 3. Generated Documentation Provenance & Pipeline
41
+
42
+ ForgeLoop mechanically enforces documentation freshness using deterministic generator targets. If public facts change and documentation regions are not refreshed, CI fails.
43
+
44
+ ```text
45
+ runtime facts
46
+
47
+ canonical registries / schemas
48
+
49
+ deterministic generators (scripts/generate_documentation_reference.mjs)
50
+
51
+ generated Markdown regions (<!-- BEGIN FORGELOOP GENERATED: ... -->)
52
+
53
+ semantic conformance checks (scripts/validate_documentation_conformance.mjs)
54
+
55
+ cross-platform CI (.github/workflows/docs-quality.yml)
56
+ ```
57
+
58
+ ### Provenance Mapping Table
59
+
60
+ | Fact Category | Canonical Machine Source | Generated Target File | Generated Region Marker |
61
+ | --- | --- | --- | --- |
62
+ | **Artifact Inventory** | `ARTIFACT_REGISTRY` (`src/core/artifact-registry.js`) | `docs/ARTIFACT_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: artifact-registry -->` |
63
+ | **Artifact Fields** (12 schemas) | `schemas/*.schema.json` | `docs/ARTIFACT_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: schema:<name> -->` |
64
+ | **CLI Command Index** | `CLI_COMMAND_DEFINITIONS` (`src/core/cli-command-definitions.js`) | `docs/CLI_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: cli-command-index -->` |
65
+ | **CLI Common Options** | `CLI_COMMAND_DEFINITIONS` (`src/core/cli-command-definitions.js`) | `docs/CLI_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: cli-common-options -->` |
66
+ | **CLI Command Options** (27 commands) | `CLI_COMMAND_DEFINITIONS` (`src/core/cli-command-definitions.js`) | `docs/CLI_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: cli:<command>:options -->` |
67
+ | **Public Error Codes** | `PUBLIC_ERROR_CODES` (`src/core/error-codes.js`) | `docs/TROUBLESHOOTING.md` | `<!-- BEGIN FORGELOOP GENERATED: public-error-codes -->` |
68
+ | **Architecture Flow** | `docs/forgeloop-flow.mmd` | `docs/assets/forgeloop-flow.svg` | Verified via embedded SHA-256 fingerprint |
69
+
70
+ ### Maintenance Workflow
71
+
72
+ Whenever CLI definitions, schemas, or error codes change:
73
+
74
+ ```bash
75
+ # 1. Regenerate all deterministic documentation regions
76
+ npm run docs:generate
77
+
78
+ # 2. Run the test suite (includes parser parity and unit tests)
79
+ npm test
80
+
81
+ # 3. Verify freshness, diagram fingerprints, and semantic conformance
82
+ npm run docs:check
83
+ ```
84
+
85
+ ---
86
+
87
+ ## 4. Documentation Conformance Matrix
88
+
89
+ | Documentation Area | Canonical Machine Source | Conformance Validator |
90
+ | --- | --- | --- |
91
+ | **CLI commands & flags** | `CLI_COMMAND_METADATA` (`src/core/cli-metadata.js`) & `src/cli.js` | `scripts/validate_documentation_conformance.mjs` |
92
+ | **Artifact paths** | `ARTIFACT_REGISTRY` & `task-paths.js` | `scripts/validate_documentation_conformance.mjs` |
93
+ | **Artifact fields & types** | `schemas/*.schema.json` | `scripts/validate_documentation_conformance.mjs` |
94
+ | **Enums & consts** | `schemas/*.schema.json` | `scripts/validate_documentation_conformance.mjs` |
95
+ | **Lifecycle phases** | `WORK_PHASES` (`src/core/protocol.js`) | `scripts/validate_documentation_conformance.mjs` |
96
+ | **Stable error codes** | `PUBLIC_ERROR_CODES` (`src/core/error-codes.js`) | `scripts/validate_documentation_conformance.mjs` |
97
+ | **Discovery resume rules** | `DISCOVERY_SURFACES` & `nativeShim` | `scripts/validate_documentation_conformance.mjs` |
98
+ | **Operational path freshness** | `OPERATIONAL_DOCUMENTS` & `task-paths.js` | `scripts/validate_documentation_conformance.mjs` |
99
+ | **Package-shipped docs** | `package.json` (`files`) | `tests/package.test.js` |
100
+ | **Architecture diagram** | `docs/forgeloop-flow.mmd` | `scripts/check-generated-diagram.mjs` |
101
+
102
+ ---
103
+
104
+ ## 5. Normative Language Conventions
105
+
106
+ When writing documentation, use precise terms:
107
+
108
+ - **MUST / MUST NOT**: Strict protocol requirements enforced by schemas or CLI algorithms.
109
+ - **SHOULD / SHOULD NOT**: Strong interoperability recommendations for harnesses.
110
+ - **MAY**: Optional behaviors or flags.
111
+ - **Illustrative**: Non-normative examples provided for human understanding.
112
+
113
+ Avoid ambiguous phrases like *"should generally"* or *"usually"* for behaviors that are strictly enforced by the validator.
114
+
115
+ ### Multi-Task Layout Rules
116
+
117
+ - Canonical task-scoped paths are defined in `src/core/task-paths.js` under `.forgeloop/task-state/<taskKey>/`.
118
+ - Operational guides (`README.md`, `GETTING_STARTED.md`, `RECIPES.md`, `CROSS_HARNESS_CONTINUITY.md`, `TROUBLESHOOTING.md`) must document namespaced paths by default.
119
+ - Legacy ForgeLoop 1.0 singleton paths (e.g. `.forgeloop/current-contract.json`) are permitted **only** inside explicit legacy migration regions:
120
+
121
+ ```markdown
122
+ <!-- BEGIN FORGELOOP LEGACY LAYOUT EXAMPLE -->
123
+ ...
124
+ <!-- END FORGELOOP LEGACY LAYOUT EXAMPLE -->
125
+ ```
126
+
127
+ - `scripts/validate_documentation_conformance.mjs` mechanically rejects any singleton task path outside these markers.
128
+
129
+ ---
130
+
131
+ ## 6. Linking Conventions
132
+
133
+ - **Relative Links Only**: Always use relative markdown links for repository files (e.g. `[`LOOP_ENGINEERING.md`](../LOOP_ENGINEERING.md)`).
134
+ - **Valid Targets**: Every relative link must point to an existing file and is validated by `python3 scripts/validate_markdown.py`.
135
+ - **Anchors**: Anchor links should match standard GitHub heading slugs.
136
+
137
+ ---
138
+
139
+ ## 7. Mermaid Diagrams and SVG Generation
140
+
141
+ 1. **Source is Canonical**: Diagram source files live in `.mmd` files (e.g. `docs/forgeloop-flow.mmd`). Never modify SVG files directly.
142
+ 2. **Local Committed SVGs**: Generated SVGs are committed locally in `docs/assets/`. Never hotlink externally rendered diagram images.
143
+ 3. **Self-Contained & GitHub-Safe**: Generated SVGs must not import external stylesheets (e.g. `@import url(...)`), must not embed `<script>` or `<foreignObject>`, and must be visible via standard Markdown image syntax (`![alt](./path.svg)`).
144
+ 4. **Fingerprint Verification**: Generated SVGs embed a `data-forgeloop-source-sha256` attribute verified by `npm run docs:check`.
145
+
146
+ ---
147
+
148
+ ## 8. Documentation Change Checklist for Pull Requests
149
+
150
+ For documentation-impacting changes, verify each item before merging:
151
+
152
+ - [ ] Did CLI behavior change?
153
+ - [ ] Did any schema field change?
154
+ - [ ] Did any enum or status change?
155
+ - [ ] Did any lifecycle transition change?
156
+ - [ ] Did any artifact mutation rule change?
157
+ - [ ] Did any stable reason/error code change?
158
+ - [ ] Did cross-harness resume behavior change?
159
+ - [ ] Did package-shipped documentation change?
160
+ - [ ] Were generated reference docs updated (`npm run docs:generate`)?
161
+ - [ ] Did documentation conformance CI pass (`npm run docs:check`)?