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
package/dist/audit.js CHANGED
@@ -4,36 +4,63 @@
4
4
  * happened per round); audit is the assessment layer (which claims are
5
5
  * machine-verified, which gates were decided, is the sequence intact).
6
6
  * Everything is derived from committed vault entries — audit never writes.
7
+ *
8
+ * v3.8: the CONTRACT ITEM axis is the primary completion basis. The criterion
9
+ * claims stay as an advisory second view — a criterion claim is an agent
10
+ * statement whose machine backing is mediated by the contract items, so it
11
+ * cannot be the completion signal. Both axes read the same committed-round
12
+ * model and the same item reducer the coordinator and explain use.
7
13
  */
8
14
  import { eventSequence, StorageCorruptionError } from "./loop-store.js";
9
15
  import { auditOrder, deriveGate } from "./cognitive-governance.js";
10
16
  import { rederiveClaimViewWithFlags, listVerifiedClaims } from "./evidence-claims.js";
11
17
  import { isRecord, entryRound } from "./token-utils.js";
12
- import { decodeCommittedRound, machineEvidenceForRound } from "./committed-round.js";
18
+ import { legacyTransactionRounds, machineEvidenceForRound, readOnlyRounds, } from "./committed-round.js";
19
+ import { deriveRoundContractView } from "./round-contract.js";
20
+ import { getPolicy } from "./policy.js";
13
21
  /** Build the audit from committed vault entries. Pure, read-only.
14
22
  * @param store Optional LoopStore — when provided, sequence integrity is
15
23
  * checked and provenanceAvailable becomes true. */
16
24
  export function buildAudit(loopId, entries, store) {
17
25
  const ordered = auditOrder(entries);
26
+ // v3.8: the shared committed-round read model — ordering, dedup and rollback
27
+ // exclusion come from it, not from a private rule. v3.8.1: the READ-ONLY
28
+ // window, which additionally applies the session frontier while a committed
29
+ // rollback directive is in effect, so a backtracked branch is not audited as
30
+ // this branch's history.
31
+ const views = readOnlyRounds(entries).filter((view) => view.loopId === loopId);
32
+ const commands = getPolicy().evidence.commands ?? [];
33
+ // The executed contract per round, through the ONE derivation explain and
34
+ // the live coordinator also call. Re-derived per round rather than walked
35
+ // incrementally on purpose: a private incremental walker would be a second
36
+ // history interpretation, which is exactly what this project forbids.
37
+ const contractByRound = new Map();
38
+ for (const view of views) {
39
+ contractByRound.set(view.round, deriveRoundContractView({
40
+ rounds: views,
41
+ round: view.round,
42
+ report: view.executionReport,
43
+ observations: view.observationDelta,
44
+ outcome: view.outcome,
45
+ commands,
46
+ }));
47
+ }
18
48
  // ── Rounds: per-round claims + checks from committed snapshots ─────────
49
+ //
50
+ // v3.8.1: the list is built from the SAME window the contract axis below
51
+ // reads. Scanning the raw entries here applied a second, weaker history
52
+ // rule — no replacement of a round by a later record of the same logical
53
+ // round — so a superseded record was listed twice and could still flip the
54
+ // verdict to `contradicted`, while explain (which reads only the window)
55
+ // reported a different loop. Rollback exclusion comes from the window too.
19
56
  const rounds = [];
20
- for (const entry of ordered) {
21
- const taskId = String(entry.task_id ?? "");
22
- if (!taskId.startsWith(`loop:${loopId}:r`) || !taskId.endsWith(":feedback"))
23
- continue;
24
- const committed = decodeCommittedRound(entry);
25
- if (!committed)
26
- continue;
27
- // v2.14: rounds committed with action="backtrack" were rolled back —
28
- // they are not part of the loop's final history. Counting them would
29
- // inflate the round list and let their error flags flip the verdict.
30
- if (committed.action === "backtrack")
31
- continue;
32
- const round = entryRound(entry);
33
- const outcome = committed.outcome ?? "unknown";
34
- const claimView = committed.evaluation
35
- ? rederiveClaimViewWithFlags(committed.evaluation, machineEvidenceForRound(committed), committed.verificationFlags)
57
+ for (const view of views) {
58
+ const round = view.round;
59
+ const outcome = view.outcome ?? "unknown";
60
+ const claimView = view.evaluation
61
+ ? rederiveClaimViewWithFlags(view.evaluation, machineEvidenceForRound(view), view.verificationFlags)
36
62
  : null;
63
+ const executed = contractByRound.get(round);
37
64
  rounds.push({
38
65
  round,
39
66
  outcome,
@@ -43,13 +70,57 @@ export function buildAudit(loopId, entries, store) {
43
70
  status: claim.status === "verified" ? "verified" : "unverified",
44
71
  }))
45
72
  : [],
46
- checks: committed.verificationFlags.map((flag) => ({
73
+ checks: view.verificationFlags.map((flag) => ({
47
74
  check: flag.check,
48
75
  severity: flag.severity,
49
76
  verdict: flag.severity === "error" ? "failed" : flag.severity,
50
77
  })),
78
+ contract: executed?.contract && executed.statuses.contractId
79
+ ? {
80
+ id: executed.statuses.contractId,
81
+ declared_at_round: executed.contract.declared_at_round,
82
+ closure: executed.statuses.closure,
83
+ items: executed.statuses.items.map((item) => ({
84
+ itemId: item.itemId,
85
+ status: item.status,
86
+ })),
87
+ }
88
+ : null,
51
89
  });
52
90
  }
91
+ // ── Contract item axis — the verification skeleton ─────────────────────
92
+ const contractsById = new Map();
93
+ for (const view of views) {
94
+ const executed = contractByRound.get(view.round);
95
+ if (!executed?.contract || !executed.statuses.contractId)
96
+ continue;
97
+ const id = executed.statuses.contractId;
98
+ const existing = contractsById.get(id);
99
+ contractsById.set(id, {
100
+ contract_id: id,
101
+ declared_at_round: existing?.declared_at_round ?? executed.contract.declared_at_round,
102
+ first_active_round: existing?.first_active_round ?? view.round,
103
+ last_active_round: view.round,
104
+ closure: executed.statuses.closure,
105
+ closed_at_round: executed.statuses.closed_at_round,
106
+ items: executed.statuses.items.map((item) => ({
107
+ itemId: item.itemId,
108
+ description: item.description,
109
+ status: item.status,
110
+ })),
111
+ });
112
+ }
113
+ const contracts = [...contractsById.values()]
114
+ .sort((a, b) => a.first_active_round - b.first_active_round || a.contract_id.localeCompare(b.contract_id));
115
+ const flatItems = contracts.flatMap((contract) => contract.items);
116
+ const contractsSummary = {
117
+ contracts,
118
+ open: contracts.filter((contract) => contract.closure === "open").length,
119
+ verifiedItems: flatItems.filter((item) => item.status === "verified").length,
120
+ insufficientItems: flatItems.filter((item) => item.status === "insufficient").length,
121
+ contradictedItems: flatItems.filter((item) => item.status === "contradicted").length,
122
+ pendingItems: flatItems.filter((item) => item.status === "pending").length,
123
+ };
53
124
  // ── Gates: latest decision wins; opened-without-decision stays open ────
54
125
  const decisionsByGate = new Map();
55
126
  const openedGates = new Map();
@@ -101,15 +172,26 @@ export function buildAudit(loopId, entries, store) {
101
172
  throw error;
102
173
  }
103
174
  }
104
- // ── Criteria accounting + verdict ──────────────────────────────────────
175
+ // ── Criteria accounting (advisory second axis) + verdict ───────────────
176
+ //
177
+ // v3.8 fix: `declared` used to be a PER-ROUND SUM while `evidenced` was a
178
+ // DEDUPLICATED count — a criterion claimed in three rounds read as three
179
+ // declared against one evidenced, so `missing` was fiction. Both sides are
180
+ // now distinct-id counts over the same history and compare directly.
105
181
  const verified = listVerifiedClaims(entries, loopId);
106
- const declared = rounds.reduce((sum, round) => sum + round.claims.length, 0);
182
+ const declaredIds = new Set(rounds.flatMap((round) => round.claims.map((claim) => claim.text)));
183
+ const declared = declaredIds.size;
107
184
  const evidenced = verified.length;
185
+ // v3.8: the contract item axis decides completion. A contradicted item is a
186
+ // machine denial; an open contract is unfinished verification; the claim
187
+ // axis only speaks when no contract item exists to speak for it.
108
188
  let verdict = "passed";
109
- if (rounds.some((round) => round.checks.some((check) => check.verdict === "failed"))) {
189
+ if (rounds.some((round) => round.checks.some((check) => check.verdict === "failed")) ||
190
+ contractsSummary.contradictedItems > 0) {
110
191
  verdict = "contradicted";
111
192
  }
112
- else if (unresolvedUserGates.length > 0 || (declared > 0 && evidenced === 0)) {
193
+ else if (unresolvedUserGates.length > 0 || contractsSummary.open > 0 ||
194
+ (declared > 0 && evidenced === 0)) {
113
195
  verdict = "incomplete";
114
196
  }
115
197
  return {
@@ -118,9 +200,11 @@ export function buildAudit(loopId, entries, store) {
118
200
  rounds,
119
201
  gates,
120
202
  unresolvedUserGates,
203
+ contracts: contractsSummary,
121
204
  criteria: { declared, evidenced, missing: Math.max(0, declared - evidenced) },
122
205
  sequenceComplete,
123
206
  provenanceAvailable,
207
+ legacyRounds: legacyTransactionRounds(entries).map((item) => item.round),
124
208
  };
125
209
  }
126
210
  //# sourceMappingURL=audit.js.map
package/dist/audit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AA8BrF;;oDAEoD;AACpD,MAAM,UAAU,UAAU,CACxB,MAAc,EACd,OAAqB,EACrB,KAAiB;IAEjB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAEpC,0EAA0E;IAC1E,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,MAAM,IAAI,CAAC,IAAI,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}
@@ -3,33 +3,25 @@
3
3
  * The canonical state is data, not Markdown. Prompt and state-file renderers
4
4
  * consume the same value so they cannot silently drift apart.
5
5
  */
6
- import type { ConstraintMeta, CriterionStatus, Lesson, LoopCompileRequest, LoopCompileResponse, MilestoneSummary, RoundContract, SubGoal, VerificationFlag } from "./protocol.js";
6
+ import type { ConstraintMeta, CriterionStatus, RecurringFlag, LoopCompileRequest, LoopCompileResponse, MilestoneSummary, SubGoal, VerificationFlag } from "./protocol.js";
7
+ import type { ActiveContractView } from "./round-contract.js";
8
+ import type { ContractItemStatusView } from "./contract-items.js";
9
+ import type { ConfiguredCapability, VerifiedSubGoalFact } from "./protocol.js";
10
+ import type { RoundFacts } from "./round-facts.js";
7
11
  export declare const CANONICAL_STATE_SCHEMA_VERSION: 1;
8
- /** v3.2: Durable snapshot of what an L1 prompt actually presented last round.
9
- * Used as the diff baseline for L1 collapse. Persisted inside the lineage
10
- * entry's loop_lineage (field extension — no new persistence format) and
11
- * carried on PromptArtifact for the compile-to-persist round-trip. */
12
- export interface PresentedStateSnapshot {
13
- /** Round whose presentation this snapshot describes (the baseline round). */
14
- round: number;
15
- /** Stable IDs (c-XXXXXXXX) of constraints rendered in the L1 Active
16
- * Constraints section (post-emphasize, non-hard). */
17
- constraintIds: string[];
18
- /** [sub-goal id, status] pairs rendered in the L1 Active Sub-Goals section
19
- * (in_progress + pending only). Statuses enable transition detection. */
20
- subGoals: Array<[string, string]>;
21
- /** [start, end] round ranges of all milestones at presentation time. */
22
- milestoneRanges: Array<[number, number]>;
23
- }
24
- /** v3.3: Per-round statistics for the display (files changed, rejected
25
- * attempts, self-reported progress delta). Compiler-derived from committed
26
- * entries — zero persistence. Optional: absent when no committed rounds. */
27
- export interface RoundStat {
28
- round: number;
29
- filesChangedCount: number | null;
30
- rejectedAttempts: number | null;
31
- progressDelta: number | null;
32
- }
12
+ /** v3.7.1: Presentation view of sub-goals shared by prompts and the state
13
+ * file (one derivation, no second copy). Only ACTIVE items render as rows
14
+ * — pending/in_progress/blocked — ordered blocked → in_progress → pending
15
+ * (priority ascending, then most recently changed first) and trimmed to
16
+ * `cap`. done/canceled never render as items: they stay in the vault, in
17
+ * replay, and in these counts. */
18
+ export declare function activeSubGoalView(subGoals: SubGoal[], cap: number): {
19
+ active: SubGoal[];
20
+ activeTotal: number;
21
+ done: number;
22
+ canceled: number;
23
+ total: number;
24
+ };
33
25
  /** v3.3: Machine git-motion cross-check over the last committed rounds.
34
26
  * Display-only companion to the R4/R5 exculpatory signal. Optional:
35
27
  * absent when no committed rounds carry git snapshots — the object, when
@@ -60,9 +52,7 @@ export interface CanonicalLoopState {
60
52
  blockers: string[];
61
53
  verificationFlags: VerificationFlag[];
62
54
  discoveries: string[];
63
- nextAction: string;
64
55
  rollingOutcomes: string[];
65
- recurringIssues: string[];
66
56
  failedPatterns: string[];
67
57
  /** v2.1: Phase-boundary milestone summaries that survive window eviction. */
68
58
  milestones: MilestoneSummary[];
@@ -70,13 +60,10 @@ export interface CanonicalLoopState {
70
60
  subGoals: SubGoal[];
71
61
  /** v3.2: Derived per-criterion status (goal → criteria → evidence view). */
72
62
  criterionStatuses: CriterionStatus[];
73
- /** v3.2: Deterministic lessons learned (repeated violations / failures). */
74
- lessons: Lesson[];
75
- /** v2.5: Agent trust score [0, 1] from verification flags. */
76
- agentTrustScore: number | undefined;
77
- /** v2.5: Trust trend over last 10 rounds. */
78
- agentTrustTrend: number[];
79
- suggestedNextTask: string;
63
+ /** v3.8.1: THE repeated-fact list (see RecurringFlag). One derivation
64
+ * replaces the former Lessons list and the rolling summary's
65
+ * "recurring_issues" window; renderers filter it. */
66
+ recurringFlags: RecurringFlag[];
80
67
  externalContext: string;
81
68
  stateFilePath: string;
82
69
  progress: {
@@ -90,9 +77,6 @@ export interface CanonicalLoopState {
90
77
  skipped: number;
91
78
  } | null;
92
79
  };
93
- /** v3.3: Display-only round stats over the last committed rounds.
94
- * Conditional presence: absent when there are no committed rounds. */
95
- roundStats?: RoundStat[];
96
80
  /** v3.3: Machine git-motion cross-check for the progress dashboard.
97
81
  * Conditional presence: absent when no committed git snapshots exist. */
98
82
  machineStatus?: MachineStatus;
@@ -101,51 +85,73 @@ export interface CanonicalLoopState {
101
85
  * round_contract, which is a proposal for the NEXT round). Conditional
102
86
  * presence: absent without an active contract — keeps state hashes
103
87
  * byte-identical for contract-less rounds. */
104
- roundContract?: RoundContract;
88
+ roundContract?: ActiveContractView;
89
+ /** v3.8: The derived item statuses of the ACTIVE contract — the runtime's
90
+ * statement about what the agent claimed under it. Conditional presence:
91
+ * absent without an active contract. */
92
+ contractItemStatuses?: ContractItemStatusView;
93
+ /** v3.8: Sub-goals a verified contract item backs. DERIVED, never
94
+ * persisted — the machine's separate statement about a `done` sub-goal. */
95
+ verifiedSubGoals?: VerifiedSubGoalFact[];
96
+ /** v3.8: The static verification capability (policy-derived). Unconditional:
97
+ * it is part of the round's verification context, so every state hash
98
+ * changes once, deliberately. */
99
+ capability: ConfiguredCapability;
105
100
  }
106
101
  /** Deterministic JSON serialization used by state and prompt hashes. */
107
102
  export declare function stableStringify(value: unknown): string;
108
103
  export declare function hashCanonicalState(state: CanonicalLoopState): string;
109
- /** Human/Agent-readable materialized view. It is always reproducible from the
110
- * canonical state and is never consulted as transaction truth. */
111
- /** v3.3: Forward-looking "roadmap" view derived from existing state — loop
112
- * position, met/remaining criteria (with IDs), and sub-goal activity.
104
+ /** v3.8.1: the one-line phase position — which phase the loop is in, and how
105
+ * far the next boundary is.
113
106
  *
114
- * Deliberately label-free: milestone labels/ranges are collapsed content in
115
- * L1 (the diff-collapse invariant) and are rendered in full by Phase
116
- * History everywhere else — the roadmap only reports "N rounds since the
117
- * last milestone boundary", never the boundary's identity. Next action is
118
- * likewise excluded: every level renders its own Next Action section.
119
- * Shared by the state-file and prompt renderers so they cannot silently
120
- * drift apart (module contract above). Returns [] — renders nothing —
121
- * when the state carries none of these. Presentation only; never feeds
122
- * enforcement. */
123
- export declare function buildRoadmap(state: CanonicalLoopState): string[];
107
+ * This is all that survives of v3.3's "roadmap": of its four lines, three
108
+ * (met/remaining criteria with ids, sub-goal activity) were already rendered
109
+ * in full by the sections that own them. Returns "" when no milestone exists,
110
+ * so the caller renders no section at all — bare position is already in the
111
+ * prompt header.
112
+ *
113
+ * Shared by the state-file and prompt renderers so they cannot drift apart
114
+ * (module contract above). Presentation only; never feeds enforcement. */
115
+ export declare function buildPhaseLine(state: CanonicalLoopState): string;
124
116
  /** v3.3/v3.4: Render the ACTIVE Round Contract as the Current Task section
125
117
  * body — the single formatting source shared by prompts and the state
126
118
  * file (module contract above). The original objective is NOT here: it
127
119
  * lives in the Objective section. Empty arrays render no line. */
128
- export declare function formatRoundContract(contract: RoundContract): string;
129
- /** The trust bar line ("██████░░░░ 60%"). The L2 Agent Trust section and the
130
- * detailed L1 renderer used to carry private copies of this formula — shared
131
- * here so a formatting change is made once (module contract: renderers must
132
- * not silently drift apart). */
133
- export declare function trustBarLine(score: number): string;
120
+ export declare function formatRoundContract(contract: ActiveContractView,
121
+ /** v3.8: the derived item statuses. When given, each item renders with its
122
+ * machine status — the agent sees the verification debt in its own task. */
123
+ statuses?: ContractItemStatusView | null): string;
134
124
  /** Milestone heading line ("**🏁 Round 7** (Rounds 3–7, 60%)"). Shared by the
135
125
  * L2 Phase History and the detailed L1 renderer; the L1 copy previously
136
126
  * rendered the range as "R3–R7", a format only this heading used. */
137
127
  export declare function milestoneHeading(milestone: MilestoneSummary): string;
138
- export declare function renderCanonicalStateMarkdown(state: CanonicalLoopState): string;
139
- export declare function createCanonicalLoopState(request: LoopCompileRequest, response: LoopCompileResponse, stateFilePath: string,
140
- /** v3.3: Display-only derived data (round stats, machine git-motion).
141
- * Optional 4th param — callers that predate v3.3 stay on 3-arg calls. */
128
+ /** Options that vary per render: the retry attempt (single version of the
129
+ * file across attempts is impossible — the attempt IS part of the derived
130
+ * view) and the recovery-window Recovery Brief lines (W5, present only
131
+ * while a committed backtrack decision is the current round's record). */
132
+ export interface StateFileRenderOptions {
133
+ attempt?: number;
134
+ recoveryBrief?: string[];
135
+ }
136
+ /** Human/Agent-readable materialized view. It is always reproducible from the
137
+ * canonical state and is never consulted as transaction truth.
138
+ *
139
+ * v3.8.1: this is where the diagnostics live — the progress dashboard, the
140
+ * criterion list, round stats, the FULL recurring-flag history and the phase
141
+ * history. The prompt carries only what the next round needs. */
142
+ export declare function renderCanonicalStateMarkdown(state: CanonicalLoopState, options?: StateFileRenderOptions): string;
143
+ export declare function createCanonicalLoopState(request: LoopCompileRequest, response: LoopCompileResponse, stateFilePath: string,
144
+ /** v3.3: Display-only derived data. Optional 4th param — callers that
145
+ * predate v3.3 stay on 3-arg calls. */
142
146
  derived?: {
143
- roundStats?: RoundStat[];
144
147
  machineStatus?: MachineStatus;
145
- /** v3.4: ACTIVE Round Contract for this round (compile-derived from the
146
- * committed evals of earlier rounds — see loop-compiler). Drives the
147
- * Current Task. Never the submission's own round_contract field, which
148
- * is a proposal for the NEXT round. */
149
- roundContract?: RoundContract | null;
148
+ /** v3.8.1: the contract-fact bundle — the ACTIVE Round Contract (drives
149
+ * the Current Task; never the submission's own `round_contract` field,
150
+ * which is a proposal for the NEXT round), its derived item statuses, and
151
+ * the machine-verified sub-goal facts, all from ONE `deriveRoundFacts`
152
+ * call. Taking them as a bundle makes it structurally impossible to
153
+ * assemble a state out of values derived over different history windows —
154
+ * v3.4/v3.8 passed them as three independent options. */
155
+ roundFacts?: RoundFacts;
150
156
  }): CanonicalLoopState;
151
157
  //# sourceMappingURL=canonical-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"canonical-state.d.ts","sourceRoot":"","sources":["../src/canonical-state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,8BAA8B,EAAG,CAA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