@cassiomc1/forgeloop 1.8.1 → 1.10.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 (93) hide show
  1. package/.cursor/rules/project-loop.mdc +6 -3
  2. package/.github/copilot-instructions.md +5 -0
  3. package/AGENTS.md +6 -0
  4. package/AGENT_COMPATIBILITY.md +15 -0
  5. package/CLAUDE.md +6 -0
  6. package/DELEGATION_PROTOCOL.md +6 -0
  7. package/DOCS_INDEX.md +9 -2
  8. package/ENG/accessibility-eng.md +12 -2
  9. package/ENG/design-code-eng.md +22 -1
  10. package/LOOP_ENGINEERING.md +41 -0
  11. package/LOOP_SYSTEM_DESIGN.md +33 -0
  12. package/ORCHESTRATOR_INTEGRATION.md +9 -0
  13. package/PROTOCOL_INTEGRATION.md +57 -0
  14. package/QUALITY_SCORECARD.md +2 -0
  15. package/README.md +51 -0
  16. package/TERMINOLOGY.md +12 -0
  17. package/THREAT_MODEL.md +48 -0
  18. package/completions/_forgeloop +5 -1
  19. package/completions/forgeloop.bash +9 -1
  20. package/completions/forgeloop.fish +27 -1
  21. package/docs/ADVISORY_CONTEXT.md +174 -0
  22. package/docs/AGENT_PROTOCOL_SUMMARY.md +33 -2
  23. package/docs/ARTIFACT_REFERENCE.md +142 -0
  24. package/docs/CLI_REFERENCE.md +124 -1
  25. package/docs/CROSS_HARNESS_CONTINUITY.md +85 -0
  26. package/docs/DOCUMENTATION_GUIDE.md +7 -0
  27. package/docs/GETTING_STARTED.md +22 -0
  28. package/docs/KNOWLEDGE_SOURCES.md +171 -0
  29. package/docs/MCP.md +17 -1
  30. package/docs/RECIPES.md +111 -0
  31. package/docs/RELEASE_CHECKLIST.md +14 -0
  32. package/docs/STRUCTURAL_QUALITY.md +350 -0
  33. package/docs/TROUBLESHOOTING.md +161 -2
  34. package/docs/UNIVERSAL_INTEGRATION.md +60 -0
  35. package/package.json +4 -1
  36. package/schemas/config.schema.json +46 -0
  37. package/schemas/handoff-envelope.schema.json +1 -0
  38. package/schemas/preflight.schema.json +2 -1
  39. package/schemas/structural-quality.schema.json +175 -0
  40. package/scripts/check-changelog-freshness.mjs +27 -3
  41. package/scripts/generate-agent-protocol-summary.mjs +18 -0
  42. package/src/cli.js +24 -0
  43. package/src/commands/handoff-accept.js +36 -0
  44. package/src/commands/handoff-list.js +28 -2
  45. package/src/commands/handoff-show.js +27 -2
  46. package/src/commands/quality-baseline.js +28 -0
  47. package/src/commands/quality-status.js +34 -0
  48. package/src/commands/quality-verify.js +30 -0
  49. package/src/commands/reconcile-continuity.js +4 -0
  50. package/src/core/advisory-context/constants.js +74 -0
  51. package/src/core/advisory-context/provider.js +287 -0
  52. package/src/core/advisory-context/service.js +140 -0
  53. package/src/core/artifact-registry.js +12 -0
  54. package/src/core/audit.js +38 -0
  55. package/src/core/bundles.js +134 -1
  56. package/src/core/cli-command-definitions.js +62 -0
  57. package/src/core/command-executors.js +28 -0
  58. package/src/core/command-input.js +23 -1
  59. package/src/core/completion-artifacts.js +2 -0
  60. package/src/core/completion.js +42 -0
  61. package/src/core/config.js +3 -0
  62. package/src/core/continuity-lint.js +89 -0
  63. package/src/core/continuity-reconciliation.js +16 -0
  64. package/src/core/continuity.js +10 -11
  65. package/src/core/error-codes.js +186 -0
  66. package/src/core/events.js +32 -0
  67. package/src/core/execution-profile-context.js +15 -1
  68. package/src/core/filesystem.js +34 -3
  69. package/src/core/handoff-acceptance.js +277 -0
  70. package/src/core/handoff.js +41 -8
  71. package/src/core/inspect.js +64 -0
  72. package/src/core/integration-invocation-policy.js +34 -2
  73. package/src/core/integration-resources.js +38 -1
  74. package/src/core/next-action-model.js +11 -1
  75. package/src/core/next-action-phases.js +84 -5
  76. package/src/core/phase.js +9 -1
  77. package/src/core/portable-context.js +103 -0
  78. package/src/core/preflight.js +33 -0
  79. package/src/core/protocol-info.js +33 -2
  80. package/src/core/runtime-context.js +58 -0
  81. package/src/core/schema-validation.js +1 -0
  82. package/src/core/structural-quality/artifacts.js +329 -0
  83. package/src/core/structural-quality/constants.js +67 -0
  84. package/src/core/structural-quality/policy.js +227 -0
  85. package/src/core/structural-quality/provider.js +287 -0
  86. package/src/core/structural-quality/sentrux-mcp.js +477 -0
  87. package/src/core/structural-quality/service.js +1138 -0
  88. package/src/core/structural-quality/source-fingerprint.js +112 -0
  89. package/src/core/structural-quality/status.js +3 -0
  90. package/src/core/task-paths.js +24 -0
  91. package/src/core/templates.js +1 -0
  92. package/src/integration.d.ts +141 -0
  93. package/src/integration.js +36 -0
@@ -35,6 +35,7 @@ All artifact schemas are defined in `schemas/*.schema.json`. Persisted artifact
35
35
  | `task-state/<task-key>/approvals/approval-<id>.json` | `approval` | Protocol Managed | Append Decision Once | Action Approval Attestation |
36
36
  | `policy/capabilities.json` | `capability-policy` | Operator Or Agent | Mutable Configuration | Capability Policy Specification |
37
37
  | `task-state/<task-key>/evaluations/eval-<id>.json` | `trajectory-evaluation` | Protocol Compiled | Immutable Once Written | Trajectory Evaluation |
38
+ | `task-state/<task-key>/structural-quality/baseline.json` | `structural-quality` | Protocol Compiled | Baseline Immutable After Execution | Structural Quality Evidence |
38
39
  | `task-state/<task-key>/usage.json` | `usage` | Actor Or Trusted Host | Overwritten On Usage Record | Informational Usage Telemetry |
39
40
  | `task-state/<task-key>/workspace-binding.json` | `workspace-binding` | Protocol Generated | Immutable After Bind | Workspace Identity Binding |
40
41
  | `task-state/<task-key>/handoffs/handoff-<id>.json` | `handoff-envelope` | Protocol Compiled | Immutable Once Written | Canonical Handoff Snapshot |
@@ -165,6 +166,7 @@ Readiness attestation evaluated prior to implementation.
165
166
  - `fingerprints` *(object, optional)*
166
167
  - `sources` *(object, optional)*
167
168
  - `policy` *(object, optional)*
169
+ - `structuralQuality` *(object, optional)*
168
170
 
169
171
  <!-- END FORGELOOP GENERATED: schema:preflight -->
170
172
 
@@ -250,6 +252,28 @@ Local ForgeLoop configuration settings and policy bindings.
250
252
  - `policy` *(string, optional, minLength: 1)*
251
253
  - `requiredGates` *(array<string>, optional)*
252
254
  - `requiredEvidence` *(array<string>, optional)*
255
+ - `structuralQuality` *(object, optional)*
256
+ - `mode` *(string, optional, enum: `off`, `observe`, `gate`)*
257
+ - `provider` *(string, optional, pattern: `^[a-z][a-z0-9-]{0,63}$`)*
258
+ - `maxRegressionPoints` *(integer, optional, minimum: 0, maximum: 10000)*
259
+ - `dimensionBudgets` *(dimensionMap, optional)*
260
+ - `modularity` *(integer or null, optional)*
261
+ - `acyclicity` *(integer or null, optional)*
262
+ - `depth` *(integer or null, optional)*
263
+ - `equality` *(integer or null, optional)*
264
+ - `redundancy` *(integer or null, optional)*
265
+ - `forbidNewCycles` *(boolean, optional)*
266
+ - `minQualitySignal` *(integer or null, optional)*
267
+ - `minimums` *(minimumMap, optional)*
268
+ - `modularity` *(integer, optional, minimum: 0, maximum: 10000)*
269
+ - `acyclicity` *(integer, optional, minimum: 0, maximum: 10000)*
270
+ - `depth` *(integer, optional, minimum: 0, maximum: 10000)*
271
+ - `equality` *(integer, optional, minimum: 0, maximum: 10000)*
272
+ - `redundancy` *(integer, optional, minimum: 0, maximum: 10000)*
273
+ - `optimization` *(object, optional)*
274
+ - `mode` *(string, optional, enum: `off`, `bounded`)*
275
+ - `maxExtraEvaluations` *(integer, optional, minimum: 0, maximum: 2)*
276
+ - `minGainPoints` *(integer, optional, minimum: 1, maximum: 10000)*
253
277
  - `verification` *(object, optional)*
254
278
  - `checkers` *(array<object>, required)*
255
279
  - `checkId` *(string, required, minLength: 1)*
@@ -926,6 +950,7 @@ completion, or authority evidence.
926
950
  - `phase` *(string, required, minLength: 1)*
927
951
  - `revision` *(integer, required, minimum: 0)*
928
952
  - `verificationCycle` *(integer, required, minimum: 1)*
953
+ - `workStateFingerprint` *(string, optional, pattern: `^[a-f0-9]{64}$`)*
929
954
  - `contractFingerprint` *(string, required, pattern: `^[a-f0-9]{64}$`)*
930
955
  - `routeFingerprint` *(string or null, required)*
931
956
  - `repositoryFingerprint` *(object, required)*
@@ -941,6 +966,19 @@ completion, or authority evidence.
941
966
 
942
967
  <!-- END FORGELOOP GENERATED: schema:handoff-envelope -->
943
968
 
969
+ The handoff `state` binds the immutable snapshot to the exact
970
+ `workStateFingerprint`, contract identity, route identity, selected-guide
971
+ context, repository branch/HEAD fingerprint, changed paths, and historical
972
+ write claims observed at creation. `HANDOFF_CREATED` records the envelope's
973
+ relationship to the task ledger. A later `HANDOFF_ACCEPTED` event records only
974
+ that one consumer operationally consumed the unchanged snapshot; it does not
975
+ transfer claims, create evidence, or grant authority.
976
+
977
+ Acceptance status is a derived projection from the immutable handoff, its
978
+ digest, and the validated event ledger. Acceptance fields are intentionally not
979
+ stored in the handoff JSON itself. Invalid or mismatched ledger history
980
+ projects `INCONSISTENT`, never a successful acceptance.
981
+
944
982
  ### 2.27 `task-state/<taskKey>/responsibility.json`
945
983
 
946
984
  <!-- forgeloop-doc: schema=responsibility artifact=.forgeloop/task-state/<task-key>/responsibility.json -->
@@ -1075,3 +1113,107 @@ back-reference itself from the execution receipt.
1075
1113
  Optional external signing-provider bundle. Its presence is not proof of a
1076
1114
  valid signature; verification must be performed by the configured signing
1077
1115
  provider with the requested identity and issuer policy.
1116
+
1117
+ ### 2.32 `task-state/<taskKey>/structural-quality/`
1118
+
1119
+ <!-- forgeloop-doc: schema=structural-quality artifact=.forgeloop/task-state/<task-key>/structural-quality/baseline.json -->
1120
+
1121
+ Task-owned provider-neutral structural-quality evidence. The directory contains
1122
+ one immutable `baseline.json` and zero or more typed evaluations under
1123
+ `evaluations/cycle-<cycle>-attempt-<attempt>.json`. There is deliberately no
1124
+ `latest.json`; readers derive the latest evaluation by numeric cycle and
1125
+ attempt ordering.
1126
+
1127
+ The baseline is captured before execution and cannot be replaced after
1128
+ `EXECUTING` begins. Evaluations bind the current verification cycle to the
1129
+ baseline, contract, route, policy, scope, provider identity, and persisted
1130
+ check projection. Portable bundles include the evidence needed for audit and
1131
+ validate it without starting the provider.
1132
+
1133
+ #### Canonical Fields
1134
+
1135
+ <!-- BEGIN FORGELOOP GENERATED: schema:structural-quality -->
1136
+
1137
+ - `schemaVersion` *(number, required, const: 1)*
1138
+ - `protocolVersion` *(number, required, const: 1)*
1139
+ - `role` *(string, required, enum: `BASELINE`, `EVALUATION`)*
1140
+ - `taskId` *(string, required, minLength: 1)*
1141
+ - `capturedAt` *(string, required, minLength: 1)*
1142
+ - `verificationCycle` *(integer or null, required)*
1143
+ - `attempt` *(integer, required, minimum: 1)*
1144
+ - `status` *(string, required, enum: `PASS`, `FAIL`, `BLOCKED`, `NOT_OBSERVED`)*
1145
+ - `reasonCodes` *(array<string>, required)*
1146
+ - `errorCode` *(string or null, optional)*
1147
+ - `baselineSignal` *(integer or null, optional)*
1148
+ - `currentSignal` *(integer or null, optional)*
1149
+ - `bindings` *(object, required)*
1150
+ - `contractFingerprint` *(string, required, pattern: `^[a-f0-9]{64}$`)*
1151
+ - `routeFingerprint` *(string, required, pattern: `^[a-f0-9]{64}$`)*
1152
+ - `policyFingerprint` *(string, required, pattern: `^[a-f0-9]{64}$`)*
1153
+ - `scopeFingerprint` *(string, required, pattern: `^[a-f0-9]{64}$`)*
1154
+ - `baselineFingerprint` *(string or null, optional)*
1155
+ - `sourceMaterialFingerprint` *(string or null, optional)*
1156
+ - `stateRevision` *(integer, optional, minimum: 0)*
1157
+ - `sourceObservation` *(object, optional)*
1158
+ - `beforeFingerprint` *(string, required, pattern: `^[a-f0-9]{64}$`)*
1159
+ - `afterFingerprint` *(string, required, pattern: `^[a-f0-9]{64}$`)*
1160
+ - `stable` *(boolean, required)*
1161
+ - `provider` *(object, required)*
1162
+ - `id` *(string, required, minLength: 1)*
1163
+ - `version` *(string or null, required)*
1164
+ - `transport` *(string, required, minLength: 1)*
1165
+ - `executionMode` *(string, required, minLength: 1)*
1166
+ - `measurementModel` *(string, optional, minLength: 1)*
1167
+ - `compatibilityKey` *(string or null, optional)*
1168
+ - `detection` *(object, optional)*
1169
+ - `available` *(boolean, required)*
1170
+ - `providerId` *(string, required, minLength: 1)*
1171
+ - `providerVersion` *(string or null, optional)*
1172
+ - `transport` *(string, required, minLength: 1)*
1173
+ - `measurementModel` *(string, optional, minLength: 1)*
1174
+ - `compatibilityKey` *(string or null, optional)*
1175
+ - `reasonCode` *(string or null, required)*
1176
+ - `scope` *(object, required)*
1177
+ - `kind` *(string, required, const: `PROJECT`)*
1178
+ - `projectRoot` *(string, required, const: `.`)*
1179
+ - `providerConfigFingerprint` *(string or null, optional)*
1180
+ - `architectureRulesFingerprint` *(string, optional, pattern: `^[a-f0-9]{64}$`)*
1181
+ - `snapshot` *(snapshot, optional)*
1182
+ - `qualitySignal` *(integer, required, minimum: 0, maximum: 10000)*
1183
+ - `bottleneck` *(string, required, enum: `modularity`, `acyclicity`, `depth`, `equality`, `redundancy`)*
1184
+ - `rootCauses` *(object, required)*
1185
+ - `modularity` *(rootCause, required)*
1186
+ - `score` *(integer, required, minimum: 0, maximum: 10000)*
1187
+ - `raw` *(number, required)*
1188
+ - `acyclicity` *(rootCause, required)*
1189
+ - `score` *(integer, required, minimum: 0, maximum: 10000)*
1190
+ - `raw` *(number, required)*
1191
+ - `depth` *(rootCause, required)*
1192
+ - `score` *(integer, required, minimum: 0, maximum: 10000)*
1193
+ - `raw` *(number, required)*
1194
+ - `equality` *(rootCause, required)*
1195
+ - `score` *(integer, required, minimum: 0, maximum: 10000)*
1196
+ - `raw` *(number, required)*
1197
+ - `redundancy` *(rootCause, required)*
1198
+ - `score` *(integer, required, minimum: 0, maximum: 10000)*
1199
+ - `raw` *(number, required)*
1200
+ - `statistics` *(object, required)*
1201
+ - `files` *(integer or null, required)*
1202
+ - `lines` *(integer or null, required)*
1203
+ - `importEdges` *(integer or null, required)*
1204
+ - `crossModuleEdges` *(integer or null, required)*
1205
+ - `diagnostics` *(object or null, required)*
1206
+ - `comparison` *(comparison, optional)*
1207
+ - `comparable` *(boolean, required)*
1208
+ - `qualityDelta` *(integer or null, required)*
1209
+ - `rootCauseDeltas` *(object, required)*
1210
+ - `failedConditions` *(array<string>, optional)*
1211
+ - `status` *(string, required, enum: `PASS`, `FAIL`, `BLOCKED`, `NOT_OBSERVED`)*
1212
+ - `reasonCodes` *(array<string>, required)*
1213
+
1214
+ <!-- END FORGELOOP GENERATED: schema:structural-quality -->
1215
+
1216
+ For `BASELINE` artifacts and `PASS`/`FAIL` evaluations, `sourceMaterialFingerprint`
1217
+ and stable `sourceObservation` are conditionally required; their before and after
1218
+ fingerprints must equal the bound source fingerprint. `BLOCKED` and
1219
+ `NOT_OBSERVED` artifacts may omit these observed-source fields.
@@ -61,11 +61,12 @@ error codes. Default output and default JSON remain unchanged.
61
61
  | **Inspection & Diagnostics** | [`protocol-info`](#protocol-info), [`doctor`](#doctor), [`metrics`](#metrics), [`usage-record`](#usage-record), [`efficiency`](#efficiency), [`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) |
62
62
  | **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) |
63
63
  | **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) |
64
+ | **Verification & Completion** | [`quality-baseline`](#quality-baseline), [`quality-verify`](#quality-verify), [`quality-status`](#quality-status), [`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), [`verify-scope`](#verify-scope) |
64
65
  | **Cross-Harness Continuity** | [`continuity`](#continuity), [`record-continuity`](#record-continuity), [`reconcile-continuity`](#reconcile-continuity), [`clear-continuity`](#clear-continuity), [`handoff-create`](#handoff-create), [`handoff-list`](#handoff-list), [`handoff-show`](#handoff-show) |
65
- | **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), [`verify-scope`](#verify-scope) |
66
66
  | **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) |
67
67
  | **Policy & Auditing** | [`policy`](#policy), [`policy-discover`](#policy-discover), [`policy-status`](#policy-status), [`policy-diff`](#policy-diff), [`rule-verify`](#rule-verify), [`baseline`](#baseline), [`bundle`](#bundle) |
68
68
  | **workspace** | [`workspace-bind`](#workspace-bind), [`workspace-status`](#workspace-status) |
69
+ | **task** | [`handoff-accept`](#handoff-accept) |
69
70
  | **scope** | [`responsibility-set`](#responsibility-set), [`responsibility-status`](#responsibility-status) |
70
71
  | **attestation** | [`attestation-create`](#attestation-create), [`attestation-verify`](#attestation-verify), [`attestation-status`](#attestation-status), [`attestation-verify-range`](#attestation-verify-range) |
71
72
 
@@ -157,6 +158,9 @@ Lists immutable handoff snapshots for a task.
157
158
 
158
159
  - **Purpose**: Inspect existing handoff snapshots without changing them.
159
160
  - **Mutation**: Read-only.
161
+ - **Acceptance projection**: Derives `OPEN`, `ACCEPTED`, `UNBOUND`, or
162
+ `INCONSISTENT` from the validated event ledger. Invalid or unreadable ledgers
163
+ are fail-closed and expose `reasonCodes`; they are never treated as empty.
160
164
  - **Options**:
161
165
 
162
166
  <!-- BEGIN FORGELOOP GENERATED: cli:handoff-list:options -->
@@ -178,6 +182,8 @@ Lists immutable handoff snapshots for a task.
178
182
  Reads and verifies one immutable handoff snapshot.
179
183
 
180
184
  - **Purpose**: Inspect one handoff by ID and validate its digest and bindings.
185
+ - **Acceptance projection**: Uses the same fail-closed ledger-derived status as
186
+ `handoff-list`.
181
187
  - **Mutation**: Read-only.
182
188
  - **Options**:
183
189
 
@@ -196,6 +202,37 @@ Reads and verifies one immutable handoff snapshot.
196
202
  forgeloop handoff-show --task task-001 --id handoff-001 --json
197
203
  ```
198
204
 
205
+ ### `handoff-accept`
206
+
207
+ Records exactly-once acceptance of an immutable handoff into the task event ledger.
208
+
209
+ - **Purpose**: Bind an incoming consumer/harness to an immutable handoff snapshot.
210
+ - **Mutation**: Appends a `HANDOFF_ACCEPTED` event.
211
+ - **Freshness**: Acceptance requires the current canonical state and directly
212
+ observed repository branch/HEAD to match the immutable snapshot, including a
213
+ clean committed HEAD drift check.
214
+ - **Human output**: Reports `authority: OPERATIONAL_RECEIPT_ONLY`,
215
+ `evidence: NONE`, and `claims transferred: NO`; acceptance is exactly-once
216
+ operational receipt only.
217
+ - **Options**:
218
+
219
+ <!-- BEGIN FORGELOOP GENERATED: cli:handoff-accept:options -->
220
+
221
+ - `--path <directory>`: target project directory (default: current directory)
222
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
223
+ - `--handoff <id>`: handoff identifier
224
+ - `--consumer-id <id>`: consumer identifier accepting the handoff
225
+ - `--harness <name>`: optional harness accepting the handoff
226
+ - `--json`: emit acceptance result as JSON
227
+
228
+ <!-- END FORGELOOP GENERATED: cli:handoff-accept:options -->
229
+
230
+ - **Example**:
231
+
232
+ ```bash
233
+ forgeloop handoff-accept --task task-001 --handoff handoff-001 --consumer-id agent-42 --json
234
+ ```
235
+
199
236
  ### `responsibility-set`
200
237
 
201
238
  Creates immutable constraints for the current task pass.
@@ -914,6 +951,9 @@ Records operational handoff context before pausing or switching tools.
914
951
  Reconciles continuity with the active work state and checkout.
915
952
 
916
953
  - **Purpose**: Compares continuity bindings against the canonical work state, contract, phase, repository fingerprint, and checkout state.
954
+ - **Lint**: Returns deterministic `PASS`/`WARN` findings for stale completed
955
+ item references, role conflicts, missing `inspectFirst` paths, and empty hint
956
+ sets without changing reconciliation classification.
917
957
  - **When to use**: When starting a session in an active task.
918
958
  - **Mutation**: Read-only.
919
959
  - **Options**:
@@ -1235,6 +1275,89 @@ Evaluates task progress across verification cycles and detects stalls determinis
1235
1275
 
1236
1276
  ## 5. Completion & Reporting
1237
1277
 
1278
+ ### `quality-baseline`
1279
+
1280
+ Captures the provider observation that becomes the task's structural-quality
1281
+ baseline.
1282
+
1283
+ - **Purpose**: Persist an immutable, task-bound structural-quality baseline before execution.
1284
+ - **When to use**: After a valid preflight checkpoint in `PLANNED`, before entering `EXECUTING`.
1285
+ - **Mutation**: Executes the configured provider, writes `baseline.json`, and appends a quality-baseline ledger event.
1286
+ - **Options**:
1287
+
1288
+ <!-- BEGIN FORGELOOP GENERATED: cli:quality-baseline:options -->
1289
+
1290
+ - `--path <directory>`: target project directory (default: current directory)
1291
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
1292
+ - `--replace`: replace a different baseline before EXECUTING
1293
+ - `--timeout-ms <number>`: bounded analyzer timeout in milliseconds
1294
+ - `--json`: emit baseline result as JSON
1295
+
1296
+ <!-- END FORGELOOP GENERATED: cli:quality-baseline:options -->
1297
+
1298
+ - **Example**:
1299
+
1300
+ ```bash
1301
+ forgeloop quality-baseline --task task-001 --json
1302
+ ```
1303
+
1304
+ Use `--replace` only for an intentional pre-execution baseline replacement.
1305
+ The superseded fingerprint remains in the append-only ledger. The command
1306
+ does not accept an executable path, shell fragment, arbitrary arguments, score,
1307
+ or baseline value.
1308
+
1309
+ ### `quality-verify`
1310
+
1311
+ Scans the current project through the configured structural-quality provider and
1312
+ compares it with the task baseline.
1313
+
1314
+ - **Purpose**: Record a current-cycle structural-quality evaluation and project it into the canonical `structural-quality` check.
1315
+ - **When to use**: In `VERIFYING`, before `REVIEWING`.
1316
+ - **Mutation**: Executes the configured provider, writes a typed evaluation, and records the bound check/evidence projection.
1317
+ - **Options**:
1318
+
1319
+ <!-- BEGIN FORGELOOP GENERATED: cli:quality-verify:options -->
1320
+
1321
+ - `--path <directory>`: target project directory (default: current directory)
1322
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
1323
+ - `--timeout-ms <number>`: bounded analyzer timeout in milliseconds
1324
+ - `--json`: emit structural-quality verification as JSON
1325
+
1326
+ <!-- END FORGELOOP GENERATED: cli:quality-verify:options -->
1327
+
1328
+ - **Example**:
1329
+
1330
+ ```bash
1331
+ forgeloop quality-verify --task task-001 --json
1332
+ ```
1333
+
1334
+ `PASS`, `FAIL`, `BLOCKED`, and `NOT_OBSERVED` remain distinct. A failed,
1335
+ unavailable, malformed, timed-out, truncated, stale, or incomparable provider
1336
+ result cannot become a passing check.
1337
+
1338
+ ### `quality-status`
1339
+
1340
+ Projects the persisted structural-quality evidence without launching a provider.
1341
+
1342
+ - **Purpose**: Inspect baseline, current-cycle status, policy comparison, and next guidance.
1343
+ - **When to use**: At any point when a read-only quality projection is needed.
1344
+ - **Mutation**: Read-only; it creates no provider process and writes no quality artifact.
1345
+ - **Options**:
1346
+
1347
+ <!-- BEGIN FORGELOOP GENERATED: cli:quality-status:options -->
1348
+
1349
+ - `--path <directory>`: target project directory (default: current directory)
1350
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
1351
+ - `--json`: emit persisted structural-quality status as JSON
1352
+
1353
+ <!-- END FORGELOOP GENERATED: cli:quality-status:options -->
1354
+
1355
+ - **Example**:
1356
+
1357
+ ```bash
1358
+ forgeloop quality-status --task task-001 --json
1359
+ ```
1360
+
1238
1361
  ### `prepare-completion`
1239
1362
 
1240
1363
  Initializes or refreshes `.forgeloop/task-state/<taskKey>/execution-receipt.json`.
@@ -114,6 +114,33 @@ exists, compare the current checkout, and only then follow `forgeloop next`.
114
114
  Handoff notes can focus inspection, but only valid execution evidence,
115
115
  completion receipts, and the append-only ledger can satisfy verification.
116
116
 
117
+ The complete immutable-handoff flow is:
118
+
119
+ ```bash
120
+ forgeloop handoff-create --task auth-feature --recipient codex --json
121
+ forgeloop handoff-list --task auth-feature --json
122
+ forgeloop handoff-show --task auth-feature --id <handoff-id> --json
123
+ forgeloop handoff-accept \
124
+ --task auth-feature \
125
+ --handoff <handoff-id> \
126
+ --consumer-id codex-session-42 \
127
+ --harness codex \
128
+ --json
129
+ ```
130
+
131
+ Before acceptance, the receiver must inspect the immutable snapshot and
132
+ reconcile all of its freshness bindings: the work-state fingerprint, contract
133
+ identity, route identity, selected guides, current repository branch, current
134
+ repository HEAD, changed paths, and the origin of the event ledger. Receiving a
135
+ file or message is not acceptance. `handoff-accept` is run only when the
136
+ receiving harness actually consumes the handoff.
137
+
138
+ Acceptance retry semantics are deterministic: retrying with the same
139
+ `consumerId` returns the existing operational receipt idempotently; a different
140
+ consumer fails with `E_HANDOFF_ALREADY_ACCEPTED`. An old unbound handoff remains
141
+ readable for historical continuity but is not acceptable and returns
142
+ `E_HANDOFF_ACCEPTANCE_UNBOUND`.
143
+
117
144
  ---
118
145
 
119
146
  ## 4. Harness A — Recording Handoff Context
@@ -251,3 +278,61 @@ Every discovery adapter (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules/project-loop.m
251
278
  > Discover task namespaces with ForgeLoop; if exactly one active task is healthy it may be selected implicitly; if multiple active tasks exist, select with `--task` or `FORGELOOP_TASK`.
252
279
  > Inspect the existing task, reconcile continuity when present, inspect the checkout, and run `forgeloop next`.
253
280
  > A change of harness, model, provider, IDE, process, terminal, or session does not create a new task.
281
+
282
+ ---
283
+
284
+ ## 8. Canonical Handoff Acceptance & State Binding
285
+
286
+ ### 8.1 Work-State Binding
287
+
288
+ Handoff envelopes (`.forgeloop/task-state/<taskKey>/handoffs/handoff-*.json`) bind to the exact lifecycle state snapshot at creation time via `state.workStateFingerprint`.
289
+ The envelope itself remains strictly immutable after creation.
290
+ A handoff is acceptable only when both canonical state and the current repository
291
+ checkout still match that immutable snapshot. A clean Git HEAD or branch change
292
+ can make a handoff stale even when the worktree has no uncommitted changes.
293
+
294
+ ### 8.2 Exactly-Once Handoff Acceptance
295
+
296
+ Harnesses taking ownership of an existing handoff record their acceptance into the task event ledger using `handoff-accept`:
297
+
298
+ ```bash
299
+ forgeloop handoff-accept \
300
+ --task auth-feature \
301
+ --handoff handoff-001 \
302
+ --consumer-id agent-session-42 \
303
+ --harness cursor \
304
+ --json
305
+ ```
306
+
307
+ Acceptance enforces:
308
+
309
+ 1. **Unbroken Binding**: Handoff must contain `workStateFingerprint` (legacy unbound handoffs fail with `E_HANDOFF_ACCEPTANCE_UNBOUND`).
310
+ 2. **Freshness**: Work state, contract fingerprint, route fingerprint, changed paths, and the directly observed current repository branch and HEAD must match the handoff snapshot (any drift fails with `E_HANDOFF_STALE`).
311
+ 3. **Single Consumer**: The handoff can be accepted by at most one consumer. If another consumer attempts acceptance, it fails with `E_HANDOFF_ALREADY_ACCEPTED`. Retrying with the same `consumerId` is idempotent.
312
+ 4. **Ledger Integrity**: An immutable `HANDOFF_ACCEPTED` event is appended to `events.ndjson`.
313
+
314
+ Acceptance is exactly-once operational receipt only. It does not transfer claims,
315
+ delegate work, authorize actions, approve review, or create verification evidence.
316
+
317
+ ### 8.3 Acceptance Inspection
318
+
319
+ Commands `handoff-show` and `handoff-list` project current acceptance status:
320
+
321
+ - `OPEN`: Handoff is valid, bound, and waiting for acceptance.
322
+ - `ACCEPTED`: Successfully accepted by a specific consumer.
323
+ - `UNBOUND`: Legacy handoff envelope lacking work-state binding.
324
+ - `INCONSISTENT`: Digest, ledger validation, or acceptance event mismatch detected. An unreadable or invalid ledger is never projected as `OPEN` or `ACCEPTED`; its unique sorted ledger error codes are exposed as `reasonCodes`.
325
+
326
+ ### 8.4 Semantic Continuity Linting
327
+
328
+ When running `forgeloop reconcile-continuity`, ForgeLoop executes deterministic
329
+ semantic lint checks against schema-valid operational hints. It warns when a
330
+ remaining-work item or current focus ID is already in `state.completedSteps`,
331
+ when an ID appears in both `remainingWork` and `knownIssues`, or when a relative
332
+ `inspectFirst` path is missing from the target. If all operational hints are
333
+ empty, it emits the informational `CONTINUITY_EMPTY_HINT_SET` finding while the
334
+ lint status remains `PASS`.
335
+
336
+ Lint results use `{ status: "PASS" | "WARN", findings: [...] }`. They are
337
+ non-authoritative, non-evidence diagnostics and do not change reconciliation
338
+ classification or lifecycle state.
@@ -38,6 +38,13 @@ MCP package boundary -> MCP package tests + scripts/mcp-package-smoke.mjs
38
38
 
39
39
  Operational documentation must explain canonical behavior, not redefine it.
40
40
 
41
+ Terminology must remain consistent across active documents: say “advisory
42
+ context,” not “canonical memory”; “handoff acceptance,” not “ownership
43
+ transfer”; and “operational receipt,” not “delegation.” Advisory output is
44
+ never canonical state, evidence, authority, completion truth, or next-action
45
+ authority. `consumerId`, harness names, recipient hints, and transport labels
46
+ are descriptive values rather than authenticated identity or authority.
47
+
41
48
  Documentation-impact questions for integration/MCP changes:
42
49
 
43
50
  - Did a server mode or capability gate change?
@@ -439,6 +439,8 @@ the workflow needs those boundaries:
439
439
  forgeloop handoff-create --task <taskId> --note "Continue verification" --json
440
440
  forgeloop handoff-list --task <taskId> --json
441
441
  forgeloop handoff-show --task <taskId> --id <handoffId> --json
442
+ forgeloop handoff-accept --task <taskId> --handoff <handoffId> \
443
+ --consumer-id <consumerId> --harness <harness> --json
442
444
  forgeloop responsibility-set --task <taskId> --label implementation --allowed-path src --required-check unit-tests --json
443
445
  forgeloop responsibility-status --task <taskId> --json
444
446
  ```
@@ -450,6 +452,26 @@ not delegation or evidence. A responsibility label is descriptive, not a
450
452
  coder/reviewer/cleaner role, and its allowed paths, required checks, and frozen
451
453
  inputs are mechanically enforced when present.
452
454
 
455
+ ### Optional advisory context
456
+
457
+ An embedding host may inject an advisory provider through the Integration API
458
+ when extra context is useful. This is not part of the minimum quickstart:
459
+
460
+ ```javascript
461
+ const runtimeContext = createForgeLoopContext({
462
+ advisoryContextProviders: {
463
+ "host-context": {
464
+ id: "host-context",
465
+ recall: async ({ query }) => ({ items: await hostLookup(query) }),
466
+ },
467
+ },
468
+ });
469
+ ```
470
+
471
+ Recall is explicit, lazy, bounded, and non-persisted. Provider output is never
472
+ state, evidence, authority, completion truth, or executable instructions. See
473
+ [`ADVISORY_CONTEXT.md`](./ADVISORY_CONTEXT.md) for the full contract.
474
+
453
475
  ### Differential Verification Scope
454
476
 
455
477
  Configure a trusted scoped checker only when it can consume canonical paths:
@@ -0,0 +1,171 @@
1
+ # Knowledge sources and provenance
2
+
3
+ Snapshot date: 2026-09-01
4
+ Task: `luna-knowledge-pr-correction-20260901-v2`
5
+ Target: ForgeLoop 1.8.0 at current `main` state at review start
6
+ (`a4360ac9b24b19c74171fdbac3163b892d896484`, tag `v1.8.0`)
7
+
8
+ This ledger records research inputs for the knowledge-integration review. It is
9
+ not an endorsement list, a source-content mirror, or an evidence registry.
10
+
11
+ ## Current optional provider source class
12
+
13
+ This note is an operational boundary added after the historical snapshot above;
14
+ it does not rewrite that review's target version or accepted sources. A host may
15
+ provide external advisory context through the ForgeLoop Integration API, but a
16
+ knowledge source is not canonical task state, evidence, authority, completion,
17
+ or next-action authority. Provider results remain lazy, opt-in, bounded, and
18
+ non-persisted; provenance belongs to the host unless a separately versioned
19
+ canonical artifact is introduced.
20
+
21
+ ## User-provided revised plan
22
+
23
+ Source: user-provided `FORGELOOP_LUNA_KNOWLEDGE_INTEGRATION_PLAN_REVISED.md`
24
+ Availability: task-local specification; not redistributed
25
+ Snapshot date: 2026-08-31
26
+ Revision/commit: not applicable
27
+ License observed: not applicable; user-provided task specification
28
+ Role: specification and curation boundary
29
+
30
+ Accepted concepts:
31
+
32
+ - candidate → coverage → proven gap → canonical home → minimal change →
33
+ proportional verification;
34
+ - explicit context-cost, change-class, licensing, and fail-closed decisions;
35
+ - execution-profile, provenance, lifecycle, and publication distinctions.
36
+
37
+ Skipped concepts:
38
+
39
+ - none of the plan's instructions were treated as external source material;
40
+ they define this task's scope and acceptance criteria.
41
+
42
+ Canonical homes:
43
+
44
+ - `docs/KNOWLEDGE_INTEGRATION_GAP_ANALYSIS.md` for decisions;
45
+ - `docs/KNOWLEDGE_SOURCES.md` for provenance;
46
+ - existing `ENG/` and protocol documents for operational rules.
47
+
48
+ Reuse notes:
49
+
50
+ - The attachment was used as a specification, not copied into a guide.
51
+
52
+ ## Learn UI
53
+
54
+ URL: [https://learn-ui.com/](https://learn-ui.com/) and the Markdown index at
55
+ [https://learn-ui.com/llms.txt](https://learn-ui.com/llms.txt)
56
+ Snapshot date: 2026-08-31
57
+ Revision/commit: not exposed by the inspected site
58
+ License observed: no reuse license was identified in the inspected index and
59
+ pages; reuse was therefore not assumed
60
+ Role: discovery and research-only
61
+
62
+ Accepted concepts:
63
+
64
+ - prompts to check focus lifecycle, semantic representation, component states,
65
+ feedback, reduced motion, responsive behavior, and perceived performance;
66
+ - independent, generalized guide refinements recorded in the gap matrix and
67
+ canonical accessibility/design guides.
68
+
69
+ Skipped concepts:
70
+
71
+ - source wording, examples, code, illustrations, page-specific constants,
72
+ visual recipes, and any source-exclusive taxonomy;
73
+ - any claim that the site supplies a license or authorizes redistribution.
74
+
75
+ Canonical homes:
76
+
77
+ - `ENG/accessibility-eng.md` for objective keyboard, focus, semantic, and
78
+ status guidance;
79
+ - `ENG/design-code-eng.md` for contextual component-state guidance;
80
+ - existing performance and testing guides where equivalent coverage already
81
+ exists.
82
+
83
+ Reuse notes:
84
+
85
+ - No Learn UI text, code, example, image, or diagram was vendored.
86
+ - The accepted wording was written from the concrete ForgeLoop gap and
87
+ corroborated with primary W3C/WAI/APG material where it became objective.
88
+
89
+ ## System Design Academy
90
+
91
+ URL: [https://github.com/systemdesign42/system-design-academy](https://github.com/systemdesign42/system-design-academy)
92
+ Snapshot date: 2026-08-31
93
+ Revision/commit: `62cca085d6f5d7df1cfaf72c81f7304be9b9386e` (`main` at snapshot)
94
+ License observed: `CC BY-NC-ND 4.0`, as declared by the repository license
95
+ Role: discovery-only
96
+
97
+ Accepted concepts:
98
+
99
+ - broad topic discovery for context engineering, state/recovery, evaluation,
100
+ retries/idempotency, and distributed-system boundaries;
101
+ - a prompt to verify each topic against ForgeLoop's existing canonical home.
102
+
103
+ Skipped concepts:
104
+
105
+ - all source-specific articles, prose, examples, diagrams, taxonomies, and
106
+ adaptations;
107
+ - new protocol, router, profile, schema, evidence, or orchestration behavior;
108
+ - a parallel knowledge library or technology-specific guide.
109
+
110
+ Canonical homes:
111
+
112
+ - existing `LOOP_SYSTEM_DESIGN.md`, `EXECUTION_STATE.md`,
113
+ `PROTOCOL_INTEGRATION.md`, `GUIDE_ROUTER.md`, `QUALITY_SCORECARD.md`,
114
+ `docs/EXECUTION_PROFILE_BENCHMARKS.md`, and current `ENG/` guides.
115
+
116
+ Reuse notes:
117
+
118
+ - This repository was used only to discover generic candidate topics.
119
+ - Nothing from the repository was copied, translated, closely paraphrased,
120
+ diagrammed, or adapted.
121
+
122
+ ## W3C, WAI, and WAI-ARIA APG
123
+
124
+ URLs: [WCAG 2.2](https://www.w3.org/TR/WCAG22/), [APG](https://www.w3.org/WAI/ARIA/apg/),
125
+ [keyboard interface](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/),
126
+ [dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/),
127
+ [focus visible](https://www.w3.org/WAI/WCAG22/Understanding/focus-visible.html),
128
+ [reflow](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html),
129
+ [animation from interactions](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html),
130
+ and [status technique](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA22.html)
131
+ Snapshot date: 2026-08-31
132
+ Revision/commit: current web pages; no repository revision used
133
+ License observed: primary standards/reference pages; no source text was
134
+ reproduced
135
+ Role: normative corroboration
136
+
137
+ Accepted concepts:
138
+
139
+ - keyboard operation and focus order;
140
+ - focus visibility, dialog focus management, reflow, reduced-motion, and
141
+ status-announcement boundaries;
142
+ - the distinction between automated checks and human assistive-technology
143
+ evaluation.
144
+
145
+ Skipped concepts:
146
+
147
+ - copying normative prose or presenting guide checks as certification;
148
+ - claims of legal compliance, conformance, or human testing without scoped
149
+ evidence.
150
+
151
+ Canonical homes:
152
+
153
+ - `ENG/accessibility-eng.md` for implementation guidance;
154
+ - `ENG/test-code-eng.md` for the automation-plus-human verification boundary.
155
+
156
+ Reuse notes:
157
+
158
+ - Links are retained for corroboration; no standards text, test result, or
159
+ certification claim is embedded.
160
+
161
+ ## Cross-source reuse boundary
162
+
163
+ - No source text, source code, source examples, diagrams, or images are stored
164
+ in this repository as a result of this review.
165
+ - External ideas remain research inputs until independently abstracted,
166
+ mapped to a current canonical home, and supported by a proven operational
167
+ gap.
168
+ - Subjective judgments such as “premium,” “polished,” or “sophisticated” stay
169
+ advisory and cannot become completion evidence.
170
+ - Licensing status is recorded only as observed at the snapshot; it is not
171
+ inferred, upgraded, or used as permission to redistribute material.