loopforge 3.9.2 → 4.0.7

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 (285) hide show
  1. package/README.md +236 -112
  2. package/dist/audit.d.ts +73 -15
  3. package/dist/audit.d.ts.map +1 -1
  4. package/dist/audit.js +131 -61
  5. package/dist/audit.js.map +1 -1
  6. package/dist/canonical-state.d.ts +152 -40
  7. package/dist/canonical-state.d.ts.map +1 -1
  8. package/dist/canonical-state.js +382 -206
  9. package/dist/canonical-state.js.map +1 -1
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/cli.js +41 -12
  12. package/dist/cli.js.map +1 -1
  13. package/dist/cognitive-governance.d.ts +0 -2
  14. package/dist/cognitive-governance.d.ts.map +1 -1
  15. package/dist/cognitive-governance.js +0 -4
  16. package/dist/cognitive-governance.js.map +1 -1
  17. package/dist/committed-round.d.ts +105 -141
  18. package/dist/committed-round.d.ts.map +1 -1
  19. package/dist/committed-round.js +249 -372
  20. package/dist/committed-round.js.map +1 -1
  21. package/dist/constraint-lifecycle.d.ts +73 -0
  22. package/dist/constraint-lifecycle.d.ts.map +1 -0
  23. package/dist/constraint-lifecycle.js +174 -0
  24. package/dist/constraint-lifecycle.js.map +1 -0
  25. package/dist/context-boundary.d.ts +83 -0
  26. package/dist/context-boundary.d.ts.map +1 -0
  27. package/dist/context-boundary.js +101 -0
  28. package/dist/context-boundary.js.map +1 -0
  29. package/dist/contract-items.d.ts +12 -8
  30. package/dist/contract-items.d.ts.map +1 -1
  31. package/dist/contract-items.js +31 -26
  32. package/dist/contract-items.js.map +1 -1
  33. package/dist/contract-requirement.d.ts +47 -0
  34. package/dist/contract-requirement.d.ts.map +1 -0
  35. package/dist/contract-requirement.js +51 -0
  36. package/dist/contract-requirement.js.map +1 -0
  37. package/dist/criterion-status.d.ts +35 -0
  38. package/dist/criterion-status.d.ts.map +1 -0
  39. package/dist/criterion-status.js +89 -0
  40. package/dist/criterion-status.js.map +1 -0
  41. package/dist/enforcement-gate.d.ts +32 -67
  42. package/dist/enforcement-gate.d.ts.map +1 -1
  43. package/dist/enforcement-gate.js +203 -439
  44. package/dist/enforcement-gate.js.map +1 -1
  45. package/dist/engine.d.ts +9 -103
  46. package/dist/engine.d.ts.map +1 -1
  47. package/dist/engine.js +28 -887
  48. package/dist/engine.js.map +1 -1
  49. package/dist/errors.d.ts +41 -0
  50. package/dist/errors.d.ts.map +1 -0
  51. package/dist/errors.js +69 -0
  52. package/dist/errors.js.map +1 -0
  53. package/dist/evidence-claims.d.ts +33 -31
  54. package/dist/evidence-claims.d.ts.map +1 -1
  55. package/dist/evidence-claims.js +58 -72
  56. package/dist/evidence-claims.js.map +1 -1
  57. package/dist/evidence-posture-view.d.ts +19 -0
  58. package/dist/evidence-posture-view.d.ts.map +1 -0
  59. package/dist/evidence-posture-view.js +116 -0
  60. package/dist/evidence-posture-view.js.map +1 -0
  61. package/dist/evidence-posture.d.ts +73 -0
  62. package/dist/evidence-posture.d.ts.map +1 -0
  63. package/dist/evidence-posture.js +281 -0
  64. package/dist/evidence-posture.js.map +1 -0
  65. package/dist/evidence-provider.d.ts +55 -37
  66. package/dist/evidence-provider.d.ts.map +1 -1
  67. package/dist/evidence-provider.js +182 -332
  68. package/dist/evidence-provider.js.map +1 -1
  69. package/dist/explain.d.ts +167 -27
  70. package/dist/explain.d.ts.map +1 -1
  71. package/dist/explain.js +373 -58
  72. package/dist/explain.js.map +1 -1
  73. package/dist/field-accounting.d.ts.map +1 -1
  74. package/dist/field-accounting.js +3 -22
  75. package/dist/field-accounting.js.map +1 -1
  76. package/dist/generate-schema.js +13 -8
  77. package/dist/generate-schema.js.map +1 -1
  78. package/dist/git-boundary.d.ts +128 -0
  79. package/dist/git-boundary.d.ts.map +1 -0
  80. package/dist/git-boundary.js +625 -0
  81. package/dist/git-boundary.js.map +1 -0
  82. package/dist/git-facts.d.ts +22 -0
  83. package/dist/git-facts.d.ts.map +1 -0
  84. package/dist/git-facts.js +29 -0
  85. package/dist/git-facts.js.map +1 -0
  86. package/dist/git-motion.d.ts +37 -0
  87. package/dist/git-motion.d.ts.map +1 -0
  88. package/dist/git-motion.js +59 -0
  89. package/dist/git-motion.js.map +1 -0
  90. package/dist/history.d.ts +44 -0
  91. package/dist/history.d.ts.map +1 -0
  92. package/dist/history.js +77 -0
  93. package/dist/history.js.map +1 -0
  94. package/dist/index.d.ts +19 -9
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +12 -4
  97. package/dist/index.js.map +1 -1
  98. package/dist/init.d.ts +16 -0
  99. package/dist/init.d.ts.map +1 -1
  100. package/dist/init.js +80 -14
  101. package/dist/init.js.map +1 -1
  102. package/dist/loop-compiler.d.ts +51 -19
  103. package/dist/loop-compiler.d.ts.map +1 -1
  104. package/dist/loop-compiler.js +423 -507
  105. package/dist/loop-compiler.js.map +1 -1
  106. package/dist/loop-store.d.ts +6 -5
  107. package/dist/loop-store.d.ts.map +1 -1
  108. package/dist/loop-store.js +153 -35
  109. package/dist/loop-store.js.map +1 -1
  110. package/dist/mcp/round-lifecycle.d.ts +285 -81
  111. package/dist/mcp/round-lifecycle.d.ts.map +1 -1
  112. package/dist/mcp/round-lifecycle.js +1629 -574
  113. package/dist/mcp/round-lifecycle.js.map +1 -1
  114. package/dist/mcp/server.d.ts +5 -0
  115. package/dist/mcp/server.d.ts.map +1 -1
  116. package/dist/mcp/server.js +61 -19
  117. package/dist/mcp/server.js.map +1 -1
  118. package/dist/mcp/session.d.ts +81 -39
  119. package/dist/mcp/session.d.ts.map +1 -1
  120. package/dist/mcp/session.js +963 -271
  121. package/dist/mcp/session.js.map +1 -1
  122. package/dist/mcp/submission-boundary.d.ts +23 -31
  123. package/dist/mcp/submission-boundary.d.ts.map +1 -1
  124. package/dist/mcp/submission-boundary.js +242 -82
  125. package/dist/mcp/submission-boundary.js.map +1 -1
  126. package/dist/mcp/submission-handle.d.ts +66 -0
  127. package/dist/mcp/submission-handle.d.ts.map +1 -0
  128. package/dist/mcp/submission-handle.js +173 -0
  129. package/dist/mcp/submission-handle.js.map +1 -0
  130. package/dist/mcp/tools.d.ts +17 -7
  131. package/dist/mcp/tools.d.ts.map +1 -1
  132. package/dist/mcp/tools.js +763 -244
  133. package/dist/mcp/tools.js.map +1 -1
  134. package/dist/open-question.d.ts +7 -0
  135. package/dist/open-question.d.ts.map +1 -0
  136. package/dist/open-question.js +14 -0
  137. package/dist/open-question.js.map +1 -0
  138. package/dist/policy-metrics.d.ts +31 -21
  139. package/dist/policy-metrics.d.ts.map +1 -1
  140. package/dist/policy-metrics.js +117 -64
  141. package/dist/policy-metrics.js.map +1 -1
  142. package/dist/policy.d.ts +15 -40
  143. package/dist/policy.d.ts.map +1 -1
  144. package/dist/policy.js +13 -13
  145. package/dist/policy.js.map +1 -1
  146. package/dist/progress.d.ts +45 -0
  147. package/dist/progress.d.ts.map +1 -0
  148. package/dist/progress.js +136 -0
  149. package/dist/progress.js.map +1 -0
  150. package/dist/prompt-assembler.d.ts +28 -9
  151. package/dist/prompt-assembler.d.ts.map +1 -1
  152. package/dist/prompt-assembler.js +592 -603
  153. package/dist/prompt-assembler.js.map +1 -1
  154. package/dist/prompt-coverage.d.ts +39 -0
  155. package/dist/prompt-coverage.d.ts.map +1 -0
  156. package/dist/prompt-coverage.js +80 -0
  157. package/dist/prompt-coverage.js.map +1 -0
  158. package/dist/prompt-freshness.d.ts +25 -0
  159. package/dist/prompt-freshness.d.ts.map +1 -0
  160. package/dist/prompt-freshness.js +88 -0
  161. package/dist/prompt-freshness.js.map +1 -0
  162. package/dist/prompt-policy.d.ts +14 -4
  163. package/dist/prompt-policy.d.ts.map +1 -1
  164. package/dist/prompt-policy.js +29 -10
  165. package/dist/prompt-policy.js.map +1 -1
  166. package/dist/protocol.d.ts +875 -419
  167. package/dist/protocol.d.ts.map +1 -1
  168. package/dist/protocol.js +73 -99
  169. package/dist/protocol.js.map +1 -1
  170. package/dist/recovery-guidance.d.ts +13 -0
  171. package/dist/recovery-guidance.d.ts.map +1 -0
  172. package/dist/recovery-guidance.js +15 -0
  173. package/dist/recovery-guidance.js.map +1 -0
  174. package/dist/recovery.d.ts +68 -0
  175. package/dist/recovery.d.ts.map +1 -0
  176. package/dist/recovery.js +234 -0
  177. package/dist/recovery.js.map +1 -0
  178. package/dist/replay.d.ts +42 -8
  179. package/dist/replay.d.ts.map +1 -1
  180. package/dist/replay.js +311 -84
  181. package/dist/replay.js.map +1 -1
  182. package/dist/result-facts.d.ts +45 -0
  183. package/dist/result-facts.d.ts.map +1 -0
  184. package/dist/result-facts.js +86 -0
  185. package/dist/result-facts.js.map +1 -0
  186. package/dist/round-contract.d.ts +38 -8
  187. package/dist/round-contract.d.ts.map +1 -1
  188. package/dist/round-contract.js +71 -31
  189. package/dist/round-contract.js.map +1 -1
  190. package/dist/round-coordinator.d.ts +45 -91
  191. package/dist/round-coordinator.d.ts.map +1 -1
  192. package/dist/round-coordinator.js +254 -271
  193. package/dist/round-coordinator.js.map +1 -1
  194. package/dist/round-driver.d.ts +56 -16
  195. package/dist/round-driver.d.ts.map +1 -1
  196. package/dist/round-driver.js +225 -39
  197. package/dist/round-driver.js.map +1 -1
  198. package/dist/round-facts.d.ts +33 -52
  199. package/dist/round-facts.d.ts.map +1 -1
  200. package/dist/round-facts.js +54 -157
  201. package/dist/round-facts.js.map +1 -1
  202. package/dist/round-guidance.d.ts +56 -0
  203. package/dist/round-guidance.d.ts.map +1 -0
  204. package/dist/round-guidance.js +161 -0
  205. package/dist/round-guidance.js.map +1 -0
  206. package/dist/round-outcome.d.ts +21 -0
  207. package/dist/round-outcome.d.ts.map +1 -0
  208. package/dist/round-outcome.js +31 -0
  209. package/dist/round-outcome.js.map +1 -0
  210. package/dist/round-transaction.d.ts +168 -21
  211. package/dist/round-transaction.d.ts.map +1 -1
  212. package/dist/round-transaction.js +856 -39
  213. package/dist/round-transaction.js.map +1 -1
  214. package/dist/self-eval.d.ts +40 -60
  215. package/dist/self-eval.d.ts.map +1 -1
  216. package/dist/self-eval.js +455 -384
  217. package/dist/self-eval.js.map +1 -1
  218. package/dist/storage.d.ts +16 -0
  219. package/dist/storage.d.ts.map +1 -1
  220. package/dist/storage.js +54 -4
  221. package/dist/storage.js.map +1 -1
  222. package/dist/subgoal-state.d.ts +2 -3
  223. package/dist/subgoal-state.d.ts.map +1 -1
  224. package/dist/subgoal-state.js +2 -3
  225. package/dist/subgoal-state.js.map +1 -1
  226. package/dist/submission-guidance.d.ts +43 -21
  227. package/dist/submission-guidance.d.ts.map +1 -1
  228. package/dist/submission-guidance.js +368 -262
  229. package/dist/submission-guidance.js.map +1 -1
  230. package/dist/submission-receipt.d.ts +16 -8
  231. package/dist/submission-receipt.d.ts.map +1 -1
  232. package/dist/submission-receipt.js +146 -51
  233. package/dist/submission-receipt.js.map +1 -1
  234. package/dist/token-utils.d.ts +47 -7
  235. package/dist/token-utils.d.ts.map +1 -1
  236. package/dist/token-utils.js +66 -15
  237. package/dist/token-utils.js.map +1 -1
  238. package/dist/transaction-identity.d.ts +9 -0
  239. package/dist/transaction-identity.d.ts.map +1 -0
  240. package/dist/transaction-identity.js +69 -0
  241. package/dist/transaction-identity.js.map +1 -0
  242. package/dist/verification-actions.d.ts +13 -0
  243. package/dist/verification-actions.d.ts.map +1 -0
  244. package/dist/verification-actions.js +44 -0
  245. package/dist/verification-actions.js.map +1 -0
  246. package/dist/verification-gate.d.ts +26 -46
  247. package/dist/verification-gate.d.ts.map +1 -1
  248. package/dist/verification-gate.js +218 -427
  249. package/dist/verification-gate.js.map +1 -1
  250. package/dist/version.d.ts +1 -1
  251. package/dist/version.js +1 -1
  252. package/dist/working-memory.d.ts +187 -0
  253. package/dist/working-memory.d.ts.map +1 -0
  254. package/dist/working-memory.js +767 -0
  255. package/dist/working-memory.js.map +1 -0
  256. package/dist/workspace-checkpoint.d.ts +88 -0
  257. package/dist/workspace-checkpoint.d.ts.map +1 -0
  258. package/dist/workspace-checkpoint.js +326 -0
  259. package/dist/workspace-checkpoint.js.map +1 -0
  260. package/dist/workspace-restore.d.ts +68 -0
  261. package/dist/workspace-restore.d.ts.map +1 -0
  262. package/dist/workspace-restore.js +604 -0
  263. package/dist/workspace-restore.js.map +1 -0
  264. package/dist/workspace.d.ts +0 -9
  265. package/dist/workspace.d.ts.map +1 -1
  266. package/dist/workspace.js +0 -17
  267. package/dist/workspace.js.map +1 -1
  268. package/loop_policy.json +5 -19
  269. package/package.json +2 -2
  270. package/skills/forge/SKILL.md +212 -0
  271. package/skills/forge/references/evidence-and-contracts.md +204 -0
  272. package/skills/forge/references/recovery-and-views.md +188 -0
  273. package/dist/cognitive-facts.d.ts +0 -30
  274. package/dist/cognitive-facts.d.ts.map +0 -1
  275. package/dist/cognitive-facts.js +0 -113
  276. package/dist/cognitive-facts.js.map +0 -1
  277. package/dist/loop-extras-parser.d.ts +0 -81
  278. package/dist/loop-extras-parser.d.ts.map +0 -1
  279. package/dist/loop-extras-parser.js +0 -213
  280. package/dist/loop-extras-parser.js.map +0 -1
  281. package/dist/loop-projection.d.ts +0 -6
  282. package/dist/loop-projection.d.ts.map +0 -1
  283. package/dist/loop-projection.js +0 -28
  284. package/dist/loop-projection.js.map +0 -1
  285. package/skills/perception/SKILL.md +0 -370
@@ -7,71 +7,107 @@
7
7
  * future CLI command, or any direct `mgr.advance()` got NONE of it. The
8
8
  * handler now only maps the result onto its tool envelope.
9
9
  *
10
- * The placement is also what makes the ordering invariants hold. AGENTS.md:
11
- * an invalid evaluation is handled BEFORE `RoundLifecycle.advance()` and
12
- * "must not save session state, write the Vault, run verification or
13
- * enforcement gates, increment rejection state, or record metrics". So it
14
- * runs before the session queue and before the lease heartbeat — renewing a
15
- * lease writes the session document, which would be a durable effect of a
16
- * payload that was never accepted. It is judged before the session is even
17
- * resolved, because a malformed evaluation is a payload defect whatever the
18
- * session's state, and answering `session_not_found` for it would send the
19
- * agent after the wrong problem.
10
+ * The placement is also what makes the ordering invariants hold. v4.0.0:
11
+ * `SessionManager` validates the `submissionHandle` (shape, session, exact
12
+ * held snapshot) BEFORE this boundary and before its queue/lease heartbeat.
13
+ * A stale handle short-circuits; only a matching handle's payload is judged
14
+ * here. AGENTS.md's durable-effect invariant is unchanged: an invalid
15
+ * evaluation must not save session state, write the Vault, run verification
16
+ * or enforcement gates, increment rejection state, or record metrics. The
17
+ * whole boundary still runs before the session queue and before the lease
18
+ * heartbeat.
20
19
  *
21
- * This module also owns the compile context the boundary reads, because the
22
- * sub-goal reference space IS the compiled set the prompt carried — the
23
- * session's own projection reads the same function, so the two cannot
24
- * disagree about it.
20
+ * This module derives the reference spaces the boundary reads from the same
21
+ * committed history window the prompt was compiled from, so the prompt, the
22
+ * boundary and `submission_guidance` cannot disagree about them.
25
23
  */
26
- import { queryLoopEntries } from "../loop-store.js";
27
- import { Mode } from "../protocol.js";
28
24
  import { deriveActiveRoundContract } from "../round-contract.js";
29
- import { derivationRounds } from "../committed-round.js";
25
+ import { deriveContractRequirement } from "../contract-requirement.js";
26
+ import { historyWindow, loadCommittedHistory } from "../history.js";
30
27
  import { boundedEmergedSubtasks, normalizeSelfEvaluation, parseSubGoalUpdates, validateContractShape, validateCoreSelfEvaluation, validateSubGoalUpdatesShape, } from "../self-eval.js";
31
- import { deriveEmergedItems, validateSubGoalUpdates } from "../subgoal-state.js";
32
- import { isConfiguredCommand } from "../policy.js";
33
- import { scopeEntryDetail } from "../workspace.js";
34
- import { isRecord } from "../token-utils.js";
35
- /** The compile response this round's prompt came from.
36
- *
37
- * Cached-when-fresh (the artifact's deterministic roundId guards against
38
- * stale reuse), recompiled otherwise with `persistLineage: false` so it never
39
- * writes the Vault, and null when it cannot be observed. Callers fail OPEN:
40
- * an unobservable reference space must not become a rejection. */
41
- export function compileSessionContext(session) {
42
- const cached = session.lastCompileResponse;
43
- const expectedRoundId = session.roundSnapshot?.roundId
44
- ?? `loop:${session.loopId}:round:${session.currentRound}`;
45
- if (cached?.prompt_artifact && cached.prompt_artifact.roundId === expectedRoundId) {
46
- return cached;
47
- }
28
+ import { deriveEmergedItems, deriveSubGoals, validateSubGoalUpdates, } from "../subgoal-state.js";
29
+ import { deriveConfiguredCapability, isConfiguredCommand } from "../policy.js";
30
+ import { canonicalContractItemText, deriveCriterionId, isRecord, uniqueNormalized, } from "../token-utils.js";
31
+ import { latestObjective } from "../loop-compiler.js";
32
+ import { deriveConstraintProvenance, resolveConstraintRetractions, } from "../constraint-lifecycle.js";
33
+ import { getPolicy } from "../policy.js";
34
+ function referenceFactsFor(store, session) {
48
35
  try {
49
- const request = {
50
- task: session.task,
51
- mode: Mode.LOOP_COMPILE,
52
- feedback: null,
53
- skill_name: null,
54
- task_id: null,
55
- loop_id: session.loopId,
56
- round: session.currentRound,
57
- max_rounds: session.maxRounds,
58
- verification_flags: [],
59
- };
60
- const compiled = session.engine.invokeLoopCompile(request, undefined, { persistLineage: false });
61
- return compiled.response ?? null;
36
+ const history = loadCommittedHistory(store, session.loopId);
37
+ const entries = history.entries;
38
+ const windowRounds = historyWindow(history, session.currentRound);
39
+ const subGoals = deriveSubGoals({
40
+ loopId: session.loopId,
41
+ currentRound: session.currentRound,
42
+ rounds: windowRounds,
43
+ });
44
+ // v3.9.6: the held acceptance is the operator fact. Committed objective
45
+ // lineage is the fallback for a snapshot that predates it — never a
46
+ // second compile of mutable session state.
47
+ const objective = session.roundSnapshot?.operatorAcceptance
48
+ ? {
49
+ objective: session.roundSnapshot.operatorAcceptance.task,
50
+ success_criteria: session.roundSnapshot.operatorAcceptance.success_criteria,
51
+ hard_constraints: session.roundSnapshot.operatorAcceptance.hard_constraints,
52
+ created_at_round: 1,
53
+ loop_id: session.loopId,
54
+ }
55
+ : latestObjective(session.loopId, { results: entries });
56
+ const criteriaTexts = objective?.success_criteria ?? null;
57
+ const criteria = criteriaTexts === null
58
+ ? null
59
+ : uniqueNormalized([...criteriaTexts]).map((text) => ({
60
+ id: deriveCriterionId(text),
61
+ text,
62
+ }));
63
+ // The held prompt's compile stamped the exact active set it rendered.
64
+ // This is the same text set the prompt carried; provenance is re-derived
65
+ // from the committed window, never from a second ledger.
66
+ const rawActive = session.roundSnapshot?.compiled?.constraintsActive ?? null;
67
+ const pending = history.pendingDirective?.recovery?.target.redo_round ===
68
+ session.currentRound
69
+ ? history.pendingDirective
70
+ : null;
71
+ const preservedDiscoveries = pending?.recovery &&
72
+ getPolicy().engine.backtrack_preserve_discoveries
73
+ ? pending.recovery.skipped_discoveries
74
+ : [];
75
+ const roundOnePlan = session.currentRound === 1
76
+ ? objective?.hard_constraints ?? []
77
+ : [];
78
+ const constraints = rawActive === null
79
+ ? null
80
+ : uniqueNormalized(rawActive).map((text) => ({
81
+ text,
82
+ provenance: deriveConstraintProvenance({
83
+ text,
84
+ objective,
85
+ windowRounds,
86
+ roundOnePlan,
87
+ preservedDiscoveries,
88
+ preservedRound: pending?.round,
89
+ }),
90
+ }));
91
+ const previouslyRetired = uniqueNormalized(windowRounds.flatMap((round) => round.compiledRetirements ?? round.retractedConstraints ?? []));
92
+ return { subGoals, criteria, constraints, previouslyRetired };
62
93
  }
63
94
  catch {
64
- return null; // projection / boundary degrades gracefully
95
+ return {
96
+ subGoals: null,
97
+ criteria: null,
98
+ constraints: null,
99
+ previouslyRetired: [],
100
+ }; // projection degrades gracefully
65
101
  }
66
102
  }
67
- /** The sub-goal set an agent may legitimately reference: the compiled set the
103
+ /** The sub-goal set an agent may legitimately reference: the committed set the
68
104
  * prompt carried, PLUS this submission's own `emerged_subtasks` — a sub-goal
69
105
  * may be created and referenced (or transitioned) in one round. Null when it
70
106
  * cannot be observed. */
71
- export function knownSubGoalsFor(session, emerged, response = compileSessionContext(session)) {
72
- if (!response?.sub_goals)
107
+ export function knownSubGoalsFor(session, emerged, knownSubGoals) {
108
+ if (!knownSubGoals)
73
109
  return null;
74
- const known = [...response.sub_goals];
110
+ const known = [...knownSubGoals];
75
111
  for (const item of deriveEmergedItems(session.loopId, session.currentRound, emerged)) {
76
112
  if (!known.some((subGoal) => subGoal.id === item.id)) {
77
113
  known.push({
@@ -89,20 +125,33 @@ export function knownSubGoalsFor(session, emerged, response = compileSessionCont
89
125
  /** The ACTIVE Round Contract governing a session's next round — ONE
90
126
  * derivation, shared by the session's public view and the boundary. */
91
127
  export function activeContractOf(store, session) {
92
- const prefix = `loop:${session.loopId}:`;
93
- const entries = [
94
- ...queryLoopEntries(store, session.loopId, { prefix }),
95
- ...queryLoopEntries(store, session.loopId, { prefix, feedbackOnly: true }),
96
- ];
97
- return deriveActiveRoundContract(derivationRounds(entries, session.currentRound));
128
+ const history = loadCommittedHistory(store, session.loopId);
129
+ return deriveActiveRoundContract(historyWindow(history, session.currentRound));
98
130
  }
99
131
  /** Map a strict boundary error onto the same diagnostic vocabulary, without
100
132
  * persisting it. Strict failures are returned only for that attempt. */
101
133
  function rejectedDiagnostic(path, code, detail) {
102
134
  return { path, code, handling: "rejected", detail };
103
135
  }
104
- const EVALUATION_REQUIRED = "A structured evaluation object is required. Resubmit the same roundId " +
105
- "with success, output_summary, constraint_violations, and should_continue.";
136
+ const EVALUATION_REQUIRED = "A structured evaluation object is required. Resubmit the same submissionHandle " +
137
+ "with outcome, output_summary, constraint_violations, and should_continue.";
138
+ /** A contract refusal is either a malformed declaration or a coverage/stop
139
+ * rule. The detailed reason is always in `contract_errors`; this top-level
140
+ * sentence must not call a coverage refusal "malformed". */
141
+ function contractRefusalDetail(errors) {
142
+ if (errors.some((error) => error.reason === "contract_on_stop")) {
143
+ return "A stopping or blocked round cannot leave a round_contract for the " +
144
+ "next round. Remove it and resubmit the same submissionHandle.";
145
+ }
146
+ if (errors.some((error) => error.reason === "contract_required")) {
147
+ return "This continuing round must leave an active Round Contract for the " +
148
+ "next round. Submit round_contract with a work_item and at least one " +
149
+ "item bound to a configured command, then resubmit the same " +
150
+ "submissionHandle.";
151
+ }
152
+ return "The Round Contract declaration or its item claims are malformed. " +
153
+ "Fix them and resubmit the same submissionHandle.";
154
+ }
106
155
  /** THE submission boundary. Five checks, in this order, all of them before
107
156
  * anything durable happens.
108
157
  *
@@ -161,7 +210,7 @@ export function validateSubmission(store, session, submission) {
161
210
  if (subgoalShapeErrors.length > 0) {
162
211
  return {
163
212
  ok: false,
164
- stopDetail: "subgoal_updates is malformed. Fix the entries and resubmit the same roundId.",
213
+ stopDetail: "subgoal_updates is malformed. Fix the entries and resubmit the same submissionHandle.",
165
214
  submissionError: {
166
215
  code: "evaluation_invalid",
167
216
  details: {
@@ -173,8 +222,8 @@ export function validateSubmission(store, session, submission) {
173
222
  },
174
223
  };
175
224
  }
176
- const compileResponse = session ? compileSessionContext(session) : null;
177
- const known = session ? knownSubGoalsFor(session, emerged, compileResponse) : null;
225
+ const facts = session ? referenceFactsFor(store, session) : null;
226
+ const known = session ? knownSubGoalsFor(session, emerged, facts?.subGoals ?? null) : null;
178
227
  const updates = parseSubGoalUpdates(submission.subgoal_updates);
179
228
  if (updates.length > 0 && known) {
180
229
  const referentialErrors = validateSubGoalUpdates(known, updates).map((error) => ({
@@ -187,7 +236,7 @@ export function validateSubmission(store, session, submission) {
187
236
  ok: false,
188
237
  stopDetail: "subgoal_updates references a sub-goal this loop does not have, a " +
189
238
  "terminal one, or an illegal transition. Fix the entries and " +
190
- "resubmit the same roundId.",
239
+ "resubmit the same submissionHandle.",
191
240
  submissionError: {
192
241
  code: "evaluation_invalid",
193
242
  details: {
@@ -200,12 +249,29 @@ export function validateSubmission(store, session, submission) {
200
249
  };
201
250
  }
202
251
  }
203
- const contractErrors = contractShapeErrors(store, session, submission, known);
252
+ const retraction = resolveSubmissionRetractions(facts, submission);
253
+ if (retraction.errors.length > 0) {
254
+ return {
255
+ ok: false,
256
+ stopDetail: "retracted_constraints may only name active Agent-discovered constraints; " +
257
+ "operator criteria/hard constraints and plan constraints are not retractable. " +
258
+ "Remove them and resubmit the same submissionHandle.",
259
+ submissionError: {
260
+ code: "evaluation_invalid",
261
+ details: {
262
+ missing: [],
263
+ invalid: [],
264
+ retraction_errors: retraction.errors,
265
+ diagnostics: retraction.errors.map((error) => rejectedDiagnostic(error.field, error.reason, error.detail)),
266
+ },
267
+ },
268
+ };
269
+ }
270
+ const contractErrors = contractShapeErrors(store, session, submission, facts?.criteria ?? null);
204
271
  if (contractErrors.length > 0) {
205
272
  return {
206
273
  ok: false,
207
- stopDetail: "The Round Contract declaration or its item claims are malformed. " +
208
- "Fix them and resubmit the same roundId.",
274
+ stopDetail: contractRefusalDetail(contractErrors),
209
275
  submissionError: {
210
276
  code: "contract_invalid",
211
277
  details: {
@@ -217,32 +283,126 @@ export function validateSubmission(store, session, submission) {
217
283
  },
218
284
  };
219
285
  }
286
+ const normalized = normalizeSelfEvaluation(submission, {
287
+ knownCriterionRefs: facts?.criteria ?? null,
288
+ maxDiscoveredConstraints: getPolicy().evolution.max_discovered_constraints_per_round,
289
+ });
220
290
  return {
221
291
  ok: true,
222
- ...normalizeSelfEvaluation(submission, {
223
- knownCriterionRefs: knownCriterionRefsFor(compileResponse),
224
- }),
292
+ evaluation: normalized.evaluation,
293
+ // No-op retractions are visible as diagnostics; they never reject and
294
+ // never appear as effective effects.
295
+ diagnostics: [
296
+ ...retraction.noopDiagnostics,
297
+ ...normalized.diagnostics,
298
+ ],
299
+ submittedFields: normalized.submittedFields,
225
300
  };
226
301
  }
227
- function knownCriterionRefsFor(response) {
228
- return Array.isArray(response?.criterion_statuses)
229
- ? response.criterion_statuses.map((criterion) => ({
230
- id: criterion.id,
231
- text: criterion.text,
232
- }))
233
- : null;
302
+ function resolveSubmissionRetractions(facts, submission) {
303
+ const targets = Array.isArray(submission.retracted_constraints)
304
+ ? submission.retracted_constraints.filter((item) => typeof item === "string")
305
+ : [];
306
+ if (targets.length === 0 || !facts?.constraints) {
307
+ return { errors: [], noopDiagnostics: [] };
308
+ }
309
+ const newDiscoveries = Array.isArray(submission.discovered_constraints)
310
+ ? submission.discovered_constraints.filter((item) => typeof item === "string")
311
+ : [];
312
+ const resolved = resolveConstraintRetractions({
313
+ targets,
314
+ active: facts.constraints,
315
+ newDiscoveries,
316
+ previouslyRetired: facts.previouslyRetired,
317
+ });
318
+ return {
319
+ errors: resolved.errors.map((error) => ({
320
+ field: "retracted_constraints",
321
+ reason: error.reason,
322
+ detail: error.detail,
323
+ })),
324
+ noopDiagnostics: resolved.noops.map((noop) => ({
325
+ path: "retracted_constraints",
326
+ code: noop.reason,
327
+ handling: "dropped",
328
+ detail: `${noop.target}: ${noop.reason.replace(/_/g, " ")}`,
329
+ })),
330
+ };
234
331
  }
235
- function contractShapeErrors(store, session, submission, knownSubGoals) {
332
+ function contractShapeErrors(store, session, submission, criteria) {
236
333
  const active = session ? activeContractOf(store, session) : null;
237
- return validateContractShape(submission, {
334
+ const shapeErrors = validateContractShape(submission, {
238
335
  activeItemIds: session
239
336
  ? new Set((active?.items ?? []).map((item) => item.id))
240
337
  : null,
241
- knownSubGoalIds: knownSubGoals
242
- ? new Set(knownSubGoals.map((subGoal) => subGoal.id))
338
+ // v4.0.6: the `supersedes` modifier is a STRUCTURAL boundary like the
339
+ // contract itself. Target identity and "successor acceptance content
340
+ // actually changed" are checked only when the active contract was
341
+ // observable; structure stays strict either way.
342
+ observed: session !== undefined,
343
+ activeContractId: session ? active?.id ?? null : null,
344
+ activeItemIdentities: active
345
+ ? new Set(active.items.map((item) => canonicalContractItemText(item)))
346
+ : null,
347
+ knownCriterionIds: criteria
348
+ ? new Set(criteria.map((criterion) => criterion.id))
243
349
  : null,
244
350
  isConfiguredCommand,
245
- checkScopeEntry: scopeEntryDetail,
246
351
  });
352
+ if (!session)
353
+ return shapeErrors;
354
+ // v4.0.6: contract coverage BEFORE round advancement, always with
355
+ // closure="open" — this attempt's evidence cannot be assumed to close the
356
+ // active contract. `contract_required` uses the SAME derivation as the
357
+ // post-evidence gate.
358
+ const errors = [...shapeErrors];
359
+ const proposalPresent = submission.round_contract !== undefined;
360
+ const shouldContinue = submission.should_continue !== false;
361
+ const blocked = submission.outcome === "blocked";
362
+ const requirement = deriveContractRequirement({
363
+ shouldContinue,
364
+ blocked,
365
+ proposalPresent,
366
+ activeContract: active,
367
+ closure: "open",
368
+ contractCapability: deriveConfiguredCapability(getPolicy()).contractVerificationAvailable,
369
+ successorRoundAvailable: session.maxRounds === undefined || session.currentRound < session.maxRounds,
370
+ });
371
+ if (requirement.required) {
372
+ errors.push({
373
+ field: "round_contract",
374
+ reason: "contract_required",
375
+ detail: requirement.reason === "no_active_contract"
376
+ ? "an after-capable verification command is configured and this round " +
377
+ "continues, but no Round Contract is active for the next round and " +
378
+ "none was proposed; submit round_contract (work_item + items with " +
379
+ "verify_with)"
380
+ : "the active Round Contract closed and this round continues, but no " +
381
+ "successor round_contract was proposed; submit the next slice's " +
382
+ "contract",
383
+ });
384
+ }
385
+ if (proposalPresent && (!shouldContinue || blocked)) {
386
+ errors.push({
387
+ field: "round_contract",
388
+ reason: "contract_on_stop",
389
+ detail: !shouldContinue
390
+ ? "round_contract activates a NEXT-round contract; it cannot be submitted " +
391
+ "with should_continue=false — a stopping round must not leave an " +
392
+ "unused contract"
393
+ : "round_contract cannot be submitted with outcome=blocked — a blocked " +
394
+ "round closes the contract and must not leave an unused successor",
395
+ });
396
+ }
397
+ if (proposalPresent && shouldContinue && !blocked &&
398
+ session.maxRounds !== undefined && session.currentRound >= session.maxRounds) {
399
+ errors.push({
400
+ field: "round_contract",
401
+ reason: "contract_on_stop",
402
+ detail: "This is the final configured round and has no successor consumer; " +
403
+ "remove round_contract and resubmit the same submissionHandle.",
404
+ });
405
+ }
406
+ return errors;
247
407
  }
248
408
  //# sourceMappingURL=submission-boundary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"submission-boundary.js","sourceRoot":"","sources":["../../src/mcp/submission-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM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AAC;QACpD,MAAM,CAAC,IAAI,CAAC;YACV,KAAK,EAAE,gBAAgB;YACvB,MAAM,EAAE,kBAAkB;YAC1B,MAAM,EAAE,CAAC,cAAc;gBACrB,CAAC,CAAC,yEAAyE;oBACzE,kEAAkE;oBAClE,iBAAiB;gBACnB,CAAC,CAAC,sEAAsE;oBACtE,kEAAkE;SACvE,CAAC,CAAC;IACL,CAAC;IACD,IAAI,eAAe,IAAI,cAAc,IAAI,CAAC,OAAO;QAC7C,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACjF,MAAM,CAAC,IAAI,CAAC;YACV,KAAK,EAAE,gBAAgB;YACvB,MAAM,EAAE,kBAAkB;YAC1B,MAAM,EACJ,oEAAoE;gBACpE,+DAA+D;SAClE,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,66 @@
1
+ /** v4.0.0: the ONE submission-handle projection and validator.
2
+ *
3
+ * A handle bundles the three identities a held-round call needs. It is derived
4
+ * from the persisted session snapshot on every response and is never written
5
+ * to durable state. This module is deliberately free of I/O and of the
6
+ * `McpSession` import: `round-lifecycle.ts` needs the factory, so importing
7
+ * that module here would create a cycle.
8
+ */
9
+ import type { SubmissionHandle } from "../protocol.js";
10
+ import type { RoundTransactionSnapshot } from "../round-transaction.js";
11
+ /** The structural session view the handle predicate needs. */
12
+ export interface HeldSessionView {
13
+ sessionId: string;
14
+ currentRound: number;
15
+ status: "running" | "stopped" | "stalled" | "paused";
16
+ roundSnapshot?: RoundTransactionSnapshot | null;
17
+ }
18
+ /** THE held-prompt predicate. A snapshot is held only when it names the current
19
+ * round and the exact prompted attempt the artifact was rendered for. A
20
+ * committed/terminated/stopped/retrying snapshot must never expose a handle:
21
+ * returning a stale prompt as "held" is the failure mode this predicate
22
+ * closes. */
23
+ export declare function heldPromptSnapshot(session: HeldSessionView | undefined): RoundTransactionSnapshot | null;
24
+ /** Derive the handle from the held snapshot. Never recomputes the transaction
25
+ * id (the snapshot's identity is the authority), never reads the vault, and
26
+ * never mutates the session. */
27
+ export declare function makeSubmissionHandle(session: HeldSessionView | undefined): SubmissionHandle | null;
28
+ /** Strict shape parsing: a plain object with exactly the three non-empty
29
+ * string fields. No trimming, case folding, prefix matching, or defaults. */
30
+ export declare function parseSubmissionHandle(raw: unknown): SubmissionHandle | null;
31
+ export type SubmissionHandleMismatchReason = "no_held_prompt" | "session" | "round" | "transaction" | "attempt";
32
+ export type SubmissionHandleFailure = {
33
+ ok: false;
34
+ code: "submission_handle_required";
35
+ reason: "shape";
36
+ mismatched: [];
37
+ current: null;
38
+ detail: string;
39
+ } | {
40
+ ok: false;
41
+ code: "session_not_found";
42
+ reason: "session";
43
+ mismatched: [];
44
+ current: null;
45
+ detail: string;
46
+ } | {
47
+ ok: false;
48
+ code: "submission_handle_mismatch";
49
+ reason: SubmissionHandleMismatchReason;
50
+ mismatched: string[];
51
+ current: SubmissionHandle | null;
52
+ detail: string;
53
+ };
54
+ export type SubmissionHandleCheck = {
55
+ ok: true;
56
+ handle: SubmissionHandle;
57
+ snapshot: RoundTransactionSnapshot;
58
+ } | SubmissionHandleFailure;
59
+ /** Exact comparison against the held snapshot. The caller resolves the session
60
+ * by `handle.sessionId`; this function owns every field comparison so no
61
+ * second anchor rule can appear in the lifecycle or transport. */
62
+ export declare function validateSubmissionHandle(raw: unknown, session: HeldSessionView | undefined): SubmissionHandleCheck;
63
+ /** The one deterministic warning used whenever a stale handle returns the
64
+ * held prompt. It names no ids and never changes with the attempt. */
65
+ export declare function staleHandleWarning(): string;
66
+ //# sourceMappingURL=submission-handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submission-handle.d.ts","sourceRoot":"","sources":["../../src/mcp/submission-handle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACv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