loopforge 3.7.0 → 3.8.1

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 (151) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +171 -157
  3. package/dist/audit.d.ts +53 -1
  4. package/dist/audit.d.ts.map +1 -1
  5. package/dist/audit.js +106 -22
  6. package/dist/audit.js.map +1 -1
  7. package/dist/canonical-state.d.ts +75 -69
  8. package/dist/canonical-state.d.ts.map +1 -1
  9. package/dist/canonical-state.js +276 -168
  10. package/dist/canonical-state.js.map +1 -1
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +111 -12
  13. package/dist/cli.js.map +1 -1
  14. package/dist/cognitive-facts.d.ts +13 -0
  15. package/dist/cognitive-facts.d.ts.map +1 -1
  16. package/dist/cognitive-facts.js +30 -16
  17. package/dist/cognitive-facts.js.map +1 -1
  18. package/dist/cognitive-governance.d.ts +30 -6
  19. package/dist/cognitive-governance.d.ts.map +1 -1
  20. package/dist/cognitive-governance.js +74 -18
  21. package/dist/cognitive-governance.js.map +1 -1
  22. package/dist/committed-round.d.ts +109 -24
  23. package/dist/committed-round.d.ts.map +1 -1
  24. package/dist/committed-round.js +235 -52
  25. package/dist/committed-round.js.map +1 -1
  26. package/dist/contract-items.d.ts +55 -0
  27. package/dist/contract-items.d.ts.map +1 -0
  28. package/dist/contract-items.js +180 -0
  29. package/dist/contract-items.js.map +1 -0
  30. package/dist/enforcement-gate.d.ts +43 -20
  31. package/dist/enforcement-gate.d.ts.map +1 -1
  32. package/dist/enforcement-gate.js +269 -378
  33. package/dist/enforcement-gate.js.map +1 -1
  34. package/dist/engine.d.ts +11 -6
  35. package/dist/engine.d.ts.map +1 -1
  36. package/dist/engine.js +102 -67
  37. package/dist/engine.js.map +1 -1
  38. package/dist/evidence-claims.d.ts +4 -4
  39. package/dist/evidence-claims.d.ts.map +1 -1
  40. package/dist/evidence-claims.js +16 -14
  41. package/dist/evidence-claims.js.map +1 -1
  42. package/dist/evidence-provider.d.ts +91 -90
  43. package/dist/evidence-provider.d.ts.map +1 -1
  44. package/dist/evidence-provider.js +349 -160
  45. package/dist/evidence-provider.js.map +1 -1
  46. package/dist/explain.d.ts +76 -0
  47. package/dist/explain.d.ts.map +1 -0
  48. package/dist/explain.js +127 -0
  49. package/dist/explain.js.map +1 -0
  50. package/dist/generate-schema.js +250 -53
  51. package/dist/generate-schema.js.map +1 -1
  52. package/dist/index.d.ts +8 -7
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +7 -6
  55. package/dist/index.js.map +1 -1
  56. package/dist/loop-compiler.d.ts +41 -40
  57. package/dist/loop-compiler.d.ts.map +1 -1
  58. package/dist/loop-compiler.js +275 -515
  59. package/dist/loop-compiler.js.map +1 -1
  60. package/dist/loop-extras-parser.d.ts +0 -1
  61. package/dist/loop-extras-parser.d.ts.map +1 -1
  62. package/dist/loop-extras-parser.js +0 -4
  63. package/dist/loop-extras-parser.js.map +1 -1
  64. package/dist/loop-projection.d.ts.map +1 -1
  65. package/dist/loop-projection.js +3 -1
  66. package/dist/loop-projection.js.map +1 -1
  67. package/dist/mcp/round-lifecycle.d.ts +40 -21
  68. package/dist/mcp/round-lifecycle.d.ts.map +1 -1
  69. package/dist/mcp/round-lifecycle.js +173 -120
  70. package/dist/mcp/round-lifecycle.js.map +1 -1
  71. package/dist/mcp/server.d.ts.map +1 -1
  72. package/dist/mcp/server.js +63 -10
  73. package/dist/mcp/server.js.map +1 -1
  74. package/dist/mcp/session.d.ts +53 -7
  75. package/dist/mcp/session.d.ts.map +1 -1
  76. package/dist/mcp/session.js +240 -139
  77. package/dist/mcp/session.js.map +1 -1
  78. package/dist/mcp/submission-boundary.d.ts +89 -0
  79. package/dist/mcp/submission-boundary.d.ts.map +1 -0
  80. package/dist/mcp/submission-boundary.js +203 -0
  81. package/dist/mcp/submission-boundary.js.map +1 -0
  82. package/dist/mcp/tools.d.ts.map +1 -1
  83. package/dist/mcp/tools.js +377 -125
  84. package/dist/mcp/tools.js.map +1 -1
  85. package/dist/policy-metrics.js +2 -2
  86. package/dist/policy-metrics.js.map +1 -1
  87. package/dist/policy.d.ts +65 -95
  88. package/dist/policy.d.ts.map +1 -1
  89. package/dist/policy.js +151 -39
  90. package/dist/policy.js.map +1 -1
  91. package/dist/prompt-assembler.d.ts +7 -33
  92. package/dist/prompt-assembler.d.ts.map +1 -1
  93. package/dist/prompt-assembler.js +313 -473
  94. package/dist/prompt-assembler.js.map +1 -1
  95. package/dist/prompt-policy.d.ts +1 -4
  96. package/dist/prompt-policy.d.ts.map +1 -1
  97. package/dist/prompt-policy.js +6 -7
  98. package/dist/prompt-policy.js.map +1 -1
  99. package/dist/protocol.d.ts +411 -168
  100. package/dist/protocol.d.ts.map +1 -1
  101. package/dist/protocol.js +23 -69
  102. package/dist/protocol.js.map +1 -1
  103. package/dist/replay.js +2 -2
  104. package/dist/replay.js.map +1 -1
  105. package/dist/round-contract.d.ts +69 -57
  106. package/dist/round-contract.d.ts.map +1 -1
  107. package/dist/round-contract.js +104 -64
  108. package/dist/round-contract.js.map +1 -1
  109. package/dist/round-coordinator.d.ts +55 -16
  110. package/dist/round-coordinator.d.ts.map +1 -1
  111. package/dist/round-coordinator.js +179 -57
  112. package/dist/round-coordinator.js.map +1 -1
  113. package/dist/round-driver.d.ts +7 -5
  114. package/dist/round-driver.d.ts.map +1 -1
  115. package/dist/round-driver.js +2 -1
  116. package/dist/round-driver.js.map +1 -1
  117. package/dist/round-facts.d.ts +96 -0
  118. package/dist/round-facts.d.ts.map +1 -0
  119. package/dist/round-facts.js +216 -0
  120. package/dist/round-facts.js.map +1 -0
  121. package/dist/round-transaction.d.ts +23 -9
  122. package/dist/round-transaction.d.ts.map +1 -1
  123. package/dist/round-transaction.js +99 -22
  124. package/dist/round-transaction.js.map +1 -1
  125. package/dist/self-eval.d.ts +127 -11
  126. package/dist/self-eval.d.ts.map +1 -1
  127. package/dist/self-eval.js +517 -36
  128. package/dist/self-eval.js.map +1 -1
  129. package/dist/subgoal-state.d.ts +77 -0
  130. package/dist/subgoal-state.d.ts.map +1 -0
  131. package/dist/subgoal-state.js +198 -0
  132. package/dist/subgoal-state.js.map +1 -0
  133. package/dist/token-utils.d.ts +52 -19
  134. package/dist/token-utils.d.ts.map +1 -1
  135. package/dist/token-utils.js +83 -72
  136. package/dist/token-utils.js.map +1 -1
  137. package/dist/verification-gate.d.ts +27 -46
  138. package/dist/verification-gate.d.ts.map +1 -1
  139. package/dist/verification-gate.js +308 -557
  140. package/dist/verification-gate.js.map +1 -1
  141. package/dist/version.d.ts +5 -0
  142. package/dist/version.d.ts.map +1 -0
  143. package/dist/version.js +5 -0
  144. package/dist/version.js.map +1 -0
  145. package/dist/workspace.d.ts +9 -0
  146. package/dist/workspace.d.ts.map +1 -1
  147. package/dist/workspace.js +17 -0
  148. package/dist/workspace.js.map +1 -1
  149. package/loop_policy.json +17 -25
  150. package/package.json +7 -7
  151. package/skills/perception/SKILL.md +266 -64
@@ -1,80 +1,120 @@
1
- import { deriveItemId, jaccardSimilarity } from "./token-utils.js";
1
+ /** Round Contract derivation — the ACTIVE contract a round executes under.
2
+ *
3
+ * A submission's `round_contract` is a PROPOSAL for the next round. It
4
+ * becomes ACTIVE only after the declaring round commits; the active contract
5
+ * is then derived from committed rounds on every compile path (retry,
6
+ * resume, backtrack). It closes when every item is machine-verified, or when
7
+ * the agent reports `outcome: "blocked"`; while it is open a different
8
+ * proposal is ignored.
9
+ *
10
+ * v3.8 identity: `rc-` / `rci-` are derived from CONTENT ONLY (loop id +
11
+ * canonical proposal), so restating an unchanged contract keeps the same
12
+ * identity and the item ids the agent already cited. This is deliberately
13
+ * the opposite of a SubGoal, whose id includes its declaration round.
14
+ */
15
+ import { canonicalContractText, deriveContractId, deriveContractItemIds, } from "./token-utils.js";
16
+ import { deriveContractItemStatuses } from "./contract-items.js";
2
17
  import { getPolicy } from "./policy.js";
3
- // ── Criterion reference matching ──────────────────────────────────────────
4
- // Mirrors criteriaMatch (loop-compiler.ts) without importing loop-compiler
5
- // (round-contract is imported BY loop-compiler — importing back would be a
6
- // cycle). Parity is locked by round-contract.test.ts.
7
- const CRITERION_ID_RE = /^cr-[a-f0-9]{8}$/;
8
- function isCriterionId(ref) {
9
- return CRITERION_ID_RE.test(ref);
10
- }
11
- function deriveCriterionId(text) {
12
- return "cr-" + deriveItemId(text);
18
+ /** v3.8: Build the derived active contract from a committed proposal plus the
19
+ * binding the runtime stamped when that round committed. */
20
+ export function activateContract(proposal, declaredAtRound, binding, loopId) {
21
+ const itemIds = deriveContractItemIds(proposal.items);
22
+ return {
23
+ id: deriveContractId(loopId, proposal),
24
+ declared_at_round: declaredAtRound,
25
+ work_item: proposal.work_item,
26
+ scope: [...proposal.scope],
27
+ items: proposal.items.map((item, index) => ({
28
+ description: item.description,
29
+ criterion_refs: [...item.criterion_refs],
30
+ subgoal_refs: [...item.subgoal_refs],
31
+ verify_with: [...item.verify_with],
32
+ id: itemIds[index],
33
+ })),
34
+ config_hash_by_command: { ...(binding?.config_hash_by_command ?? {}) },
35
+ };
13
36
  }
14
- /** Match two done_when / met-claim references for completion testing.
15
- * cr-ID-aware + Jaccard fallback, identical to criteriaMatch. */
16
- export function contractItemMatches(a, b) {
17
- const aIsId = isCriterionId(a);
18
- const bIsId = isCriterionId(b);
19
- if (aIsId && bIsId)
20
- return a === b;
21
- if (aIsId)
22
- return a === deriveCriterionId(b);
23
- if (bIsId)
24
- return deriveCriterionId(a) === b;
25
- return jaccardSimilarity(a, b) >= getPolicy().evolution.criteria_dedup_threshold;
37
+ /** v3.8: Content equality — restating a contract unchanged is the same
38
+ * contract. Never compare by id (8 hex = 32 bits; a collision must not merge
39
+ * two different contracts). */
40
+ export function sameContract(left, right) {
41
+ return canonicalContractText(left) === canonicalContractText(right);
26
42
  }
27
- /** Whether every done_when item of `contract` matches a claim in `met`.
28
- * Vacuous when done_when is empty (such contracts were already warned
29
- * round_underspecified at declaration; they close at the first eval
30
- * committed while active). */
31
- export function contractDoneWhenSatisfied(contract, met) {
32
- if (contract.done_when.length === 0)
33
- return true;
34
- return contract.done_when.every((item) => met.some((claim) => contractItemMatches(item, claim)));
35
- }
36
- /** Walk committed evals (ASCENDING by round; the caller already restricts
37
- * them to rounds earlier than the compile/verify round) and return the
38
- * ACTIVE contract for the round after the last committed one — null means
39
- * the Current Task falls back to the original task text.
40
- *
41
- * State machine per committed eval r, with `active` the contract carried
42
- * into r (null = whole-task round):
43
- * - active && r.outcome === "blocked" → active = r.proposal
44
- * - active && all done_when in r.met → active = r.proposal
45
- * - active && neither → active unchanged (r's
46
- * different proposal is a premature replacement and is ignored)
47
- * - !active → active = r.proposal
48
- * (a proposal never activates on its own declaration round — it becomes
49
- * active only for the rounds that follow the commit). */
50
- export function deriveActiveRoundContract(committed) {
43
+ /** v3.8: The active contract after replaying committed rounds in order. */
44
+ export function deriveActiveRoundContract(rounds, commands = getPolicy().evidence.commands ?? []) {
51
45
  let active = null;
52
- for (const r of committed) {
46
+ for (let index = 0; index < rounds.length; index++) {
47
+ const round = rounds[index];
48
+ const proposal = round.contractProposal;
49
+ const activate = () => proposal
50
+ ? activateContract(proposal, round.round, round.contractBinding, round.loopId)
51
+ : null;
53
52
  if (active === null) {
54
- active = r.proposal ?? null;
53
+ active = activate();
55
54
  continue;
56
55
  }
57
- if (r.outcome === "blocked") {
58
- active = r.proposal ?? null;
56
+ // A blocked round closes the active contract (existing semantics), and a
57
+ // fully verified one does too. Order matters: blocked is checked first,
58
+ // mirroring the historical walker.
59
+ if (round.outcome === "blocked") {
60
+ active = activate();
59
61
  continue;
60
62
  }
61
- if (contractDoneWhenSatisfied(active, r.met)) {
62
- active = r.proposal ?? null;
63
+ const statuses = deriveContractItemStatuses({
64
+ contract: active,
65
+ rounds: rounds.slice(0, index + 1),
66
+ currentRound: round.round + 1,
67
+ currentReport: null,
68
+ currentObservations: [],
69
+ commands,
70
+ });
71
+ if (statuses.closure === "verified") {
72
+ active = activate();
63
73
  continue;
64
74
  }
65
- // active !== null and not closed — it continues; r's proposal (if any)
66
- // is a premature replacement and is ignored.
75
+ // Otherwise the active contract stays; a different proposal is ignored.
67
76
  }
68
77
  return active;
69
78
  }
70
- /** Narrow the shared committed-round view to the contract state machine's
71
- * inputs. Contract code never interprets persistence envelopes itself. */
72
- export function contractRoundEvaluations(rounds) {
73
- return rounds.map((view) => ({
74
- round: view.round,
75
- proposal: view.contractProposal,
76
- outcome: view.outcome,
77
- met: view.executionEvidence?.success_criteria_met ?? [],
78
- }));
79
+ /** v3.8: Every criterion id referenced by the contract's items. */
80
+ export function contractCriterionIds(contract) {
81
+ const ids = new Set();
82
+ for (const item of contract.items) {
83
+ for (const ref of item.criterion_refs) {
84
+ if (/^cr-[a-f0-9]{8}$/.test(ref))
85
+ ids.add(ref);
86
+ }
87
+ }
88
+ return [...ids];
89
+ }
90
+ /** v3.8: The contract a round EXECUTED under, plus every item's status as of
91
+ * that round — the ONE derivation the live coordinator, explain and audit
92
+ * share, so the three can never disagree about what a round ran under.
93
+ *
94
+ * Two things make this different from "derive from every round up to and
95
+ * including this one":
96
+ *
97
+ * - The executed contract comes from the rounds BEFORE this one. A proposal
98
+ * declared in round R becomes active in R+1, and a contract round R CLOSES
99
+ * must still be reported as round R's contract — folding R's own proposal
100
+ * into the walker would hand the round the successor (or nothing).
101
+ * - The round's own report and observations enter as the in-flight slice, so
102
+ * its claims and its bound commands are judged with the same reducer the
103
+ * coordinator uses before the round commits. */
104
+ export function deriveRoundContractView(input) {
105
+ const prior = input.rounds.filter((candidate) => candidate.round < input.round);
106
+ const contract = deriveActiveRoundContract(prior, input.commands);
107
+ return {
108
+ contract,
109
+ statuses: deriveContractItemStatuses({
110
+ contract,
111
+ rounds: prior,
112
+ currentRound: input.round,
113
+ currentReport: input.report,
114
+ currentObservations: input.observations,
115
+ currentOutcome: input.outcome,
116
+ commands: input.commands,
117
+ }),
118
+ };
79
119
  }
80
120
  //# sourceMappingURL=round-contract.js.map
@@ -1 +1 @@
1
- {"version":3,"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,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtC,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;mDAamD;AACnD,MAAM,UAAU,uBAAuB,CAAC,KASvC;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAChF,MAAM,QAAQ,GAAG,yBAAyB,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClE,OAAO;QACL,QAAQ;QACR,QAAQ,EAAE,0BAA0B,CAAC;YACnC,QAAQ;YACR,MAAM,EAAE,KAAK;YACb,YAAY,EAAE,KAAK,CAAC,KAAK;YACzB,aAAa,EAAE,KAAK,CAAC,MAAM;YAC3B,mBAAmB,EAAE,KAAK,CAAC,YAAY;YACvC,cAAc,EAAE,KAAK,CAAC,OAAO;YAC7B,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -17,9 +17,9 @@
17
17
  * Persistence is owned by round-transaction.ts so reject paths remain
18
18
  * side-effect free and accepted decisions can be replayed idempotently.
19
19
  */
20
- import type { LoopStore } from "./loop-store.js";
21
- import type { ProviderSnapshot } from "./evidence-provider.js";
22
- import type { SelfEvaluation, StopReason, VerificationFlag } from "./protocol.js";
20
+ import type { LoopStore, VaultEntry } from "./loop-store.js";
21
+ import type { MachineObservation } from "./protocol.js";
22
+ import type { SelfEvaluation, RoundVerificationStatus, StopReason, VerificationFlag } from "./protocol.js";
23
23
  /** Input to a single round processing step. */
24
24
  export interface RoundProcessInput {
25
25
  loopId: string;
@@ -32,13 +32,20 @@ export interface RoundProcessInput {
32
32
  lastSelfEval?: SelfEvaluation;
33
33
  /** How many consecutive rounds have been rejected by enforcement. */
34
34
  consecutiveRejections: number;
35
+ /** L4 (v3.7.x): which check rejected the previous round — lets uniform
36
+ * escalation rows act on their own streak, not an unrelated one. */
37
+ lastRejectionCheck?: string;
35
38
  /** v1.18: Evidence snapshots from configured providers. */
36
- evidenceSnapshots?: ProviderSnapshot[];
39
+ evidenceSnapshots?: MachineObservation[];
37
40
  /** Success values from already committed rounds. */
38
41
  successTrajectory?: boolean[];
39
42
  /** v2.13: Files from skipped backtrack rounds. Passed to verification
40
43
  * gate for post-backtrack workspace restore check. */
41
44
  backtrackSkippedFiles?: string[];
45
+ /** M3 (v3.7.x): git fingerprint of each skipped file as recorded at its
46
+ * failed round — machine proof of "untouched since the rollback" for
47
+ * the restore check. */
48
+ backtrackSkippedFingerprints?: Record<string, string>;
42
49
  /** v2.12: Git HEAD of the backtrack restore point. The verification gate
43
50
  * checks the workspace returns to this commit before accepting work. */
44
51
  backtrackTargetGitHead?: string;
@@ -59,6 +66,18 @@ export interface RoundProcessResult {
59
66
  backtrackSkippedDiscoveries?: string[];
60
67
  /** v2.10: Which enforcement rule triggered the backtrack. */
61
68
  backtrackTriggerRule?: string;
69
+ /** v3.7.1: Rounds rolled back (exclusive range above the restore point).
70
+ * Derived from committed facts + the in-flight attempt — rejected
71
+ * payloads are not durable history and never become a source. */
72
+ backtrackFailedRounds?: number[];
73
+ /** v3.7.1: One approach per failed round (committed output_summary or the
74
+ * in-flight attempt's), truncated — what must NOT be repeated. */
75
+ backtrackApproaches?: string[];
76
+ /** v3.7.1: Falsified assumptions from the failed rounds. */
77
+ backtrackWrongAssumptions?: string[];
78
+ /** M3 (v3.7.x): per-file git fingerprint at the failed round — lets the
79
+ * restore check prove a skipped file was never touched since the rollback. */
80
+ backtrackSkippedFingerprints?: Record<string, string>;
62
81
  /** Verification flags from this round (for injection into next prompt). */
63
82
  verificationFlags: VerificationFlag[];
64
83
  /** Enforcement action for observability. */
@@ -69,6 +88,11 @@ export interface RoundProcessResult {
69
88
  roundSuccess: boolean;
70
89
  /** Whether the verification gate returned "contradicted". */
71
90
  gateContradicted: boolean;
91
+ /** v3.8: The round-level verification posture, derived from the ACTIVE
92
+ * contract's item statuses and this round's claims: `trusted` (everything
93
+ * claimed is machine-backed), `insufficient` (claims unbacked, nothing
94
+ * contradicted), `contradicted` (a machine fact denies a claim). */
95
+ verificationStatus: RoundVerificationStatus;
72
96
  /** Updated consecutiveRejections count — caller must persist. */
73
97
  newConsecutiveRejections: number;
74
98
  /** Which enforcement check fired (set when action is "reject" or "terminate").
@@ -80,13 +104,6 @@ export interface RoundProcessResult {
80
104
  /** Whether the caller should push roundSuccess onto the success trajectory.
81
105
  * false when gateContradicted or when action is "reject". */
82
106
  shouldPushSuccessTrajectory: boolean;
83
- /** v2.12: True when this round's intent_drift was waived via substantive
84
- * drift_clarification. The caller uses this to track clarification streaks.
85
- * v3.3.1: false when R7 itself rejected/terminated on a weak or missing
86
- * clarification (the caller increments the streak); undefined when R7 did
87
- * not participate in the decision — a higher-priority rule's rejection
88
- * must never touch the streak. */
89
- clarificationAccepted?: boolean;
90
107
  /** v2.13: Git HEAD commit hash of the backtrack target round.
91
108
  * Set when action is "backtrack". The verification gate uses this
92
109
  * to check that the agent restored the workspace before working. */
@@ -96,6 +113,31 @@ export interface RoundProcessResult {
96
113
  * not still dirty (agent must restore workspace first). */
97
114
  backtrackSkippedFiles?: string[];
98
115
  }
116
+ /** v3.8.1: The rolled-back branch's facts — the ONE derivation of which rounds
117
+ * failed, which approaches must not be repeated, which assumptions were
118
+ * falsified, and which files (with their failed-round git fingerprints) the
119
+ * agent must restore.
120
+ *
121
+ * Sources are COMMITTED rounds above the restore point; rejected attempts are
122
+ * not durable history and never become a source. The in-flight attempt that
123
+ * triggered the rollback is the one exception — its evaluation lives in this
124
+ * process, not in committed history.
125
+ *
126
+ * Extracted from the coordinator's inline walk so it is unit-testable without
127
+ * driving a whole rollback, and so the prompt, the state file and the
128
+ * committed decision all describe one event. */
129
+ export declare function deriveBacktrackRecoveryFacts(input: {
130
+ currentRound: number;
131
+ restoreRound: number;
132
+ vaultEntries: VaultEntry[];
133
+ selfEval: SelfEvaluation;
134
+ }): {
135
+ skippedFiles: string[];
136
+ skippedFingerprints: Record<string, string>;
137
+ failedRounds: number[];
138
+ approaches: string[];
139
+ wrongAssumptions: string[];
140
+ };
99
141
  export declare class RoundCoordinator {
100
142
  private store;
101
143
  constructor(store?: LoopStore);
@@ -108,10 +150,7 @@ export declare class RoundCoordinator {
108
150
  * - Managing heartbeat / signal handlers (runtime only)
109
151
  * - Memory injection (both paths, before calling processRound)
110
152
  * - Transactional feedback commit (accepted rounds only)
111
- * - State file I/O (both paths, after compiling)
112
- *
113
- * @param driftClarificationStreak v2.12: Current clarification streak
114
- * from session state. Passed through to enforceRound for R7 escalation. */
115
- processRound(input: RoundProcessInput, driftClarificationStreak?: number): RoundProcessResult;
153
+ * - State file I/O (both paths, after compiling) */
154
+ processRound(input: RoundProcessInput): RoundProcessResult;
116
155
  }
117
156
  //# sourceMappingURL=round-coordinator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"round-coordinator.d.ts","sourceRoot":"","sources":["../src/round-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAEV,cAAc,EACd,UAAU,EACV,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAiBvB,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,C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