loopforge 3.2.1 → 3.7.0

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 (122) hide show
  1. package/README.md +74 -71
  2. package/dist/audit.d.ts.map +1 -1
  3. package/dist/audit.js +6 -38
  4. package/dist/audit.js.map +1 -1
  5. package/dist/canonical-state.d.ts +71 -6
  6. package/dist/canonical-state.d.ts.map +1 -1
  7. package/dist/canonical-state.js +176 -29
  8. package/dist/canonical-state.js.map +1 -1
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +16 -26
  11. package/dist/cli.js.map +1 -1
  12. package/dist/cognitive-facts.d.ts +17 -0
  13. package/dist/cognitive-facts.d.ts.map +1 -0
  14. package/dist/cognitive-facts.js +99 -0
  15. package/dist/cognitive-facts.js.map +1 -0
  16. package/dist/cognitive-governance.d.ts +0 -1
  17. package/dist/cognitive-governance.d.ts.map +1 -1
  18. package/dist/cognitive-governance.js +1 -4
  19. package/dist/cognitive-governance.js.map +1 -1
  20. package/dist/committed-round.d.ts +100 -0
  21. package/dist/committed-round.d.ts.map +1 -0
  22. package/dist/committed-round.js +349 -0
  23. package/dist/committed-round.js.map +1 -0
  24. package/dist/enforcement-gate.d.ts +4 -2
  25. package/dist/enforcement-gate.d.ts.map +1 -1
  26. package/dist/enforcement-gate.js +385 -357
  27. package/dist/enforcement-gate.js.map +1 -1
  28. package/dist/engine.d.ts +16 -4
  29. package/dist/engine.d.ts.map +1 -1
  30. package/dist/engine.js +65 -16
  31. package/dist/engine.js.map +1 -1
  32. package/dist/evidence-claims.d.ts.map +1 -1
  33. package/dist/evidence-claims.js +15 -39
  34. package/dist/evidence-claims.js.map +1 -1
  35. package/dist/evidence-provider.d.ts +35 -17
  36. package/dist/evidence-provider.d.ts.map +1 -1
  37. package/dist/evidence-provider.js +105 -108
  38. package/dist/evidence-provider.js.map +1 -1
  39. package/dist/index.d.ts +4 -4
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +3 -3
  42. package/dist/index.js.map +1 -1
  43. package/dist/loop-compiler.d.ts +21 -10
  44. package/dist/loop-compiler.d.ts.map +1 -1
  45. package/dist/loop-compiler.js +232 -276
  46. package/dist/loop-compiler.js.map +1 -1
  47. package/dist/loop-projection.d.ts +5 -25
  48. package/dist/loop-projection.d.ts.map +1 -1
  49. package/dist/loop-projection.js +18 -134
  50. package/dist/loop-projection.js.map +1 -1
  51. package/dist/loop-store.d.ts +16 -18
  52. package/dist/loop-store.d.ts.map +1 -1
  53. package/dist/loop-store.js +21 -63
  54. package/dist/loop-store.js.map +1 -1
  55. package/dist/mcp/round-lifecycle.d.ts +13 -10
  56. package/dist/mcp/round-lifecycle.d.ts.map +1 -1
  57. package/dist/mcp/round-lifecycle.js +95 -68
  58. package/dist/mcp/round-lifecycle.js.map +1 -1
  59. package/dist/mcp/server.js +3 -3
  60. package/dist/mcp/server.js.map +1 -1
  61. package/dist/mcp/session.d.ts +17 -5
  62. package/dist/mcp/session.d.ts.map +1 -1
  63. package/dist/mcp/session.js +177 -54
  64. package/dist/mcp/session.js.map +1 -1
  65. package/dist/mcp/tools.d.ts +12 -0
  66. package/dist/mcp/tools.d.ts.map +1 -1
  67. package/dist/mcp/tools.js +161 -53
  68. package/dist/mcp/tools.js.map +1 -1
  69. package/dist/policy-metrics.d.ts +0 -7
  70. package/dist/policy-metrics.d.ts.map +1 -1
  71. package/dist/policy-metrics.js +15 -55
  72. package/dist/policy-metrics.js.map +1 -1
  73. package/dist/policy.d.ts +22 -31
  74. package/dist/policy.d.ts.map +1 -1
  75. package/dist/policy.js +24 -42
  76. package/dist/policy.js.map +1 -1
  77. package/dist/prompt-assembler.d.ts +0 -3
  78. package/dist/prompt-assembler.d.ts.map +1 -1
  79. package/dist/prompt-assembler.js +124 -191
  80. package/dist/prompt-assembler.js.map +1 -1
  81. package/dist/protocol.d.ts +61 -46
  82. package/dist/protocol.d.ts.map +1 -1
  83. package/dist/protocol.js +2 -18
  84. package/dist/protocol.js.map +1 -1
  85. package/dist/replay.d.ts.map +1 -1
  86. package/dist/replay.js +21 -22
  87. package/dist/replay.js.map +1 -1
  88. package/dist/round-contract.d.ts +64 -0
  89. package/dist/round-contract.d.ts.map +1 -0
  90. package/dist/round-contract.js +80 -0
  91. package/dist/round-contract.js.map +1 -0
  92. package/dist/round-coordinator.d.ts +5 -3
  93. package/dist/round-coordinator.d.ts.map +1 -1
  94. package/dist/round-coordinator.js +34 -29
  95. package/dist/round-coordinator.js.map +1 -1
  96. package/dist/round-driver.d.ts +0 -4
  97. package/dist/round-driver.d.ts.map +1 -1
  98. package/dist/round-driver.js +1 -11
  99. package/dist/round-driver.js.map +1 -1
  100. package/dist/round-transaction.d.ts +0 -1
  101. package/dist/round-transaction.d.ts.map +1 -1
  102. package/dist/round-transaction.js +0 -1
  103. package/dist/round-transaction.js.map +1 -1
  104. package/dist/self-eval.d.ts +29 -34
  105. package/dist/self-eval.d.ts.map +1 -1
  106. package/dist/self-eval.js +112 -148
  107. package/dist/self-eval.js.map +1 -1
  108. package/dist/token-utils.d.ts +7 -3
  109. package/dist/token-utils.d.ts.map +1 -1
  110. package/dist/token-utils.js +18 -3
  111. package/dist/token-utils.js.map +1 -1
  112. package/dist/verification-gate.d.ts +72 -21
  113. package/dist/verification-gate.d.ts.map +1 -1
  114. package/dist/verification-gate.js +544 -157
  115. package/dist/verification-gate.js.map +1 -1
  116. package/dist/workspace.d.ts +29 -0
  117. package/dist/workspace.d.ts.map +1 -0
  118. package/dist/workspace.js +61 -0
  119. package/dist/workspace.js.map +1 -0
  120. package/loop_policy.json +5 -17
  121. package/package.json +2 -2
  122. package/skills/perception/SKILL.md +137 -136
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **A context window is not memory. Memory needs a runtime.**
4
4
 
5
- > **v3.2.1** — `npm install -g loopforge`. Node.js ≥ 18. Zero runtime dependencies.
5
+ > **v3.7.0** — `npm install -g loopforge`. Node.js ≥ 18. Zero runtime dependencies.
6
6
  > [中文文档](../README.zh-CN.md)
7
7
 
8
8
  ---
@@ -29,41 +29,54 @@ If each step succeeds with probability p, N sequential steps succeed with probab
29
29
 
30
30
  ## What LoopForge does about it
31
31
 
32
- LoopForge doesn't compete on context window size. It runs **outside** the agent and provides three things:
33
-
34
- ### 1. Breaks the summary cascade: Vault → compile, not summary → summary
35
-
36
- Each round's self-evaluation is written to a **typed vault** (JSON documents). The next round's prompt is not generated from the previous prompt's summary — it's **recompiled from the vault**. Milestones aren't summaries of summaries; they're recomputed from raw vault entries. Constraints and criteria carry stable IDs (`c-XXXXXXXX`, `cr-XXXXXXXX`) for exact matching — no Jaccard guesswork.
37
-
32
+ LoopForge runs outside the agent and owns the boundary between rounds. Its
33
+ design has two explicit sources:
34
+
35
+ - **One factual source:** committed typed round documents in the Vault.
36
+ - **One cognitive source:** Canonical State compiled from those facts.
37
+
38
+ `loopforge_next` accepts a structured evaluation. The core fields `success`,
39
+ `output_summary`, `constraint_violations`, and `should_continue` are strict;
40
+ optional fields are normalized. Invalid input returns `evaluation_invalid` and
41
+ can be corrected with the same `roundId` without saving session state, writing
42
+ a round, entering either gate, or changing metrics.
43
+
44
+ Valid submissions pass through evidence collection, a verification gate
45
+ organized into four domains (evaluation consistency, evidence integrity, plan
46
+ & contract, progress & recovery), and an enforcement gate driven by one
47
+ ordered strategy table across four action classes (evidence contradiction,
48
+ contract & scope, plan drift, progress recovery). Only an allowed round joins
49
+ committed history. The shared internal `CommittedRoundView` gives Replay,
50
+ Audit, Metrics, contracts, the compiler, and gate history one decoder and one
51
+ filtering policy. It does not create another storage format.
52
+
53
+ The compiler evolves Canonical State from committed history, then derives
54
+ focus, todo, phase, delegation, and handoff for prompts and status views. The
55
+ next prompt therefore comes from typed cognitive state, not from a summary of
56
+ the previous prompt.
57
+
58
+ ```text
59
+ Traditional: prompt -> summary -> next prompt -> another summary
60
+ LoopForge: committed rounds -> Canonical State -> next prompt
38
61
  ```
39
- ❌ Traditional: prompt → summary → next prompt → re-summarize → … (information evaporates each cycle)
40
- ✅ LoopForge: prompt → vault entry → next prompt (recompiled from vault, zero evaporation)
41
- ```
42
-
43
- ### 2. External judgment: the perspective the agent cannot provide for itself
44
-
45
- The verification gate cross-checks every agent claim against independent evidence — Git snapshots, test runner output, explicit verification commands. The enforcement gate detects what the agent cannot self-diagnose:
46
-
47
- - R1: You claimed success but criteria remain unmet → **you're deceiving yourself**
48
- - R3: You claimed success with no verifiable evidence → **your claim is empty**
49
- - R4: You've been stuck for 3 rounds → **you're stalled and you don't know it**
50
- - R5: Your progress is exactly zero → **you're going through the motions**
51
- - R7: You said you'd do X but did Y → **your intent and actions are disconnected**
52
-
53
- **The agent cannot self-detect these. The agent is the system that produced those narratives. External judgment is necessary.**
54
-
55
- ### 3. Walk back from dead ends
56
62
 
57
- Progress stall or flatline → roll back to the last clean round instead of terminating. A diagnosis of why the path failed is injected. The backtrack prompt includes concrete workspace restore commands — `git checkout -- . && git clean -fd` with affected file lists. The verification gate checks that the workspace was actually restored before the next submission. Valid discoveries from skipped rounds are preserved.
63
+ The verification gate compares claims with Git snapshots, test output, and
64
+ configured command evidence. The enforcement gate can accept, reject,
65
+ backtrack, or terminate. A rejected submission commits nothing. A stalled-
66
+ progress evaluator can restore the last clean round, inject a diagnosis, and
67
+ verify workspace restoration before work continues.
58
68
 
59
69
  ---
60
70
 
61
71
  ## What LoopForge is not
62
72
 
63
- - ❌ **Not a memory system** — the state file is a derived view. The vault is truth. No RAG, no vector DB.
64
- - ❌ **Not a context compressor** — doesn't compress prompts, doesn't do smart summarization. Recompiles from vault, not from the previous prompt.
65
- - ❌ **Not a constraint tracker** — constraints are one signal the verification gate monitors. The core value is external judgment.
66
- - ❌ **Not a replacement for the agent** — the agent still reads code, edits files, runs tools, and decides how to reason. LoopForge owns the **round boundary**.
73
+ - **Not a memory database.** The optional state file is derived. Committed
74
+ rounds hold facts, and Canonical State supplies runtime cognition.
75
+ - **Not a context compressor.** It recompiles prompts from typed state instead
76
+ of compressing the prior prompt.
77
+ - **Not a constraint tracker.** Constraints are one input to external judgment.
78
+ - **Not an agent or unattended executor.** The external agent owns planning,
79
+ code changes, and tool use. LoopForge governs round transitions.
67
80
 
68
81
  ---
69
82
 
@@ -86,54 +99,44 @@ available as a library for custom integrations.
86
99
 
87
100
  ## Architecture
88
101
 
89
- ```
90
- ┌─────────────────────────────────────────────────────┐
91
- │ Agent executes round │
92
- │ Reads code · Edits files · Runs tools · Reasons │
93
- └──────────────────────┬──────────────────────────────┘
94
- │ Agent submits SelfEvaluation
95
- ▼
96
- ┌─────────────────────────────────────────────────────┐
97
- │ LoopForge round boundary │
98
- │ │
99
- │ Evidence → Verify → Enforce → Commit → Compile │
100
- │ (Git/cmd) (19 checks) (10 rules) (vault) (next) │
101
- │ │
102
- │ accept: commit state, compile next round │
103
- │ reject: retry same round, zero state mutation │
104
- │ backtrack: roll back to last clean round, restore │
105
- │ terminate: persist terminal state │
106
- └──────────────────────┬──────────────────────────────┘
107
- │ Recompile prompt from vault
108
- ▼
109
- ┌─────────────────────────────────────────────────────┐
110
- │ Vault (typed JSON persistence) │
111
- │ loops/<id>/rounds/<n>.json · session.json · policy │
112
- │ Source of truth. Not a summary chain. │
113
- └─────────────────────────────────────────────────────┘
102
+ ```text
103
+ External agent
104
+ -> structured evaluation
105
+ -> evidence / verification / enforcement
106
+ -> accept, reject, backtrack, or terminate
107
+ reject / terminate: no round commit
108
+ accept / stop / backtrack: commit transaction decision
109
+ -> committed round documents [factual source]
110
+ -> CommittedRoundView [shared read model]
111
+ -> Replay [what happened]
112
+ -> Audit / Metrics [evidence and diagnostics]
113
+ -> Canonical State [cognitive source]
114
+ -> DerivedCognitiveFacts
115
+ -> prompt / state file / status
116
+ -> external agent, next round
114
117
  ```
115
118
 
116
119
  ---
117
120
 
118
121
  ## Key capabilities
119
122
 
120
- **Vault → compile, not summary → summary.** Every round's self-evaluation is written to the vault. The next prompt is recompiled from vault entries. Stable IDs (`c-` / `cr-` / `sg-XXXXXXXX`) enable exact constraint, criterion, and sub-goal matching — no Jaccard false positives.
121
-
122
- **External judgment.** The verification gate cross-checks agent claims against independent evidence. The enforcement gate detects cognitive integrity violations — progress stalls, intent-action gaps, empty success claims. The judge never shares the agent's context.
123
-
124
- **Model expresses information needs.** Each round, the agent tells the compiler: what to emphasize, which sections to expand, where it's confused. The compiler reorders within safety boundaries — mandatory sections untouched, budget respected.
125
-
126
- **Walk back from dead ends.** Progress stall → roll back to last clean round with a diagnosis. Workspace restore is prompted and verified — the next submission is rejected if files from skipped rounds are still dirty.
127
-
128
- **Substantive drift, not filler.** R7 accepts intentional pivots only when the clarification references concrete IDs or file paths. Three consecutive weak clarifications terminate the loop.
129
-
130
- **Thin prompt, fat state file.** L0 (retry) / L1 (continuation) / L2 (full rehydration) control density only — reasoning strategy belongs to the agent. Truth is in the vault.
131
-
132
- **Pause · Resume · Replay.** Cross-process session leases. Idempotent resume after interruption. Time-travel queries over committed rounds.
133
-
134
- **Nine MCP tools.** `start` · `next` · `status` · `stop` · `pause` · `resume` · `replay` + `gate_check` · `gate_resolve`. `status` is the unified inspection tool (`view=session|loop|all|audit`). Every tool returns JSON content blocks.
135
-
136
- **Zero dependencies. Policy-driven.** Node.js stdlib only. All thresholds, budgets, and intervals live in `loop_policy.json`. 715 tests.
123
+ - Structured evaluation with strict core fields, lenient optional normalization,
124
+ and retryable `evaluation_invalid` responses.
125
+ - One committed-round history for the compiler, contracts, gates, Replay,
126
+ Audit, and Metrics.
127
+ - One Canonical State for prompts, the optional state file, and current-status
128
+ cognition.
129
+ - Evidence-backed accept, reject, backtrack, and terminate decisions, including
130
+ Round Contract and workspace-restore checks.
131
+ - L0, L1, and L2 prompt density, five-state sub-goals, constraint lifecycle,
132
+ milestones, and agent-requested emphasis or confusion points.
133
+ - Separate Replay and Audit views. Replay answers what happened; Audit checks
134
+ evidence and completeness.
135
+ - Durable sessions with atomic round documents, sequence checks, owned locks,
136
+ renewable leases, pause, resume, and idempotent recovery.
137
+ - Nine MCP tools: `start`, `next`, `status`, `stop`, `pause`, `resume`, `replay`,
138
+ `gate_check`, and `gate_resolve`.
139
+ - Zero runtime dependencies. Policy controls thresholds, budgets, and intervals.
137
140
 
138
141
  ---
139
142
 
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAKjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,CAAA;KAAE,CAAC,CAAC;IACnF,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,CAAC;CACzF;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,GAAG,YAAY,GAAG,cAAc,CAAC;IAClD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,E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AE,CAAC;IACrB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,gBAAgB,EAAE,OAAO,CAAC;IAC1B,2EAA2E;IAC3E,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED;;oDAEoD;AACpD,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,UAAU,EAAE,EACrB,KAAK,CAAC,EAAE,SAAS,GAChB,WAAW,CA8Gb"}
package/dist/audit.js CHANGED
@@ -8,38 +8,8 @@
8
8
  import { eventSequence, StorageCorruptionError } from "./loop-store.js";
9
9
  import { auditOrder, deriveGate } from "./cognitive-governance.js";
10
10
  import { rederiveClaimViewWithFlags, listVerifiedClaims } from "./evidence-claims.js";
11
- import { effectiveOutcome } from "./self-eval.js";
12
- import { isRecord, entryRound as sharedEntryRound } from "./token-utils.js";
13
- function entryRound(entry) {
14
- return sharedEntryRound(entry);
15
- }
16
- /** Committed transaction payload from a feedback entry. */
17
- function committedTransaction(entry) {
18
- if (!isRecord(entry.loop_lineage))
19
- return null;
20
- const transaction = entry.loop_lineage.round_transaction;
21
- if (!isRecord(transaction) || !isRecord(transaction.snapshot))
22
- return null;
23
- const snapshot = transaction.snapshot;
24
- const evaluation = isRecord(snapshot.evaluation)
25
- ? snapshot.evaluation
26
- : null;
27
- const result = isRecord(snapshot.result) ? snapshot.result : null;
28
- const flags = Array.isArray(result?.verificationFlags)
29
- ? result.verificationFlags
30
- : [];
31
- const evidence = Array.isArray(snapshot.afterEvidence)
32
- ? snapshot.afterEvidence
33
- : Array.isArray(snapshot.roundEvidence)
34
- ? snapshot.roundEvidence
35
- : [];
36
- return {
37
- evaluation,
38
- flags,
39
- afterEvidence: evidence,
40
- action: typeof result?.action === "string" ? result.action : undefined,
41
- };
42
- }
11
+ import { isRecord, entryRound } from "./token-utils.js";
12
+ import { decodeCommittedRound, machineEvidenceForRound } from "./committed-round.js";
43
13
  /** Build the audit from committed vault entries. Pure, read-only.
44
14
  * @param store Optional LoopStore — when provided, sequence integrity is
45
15
  * checked and provenanceAvailable becomes true. */
@@ -51,7 +21,7 @@ export function buildAudit(loopId, entries, store) {
51
21
  const taskId = String(entry.task_id ?? "");
52
22
  if (!taskId.startsWith(`loop:${loopId}:r`) || !taskId.endsWith(":feedback"))
53
23
  continue;
54
- const committed = committedTransaction(entry);
24
+ const committed = decodeCommittedRound(entry);
55
25
  if (!committed)
56
26
  continue;
57
27
  // v2.14: rounds committed with action="backtrack" were rolled back —
@@ -60,11 +30,9 @@ export function buildAudit(loopId, entries, store) {
60
30
  if (committed.action === "backtrack")
61
31
  continue;
62
32
  const round = entryRound(entry);
63
- const outcome = committed.evaluation
64
- ? effectiveOutcome(committed.evaluation)
65
- : "unknown";
33
+ const outcome = committed.outcome ?? "unknown";
66
34
  const claimView = committed.evaluation
67
- ? rederiveClaimViewWithFlags(committed.evaluation, committed.afterEvidence, committed.flags)
35
+ ? rederiveClaimViewWithFlags(committed.evaluation, machineEvidenceForRound(committed), committed.verificationFlags)
68
36
  : null;
69
37
  rounds.push({
70
38
  round,
@@ -75,7 +43,7 @@ export function buildAudit(loopId, entries, store) {
75
43
  status: claim.status === "verified" ? "verified" : "unverified",
76
44
  }))
77
45
  : [],
78
- checks: committed.flags.map((flag) => ({
46
+ checks: committed.verificationFlags.map((flag) => ({
79
47
  check: flag.check,
80
48
  severity: flag.severity,
81
49
  verdict: flag.severity === "error" ? "failed" : flag.severity,
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,E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AAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC;IAElC,IAAI,OAAO,GAA2B,QAAQ,CAAC;IAC/C,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC;QACrF,OAAO,GAAG,cAAc,CAAC;IAC3B,CAAC;SAAM,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/E,OAAO,GAAG,YAAY,CAAC;IACzB,CAAC;IAED,OAAO;QACL,MAAM;QACN,OAAO;QACP,MAAM;QACN,KAAK;QACL,mBAAmB;QACnB,QAAQ,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC,EAAE;QAC7E,gBAAgB;QAChB,mBAAmB;KACpB,CAAC;AACJ,CAAC"}
@@ -3,7 +3,7 @@
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, SubGoal, VerificationFlag } from "./protocol.js";
6
+ import type { ConstraintMeta, CriterionStatus, Lesson, LoopCompileRequest, LoopCompileResponse, MilestoneSummary, RoundContract, SubGoal, VerificationFlag } from "./protocol.js";
7
7
  export declare const CANONICAL_STATE_SCHEMA_VERSION: 1;
8
8
  /** v3.2: Durable snapshot of what an L1 prompt actually presented last round.
9
9
  * Used as the diff baseline for L1 collapse. Persisted inside the lineage
@@ -21,6 +21,25 @@ export interface PresentedStateSnapshot {
21
21
  /** [start, end] round ranges of all milestones at presentation time. */
22
22
  milestoneRanges: Array<[number, number]>;
23
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
+ }
33
+ /** v3.3: Machine git-motion cross-check over the last committed rounds.
34
+ * Display-only companion to the R4/R5 exculpatory signal. Optional:
35
+ * absent when no committed rounds carry git snapshots — the object, when
36
+ * present, always carries definite values (v3.6: the null arms were dead —
37
+ * the derive path returns undefined wholesale instead of null fields). */
38
+ export interface MachineStatus {
39
+ windowRounds: number;
40
+ gitMotion: boolean;
41
+ motionRounds: number;
42
+ }
24
43
  export interface CanonicalLoopState {
25
44
  schemaVersion: typeof CANONICAL_STATE_SCHEMA_VERSION;
26
45
  loopId: string;
@@ -34,8 +53,6 @@ export interface CanonicalLoopState {
34
53
  hardConstraints: string[];
35
54
  activeConstraints: string[];
36
55
  retiredConstraints: string[];
37
- /** v2.3: Constraints demoted to inactive after prolonged inactivity. */
38
- inactiveConstraints: string[];
39
56
  /** v2.3: Per-constraint lifecycle metadata. */
40
57
  constraintMetadata: ConstraintMeta[];
41
58
  changesSinceLastRound: string[];
@@ -49,8 +66,6 @@ export interface CanonicalLoopState {
49
66
  failedPatterns: string[];
50
67
  /** v2.1: Phase-boundary milestone summaries that survive window eviction. */
51
68
  milestones: MilestoneSummary[];
52
- /** v2.1: Single-paragraph loop-level synthesis (formulaic). */
53
- loopSynthesis: string;
54
69
  /** v2.2: Structured sub-goals with compiler-managed lifecycle. */
55
70
  subGoals: SubGoal[];
56
71
  /** v3.2: Derived per-criterion status (goal → criteria → evidence view). */
@@ -75,12 +90,62 @@ export interface CanonicalLoopState {
75
90
  skipped: number;
76
91
  } | null;
77
92
  };
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
+ /** v3.3: Machine git-motion cross-check for the progress dashboard.
97
+ * Conditional presence: absent when no committed git snapshots exist. */
98
+ machineStatus?: MachineStatus;
99
+ /** v3.4: The ACTIVE Round Contract this round executes under —
100
+ * compile-derived from committed rounds (never the submission's own
101
+ * round_contract, which is a proposal for the NEXT round). Conditional
102
+ * presence: absent without an active contract — keeps state hashes
103
+ * byte-identical for contract-less rounds. */
104
+ roundContract?: RoundContract;
78
105
  }
79
106
  /** Deterministic JSON serialization used by state and prompt hashes. */
80
107
  export declare function stableStringify(value: unknown): string;
81
108
  export declare function hashCanonicalState(state: CanonicalLoopState): string;
82
109
  /** Human/Agent-readable materialized view. It is always reproducible from the
83
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.
113
+ *
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[];
124
+ /** v3.3/v3.4: Render the ACTIVE Round Contract as the Current Task section
125
+ * body — the single formatting source shared by prompts and the state
126
+ * file (module contract above). The original objective is NOT here: it
127
+ * 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;
134
+ /** Milestone heading line ("**🏁 Round 7** (Rounds 3–7, 60%)"). Shared by the
135
+ * L2 Phase History and the detailed L1 renderer; the L1 copy previously
136
+ * rendered the range as "R3–R7", a format only this heading used. */
137
+ export declare function milestoneHeading(milestone: MilestoneSummary): string;
84
138
  export declare function renderCanonicalStateMarkdown(state: CanonicalLoopState): string;
85
- export declare function createCanonicalLoopState(request: LoopCompileRequest, response: LoopCompileResponse, stateFilePath: string): CanonicalLoopState;
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. */
142
+ derived?: {
143
+ roundStats?: RoundStat[];
144
+ 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;
150
+ }): CanonicalLoopState;
86
151
  //# 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,OAAO,EACP,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,8BAA8B,EAAG,CAAU,CAAC;AAEzD;;;uEAGuE;AACvE,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd;0DACsD;IACtD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;8E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