@cassiomc1/forgeloop 1.2.1 → 1.2.3
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 +59 -0
- package/ENG/premium-sites-studio-eng.md +28 -0
- package/LOOP_ENGINEERING.md +23 -0
- package/LOOP_SYSTEM_DESIGN.md +9 -5
- package/ORCHESTRATOR_INTEGRATION.md +37 -4
- package/PROTOCOL_INTEGRATION.md +13 -0
- package/README.md +34 -2
- package/TERMINOLOGY.md +10 -0
- package/THIRD_PARTY_NOTICES.md +34 -0
- package/THREAT_MODEL.md +12 -1
- package/docs/ARTIFACT_REFERENCE.md +150 -0
- package/docs/CLI_REFERENCE.md +263 -30
- package/docs/CROSS_HARNESS_CONTINUITY.md +1 -0
- package/docs/DOCUMENTATION_GUIDE.md +41 -4
- package/docs/GETTING_STARTED.md +9 -4
- package/docs/RECIPES.md +31 -1
- package/docs/TROUBLESHOOTING.md +191 -0
- 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 +69 -1
- package/src/commands/baseline.js +120 -0
- package/src/commands/init.js +304 -6
- 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/reconcile-closure.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 +114 -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/error-codes.js +227 -0
- package/src/core/events.js +22 -0
- 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 +9 -0
- package/src/core/next-action.js +128 -82
- 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.js +65 -1
- package/src/core/reconcile-closure.js +175 -0
- package/src/core/schema-validation.js +6 -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
|
@@ -35,6 +35,10 @@ Documentation routing -> DOCS_INDEX.md
|
|
|
35
35
|
|
|
36
36
|
Operational documentation must explain canonical behavior, not redefine it.
|
|
37
37
|
|
|
38
|
+
Canonical phase and transition inventories must be derived from `WORK_PHASES`
|
|
39
|
+
and `WORK_TRANSITIONS`; do not maintain independent hand-written transition
|
|
40
|
+
enums when a generated or mechanically validated representation is available.
|
|
41
|
+
|
|
38
42
|
---
|
|
39
43
|
|
|
40
44
|
## 3. Generated Documentation Provenance & Pipeline
|
|
@@ -60,10 +64,11 @@ cross-platform CI (.github/workflows/docs-quality.yml)
|
|
|
60
64
|
| Fact Category | Canonical Machine Source | Generated Target File | Generated Region Marker |
|
|
61
65
|
| --- | --- | --- | --- |
|
|
62
66
|
| **Artifact Inventory** | `ARTIFACT_REGISTRY` (`src/core/artifact-registry.js`) | `docs/ARTIFACT_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: artifact-registry -->` |
|
|
63
|
-
| **Artifact Fields**
|
|
67
|
+
| **Artifact Fields** | `schemas/*.schema.json` | `docs/ARTIFACT_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: schema:<name> -->` |
|
|
64
68
|
| **CLI Command Index** | `CLI_COMMAND_DEFINITIONS` (`src/core/cli-command-definitions.js`) | `docs/CLI_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: cli-command-index -->` |
|
|
65
69
|
| **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**
|
|
70
|
+
| **CLI Command Options** | `CLI_COMMAND_DEFINITIONS` (`src/core/cli-command-definitions.js`) | `docs/CLI_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: cli:<command>:options -->` |
|
|
71
|
+
| **Work-State Transitions** | `WORK_PHASES` / `WORK_TRANSITIONS` (`src/core/protocol.js`) | `ORCHESTRATOR_INTEGRATION.md` | `<!-- BEGIN FORGELOOP GENERATED: work-transitions -->` |
|
|
67
72
|
| **Public Error Codes** | `PUBLIC_ERROR_CODES` (`src/core/error-codes.js`) | `docs/TROUBLESHOOTING.md` | `<!-- BEGIN FORGELOOP GENERATED: public-error-codes -->` |
|
|
68
73
|
| **Architecture Flow** | `docs/forgeloop-flow.mmd` | `docs/assets/forgeloop-flow.svg` | Verified via embedded SHA-256 fingerprint |
|
|
69
74
|
|
|
@@ -82,6 +87,11 @@ npm test
|
|
|
82
87
|
npm run docs:check
|
|
83
88
|
```
|
|
84
89
|
|
|
90
|
+
Do not hard-code inventory totals in prose or headings. Counts of commands,
|
|
91
|
+
schemas, fields, and public codes are derived from the registries and schemas;
|
|
92
|
+
when those sources change, regenerate the reference documents and let the
|
|
93
|
+
conformance checks detect omissions.
|
|
94
|
+
|
|
85
95
|
---
|
|
86
96
|
|
|
87
97
|
## 4. Documentation Conformance Matrix
|
|
@@ -93,9 +103,10 @@ npm run docs:check
|
|
|
93
103
|
| **Artifact fields & types** | `schemas/*.schema.json` | `scripts/validate_documentation_conformance.mjs` |
|
|
94
104
|
| **Enums & consts** | `schemas/*.schema.json` | `scripts/validate_documentation_conformance.mjs` |
|
|
95
105
|
| **Lifecycle phases** | `WORK_PHASES` (`src/core/protocol.js`) | `scripts/validate_documentation_conformance.mjs` |
|
|
106
|
+
| **Lifecycle transitions** | `WORK_TRANSITIONS` (`src/core/protocol.js`) + the special `BLOCKED` rule | `scripts/generate_documentation_reference.mjs` and `scripts/validate_documentation_conformance.mjs` |
|
|
96
107
|
| **Stable error codes** | `PUBLIC_ERROR_CODES` (`src/core/error-codes.js`) | `scripts/validate_documentation_conformance.mjs` |
|
|
97
108
|
| **Discovery resume rules** | `DISCOVERY_SURFACES` & `nativeShim` | `scripts/validate_documentation_conformance.mjs` |
|
|
98
|
-
| **
|
|
109
|
+
| **Task-layout path freshness** | `TASK_LAYOUT_DOCUMENTS` & `task-paths.js` | `scripts/validate_documentation_conformance.mjs` |
|
|
99
110
|
| **Package-shipped docs** | `package.json` (`files`) | `tests/package.test.js` |
|
|
100
111
|
| **Architecture diagram** | `docs/forgeloop-flow.mmd` | `scripts/check-generated-diagram.mjs` |
|
|
101
112
|
|
|
@@ -116,6 +127,7 @@ Avoid ambiguous phrases like *"should generally"* or *"usually"* for behaviors t
|
|
|
116
127
|
|
|
117
128
|
- Canonical task-scoped paths are defined in `src/core/task-paths.js` under `.forgeloop/task-state/<taskKey>/`.
|
|
118
129
|
- Operational guides (`README.md`, `GETTING_STARTED.md`, `RECIPES.md`, `CROSS_HARNESS_CONTINUITY.md`, `TROUBLESHOOTING.md`) must document namespaced paths by default.
|
|
130
|
+
- Architecture/integration documents (`LOOP_SYSTEM_DESIGN.md`, `ORCHESTRATOR_INTEGRATION.md`) are covered by the same task-layout conformance scope (`TASK_LAYOUT_DOCUMENTS`).
|
|
119
131
|
- Legacy ForgeLoop 1.0 singleton paths (e.g. `.forgeloop/current-contract.json`) are permitted **only** inside explicit legacy migration regions:
|
|
120
132
|
|
|
121
133
|
```markdown
|
|
@@ -145,7 +157,32 @@ Avoid ambiguous phrases like *"should generally"* or *"usually"* for behaviors t
|
|
|
145
157
|
|
|
146
158
|
---
|
|
147
159
|
|
|
148
|
-
## 8.
|
|
160
|
+
## 8. README Hero and Package Boundary
|
|
161
|
+
|
|
162
|
+
README hero assets are branding/conceptual illustrations. They are not the
|
|
163
|
+
canonical protocol diagram. `docs/forgeloop-flow.mmd` remains the canonical
|
|
164
|
+
architecture flow source and `docs/assets/forgeloop-flow.svg` remains its
|
|
165
|
+
generated render.
|
|
166
|
+
|
|
167
|
+
The README hero is intentionally GitHub-repository-only:
|
|
168
|
+
|
|
169
|
+
- `README.md` may reference `docs/assets/eng_readme_forgeloop.png`; GitHub
|
|
170
|
+
renders it from the repository.
|
|
171
|
+
- The hero PNG is excluded from the npm package (`package.json` `files`), and
|
|
172
|
+
`tests/package.test.js` asserts that exclusion so it cannot be silently
|
|
173
|
+
re-included.
|
|
174
|
+
- The packaged README is therefore not self-contained for that relative hero
|
|
175
|
+
path; do not claim otherwise.
|
|
176
|
+
- If a portable hero is ever shipped, any relative README asset referenced by
|
|
177
|
+
packaged Markdown must be present in the package and covered by
|
|
178
|
+
`tests/package.test.js`.
|
|
179
|
+
|
|
180
|
+
Never delete `docs/assets/forgeloop-flow.svg`; it is generator-owned output of
|
|
181
|
+
the diagram workflow.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 9. Documentation Change Checklist for Pull Requests
|
|
149
186
|
|
|
150
187
|
For documentation-impacting changes, verify each item before merging:
|
|
151
188
|
|
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
|
|
@@ -297,7 +301,7 @@ Output:
|
|
|
297
301
|
{
|
|
298
302
|
"status": "VALID",
|
|
299
303
|
"taskStatus": "COMPLETE",
|
|
300
|
-
"verificationStatus": "
|
|
304
|
+
"verificationStatus": "VALID"
|
|
301
305
|
}
|
|
302
306
|
```
|
|
303
307
|
|
|
@@ -342,9 +346,10 @@ Under `.forgeloop/task-state/<taskKey>/`:
|
|
|
342
346
|
- `work-state.json`: lifecycle phase and resumption checkpoint;
|
|
343
347
|
- `events.ndjson`: hash-chained append-only event ledger;
|
|
344
348
|
- `executions/*.json`: provenance records for executed verification commands;
|
|
345
|
-
- `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).
|
|
346
351
|
|
|
347
|
-
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`).
|
|
348
353
|
|
|
349
354
|
---
|
|
350
355
|
|
package/docs/RECIPES.md
CHANGED
|
@@ -19,6 +19,7 @@ Concise, copy-paste friendly recipes for common ForgeLoop tasks.
|
|
|
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
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)
|
|
22
23
|
|
|
23
24
|
---
|
|
24
25
|
|
|
@@ -38,7 +39,7 @@ forgeloop route --task task-001 --work code --surface api --risk untrusted-input
|
|
|
38
39
|
forgeloop preflight --task task-001 --json
|
|
39
40
|
|
|
40
41
|
# 5. Activate session and plan
|
|
41
|
-
forgeloop activate
|
|
42
|
+
forgeloop activate
|
|
42
43
|
forgeloop advance --task task-001 --to PLANNED
|
|
43
44
|
forgeloop advance --task task-001 --to EXECUTING
|
|
44
45
|
```
|
|
@@ -277,3 +278,32 @@ forgeloop record-decision-criterion \
|
|
|
277
278
|
# 2. Inspect next action (surfaces the guidance)
|
|
278
279
|
forgeloop next --task task-001
|
|
279
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
|
@@ -18,6 +18,11 @@ This guide provides symptom-first recovery procedures for common ForgeLoop proto
|
|
|
18
18
|
- [Execution reference invalid (`E_EXECUTION_REF_INVALID`)](#symptom-execution-reference-invalid)
|
|
19
19
|
- [`forgeloop complete` returns `INCOMPLETE`](#symptom-forgeloop-complete-returns-incomplete)
|
|
20
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)
|
|
21
26
|
- [Another harness cannot resume the task](#symptom-another-harness-cannot-resume)
|
|
22
27
|
- [Stable Error & Reason Code Reference](#stable-error-and-reason-codes)
|
|
23
28
|
|
|
@@ -190,6 +195,40 @@ forgeloop status --task <id> --json
|
|
|
190
195
|
|
|
191
196
|
---
|
|
192
197
|
|
|
198
|
+
### Symptom: `EXECUTING`/`VERIFYING` 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` or `VERIFYING` (later phases are not reconcilable; work must return to a verification phase first).
|
|
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
|
+
|
|
193
232
|
### Symptom: Continuity is `STALE`
|
|
194
233
|
|
|
195
234
|
#### What it means
|
|
@@ -366,6 +405,133 @@ Inspect the specific error reported in `errors[]` and correct the inconsistent a
|
|
|
366
405
|
|
|
367
406
|
---
|
|
368
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
|
+
|
|
369
535
|
### Symptom: Another Harness Cannot Resume
|
|
370
536
|
|
|
371
537
|
#### Likely causes
|
|
@@ -415,6 +581,14 @@ forgeloop next --task <id> --json
|
|
|
415
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. |
|
|
416
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. |
|
|
417
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 or VERIFYING. | reconcile-closure supports EXECUTING or VERIFYING 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. |
|
|
418
592
|
| `E_DIAGNOSIS_REQUIRED` | Current correction cycle has no append-only diagnosis record. | Run forgeloop record-diagnosis with current failed evidence before correcting. |
|
|
419
593
|
| `E_DIAGNOSIS_INVALID` | Diagnosis record details or parameters are malformed. | Provide valid failureClass, hypothesis, evidenceRefs, settledBy, and nextSafeAction. |
|
|
420
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. |
|
|
@@ -423,5 +597,22 @@ forgeloop next --task <id> --json
|
|
|
423
597
|
| `E_PROGRESS_STALLED` | Persisted correction history shows no new diagnostic information. | Use an independent check, revisit assumptions, or record a materially different diagnosis. |
|
|
424
598
|
| `E_DECISION_CRITERION_INVALID` | Decision settlement criterion details or parameters are malformed. | Provide non-empty decision text and settledBy criterion. |
|
|
425
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. |
|
|
426
617
|
|
|
427
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "forgeloop://schemas/policy-rules.schema.json",
|
|
4
|
+
"title": "ForgeLoop executable policy rules",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schemaVersion", "rules"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": { "const": 1 },
|
|
9
|
+
"rules": {
|
|
10
|
+
"type": "array",
|
|
11
|
+
"items": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"required": ["id", "severity", "source", "blocking", "why", "fix", "check"],
|
|
14
|
+
"properties": {
|
|
15
|
+
"id": { "type": "string", "minLength": 1 },
|
|
16
|
+
"severity": { "enum": ["HIGH", "MEDIUM", "LOW", "INFO"] },
|
|
17
|
+
"source": { "enum": ["builtin", "discovered", "project"] },
|
|
18
|
+
"blocking": { "type": "boolean" },
|
|
19
|
+
"why": { "type": "string", "minLength": 1 },
|
|
20
|
+
"fix": { "type": "string", "minLength": 1 },
|
|
21
|
+
"confidence": { "enum": ["HIGH", "MEDIUM", "LOW", "UNKNOWN"] },
|
|
22
|
+
"scope": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"properties": {
|
|
25
|
+
"includes": { "type": "array", "items": { "type": "string" } },
|
|
26
|
+
"excludes": { "type": "array", "items": { "type": "string" } }
|
|
27
|
+
},
|
|
28
|
+
"additionalProperties": false
|
|
29
|
+
},
|
|
30
|
+
"check": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"required": ["type"],
|
|
33
|
+
"properties": {
|
|
34
|
+
"type": { "type": "string", "minLength": 1 },
|
|
35
|
+
"adapter": { "type": "string" },
|
|
36
|
+
"command": { "type": "array", "items": { "type": "string" } },
|
|
37
|
+
"threshold": { "type": "number" },
|
|
38
|
+
"parameters": { "type": "object" }
|
|
39
|
+
},
|
|
40
|
+
"additionalProperties": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"additionalProperties": true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"additionalProperties": false
|
|
48
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "forgeloop://schemas/policy-snapshot.schema.json",
|
|
4
|
+
"title": "ForgeLoop task policy snapshot",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schemaVersion", "policyDigest", "rules"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schemaVersion": { "const": 1 },
|
|
9
|
+
"policyDigest": { "type": "string", "minLength": 1 },
|
|
10
|
+
"rules": { "type": "array", "items": { "type": ["string", "object"] } },
|
|
11
|
+
"baseline": { "type": "object" },
|
|
12
|
+
"baselineDigest": { "type": "string" },
|
|
13
|
+
"capturedAt": { "type": "string" }
|
|
14
|
+
},
|
|
15
|
+
"additionalProperties": false
|
|
16
|
+
}
|