@cassiomc1/forgeloop 1.1.1 → 1.2.2
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.
- package/.cursor/rules/project-loop.mdc +1 -1
- package/.github/copilot-instructions.md +1 -1
- package/AGENTS.md +1 -1
- package/CLAUDE.md +1 -1
- package/DOCS_INDEX.md +3 -0
- package/ENG/design-code-eng.md +124 -0
- package/ENG/premium-sites-studio-eng.md +28 -0
- package/ENG/taste-frontend-eng.md +3 -2
- package/ENG/test-code-eng.md +45 -0
- package/LOOP_ENGINEERING.md +74 -0
- package/LOOP_SYSTEM_DESIGN.md +9 -5
- package/ORCHESTRATOR_INTEGRATION.md +41 -6
- package/PROTOCOL_INTEGRATION.md +13 -0
- package/README.md +40 -6
- package/TERMINOLOGY.md +10 -0
- package/THIRD_PARTY_NOTICES.md +58 -1
- package/THREAT_MODEL.md +12 -1
- package/docs/ARTIFACT_REFERENCE.md +152 -2
- package/docs/CLI_REFERENCE.md +346 -30
- package/docs/CROSS_HARNESS_CONTINUITY.md +1 -0
- package/docs/DOCUMENTATION_GUIDE.md +41 -4
- package/docs/GETTING_STARTED.md +39 -8
- package/docs/RECIPES.md +66 -7
- package/docs/TROUBLESHOOTING.md +279 -6
- package/package.json +1 -1
- package/schemas/policy-baseline.schema.json +26 -0
- package/schemas/policy-discovery.schema.json +45 -0
- package/schemas/policy-lock.schema.json +16 -0
- package/schemas/policy-rules.schema.json +48 -0
- package/schemas/policy-snapshot.schema.json +16 -0
- package/src/cli.js +102 -1
- package/src/commands/baseline.js +120 -0
- package/src/commands/init.js +304 -6
- package/src/commands/next.js +15 -1
- package/src/commands/policy-diff.js +51 -0
- package/src/commands/policy-discover.js +42 -0
- package/src/commands/policy-status.js +33 -0
- package/src/commands/profile-interview.js +50 -0
- package/src/commands/progress.js +51 -0
- package/src/commands/reconcile-closure.js +49 -0
- package/src/commands/record-decision-criterion.js +34 -0
- package/src/commands/record-diagnosis.js +49 -0
- package/src/commands/rule-verify.js +36 -0
- package/src/commands/validate-receipt.js +38 -3
- package/src/core/artifact-registry.js +60 -0
- package/src/core/audit.js +24 -0
- package/src/core/cli-command-definitions.js +163 -7
- package/src/core/cli-metadata.js +1 -1
- package/src/core/completion-artifacts.js +29 -3
- package/src/core/completion.js +101 -10
- package/src/core/diagnosis-model.js +214 -0
- package/src/core/diagnosis.js +171 -0
- package/src/core/error-codes.js +292 -0
- package/src/core/events.js +47 -1
- package/src/core/execution-prerequisites.js +38 -20
- package/src/core/execution.js +20 -3
- package/src/core/native-adapters.js +14 -4
- package/src/core/next-action-model.js +40 -5
- package/src/core/next-action.js +234 -91
- package/src/core/phase.js +29 -0
- package/src/core/policy-adapters.js +276 -0
- package/src/core/policy-baseline.js +144 -0
- package/src/core/policy-diff.js +133 -0
- package/src/core/policy-discovery.js +225 -0
- package/src/core/policy-engine.js +533 -0
- package/src/core/policy-mutation.js +139 -0
- package/src/core/preflight-consistency.js +23 -15
- package/src/core/preflight-model.js +10 -2
- package/src/core/preflight.js +65 -1
- package/src/core/progress.js +143 -0
- package/src/core/protocol.js +8 -0
- package/src/core/reconcile-closure.js +173 -0
- package/src/core/schema-validation.js +6 -0
- package/src/core/settlement-model.js +85 -0
- package/src/core/settlement.js +78 -0
- package/src/core/task-context.js +11 -0
- package/src/core/task-discovery.js +67 -1
- package/src/core/task-paths.js +9 -0
- package/src/core/templates.js +5 -0
package/docs/GETTING_STARTED.md
CHANGED
|
@@ -191,6 +191,8 @@ Output:
|
|
|
191
191
|
|
|
192
192
|
When preflight returns `READY`, ForgeLoop synchronizes resumable work state (`.forgeloop/task-state/<taskKey>/work-state.json`) and preflight status (`.forgeloop/task-state/<taskKey>/preflight.json`). If preflight reports `BLOCKED`, inspect the required gates in the output and satisfy them first.
|
|
193
193
|
|
|
194
|
+
If executable policy artifacts exist under `.forgeloop/policy/`, preflight also captures the effective rules and baseline into `.forgeloop/task-state/<taskKey>/policy-snapshot.json` so later policy drift can be detected. Malformed policy artifacts block preflight with `E_POLICY_INVALID`. See [LOOP_ENGINEERING.md](../LOOP_ENGINEERING.md#executable-policy--autonomy-preserving-invariants).
|
|
195
|
+
|
|
194
196
|
---
|
|
195
197
|
|
|
196
198
|
### Step 4 — Activate Session and Plan
|
|
@@ -198,10 +200,12 @@ When preflight returns `READY`, ForgeLoop synchronizes resumable work state (`.f
|
|
|
198
200
|
Create a session activation marker and transition to `PLANNED`:
|
|
199
201
|
|
|
200
202
|
```bash
|
|
201
|
-
forgeloop activate
|
|
203
|
+
forgeloop activate
|
|
202
204
|
forgeloop advance --task task-contact-form-001 --to PLANNED
|
|
203
205
|
```
|
|
204
206
|
|
|
207
|
+
`activate` is session-scoped, not task-scoped: it records the current harness session (`.forgeloop/sessions/<sessionId>.json`) and does not accept `--task`.
|
|
208
|
+
|
|
205
209
|
---
|
|
206
210
|
|
|
207
211
|
### Step 5 — Implement
|
|
@@ -237,10 +241,36 @@ forgeloop run-check --task task-contact-form-001 --id lint --requirement "npm ru
|
|
|
237
241
|
|
|
238
242
|
If a check fails:
|
|
239
243
|
|
|
240
|
-
1.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
1. Advance to `DIAGNOSING`:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
forgeloop advance --task task-contact-form-001 --to DIAGNOSING
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
2. Record an append-only root-cause diagnosis in the event ledger:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
forgeloop record-diagnosis \
|
|
254
|
+
--task task-contact-form-001 \
|
|
255
|
+
--hypothesis="Form validation regex incorrectly rejects valid domain formats" \
|
|
256
|
+
--failure-class="VERIFICATION_FAILURE" \
|
|
257
|
+
--evidence-ref="unit-tests" \
|
|
258
|
+
--settled-by="All domain validation unit tests pass" \
|
|
259
|
+
--next-safe-action="Update email domain regex in ContactForm.jsx"
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
3. Advance to `CORRECTING` and apply the fix:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
forgeloop advance --task task-contact-form-001 --to CORRECTING
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
4. Re-enter `VERIFYING` (advances `verificationCycle` monotonically) and re-run checks:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
forgeloop advance --task task-contact-form-001 --to VERIFYING
|
|
272
|
+
forgeloop run-check --task task-contact-form-001 --id unit-tests --requirement "npm test passes for contact form" -- npm test
|
|
273
|
+
```
|
|
244
274
|
|
|
245
275
|
---
|
|
246
276
|
|
|
@@ -271,7 +301,7 @@ Output:
|
|
|
271
301
|
{
|
|
272
302
|
"status": "VALID",
|
|
273
303
|
"taskStatus": "COMPLETE",
|
|
274
|
-
"verificationStatus": "
|
|
304
|
+
"verificationStatus": "VALID"
|
|
275
305
|
}
|
|
276
306
|
```
|
|
277
307
|
|
|
@@ -316,9 +346,10 @@ Under `.forgeloop/task-state/<taskKey>/`:
|
|
|
316
346
|
- `work-state.json`: lifecycle phase and resumption checkpoint;
|
|
317
347
|
- `events.ndjson`: hash-chained append-only event ledger;
|
|
318
348
|
- `executions/*.json`: provenance records for executed verification commands;
|
|
319
|
-
- `execution-receipt.json`: completion evidence and coverage mapping
|
|
349
|
+
- `execution-receipt.json`: completion evidence and coverage mapping;
|
|
350
|
+
- `policy-snapshot.json`: effective policy and baseline captured at preflight (created when executable policy is configured).
|
|
320
351
|
|
|
321
|
-
Shared repository artifacts (`sources.json`, `config.json`) remain at `.forgeloop/`.
|
|
352
|
+
Shared repository artifacts (`sources.json`, `config.json`) remain at `.forgeloop/`. When executable policy is configured, its shared artifacts live under `.forgeloop/policy/` (`rules.json`, `baseline.json`, `policy.lock`, `discovery.json`).
|
|
322
353
|
|
|
323
354
|
---
|
|
324
355
|
|
package/docs/RECIPES.md
CHANGED
|
@@ -18,6 +18,8 @@ Concise, copy-paste friendly recipes for common ForgeLoop tasks.
|
|
|
18
18
|
10. [Final Verification Before Pull Request](#recipe-10--final-verification-before-pull-request)
|
|
19
19
|
11. [Run Multi-Task Workflows Concurrently](#recipe-11--run-multi-task-workflows-concurrently)
|
|
20
20
|
12. [Migrate Legacy 1.0 Single-Task Layout](#recipe-12--migrate-legacy-10-single-task-layout)
|
|
21
|
+
13. [Record Decision Settlement Criteria](#recipe-13--record-decision-settlement-criteria)
|
|
22
|
+
14. [Executable Policy, Baseline Ratchet, and Recovery](#recipe-14--executable-policy-baseline-ratchet-and-recovery)
|
|
21
23
|
|
|
22
24
|
---
|
|
23
25
|
|
|
@@ -37,7 +39,7 @@ forgeloop route --task task-001 --work code --surface api --risk untrusted-input
|
|
|
37
39
|
forgeloop preflight --task task-001 --json
|
|
38
40
|
|
|
39
41
|
# 5. Activate session and plan
|
|
40
|
-
forgeloop activate
|
|
42
|
+
forgeloop activate
|
|
41
43
|
forgeloop advance --task task-001 --to PLANNED
|
|
42
44
|
forgeloop advance --task task-001 --to EXECUTING
|
|
43
45
|
```
|
|
@@ -98,16 +100,29 @@ export FORGELOOP_TASK="task-001"
|
|
|
98
100
|
forgeloop run-check --id unit-tests --requirement "All tests pass" -- npm test
|
|
99
101
|
# Output: status = failed
|
|
100
102
|
|
|
101
|
-
# 2.
|
|
102
|
-
forgeloop
|
|
103
|
+
# 2. Advance to DIAGNOSING
|
|
104
|
+
forgeloop advance --to DIAGNOSING
|
|
105
|
+
|
|
106
|
+
# 3. Record append-only root-cause diagnosis in ledger
|
|
107
|
+
forgeloop record-diagnosis \
|
|
108
|
+
--hypothesis="Edge case comparison operator <= instead of < in validator" \
|
|
109
|
+
--failure-class="VERIFICATION_FAILURE" \
|
|
110
|
+
--evidence-ref="unit-tests" \
|
|
111
|
+
--settled-by="Boundary test passes with status 400" \
|
|
112
|
+
--next-safe-action="Replace <= with < in validator.js"
|
|
103
113
|
|
|
104
|
-
#
|
|
114
|
+
# 4. Advance to CORRECTING and apply the fix
|
|
115
|
+
forgeloop advance --to CORRECTING
|
|
116
|
+
|
|
117
|
+
# 5. Re-enter VERIFYING (advances verificationCycle monotonically)
|
|
118
|
+
forgeloop advance --to VERIFYING
|
|
105
119
|
|
|
106
|
-
#
|
|
120
|
+
# 6. Re-run verification check
|
|
107
121
|
forgeloop run-check --id unit-tests --requirement "All tests pass" -- npm test
|
|
108
122
|
|
|
109
|
-
#
|
|
110
|
-
forgeloop
|
|
123
|
+
# 7. Advance to REVIEWING and complete
|
|
124
|
+
forgeloop advance --to REVIEWING
|
|
125
|
+
forgeloop complete --json
|
|
111
126
|
```
|
|
112
127
|
|
|
113
128
|
---
|
|
@@ -248,3 +263,47 @@ forgeloop task-migrate --json
|
|
|
248
263
|
forgeloop task-list --json
|
|
249
264
|
forgeloop status --json
|
|
250
265
|
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### Recipe 13 — Record Decision Settlement Criteria
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# 1. Record an append-only settlement criterion bound to the active contract
|
|
273
|
+
forgeloop record-decision-criterion \
|
|
274
|
+
--task task-001 \
|
|
275
|
+
--decision="Which authentication provider should be used?" \
|
|
276
|
+
--settled-by="Use provider with native support for current JWT session tokens"
|
|
277
|
+
|
|
278
|
+
# 2. Inspect next action (surfaces the guidance)
|
|
279
|
+
forgeloop next --task task-001
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Recipe 14 — Executable Policy, Baseline Ratchet, and Recovery
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# 1. Discover architecture conventions and candidate rules
|
|
288
|
+
# (read-only observation; add --write to persist discovery and regenerate the lock)
|
|
289
|
+
forgeloop policy-discover --json
|
|
290
|
+
|
|
291
|
+
# 2. Record pre-existing debt into brownfield baseline
|
|
292
|
+
forgeloop baseline --record --json
|
|
293
|
+
|
|
294
|
+
# 3. Check policy verification status and lock integrity
|
|
295
|
+
forgeloop policy-status --json
|
|
296
|
+
|
|
297
|
+
# 4. Prove checker efficacy against mutation fixtures
|
|
298
|
+
forgeloop rule-verify --rule SECURITY.NO_HARDCODED_SECRET --json
|
|
299
|
+
|
|
300
|
+
# 5. Ratchet down baseline as debt is resolved during task
|
|
301
|
+
forgeloop baseline --update --json
|
|
302
|
+
|
|
303
|
+
# 6. If policy weakens mid-task, inspect next recovery action
|
|
304
|
+
forgeloop next --task task-001 --json
|
|
305
|
+
# Follow returned action (e.g. RESTORE_POLICY, REPAIR_CHECKER, REPAIR_POLICY)
|
|
306
|
+
|
|
307
|
+
# Intentional operator-authorized baseline reset (not normal recovery)
|
|
308
|
+
forgeloop baseline --record --policy-reset-authorized --json
|
|
309
|
+
```
|
package/docs/TROUBLESHOOTING.md
CHANGED
|
@@ -8,6 +8,8 @@ This guide provides symptom-first recovery procedures for common ForgeLoop proto
|
|
|
8
8
|
|
|
9
9
|
- [`preflight` is `BLOCKED`](#symptom-preflight-is-blocked)
|
|
10
10
|
- [`forgeloop next` returns `RESOLVE_BLOCKER`](#symptom-forgeloop-next-returns-resolve_blocker)
|
|
11
|
+
- [`forgeloop next` returns `RECORD_DIAGNOSIS`](#symptom-forgeloop-next-returns-record_diagnosis)
|
|
12
|
+
- [Progress is `STALLED` or `forgeloop next` returns `CHANGE_STRATEGY`](#symptom-progress-is-stalled)
|
|
11
13
|
- [Protocol state or contract is `STALE`](#symptom-state-or-contract-is-stale)
|
|
12
14
|
- [Execution continuity is `STALE`](#symptom-continuity-is-stale)
|
|
13
15
|
- [Multiple tasks ambiguous (`E_TASK_AMBIGUOUS`)](#symptom-multiple-tasks-ambiguous)
|
|
@@ -16,6 +18,11 @@ This guide provides symptom-first recovery procedures for common ForgeLoop proto
|
|
|
16
18
|
- [Execution reference invalid (`E_EXECUTION_REF_INVALID`)](#symptom-execution-reference-invalid)
|
|
17
19
|
- [`forgeloop complete` returns `INCOMPLETE`](#symptom-forgeloop-complete-returns-incomplete)
|
|
18
20
|
- [`forgeloop complete` returns `INVALID`](#symptom-forgeloop-complete-returns-invalid)
|
|
21
|
+
- [Policy lock mismatch (`E_POLICY_LOCK_MISMATCH`)](#symptom-policy-lock-mismatch)
|
|
22
|
+
- [Invalid policy artifacts fail closed (`E_POLICY_INVALID`)](#symptom-invalid-policy-artifacts-fail-closed)
|
|
23
|
+
- [Policy weakening detected (`E_POLICY_WEAKENING`)](#symptom-policy-weakening-detected)
|
|
24
|
+
- [Baseline re-record blocked during active task (`E_BASELINE_RECORD_DURING_ACTIVE_TASK`)](#symptom-baseline-re-record-blocked-during-active-task)
|
|
25
|
+
- [Mutation checker execution error (`E_CHECK_MUTATION_EXECUTION_ERROR`)](#symptom-mutation-checker-execution-error)
|
|
19
26
|
- [Another harness cannot resume the task](#symptom-another-harness-cannot-resume)
|
|
20
27
|
- [Stable Error & Reason Code Reference](#stable-error-and-reason-codes)
|
|
21
28
|
|
|
@@ -27,26 +34,30 @@ This guide provides symptom-first recovery procedures for common ForgeLoop proto
|
|
|
27
34
|
|
|
28
35
|
#### What it means
|
|
29
36
|
|
|
30
|
-
Pre-implementation gates (e.g. `design`, `threat-boundary`) are unsatisfied, missing, or referencing stale files.
|
|
37
|
+
Pre-implementation gates (e.g. `design`, `threat-boundary`) are unsatisfied, missing, or referencing stale files, or the contract contains unresolved blocking decisions. ForgeLoop preserves specific preflight error codes (`E_CONTRACT_UNRESOLVED_DECISION`, `E_CONTRACT_STALE`, `E_ROUTE_STALE`, `E_GATE_UNVERIFIED`) in `reasons` instead of reducing them to generic readiness errors.
|
|
31
38
|
|
|
32
39
|
#### Likely causes
|
|
33
40
|
|
|
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.
|
|
41
|
+
1. A gate required by an activated guide has no corresponding `.forgeloop/task-state/<taskKey>/gates/<gate>.json` file (`E_GATE_UNVERIFIED`).
|
|
42
|
+
2. The gate artifact references files whose SHA-256 hashes changed after the gate was satisfied (`E_GATE_STALE`).
|
|
43
|
+
3. Contract `unresolvedDecisions` contains blocking decisions (`E_CONTRACT_UNRESOLVED_DECISION`).
|
|
37
44
|
|
|
38
45
|
#### Inspect
|
|
39
46
|
|
|
40
47
|
```bash
|
|
41
48
|
forgeloop task-show --task <id> --json
|
|
42
49
|
forgeloop preflight --task <id> --json
|
|
50
|
+
forgeloop next --task <id> --json
|
|
43
51
|
```
|
|
44
52
|
|
|
45
53
|
#### Safe recovery
|
|
46
54
|
|
|
47
55
|
1. If a gate is missing, satisfy required gates or create the gate artifact with status `"satisfied"`.
|
|
48
56
|
2. If an artifact hash changed, update the artifact SHA-256 in the gate file.
|
|
49
|
-
3.
|
|
57
|
+
3. If `unresolvedDecisions` contains blocking items:
|
|
58
|
+
- Record settlement guidance with `forgeloop record-decision-criterion --decision="..." --settled-by="..."` to provide context.
|
|
59
|
+
- Resolve or remove the blocking decision in `contract.json`.
|
|
60
|
+
4. Re-run `forgeloop preflight --task <id> --json`.
|
|
50
61
|
|
|
51
62
|
#### Do not
|
|
52
63
|
|
|
@@ -77,7 +88,75 @@ forgeloop next --task <id> --json
|
|
|
77
88
|
|
|
78
89
|
1. Check the `reasons` field in the `forgeloop next --json` output.
|
|
79
90
|
2. Follow the suggested command in `commands` or `commandSpecs`.
|
|
80
|
-
3. If in `VERIFYING` after a failure, record a
|
|
91
|
+
3. If in `VERIFYING` after a failure, advance to `DIAGNOSING`, record a diagnosis with `forgeloop record-diagnosis`, and advance to `CORRECTING`.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### Symptom: `forgeloop next` returns `RECORD_DIAGNOSIS`
|
|
96
|
+
|
|
97
|
+
#### What it means
|
|
98
|
+
|
|
99
|
+
The task is in `DIAGNOSING` phase following a verification failure, but no append-only diagnosis event (`DIAGNOSIS_RECORDED`) has been recorded for the active verification cycle (`E_DIAGNOSIS_REQUIRED`).
|
|
100
|
+
|
|
101
|
+
#### Likely causes
|
|
102
|
+
|
|
103
|
+
1. A check failed in `VERIFYING` and the phase was advanced to `DIAGNOSING` without calling `record-diagnosis`.
|
|
104
|
+
2. An attempt was made to advance directly to `CORRECTING` without recording an evidence-backed root cause hypothesis.
|
|
105
|
+
|
|
106
|
+
#### Inspect
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
forgeloop status --task <id> --json
|
|
110
|
+
forgeloop next --task <id> --json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### Safe recovery
|
|
114
|
+
|
|
115
|
+
Record an append-only diagnosis referencing at least one failed or blocked check from the current verification cycle:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
forgeloop record-diagnosis --task <id> \
|
|
119
|
+
--hypothesis="Root cause explanation" \
|
|
120
|
+
--failure-class="VERIFICATION_FAILURE" \
|
|
121
|
+
--evidence-ref="failed-check-id" \
|
|
122
|
+
--settled-by="Observable condition that settles the hypothesis" \
|
|
123
|
+
--next-safe-action="Smallest safe action to address the hypothesis"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Then advance to `CORRECTING`:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
forgeloop advance --task <id> --to CORRECTING
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### Symptom: Progress is `STALLED`
|
|
135
|
+
|
|
136
|
+
#### What it means
|
|
137
|
+
|
|
138
|
+
Deterministic progress evaluation detected that iterative correction cycles are not advancing (`E_PROGRESS_STALLED`). The latest diagnosis produced `informationGain: NONE` (signal `NO_DIAGNOSTIC_INFORMATION_GAIN`), or a specific contract requirement failed across 3+ verification cycles with an identical diagnosis (`REPEATED_FAILURE_WITH_SAME_DIAGNOSIS`).
|
|
139
|
+
|
|
140
|
+
#### Likely causes
|
|
141
|
+
|
|
142
|
+
1. A recorded diagnosis in a new cycle repeated the previous hypothesis with the exact same evidence references (`informationGain: NONE`). Note: technical retries within the *same* cycle are idempotent and do not cause stalls, but repeating in a *new* cycle does.
|
|
143
|
+
2. The same requirement has repeatedly failed across 3 or more verification cycles with unchanged diagnostic hypotheses.
|
|
144
|
+
3. Minor cosmetic changes were made to `settledBy` or `nextSafeAction` without changing the root hypothesis or evidence references.
|
|
145
|
+
|
|
146
|
+
#### Inspect
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
forgeloop progress --task <id> --json
|
|
150
|
+
forgeloop next --task <id> --json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Safe recovery
|
|
154
|
+
|
|
155
|
+
1. When stalled, `forgeloop next` returns `nextAction: "CHANGE_STRATEGY"` with error code `E_PROGRESS_STALLED`.
|
|
156
|
+
2. Do not repeat the same retry or correction action.
|
|
157
|
+
3. Re-examine the failure evidence from a new angle or gather fresh diagnostic evidence.
|
|
158
|
+
4. Formulate a genuinely new root-cause hypothesis with new evidence references and record it with `forgeloop record-diagnosis`.
|
|
159
|
+
5. Once a diagnosis with positive information gain (`NEW_HYPOTHESIS`, `NEW_EVIDENCE`, `NEW_HYPOTHESIS_AND_EVIDENCE`) is recorded, `forgeloop next` returns `CORRECT` and status returns to `ADVANCING`.
|
|
81
160
|
|
|
82
161
|
---
|
|
83
162
|
|
|
@@ -116,6 +195,40 @@ forgeloop status --task <id> --json
|
|
|
116
195
|
|
|
117
196
|
---
|
|
118
197
|
|
|
198
|
+
### Symptom: `EXECUTING` task is stale because the repository moved (`E_REPOSITORY_CHANGED`)
|
|
199
|
+
|
|
200
|
+
#### What it means
|
|
201
|
+
|
|
202
|
+
A task entered `EXECUTING` at an older checkout and the repository HEAD changed (commit, merge, or checkout). The work-state checkpoint fingerprint no longer matches, so transitions and completion are fail-closed with `E_REPOSITORY_CHANGED` / `E_STATE_REVALIDATION_REQUIRED`. This is intentional: execution must not silently continue against different code.
|
|
203
|
+
|
|
204
|
+
If the task's objective is already satisfied by the current repository (for example, the work was merged by another change), the checkpoint can be reconciled with executed evidence:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
forgeloop reconcile-closure --task <id> --id <verification-id> \
|
|
208
|
+
--requirement "<exact contract verification text>" -- <command>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`reconcile-closure` requires:
|
|
212
|
+
|
|
213
|
+
1. The task is `EXECUTING`.
|
|
214
|
+
2. The only drift is `REPOSITORY_CHANGED` (contract or required-artifact drift stays blocked).
|
|
215
|
+
3. The append-only event ledger is valid.
|
|
216
|
+
4. `--id` and `--requirement` exactly match a `VERIFICATION` item of the task contract, and the executed command exits 0, proving the objective is present in the current repository.
|
|
217
|
+
|
|
218
|
+
It then appends a `CHECKPOINT_RECONCILED` ledger event (previous/current repository fingerprints plus the evidence) and refreshes the work-state repository fingerprint. Closure still goes through the canonical pipeline:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
forgeloop advance --task <id> --to VERIFYING
|
|
222
|
+
forgeloop prepare-completion --task <id>
|
|
223
|
+
forgeloop run-check --task <id> --id <id> --requirement "<text>" -- <command>
|
|
224
|
+
forgeloop advance --task <id> --to REVIEWING
|
|
225
|
+
forgeloop complete --task <id>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Write claims release only when completion is validator-backed (`COMPLETE`).
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
119
232
|
### Symptom: Continuity is `STALE`
|
|
120
233
|
|
|
121
234
|
#### What it means
|
|
@@ -292,6 +405,133 @@ Inspect the specific error reported in `errors[]` and correct the inconsistent a
|
|
|
292
405
|
|
|
293
406
|
---
|
|
294
407
|
|
|
408
|
+
### Symptom: Policy Lock Mismatch
|
|
409
|
+
|
|
410
|
+
#### Error Code: `E_POLICY_LOCK_MISMATCH`
|
|
411
|
+
|
|
412
|
+
#### What it means
|
|
413
|
+
|
|
414
|
+
The persisted `.forgeloop/policy/policy.lock` digest or required subdigests (`rulesDigest`, `baselineDigest`, `algorithm`) do not match current effective rules or baseline.
|
|
415
|
+
|
|
416
|
+
#### Inspect
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
forgeloop policy-status --json
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### Safe recovery
|
|
423
|
+
|
|
424
|
+
1. If rules or baseline were legitimately modified, re-evaluate and update the lock via discovery/baseline commands:
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
forgeloop policy-discover --write --json
|
|
428
|
+
forgeloop baseline --update --json
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
2. If modifications were unintentional, restore the previous `.forgeloop/policy/rules.json` or `.forgeloop/policy/baseline.json`.
|
|
432
|
+
|
|
433
|
+
3. Follow `forgeloop next --json` if returned recovery action is `RESTORE_POLICY`.
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
### Symptom: Invalid Policy Artifacts Fail Closed
|
|
438
|
+
|
|
439
|
+
#### Error Code: `E_POLICY_INVALID`
|
|
440
|
+
|
|
441
|
+
#### What it means
|
|
442
|
+
|
|
443
|
+
One or more executable policy artifacts (`.forgeloop/policy/rules.json`, `.forgeloop/policy/baseline.json`, `.forgeloop/policy/discovery.json`, or `.forgeloop/policy/policy.lock`) is present but malformed or fails schema validation. ForgeLoop does not silently ignore corrupt policy: preflight and completion fail closed.
|
|
444
|
+
|
|
445
|
+
#### Inspect
|
|
446
|
+
|
|
447
|
+
```bash
|
|
448
|
+
forgeloop policy-status --json
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### Safe recovery
|
|
452
|
+
|
|
453
|
+
1. Validate each policy artifact against its schema and repair the malformed JSON or invalid fields.
|
|
454
|
+
|
|
455
|
+
2. Re-run preflight:
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
forgeloop preflight --task <id> --json
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
3. Follow `forgeloop next --task <id> --json` if the returned recovery action is `REPAIR_POLICY`.
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
### Symptom: Policy Weakening Detected
|
|
466
|
+
|
|
467
|
+
#### Error Code: `E_POLICY_WEAKENING`
|
|
468
|
+
|
|
469
|
+
#### What it means
|
|
470
|
+
|
|
471
|
+
Policy rules were relaxed or baseline debt expanded after the task policy snapshot was captured during preflight.
|
|
472
|
+
|
|
473
|
+
#### Safe recovery
|
|
474
|
+
|
|
475
|
+
1. Inspect the policy diff:
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
forgeloop policy-diff --task <id> --json
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
2. Restore the original policy configuration captured in `.forgeloop/task-state/<taskKey>/policy-snapshot.json`.
|
|
482
|
+
|
|
483
|
+
3. Re-query `forgeloop next --task <id> --json` (returns `RESTORE_POLICY`).
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
### Symptom: Baseline Re-Record Blocked During Active Task
|
|
488
|
+
|
|
489
|
+
#### Error Code: `E_BASELINE_RECORD_DURING_ACTIVE_TASK`
|
|
490
|
+
|
|
491
|
+
#### What it means
|
|
492
|
+
|
|
493
|
+
`forgeloop baseline --record` was executed during an active task bound to a preflight policy snapshot. Re-recording during active tasks is blocked to prevent converting new violations into accepted debt.
|
|
494
|
+
|
|
495
|
+
#### Safe recovery
|
|
496
|
+
|
|
497
|
+
1. Fix newly introduced violations instead of recording them into baseline debt.
|
|
498
|
+
|
|
499
|
+
2. If resolving legacy debt, use monotonic ratchet-down:
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
forgeloop baseline --update --json
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
3. If an intentional full baseline re-recording is authorized by an operator, supply the explicit authority flag:
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
forgeloop baseline --record --policy-reset-authorized --json
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
### Symptom: Mutation Checker Execution Error
|
|
514
|
+
|
|
515
|
+
#### Error Code: `E_CHECK_MUTATION_EXECUTION_ERROR`
|
|
516
|
+
|
|
517
|
+
#### What it means
|
|
518
|
+
|
|
519
|
+
A policy rule checker threw an unhandled exception while evaluating its synthetic mutation fixture during `rule-verify`. A crashing checker cannot prove its mutation detection efficacy.
|
|
520
|
+
|
|
521
|
+
#### Safe recovery
|
|
522
|
+
|
|
523
|
+
1. Inspect the checker error stack and adapter implementation:
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
forgeloop rule-verify --rule <rule-id> --json
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
2. Repair the unhandled exception path in the checker adapter.
|
|
530
|
+
|
|
531
|
+
3. Re-run `forgeloop rule-verify --rule <rule-id> --json` until the mutation is proven (`PROVEN`).
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
295
535
|
### Symptom: Another Harness Cannot Resume
|
|
296
536
|
|
|
297
537
|
#### Likely causes
|
|
@@ -341,5 +581,38 @@ forgeloop next --task <id> --json
|
|
|
341
581
|
| `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
582
|
| `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
583
|
| `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. |
|
|
584
|
+
| `E_RECONCILE_NOT_STALE` | reconcile-closure was invoked for a work-state checkpoint that is already fresh. | No reconciliation is required; continue the normal lifecycle. |
|
|
585
|
+
| `E_RECONCILE_PHASE_INVALID` | reconcile-closure was invoked for a task that is not EXECUTING. | reconcile-closure supports EXECUTING tasks whose objective is already satisfied. |
|
|
586
|
+
| `E_RECONCILE_UNSUPPORTED_DRIFT` | Work-state drift includes kinds other than REPOSITORY_CHANGED (contract or required-artifact drift). | Resolve contract or artifact drift through their dedicated recovery surfaces; reconcile-closure only refreshes repository fingerprint drift. |
|
|
587
|
+
| `E_RECONCILE_LEDGER_INVALID` | The append-only event ledger is not valid, so reconciliation cannot be recorded. | Inspect the ledger errors and repair before reconciling. |
|
|
588
|
+
| `E_RECONCILE_REQUIREMENT_UNKNOWN` | The supplied check id and requirement text do not exactly match a contract verification item of type VERIFICATION. | Supply the exact id and requirement text of an existing contract verification item. |
|
|
589
|
+
| `E_RECONCILE_EVIDENCE_FAILED` | The executed objective-satisfaction evidence command did not pass. | Inspect the execution artifact; reconciliation is refused until evidence passes in the current repository. |
|
|
590
|
+
| `E_REPOSITORY_CHANGED` | The repository fingerprint (branch or HEAD) moved after the work-state checkpoint was recorded. | If the task objective is already satisfied in the current repository, run forgeloop reconcile-closure; otherwise resume from a checkpoint that matches the current repository. |
|
|
591
|
+
| `E_STATE_REVALIDATION_REQUIRED` | The work-state checkpoint must be revalidated before the lifecycle can continue. | Run forgeloop reconcile-closure for externally satisfied EXECUTING tasks, or inspect the freshness reasons for other drift. |
|
|
592
|
+
| `E_DIAGNOSIS_REQUIRED` | Current correction cycle has no append-only diagnosis record. | Run forgeloop record-diagnosis with current failed evidence before correcting. |
|
|
593
|
+
| `E_DIAGNOSIS_INVALID` | Diagnosis record details or parameters are malformed. | Provide valid failureClass, hypothesis, evidenceRefs, settledBy, and nextSafeAction. |
|
|
594
|
+
| `E_DIAGNOSIS_EVIDENCE_INVALID` | Referenced diagnosis evidence is missing or has no failed checks in the current cycle. | Reference at least one failed or blocked check ID from the active verification cycle. |
|
|
595
|
+
| `E_DIAGNOSIS_CYCLE_MISMATCH` | Diagnosis verification cycle does not match the active work state verification cycle. | Record diagnosis for the current active verification cycle. |
|
|
596
|
+
| `E_DIAGNOSIS_NO_NEW_INFORMATION` | The proposed retry repeats the previous hypothesis with the same evidence. | Change the hypothesis, collect independent evidence, or change strategy. |
|
|
597
|
+
| `E_PROGRESS_STALLED` | Persisted correction history shows no new diagnostic information. | Use an independent check, revisit assumptions, or record a materially different diagnosis. |
|
|
598
|
+
| `E_DECISION_CRITERION_INVALID` | Decision settlement criterion details or parameters are malformed. | Provide non-empty decision text and settledBy criterion. |
|
|
599
|
+
| `E_DECISION_NOT_UNRESOLVED` | A settlement criterion referenced a decision not present in current unresolvedDecisions. | Use the exact current unresolved decision text or update the contract first. |
|
|
600
|
+
| `E_CHECK_INERT` | An enabled check has no effective scope or target files. | Provide an applicable target scope, configure matching files, or mark the rule unsupported. |
|
|
601
|
+
| `E_CHECK_MUTATION_NOT_DETECTED` | A blocking rule checker failed to detect an intentional mutation fixture. | Fix checker logic to properly identify target violations. |
|
|
602
|
+
| `E_POLICY_DRIFT` | Active policy lock does not match the policy snapshot captured at task activation. | Re-verify affected checks or restore original policy. |
|
|
603
|
+
| `E_POLICY_WEAKENING` | Policy rules were weakened during task execution without explicit authority. | Restore the original policy configuration. |
|
|
604
|
+
| `E_POLICY_LOCK_INVALID` | Policy lockfile is missing, malformed, or corrupt. | Run forgeloop policy-status or regenerate policy.lock. |
|
|
605
|
+
| `E_NEW_POLICY_VIOLATION` | New executable policy violation detected that is not present in brownfield baseline. | Fix the violation before completing the task. |
|
|
606
|
+
| `E_BASELINE_EXPANSION` | Attempted unauthorized addition of new violations to brownfield baseline. | Resolve new violations rather than expanding the baseline. |
|
|
607
|
+
| `E_POLICY_PROOF_STALE` | Mutation verification proof is stale due to checker or fixture modifications. | Re-run forgeloop rule-verify to refresh mutation proof. |
|
|
608
|
+
| `E_CHECK_MUTATION_EXECUTION_ERROR` | A policy checker threw an unhandled exception while evaluating its mutation fixture. | Repair the checker execution path and rerun rule verification. |
|
|
609
|
+
| `E_POLICY_EVALUATION_FAILED` | Policy evaluation threw an unexpected error during execution. | Inspect policy configuration and checker adapters for unhandled errors. |
|
|
610
|
+
| `E_POLICY_INVALID` | Policy artifact is malformed, corrupt, or schema-invalid. | Validate and repair rules.json, baseline.json, or discovery.json against schema. |
|
|
611
|
+
| `E_POLICY_SNAPSHOT_WRITE_FAILED` | Failed to persist task policy snapshot during preflight. | Ensure the target task directory is writable and repair filesystem permissions. |
|
|
612
|
+
| `E_POLICY_LOCK_MISMATCH` | Persisted policy lock digest does not match current effective policy state. | Re-evaluate effective rules and update policy.lock or restore modified rules. |
|
|
613
|
+
| `E_POLICY_DRIFT_UNKNOWN` | Task policy drift was detected but baseline snapshot details are unavailable. | Re-verify the task under the current policy state. |
|
|
614
|
+
| `E_BASELINE_RECORD_DURING_ACTIVE_TASK` | Cannot re-record baseline during an active task with policy snapshot. | Resolve new violations or use monotonic baseline --update. |
|
|
615
|
+
| `E_POLICY_INITIALIZATION_FAILED` | Executable policy bootstrap could not complete during initialization. | Repair the reported filesystem/schema error and rerun `forgeloop init`. Initialization is restartable while no committed manifest exists. |
|
|
616
|
+
| `E_INIT_KIT_CONFLICT` | A canonical ForgeLoop kit destination already exists with content that does not match the shipped canonical template. | Inspect the conflicting `.forgeloop/kit/...` file. If it is stale or partial ForgeLoop output, remove or restore it and rerun `forgeloop init`. Do not overwrite unknown content automatically. |
|
|
344
617
|
|
|
345
618
|
<!-- END FORGELOOP GENERATED: public-error-codes -->
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "forgeloop://schemas/policy-baseline.schema.json",
|
|
4
|
+
"title": "ForgeLoop policy baseline",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schemaVersion", "createdAt", "entries"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": { "const": 1 },
|
|
9
|
+
"createdAt": { "type": "string", "minLength": 1 },
|
|
10
|
+
"entries": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"required": ["ruleId", "fingerprints"],
|
|
15
|
+
"properties": {
|
|
16
|
+
"ruleId": { "type": "string", "minLength": 1 },
|
|
17
|
+
"fingerprints": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
18
|
+
"reviewBy": { "type": "string" },
|
|
19
|
+
"details": { "type": "array", "items": { "type": "object" } }
|
|
20
|
+
},
|
|
21
|
+
"additionalProperties": true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"additionalProperties": false
|
|
26
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "forgeloop://schemas/policy-discovery.schema.json",
|
|
4
|
+
"title": "ForgeLoop policy discovery result",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schemaVersion", "languages", "testing", "linting", "architecture", "discoveredRules"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": { "const": 1 },
|
|
9
|
+
"languages": { "type": "array", "items": { "type": "string" } },
|
|
10
|
+
"testing": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"required": ["detected", "confidence"],
|
|
13
|
+
"properties": {
|
|
14
|
+
"detected": { "type": "boolean" },
|
|
15
|
+
"command": { "type": "array", "items": { "type": "string" } },
|
|
16
|
+
"framework": { "type": "string" },
|
|
17
|
+
"confidence": { "enum": ["HIGH", "MEDIUM", "LOW", "UNKNOWN"] }
|
|
18
|
+
},
|
|
19
|
+
"additionalProperties": true
|
|
20
|
+
},
|
|
21
|
+
"linting": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"required": ["detected", "confidence"],
|
|
24
|
+
"properties": {
|
|
25
|
+
"detected": { "type": "boolean" },
|
|
26
|
+
"command": { "type": "array", "items": { "type": "string" } },
|
|
27
|
+
"tool": { "type": "string" },
|
|
28
|
+
"confidence": { "enum": ["HIGH", "MEDIUM", "LOW", "UNKNOWN"] }
|
|
29
|
+
},
|
|
30
|
+
"additionalProperties": true
|
|
31
|
+
},
|
|
32
|
+
"architecture": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"required": ["confidence", "enforcement"],
|
|
35
|
+
"properties": {
|
|
36
|
+
"value": { "type": ["string", "null"] },
|
|
37
|
+
"confidence": { "enum": ["HIGH", "MEDIUM", "LOW", "UNKNOWN"] },
|
|
38
|
+
"enforcement": { "enum": ["BLOCKING", "ADVISORY", "NONE"] }
|
|
39
|
+
},
|
|
40
|
+
"additionalProperties": true
|
|
41
|
+
},
|
|
42
|
+
"discoveredRules": { "type": "array", "items": { "type": "object" } }
|
|
43
|
+
},
|
|
44
|
+
"additionalProperties": false
|
|
45
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "forgeloop://schemas/policy-lock.schema.json",
|
|
4
|
+
"title": "ForgeLoop policy lockfile",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schemaVersion", "algorithm", "digest", "rulesDigest", "baselineDigest"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": { "const": 1 },
|
|
9
|
+
"algorithm": { "const": "sha256" },
|
|
10
|
+
"digest": { "type": "string", "minLength": 1 },
|
|
11
|
+
"rulesDigest": { "type": "string" },
|
|
12
|
+
"baselineDigest": { "type": "string" },
|
|
13
|
+
"capturedAt": { "type": "string" }
|
|
14
|
+
},
|
|
15
|
+
"additionalProperties": false
|
|
16
|
+
}
|