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
@@ -0,0 +1,161 @@
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
+ export const ROUND_BOUNDARY_PRINCIPLE = "One round is a work slice with before/after evidence, not file/token/commit " +
16
+ "count.";
17
+ export const ROUND_BOUNDARY_SIZING = "Keep coupled work together; split when unsafe to verify.";
18
+ export const ROUND_BOUNDARY_SUBMISSION = "Agent chooses continuation via should_continue. A Round Contract scopes " +
19
+ "bounded NEXT-round work and acceptance, not this round's end. Acceptance " +
20
+ "commits; rejection retries the round (+1); maxRounds stops.";
21
+ export const ROUND_BOUNDARY_NON_BOUNDARIES = "Time, invocation/session/stage changes, redelivery, checkpoints, restores, " +
22
+ "status, resume and unpause do not end rounds.";
23
+ /** v4.0.5: the ONE routing sentence for a lost in-context retry invocation.
24
+ * The prompt footer and the short retry guidance read it. LoopForge — not
25
+ * the Agent — recompiles the same round/attempt in clean context. */
26
+ export const ROUND_BOUNDARY_INVOCATION_LOST = "If the invocation that received the previous prompt is gone, call " +
27
+ "loopforge_resume(loopId, invocationLost: true); LoopForge recompiles the " +
28
+ "same logical round and attempt in clean context. Never carry this " +
29
+ "in-context retry prompt into a new invocation.";
30
+ /** v4.0.7: the ONE host invocation contract. It separates the cleared model
31
+ * conversation from the warm host runtime and states what LoopForge does not
32
+ * manage. It is rendered at server density only; the per-round prompt footer
33
+ * does not repeat it. */
34
+ export const HOST_INVOCATION_CONTRACT = "Clean context starts a new model conversation, not a new host or tool " +
35
+ "runtime: do not carry the previous model transcript, tool outputs or " +
36
+ "uncommitted reasoning into it. Keep the same loopId, logical session and " +
37
+ "modified workspace; a host process that stays alive may keep the MCP " +
38
+ "connection and tool processes warm and the installed skill files " +
39
+ "available, while the host holds the submissionHandle for tool calls. " +
40
+ "A warm runtime is not model memory: the new conversation knows only what " +
41
+ "this prompt and the host's stable environment provide. LoopForge does not " +
42
+ "manage provider prompt/KV caches or implicit model habits and neither " +
43
+ "clears nor relies on them. Only committed facts and the bounded " +
44
+ "projections LoopForge returns for this invocation are guaranteed; " +
45
+ "anything else that must survive belongs to explicit host configuration, " +
46
+ "not a LoopForge fact.";
47
+ /** v4.0.7: the ONE tools/list description of PromptContextMode. tools.ts
48
+ * imports it so the wire description and the runtime prose cannot drift. */
49
+ export const CONTEXT_MODE_DESCRIPTION = "The derived context boundary of the returned prompt, projected from its " +
50
+ "PromptArtifact. fresh_invocation starts a new model conversation, not a " +
51
+ "host runtime: the previous model transcript, tool outputs and uncommitted " +
52
+ "reasoning are not carried; the invocation keeps the same loopId, logical " +
53
+ "session and workspace; a live host may keep its MCP connection, tool " +
54
+ "processes and installed skill files warm. It covers first_round, " +
55
+ "next_round, recovery_redo, rejection_escalation and invocation_recovery, " +
56
+ "and may describe the SAME logical round. same_round_retry " +
57
+ "(enforcement_retry) continues the original invocation below the repeated " +
58
+ "same-check rejection threshold. Prompt density does not determine it. " +
59
+ "LoopForge does not manage provider prompt/KV caches or implicit model " +
60
+ "habits. Read contextReason for the specific case.";
61
+ /** The host execution contract. It names the four context strategies instead
62
+ * of asking the host to reinterpret an enum value:
63
+ * clean context, in-context repair, clean-context repair, recovery redo. */
64
+ export const CONTEXT_CONTINUITY_RULES = "A fresh invocation is not a new loop: reuse the same loopId and workspace. " +
65
+ "It may carry the same logical round (an enforcement retry) or the next " +
66
+ "round after the last commit; it is the context boundary, not the round " +
67
+ "boundary. Clean context is not a workspace reset: the current modified " +
68
+ "workspace continues; it exists to keep the round focused and avoid an " +
69
+ "overloaded or misleading transcript. " +
70
+ HOST_INVOCATION_CONTRACT + " " +
71
+ "Prompt density does not choose the context boundary. Below the repeated " +
72
+ "same-check rejection threshold, continue the original invocation and " +
73
+ "inject the rejection notice, findings and failure reason. If that " +
74
+ "invocation is gone, call loopforge_resume(loopId, invocationLost: true): " +
75
+ "LoopForge recompiles the SAME round and attempt as a cold-context " +
76
+ "invocation_recovery prompt; never reuse the in-context retry prompt in a " +
77
+ "new model conversation. At the rejection escalation threshold, start a " +
78
+ "clean model conversation with the retry notice, findings, rejected-attempt " +
79
+ "posture and committed memory. That posture describes the rejected attempt, " +
80
+ "not the current workspace; inspect the current workspace before acting. " +
81
+ "A retry inside a recovered redo keeps its Recovery Brief. A held prompt, " +
82
+ "checkpoint, restore, status, resume or unpause never advances or resets " +
83
+ "the round. If the loopId or prompt is lost, use loopforge_status view=all " +
84
+ "and loopforge_resume; do not call loopforge_start for an existing " +
85
+ "objective. A stopped loop is terminal; resume does not reopen it.";
86
+ /** Render the runtime guidance.
87
+ *
88
+ * - `prompt` renders the boundary principle, sizing, submission and
89
+ * non-boundary rules. A `same_round_retry` already explained its single
90
+ * logical round in the retry section, so only submission and non-boundary
91
+ * rules are repeated. The fresh body is kept under ~480 characters so the
92
+ * L0 footer does not force a policy-budget change.
93
+ * - `server` renders the same rules plus the host context-continuity
94
+ * contract. */
95
+ export function renderRoundGuidance(density, contextMode) {
96
+ if (density === "prompt") {
97
+ if (contextMode === "same_round_retry") {
98
+ return [
99
+ ROUND_BOUNDARY_SUBMISSION,
100
+ ROUND_BOUNDARY_NON_BOUNDARIES,
101
+ ROUND_BOUNDARY_INVOCATION_LOST,
102
+ ].join("\n");
103
+ }
104
+ return [
105
+ ROUND_BOUNDARY_PRINCIPLE,
106
+ ROUND_BOUNDARY_SIZING,
107
+ ROUND_BOUNDARY_SUBMISSION,
108
+ ROUND_BOUNDARY_NON_BOUNDARIES,
109
+ ].join("\n");
110
+ }
111
+ return [
112
+ ROUND_BOUNDARY_PRINCIPLE,
113
+ ROUND_BOUNDARY_SIZING,
114
+ ROUND_BOUNDARY_SUBMISSION,
115
+ ROUND_BOUNDARY_NON_BOUNDARIES,
116
+ CONTEXT_CONTINUITY_RULES,
117
+ ].join("\n");
118
+ }
119
+ /** Human-readable strategy label for one context boundary. JSON/artifacts keep
120
+ * the enum values; every human surface uses this ONE mapping.
121
+ *
122
+ * `recoveryBoundary` means a committed rollback directive governs this
123
+ * compile. A repeated rejection can escalate a retried redo; the label must
124
+ * keep the recovery-lesson fact instead of dropping it. */
125
+ export function formatContextBoundaryLabel(mode, reason, options = {}) {
126
+ if (mode === "same_round_retry") {
127
+ return "in-context repair (same_round_retry; enforcement_retry; continue " +
128
+ "original invocation if alive; lessons injected)";
129
+ }
130
+ if (reason === "rejection_escalation") {
131
+ return options.recoveryBoundary
132
+ ? "clean context repair + recovery retry (fresh_invocation; " +
133
+ "rejection_escalation; recovery lessons carried)"
134
+ : "clean context repair (fresh_invocation; rejection_escalation; same " +
135
+ "logical round; rejected posture is attempt-time only)";
136
+ }
137
+ if (reason === "invocation_recovery") {
138
+ return options.recoveryBoundary
139
+ ? "clean context repair + invocation recovery + recovery retry " +
140
+ "(fresh_invocation; invocation_recovery; same logical round; " +
141
+ "retry and recovery lessons carried)"
142
+ : "clean context repair + invocation recovery (fresh_invocation; " +
143
+ "invocation_recovery; same logical round; retry lessons carried)";
144
+ }
145
+ if (reason === "enforcement_retry") {
146
+ return options.recoveryBoundary
147
+ ? "clean context repair + recovery retry (fresh_invocation; " +
148
+ "enforcement_retry; recovery lessons carried)"
149
+ : "clean context repair (fresh_invocation; enforcement_retry; same " +
150
+ "logical round; lessons carried)";
151
+ }
152
+ if (reason === "recovery_redo") {
153
+ return "clean context after restore (fresh_invocation; recovery_redo; " +
154
+ "lessons carried)";
155
+ }
156
+ if (reason === "first_round") {
157
+ return "clean context — first round (fresh_invocation)";
158
+ }
159
+ return "clean context — next round (fresh_invocation; workspace continues)";
160
+ }
161
+ //# sourceMappingURL=round-guidance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round-guidance.js","sourceRoot":"","sources":["../src/round-guidance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,MAAM,CAAC,MAAM,wBAAwB,GACnC,8EAA8E;IAC9E,QAAQ,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAChC,0DAA0D,CAAC;AAE7D,MAAM,CAAC,MAAM,yBAAyB,GACpC,0EAA0E;IAC1E,2EAA2E;IAC3E,6DAA6D,CAAC;AAEhE,MAAM,CAAC,MAAM,6BAA6B,GACxC,6EAA6E;IAC7E,+CAA+C,CAAC;AAElD;;sEAEsE;AACtE,MAAM,CAAC,MAAM,8BAA8B,GACzC,oEAAoE;IACpE,2EAA2E;IA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0.6: the ONE round-outcome predicates.
2
+ *
3
+ * Kept in a neutral module so contract closure, the contract walker, the
4
+ * verification gate, the coordinator and the gate record all share the same
5
+ * blocked definition without an import cycle through self-eval.
6
+ *
7
+ * v4.0.6: `outcome` is the SOLE round conclusion — `success` and
8
+ * `agent_stop_reason` are gone, so these predicates read one field.
9
+ */
10
+ import type { RoundOutcome, SelfEvaluation } from "./protocol.js";
11
+ /** v2.12 / v4.0.6: the round outcome. `outcome` is required on every
12
+ * evaluation; the defensive fallback only protects malformed library input
13
+ * and never invents success. */
14
+ export declare function effectiveOutcome(selfEval: SelfEvaluation): RoundOutcome;
15
+ /** v2.12 / v4.0.6: Whether the outcome is a success claim. */
16
+ export declare function effectiveSuccess(selfEval: SelfEvaluation): boolean;
17
+ /** v3.8.3 / v4.0.6: the ONE definition of "this round declares itself
18
+ * blocked" — a declared `outcome: "blocked"`. `needs_human_input` is now
19
+ * expressed by the blocker text, not a separate field. */
20
+ export declare function declaresBlocked(selfEval: SelfEvaluation): boolean;
21
+ //# sourceMappingURL=round-outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round-outcome.d.ts","sourceRoot":"","sources":["../src/round-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAElE;;iCAEiC;AACjC,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,YAAY,CAOvE;AAED,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAElE;AAED;;2DAE2D;AAC3D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAEjE"}
@@ -0,0 +1,31 @@
1
+ /** v3.9.7 / v4.0.6: the ONE round-outcome predicates.
2
+ *
3
+ * Kept in a neutral module so contract closure, the contract walker, the
4
+ * verification gate, the coordinator and the gate record all share the same
5
+ * blocked definition without an import cycle through self-eval.
6
+ *
7
+ * v4.0.6: `outcome` is the SOLE round conclusion — `success` and
8
+ * `agent_stop_reason` are gone, so these predicates read one field.
9
+ */
10
+ /** v2.12 / v4.0.6: the round outcome. `outcome` is required on every
11
+ * evaluation; the defensive fallback only protects malformed library input
12
+ * and never invents success. */
13
+ export function effectiveOutcome(selfEval) {
14
+ const outcome = selfEval.outcome;
15
+ if (outcome === "success" || outcome === "partial" ||
16
+ outcome === "failed" || outcome === "blocked") {
17
+ return outcome;
18
+ }
19
+ return "failed";
20
+ }
21
+ /** v2.12 / v4.0.6: Whether the outcome is a success claim. */
22
+ export function effectiveSuccess(selfEval) {
23
+ return effectiveOutcome(selfEval) === "success";
24
+ }
25
+ /** v3.8.3 / v4.0.6: the ONE definition of "this round declares itself
26
+ * blocked" — a declared `outcome: "blocked"`. `needs_human_input` is now
27
+ * expressed by the blocker text, not a separate field. */
28
+ export function declaresBlocked(selfEval) {
29
+ return selfEval.outcome === "blocked";
30
+ }
31
+ //# sourceMappingURL=round-outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round-outcome.js","sourceRoot":"","sources":["../src/round-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;iCAEiC;AACjC,MAAM,UAAU,gBAAgB,CAAC,QAAwB;IACvD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IACjC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;QAC9C,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,gBAAgB,CAAC,QAAwB;IACvD,OAAO,gBAAgB,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC;AAClD,CAAC;AAED;;2DAE2D;AAC3D,MAAM,UAAU,eAAe,CAAC,QAAwB;IACtD,OAAO,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC;AACxC,CAAC"}
@@ -6,17 +6,88 @@
6
6
  * a process crash is idempotent.
7
7
  */
8
8
  import type { LoopStore } from "./loop-store.js";
9
- import { LoopForgeEngine } from "./engine.js";
10
9
  import type { ObservationDelta } from "./evidence-provider.js";
11
- import type { ContractBinding, MachineObservation, PromptArtifact, SelfEvaluation, SubmissionDiagnostic } from "./protocol.js";
10
+ import type { CheckpointRef, CompiledRoundFacts, ContractBinding, EvidencePosture, MachineObservation, OperatorAcceptance, PromptArtifact, RecoveryDirective, RecoveryTarget, SelfEvaluation, SubmissionDiagnostic, VerificationFlag, WorkspaceCheckpointManifest } from "./protocol.js";
12
11
  import { type RoundProcessResult } from "./round-coordinator.js";
13
12
  import type { RoundCommitStore } from "./storage.js";
14
- /** v3.9.1: schema 3 embeds Git observation schema 2 (complete boundary
15
- * fingerprints) and later adds optional diagnostics/manifest fields. */
16
- export declare const ROUND_TRANSACTION_SCHEMA_VERSION: 3;
13
+ /** v3.9.7: schema 5 adds the transaction before-image, explicit mid-round
14
+ * checkpoints and the redo restore marker. v4.0.3: schema 7 requires the
15
+ * persisted `EvidencePosture` on every result and adds the transient
16
+ * `RetryContext`. v4.0.4: schema 8 embeds the schema-10 PromptArtifact
17
+ * (`fresh_invocation`) and the renamed `SelfEvaluation.agent_stop_reason`.
18
+ * v4.0.6: schema 9 is a BREAKING shape break — the committed evaluation
19
+ * carries a required `outcome`, one `execution_report.claims` channel
20
+ * (`cr-`/`rci-`) and `round_contract.supersedes`; `success`,
21
+ * `agent_stop_reason`, `contract_transition`, `tests_reported`,
22
+ * `criterion_claims` and `contract_item_claims` are gone. Every earlier
23
+ * version is reported as legacy by `legacyTransactionRounds`; there is no
24
+ * compatibility migration. */
25
+ export declare const ROUND_TRANSACTION_SCHEMA_VERSION: 9;
26
+ /** Maximum distinct mid-round checkpoints one transaction may reference. */
27
+ export declare const MAX_MID_CHECKPOINTS_PER_TRANSACTION = 32;
28
+ /** The root branch identity for every loop. */
29
+ export declare function rootBranchId(loopId: string): string;
30
+ /** v3.9.6: deterministic transaction identity. The logical round identity is
31
+ * still `roundId`; this id prevents a deep redo from replaying an abandoned
32
+ * commit at the same numeric round. */
33
+ export declare function deriveTransactionId(input: {
34
+ kind: "evaluation" | "rollback";
35
+ branchId: string;
36
+ roundId: string;
37
+ attempt: number;
38
+ promptHash?: string;
39
+ recovery?: {
40
+ target: RecoveryTarget;
41
+ reason: string;
42
+ /** v4.0.3: directive facts that distinguish two rollbacks of the same
43
+ * target/reason (stable, sorted, never arbitrary object order). */
44
+ abandonedRounds?: number[];
45
+ failedRounds?: number[];
46
+ observedSkippedFiles?: string[];
47
+ reportedSkippedFiles?: string[];
48
+ triggerFindings?: string[];
49
+ };
50
+ }): string;
17
51
  export type RoundTransactionPhase = "prepared" | "prompted" | "evaluated" | "rejected" | "committed" | "terminated";
52
+ /** v4.0.3: the transient facts a held retry needs, attached to the REJECTED
53
+ * snapshot before the retry prompt is compiled.
54
+ *
55
+ * It is in-flight transaction state, never committed history: a rejected
56
+ * attempt writes no Vault entry, and the retry commit clears this context
57
+ * together with the evaluation/result of the rejected attempt. Keeping it on
58
+ * the held snapshot (rather than only in the process that produced the
59
+ * rejection) is what lets `loopforge_resume`/a stalled retry still know the
60
+ * attempt number, rejection notice, findings and transient posture.
61
+ *
62
+ * `attempt` is the attempt the NEXT compile/submission uses — it equals
63
+ * `rejectedAttempt + 1`. */
64
+ export interface RetryContext {
65
+ /** The next attempt; equals `rejectedAttempt + 1`. */
66
+ attempt: number;
67
+ rejectedAttempt: number;
68
+ /** The enforcement gate's protected rejection notice. */
69
+ rejectionNotice: string;
70
+ /** Findings from the rejected attempt — authority for the retry, never for
71
+ * committed history. */
72
+ verificationFlags: VerificationFlag[];
73
+ /** The rejected attempt's transient evidence posture. It is rendered only
74
+ * as "not committed" and never enters the Vault, Working Memory or a gate. */
75
+ evidencePosture: EvidencePosture;
76
+ rejectedAt: number;
77
+ }
18
78
  export interface RoundTransactionSnapshot {
19
79
  schemaVersion: typeof ROUND_TRANSACTION_SCHEMA_VERSION;
80
+ /** v3.9.6: the transaction's branch. The root branch is
81
+ * `loop:<loopId>:branch:root`; a rollback directive's transactionId names
82
+ * the child branch used by its redo and all later transactions. */
83
+ branchId: string;
84
+ /** v3.9.6: stable identity of this transaction. `roundId` remains the
85
+ * logical round; `transactionId` distinguishes a redo from an abandoned
86
+ * commit at the same numeric round. */
87
+ transactionId: string;
88
+ /** v3.9.6: evaluations are normal work rounds; rollbacks are directives
89
+ * that abandon a round without claiming work. */
90
+ kind: "evaluation" | "rollback";
20
91
  roundId: string;
21
92
  loopId: string;
22
93
  round: number;
@@ -25,13 +96,47 @@ export interface RoundTransactionSnapshot {
25
96
  beforeEvidence: MachineObservation[];
26
97
  afterEvidence?: MachineObservation[];
27
98
  evaluation?: SelfEvaluation;
99
+ /** v4.0.1: the immutable operator surface, carried byte-identically on every
100
+ * evaluation transaction and rollback directive. A same-round redo may
101
+ * replace the numeric round slot, so the fact must travel with each durable
102
+ * document rather than existing only on the root. */
103
+ operatorAcceptance?: OperatorAcceptance;
104
+ /** v4.0.1: the compile facts that produced this evaluation. Absent on a
105
+ * rollback directive. */
106
+ compiled?: CompiledRoundFacts;
107
+ /** v3.9.6: committed rollback directive facts (rollback kind only). */
108
+ recovery?: RecoveryDirective;
28
109
  result?: RoundProcessResult;
110
+ /** v4.0.3: transient retry facts. Present only on a rejected attempt or its
111
+ * held retry prompt; never on a committed transaction, a directive or a
112
+ * terminated attempt. It is cleared before the retry commit. */
113
+ retryContext?: RetryContext;
29
114
  /** v3.9.1: every lossy normalization decision for this submission. Saved
30
115
  * with the transaction; strict boundary failures never reach here. */
31
116
  normalizationDiagnostics?: SubmissionDiagnostic[];
32
117
  /** v3.9.1: the known evaluation paths present in the raw submission. The
33
118
  * receipt uses this manifest; unknown paths live in diagnostics only. */
34
119
  submittedFields?: string[];
120
+ /** v3.9.7: the automatic transaction before-image. Required when the
121
+ * before-phase Git boundary was observed and materialized. */
122
+ beforeCheckpoint?: CheckpointRef;
123
+ /** v3.9.7: explicit machine fact when the automatic before-image failed.
124
+ * The round may continue; it is simply not a recovery target. */
125
+ beforeCheckpointError?: {
126
+ code: string;
127
+ detail: string;
128
+ at: number;
129
+ };
130
+ /** v3.9.7: Agent-created mid-round savepoints, creation order, capped. */
131
+ checkpoints?: CheckpointRef[];
132
+ /** v3.9.7: only on the redo transaction. Proves this round's before state
133
+ * was produced by a verified restore of the named directive. The target
134
+ * checkpoint id/hash live only in the directive. */
135
+ restore?: {
136
+ directiveTransactionId: string;
137
+ redoRound: number;
138
+ verifiedAt: number;
139
+ };
35
140
  /** v3.8: the contract binding resolved at commit time (see ContractBinding).
36
141
  * Absent when the committing round declared no contract. */
37
142
  contractBinding?: ContractBinding;
@@ -44,28 +149,24 @@ export interface RoundTransactionInput {
44
149
  snapshot: RoundTransactionSnapshot;
45
150
  task: string;
46
151
  maxRounds: number;
152
+ /** v4.0.1: the pre-commit history loaded by the advance path. Absent for
153
+ * direct callers, which let the round coordinator load it. */
154
+ history?: import("./history.js").CommittedHistory;
47
155
  selfEval: SelfEvaluation;
48
- lastSelfEval?: SelfEvaluation;
49
156
  consecutiveRejections: number;
50
157
  /** L4 (v3.7.x): previous round's rejection check (own-streak basis). */
51
158
  lastRejectionCheck?: string;
52
- successTrajectory: boolean[];
53
- /** v2.13: Files from skipped backtrack rounds for restore check. */
54
- backtrackSkippedFiles?: string[];
55
- /** M3 (v3.7.x): skipped-file git fingerprints at their failed rounds. */
56
- backtrackSkippedFingerprints?: Record<string, string>;
57
- /** v2.12: Git HEAD of the backtrack restore point. The verification gate
58
- * checks the workspace returns to this commit before accepting work. */
59
- backtrackTargetGitHead?: string;
60
- /** v3.9: files already dirty at the backtrack restore point (restore
61
- * baseline — see RoundProcessResult.backtrackTargetDirty). */
62
- backtrackTargetDirty?: string[];
63
159
  /** v3.8.3: trusted round-start entrypoint fingerprints (see RoundProcessInput). */
64
160
  entrypointTrust?: Record<string, string>;
65
161
  /** v3.9.1: normalization metadata carried into the evaluated snapshot. */
66
162
  normalizationDiagnostics?: SubmissionDiagnostic[];
67
163
  submittedFields?: string[];
68
164
  actualEvidence: MachineObservation[];
165
+ /** The in-flight transaction's before-image, for machine backtrack target
166
+ * mapping. Never a cognitive input. */
167
+ beforeCheckpoint?: CheckpointRef;
168
+ /** Reads a checkpoint manifest from the store (machine backtrack only). */
169
+ resolveCheckpointManifest?: (ref: CheckpointRef) => WorkspaceCheckpointManifest | null;
69
170
  }
70
171
  export interface RoundTransactionOutcome {
71
172
  snapshot: RoundTransactionSnapshot;
@@ -73,6 +174,15 @@ export interface RoundTransactionOutcome {
73
174
  /** true when a prior committed decision was replayed from the vault. */
74
175
  replayed: boolean;
75
176
  }
177
+ /** v3.9.6: a first-class rollback directive. `snapshot` is the held
178
+ * evaluation snapshot of the abandoned round; `recovery.transaction_id` is
179
+ * both the directive transaction and the child branch identity. */
180
+ export interface RecoveryTransactionInput {
181
+ snapshot: RoundTransactionSnapshot;
182
+ loopId: string;
183
+ recovery: RecoveryDirective;
184
+ actualEvidence: MachineObservation[];
185
+ }
76
186
  /** v3.8/v3.9.1: The round's observation delta (before → after). Each entry
77
187
  * carries raw before/after references; Git's `changedFiles` is the only
78
188
  * file-change fact and is null when the pair cannot be compared. DERIVED,
@@ -85,20 +195,57 @@ export declare function deriveRoundObservationDelta(before: MachineObservation[]
85
195
  * legacy documents explicitly instead of letting them vanish from history. */
86
196
  export declare function transactionSchemaVersionOf(value: unknown): number | null;
87
197
  export declare function makeRoundId(loopId: string, round: number): string;
88
- export declare function prepareRoundTransaction(loopId: string, round: number, beforeEvidence: MachineObservation[], promptArtifact?: PromptArtifact): RoundTransactionSnapshot;
198
+ export declare function prepareRoundTransaction(loopId: string, round: number, beforeEvidence: MachineObservation[], promptArtifact?: PromptArtifact, opts?: {
199
+ branchId?: string;
200
+ operatorAcceptance?: OperatorAcceptance;
201
+ compiled?: CompiledRoundFacts;
202
+ kind?: "evaluation";
203
+ beforeCheckpoint?: CheckpointRef;
204
+ beforeCheckpointError?: {
205
+ code: string;
206
+ detail: string;
207
+ at: number;
208
+ };
209
+ }): RoundTransactionSnapshot;
89
210
  /** Attach the next prompt attempt to a rejected logical round without changing
90
211
  * its identity or evidence baseline. Evaluation fields belong to the previous
91
212
  * attempt and are cleared before the Agent receives the retry prompt. */
92
- export declare function prepareRejectedAttempt(rejected: RoundTransactionSnapshot, promptArtifact: PromptArtifact): RoundTransactionSnapshot;
213
+ export declare function prepareRejectedAttempt(rejected: RoundTransactionSnapshot, promptArtifact: PromptArtifact, compiled?: CompiledRoundFacts, operatorAcceptance?: OperatorAcceptance): RoundTransactionSnapshot;
214
+ /** v4.0.5: re-bind a held RETRY prompt to a newly compiled artifact for the
215
+ * SAME logical round and attempt. This is not a new attempt: attempt, round,
216
+ * before evidence, retry facts, restore marker and branch stay byte-identical;
217
+ * only the prompt-derived identity (artifact, prompt hash, transaction id and
218
+ * the owning ids on checkpoints) changes.
219
+ *
220
+ * Context preservation is enforced here, not by convention:
221
+ * - the artifact identity must equal the held identity;
222
+ * - an invocation-recovery recompile must be
223
+ * `fresh_invocation / invocation_recovery`;
224
+ * - every other recompile must keep the held mode and reason exactly.
225
+ *
226
+ * Evaluation/result fields of the rejected attempt are cleared before the
227
+ * Agent receives the new prompt, exactly like `prepareRejectedAttempt`. */
228
+ export declare function rebindHeldPrompt(held: RoundTransactionSnapshot, artifact: PromptArtifact, compiled?: CompiledRoundFacts, operatorAcceptance?: OperatorAcceptance): RoundTransactionSnapshot;
229
+ /** v4.0.3: schema 7 structural validation of the persisted evidence posture.
230
+ * A committed round without a well-formed posture is a HARD break — it is not
231
+ * committed history and is reported as legacy, never silently re-derived. */
232
+ export declare function isEvidencePosture(value: unknown): value is EvidencePosture;
233
+ /** v4.0.3: structural validation of the transient retry context. It is only
234
+ * legal on a rejected attempt or its held retry prompt. */
235
+ export declare function isRetryContext(value: unknown): value is RetryContext;
93
236
  export declare function isProcessResult(value: unknown): value is RoundProcessResult;
94
237
  /** Parse a persisted snapshot without trusting arbitrary vault data. */
95
238
  export declare function parseRoundTransactionSnapshot(value: unknown): RoundTransactionSnapshot | null;
96
239
  export declare class RoundTransactionCoordinator {
97
- private readonly engine;
98
240
  private readonly store;
99
241
  private readonly commitStore;
100
- constructor(engine: LoopForgeEngine, store?: LoopStore, commitStore?: RoundCommitStore);
242
+ constructor(store: LoopStore, commitStore?: RoundCommitStore);
101
243
  process(input: RoundTransactionInput): RoundTransactionOutcome;
244
+ /** v3.9.6: commit an Agent-initiated rollback directive. This path does not
245
+ * run verification or enforcement: abandoning work is an action, not a
246
+ * success claim. The directive is a typed event, not a `:feedback` round. */
247
+ commitRecovery(input: RecoveryTransactionInput): RoundTransactionOutcome;
248
+ private readRecoveryCommitted;
102
249
  /** Recover an already committed decision without evaluating or writing. */
103
250
  recover(snapshot: RoundTransactionSnapshot): RoundTransactionOutcome | null;
104
251
  private readCommitted;
@@ -1 +1 @@
1
- {"version":3,"file":"round-transaction.d.ts","sourceRoot":"","sources":["../src/round-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EAEd,cAAc,EACd,oBAAoB,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAUhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;yEACyE;AACzE,eAAO,MAAM,gCAAgC,EAAG,CAAU,CAAC;AAO3D,MAAM,MAAM,qBAAqB,GAC7B,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,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