loopforge 2.7.0 → 3.0.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.
- package/README.md +136 -182
- package/dist/canonical-event-writer.d.ts +20 -0
- package/dist/canonical-event-writer.d.ts.map +1 -0
- package/dist/canonical-event-writer.js +131 -0
- package/dist/canonical-event-writer.js.map +1 -0
- package/dist/canonical-state.d.ts +20 -16
- package/dist/canonical-state.d.ts.map +1 -1
- package/dist/canonical-state.js +211 -64
- package/dist/canonical-state.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -10
- package/dist/cli.js.map +1 -1
- package/dist/cognitive-governance.d.ts +48 -0
- package/dist/cognitive-governance.d.ts.map +1 -0
- package/dist/cognitive-governance.js +226 -0
- package/dist/cognitive-governance.js.map +1 -0
- package/dist/compiler-subgoals.d.ts +7 -0
- package/dist/compiler-subgoals.d.ts.map +1 -0
- package/dist/compiler-subgoals.js +93 -0
- package/dist/compiler-subgoals.js.map +1 -0
- package/dist/derive-id.d.ts +12 -0
- package/dist/derive-id.d.ts.map +1 -0
- package/dist/derive-id.js +31 -0
- package/dist/derive-id.js.map +1 -0
- package/dist/evidence-provider.d.ts +26 -26
- package/dist/evidence-provider.d.ts.map +1 -1
- package/dist/evidence-provider.js +45 -71
- package/dist/evidence-provider.js.map +1 -1
- package/dist/generate-schema.js +90 -2
- package/dist/generate-schema.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -26
- package/dist/index.js.map +1 -1
- package/dist/loop-compiler.d.ts +2 -2
- package/dist/loop-compiler.d.ts.map +1 -1
- package/dist/loop-compiler.js +321 -315
- package/dist/loop-compiler.js.map +1 -1
- package/dist/loop-extras-parser.d.ts +2 -2
- package/dist/loop-extras-parser.d.ts.map +1 -1
- package/dist/loop-extras-parser.js +2 -2
- package/dist/loop-extras-parser.js.map +1 -1
- package/dist/loop-store.d.ts +20 -58
- package/dist/loop-store.d.ts.map +1 -1
- package/dist/loop-store.js +232 -311
- package/dist/loop-store.js.map +1 -1
- package/dist/mcp/server.d.ts +3 -3
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +123 -19
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session-projection.d.ts +5 -0
- package/dist/mcp/session-projection.d.ts.map +1 -0
- package/dist/mcp/session-projection.js +18 -0
- package/dist/mcp/session-projection.js.map +1 -0
- package/dist/mcp/session-queue.d.ts +3 -0
- package/dist/mcp/session-queue.d.ts.map +1 -0
- package/dist/mcp/session-queue.js +18 -0
- package/dist/mcp/session-queue.js.map +1 -0
- package/dist/mcp/session-types.d.ts +72 -0
- package/dist/mcp/session-types.d.ts.map +1 -0
- package/dist/mcp/session-types.js +2 -0
- package/dist/mcp/session-types.js.map +1 -0
- package/dist/mcp/session.d.ts +65 -84
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +667 -224
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/tools.d.ts +26 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +401 -254
- package/dist/mcp/tools.js.map +1 -1
- package/dist/policy-metrics.d.ts +24 -0
- package/dist/policy-metrics.d.ts.map +1 -1
- package/dist/policy-metrics.js +174 -0
- package/dist/policy-metrics.js.map +1 -1
- package/dist/policy.d.ts +74 -12
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +124 -19
- package/dist/policy.js.map +1 -1
- package/dist/prompt-assembler.d.ts +8 -4
- package/dist/prompt-assembler.d.ts.map +1 -1
- package/dist/prompt-assembler.js +533 -86
- package/dist/prompt-assembler.js.map +1 -1
- package/dist/prompt-policy.d.ts +8 -1
- package/dist/prompt-policy.d.ts.map +1 -1
- package/dist/prompt-policy.js +26 -8
- package/dist/prompt-policy.js.map +1 -1
- package/dist/protocol.d.ts +259 -173
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +17 -96
- package/dist/protocol.js.map +1 -1
- package/dist/replay.d.ts +11 -3
- package/dist/replay.d.ts.map +1 -1
- package/dist/replay.js +51 -14
- package/dist/replay.js.map +1 -1
- package/dist/round-commit-store.d.ts +12 -0
- package/dist/round-commit-store.d.ts.map +1 -0
- package/dist/round-commit-store.js +13 -0
- package/dist/round-commit-store.js.map +1 -0
- package/dist/round-coordinator.d.ts +53 -22
- package/dist/round-coordinator.d.ts.map +1 -1
- package/dist/round-coordinator.js +140 -44
- package/dist/round-coordinator.js.map +1 -1
- package/dist/round-driver.d.ts +18 -10
- package/dist/round-driver.d.ts.map +1 -1
- package/dist/round-driver.js +11 -13
- package/dist/round-driver.js.map +1 -1
- package/dist/round-gate.d.ts +31 -0
- package/dist/round-gate.d.ts.map +1 -0
- package/dist/round-gate.js +259 -0
- package/dist/round-gate.js.map +1 -0
- package/dist/round-recovery.d.ts +17 -0
- package/dist/round-recovery.d.ts.map +1 -0
- package/dist/round-recovery.js +117 -0
- package/dist/round-recovery.js.map +1 -0
- package/dist/round-report.d.ts +16 -0
- package/dist/round-report.d.ts.map +1 -0
- package/dist/round-report.js +401 -0
- package/dist/round-report.js.map +1 -0
- package/dist/round-transaction.d.ts +23 -12
- package/dist/round-transaction.d.ts.map +1 -1
- package/dist/round-transaction.js +104 -91
- package/dist/round-transaction.js.map +1 -1
- package/dist/runtime-services.d.ts +59 -0
- package/dist/runtime-services.d.ts.map +1 -0
- package/dist/{engine.js → runtime-services.js} +157 -275
- package/dist/runtime-services.js.map +1 -0
- package/dist/storage.d.ts +3 -9
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +6 -17
- package/dist/storage.js.map +1 -1
- package/dist/token-utils.d.ts +12 -8
- package/dist/token-utils.d.ts.map +1 -1
- package/dist/token-utils.js +56 -10
- package/dist/token-utils.js.map +1 -1
- package/dist/vault-format.d.ts +4 -0
- package/dist/vault-format.d.ts.map +1 -0
- package/dist/vault-format.js +4 -0
- package/dist/vault-format.js.map +1 -0
- package/dist/vault-types.d.ts +24 -0
- package/dist/vault-types.d.ts.map +1 -0
- package/dist/vault-types.js +2 -0
- package/dist/vault-types.js.map +1 -0
- package/loop_policy.json +10 -12
- package/loopforge-policy.json +340 -0
- package/package.json +13 -7
- package/skills/perception/SKILL.md +200 -90
- package/dist/backends/interface.d.ts +0 -39
- package/dist/backends/interface.d.ts.map +0 -1
- package/dist/backends/interface.js +0 -6
- package/dist/backends/interface.js.map +0 -1
- package/dist/enforcement-gate.d.ts +0 -50
- package/dist/enforcement-gate.d.ts.map +0 -1
- package/dist/enforcement-gate.js +0 -501
- package/dist/enforcement-gate.js.map +0 -1
- package/dist/engine.d.ts +0 -59
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js.map +0 -1
- package/dist/interop.d.ts +0 -35
- package/dist/interop.d.ts.map +0 -1
- package/dist/interop.js +0 -34
- package/dist/interop.js.map +0 -1
- package/dist/run.d.ts +0 -51
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -200
- package/dist/run.js.map +0 -1
- package/dist/self-eval.d.ts +0 -23
- package/dist/self-eval.d.ts.map +0 -1
- package/dist/self-eval.js +0 -151
- package/dist/self-eval.js.map +0 -1
- package/dist/verification-gate.d.ts +0 -52
- package/dist/verification-gate.d.ts.map +0 -1
- package/dist/verification-gate.js +0 -527
- package/dist/verification-gate.js.map +0 -1
package/dist/protocol.js
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
export var Mode;
|
|
10
10
|
(function (Mode) {
|
|
11
11
|
Mode["LOOP_COMPILE"] = "loop_compile";
|
|
12
|
-
Mode["FEEDBACK"] = "feedback";
|
|
13
12
|
})(Mode || (Mode = {}));
|
|
14
13
|
export var AgentStatus;
|
|
15
14
|
(function (AgentStatus) {
|
|
@@ -17,25 +16,6 @@ export var AgentStatus;
|
|
|
17
16
|
AgentStatus["ERROR"] = "error";
|
|
18
17
|
AgentStatus["STALLED"] = "stalled";
|
|
19
18
|
})(AgentStatus || (AgentStatus = {}));
|
|
20
|
-
export function makeExecutionFeedback(overrides = {}) {
|
|
21
|
-
return {
|
|
22
|
-
output: "",
|
|
23
|
-
success: false,
|
|
24
|
-
constraint_violations: [],
|
|
25
|
-
manual_fixes_needed: "",
|
|
26
|
-
...overrides,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export function makeExecutionEvidence(overrides = {}) {
|
|
30
|
-
return {
|
|
31
|
-
files_changed: [],
|
|
32
|
-
test_results: null,
|
|
33
|
-
success_criteria_met: [],
|
|
34
|
-
success_criteria_remaining: [],
|
|
35
|
-
progress_estimate: 0.0,
|
|
36
|
-
...overrides,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
19
|
export function makeMilestoneSummary(overrides = {}) {
|
|
40
20
|
return {
|
|
41
21
|
label: "",
|
|
@@ -49,32 +29,6 @@ export function makeMilestoneSummary(overrides = {}) {
|
|
|
49
29
|
...overrides,
|
|
50
30
|
};
|
|
51
31
|
}
|
|
52
|
-
export function makeSelfEvaluation(overrides = {}) {
|
|
53
|
-
return {
|
|
54
|
-
success: false,
|
|
55
|
-
output_summary: "",
|
|
56
|
-
constraint_violations: [],
|
|
57
|
-
should_continue: true,
|
|
58
|
-
discovered_constraints: [],
|
|
59
|
-
objective_refinement: "",
|
|
60
|
-
emerged_subtasks: [],
|
|
61
|
-
execution_evidence: undefined,
|
|
62
|
-
retracted_constraints: [],
|
|
63
|
-
revised_success_criteria: [],
|
|
64
|
-
wrong_assumptions: [],
|
|
65
|
-
worker_results: [],
|
|
66
|
-
compression_checkpoint: false,
|
|
67
|
-
checkpoint_label: "",
|
|
68
|
-
next_action: undefined,
|
|
69
|
-
completed_subtasks: [],
|
|
70
|
-
blocked_subtasks: [],
|
|
71
|
-
canceled_subtasks: [],
|
|
72
|
-
stop_reason: undefined,
|
|
73
|
-
...overrides,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/** Regex to extract a self-evaluation JSON block from agent output. */
|
|
77
|
-
export const SELF_EVAL_REGEX = /---loopforge-eval\s*([\s\S]*?)\s*---end-loopforge-eval/;
|
|
78
32
|
export function makeLoopObjective(overrides = {}) {
|
|
79
33
|
return {
|
|
80
34
|
objective: "",
|
|
@@ -123,6 +77,7 @@ export function makeSubGoal(overrides = {}) {
|
|
|
123
77
|
}
|
|
124
78
|
export function makeConstraintMeta(overrides = {}) {
|
|
125
79
|
return {
|
|
80
|
+
id: "",
|
|
126
81
|
text: "",
|
|
127
82
|
discovered_at_round: 0,
|
|
128
83
|
last_violated_at_round: 0,
|
|
@@ -140,30 +95,6 @@ export function makeTaskAlignment(overrides = {}) {
|
|
|
140
95
|
...overrides,
|
|
141
96
|
};
|
|
142
97
|
}
|
|
143
|
-
export function makeLoopRoundResult(overrides = {}) {
|
|
144
|
-
return {
|
|
145
|
-
round: 0,
|
|
146
|
-
success: false,
|
|
147
|
-
output_summary: "",
|
|
148
|
-
constraint_violations: [],
|
|
149
|
-
manual_fixes_needed: "",
|
|
150
|
-
discovered_constraints: [],
|
|
151
|
-
objective_refinement: "",
|
|
152
|
-
emerged_subtasks: [],
|
|
153
|
-
execution_evidence: undefined,
|
|
154
|
-
retracted_constraints: [],
|
|
155
|
-
revised_success_criteria: [],
|
|
156
|
-
wrong_assumptions: [],
|
|
157
|
-
worker_results: [],
|
|
158
|
-
compression_checkpoint: false,
|
|
159
|
-
checkpoint_label: "",
|
|
160
|
-
next_action: undefined,
|
|
161
|
-
completed_subtasks: [],
|
|
162
|
-
blocked_subtasks: [],
|
|
163
|
-
canceled_subtasks: [],
|
|
164
|
-
...overrides,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
98
|
export function makeLoopCompileRequest(overrides = {}) {
|
|
168
99
|
return {
|
|
169
100
|
mode: Mode.LOOP_COMPILE,
|
|
@@ -177,7 +108,7 @@ export function makeLoopCompileRequest(overrides = {}) {
|
|
|
177
108
|
plan_source: null,
|
|
178
109
|
constraints_from_plan: [],
|
|
179
110
|
new_since_last_round: "",
|
|
180
|
-
|
|
111
|
+
last_round_view: null,
|
|
181
112
|
force_level: "auto",
|
|
182
113
|
health_check_interval: 1,
|
|
183
114
|
external_context: "",
|
|
@@ -210,12 +141,24 @@ export function makeLoopCompileResponse(overrides = {}) {
|
|
|
210
141
|
constraint_metadata: [],
|
|
211
142
|
agent_trust_score: undefined,
|
|
212
143
|
agent_trust_trend: [],
|
|
213
|
-
|
|
144
|
+
projection: makeLoopCompileProjection(),
|
|
214
145
|
plan_source: null,
|
|
215
146
|
warnings: [],
|
|
216
147
|
error: "",
|
|
217
148
|
state_file_content: undefined,
|
|
218
149
|
prompt_artifact: undefined,
|
|
150
|
+
canonical_state: undefined,
|
|
151
|
+
...overrides,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export function makeLoopCompileProjection(overrides = {}) {
|
|
155
|
+
return {
|
|
156
|
+
suggestedNextAction: "",
|
|
157
|
+
verifiedFacts: [],
|
|
158
|
+
verifiedEvidenceRefs: [],
|
|
159
|
+
regressionObligations: [],
|
|
160
|
+
discoveredFacts: [],
|
|
161
|
+
activeBlockers: [],
|
|
219
162
|
...overrides,
|
|
220
163
|
};
|
|
221
164
|
}
|
|
@@ -225,10 +168,6 @@ export function makeEvidenceSnapshot(overrides = {}) {
|
|
|
225
168
|
export function makeSessionState(taskId) {
|
|
226
169
|
return {
|
|
227
170
|
task_id: taskId,
|
|
228
|
-
call_count: 0,
|
|
229
|
-
success_trend: [],
|
|
230
|
-
current_version: "v1",
|
|
231
|
-
feedback_buffer: [],
|
|
232
171
|
};
|
|
233
172
|
}
|
|
234
173
|
export function makeEnforcementResult(overrides = {}) {
|
|
@@ -237,6 +176,8 @@ export function makeEnforcementResult(overrides = {}) {
|
|
|
237
176
|
reason: "",
|
|
238
177
|
fix_instructions: "",
|
|
239
178
|
check: "",
|
|
179
|
+
clarification_accepted: false,
|
|
180
|
+
escalation_issued: false,
|
|
240
181
|
...overrides,
|
|
241
182
|
};
|
|
242
183
|
}
|
|
@@ -256,26 +197,6 @@ export function makeVerificationResult(overrides = {}) {
|
|
|
256
197
|
...overrides,
|
|
257
198
|
};
|
|
258
199
|
}
|
|
259
|
-
// ── Serialisation helpers ───────────────────────────────────────────────────
|
|
260
|
-
export function toDict(obj) {
|
|
261
|
-
const result = {};
|
|
262
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
263
|
-
if (value === null || value === undefined)
|
|
264
|
-
continue;
|
|
265
|
-
if (typeof value === "object" && !Array.isArray(value)) {
|
|
266
|
-
result[key] = toDict(value);
|
|
267
|
-
}
|
|
268
|
-
else if (Array.isArray(value)) {
|
|
269
|
-
result[key] = value.map((v) => typeof v === "object" && v !== null && !Array.isArray(v)
|
|
270
|
-
? toDict(v)
|
|
271
|
-
: v);
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
result[key] = value;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
200
|
// ── Factory helpers ─────────────────────────────────────────────────────────
|
|
280
201
|
export function makeTaskId(taskDescription) {
|
|
281
202
|
let slug = taskDescription.toLowerCase().trim().slice(0, 60);
|
package/dist/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8EAA8E;AAE9E,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8EAA8E;AAE9E,MAAM,CAAN,IAAY,IAEX;AAFD,WAAY,IAAI;IACd,qCAA6B,CAAA;AAC/B,CAAC,EAFW,IAAI,KAAJ,IAAI,QAEf;AAED,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,wBAAS,CAAA;IACT,8BAAe,CAAA;IACf,kCAAmB,CAAA;AACrB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AA6PD,MAAM,UAAU,oBAAoB,CACl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ChB,CAAC;AACJ,CAAC;AAqDD,MAAM,UAAU,qBAAqB,CACnC,YAAwC,EAAE;IAE1C,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,EAAE;QACV,gBAAgB,EAAE,EAAE;QACpB,KAAK,EAAE,EAAE;QACT,sBAAsB,EAAE,KAAK;QAC7B,iBAAiB,EAAE,KAAK;QACxB,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AA4CD,MAAM,UAAU,oBAAoB,CAClC,YAAuC,EAAE;IAEzC,OAAO;QACL,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAgBD,MAAM,UAAU,sBAAsB,CACpC,YAAyC,EAAE;IAE3C,OAAO;QACL,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,EAAE;QACT,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,+EAA+E;AAE/E,MAAM,UAAU,UAAU,CAAC,eAAuB;IAChD,IAAI,IAAI,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7D,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IACzC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,OAAO,IAAI,IAAI,cAAc,CAAC;AAChC,CAAC"}
|
package/dist/replay.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
/** ReplayBackend — time-travel queries over vault lineage.
|
|
2
2
|
*
|
|
3
|
-
* Depends on
|
|
3
|
+
* Depends on LoopStore — no direct filesystem access.
|
|
4
4
|
* Enables audit, comparison, and timeline analysis of loop rounds.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { VaultEntry } from "./vault-types.js";
|
|
7
|
+
import type { LoopStore } from "./loop-store.js";
|
|
7
8
|
export declare class ReplayBackend {
|
|
8
9
|
private readonly backend;
|
|
9
|
-
constructor(backend:
|
|
10
|
+
constructor(backend: LoopStore);
|
|
10
11
|
getRound(loopId: string, roundNum: number): VaultEntry | null;
|
|
11
12
|
replay(loopId: string, opts?: {
|
|
12
13
|
start?: number;
|
|
13
14
|
end?: number;
|
|
14
15
|
}): VaultEntry[];
|
|
16
|
+
/** Return the complete canonical event stream for a loop.
|
|
17
|
+
*
|
|
18
|
+
* Unlike the legacy round summary below, this view preserves every event
|
|
19
|
+
* (round events, gates, retries and lineage) and its event_sequence so callers
|
|
20
|
+
* can paginate and replay the durable source of truth deterministically.
|
|
21
|
+
*/
|
|
22
|
+
eventTimeline(loopId: string): Record<string, unknown>[];
|
|
15
23
|
timeline(loopId: string): Record<string, unknown>[];
|
|
16
24
|
private maxRound;
|
|
17
25
|
}
|
package/dist/replay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMjD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAY;gBAExB,OAAO,EAAE,SAAS;IAM9B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAgC7D,MAAM,CACJ,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACtC,UAAU,EAAE;IAkBf;;;;;OAKG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IA+BxD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAqBnD,OAAO,CAAC,QAAQ;CAcjB"}
|
package/dist/replay.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** ReplayBackend — time-travel queries over vault lineage.
|
|
2
2
|
*
|
|
3
|
-
* Depends on
|
|
3
|
+
* Depends on LoopStore — no direct filesystem access.
|
|
4
4
|
* Enables audit, comparison, and timeline analysis of loop rounds.
|
|
5
5
|
*/
|
|
6
6
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -14,22 +14,20 @@ export class ReplayBackend {
|
|
|
14
14
|
// ── Single-round lookup ────────────────────────────────────────────────
|
|
15
15
|
getRound(loopId, roundNum) {
|
|
16
16
|
const prefix = `loop:${loopId}:r${roundNum}`;
|
|
17
|
-
const entries = this.backend.
|
|
18
|
-
|
|
17
|
+
const entries = this.backend.queryLoopEvents(loopId)
|
|
18
|
+
.filter((entry) => String(entry.task_id ?? "").startsWith(prefix));
|
|
19
|
+
const lineageEntries = entries.filter((e) => !String(e.task_id ?? "").endsWith(":event"));
|
|
19
20
|
if (!lineageEntries.length)
|
|
20
21
|
return null;
|
|
21
22
|
const entry = { ...lineageEntries[0] };
|
|
22
|
-
// Merge
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const fbSuccess = fbEntries[0].success;
|
|
29
|
-
if (fbSuccess !== undefined) {
|
|
30
|
-
entry.success = fbSuccess;
|
|
23
|
+
// Merge round-event success flag
|
|
24
|
+
const roundEvents = entries.filter((entry) => String(entry.task_id ?? "").endsWith(":event"));
|
|
25
|
+
if (roundEvents.length) {
|
|
26
|
+
const eventSuccess = roundEvents[0].success;
|
|
27
|
+
if (eventSuccess !== undefined) {
|
|
28
|
+
entry.success = eventSuccess;
|
|
31
29
|
const lineage = (entry.loop_lineage ?? {});
|
|
32
|
-
lineage.success =
|
|
30
|
+
lineage.success = eventSuccess;
|
|
33
31
|
entry.loop_lineage = lineage;
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -53,6 +51,44 @@ export class ReplayBackend {
|
|
|
53
51
|
return results;
|
|
54
52
|
}
|
|
55
53
|
// ── Timeline ──────────────────────────────────────────────────────────
|
|
54
|
+
/** Return the complete canonical event stream for a loop.
|
|
55
|
+
*
|
|
56
|
+
* Unlike the legacy round summary below, this view preserves every event
|
|
57
|
+
* (round events, gates, retries and lineage) and its event_sequence so callers
|
|
58
|
+
* can paginate and replay the durable source of truth deterministically.
|
|
59
|
+
*/
|
|
60
|
+
eventTimeline(loopId) {
|
|
61
|
+
const entries = this.backend.queryLoopEvents(loopId);
|
|
62
|
+
const seen = new Set();
|
|
63
|
+
return entries
|
|
64
|
+
.filter((entry) => {
|
|
65
|
+
const key = `${entry.task_id ?? entry.id ?? ""}:${entry.event_sequence ?? ""}`;
|
|
66
|
+
if (seen.has(key))
|
|
67
|
+
return false;
|
|
68
|
+
seen.add(key);
|
|
69
|
+
const taskId = String(entry.task_id ?? "");
|
|
70
|
+
return entry.loop_id === loopId ||
|
|
71
|
+
(entry.loop_id === undefined &&
|
|
72
|
+
(taskId === `loop:${loopId}` || taskId.startsWith(`loop:${loopId}:`)));
|
|
73
|
+
})
|
|
74
|
+
.sort((left, right) => {
|
|
75
|
+
const leftSequence = left.event_sequence;
|
|
76
|
+
const rightSequence = right.event_sequence;
|
|
77
|
+
if (typeof leftSequence === "number" && typeof rightSequence === "number" && leftSequence !== rightSequence) {
|
|
78
|
+
return leftSequence - rightSequence;
|
|
79
|
+
}
|
|
80
|
+
const leftRound = typeof left.loop_lineage?.round === "number" ? left.loop_lineage.round : 0;
|
|
81
|
+
const rightRound = typeof right.loop_lineage?.round === "number" ? right.loop_lineage.round : 0;
|
|
82
|
+
if (leftRound !== rightRound)
|
|
83
|
+
return leftRound - rightRound;
|
|
84
|
+
return String(left.task_id ?? left.id ?? "").localeCompare(String(right.task_id ?? right.id ?? ""));
|
|
85
|
+
})
|
|
86
|
+
.map((entry) => ({
|
|
87
|
+
...entry,
|
|
88
|
+
round: typeof entry.loop_lineage?.round === "number" ? entry.loop_lineage.round : 0,
|
|
89
|
+
eventType: entry.task_type ?? "event",
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
56
92
|
timeline(loopId) {
|
|
57
93
|
const entries = this.replay(loopId);
|
|
58
94
|
const timeline = [];
|
|
@@ -72,7 +108,8 @@ export class ReplayBackend {
|
|
|
72
108
|
// ── Helpers ─────────────────────────────────────────────────────────────
|
|
73
109
|
maxRound(loopId) {
|
|
74
110
|
const prefix = `loop:${loopId}:r`;
|
|
75
|
-
const entries = this.backend.
|
|
111
|
+
const entries = this.backend.queryLoopEvents(loopId)
|
|
112
|
+
.filter((entry) => String(entry.task_id ?? "").startsWith(prefix));
|
|
76
113
|
let maxR = 0;
|
|
77
114
|
for (const e of entries) {
|
|
78
115
|
const lineage = (e.loop_lineage ?? {});
|
package/dist/replay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAM,OAAO,aAAa;IACP,OAAO,CAAY;IAEpC,YAAY,OAAkB;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,0EAA0E;IAE1E,QAAQ,CAAC,MAAc,EAAE,QAAgB;QACvC,MAAM,MAAM,GAAG,QA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ACxB,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAA4B,CAAC;YAClE,MAAM,GAAG,GAAG,OAAO,CAAC,KAAe,CAAC;YACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,IAAI;gBAAE,IAAI,GAAG,GAAG,CAAC;QACxD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VaultEntry } from "./vault-types.js";
|
|
2
|
+
import type { LoopStore } from "./loop-store.js";
|
|
3
|
+
export interface RoundCommitStore {
|
|
4
|
+
find(loopId: string, round: number): VaultEntry[];
|
|
5
|
+
}
|
|
6
|
+
/** Backend-specific lookup kept outside storage/session orchestration. */
|
|
7
|
+
export declare class VaultRoundCommitStore implements RoundCommitStore {
|
|
8
|
+
private readonly backend;
|
|
9
|
+
constructor(backend: LoopStore);
|
|
10
|
+
find(loopId: string, round: number): VaultEntry[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=round-commit-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round-commit-store.d.ts","sourceRoot":"","sources":["../src/round-commit-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAAC;CACnD;AAED,0EAA0E;AAC1E,qBAAa,qBAAsB,YAAW,gBAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,SAAS;IAE/C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE;CAKlD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Backend-specific lookup kept outside storage/session orchestration. */
|
|
2
|
+
export class VaultRoundCommitStore {
|
|
3
|
+
backend;
|
|
4
|
+
constructor(backend) {
|
|
5
|
+
this.backend = backend;
|
|
6
|
+
}
|
|
7
|
+
find(loopId, round) {
|
|
8
|
+
const prefix = `loop:${loopId}:r${round}:event`;
|
|
9
|
+
return this.backend.queryLoopEvents(loopId)
|
|
10
|
+
.filter((entry) => entry.task_id === prefix);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=round-commit-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round-commit-store.js","sourceRoot":"","sources":["../src/round-commit-store.ts"],"names":[],"mappings":"AAOA,0EAA0E;AAC1E,MAAM,OAAO,qBAAqB;IACH;IAA7B,YAA6B,OAAkB;QAAlB,YAAO,GAAP,OAAO,CAAW;IAAG,CAAC;IAEnD,IAAI,CAAC,MAAc,EAAE,KAAa;QAChC,MAAM,MAAM,GAAG,QAAQ,MAAM,KAAK,KAAK,QAAQ,CAAC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC;aACxC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* verify → enforce → stop decision
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* paths (e.g. git verification only wired into one side) was a known
|
|
11
|
-
* risk. The RoundCoordinator is the single source of truth.
|
|
8
|
+
* The RoundCoordinator is the single source of truth for this pipeline;
|
|
9
|
+
* transport adapters only prepare input and route the resulting decision.
|
|
12
10
|
*
|
|
13
11
|
* State transitions:
|
|
14
12
|
* RoundStarted → EvidenceCaptured → EvaluationSubmitted
|
|
@@ -17,43 +15,61 @@
|
|
|
17
15
|
* Persistence is owned by round-transaction.ts so reject paths remain
|
|
18
16
|
* side-effect free and accepted decisions can be replayed idempotently.
|
|
19
17
|
*/
|
|
20
|
-
import type {
|
|
18
|
+
import type { LoopStore } from "./loop-store.js";
|
|
21
19
|
import type { ProviderSnapshot } from "./evidence-provider.js";
|
|
22
|
-
import type {
|
|
20
|
+
import type { CompilerRoundProjection, RoundReport, StopReason, VerificationFlag } from "./protocol.js";
|
|
23
21
|
/** Input to a single round processing step. */
|
|
24
22
|
export interface RoundProcessInput {
|
|
25
23
|
loopId: string;
|
|
26
24
|
task: string;
|
|
27
25
|
currentRound: number;
|
|
28
26
|
maxRounds: number;
|
|
29
|
-
/** The
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
/** The previous round's validated SelfEvaluation (null for round 1). */
|
|
34
|
-
lastSelfEval?: SelfEvaluation;
|
|
27
|
+
/** The normalized Agent report for this round. */
|
|
28
|
+
roundReport: RoundReport;
|
|
29
|
+
/** Previous accepted compiler projection (null for round 1). */
|
|
30
|
+
previousProjection?: CompilerRoundProjection;
|
|
35
31
|
/** How many consecutive rounds have been rejected by enforcement. */
|
|
36
32
|
consecutiveRejections: number;
|
|
37
33
|
/** v1.18: Evidence snapshots from configured providers. */
|
|
38
34
|
evidenceSnapshots?: ProviderSnapshot[];
|
|
39
35
|
/** Success values from already committed rounds. */
|
|
40
36
|
successTrajectory?: boolean[];
|
|
37
|
+
/** v2.13: Files from skipped backtrack rounds. Passed to verification
|
|
38
|
+
* gate for post-backtrack workspace restore check. */
|
|
39
|
+
backtrackSkippedFiles?: string[];
|
|
40
|
+
/** v2.13: Git HEAD of the active backtrack restore point. Passed to the
|
|
41
|
+
* verification gate; the post-backtrack round must match it. */
|
|
42
|
+
backtrackTargetGitHead?: string;
|
|
43
|
+
/** Runtime-derived action from the prompt being completed. */
|
|
44
|
+
expectedAction?: string;
|
|
45
|
+
/** Terminal enforcement checks that already consumed their guided retry. */
|
|
46
|
+
escalatedRejectionChecks?: string[];
|
|
47
|
+
/** Criteria still open when the report was compiled. */
|
|
48
|
+
remainingCriteria?: string[];
|
|
41
49
|
}
|
|
42
50
|
/** Result of processing a round through the coordinator. */
|
|
43
51
|
export interface RoundProcessResult {
|
|
44
52
|
/** What the caller should do next. */
|
|
45
|
-
action: "continue" | "stop" | "reject" | "terminate";
|
|
53
|
+
action: "continue" | "stop" | "reject" | "terminate" | "backtrack";
|
|
46
54
|
/** Reason for stop (set when action is "stop" or "terminate"). */
|
|
47
55
|
stopReason?: StopReason;
|
|
48
56
|
/** Rejection prompt (set when action is "reject"). */
|
|
49
57
|
rejectionPrompt?: string;
|
|
58
|
+
/** v2.10: Backtrack prompt (set when action is "backtrack"). */
|
|
59
|
+
backtrackPrompt?: string;
|
|
60
|
+
/** v2.10: Round to restore state from (set when action is "backtrack"). */
|
|
61
|
+
backtrackTarget?: number;
|
|
62
|
+
/** v2.10: Discovered constraints from skipped rounds to preserve. */
|
|
63
|
+
backtrackSkippedDiscoveries?: string[];
|
|
64
|
+
/** v2.10: Which enforcement rule triggered the backtrack. */
|
|
65
|
+
backtrackTriggerRule?: string;
|
|
50
66
|
/** Verification flags from this round (for injection into next prompt). */
|
|
51
67
|
verificationFlags: VerificationFlag[];
|
|
52
68
|
/** Enforcement action for observability. */
|
|
53
|
-
enforcementAction?: "accept" | "reject" | "terminate";
|
|
69
|
+
enforcementAction?: "accept" | "reject" | "terminate" | "backtrack";
|
|
54
70
|
/** Enforcement reason (set when rejected or terminated). */
|
|
55
71
|
enforcementReason?: string;
|
|
56
|
-
/** Whether this round was successful
|
|
72
|
+
/** Whether this round was successful according to the canonical report. */
|
|
57
73
|
roundSuccess: boolean;
|
|
58
74
|
/** Whether the verification gate returned "contradicted". */
|
|
59
75
|
gateContradicted: boolean;
|
|
@@ -62,17 +78,30 @@ export interface RoundProcessResult {
|
|
|
62
78
|
/** Which enforcement check fired (set when action is "reject" or "terminate").
|
|
63
79
|
* Used by callers to track per-rule rejection counters. */
|
|
64
80
|
rejectionCheck?: string;
|
|
65
|
-
/** The
|
|
81
|
+
/** The compiler view to store as lastRoundView for the next round
|
|
66
82
|
* (undefined when action is "reject" — caller should NOT update). */
|
|
67
|
-
|
|
83
|
+
newRoundProjection?: CompilerRoundProjection;
|
|
68
84
|
/** Whether the caller should push roundSuccess onto the success trajectory.
|
|
69
85
|
* false when gateContradicted or when action is "reject". */
|
|
70
86
|
shouldPushSuccessTrajectory: boolean;
|
|
87
|
+
/** v2.12: True when this round's intent_drift was waived via substantive
|
|
88
|
+
* drift_clarification. The caller uses this to track clarification streaks. */
|
|
89
|
+
clarificationAccepted?: boolean;
|
|
90
|
+
/** True when a terminal enforcement rule was converted into one final reject. */
|
|
91
|
+
escalationIssued?: boolean;
|
|
92
|
+
/** v2.13: Git HEAD commit hash of the backtrack target round.
|
|
93
|
+
* Set when action is "backtrack". The verification gate uses this
|
|
94
|
+
* to check that the agent restored the workspace before working. */
|
|
95
|
+
backtrackTargetGitHead?: string;
|
|
96
|
+
/** v2.13: Files changed in skipped rounds during backtrack.
|
|
97
|
+
* The next round's verification gate checks that these files are
|
|
98
|
+
* not still dirty (agent must restore workspace first). */
|
|
99
|
+
backtrackSkippedFiles?: string[];
|
|
71
100
|
}
|
|
72
101
|
export declare class RoundCoordinator {
|
|
73
102
|
private backend;
|
|
74
|
-
constructor(backend?:
|
|
75
|
-
/** Process a single round's
|
|
103
|
+
constructor(backend?: LoopStore);
|
|
104
|
+
/** Process a single round's round report through the decision pipeline:
|
|
76
105
|
* verify → enforce → stop decision.
|
|
77
106
|
*
|
|
78
107
|
* This is the single entry point called by SessionManager.
|
|
@@ -80,9 +109,11 @@ export declare class RoundCoordinator {
|
|
|
80
109
|
* - Compiling the next prompt (if action is "continue")
|
|
81
110
|
* - Managing heartbeat / signal handlers (runtime only)
|
|
82
111
|
* - Memory injection (both paths, before calling processRound)
|
|
83
|
-
* - Transactional
|
|
112
|
+
* - Transactional round-event commit (accepted rounds only)
|
|
84
113
|
* - State file I/O (both paths, after compiling)
|
|
85
|
-
|
|
86
|
-
|
|
114
|
+
*
|
|
115
|
+
* @param driftClarificationStreak v2.12: Current clarification streak
|
|
116
|
+
* from session state. Passed through to enforceRound for R7 escalation. */
|
|
117
|
+
processRound(input: RoundProcessInput, driftClarificationStreak?: number): RoundProcessResult;
|
|
87
118
|
}
|
|
88
119
|
//# 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
|
|
1
|
+
{"version":3,"file":"round-coordinator.d.ts","sourceRoot":"","sources":["../src/round-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EACV,uBAAuB,EAEvB,WAAW,EACX,UAAU,EACV,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAiBvB,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,WAAW,EAAE,WAAW,CAAC;IACzB,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,uBAAuB,CAAC;IAC7C,qEAAqE;IACrE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,OAAO,EAAE,CAAC;IAC9B;2DACuD;IACvD,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC;qEACiE;IACjE,sBAAsB,CAAC,EAAE,MAA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