@cassiomc1/forgeloop 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/DOCS_INDEX.md +13 -8
  2. package/EXECUTION_STATE.md +20 -0
  3. package/LOOP_ENGINEERING.md +81 -0
  4. package/LOOP_SYSTEM_DESIGN.md +32 -0
  5. package/PROTOCOL_INTEGRATION.md +46 -0
  6. package/QUALITY_SCORECARD.md +2 -0
  7. package/README.md +31 -9
  8. package/THIRD_PARTY_NOTICES.md +15 -0
  9. package/THREAT_MODEL.md +39 -0
  10. package/docs/ARTIFACT_REFERENCE.md +140 -0
  11. package/docs/CLI_REFERENCE.md +294 -3
  12. package/docs/DIAGNOSTIC_MODEL.md +181 -0
  13. package/docs/DOCUMENTATION_GUIDE.md +22 -13
  14. package/docs/EXECUTION_TRACE.md +76 -0
  15. package/docs/MCP.md +33 -0
  16. package/docs/RECIPES.md +67 -0
  17. package/docs/TROUBLESHOOTING.md +106 -2
  18. package/docs/assets/diagrams/forgeloop-engineering-flow.html +13797 -0
  19. package/docs/assets/diagrams/forgeloop-engineering-flow.receipt.json +37 -0
  20. package/docs/assets/diagrams/forgeloop-engineering-flow.svg +5002 -0
  21. package/docs/diagrams/README.md +55 -0
  22. package/docs/diagrams/forgeloop-engineering-flow.workflow.json +122 -0
  23. package/docs/diagrams/manifest.json +42 -0
  24. package/docs/diagrams/reviews/forgeloop-engineering-flow.review.json +20 -0
  25. package/package.json +8 -6
  26. package/schemas/action.schema.json +100 -0
  27. package/schemas/approval.schema.json +51 -0
  28. package/schemas/capability-policy.schema.json +41 -0
  29. package/schemas/diagnostic-case.schema.json +85 -0
  30. package/schemas/execution-receipt.schema.json +16 -0
  31. package/schemas/hypothesis-disposition.schema.json +16 -0
  32. package/schemas/intervention.schema.json +27 -0
  33. package/schemas/policy-lock.schema.json +1 -0
  34. package/schemas/policy-snapshot.schema.json +2 -0
  35. package/schemas/trajectory-evaluation.schema.json +64 -0
  36. package/schemas/trajectory-scenario.schema.json +42 -0
  37. package/src/cli.js +94 -0
  38. package/src/commands/action-authorize.js +41 -0
  39. package/src/commands/action-propose.js +10 -0
  40. package/src/commands/action-reconcile.js +10 -0
  41. package/src/commands/action-record.js +47 -0
  42. package/src/commands/action-show.js +10 -0
  43. package/src/commands/action-verify.js +10 -0
  44. package/src/commands/advance.js +7 -2
  45. package/src/commands/approval-request.js +64 -0
  46. package/src/commands/approval-resolve.js +10 -0
  47. package/src/commands/baseline.js +3 -3
  48. package/src/commands/eval.js +6 -0
  49. package/src/commands/history.js +18 -0
  50. package/src/commands/init.js +2 -2
  51. package/src/commands/inspect.js +49 -0
  52. package/src/commands/metrics.js +7 -0
  53. package/src/commands/next.js +8 -2
  54. package/src/commands/policy-discover.js +2 -2
  55. package/src/commands/record-diagnosis.js +37 -1
  56. package/src/commands/record-hypothesis-disposition.js +45 -0
  57. package/src/commands/record-intervention.js +35 -0
  58. package/src/commands/reflect.js +38 -0
  59. package/src/commands/report.js +9 -1
  60. package/src/commands/run-action.js +18 -0
  61. package/src/commands/trace.js +34 -0
  62. package/src/commands/validate-protocol.js +21 -13
  63. package/src/core/action-authorization.js +106 -0
  64. package/src/core/action-constants.js +86 -0
  65. package/src/core/action-execution.js +105 -0
  66. package/src/core/action-ledger-projection.js +302 -0
  67. package/src/core/action-model.js +581 -0
  68. package/src/core/action-readiness.js +141 -0
  69. package/src/core/action-reconciliation-policy.js +49 -0
  70. package/src/core/action-reconciliation.js +66 -0
  71. package/src/core/action-verification.js +111 -0
  72. package/src/core/actions.js +462 -0
  73. package/src/core/approvals.js +405 -0
  74. package/src/core/artifact-registry.js +48 -0
  75. package/src/core/audit.js +25 -0
  76. package/src/core/bundles.js +15 -0
  77. package/src/core/capability-policy.js +226 -0
  78. package/src/core/cli-command-definitions.js +210 -1
  79. package/src/core/command-executors.js +171 -15
  80. package/src/core/command-runtime.js +12 -1
  81. package/src/core/completion-artifacts.js +37 -12
  82. package/src/core/completion-recovery-rebind.js +194 -0
  83. package/src/core/completion.js +70 -0
  84. package/src/core/continuity-reconciliation.js +24 -5
  85. package/src/core/diagnostic-model.js +396 -0
  86. package/src/core/diagnostic-projection.js +51 -0
  87. package/src/core/diagnostic-record.js +360 -0
  88. package/src/core/error-codes.js +343 -0
  89. package/src/core/events.js +41 -1
  90. package/src/core/execution-prerequisites.js +4 -1
  91. package/src/core/execution.js +26 -188
  92. package/src/core/failure-signature.js +70 -0
  93. package/src/core/failure-surface.js +57 -0
  94. package/src/core/history.js +110 -0
  95. package/src/core/hypothesis-projection.js +85 -0
  96. package/src/core/information-gain-projection.js +283 -0
  97. package/src/core/information-gain.js +138 -0
  98. package/src/core/inspect.js +105 -7
  99. package/src/core/integration-invocation-policy.js +47 -0
  100. package/src/core/integration-resources.js +51 -0
  101. package/src/core/next-action-model.js +35 -1
  102. package/src/core/next-action.js +459 -3
  103. package/src/core/phase.js +40 -21
  104. package/src/core/policy-engine.js +113 -6
  105. package/src/core/preflight-consistency.js +31 -5
  106. package/src/core/preflight.js +19 -2
  107. package/src/core/prepared-execution.js +227 -0
  108. package/src/core/progress.js +41 -4
  109. package/src/core/protocol-info.js +48 -0
  110. package/src/core/protocol.js +14 -0
  111. package/src/core/receipt.js +1 -0
  112. package/src/core/reconcile-closure.js +15 -12
  113. package/src/core/reflection.js +305 -0
  114. package/src/core/resumability.js +57 -3
  115. package/src/core/schema-validation.js +8 -0
  116. package/src/core/strategy-analysis.js +97 -0
  117. package/src/core/task-paths.js +28 -0
  118. package/src/core/task-snapshot.js +53 -0
  119. package/src/core/templates.js +8 -0
  120. package/src/core/trace.js +548 -0
  121. package/src/core/trajectory-evaluation.js +71 -0
  122. package/src/core/trajectory-metrics.js +80 -0
  123. package/src/core/transaction.js +8 -0
  124. package/src/core/work-state.js +10 -5
  125. package/docs/assets/forgeloop-flow.svg +0 -1
  126. package/docs/forgeloop-flow.mmd +0 -51
@@ -39,11 +39,12 @@ ForgeLoop uses a definition-driven command-line parser:
39
39
 
40
40
  | Category | Commands |
41
41
  | --- | --- |
42
- | **Inspection & Diagnostics** | [`protocol-info`](#protocol-info), [`doctor`](#doctor), [`progress`](#progress), [`profile-interview`](#profile-interview), [`inspect`](#inspect), [`status`](#status), [`validate-state`](#validate-state), [`validate-protocol`](#validate-protocol) |
42
+ | **Inspection & Diagnostics** | [`protocol-info`](#protocol-info), [`doctor`](#doctor), [`metrics`](#metrics), [`eval`](#eval), [`history`](#history), [`trace`](#trace), [`reflect`](#reflect), [`progress`](#progress), [`profile-interview`](#profile-interview), [`inspect`](#inspect), [`status`](#status), [`validate-state`](#validate-state), [`validate-protocol`](#validate-protocol) |
43
43
  | **Setup & Maintenance** | [`init`](#init), [`update`](#update), [`task-migrate`](#task-migrate), [`migrate-protocol`](#migrate-protocol), [`task-unlock`](#task-unlock), [`task-recover`](#task-recover), [`task-repair-legacy-recovery`](#task-repair-legacy-recovery), [`task-resume`](#task-resume) |
44
- | **Lifecycle & State** | [`activate`](#activate), [`route`](#route), [`preflight`](#preflight), [`advance`](#advance), [`next`](#next), [`record-diagnosis`](#record-diagnosis), [`record-decision-criterion`](#record-decision-criterion), [`complete`](#complete), [`clear-state`](#clear-state), [`reconcile-closure`](#reconcile-closure), [`task-create`](#task-create), [`task-list`](#task-list), [`task-show`](#task-show), [`task-lock-status`](#task-lock-status), [`task-scope`](#task-scope) |
44
+ | **Lifecycle & State** | [`activate`](#activate), [`route`](#route), [`preflight`](#preflight), [`advance`](#advance), [`next`](#next), [`record-diagnosis`](#record-diagnosis), [`record-intervention`](#record-intervention), [`record-hypothesis-disposition`](#record-hypothesis-disposition), [`record-decision-criterion`](#record-decision-criterion), [`complete`](#complete), [`clear-state`](#clear-state), [`reconcile-closure`](#reconcile-closure), [`task-create`](#task-create), [`task-list`](#task-list), [`task-show`](#task-show), [`task-lock-status`](#task-lock-status), [`task-scope`](#task-scope) |
45
45
  | **Cross-Harness Continuity** | [`continuity`](#continuity), [`record-continuity`](#record-continuity), [`reconcile-continuity`](#reconcile-continuity), [`clear-continuity`](#clear-continuity) |
46
46
  | **Verification & Completion** | [`prepare-completion`](#prepare-completion), [`run-check`](#run-check), [`record-check`](#record-check), [`record-terminal-result`](#record-terminal-result), [`audit`](#audit), [`report`](#report), [`validate-receipt`](#validate-receipt) |
47
+ | **Durable Actions & Approvals** | [`run-action`](#run-action), [`action-propose`](#action-propose), [`action-record`](#action-record), [`action-show`](#action-show), [`action-reconcile`](#action-reconcile), [`action-verify`](#action-verify), [`action-authorize`](#action-authorize), [`approval-request`](#approval-request), [`approval-resolve`](#approval-resolve) |
47
48
  | **Policy & Auditing** | [`policy`](#policy), [`policy-discover`](#policy-discover), [`policy-status`](#policy-status), [`policy-diff`](#policy-diff), [`rule-verify`](#rule-verify), [`baseline`](#baseline), [`bundle`](#bundle) |
48
49
 
49
50
  <!-- END FORGELOOP GENERATED: cli-command-index -->
@@ -52,6 +53,163 @@ ForgeLoop uses a definition-driven command-line parser:
52
53
 
53
54
  ## 1. Setup & Maintenance
54
55
 
56
+ ## Durable Actions, Approvals, and Trajectory
57
+
58
+ ForgeLoop is still a protocol/evidence layer, not an agent runtime. Use
59
+ `COMMIT_UNKNOWN` as a hard stop: do not retry until an external observation is
60
+ recorded with `action-reconcile`. `run-action` has no shell mode and executes
61
+ only exact argv. Caller-reported and externally observed provenance are not host authority, and a project capability policy cannot mint host authority.
62
+
63
+ ### `run-action`
64
+
65
+ <!-- BEGIN FORGELOOP GENERATED: cli:run-action:options -->
66
+
67
+ - `--path <directory>`: target project directory (default: current directory)
68
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
69
+ - `--action <id>`: stable durable action ID
70
+ - `--capability <capability>`: canonical action capability
71
+ - `--effect-class <class>`: durable action effect class
72
+ - `--target <target>`: bounded external action target
73
+ - `--idempotency-key <key>`: immutable logical action idempotency key
74
+ - `--requirement <id>`: bound completion requirement
75
+ - `--required-for-completion`: mark the action as required for completion
76
+ - `--approval <id>`: current fingerprint-bound approval
77
+ - `--timeout-ms <number>`: maximum command duration before termination
78
+ - `-- <argv...>`: exact command argv; shell mode is never used
79
+ - `--json`: emit structured output as JSON
80
+
81
+ <!-- END FORGELOOP GENERATED: cli:run-action:options -->
82
+
83
+ ### `action-propose`
84
+
85
+ <!-- BEGIN FORGELOOP GENERATED: cli:action-propose:options -->
86
+
87
+ - `--path <directory>`: target project directory (default: current directory)
88
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
89
+ - `--id <id>`: stable action ID
90
+ - `--capability <capability>`: canonical capability
91
+ - `--effect-class <class>`: effect class
92
+ - `--target <target>`: bounded action target
93
+ - `--operation <text>`: bounded operation description
94
+ - `--idempotency-key <key>`: logical action idempotency key
95
+ - `--requirement <id>`: bound requirement
96
+ - `--required-for-completion`: mark required for completion
97
+ - `--json`: emit structured output as JSON
98
+
99
+ <!-- END FORGELOOP GENERATED: cli:action-propose:options -->
100
+
101
+ ### `action-record`
102
+
103
+ <!-- BEGIN FORGELOOP GENERATED: cli:action-record:options -->
104
+
105
+ - `--path <directory>`: target project directory (default: current directory)
106
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
107
+ - `--action <id>`: durable action ID
108
+ - `--state <state>`: next canonical action state
109
+ - `--provenance <value>`: CALLER_REPORTED or EXTERNAL_OBSERVED
110
+ - `--evidence-ref <ref>`: bounded external evidence reference
111
+ - `--json`: emit structured output as JSON
112
+
113
+ <!-- END FORGELOOP GENERATED: cli:action-record:options -->
114
+
115
+ ### `action-show`
116
+
117
+ <!-- BEGIN FORGELOOP GENERATED: cli:action-show:options -->
118
+
119
+ - `--path <directory>`: target project directory (default: current directory)
120
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
121
+ - `--action <id>`: durable action ID
122
+ - `--json`: emit structured output as JSON
123
+
124
+ <!-- END FORGELOOP GENERATED: cli:action-show:options -->
125
+
126
+ ### `action-verify`
127
+
128
+ <!-- BEGIN FORGELOOP GENERATED: cli:action-verify:options -->
129
+
130
+ - `--path <directory>`: target project directory (default: current directory)
131
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
132
+ - `--action <id>`: durable action ID
133
+ - `--evidence <ref>`: canonical execution or check reference proving the postcondition
134
+ - `--json`: emit structured output as JSON
135
+
136
+ <!-- END FORGELOOP GENERATED: cli:action-verify:options -->
137
+
138
+ ### `action-authorize`
139
+
140
+ <!-- BEGIN FORGELOOP GENERATED: cli:action-authorize:options -->
141
+
142
+ - `--path <directory>`: target project directory (default: current directory)
143
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
144
+ - `--action <id>`: durable action ID
145
+ - `--approval <id>`: current fingerprint-bound approval
146
+ - `--json`: emit structured output as JSON
147
+
148
+ <!-- END FORGELOOP GENERATED: cli:action-authorize:options -->
149
+
150
+ ### `action-reconcile`
151
+
152
+ <!-- BEGIN FORGELOOP GENERATED: cli:action-reconcile:options -->
153
+
154
+ - `--path <directory>`: target project directory (default: current directory)
155
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
156
+ - `--action <id>`: ambiguous durable action ID
157
+ - `--outcome <outcome>`: externally observed reconciliation outcome
158
+ - `--evidence-ref <ref>`: bounded external evidence reference (repeatable)
159
+ - `--observed-at <timestamp>`: external observation timestamp
160
+ - `--json`: emit structured output as JSON
161
+
162
+ <!-- END FORGELOOP GENERATED: cli:action-reconcile:options -->
163
+
164
+ ### `metrics`
165
+
166
+ <!-- BEGIN FORGELOOP GENERATED: cli:metrics:options -->
167
+
168
+ - `--path <directory>`: target project directory (default: current directory)
169
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
170
+ - `--json`: emit trajectory metrics as JSON
171
+
172
+ <!-- END FORGELOOP GENERATED: cli:metrics:options -->
173
+
174
+ ### `eval`
175
+
176
+ <!-- BEGIN FORGELOOP GENERATED: cli:eval:options -->
177
+
178
+ - `--path <directory>`: target project directory (default: current directory)
179
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
180
+ - `--scenario <path>`: project-local trajectory scenario JSON
181
+ - `--json`: emit evaluation as JSON
182
+
183
+ <!-- END FORGELOOP GENERATED: cli:eval:options -->
184
+
185
+ ### `approval-request`
186
+
187
+ <!-- BEGIN FORGELOOP GENERATED: cli:approval-request:options -->
188
+
189
+ - `--path <directory>`: target project directory (default: current directory)
190
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
191
+ - `--approval <id>`: approval artifact ID
192
+ - `--action <id>`: bound action ID
193
+ - `--reason <text>`: bounded approval reason
194
+ - `--json`: emit structured output as JSON
195
+
196
+ <!-- END FORGELOOP GENERATED: cli:approval-request:options -->
197
+
198
+ ### `approval-resolve`
199
+
200
+ <!-- BEGIN FORGELOOP GENERATED: cli:approval-resolve:options -->
201
+
202
+ - `--path <directory>`: target project directory (default: current directory)
203
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
204
+ - `--approval <id>`: approval artifact ID
205
+ - `--decision <decision>`: approval decision
206
+ - `--authority <kind>`: CALLER_ACKNOWLEDGED or HOST_ATTESTED
207
+ - `--host-grant-ref <ref>`: host boundary grant reference
208
+ - `--reason <text>`: bounded resolution reason
209
+ - `--json`: emit structured output as JSON
210
+
211
+ <!-- END FORGELOOP GENERATED: cli:approval-resolve:options -->
212
+
55
213
  ### `protocol-info`
56
214
 
57
215
  Reports the public compatibility handshake required by external ForgeLoop harnesses.
@@ -496,6 +654,7 @@ Records an append-only diagnosis event in the lifecycle event ledger for the act
496
654
 
497
655
  - `--path <directory>`: target project directory (default: current directory)
498
656
  - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
657
+ - `--file <path>`: structured diagnostic case JSON file (mutually exclusive with legacy diagnosis fields)
499
658
  - `--hypothesis <text>`: specific root-cause hypothesis explaining the verification failure
500
659
  - `--failure-class <class>`: canonical failure class taxonomy
501
660
  - `--evidence-ref <check-id>`: reference to failed/blocked check from current cycle (repeatable)
@@ -516,6 +675,63 @@ Records an append-only diagnosis event in the lifecycle event ledger for the act
516
675
  --next-safe-action="Adjust offset +1 in slice.js"
517
676
  ```
518
677
 
678
+ ### `record-intervention`
679
+
680
+ Records an append-only intervention bound to hypotheses; the described change is never executed by ForgeLoop.
681
+
682
+ - **Purpose**: Records corrective or experimental changes (code, config, tests, instrumentation) associated with one or more hypotheses.
683
+ - **When to use**: In `CORRECTING` phase after a structured diagnostic case has been recorded.
684
+ - **Mutation**: Appends `INTERVENTION_RECORDED` to event ledger.
685
+ - **Options**:
686
+
687
+ <!-- BEGIN FORGELOOP GENERATED: cli:record-intervention:options -->
688
+
689
+ - `--path <directory>`: target project directory (default: current directory)
690
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
691
+ - `--file <path>`: intervention JSON file describing the recorded change (never executed)
692
+ - `--json`: emit structured output as JSON
693
+
694
+ <!-- END FORGELOOP GENERATED: cli:record-intervention:options -->
695
+
696
+ - **Example**:
697
+
698
+ ```bash
699
+ forgeloop record-intervention --task checkout --file intervention.json --json
700
+ ```
701
+
702
+ ### `record-hypothesis-disposition`
703
+
704
+ Records an evidence-bound hypothesis disposition update in the lifecycle event ledger.
705
+
706
+ - **Purpose**: Updates hypothesis status (SUPPORTED, WEAKENED, FALSIFIED, SUPERSEDED, UNRESOLVED) based on recorded evidence.
707
+ - **When to use**: After new verification evidence resolves an open hypothesis.
708
+ - **Mutation**: Appends `HYPOTHESIS_DISPOSITION_RECORDED` to event ledger.
709
+ - **Options**:
710
+
711
+ <!-- BEGIN FORGELOOP GENERATED: cli:record-hypothesis-disposition:options -->
712
+
713
+ - `--path <directory>`: target project directory (default: current directory)
714
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
715
+ - `--hypothesis <id>`: existing hypothesis ID to disposition
716
+ - `--status <status>`: SUPPORTED, WEAKENED, FALSIFIED, SUPERSEDED, or UNRESOLVED
717
+ - `--evidence-ref <check-id>`: check ID supporting this disposition (repeatable)
718
+ - `--reason <text>`: evidence-bound reason for the disposition
719
+ - `--json`: emit structured output as JSON
720
+
721
+ <!-- END FORGELOOP GENERATED: cli:record-hypothesis-disposition:options -->
722
+
723
+ - **Example**:
724
+
725
+ ```bash
726
+ forgeloop record-hypothesis-disposition \
727
+ --task checkout \
728
+ --hypothesis h-timeout-latency \
729
+ --status SUPPORTED \
730
+ --evidence-ref checkout-tests \
731
+ --reason "Instrumented dependency time exceeded the timeout." \
732
+ --json
733
+ ```
734
+
519
735
  ### `validate-state`
520
736
 
521
737
  Validates `.forgeloop/task-state/<taskKey>/work-state.json` structure, hash chain, and repository binding.
@@ -821,7 +1037,7 @@ Displays human-readable or structured summary of current task state.
821
1037
 
822
1038
  ### `inspect`
823
1039
 
824
- Inspects checkout changes and compares them against contract deliverables.
1040
+ Inspects checkout changes and compares them against contract deliverables. With `--task <id>`, human output renders a task inspection report (phase, cycle, ledger/snapshot health, progress, verification attempts, diagnostics, failure surface, signals, next command); `--json` keeps the full additive `taskInspection` section.
825
1041
 
826
1042
  - **Purpose**: Shows modified files, untracked files, and deliverable coverage.
827
1043
  - **Mutation**: Read-only.
@@ -842,6 +1058,81 @@ Inspects checkout changes and compares them against contract deliverables.
842
1058
  forgeloop inspect --json
843
1059
  ```
844
1060
 
1061
+ ### `history`
1062
+
1063
+ Shows chronological protocol history reconstructed from canonical ForgeLoop state.
1064
+
1065
+ - **Purpose**: Answers "what happened during this task?" with deterministic, read-only reconstruction from the event ledger.
1066
+ - **Mutation**: Read-only.
1067
+ - **Options**:
1068
+
1069
+ <!-- BEGIN FORGELOOP GENERATED: cli:history:options -->
1070
+
1071
+ - `--path <directory>`: target project directory (default: current directory)
1072
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
1073
+ - `--type <list>`: comma-separated event types or categories to include
1074
+ - `--phase <list>`: comma-separated lifecycle phases to include
1075
+ - `--failures`: show only failed/blocked verification events
1076
+ - `--checks`: show only verification events
1077
+ - `--since <timestamp>`: include events at or after this timestamp
1078
+ - `--until <timestamp>`: include events at or before this timestamp
1079
+ - `--limit <number>`: show only the last N events after filtering
1080
+ - `--compact`: one line per event
1081
+ - `--verbose`: show full event data
1082
+ - `--json`: emit structured history output as JSON
1083
+
1084
+ <!-- END FORGELOOP GENERATED: cli:history:options -->
1085
+
1086
+ - **Example**:
1087
+
1088
+ ```bash
1089
+ forgeloop history --task auth-feature --json
1090
+ ```
1091
+
1092
+ ### `trace`
1093
+
1094
+ Emits detailed structured task trace with provenance and artifact relationships.
1095
+
1096
+ - **Purpose**: Machine-readable protocol reconstruction consumed by history, reflect, task-level inspect, and external integrations.
1097
+ - **Mutation**: Read-only.
1098
+ - **Options**:
1099
+
1100
+ <!-- BEGIN FORGELOOP GENERATED: cli:trace:options -->
1101
+
1102
+ - `--path <directory>`: target project directory (default: current directory)
1103
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
1104
+ - `--json`: emit structured trace output as JSON (default rendering is a summary)
1105
+
1106
+ <!-- END FORGELOOP GENERATED: cli:trace:options -->
1107
+
1108
+ - **Example**:
1109
+
1110
+ ```bash
1111
+ forgeloop trace --task auth-feature --json
1112
+ ```
1113
+
1114
+ ### `reflect`
1115
+
1116
+ Analyzes diagnostic and correction history deterministically for information gain, repeated failures, ineffective interventions, and oscillation.
1117
+
1118
+ - **Purpose**: Whole-task retrospective that reports whether the run actually learned anything, without calling an LLM.
1119
+ - **Mutation**: Read-only.
1120
+ - **Options**:
1121
+
1122
+ <!-- BEGIN FORGELOOP GENERATED: cli:reflect:options -->
1123
+
1124
+ - `--path <directory>`: target project directory (default: current directory)
1125
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
1126
+ - `--json`: emit structured reflection output as JSON
1127
+
1128
+ <!-- END FORGELOOP GENERATED: cli:reflect:options -->
1129
+
1130
+ - **Example**:
1131
+
1132
+ ```bash
1133
+ forgeloop reflect --task auth-feature --json
1134
+ ```
1135
+
845
1136
  ### `policy`
846
1137
 
847
1138
  Evaluates compliance against a named policy pack.
@@ -0,0 +1,181 @@
1
+ # ForgeLoop Diagnostic Model
2
+
3
+ Canonical reference for structured diagnostic cases, interventions, and hypothesis dispositions (ForgeLoop 1.6.0+, Protocol v1 additive).
4
+
5
+ ## Principles
6
+
7
+ 1. **Observation is not hypothesis.** Observations are bounded statements grounded in recorded evidence. Hypotheses are falsifiable claims that may explain observations.
8
+ 2. **Hypothesis is not proof.** Statuses are `OPEN`, `SUPPORTED`, `WEAKENED`, `FALSIFIED`, `SUPERSEDED`, `UNRESOLVED`. ForgeLoop never emits `ROOT_CAUSE_CONFIRMED` or similar.
9
+ 3. **Append-only truth.** Diagnostic revisions are never rewritten; the ledger records evolving understanding.
10
+ 4. **Diagnostic prose is metadata.** Statements, settlement predicates, and next-safe-action text are never executed by ForgeLoop.
11
+
12
+ ## Structured diagnostic case
13
+
14
+ One diagnostic revision for one verification cycle, recorded with:
15
+
16
+ ```bash
17
+ forgeloop record-diagnosis --task <id> --file diagnostic-case.json --json
18
+ ```
19
+
20
+ Legacy flag-based `record-diagnosis` syntax remains valid; both forms cannot be combined.
21
+
22
+ Schema: `schemas/diagnostic-case.schema.json`. Bounded limits: 64 observations, 64 contributors, 32 hypotheses per case; statements up to 4096 characters; IDs match `^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$`.
23
+
24
+ ### Semantic fingerprint
25
+
26
+ `diagnosticFingerprint` hashes the canonicalized semantic content (cycle, failure class, observations/contributors/hypotheses semantics, next-safe action). Whitespace, key ordering, unordered reference arrays, and object IDs are excluded. Re-recording a semantically identical case is idempotent.
27
+
28
+ ### Revisions
29
+
30
+ `diagnosticRevision` starts at 1 and increases monotonically per cycle. Each revision binds `previousDiagnosticFingerprint` to the prior active revision.
31
+
32
+ ## Interventions
33
+
34
+ Recorded in `CORRECTING` phase:
35
+
36
+ ```bash
37
+ forgeloop record-intervention --task <id> --file intervention.json --json
38
+ ```
39
+
40
+ Interventions bind to at least one recorded hypothesis and carry a semantic fingerprint used to detect repetition without information gain.
41
+
42
+ ## Hypothesis dispositions
43
+
44
+ ```bash
45
+ forgeloop record-hypothesis-disposition --task <id> \
46
+ --hypothesis h-timeout-latency --status SUPPORTED \
47
+ --evidence-ref checkout-tests --reason "..." --json
48
+ ```
49
+
50
+ Allowed transitions: `OPEN → {SUPPORTED, WEAKENED, FALSIFIED, SUPERSEDED, UNRESOLVED}`, `SUPPORTED → {WEAKENED, FALSIFIED, SUPERSEDED}`, `WEAKENED → {SUPPORTED, FALSIFIED, SUPERSEDED}`.
51
+
52
+ ## Diagnostic precedence
53
+
54
+ One canonical resolver backs every lifecycle gate, `next`, `progress`, and reflection:
55
+
56
+ 1. latest valid structured diagnostic case (`DIAGNOSTIC_CASE_RECORDED`) for the active task/cycle;
57
+ 2. latest valid legacy diagnosis (`DIAGNOSIS_RECORDED`) for the active task/cycle;
58
+ 3. none.
59
+
60
+ Structured diagnosis is therefore a first-class protocol-native diagnostic source: a task using only `record-diagnosis --file` can traverse `DIAGNOSING -> CORRECTING -> VERIFYING` without any legacy event, and no duplicate legacy event is synthesized. Legacy diagnosis remains fully valid as a compatibility input.
61
+
62
+ ## Hypothesis state projection
63
+
64
+ Hypothesis status is projected forward from append-only chronology (case creation in `OPEN`, then each disposition validated against the last effective projected state) — never re-read from the source case. Terminal states (`FALSIFIED`, `SUPERSEDED`, `UNRESOLVED`) do not transition unless a future protocol revision explicitly allows reopening. Invalid transitions fail closed with `E_HYPOTHESIS_DISPOSITION_INVALID`. `trace`, `reflect`, and continuity `openHypotheses` all consume this same projection.
65
+
66
+ ## Evidence binding
67
+
68
+ Structured cases require at least one hypothesis; `CHECK_RESULT` observations must resolve to a real check from the active verification cycle; a `VERIFICATION_FAILURE` case must bind at least one hypothesis or observation to failed/blocked evidence from the active cycle. Revision chains are revalidated at read time (`revision N.previousDiagnosticFingerprint == revision N-1.diagnosticFingerprint`).
69
+
70
+ ## Effective gain definition
71
+
72
+ Effective Information Gain exists when a diagnostic cycle changes a meaningful
73
+ semantic dimension of the verified engineering state:
74
+
75
+ ```text
76
+ new observation new contributor new hypothesis
77
+ new evidence hypothesis disposition hypothesis elimination
78
+ failure signature failure surface intervention semantics
79
+ strategy
80
+ ```
81
+
82
+ All of these participate in `effectiveGain`. Semantic noise — new IDs,
83
+ timestamps, property order, whitespace-equivalent paraphrases — never does.
84
+
85
+ ## Classification vs effective gain
86
+
87
+ The compatibility classification (`FIRST_DIAGNOSIS`, `NEW_HYPOTHESIS`,
88
+ `NEW_EVIDENCE`, `NEW_HYPOTHESIS_AND_EVIDENCE`, `NONE`) intentionally does not
89
+ encode every v2 dimension. A cycle can therefore report:
90
+
91
+ ```text
92
+ classification = NONE
93
+ failureSurfaceChanged = true
94
+ effectiveGain = true
95
+ ```
96
+
97
+ `effectiveGain` is computed once from the final dimensions by the authoritative
98
+ cycle analysis projection; consumers (progress, reflect, next, inspect,
99
+ continuity) must not recompute or post-mutate it.
100
+
101
+ ## Stall policy (fail-fast)
102
+
103
+ A structured diagnostic state is **stalled** when its latest comparable
104
+ diagnostic state has no effective information gain. There is no two-cycle
105
+ threshold: one no-gain comparison blocks another blind correction retry with
106
+ `E_DIAGNOSIS_NO_NEW_INFORMATION`, and progress/reflect/next/inspect expose the
107
+ same condition. The first diagnosis is never stalled. High correction-cycle
108
+ count alone remains advisory (`WATCH`), never `STALLED`.
109
+
110
+ Stall is not terminal: recording a diagnostic with meaningful new information
111
+ (a new observation, contributor, evidence, hypothesis change, and so on)
112
+ clears it immediately. Strategy oscillation (`A -> B -> A`) keeps the more
113
+ specific `INTRODUCE_NEW_OBSERVATION` guidance over generic no-gain guidance.
114
+ Historical repetition metrics remain available as reflective explanation
115
+ (`stallAnalysis`) but do not change the stall decision. Semantic noise — new IDs,
116
+ timestamps, property order, whitespace-equivalent paraphrases — never counts as
117
+ gain or as hypothesis elimination.
118
+
119
+ ## Failure surface evolution
120
+
121
+ Every canonically verified cycle appears in failure surfaces, including
122
+ successful ones:
123
+
124
+ ```text
125
+ cycle 2 ["lint"]
126
+ cycle 3 [] <- explicit empty successful cycle, direction REDUCED
127
+ ```
128
+
129
+ A full reduction to `[]` classifies the preceding intervention as `IMPROVED`.
130
+
131
+ ## Intervention repetition
132
+
133
+ ```text
134
+ repeatedSemanticIntervention
135
+ = the same intervention semantic fingerprint was recorded before
136
+
137
+ NON_INFORMATIVE
138
+ = later verification produced no meaningful semantic change
139
+ ```
140
+
141
+ Recording an intervention returns `repeatedSemanticIntervention` plus
142
+ `effectiveness: "PENDING"`. Only a subsequent completed verification cycle can
143
+ classify `IMPROVED | REGRESSED | INFORMATIVE | NON_INFORMATIVE`.
144
+
145
+ ## Continuity diagnostic context
146
+
147
+ ```json
148
+ {
149
+ "activeFailureSignatures": ["<sha256-like canonical fingerprint>"],
150
+ "activeFailedRequirements": ["auth-tests"],
151
+ "openHypotheses": [],
152
+ "latestIntervention": null,
153
+ "nextExperiment": null,
154
+ "doNotRepeat": []
155
+ }
156
+ ```
157
+
158
+ `activeFailureSignatures` contains canonical `computeFailureSignature` hashes
159
+ scoped to the active verification cycle; requirement names are exposed
160
+ separately in `activeFailedRequirements`.
161
+
162
+ ## Structured case hypothesis invariant
163
+
164
+ At least one hypothesis is mandatory: `hypotheses.minItems = 1` is enforced
165
+ identically by the JSON schema, the runtime validator, ledger validation, and
166
+ the record-diagnosis command path.
167
+
168
+ ## Information gain
169
+
170
+ Compatibility values (`FIRST_DIAGNOSIS`, `NEW_HYPOTHESIS`, `NEW_EVIDENCE`, `NEW_HYPOTHESIS_AND_EVIDENCE`, `NONE`) remain valid. Structured dimensions add observation/contributor/hypothesis novelty, disposition changes, failure-signature change, failure-surface change, and intervention change. New IDs, timestamps, whitespace, paraphrases, and identical reruns never constitute gain.
171
+
172
+ ## Stall and oscillation
173
+
174
+ - High correction-cycle count alone is advisory (`WATCH`), never `STALLED`.
175
+ - Strong stall requires identical failure signature, strategy, contributors, hypotheses, surface, and no new evidence across consecutive cycles. Two consecutive correction cycles without effective gain under the same strategy reach `STALLED` (`REQUIRE_NEW_DIAGNOSTIC_INFORMATION`).
176
+ - Repetition of an intervention is not automatically non-informative: effectiveness (`PENDING | IMPROVED | REGRESSED | INFORMATIVE | NON_INFORMATIVE`) is classified only after subsequent verification. Continuity `doNotRepeat` requires semantic repetition AND at least two completed post-intervention verification cycles AND unchanged failure surface.
177
+ - Oscillation (`A→B→A`) surfaces as `OSCILLATING_STRATEGY`; `next` recommends `INTRODUCE_NEW_OBSERVATION`.
178
+
179
+ ## Capability discovery
180
+
181
+ `forgeloop protocol-info --json` advertises `features.diagnostics`, `executionHistory`, `structuredTrace`, `taskInspection`, and `reflection`.
@@ -14,7 +14,7 @@ ForgeLoop strictly separates normative protocol definitions from operational doc
14
14
  | **Operational & Reference** | `docs/` (`GETTING_STARTED.md`, `CROSS_HARNESS_CONTINUITY.md`, `CLI_REFERENCE.md`, `ARTIFACT_REFERENCE.md`, `TROUBLESHOOTING.md`, `RECIPES.md`) | Tutorials, command reference, handoff workflows, and troubleshooting | Explains how to operate the system. Links to normative sources for formal specifications. |
15
15
  | **Domain Engineering** | `ENG/` (`clean-code-eng.md`, `design-code-eng.md`, `test-code-eng.md`, etc.) | Domain-specific implementation and quality standards | Frontmatter must adhere to `validate_loop_system.py` standards. |
16
16
  | **Consumer Documentation Quality** | [`ENG/documentation-quality-eng.md`](../ENG/documentation-quality-eng.md) | Quality standards for documentation work in projects using ForgeLoop | Governs client/consumer project documentation tasks via guide routing. |
17
- | **Visual Architecture** | `docs/forgeloop-flow.mmd` | Canonical architecture diagram source | Rendered SVG committed at `docs/assets/forgeloop-flow.svg`. |
17
+ | **Visual Architecture** | `docs/diagrams/manifest.json` + `docs/diagrams/forgeloop-engineering-flow.workflow.json` | Governance metadata and canonical typed Archify workflow source | Animated HTML explorer, animated SVG fallback, deterministic receipt, and source-bound human review are committed under `docs/assets/diagrams/` and `docs/diagrams/reviews/`. |
18
18
  | **Documentation Index** | `DOCS_INDEX.md` | Single repository index and ownership map | Updated whenever documentation structure changes. |
19
19
 
20
20
  ---
@@ -84,7 +84,7 @@ cross-platform CI (.github/workflows/docs-quality.yml)
84
84
  | **CLI Command Options** | `CLI_COMMAND_DEFINITIONS` (`src/core/cli-command-definitions.js`) | `docs/CLI_REFERENCE.md` | `<!-- BEGIN FORGELOOP GENERATED: cli:<command>:options -->` |
85
85
  | **Work-State Transitions** | `WORK_PHASES` / `WORK_TRANSITIONS` (`src/core/protocol.js`) | `ORCHESTRATOR_INTEGRATION.md` | `<!-- BEGIN FORGELOOP GENERATED: work-transitions -->` |
86
86
  | **Public Error Codes** | `PUBLIC_ERROR_CODES` (`src/core/error-codes.js`) | `docs/TROUBLESHOOTING.md` | `<!-- BEGIN FORGELOOP GENERATED: public-error-codes -->` |
87
- | **Architecture Flow** | `docs/forgeloop-flow.mmd` | `docs/assets/forgeloop-flow.svg` | Verified via embedded SHA-256 fingerprint |
87
+ | **Architecture Flow** | `docs/diagrams/manifest.json` + `docs/diagrams/forgeloop-engineering-flow.workflow.json` | `docs/assets/diagrams/forgeloop-engineering-flow.{html,svg,receipt.json}` + `docs/diagrams/reviews/forgeloop-engineering-flow.review.json` | Verified via pinned Archify renderer, trace-animation markers, source/SVG fingerprints, artifact hashes, persistent review, and composition checks |
88
88
 
89
89
  ### Maintenance Workflow
90
90
 
@@ -122,7 +122,7 @@ conformance checks detect omissions.
122
122
  | **Discovery resume rules** | `DISCOVERY_SURFACES` & `nativeShim` | `scripts/validate_documentation_conformance.mjs` |
123
123
  | **Task-layout path freshness** | `TASK_LAYOUT_DOCUMENTS` & `task-paths.js` | `scripts/validate_documentation_conformance.mjs` |
124
124
  | **Package-shipped docs** | `package.json` (`files`) | `tests/package.test.js` |
125
- | **Architecture diagram** | `docs/forgeloop-flow.mmd` | `scripts/check-generated-diagram.mjs` |
125
+ | **Architecture diagram** | `docs/diagrams/forgeloop-engineering-flow.workflow.json` | `scripts/check-documentation-diagrams.mjs` and `scripts/documentation-diagram-inventory.mjs` |
126
126
 
127
127
  ---
128
128
 
@@ -177,21 +177,29 @@ migration, or security-sensitive require `npm run docs:check` before merge.
177
177
 
178
178
  ---
179
179
 
180
- ## 7. Mermaid Diagrams and SVG Generation
180
+ ## 7. Archify Diagrams and Animated SVG Generation
181
181
 
182
- 1. **Source is Canonical**: Diagram source files live in `.mmd` files (e.g. `docs/forgeloop-flow.mmd`). Never modify SVG files directly.
183
- 2. **Local Committed SVGs**: Generated SVGs are committed locally in `docs/assets/`. Never hotlink externally rendered diagram images.
184
- 3. **Self-Contained & GitHub-Safe**: Generated SVGs must not import external stylesheets (e.g. `@import url(...)`), must not embed `<script>` or `<foreignObject>`, and must be visible via standard Markdown image syntax (`![alt](./path.svg)`).
185
- 4. **Fingerprint Verification**: Generated SVGs embed a `data-forgeloop-source-sha256` attribute verified by `npm run docs:check`.
182
+ 1. **Typed source is canonical**: The architecture flow is authored in Archify workflow IR at `docs/diagrams/forgeloop-engineering-flow.workflow.json`. Never modify generated HTML or SVG files directly.
183
+ 2. **Pinned local renderer**: Generation uses only the vendored Archify v2.15.0 source at the reviewed commit recorded in `docs/diagrams/manifest.json` and `vendor/archify/v2.15.0/PIN.json`.
184
+ 3. **Animated committed outputs**: The source uses `meta.animation: "trace"`. The interactive HTML is the primary animated explorer, and the self-contained SVG fallback carries trace-capable edge/node animation while remaining usable in repository previews. The deterministic receipt is committed under `docs/assets/diagrams/`.
185
+ 4. **GitHub-safe SVG**: The SVG must not embed `<script>` or `<foreignObject>`, must expose accessible title/description metadata, and must remain visible through standard Markdown image syntax.
186
+ 5. **Fingerprint and review verification**: The generated SVG embeds a `data-forgeloop-source-sha256` attribute, the outputs expose trace markers, and the receipt binds the source, HTML, and SVG hashes. The human-owned review at `docs/diagrams/reviews/` binds the current source and SVG hashes and is never generated or overwritten. Run `npm run docs:diagrams:check` before review.
187
+ 6. **Scoped wrapper**: The ForgeLoop Archify wrapper is intentionally documentation-scoped. It reads canonical inputs only from `docs/diagrams/` and permits deliver outputs only under `docs/assets/diagrams/`.
188
+
189
+ ForgeLoop governs five documentation-diagram categories: workflow,
190
+ architecture, sequence, dataflow, and lifecycle. The current repository has
191
+ one canonical workflow diagram. Governance support does not imply renderer
192
+ support: a type requires an explicit renderer mapping before it can be added as
193
+ an active diagram.
186
194
 
187
195
  ---
188
196
 
189
197
  ## 8. README Hero and Package Boundary
190
198
 
191
199
  README hero assets are branding/conceptual illustrations. They are not the
192
- canonical protocol diagram. `docs/forgeloop-flow.mmd` remains the canonical
193
- architecture flow source and `docs/assets/forgeloop-flow.svg` remains its
194
- generated render.
200
+ canonical protocol diagram. The typed Archify workflow under `docs/diagrams/`
201
+ remains the canonical architecture flow source, with generated outputs under
202
+ `docs/assets/diagrams/`.
195
203
 
196
204
  The README hero is intentionally GitHub-repository-only:
197
205
 
@@ -206,8 +214,9 @@ The README hero is intentionally GitHub-repository-only:
206
214
  packaged Markdown must be present in the package and covered by
207
215
  `tests/package.test.js`.
208
216
 
209
- Never delete `docs/assets/forgeloop-flow.svg`; it is generator-owned output of
210
- the diagram workflow.
217
+ Never edit or delete a generated diagram output independently of its source;
218
+ regenerate `docs/assets/diagrams/` from the typed workflow and keep the receipt
219
+ in sync.
211
220
 
212
221
  ---
213
222