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
@@ -1,21 +1,20 @@
1
1
  /** v3.8.1: THE contract-fact derivation.
2
2
  *
3
- * The contract walker, the item reducer, the verified sub-goal facts and the
4
- * verification debt are one pass over one history window. Before this module
5
- * the compile path and the projection each ran the same reducers over their
6
- * own window, so the prompt and the projection could tell different stories
7
- * about what the machine had verified — and nothing stopped a third caller
8
- * from picking a third window.
3
+ * The contract walker, the item reducer and the criterion machine facts are
4
+ * one pass over one history window. Every caller passes
5
+ * `derivationRounds(entries, currentRound)` (the shared window from
6
+ * committed-round.ts) and receives the same bundle.
9
7
  *
10
- * Every caller passes `derivationRounds(entries, currentRound)` (the shared
11
- * window from committed-round.ts) and receives the same bundle, so "one fact,
12
- * one derivation" is a property of the types rather than a convention.
8
+ * v4.0.1: the sub-goal verification link (`subgoal_refs`,
9
+ * `VerifiedSubGoalFact`, verification debt) was removed. It never rendered in
10
+ * a prompt or state file; it only fed stateHash. Sub-goals remain the Agent's
11
+ * plan report, not a machine acceptance surface.
13
12
  */
14
13
  import type { CommittedRoundView } from "./committed-round.js";
15
14
  import type { ContractItemStatusView } from "./contract-items.js";
16
15
  import type { ObservationDelta } from "./evidence-provider.js";
17
16
  import type { CommandEvidencePolicy } from "./policy.js";
18
- import type { ContractItemStatus, ExecutionReport, SubGoal, VerifiedSubGoalFact } from "./protocol.js";
17
+ import type { ContractItemStatus, ContractSupersede, ExecutionReport } from "./protocol.js";
19
18
  import type { ActiveContractView } from "./round-contract.js";
20
19
  export interface RoundFacts {
21
20
  /** The contract the NEXT round executes under — derived from committed
@@ -23,24 +22,21 @@ export interface RoundFacts {
23
22
  activeContract: ActiveContractView | null;
24
23
  /** Per-item status of `activeContract`. */
25
24
  itemStatuses: ContractItemStatusView;
26
- /** v3.8: machine-verified sub-goals. Never writes `SubGoal.status`. */
27
- verifiedSubGoals: VerifiedSubGoalFact[];
28
- /** `done` sub-goals no verified item backs, plus `insufficient` items. */
29
- verificationDebt: string[];
30
25
  /** v3.8.1: the machine fact about each criterion a contract item referenced,
31
- * over the WHOLE committed history — the criterion-side twin of
32
- * `verifiedSubGoals`, and read by the same callers. */
26
+ * over the WHOLE committed history. */
33
27
  criterionFacts: CriterionMachineFact[];
34
28
  }
35
29
  /** v3.8.1: ONE criterion's machine fact. `status` is absent while every item
36
30
  * referencing the criterion is still `pending` — "no claim yet" says nothing
37
- * about the criterion, so the criterion keeps its claim-derived status. The
38
- * links are explicit `subgoal_refs` only, and they survive their item's
39
- * contract closing just like the status does. */
31
+ * about the criterion, so the criterion keeps its claim-derived status.
32
+ *
33
+ * v4.0.3: `status_at_round` is the round the CURRENT status was first
34
+ * reached (not the claim round). It is a machine fact, so a later
35
+ * verification can supersede an earlier contradiction. */
40
36
  export interface CriterionMachineFact {
41
37
  criterion_id: string;
42
38
  status?: Exclude<ContractItemStatus, "pending">;
43
- related_subgoal_ids: string[];
39
+ status_at_round?: number;
44
40
  }
45
41
  /** The in-flight slice of a round that is being decided but is not yet
46
42
  * committed. A pure committed-history replay passes null / [] — the reducer
@@ -49,8 +45,13 @@ export interface CriterionMachineFact {
49
45
  export interface InFlightRoundSlice {
50
46
  currentReport: ExecutionReport | null;
51
47
  currentDeltas: ReadonlyArray<ObservationDelta>;
52
- /** The in-flight round's own effective outcome. A `blocked` round CLOSES its
53
- * contract, so closure cannot be derived from committed slices alone. */
48
+ /** The in-flight round's own blocked declaration. A `blocked` round CLOSES
49
+ * its contract, so closure cannot be derived from committed slices alone. */
50
+ currentBlocked?: boolean;
51
+ /** v3.9.9/v4.0.6: the in-flight round's explicit contract redirect
52
+ * (`round_contract.supersedes`). */
53
+ currentRedirect?: ContractSupersede | null;
54
+ /** Legacy shape accepted by library callers; `blocked` wins when present. */
54
55
  currentOutcome?: string | null;
55
56
  }
56
57
  export declare const NO_IN_FLIGHT_ROUND: InFlightRoundSlice;
@@ -59,39 +60,19 @@ export declare function deriveRoundFacts(input: {
59
60
  rounds: ReadonlyArray<CommittedRoundView>;
60
61
  currentRound: number;
61
62
  inFlight: InFlightRoundSlice;
62
- subGoals: ReadonlyArray<SubGoal>;
63
63
  commands: ReadonlyArray<CommandEvidencePolicy>;
64
64
  }): RoundFacts;
65
- /** v3.8: Machine-verified sub-goal facts. DERIVED, never persisted. It never
66
- * writes `SubGoal.status`: `done` stays the agent's declaration, and the fact
67
- * is the machine's separate statement about it.
68
- *
69
- * Derived from the WHOLE committed history, not from the currently-open
70
- * contract. A verified item is machine history — once proven, it stays
71
- * proven — while the active contract necessarily disappears the moment its
72
- * last item verifies. Deriving from the active contract alone made the fact
73
- * vanish at exactly the moment it became fully true, and turned the
74
- * verification-debt view into a false accusation ("agent reported done,
75
- * machine verification absent") against a sub-goal the machine had just
76
- * verified. Each round is read through `deriveRoundContractView`, the same
77
- * derivation the coordinator, explain and audit use — one history
78
- * interpretation, no second read model. That re-derivation is quadratic in the
79
- * round count (≈40ms at 120 rounds) and is deliberately bought: an incremental
80
- * walker would be a second implementation of the closure rule, which is the
81
- * one thing this module must never grow.
65
+ /** v3.8.1/v4.0.3: criterion → machine status, derived over the WHOLE committed
66
+ * history exactly like the contract walk.
82
67
  *
83
- * Attribution is per ITEM (`ContractItemProposal.subgoal_refs`), not per
84
- * contract: an item backs exactly the sub-goals it references, so a contract
85
- * whose item A verifies SubGoal 1 and whose item B verifies SubGoal 2 yields
86
- * two facts with disjoint `contract_item_ids` instead of both sub-goals
87
- * claiming every verified item. */
88
- export declare function deriveVerifiedSubGoals(input: {
89
- subGoals: ReadonlyArray<SubGoal>;
90
- /** Committed rounds (rollback-excluded), ascending. */
68
+ * Within one round the strongest item fact wins (contradicted > verified >
69
+ * insufficient); a `pending` item contributes nothing. Across rounds the
70
+ * LATEST authoritative fact wins: a later `verified` or `contradicted` may
71
+ * supersede an earlier one (so a contradiction can be re-verified), while an
72
+ * `insufficient` round never erases an existing verified/contradicted fact.
73
+ * `status_at_round` records when the current status was first reached. */
74
+ export declare function deriveCriterionFacts(input: {
91
75
  rounds: ReadonlyArray<CommittedRoundView>;
92
76
  commands: ReadonlyArray<CommandEvidencePolicy>;
93
- }): VerifiedSubGoalFact[];
94
- /** v3.8: Sub-goals the agent declared `done` that no verified contract item
95
- * backs — verification debt, surfaced in the handoff's open risks. */
96
- export declare function deriveVerificationDebt(subGoals: ReadonlyArray<SubGoal>, verified: ReadonlyArray<VerifiedSubGoalFact>, statuses: ContractItemStatusView): string[];
77
+ }): CriterionMachineFact[];
97
78
  //# sourceMappingURL=round-facts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"round-facts.d.ts","sourceRoot":"","sources":["../src/round-facts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB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M2D;AAC3D,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;aAGa;AACb,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,aAAa,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC/C;kFAC8E;IAC9E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;yCACqC;IACrC,eAAe,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC3C,6EAA6E;IAC7E,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,kBAAkB,EAAE,kBAMhC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,qEAAqE;IACrE,MAAM,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;CAChD,GAAG,UAAU,CAqBb;AAED;;;;;;;;2EAQ2E;AAC3E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,MAAM,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC1C,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;CAChD,GAAG,oBAAoB,EAAE,CA+CzB"}
@@ -1,22 +1,23 @@
1
1
  /** v3.8.1: THE contract-fact derivation.
2
2
  *
3
- * The contract walker, the item reducer, the verified sub-goal facts and the
4
- * verification debt are one pass over one history window. Before this module
5
- * the compile path and the projection each ran the same reducers over their
6
- * own window, so the prompt and the projection could tell different stories
7
- * about what the machine had verified — and nothing stopped a third caller
8
- * from picking a third window.
3
+ * The contract walker, the item reducer and the criterion machine facts are
4
+ * one pass over one history window. Every caller passes
5
+ * `derivationRounds(entries, currentRound)` (the shared window from
6
+ * committed-round.ts) and receives the same bundle.
9
7
  *
10
- * Every caller passes `derivationRounds(entries, currentRound)` (the shared
11
- * window from committed-round.ts) and receives the same bundle, so "one fact,
12
- * one derivation" is a property of the types rather than a convention.
8
+ * v4.0.1: the sub-goal verification link (`subgoal_refs`,
9
+ * `VerifiedSubGoalFact`, verification debt) was removed. It never rendered in
10
+ * a prompt or state file; it only fed stateHash. Sub-goals remain the Agent's
11
+ * plan report, not a machine acceptance surface.
13
12
  */
14
13
  import { deriveContractItemStatuses } from "./contract-items.js";
15
- import { deriveActiveRoundContract, deriveRoundContractView } from "./round-contract.js";
16
- import { deriveCriterionId, isCriterionId } from "./token-utils.js";
14
+ import { committedRoundFacts, deriveActiveRoundContract, deriveRoundContractView, } from "./round-contract.js";
15
+ import { isCriterionId } from "./token-utils.js";
17
16
  export const NO_IN_FLIGHT_ROUND = {
18
17
  currentReport: null,
19
18
  currentDeltas: [],
19
+ currentBlocked: false,
20
+ currentRedirect: null,
20
21
  currentOutcome: null,
21
22
  };
22
23
  export function deriveRoundFacts(input) {
@@ -27,93 +28,75 @@ export function deriveRoundFacts(input) {
27
28
  currentRound: input.currentRound,
28
29
  currentReport: input.inFlight.currentReport,
29
30
  currentDeltas: input.inFlight.currentDeltas,
30
- currentOutcome: input.inFlight.currentOutcome ?? null,
31
- commands: input.commands,
32
- });
33
- const verifiedSubGoals = deriveVerifiedSubGoals({
34
- subGoals: input.subGoals,
35
- rounds: input.rounds,
31
+ currentBlocked: input.inFlight.currentBlocked ??
32
+ input.inFlight.currentOutcome === "blocked",
33
+ currentRedirect: input.inFlight.currentRedirect ?? null,
36
34
  commands: input.commands,
37
35
  });
38
36
  return {
39
37
  activeContract,
40
38
  itemStatuses,
41
- verifiedSubGoals,
42
- verificationDebt: deriveVerificationDebt(input.subGoals, verifiedSubGoals, itemStatuses),
43
39
  criterionFacts: deriveCriterionFacts({
44
- activeContract,
45
40
  rounds: input.rounds,
46
41
  commands: input.commands,
47
42
  }),
48
43
  };
49
44
  }
50
- /** v3.8.1: criterion → machine status + explicit sub-goal links, derived over
51
- * the WHOLE committed history, exactly like `deriveVerifiedSubGoals` below
52
- * and for the same reason: a verified item is machine history that survives
53
- * its contract closing. Reading only the ACTIVE contract made the criterion's
54
- * machine status vanish at the moment the contract became fully true — the
55
- * state file's Goal → Criteria row fell from ✅ back to 🟡 and its
56
- * `(related: sg-…)` links disappeared, while the sub-goal side of the same
57
- * fact correctly survived.
45
+ /** v3.8.1/v4.0.3: criterion → machine status, derived over the WHOLE committed
46
+ * history exactly like the contract walk.
58
47
  *
59
- * Statuses fold by STRENGTH across the items that reference a criterion (a
60
- * machine denial outranks a verification, which outranks insufficient), and a
61
- * `pending` item contributes links but no status. */
62
- function deriveCriterionFacts(input) {
48
+ * Within one round the strongest item fact wins (contradicted > verified >
49
+ * insufficient); a `pending` item contributes nothing. Across rounds the
50
+ * LATEST authoritative fact wins: a later `verified` or `contradicted` may
51
+ * supersede an earlier one (so a contradiction can be re-verified), while an
52
+ * `insufficient` round never erases an existing verified/contradicted fact.
53
+ * `status_at_round` records when the current status was first reached. */
54
+ export function deriveCriterionFacts(input) {
63
55
  const byCriterion = new Map();
64
- // Seed with the active contract's items: links are declarations, so they do
65
- // not need a round to have executed under the contract. Statuses are only
66
- // ever machine facts from the history walk below (`pending` says nothing).
67
- for (const item of input.activeContract?.items ?? []) {
68
- for (const ref of item.criterion_refs) {
69
- const criterionId = isCriterionId(ref) ? ref : deriveCriterionId(ref);
70
- const existing = byCriterion.get(criterionId);
71
- const links = existing?.related_subgoal_ids ?? [];
72
- for (const subgoalId of item.subgoal_refs) {
73
- if (!links.includes(subgoalId))
74
- links.push(subgoalId);
75
- }
76
- byCriterion.set(criterionId, {
77
- criterion_id: criterionId,
78
- ...(existing?.status ? { status: existing.status } : {}),
79
- related_subgoal_ids: links,
80
- });
81
- }
82
- }
83
56
  for (const round of input.rounds) {
84
57
  const { contract, statuses } = deriveRoundContractView({
85
58
  rounds: input.rounds,
86
59
  round: round.round,
87
- report: round.executionReport,
88
- deltas: round.observationDelta,
89
- outcome: round.outcome,
60
+ current: committedRoundFacts(round),
90
61
  commands: input.commands,
91
62
  });
92
63
  if (!contract)
93
64
  continue;
94
65
  const statusByItem = new Map(statuses.items.map((item) => [item.itemId, item.status]));
66
+ // One round can reference a criterion from several items; fold them to
67
+ // the strongest fact THIS round states.
68
+ const roundBest = new Map();
95
69
  for (const item of contract.items) {
96
70
  const itemStatus = statusByItem.get(item.id);
97
- for (const ref of item.criterion_refs) {
98
- const criterionId = isCriterionId(ref) ? ref : deriveCriterionId(ref);
99
- const existing = byCriterion.get(criterionId);
100
- const links = existing?.related_subgoal_ids ?? [];
101
- for (const subgoalId of item.subgoal_refs) {
102
- if (!links.includes(subgoalId))
103
- links.push(subgoalId);
104
- }
105
- const machineStatus = itemStatus && itemStatus !== "pending"
106
- ? strongestStatus(existing?.status, itemStatus)
107
- : existing?.status;
108
- byCriterion.set(criterionId, {
109
- criterion_id: criterionId,
110
- ...(machineStatus ? { status: machineStatus } : {}),
111
- related_subgoal_ids: links,
112
- });
71
+ if (!itemStatus || itemStatus === "pending")
72
+ continue;
73
+ for (const ref of item.criterion_refs ?? []) {
74
+ if (!isCriterionId(ref))
75
+ continue;
76
+ roundBest.set(ref, strongestStatus(roundBest.get(ref), itemStatus));
77
+ }
78
+ }
79
+ for (const [ref, status] of roundBest) {
80
+ const existing = byCriterion.get(ref);
81
+ if (!existing) {
82
+ byCriterion.set(ref, { status, status_at_round: round.round });
83
+ continue;
113
84
  }
85
+ // A later insufficient observation is not a new conclusion; it cannot
86
+ // erase a machine-supported status. The same status keeps its first
87
+ // round.
88
+ if (status === "insufficient" || existing.status === status)
89
+ continue;
90
+ byCriterion.set(ref, { status, status_at_round: round.round });
114
91
  }
115
92
  }
116
- return [...byCriterion.values()];
93
+ return [...byCriterion.entries()]
94
+ .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
95
+ .map(([criterion_id, fact]) => ({
96
+ criterion_id,
97
+ status: fact.status,
98
+ status_at_round: fact.status_at_round,
99
+ }));
117
100
  }
118
101
  /** Rank item statuses so the strongest machine fact wins when several items
119
102
  * reference the same criterion. */
@@ -127,90 +110,4 @@ function strongestStatus(left, right) {
127
110
  return right;
128
111
  return rank[right] > rank[left] ? right : left;
129
112
  }
130
- /** v3.8: Machine-verified sub-goal facts. DERIVED, never persisted. It never
131
- * writes `SubGoal.status`: `done` stays the agent's declaration, and the fact
132
- * is the machine's separate statement about it.
133
- *
134
- * Derived from the WHOLE committed history, not from the currently-open
135
- * contract. A verified item is machine history — once proven, it stays
136
- * proven — while the active contract necessarily disappears the moment its
137
- * last item verifies. Deriving from the active contract alone made the fact
138
- * vanish at exactly the moment it became fully true, and turned the
139
- * verification-debt view into a false accusation ("agent reported done,
140
- * machine verification absent") against a sub-goal the machine had just
141
- * verified. Each round is read through `deriveRoundContractView`, the same
142
- * derivation the coordinator, explain and audit use — one history
143
- * interpretation, no second read model. That re-derivation is quadratic in the
144
- * round count (≈40ms at 120 rounds) and is deliberately bought: an incremental
145
- * walker would be a second implementation of the closure rule, which is the
146
- * one thing this module must never grow.
147
- *
148
- * Attribution is per ITEM (`ContractItemProposal.subgoal_refs`), not per
149
- * contract: an item backs exactly the sub-goals it references, so a contract
150
- * whose item A verifies SubGoal 1 and whose item B verifies SubGoal 2 yields
151
- * two facts with disjoint `contract_item_ids` instead of both sub-goals
152
- * claiming every verified item. */
153
- export function deriveVerifiedSubGoals(input) {
154
- const known = new Set(input.subGoals.map((subGoal) => subGoal.id));
155
- if (known.size === 0)
156
- return [];
157
- // First-reference order across the history — deterministic, and independent
158
- // of which item happened to verify first.
159
- const order = [];
160
- const itemIdsBySubGoal = new Map();
161
- const verifiedAt = new Map();
162
- for (const round of input.rounds) {
163
- const { contract, statuses } = deriveRoundContractView({
164
- rounds: input.rounds,
165
- round: round.round,
166
- report: round.executionReport,
167
- deltas: round.observationDelta,
168
- outcome: round.outcome,
169
- commands: input.commands,
170
- });
171
- if (!contract)
172
- continue;
173
- const statusAt = new Map(statuses.items.map((item) => [item.itemId, item]));
174
- for (const item of contract.items) {
175
- if (statusAt.get(item.id)?.status !== "verified")
176
- continue;
177
- for (const ref of item.subgoal_refs) {
178
- if (!known.has(ref))
179
- continue;
180
- const itemIds = itemIdsBySubGoal.get(ref) ?? [];
181
- if (!itemIds.includes(item.id))
182
- itemIds.push(item.id);
183
- itemIdsBySubGoal.set(ref, itemIds);
184
- if (!order.includes(ref))
185
- order.push(ref);
186
- const at = statusAt.get(item.id)?.status_at_round ?? round.round;
187
- verifiedAt.set(ref, Math.max(verifiedAt.get(ref) ?? 0, at));
188
- }
189
- }
190
- }
191
- return order.map((subgoalId) => ({
192
- subgoal_id: subgoalId,
193
- contract_item_ids: itemIdsBySubGoal.get(subgoalId) ?? [],
194
- verified_at_round: verifiedAt.get(subgoalId) ?? 0,
195
- }));
196
- }
197
- /** v3.8: Sub-goals the agent declared `done` that no verified contract item
198
- * backs — verification debt, surfaced in the handoff's open risks. */
199
- export function deriveVerificationDebt(subGoals, verified, statuses) {
200
- const debt = [];
201
- const verifiedIds = new Set(verified.map((fact) => fact.subgoal_id));
202
- for (const subGoal of subGoals) {
203
- if (subGoal.status !== "done" || verifiedIds.has(subGoal.id))
204
- continue;
205
- debt.push(`sub-goal ${subGoal.id} "${subGoal.description.slice(0, 120)}": ` +
206
- "agent reported done, machine verification absent");
207
- }
208
- for (const item of statuses.items) {
209
- if (item.status !== "insufficient")
210
- continue;
211
- debt.push(`contract item ${item.itemId}: claimed met but not machine-verified` +
212
- (item.reasons.length > 0 ? ` (${item.reasons[0]})` : ""));
213
- }
214
- return debt;
215
- }
216
113
  //# sourceMappingURL=round-facts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"round-facts.js","sourceRoot":"","sources":["../src/round-facts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;A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AA2D;QACnE,YAAY,EAAE,CAAC;QACf,QAAQ,EAAE,CAAC;QACX,YAAY,EAAE,CAAC;KAChB,CAAC;IACF,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC"}
@@ -0,0 +1,56 @@
1
+ /** v4.0.4 / v4.0.7: the ONE runtime source of round-boundary and
2
+ * context-continuity guidance.
3
+ *
4
+ * The compiled prompt footer, the MCP server instructions, the tools/list
5
+ * `contextMode` description, the state file and the Explain view read these
6
+ * constants. The Forge skill keeps only the definitions and a pointer; it
7
+ * must not grow a second copy of the executable sizing rules.
8
+ *
9
+ * `HOST_INVOCATION_CONTRACT` is server-density prose only: the per-round
10
+ * prompt footer carries the Agent action surface, not the host runtime
11
+ * contract. `CONTEXT_MODE_DESCRIPTION` is the ONE tools/list description.
12
+ *
13
+ * This module is pure: no I/O, no policy, no time, no randomness.
14
+ */
15
+ import type { PromptContextMode, PromptContextReason } from "./protocol.js";
16
+ export declare const ROUND_BOUNDARY_PRINCIPLE: string;
17
+ export declare const ROUND_BOUNDARY_SIZING = "Keep coupled work together; split when unsafe to verify.";
18
+ export declare const ROUND_BOUNDARY_SUBMISSION: string;
19
+ export declare const ROUND_BOUNDARY_NON_BOUNDARIES: string;
20
+ /** v4.0.5: the ONE routing sentence for a lost in-context retry invocation.
21
+ * The prompt footer and the short retry guidance read it. LoopForge — not
22
+ * the Agent — recompiles the same round/attempt in clean context. */
23
+ export declare const ROUND_BOUNDARY_INVOCATION_LOST: string;
24
+ /** v4.0.7: the ONE host invocation contract. It separates the cleared model
25
+ * conversation from the warm host runtime and states what LoopForge does not
26
+ * manage. It is rendered at server density only; the per-round prompt footer
27
+ * does not repeat it. */
28
+ export declare const HOST_INVOCATION_CONTRACT: string;
29
+ /** v4.0.7: the ONE tools/list description of PromptContextMode. tools.ts
30
+ * imports it so the wire description and the runtime prose cannot drift. */
31
+ export declare const CONTEXT_MODE_DESCRIPTION: string;
32
+ /** The host execution contract. It names the four context strategies instead
33
+ * of asking the host to reinterpret an enum value:
34
+ * clean context, in-context repair, clean-context repair, recovery redo. */
35
+ export declare const CONTEXT_CONTINUITY_RULES: string;
36
+ export type GuidanceDensity = "prompt" | "server";
37
+ /** Render the runtime guidance.
38
+ *
39
+ * - `prompt` renders the boundary principle, sizing, submission and
40
+ * non-boundary rules. A `same_round_retry` already explained its single
41
+ * logical round in the retry section, so only submission and non-boundary
42
+ * rules are repeated. The fresh body is kept under ~480 characters so the
43
+ * L0 footer does not force a policy-budget change.
44
+ * - `server` renders the same rules plus the host context-continuity
45
+ * contract. */
46
+ export declare function renderRoundGuidance(density: GuidanceDensity, contextMode?: PromptContextMode): string;
47
+ /** Human-readable strategy label for one context boundary. JSON/artifacts keep
48
+ * the enum values; every human surface uses this ONE mapping.
49
+ *
50
+ * `recoveryBoundary` means a committed rollback directive governs this
51
+ * compile. A repeated rejection can escalate a retried redo; the label must
52
+ * keep the recovery-lesson fact instead of dropping it. */
53
+ export declare function formatContextBoundaryLabel(mode: PromptContextMode, reason: PromptContextReason, options?: {
54
+ recoveryBoundary?: boolean;
55
+ }): string;
56
+ //# sourceMappingURL=round-guidance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round-guidance.d.ts","sourceRoot":"","sources":["../src/round-guidance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,wBAAwB,QAE3B,CAAC;AAEX,eAAO,MAAM,qBAAqB,6DAC0B,CAAC;AAE7D,eAAO,MAAM,yBAAyB,QAGyB,CAAC;AAEhE,eAAO,MAAM,6BAA6B,QAEO,CAAC;AAElD;;sEAEsE;AACtE,eAAO,MAAM,8BAA8B,QAIO,CAAC;AAEnD;;;0BAG0B;AAC1B,eAAO,MAAM,wBAAwB,QAaZ,CAAC;AAE1B;6EAC6E;AAC7E,eAAO,MAAM,wBAAwB,QAYgB,CAAC;AAEtD;;6EAE6E;AAC7E,eAAO,MAAM,wBAAwB,QAsBgC,CAAC;AAEtE,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD;;;;;;;;kBAQkB;AAClB,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,iBAAiB,GAC9B,MAAM,CAuBR;AAED;;;;;4DAK4D;AAC5D,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,mBAAmB,EAC3B,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC3C,MAAM,CAmCR"}