@cassiomc1/forgeloop 1.2.3 → 1.3.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.
- package/AGENT_COMPATIBILITY.md +4 -0
- package/DOCS_INDEX.md +7 -0
- package/EXECUTION_STATE.md +8 -0
- package/LOOP_ENGINEERING.md +1 -1
- package/LOOP_SYSTEM_DESIGN.md +10 -0
- package/PROTOCOL_INTEGRATION.md +30 -0
- package/README.md +48 -0
- package/THREAT_MODEL.md +3 -1
- package/docs/ARTIFACT_REFERENCE.md +11 -0
- package/docs/CLI_REFERENCE.md +81 -3
- package/docs/CROSS_HARNESS_CONTINUITY.md +11 -0
- package/docs/DOCUMENTATION_GUIDE.md +17 -0
- package/docs/GETTING_STARTED.md +9 -0
- package/docs/RECIPES.md +5 -1
- package/docs/TROUBLESHOOTING.md +133 -40
- package/package.json +4 -1
- package/schemas/execution.schema.json +11 -1
- package/schemas/work-state.schema.json +1 -0
- package/src/cli.js +21 -2
- package/src/commands/doctor.js +22 -0
- package/src/commands/migrate-protocol.js +18 -0
- package/src/commands/protocol-info.js +16 -0
- package/src/commands/run-check.js +2 -0
- package/src/commands/task-create.js +3 -2
- package/src/commands/task-lock-status.js +29 -0
- package/src/commands/task-show.js +3 -3
- package/src/commands/task-unlock.js +8 -6
- package/src/core/artifacts.js +17 -4
- package/src/core/cli-command-definitions.js +44 -0
- package/src/core/completion-artifacts.js +15 -3
- package/src/core/completion.js +15 -3
- package/src/core/diagnosis.js +15 -11
- package/src/core/error-codes.js +18 -0
- package/src/core/events.js +109 -8
- package/src/core/execution.js +73 -9
- package/src/core/filesystem.js +20 -2
- package/src/core/phase.js +8 -2
- package/src/core/protocol-info.js +41 -0
- package/src/core/protocol-migration.js +59 -0
- package/src/core/reconcile-closure.js +22 -4
- package/src/core/resumability.js +8 -6
- package/src/core/task-command.js +3 -3
- package/src/core/task-lock.js +40 -4
- package/src/core/task-migration.js +24 -1
- package/src/core/task-paths.js +3 -1
- package/src/core/transaction.js +259 -0
- package/src/core/work-state.js +70 -6
package/docs/TROUBLESHOOTING.md
CHANGED
|
@@ -30,6 +30,15 @@ This guide provides symptom-first recovery procedures for common ForgeLoop proto
|
|
|
30
30
|
|
|
31
31
|
## Symptoms and Recovery
|
|
32
32
|
|
|
33
|
+
Confirm the local CLI's public metadata before diagnosing a harness/version
|
|
34
|
+
mismatch. This check does not create or mutate task state.
|
|
35
|
+
|
|
36
|
+
<!-- FORGELOOP EXAMPLE: troubleshooting:protocol-info | exit=0 | json.errors.0.code=E_AUTHORITY_INVALID -->
|
|
37
|
+
```bash
|
|
38
|
+
forgeloop protocol-info --json
|
|
39
|
+
```
|
|
40
|
+
<!-- END FORGELOOP EXAMPLE -->
|
|
41
|
+
|
|
33
42
|
### Symptom: `preflight` is `BLOCKED`
|
|
34
43
|
|
|
35
44
|
#### What it means
|
|
@@ -563,56 +572,140 @@ forgeloop next --task <id> --json
|
|
|
563
572
|
|
|
564
573
|
| Code | Meaning | Safe Resolution |
|
|
565
574
|
| --- | --- | --- |
|
|
566
|
-
| `E_PREFLIGHT_NOT_READY` | Preflight gates or contract validations are incomplete. | Satisfy required gates and check preflight output. |
|
|
567
|
-
| `E_CONTRACT_STALE` | Contract modified after downstream artifacts were generated. | Re-run forgeloop route and forgeloop preflight. |
|
|
568
|
-
| `E_ROUTE_STALE` | Routing result does not match the active contract fingerprint. | Re-run forgeloop route. |
|
|
569
|
-
| `E_GATE_STALE` | Referenced gate artifact changed after approval. | Update artifact SHA-256 in gate file. |
|
|
570
|
-
| `E_VERIFICATION_TOOL_UNAVAILABLE` | Required verification executable is missing in environment. | Use local equivalent, obtain host authority, or record NOT_VERIFIED. |
|
|
571
|
-
| `E_INSTALLATION_AUTHORITY_REQUIRED` | Attempted software installation without host authority grant. | Use local non-installing binaries or request host authority grant. |
|
|
572
575
|
| `E_AUTHORITY_INVALID` | Authority grant file is malformed or expired. | Obtain a valid authority grant from host operator. |
|
|
573
576
|
| `E_AUTHORITY_SCOPE_MISMATCH` | Authority grant does not cover the requested package. | Request updated authority scope. |
|
|
574
577
|
| `E_AUTHORITY_UNTRUSTED_SOURCE` | Authority file placed inside untrusted project tree. | Place authority file in host-managed trusted location. |
|
|
575
|
-
| `
|
|
578
|
+
| `E_BASELINE_EXPANSION` | Attempted unauthorized addition of new violations to brownfield baseline. | Resolve new violations rather than expanding the baseline. |
|
|
579
|
+
| `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. |
|
|
580
|
+
| `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. |
|
|
576
581
|
| `E_CHECK_INVALID` | Check structure or required parameters are invalid. | Provide valid check ID, requirement, and parameters. |
|
|
577
|
-
| `
|
|
582
|
+
| `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. |
|
|
583
|
+
| `E_CHECK_MUTATION_NOT_DETECTED` | A blocking rule checker failed to detect an intentional mutation fixture. | Fix checker logic to properly identify target violations. |
|
|
584
|
+
| `E_CHECK_STATUS_CONTRADICTION` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
585
|
+
| `E_CIRCULAR_COMPLETION_REQUIREMENT` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
586
|
+
| `E_COMMAND_RESOLUTION_AMBIGUOUS` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
587
|
+
| `E_COMPLETION_RECOVERY_UNAUTHORIZED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
588
|
+
| `E_COMPLETION_REJECTED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
589
|
+
| `E_COMPLETION_REJECTION_LEDGER_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
590
|
+
| `E_COMPLETION_REJECTION_RECEIPT_FINGERPRINT_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
591
|
+
| `E_COMPLETION_REJECTION_STATE_FINGERPRINT_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
592
|
+
| `E_CONTINUITY_CONTRACT_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
593
|
+
| `E_CONTINUITY_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
594
|
+
| `E_CONTINUITY_PHASE_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
578
595
|
| `E_CONTINUITY_RECONCILIATION_REQUIRED` | Continuity context has drifted from work state. | Run forgeloop reconcile-continuity --json. |
|
|
579
|
-
| `
|
|
580
|
-
| `
|
|
581
|
-
| `
|
|
582
|
-
| `
|
|
583
|
-
| `
|
|
584
|
-
| `
|
|
585
|
-
| `
|
|
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. |
|
|
596
|
+
| `E_CONTINUITY_SCHEMA_UNSUPPORTED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
597
|
+
| `E_CONTINUITY_STATE_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
598
|
+
| `E_CONTINUITY_TASK_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
599
|
+
| `E_CONTRACT_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
600
|
+
| `E_CONTRACT_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
601
|
+
| `E_CONTRACT_STALE` | Contract modified after downstream artifacts were generated. | Re-run forgeloop route and forgeloop preflight. |
|
|
602
|
+
| `E_CONTRACT_UNRESOLVED_DECISION` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
598
603
|
| `E_DECISION_CRITERION_INVALID` | Decision settlement criterion details or parameters are malformed. | Provide non-empty decision text and settledBy criterion. |
|
|
599
604
|
| `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
|
-
| `
|
|
601
|
-
| `
|
|
602
|
-
| `
|
|
603
|
-
| `
|
|
604
|
-
| `
|
|
605
|
+
| `E_DIAGNOSIS_CYCLE_MISMATCH` | Diagnosis verification cycle does not match the active work state verification cycle. | Record diagnosis for the current active verification cycle. |
|
|
606
|
+
| `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. |
|
|
607
|
+
| `E_DIAGNOSIS_INVALID` | Diagnosis record details or parameters are malformed. | Provide valid failureClass, hypothesis, evidenceRefs, settledBy, and nextSafeAction. |
|
|
608
|
+
| `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. |
|
|
609
|
+
| `E_DIAGNOSIS_REQUIRED` | Current correction cycle has no append-only diagnosis record. | Run forgeloop record-diagnosis with current failed evidence before correcting. |
|
|
610
|
+
| `E_EVIDENCE_COVERAGE_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
611
|
+
| `E_EVIDENCE_COVERAGE_PARTIAL` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
612
|
+
| `E_EVIDENCE_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
613
|
+
| `E_EVIDENCE_KIND_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
614
|
+
| `E_EVIDENCE_PARTIAL` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
615
|
+
| `E_EVIDENCE_REQUIRED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
616
|
+
| `E_EVIDENCE_STALE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
617
|
+
| `E_EXECUTION_REF_INVALID` | Referenced execution ID does not exist. | Re-run check via forgeloop run-check. |
|
|
618
|
+
| `E_FUTURE_LIFECYCLE_EVIDENCE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
619
|
+
| `E_FUTURE_TERMINAL_EVIDENCE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
620
|
+
| `E_GATE_REQUIRED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
621
|
+
| `E_GATE_STALE` | Referenced gate artifact changed after approval. | Update artifact SHA-256 in gate file. |
|
|
622
|
+
| `E_GATE_UNVERIFIED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
623
|
+
| `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. |
|
|
624
|
+
| `E_INSTALLATION_AUTHORITY_REQUIRED` | Attempted software installation without host authority grant. | Use local non-installing binaries or request host authority grant. |
|
|
625
|
+
| `E_MIGRATION_INCOMPLETE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
626
|
+
| `E_MIGRATION_WRITE_VERIFY` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
627
|
+
| `E_MIXED_TERMINAL_REQUIREMENT` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
628
|
+
| `E_NATIVE_ADAPTER_STALE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
629
|
+
| `E_NATIVE_ADAPTER_TARGET_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
605
630
|
| `E_NEW_POLICY_VIOLATION` | New executable policy violation detected that is not present in brownfield baseline. | Fix the violation before completing the task. |
|
|
606
|
-
| `
|
|
607
|
-
| `
|
|
608
|
-
| `
|
|
631
|
+
| `E_PHASE_CHRONOLOGY_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
632
|
+
| `E_PHASE_PREREQUISITE_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
633
|
+
| `E_PHASE_TRANSITION_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
634
|
+
| `E_POLICY_DRIFT` | Active policy lock does not match the policy snapshot captured at task activation. | Re-verify affected checks or restore original policy. |
|
|
635
|
+
| `E_POLICY_DRIFT_UNKNOWN` | Task policy drift was detected but baseline snapshot details are unavailable. | Re-verify the task under the current policy state. |
|
|
609
636
|
| `E_POLICY_EVALUATION_FAILED` | Policy evaluation threw an unexpected error during execution. | Inspect policy configuration and checker adapters for unhandled errors. |
|
|
637
|
+
| `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. |
|
|
610
638
|
| `E_POLICY_INVALID` | Policy artifact is malformed, corrupt, or schema-invalid. | Validate and repair rules.json, baseline.json, or discovery.json against schema. |
|
|
611
|
-
| `
|
|
639
|
+
| `E_POLICY_LOCK_INVALID` | Policy lockfile is missing, malformed, or corrupt. | Run forgeloop policy-status or regenerate policy.lock. |
|
|
612
640
|
| `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
|
-
| `
|
|
614
|
-
| `
|
|
615
|
-
| `
|
|
616
|
-
| `
|
|
641
|
+
| `E_POLICY_PROOF_STALE` | Mutation verification proof is stale due to checker or fixture modifications. | Re-run forgeloop rule-verify to refresh mutation proof. |
|
|
642
|
+
| `E_POLICY_SNAPSHOT_WRITE_FAILED` | Failed to persist task policy snapshot during preflight. | Ensure the target task directory is writable and repair filesystem permissions. |
|
|
643
|
+
| `E_POLICY_WEAKENING` | Policy rules were weakened during task execution without explicit authority. | Restore the original policy configuration. |
|
|
644
|
+
| `E_PREFLIGHT_EVENT_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
645
|
+
| `E_PREFLIGHT_GATES_STALE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
646
|
+
| `E_PREFLIGHT_GATE_EVENT_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
647
|
+
| `E_PREFLIGHT_NOT_READY` | Preflight gates or contract validations are incomplete. | Satisfy required gates and check preflight output. |
|
|
648
|
+
| `E_PREFLIGHT_READY_EVENT_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
649
|
+
| `E_PREFLIGHT_READY_EVENT_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
650
|
+
| `E_PRODUCTION_READINESS_UNVERIFIED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
651
|
+
| `E_PRODUCTION_REQUIREMENT_PENDING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
652
|
+
| `E_PROFILE_SOURCE_MISCLASSIFIED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
653
|
+
| `E_PROFILE_SOURCE_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
654
|
+
| `E_PROFILE_SOURCE_UNKNOWN` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
655
|
+
| `E_PROFILE_UNVERIFIED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
656
|
+
| `E_PROGRESS_STALLED` | Persisted correction history shows no new diagnostic information. | Use an independent check, revisit assumptions, or record a materially different diagnosis. |
|
|
657
|
+
| `E_PROTOCOL_MIGRATION_TARGET_UNSUPPORTED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
658
|
+
| `E_PUBLICATION_CLAIM_UNVERIFIED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
659
|
+
| `E_PUBLICATION_REQUIREMENT_PENDING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
660
|
+
| `E_RECEIPT_CONTRACT_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
661
|
+
| `E_RECEIPT_CYCLE_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
662
|
+
| `E_RECEIPT_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
663
|
+
| `E_RECEIPT_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
664
|
+
| `E_RECEIPT_PATH_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
665
|
+
| `E_RECEIPT_ROUTE_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
666
|
+
| `E_RECEIPT_STATE_MISMATCH` | Receipt does not match current state cycle or work state. | Run forgeloop prepare-completion --json. |
|
|
667
|
+
| `E_RECEIPT_TASK_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
668
|
+
| `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. |
|
|
669
|
+
| `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. |
|
|
670
|
+
| `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. |
|
|
671
|
+
| `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. |
|
|
672
|
+
| `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. |
|
|
673
|
+
| `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. |
|
|
674
|
+
| `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. |
|
|
675
|
+
| `E_ROUTE_GUIDE_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
676
|
+
| `E_ROUTE_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
677
|
+
| `E_ROUTE_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
678
|
+
| `E_ROUTE_REASON_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
679
|
+
| `E_ROUTE_STALE` | Routing result does not match the active contract fingerprint. | Re-run forgeloop route. |
|
|
680
|
+
| `E_STATE_LEDGER_DIVERGENCE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
681
|
+
| `E_STATE_MISSING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
682
|
+
| `E_STATE_MISSING_AFTER_PREFLIGHT_READY` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
683
|
+
| `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. |
|
|
684
|
+
| `E_STATE_TASK_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
685
|
+
| `E_TASK_ALREADY_EXISTS` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
686
|
+
| `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>. |
|
|
687
|
+
| `E_TASK_CHANGE_ATTRIBUTION_UNAVAILABLE` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
688
|
+
| `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. |
|
|
689
|
+
| `E_TASK_CONTEXT_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
690
|
+
| `E_TASK_DESCRIPTOR_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
691
|
+
| `E_TASK_KEY_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
692
|
+
| `E_TASK_LAYOUT_LEGACY` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
693
|
+
| `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. |
|
|
694
|
+
| `E_TASK_LOCK_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
695
|
+
| `E_TASK_MIGRATION_IDENTITY_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
696
|
+
| `E_TASK_MIGRATION_INVALID` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
697
|
+
| `E_TASK_NOT_FOUND` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
698
|
+
| `E_TASK_REQUIRED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
699
|
+
| `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. |
|
|
700
|
+
| `E_TASK_SCOPE_DIRTY` | Claimed paths contain pre-existing uncommitted changes. | Commit or stash changes in claimed paths before defining or adopting the scope. |
|
|
701
|
+
| `E_TASK_SCOPE_FROZEN` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
702
|
+
| `E_TASK_SCOPE_REQUIRED` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
703
|
+
| `E_TASK_SELECTOR_CONFLICT` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
704
|
+
| `E_TERMINAL_REQUIREMENT_NOT_TERMINAL` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
705
|
+
| `E_TERMINAL_REQUIREMENT_PENDING` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
706
|
+
| `E_TERMINAL_REQUIREMENT_TYPE_MISMATCH` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
707
|
+
| `E_TERMINAL_REQUIREMENT_UNKNOWN` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
708
|
+
| `E_TERMINAL_STATUS_REGRESSION` | A ForgeLoop protocol validation or lifecycle condition was not satisfied. | Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json. |
|
|
709
|
+
| `E_VERIFICATION_TOOL_UNAVAILABLE` | Required verification executable is missing in environment. | Use local equivalent, obtain host authority, or record NOT_VERIFIED. |
|
|
617
710
|
|
|
618
711
|
<!-- END FORGELOOP GENERATED: public-error-codes -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cassiomc1/forgeloop",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Portable, verifiable engineering protocol for AI coding environments and developer workflows",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -59,12 +59,15 @@
|
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "node scripts/run-tests.js",
|
|
61
61
|
"pack:check": "node --test tests/package.test.js",
|
|
62
|
+
"pack:smoke": "node scripts/package_smoke.mjs",
|
|
62
63
|
"release:identity": "node scripts/verify_release_identity.mjs",
|
|
63
64
|
"docs:flow": "node scripts/generate-readme-flow.mjs",
|
|
64
65
|
"docs:diagram:check": "node scripts/check-generated-diagram.mjs",
|
|
65
66
|
"docs:generate": "node scripts/generate_documentation_reference.mjs --write",
|
|
66
67
|
"docs:generated:check": "node scripts/generate_documentation_reference.mjs --check",
|
|
67
68
|
"docs:conformance": "node scripts/validate_documentation_conformance.mjs",
|
|
69
|
+
"docs:examples:check": "node scripts/validate_documentation_examples.mjs",
|
|
70
|
+
"docs:report": "node scripts/report_documentation_health.mjs",
|
|
68
71
|
"docs:check": "node scripts/run-docs-check.js",
|
|
69
72
|
"lint": "eslint .",
|
|
70
73
|
"coverage": "c8 --all --include=src/**/*.js --reporter=text --reporter=lcov --check-coverage --lines=80 --functions=75 --branches=70 --statements=80 node scripts/run-tests.js",
|
|
@@ -57,7 +57,17 @@
|
|
|
57
57
|
"startedAt": { "type": "string", "minLength": 1 },
|
|
58
58
|
"finishedAt": { "type": "string", "minLength": 1 },
|
|
59
59
|
"status": { "enum": ["passed", "failed"] },
|
|
60
|
-
"exitCode": { "oneOf": [{ "type": "integer", "minimum": 0 }, { "type": "null" }] }
|
|
60
|
+
"exitCode": { "oneOf": [{ "type": "integer", "minimum": 0 }, { "type": "null" }] },
|
|
61
|
+
"durationMs": { "type": "integer", "minimum": 0 },
|
|
62
|
+
"termination": { "enum": ["exit", "signal", "timeout", "spawn-error"] },
|
|
63
|
+
"signal": { "oneOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }] },
|
|
64
|
+
"stdoutSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
|
|
65
|
+
"stderrSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
|
|
66
|
+
"stdoutBytes": { "type": "integer", "minimum": 0 },
|
|
67
|
+
"stderrBytes": { "type": "integer", "minimum": 0 },
|
|
68
|
+
"outputTruncated": { "type": "boolean" }
|
|
69
|
+
,"timeoutMs": { "type": "integer", "minimum": 1 }
|
|
70
|
+
,"terminationGraceMs": { "type": "integer", "minimum": 1 }
|
|
61
71
|
},
|
|
62
72
|
"additionalProperties": false
|
|
63
73
|
}
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"failures": { "type": "array", "items": { "type": "object" } },
|
|
60
60
|
"blockers": { "type": "array", "items": { "type": "object" } },
|
|
61
61
|
"lastUpdated": { "type": "string", "minLength": 1 },
|
|
62
|
+
"revision": { "type": "integer", "minimum": 0 },
|
|
62
63
|
"previousPhase": { "type": "string" },
|
|
63
64
|
"diagnosedHypothesis": { "type": "string", "minLength": 1 },
|
|
64
65
|
"verificationEvidence": { "type": "array", "items": { "type": "object" } },
|
package/src/cli.js
CHANGED
|
@@ -46,7 +46,10 @@ import { formatTaskListResult, runTaskList } from "./commands/task-list.js";
|
|
|
46
46
|
import { formatTaskShowResult, runTaskShow } from "./commands/task-show.js";
|
|
47
47
|
import { formatTaskScopeResult, runTaskScope } from "./commands/task-scope.js";
|
|
48
48
|
import { formatTaskMigrateResult, runTaskMigrate } from "./commands/task-migrate.js";
|
|
49
|
+
import { formatMigrateProtocolResult, runMigrateProtocol } from "./commands/migrate-protocol.js";
|
|
49
50
|
import { formatTaskUnlockResult, runTaskUnlock } from "./commands/task-unlock.js";
|
|
51
|
+
import { formatTaskLockStatusResult, runTaskLockStatus } from "./commands/task-lock-status.js";
|
|
52
|
+
import { formatProtocolInfoResult, runProtocolInfo } from "./commands/protocol-info.js";
|
|
50
53
|
import { continuityOptionDefaults, validateContinuityOptions } from "./core/continuity-cli-options.js";
|
|
51
54
|
import { resolveTarget } from "./core/filesystem.js";
|
|
52
55
|
import { getPackageRoot } from "./core/templates.js";
|
|
@@ -340,7 +343,7 @@ export function validateCliSemantics({ command, options } = {}) {
|
|
|
340
343
|
if (!options.checkRequirement) throw new Error("run-check requires --requirement");
|
|
341
344
|
if (options.checkKind || options.checkStatus || options.checkEvidenceKind || options.checkCommand
|
|
342
345
|
|| options.checkResult || options.checkExitCode !== null || options.checkExecutionRef || options.checkProvenance) {
|
|
343
|
-
throw new Error("run-check accepts only --id, --requirement, --details, and -- <argv>");
|
|
346
|
+
throw new Error("run-check accepts only --id, --requirement, --details, --timeout-ms, and -- <argv>");
|
|
344
347
|
}
|
|
345
348
|
if (!Array.isArray(options.commandArgv) || options.commandArgv.length === 0) {
|
|
346
349
|
throw new Error("run-check requires -- followed by an exact command argv");
|
|
@@ -381,6 +384,11 @@ function printActions(actions) {
|
|
|
381
384
|
}
|
|
382
385
|
|
|
383
386
|
export const COMMAND_HANDLERS = Object.freeze({
|
|
387
|
+
"protocol-info": async ({ packageVersion, options }) => {
|
|
388
|
+
const result = await runProtocolInfo({ packageVersion });
|
|
389
|
+
console.log(options.json ? JSON.stringify(result, null, 2) : formatProtocolInfoResult(result));
|
|
390
|
+
return 0;
|
|
391
|
+
},
|
|
384
392
|
init: async ({ target, packageRoot, packageVersion, options }) => {
|
|
385
393
|
const result = await runInit({ target, dryRun: options.dryRun, packageRoot, packageVersion });
|
|
386
394
|
printActions(result.actions);
|
|
@@ -482,6 +490,7 @@ export const COMMAND_HANDLERS = Object.freeze({
|
|
|
482
490
|
requirement: options.checkRequirement,
|
|
483
491
|
argv: options.commandArgv,
|
|
484
492
|
details: options.checkDetails ?? undefined,
|
|
493
|
+
timeoutMs: options.timeoutMs ?? undefined,
|
|
485
494
|
taskId: options.task,
|
|
486
495
|
});
|
|
487
496
|
console.log(options.json ? JSON.stringify(result, null, 2) : formatRunCheckResult(result));
|
|
@@ -675,6 +684,11 @@ export const COMMAND_HANDLERS = Object.freeze({
|
|
|
675
684
|
console.log(options.json ? JSON.stringify(result, null, 2) : formatTaskShowResult(result));
|
|
676
685
|
return 0;
|
|
677
686
|
},
|
|
687
|
+
"task-lock-status": async ({ target, packageRoot, options }) => {
|
|
688
|
+
const result = await runTaskLockStatus({ target, packageRoot, taskId: options.task });
|
|
689
|
+
console.log(options.json ? JSON.stringify(result, null, 2) : formatTaskLockStatusResult(result));
|
|
690
|
+
return 0;
|
|
691
|
+
},
|
|
678
692
|
"task-scope": async ({ target, packageRoot, options }) => {
|
|
679
693
|
const result = await runTaskScope({
|
|
680
694
|
target,
|
|
@@ -690,8 +704,13 @@ export const COMMAND_HANDLERS = Object.freeze({
|
|
|
690
704
|
console.log(options.json ? JSON.stringify(result, null, 2) : formatTaskMigrateResult(result));
|
|
691
705
|
return 0;
|
|
692
706
|
},
|
|
707
|
+
"migrate-protocol": async ({ target, packageRoot, options }) => {
|
|
708
|
+
const result = await runMigrateProtocol({ target, packageRoot, to: options.to, dryRun: options.dryRun });
|
|
709
|
+
console.log(options.json ? JSON.stringify(result, null, 2) : formatMigrateProtocolResult(result));
|
|
710
|
+
return 0;
|
|
711
|
+
},
|
|
693
712
|
"task-unlock": async ({ target, packageRoot, options }) => {
|
|
694
|
-
const result = await runTaskUnlock({ target, packageRoot, taskId: options.task, force: options.force });
|
|
713
|
+
const result = await runTaskUnlock({ target, packageRoot, taskId: options.task, force: options.force, staleOnly: options.staleOnly });
|
|
695
714
|
console.log(options.json ? JSON.stringify(result, null, 2) : formatTaskUnlockResult(result));
|
|
696
715
|
return 0;
|
|
697
716
|
},
|
package/src/commands/doctor.js
CHANGED
|
@@ -4,6 +4,7 @@ import { readTemplateEntries } from "../core/templates.js";
|
|
|
4
4
|
import { createEvidence } from "../core/evidence.js";
|
|
5
5
|
import { LAYOUT_VERSION } from "../core/target-layout.js";
|
|
6
6
|
import { inspectNativeAdapter, validateNativeAdapterTargets } from "../core/native-adapters.js";
|
|
7
|
+
import { findIncompleteTransactions, recoverIncompleteTransactions } from "../core/transaction.js";
|
|
7
8
|
|
|
8
9
|
function finding(code, severity, relativePath, message, remediation = null, evidence = null) {
|
|
9
10
|
const evidenceRecord = evidence && typeof evidence === "object"
|
|
@@ -115,6 +116,27 @@ async function adoptAdapters({ target, manifest, adoptPaths, findings }) {
|
|
|
115
116
|
|
|
116
117
|
export async function runDoctor({ target, packageRoot, adoptPaths = [], strict = false, fix = false }) {
|
|
117
118
|
const findings = [];
|
|
119
|
+
const incompleteTransactions = await findIncompleteTransactions(target);
|
|
120
|
+
for (const transaction of incompleteTransactions) {
|
|
121
|
+
findings.push(finding(
|
|
122
|
+
"E_TRANSACTION_INCOMPLETE",
|
|
123
|
+
"error",
|
|
124
|
+
`.forgeloop/.txn/${transaction.transactionId}`,
|
|
125
|
+
`Transaction ${transaction.transactionId} is ${transaction.status} and requires inspection or deterministic recovery.`,
|
|
126
|
+
"Run forgeloop doctor --fix only after ensuring no active process owns the task lock.",
|
|
127
|
+
));
|
|
128
|
+
}
|
|
129
|
+
if (fix && incompleteTransactions.some((transaction) => transaction.status === "COMMITTING")) {
|
|
130
|
+
const recovered = await recoverIncompleteTransactions(target);
|
|
131
|
+
for (const transaction of recovered) {
|
|
132
|
+
findings.push(finding(
|
|
133
|
+
transaction.status === "ROLLED_BACK" ? "TRANSACTION_RECOVERED" : "E_TRANSACTION_RECOVERY_FAILED",
|
|
134
|
+
transaction.status === "ROLLED_BACK" ? "info" : "error",
|
|
135
|
+
`.forgeloop/.txn/${transaction.transactionId}`,
|
|
136
|
+
`Transaction recovery result: ${transaction.status}.`,
|
|
137
|
+
));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
118
140
|
let manifest = null;
|
|
119
141
|
let manifestChanged = false;
|
|
120
142
|
try {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { migrateProtocol } from "../core/protocol-migration.js";
|
|
2
|
+
|
|
3
|
+
export async function runMigrateProtocol({ target, packageRoot, to, dryRun = false } = {}) {
|
|
4
|
+
return migrateProtocol(target, { to, dryRun, packageRoot });
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function formatMigrateProtocolResult(result) {
|
|
8
|
+
const lines = [
|
|
9
|
+
`target protocol: ${result.toProtocol}`,
|
|
10
|
+
`status: ${result.status}`,
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
if (result.dryRun) lines.unshift("[dry-run]");
|
|
14
|
+
if (result.taskId) lines.push(`task: ${result.taskId}`);
|
|
15
|
+
if (result.targetDirectory) lines.push(`destination: ${result.targetDirectory}`);
|
|
16
|
+
lines.push(result.message ?? "legacy layout migration completed with a receipt");
|
|
17
|
+
return `${lines.join("\n")}\n`;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { protocolInfo } from "../core/protocol-info.js";
|
|
2
|
+
|
|
3
|
+
export async function runProtocolInfo({ packageVersion = null } = {}) {
|
|
4
|
+
return protocolInfo({ packageVersion });
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function formatProtocolInfoResult(result) {
|
|
8
|
+
return [
|
|
9
|
+
`Package version: ${result.packageVersion ?? "unknown"}`,
|
|
10
|
+
`Protocol version: ${result.protocolVersion}`,
|
|
11
|
+
`Schema version: ${result.compatibility.schemaVersion}`,
|
|
12
|
+
`Commands: ${result.commands.length}`,
|
|
13
|
+
`Guides: ${result.guides.length}`,
|
|
14
|
+
`Documented errors: ${result.errors.length}`,
|
|
15
|
+
].join("\n") + "\n";
|
|
16
|
+
}
|
|
@@ -12,6 +12,7 @@ export async function runCheck({
|
|
|
12
12
|
requirement,
|
|
13
13
|
argv,
|
|
14
14
|
details,
|
|
15
|
+
timeoutMs,
|
|
15
16
|
authorityContext,
|
|
16
17
|
runtimeContext,
|
|
17
18
|
taskId,
|
|
@@ -44,6 +45,7 @@ export async function runCheck({
|
|
|
44
45
|
verificationCycle,
|
|
45
46
|
argv,
|
|
46
47
|
details,
|
|
48
|
+
timeoutMs,
|
|
47
49
|
authorityContext,
|
|
48
50
|
runtimeContext,
|
|
49
51
|
});
|
|
@@ -3,7 +3,8 @@ import { assertTaskId } from "../core/task-identity.js";
|
|
|
3
3
|
import { createTaskDescriptor, writeTaskDescriptor } from "../core/task-descriptor.js";
|
|
4
4
|
import { normalizeWriteClaims, assertNoScopeConflicts, assertScopeClean } from "../core/task-scope.js";
|
|
5
5
|
import { discoverTasks, findTaskById } from "../core/task-discovery.js";
|
|
6
|
-
import { withProjectClaimsLock
|
|
6
|
+
import { withProjectClaimsLock } from "../core/task-lock.js";
|
|
7
|
+
import { withTaskTransaction } from "../core/transaction.js";
|
|
7
8
|
import { taskDirectory } from "../core/task-paths.js";
|
|
8
9
|
import { ensureWithin, fileExists } from "../core/filesystem.js";
|
|
9
10
|
import { validateContract, writeContract } from "../core/contract.js";
|
|
@@ -37,7 +38,7 @@ export async function runTaskCreate({ target, packageRoot, taskId, claims = [],
|
|
|
37
38
|
await assertScopeClean(target, normalizedClaims);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
return
|
|
41
|
+
return withTaskTransaction({ target, taskId, operation: "task-create", packageRoot, recordCommitEvent: true }, async () => {
|
|
41
42
|
const descriptor = createTaskDescriptor({
|
|
42
43
|
taskId,
|
|
43
44
|
writeClaims: normalizedClaims,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { resolveTaskContext } from "../core/task-context.js";
|
|
2
|
+
import { classifyLockStaleness, readLockInfo } from "../core/task-lock.js";
|
|
3
|
+
|
|
4
|
+
export async function runTaskLockStatus({ target, packageRoot, taskId } = {}) {
|
|
5
|
+
const context = await resolveTaskContext(target, { taskId, packageRoot, explicitRequired: true });
|
|
6
|
+
const lock = await readLockInfo(target, context.taskId);
|
|
7
|
+
if (!lock) {
|
|
8
|
+
return {
|
|
9
|
+
taskId: context.taskId,
|
|
10
|
+
taskKey: context.taskKey,
|
|
11
|
+
status: "UNLOCKED",
|
|
12
|
+
lock: null,
|
|
13
|
+
classification: null,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const classification = classifyLockStaleness(lock);
|
|
17
|
+
return {
|
|
18
|
+
taskId: context.taskId,
|
|
19
|
+
taskKey: context.taskKey,
|
|
20
|
+
status: classification.status,
|
|
21
|
+
lock,
|
|
22
|
+
classification,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function formatTaskLockStatusResult(result) {
|
|
27
|
+
if (result.status === "UNLOCKED") return `Task ${result.taskId} is unlocked\n`;
|
|
28
|
+
return `Task ${result.taskId} lock: ${result.status} (${result.lock.operation ?? "unknown operation"})\n`;
|
|
29
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveTaskContext } from "../core/task-context.js";
|
|
2
2
|
import { readTaskDescriptor } from "../core/task-descriptor.js";
|
|
3
|
-
import { readLockInfo } from "../core/task-lock.js";
|
|
3
|
+
import { classifyLockStaleness, readLockInfo } from "../core/task-lock.js";
|
|
4
4
|
import { taskDirectory, taskArtifactPath } from "../core/task-paths.js";
|
|
5
5
|
import { readWorkState } from "../core/work-state.js";
|
|
6
6
|
import { readContract } from "../core/contract.js";
|
|
@@ -54,7 +54,7 @@ export async function runTaskShow({ target, packageRoot, taskId } = {}) {
|
|
|
54
54
|
directory: taskDirectory(effectiveTaskId),
|
|
55
55
|
phase: state?.phase ?? "UNINITIALIZED",
|
|
56
56
|
writeClaims: descriptor.writeClaims ?? [],
|
|
57
|
-
lock: lockInfo,
|
|
57
|
+
lock: lockInfo ? { ...lockInfo, classification: classifyLockStaleness(lockInfo) } : null,
|
|
58
58
|
contract: contract ? { title: contract.title ?? null, taskType: contract.taskType ?? null } : null,
|
|
59
59
|
artifacts,
|
|
60
60
|
createdAt: descriptor.createdAt,
|
|
@@ -65,7 +65,7 @@ export async function runTaskShow({ target, packageRoot, taskId } = {}) {
|
|
|
65
65
|
export function formatTaskShowResult(result) {
|
|
66
66
|
const claims = result.writeClaims.length === 0 ? "none" : result.writeClaims.join(", ");
|
|
67
67
|
const lockStatus = result.lock
|
|
68
|
-
?
|
|
68
|
+
? `${result.lock.classification.status}: locked by PID ${result.lock.pid ?? "unknown"} since ${result.lock.acquiredAt ?? "unknown"}`
|
|
69
69
|
: "unlocked";
|
|
70
70
|
const lines = [
|
|
71
71
|
`Task: ${result.taskId}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveTaskContext } from "../core/task-context.js";
|
|
2
|
-
import { forceUnlockTask, readLockInfo } from "../core/task-lock.js";
|
|
2
|
+
import { classifyLockStaleness, forceUnlockTask, readLockInfo } from "../core/task-lock.js";
|
|
3
3
|
|
|
4
|
-
export async function runTaskUnlock({ target, packageRoot, taskId, force = false } = {}) {
|
|
4
|
+
export async function runTaskUnlock({ target, packageRoot, taskId, force = false, staleOnly = false } = {}) {
|
|
5
5
|
const context = await resolveTaskContext(target, { taskId, packageRoot, explicitRequired: true });
|
|
6
6
|
const effectiveTaskId = context.taskId;
|
|
7
7
|
|
|
@@ -15,18 +15,20 @@ export async function runTaskUnlock({ target, packageRoot, taskId, force = false
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const classification = classifyLockStaleness(lockInfo);
|
|
19
|
+
if (!force && !(staleOnly && classification.stale)) {
|
|
19
20
|
const error = new Error(`Task ${effectiveTaskId} is locked by operation "${lockInfo.operation ?? "unknown"}" (PID ${lockInfo.pid ?? "unknown"}). Use --force to unlock.`);
|
|
20
21
|
error.code = "E_TASK_LOCKED";
|
|
21
22
|
throw error;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
await forceUnlockTask(target, effectiveTaskId);
|
|
25
|
+
const unlocked = await forceUnlockTask(target, effectiveTaskId, { staleOnly });
|
|
25
26
|
return {
|
|
26
27
|
taskId: effectiveTaskId,
|
|
27
28
|
taskKey: context.taskKey,
|
|
28
|
-
unlocked:
|
|
29
|
-
|
|
29
|
+
unlocked: unlocked.unlocked,
|
|
30
|
+
classification: unlocked.classification,
|
|
31
|
+
message: unlocked.unlocked ? `Released lock for task ${effectiveTaskId}` : `Task ${effectiveTaskId} lock is not stale`,
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
|