@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,345 @@
1
+ # ForgeLoop Troubleshooting Guide
2
+
3
+ This guide provides symptom-first recovery procedures for common ForgeLoop protocol, state, and verification issues.
4
+
5
+ ---
6
+
7
+ ## Quick Symptom Index
8
+
9
+ - [`preflight` is `BLOCKED`](#symptom-preflight-is-blocked)
10
+ - [`forgeloop next` returns `RESOLVE_BLOCKER`](#symptom-forgeloop-next-returns-resolve_blocker)
11
+ - [Protocol state or contract is `STALE`](#symptom-state-or-contract-is-stale)
12
+ - [Execution continuity is `STALE`](#symptom-continuity-is-stale)
13
+ - [Multiple tasks ambiguous (`E_TASK_AMBIGUOUS`)](#symptom-multiple-tasks-ambiguous)
14
+ - [Verification tool is missing (`E_VERIFICATION_TOOL_UNAVAILABLE`)](#symptom-verification-tool-is-missing)
15
+ - [Installation authority required (`E_INSTALLATION_AUTHORITY_REQUIRED`)](#symptom-installation-authority-required)
16
+ - [Execution reference invalid (`E_EXECUTION_REF_INVALID`)](#symptom-execution-reference-invalid)
17
+ - [`forgeloop complete` returns `INCOMPLETE`](#symptom-forgeloop-complete-returns-incomplete)
18
+ - [`forgeloop complete` returns `INVALID`](#symptom-forgeloop-complete-returns-invalid)
19
+ - [Another harness cannot resume the task](#symptom-another-harness-cannot-resume)
20
+ - [Stable Error & Reason Code Reference](#stable-error-and-reason-codes)
21
+
22
+ ---
23
+
24
+ ## Symptoms and Recovery
25
+
26
+ ### Symptom: `preflight` is `BLOCKED`
27
+
28
+ #### What it means
29
+
30
+ Pre-implementation gates (e.g. `design`, `threat-boundary`) are unsatisfied, missing, or referencing stale files.
31
+
32
+ #### Likely causes
33
+
34
+ 1. A gate required by an activated guide has no corresponding `.forgeloop/task-state/<taskKey>/gates/<gate>.json` file.
35
+ 2. The gate artifact references files whose SHA-256 hashes changed after the gate was satisfied.
36
+ 3. Contract `unresolvedDecisions` contains blocking decisions.
37
+
38
+ #### Inspect
39
+
40
+ ```bash
41
+ forgeloop task-show --task <id> --json
42
+ forgeloop preflight --task <id> --json
43
+ ```
44
+
45
+ #### Safe recovery
46
+
47
+ 1. If a gate is missing, satisfy required gates or create the gate artifact with status `"satisfied"`.
48
+ 2. If an artifact hash changed, update the artifact SHA-256 in the gate file.
49
+ 3. Re-run `forgeloop preflight --task <id> --json`.
50
+
51
+ #### Do not
52
+
53
+ Do not bypass preflight by manually editing `work-state.json`.
54
+
55
+ ---
56
+
57
+ ### Symptom: `forgeloop next` returns `RESOLVE_BLOCKER`
58
+
59
+ #### What it means
60
+
61
+ The protocol has encountered a condition that prevents automatic progression until an explicit blocker is resolved.
62
+
63
+ #### Likely causes
64
+
65
+ 1. Task `work-state.json` was deleted or is out of sync with `contract.json`.
66
+ 2. A verification check failed and no diagnostic hypothesis was recorded.
67
+ 3. A required gate is unsatisfied.
68
+
69
+ #### Inspect
70
+
71
+ ```bash
72
+ forgeloop status --task <id> --json
73
+ forgeloop next --task <id> --json
74
+ ```
75
+
76
+ #### Safe recovery
77
+
78
+ 1. Check the `reasons` field in the `forgeloop next --json` output.
79
+ 2. Follow the suggested command in `commands` or `commandSpecs`.
80
+ 3. If in `VERIFYING` after a failure, record a hypothesis, apply the fix, and re-run `run-check`.
81
+
82
+ ---
83
+
84
+ ### Symptom: State or Contract is `STALE`
85
+
86
+ #### What it means
87
+
88
+ An upstream artifact was modified, invalidating downstream cryptographic fingerprint bindings.
89
+
90
+ #### Likely causes
91
+
92
+ 1. `contract.json` was edited after `work-state.json` or `routing-result.json` was created (`E_CONTRACT_STALE`).
93
+ 2. Git `HEAD` changed (commit or checkout) while in `EXECUTING` or `VERIFYING`.
94
+
95
+ #### Inspect
96
+
97
+ ```bash
98
+ forgeloop task-show --task <id> --json
99
+ forgeloop status --task <id> --json
100
+ ```
101
+
102
+ #### Safe recovery
103
+
104
+ 1. If the contract changed intentionally:
105
+
106
+ ```bash
107
+ forgeloop route --task <id> --work <type> [options] --json
108
+ forgeloop preflight --task <id> --json
109
+ ```
110
+
111
+ 2. Re-validate state:
112
+
113
+ ```bash
114
+ forgeloop validate-protocol --task <id> --json
115
+ ```
116
+
117
+ ---
118
+
119
+ ### Symptom: Continuity is `STALE`
120
+
121
+ #### What it means
122
+
123
+ `.forgeloop/task-state/<taskKey>/continuity.json` references a previous `work-state.json` fingerprint or older checkout state.
124
+
125
+ #### Likely causes
126
+
127
+ Another harness or developer committed changes or advanced lifecycle phases without updating continuity.
128
+
129
+ #### Inspect
130
+
131
+ ```bash
132
+ forgeloop continuity --task <id> --json
133
+ ```
134
+
135
+ #### Safe recovery
136
+
137
+ 1. Reconcile continuity with current state:
138
+
139
+ ```bash
140
+ forgeloop reconcile-continuity --task <id> --json
141
+ ```
142
+
143
+ 2. If continuity is obsolete, clear it:
144
+
145
+ ```bash
146
+ forgeloop clear-continuity --task <id>
147
+ ```
148
+
149
+ *Note: Clearing continuity does not lose lifecycle state; `work-state.json` remains intact.*
150
+
151
+ ---
152
+
153
+ ### Symptom: Multiple Tasks Ambiguous
154
+
155
+ #### Error Code: `E_TASK_AMBIGUOUS`
156
+
157
+ #### What it means
158
+
159
+ Multiple active tasks exist in `.forgeloop/task-state/`, but the command was run without an explicit `--task` flag or `FORGELOOP_TASK` environment variable.
160
+
161
+ #### Inspect
162
+
163
+ ```bash
164
+ forgeloop task-list --json
165
+ ```
166
+
167
+ #### Safe recovery
168
+
169
+ Specify the task ID explicitly using the `--task` flag:
170
+
171
+ ```bash
172
+ forgeloop status --task <task-id> --json
173
+ forgeloop next --task <task-id> --json
174
+ ```
175
+
176
+ Or set the environment variable for your shell session:
177
+
178
+ ```bash
179
+ export FORGELOOP_TASK="<task-id>"
180
+ ```
181
+
182
+ ---
183
+
184
+ ### Symptom: Verification Tool is Missing
185
+
186
+ #### Error Code: `E_VERIFICATION_TOOL_UNAVAILABLE`
187
+
188
+ #### What it means
189
+
190
+ A verification check requires an executable or tool that is not installed in the local environment.
191
+
192
+ #### Likely causes
193
+
194
+ 1. The toolchain is missing a package or global binary (e.g. `linter`, `test runner`).
195
+ 2. Running in an isolated or sandboxed environment without network access.
196
+
197
+ #### Safe recovery
198
+
199
+ 1. Use an already available local equivalent (e.g. `node scripts/run-tests.js` instead of an external runner).
200
+ 2. If an authorized host authority grant is available, install the tool.
201
+ 3. If no equivalent exists and installation is unauthorized, record the check as `NOT_VERIFIED` or `BLOCKED`.
202
+
203
+ #### Do not
204
+
205
+ **Do not run ad-hoc install commands (e.g. `npm i -g tool` or `npx tool`) without explicit operator authority.**
206
+
207
+ ---
208
+
209
+ ### Symptom: Installation Authority Required
210
+
211
+ #### Error Code: `E_INSTALLATION_AUTHORITY_REQUIRED`
212
+
213
+ #### What it means
214
+
215
+ ForgeLoop intercepted a command that attempted to install software or fetch remote packages without a verified host authority grant.
216
+
217
+ #### Likely causes
218
+
219
+ Running `npx`, `npm install`, `yarn add`, or `pnpm add` during `run-check` or `record-check`.
220
+
221
+ #### Safe recovery
222
+
223
+ Use non-installing execution equivalents (e.g. `npm test`, `node <script>`, `./node_modules/.bin/<tool>`).
224
+
225
+ ---
226
+
227
+ ### Symptom: Execution Reference Invalid
228
+
229
+ #### Error Code: `E_EXECUTION_REF_INVALID`
230
+
231
+ #### What it means
232
+
233
+ A check was claimed with a reference to an execution ID that does not exist in `.forgeloop/task-state/<taskKey>/executions/`.
234
+
235
+ #### Safe recovery
236
+
237
+ Execute the check through ForgeLoop CLI so that execution provenance is attested:
238
+
239
+ ```bash
240
+ forgeloop run-check --task <id> --id <check-id> --requirement <requirement-id> -- <command...>
241
+ ```
242
+
243
+ ---
244
+
245
+ ### Symptom: `forgeloop complete` returns `INCOMPLETE`
246
+
247
+ #### What it means
248
+
249
+ One or more contract success criteria have not been covered by passing verification checks.
250
+
251
+ #### Inspect
252
+
253
+ ```bash
254
+ forgeloop audit --task <id> --json
255
+ ```
256
+
257
+ Inspect the `coverage` array to find items with status `"NOT_VERIFIED"` or `"FAILED"`.
258
+
259
+ #### Safe recovery
260
+
261
+ 1. Advance to `VERIFYING` if not already there:
262
+
263
+ ```bash
264
+ forgeloop advance --task <id> --to VERIFYING
265
+ ```
266
+
267
+ 2. Execute the missing check:
268
+
269
+ ```bash
270
+ forgeloop run-check --task <id> --id <id> --requirement <uncovered-requirement> -- <command...>
271
+ ```
272
+
273
+ 3. Advance to `REVIEWING` and retry `forgeloop complete --task <id> --json`.
274
+
275
+ ---
276
+
277
+ ### Symptom: `forgeloop complete` returns `INVALID`
278
+
279
+ #### What it means
280
+
281
+ Protocol integrity checks failed (e.g. ledger sequence error, missing contract deliverable, or hash mismatch).
282
+
283
+ #### Inspect
284
+
285
+ ```bash
286
+ forgeloop validate-protocol --task <id> --json
287
+ ```
288
+
289
+ #### Safe recovery
290
+
291
+ Inspect the specific error reported in `errors[]` and correct the inconsistent artifact.
292
+
293
+ ---
294
+
295
+ ### Symptom: Another Harness Cannot Resume
296
+
297
+ #### Likely causes
298
+
299
+ 1. The new harness started by creating a new contract instead of discovering existing tasks via `task-list` or `status`.
300
+ 2. State is locked in a terminal or blocked condition.
301
+
302
+ #### Safe recovery
303
+
304
+ In the new harness:
305
+
306
+ ```bash
307
+ # 1. Discover existing state
308
+ forgeloop task-list --json
309
+ forgeloop status --task <id> --json
310
+
311
+ # 2. Reconcile continuity
312
+ forgeloop reconcile-continuity --task <id> --json
313
+
314
+ # 3. Ask for next action
315
+ forgeloop next --task <id> --json
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Stable Error and Reason Codes
321
+
322
+ <!-- BEGIN FORGELOOP GENERATED: public-error-codes -->
323
+
324
+ | Code | Meaning | Safe Resolution |
325
+ | --- | --- | --- |
326
+ | `E_PREFLIGHT_NOT_READY` | Preflight gates or contract validations are incomplete. | Satisfy required gates and check preflight output. |
327
+ | `E_CONTRACT_STALE` | Contract modified after downstream artifacts were generated. | Re-run forgeloop route and forgeloop preflight. |
328
+ | `E_ROUTE_STALE` | Routing result does not match the active contract fingerprint. | Re-run forgeloop route. |
329
+ | `E_GATE_STALE` | Referenced gate artifact changed after approval. | Update artifact SHA-256 in gate file. |
330
+ | `E_VERIFICATION_TOOL_UNAVAILABLE` | Required verification executable is missing in environment. | Use local equivalent, obtain host authority, or record NOT_VERIFIED. |
331
+ | `E_INSTALLATION_AUTHORITY_REQUIRED` | Attempted software installation without host authority grant. | Use local non-installing binaries or request host authority grant. |
332
+ | `E_AUTHORITY_INVALID` | Authority grant file is malformed or expired. | Obtain a valid authority grant from host operator. |
333
+ | `E_AUTHORITY_SCOPE_MISMATCH` | Authority grant does not cover the requested package. | Request updated authority scope. |
334
+ | `E_AUTHORITY_UNTRUSTED_SOURCE` | Authority file placed inside untrusted project tree. | Place authority file in host-managed trusted location. |
335
+ | `E_EXECUTION_REF_INVALID` | Referenced execution ID does not exist. | Re-run check via forgeloop run-check. |
336
+ | `E_CHECK_INVALID` | Check structure or required parameters are invalid. | Provide valid check ID, requirement, and parameters. |
337
+ | `E_RECEIPT_STATE_MISMATCH` | Receipt does not match current state cycle or work state. | Run forgeloop prepare-completion --json. |
338
+ | `E_CONTINUITY_RECONCILIATION_REQUIRED` | Continuity context has drifted from work state. | Run forgeloop reconcile-continuity --json. |
339
+ | `E_TASK_AMBIGUOUS` | Multiple tasks exist in the project but no task selector was provided. | Select a task explicitly using --task <id> or FORGELOOP_TASK=<id>. |
340
+ | `E_TASK_LOCKED` | Task mutation is currently locked by another concurrent process or run-check. | Wait for the active mutation to complete or inspect the lock with forgeloop task-show. |
341
+ | `E_TASK_SCOPE_CONFLICT` | Task write claims overlap with another non-complete task in the same checkout. | Adjust write claims to non-overlapping paths or run tasks in separate worktrees. |
342
+ | `E_TASK_SCOPE_DIRTY` | Claimed paths contain pre-existing uncommitted changes. | Commit or stash changes in claimed paths before defining or adopting the scope. |
343
+ | `E_TASK_CHANGE_OUTSIDE_SCOPE` | Modified paths in repository exceed the declared task write claims. | Update write claims with forgeloop task-scope or revert out-of-scope modifications. |
344
+
345
+ <!-- END FORGELOOP GENERATED: public-error-codes -->