@linzumi/cli 1.0.272 → 1.0.273
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 +1 -1
- package/dist/impl-res/cloud-supervisor.mjs +69 -69
- package/dist/impl-res/index.js +353 -312
- package/dist/impl-res/mcp-server.mjs +34 -34
- package/dist/impl-ts/cloud-supervisor.mjs +69 -69
- package/dist/impl-ts/index.js +488 -488
- package/dist/impl-ts/mcp-server.mjs +1 -1
- package/dist/mcp-server.mjs +1 -1
- package/package.json +3 -2
- package/scripts/build-auth-parity-oracle.mjs +0 -709
- package/scripts/build-canonical-codex-transpiler-oracle.mjs +0 -93
- package/scripts/build-config-identity-parity-oracle.mjs +0 -526
- package/scripts/build-core-commander-seams-parity-oracle.mjs +0 -799
- package/scripts/build-core-daemon-parity-oracle.mjs +0 -573
- package/scripts/build-core-dispatch-input-queue-parity-oracle.mjs +0 -225
- package/scripts/build-core-fate-ladder-parity-oracle.mjs +0 -350
- package/scripts/build-core-generation-overlap-parity-oracle.mjs +0 -292
- package/scripts/build-core-integration-parity-oracle.mjs +0 -453
- package/scripts/build-core-lifecycle-guards-parity-oracle.mjs +0 -443
- package/scripts/build-core-lock-parity-oracle.mjs +0 -462
- package/scripts/build-core-reconnect-resume-parity-oracle.mjs +0 -365
- package/scripts/build-core-startup-resume-scan-parity-oracle.mjs +0 -296
- package/scripts/build-core-supervisor-parity-oracle.mjs +0 -781
- package/scripts/build-cross-harness-failover-oracle.mjs +0 -349
- package/scripts/build-editor-parity-oracle.mjs +0 -1525
- package/scripts/build-forwarding-parity-oracle.mjs +0 -1390
- package/scripts/build-harness-claude-parity-oracle.mjs +0 -407
- package/scripts/build-harness-codex-parity-oracle.mjs +0 -479
- package/scripts/build-mcp-parity-oracle.mjs +0 -412
- package/scripts/build-mcp-selector-parity-oracle.mjs +0 -65
- package/scripts/build-onboarding-discovery-parity-oracle.mjs +0 -388
- package/scripts/build-onboarding-flow-parity-oracle.mjs +0 -562
- package/scripts/build-onboarding-gateway-parity-oracle.mjs +0 -313
- package/scripts/build-onboarding-support-parity-oracle.mjs +0 -519
- package/scripts/build-pipeline-parity-oracle.mjs +0 -614
- package/scripts/build-protocol-parity-oracle.mjs +0 -398
- package/scripts/build-queue-parity-oracle.mjs +0 -1012
- package/scripts/build-session-registry-parity-oracle.mjs +0 -582
- package/scripts/build-transport-parity-oracle.mjs +0 -694
- package/scripts/build-tui-parity-oracle.mjs +0 -577
- package/scripts/build-vm-sandbox-parity-oracle.mjs +0 -1281
- package/scripts/build-worker-entry-parity-oracle.mjs +0 -424
- package/scripts/build-worker-spawn-parity-oracle.mjs +0 -823
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
// Spec: kandan/plans/2026-07-10-compute-nodes-rescript-commander-zero-ts-program.md
|
|
2
|
-
// (M3 cluster 10, runner core).
|
|
3
|
-
// Relationship: Builds the TS-side PARITY ORACLE for the pipeline
|
|
4
|
-
// INTEGRATION module of the ReScript commander port, the sibling of
|
|
5
|
-
// build-pipeline-parity-oracle.mjs (cluster 9) and
|
|
6
|
-
// build-queue-parity-oracle.mjs (cluster 5). The oracle bundles the REAL
|
|
7
|
-
// TS pipeline integration module (src/pipeline/integration.ts - the
|
|
8
|
-
// per-session loop + outbox lifecycle, the outbox entry builders, and the
|
|
9
|
-
// completion-snapshot resolution helpers) plus the real phoenix push-error
|
|
10
|
-
// factory and the turnTrace per-thread traceparent registry, behind the
|
|
11
|
-
// cluster 1/2 one-shot BATCH driver (a JSON array of cases on stdin, a
|
|
12
|
-
// JSON array of results on stdout).
|
|
13
|
-
//
|
|
14
|
-
// Byte parity: builder results and snapshot-helper outputs are returned
|
|
15
|
-
// VERBATIM (the TS object literals' own key order rides JSON.stringify),
|
|
16
|
-
// and scripted SESSION runs return their full event trace - pushes with
|
|
17
|
-
// complete payloads, acks/failures, snapshot resolutions, terminal
|
|
18
|
-
// callbacks, log events, flushes, metrics counters, close - so the
|
|
19
|
-
// ReScript side must reproduce field presence AND insertion order exactly.
|
|
20
|
-
// Determinism: hosts are fully scripted (push outcomes, snapshot outcomes,
|
|
21
|
-
// wire contexts, envelope shapes, recovered turns, runtime metadata);
|
|
22
|
-
// retry cadences are configured to millisecond-scale delays so the traces
|
|
23
|
-
// pin the LOGGED delay values while real time stays tiny; the stats
|
|
24
|
-
// interval is disabled (0) in session runs; traces capture only
|
|
25
|
-
// deterministic metric counters (never wall-clock ages).
|
|
26
|
-
//
|
|
27
|
-
// SECRETS: the oracle only ever sees the conformance suite's synthetic
|
|
28
|
-
// payloads. The output is a local test artifact (.differential/ is
|
|
29
|
-
// gitignored, never published) and stays unminified for debuggability.
|
|
30
|
-
import { mkdir } from 'node:fs/promises';
|
|
31
|
-
import { dirname, join } from 'node:path';
|
|
32
|
-
import { fileURLToPath } from 'node:url';
|
|
33
|
-
import { build } from 'esbuild';
|
|
34
|
-
|
|
35
|
-
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
36
|
-
|
|
37
|
-
const driverSource = `
|
|
38
|
-
import {
|
|
39
|
-
createSessionPipeline,
|
|
40
|
-
createSessionPipelineBuilders,
|
|
41
|
-
defaultOutboxMaxInFlightPushes,
|
|
42
|
-
isConnectionLostPushError,
|
|
43
|
-
isConnectionWaitPushError,
|
|
44
|
-
mergeSnapshotItems,
|
|
45
|
-
preReduceSnapshotItems,
|
|
46
|
-
rawSnapshotItemsForTurn,
|
|
47
|
-
} from './src/pipeline/integration';
|
|
48
|
-
import { outboxEntryKinds, adoptAdtStreamBinding } from './src/pipeline/contracts';
|
|
49
|
-
import { phoenixPushErrors } from './src/phoenix';
|
|
50
|
-
import {
|
|
51
|
-
rememberTurnTraceparent,
|
|
52
|
-
__resetTurnTraceparentsForTest,
|
|
53
|
-
} from './src/turnTrace';
|
|
54
|
-
|
|
55
|
-
function sleep(ms) {
|
|
56
|
-
return new Promise((resolve) => {
|
|
57
|
-
setTimeout(resolve, ms);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// The scripted row-command envelope shared with the ReScript conformance
|
|
62
|
-
// side (both implement this exact shape over the same case JSON, so the
|
|
63
|
-
// seam itself is identical while the builder's spread/override semantics
|
|
64
|
-
// around it are what the comparison pins).
|
|
65
|
-
function scriptedEnvelope(caseInput) {
|
|
66
|
-
return (eventType, sessionId, sourceMessageSeq, extraMetadata) => ({
|
|
67
|
-
...(caseInput.envelopeBase ?? {}),
|
|
68
|
-
type: eventType,
|
|
69
|
-
thread: sessionId,
|
|
70
|
-
...(sourceMessageSeq === undefined ? {} : { envelope_seq: sourceMessageSeq }),
|
|
71
|
-
...(extraMetadata === undefined ? {} : { local_runner_metadata: extraMetadata }),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function wireOf(spec) {
|
|
76
|
-
return {
|
|
77
|
-
workspaceSlug: spec.workspaceSlug,
|
|
78
|
-
channelSlug: spec.channelSlug,
|
|
79
|
-
kandanThreadId: spec.threadId ?? undefined,
|
|
80
|
-
codexThreadId: spec.harnessSessionId ?? undefined,
|
|
81
|
-
rootSeq: spec.rootSeq ?? undefined,
|
|
82
|
-
...(spec.leaseEpoch === undefined ? {} : { leaseEpoch: spec.leaseEpoch }),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function seedTraceparents(caseInput) {
|
|
87
|
-
__resetTurnTraceparentsForTest();
|
|
88
|
-
for (const entry of caseInput.traceparents ?? []) {
|
|
89
|
-
rememberTurnTraceparent(entry.threadId, entry.traceparent);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function runBuildersCase(caseInput) {
|
|
94
|
-
seedTraceparents(caseInput);
|
|
95
|
-
const recovered = new Set(caseInput.recoveredTurns ?? []);
|
|
96
|
-
const wires = (caseInput.wires ?? []).map(wireOf);
|
|
97
|
-
let wireIndex = 0;
|
|
98
|
-
const builders = createSessionPipelineBuilders({
|
|
99
|
-
instanceId: caseInput.instanceId ?? 'instance-parity',
|
|
100
|
-
wire: () => wires[wireIndex],
|
|
101
|
-
runnerPayload: scriptedEnvelope(caseInput),
|
|
102
|
-
isRecoveredTurn: (turnId) => recovered.has(turnId),
|
|
103
|
-
// Spec: spec/sandbox-denial-surfacing.md (:sandbox-denial/rule-08): the
|
|
104
|
-
// per-host classification opt-in, driven from the case JSON so the
|
|
105
|
-
// ReScript conformance side pins the annotated bytes differentially.
|
|
106
|
-
...(caseInput.sandboxNetworkDenialSurfacing === true
|
|
107
|
-
? { sandboxNetworkDenialSurfacing: true }
|
|
108
|
-
: {}),
|
|
109
|
-
});
|
|
110
|
-
const context = {
|
|
111
|
-
remember: () => {},
|
|
112
|
-
recall: () => undefined,
|
|
113
|
-
};
|
|
114
|
-
return {
|
|
115
|
-
results: (caseInput.calls ?? []).map((call) => {
|
|
116
|
-
wireIndex = call.wireIndex ?? 0;
|
|
117
|
-
const builder = builders[call.kind];
|
|
118
|
-
if (builder === undefined) {
|
|
119
|
-
return { missingBuilder: true };
|
|
120
|
-
}
|
|
121
|
-
return builder.build(call.data ?? {}, context);
|
|
122
|
-
}),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function scriptedFailure(spec) {
|
|
127
|
-
switch (spec.factory) {
|
|
128
|
-
case 'socketClosed':
|
|
129
|
-
return phoenixPushErrors.socketClosed();
|
|
130
|
-
case 'reconnectFailed':
|
|
131
|
-
return phoenixPushErrors.reconnectFailed();
|
|
132
|
-
case 'socketNotOpen':
|
|
133
|
-
return phoenixPushErrors.socketNotOpen();
|
|
134
|
-
case 'clientClosedWait':
|
|
135
|
-
return phoenixPushErrors.clientClosed('wait_for_connection');
|
|
136
|
-
case 'clientClosedReply':
|
|
137
|
-
return phoenixPushErrors.clientClosed('reply');
|
|
138
|
-
case 'notConnected':
|
|
139
|
-
return phoenixPushErrors.notConnected();
|
|
140
|
-
case 'connectionWaitTimeout':
|
|
141
|
-
return phoenixPushErrors.connectionWaitTimeout(spec.timeoutMs ?? 5, spec.event ?? 'evt');
|
|
142
|
-
case 'replyTimeout':
|
|
143
|
-
return phoenixPushErrors.replyTimeout(spec.timeoutMs ?? 5, spec.event ?? 'evt');
|
|
144
|
-
default:
|
|
145
|
-
return new Error(spec.message ?? 'scripted push failure');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function runClassifierCase(caseInput) {
|
|
150
|
-
const failure = scriptedFailure(caseInput.failure ?? {});
|
|
151
|
-
return {
|
|
152
|
-
lost: isConnectionLostPushError(failure),
|
|
153
|
-
wait: isConnectionWaitPushError(failure),
|
|
154
|
-
message: failure.message,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async function runSessionCase(caseInput) {
|
|
159
|
-
seedTraceparents(caseInput);
|
|
160
|
-
const trace = [];
|
|
161
|
-
const recovered = new Set(caseInput.recoveredTurns ?? []);
|
|
162
|
-
const wires = (caseInput.wires ?? []).map(wireOf);
|
|
163
|
-
let wireIndex = 0;
|
|
164
|
-
const turnSeqs = new Map();
|
|
165
|
-
const retryAttempts = new Map();
|
|
166
|
-
const resumeAttempts = new Map();
|
|
167
|
-
const ladders = new Map();
|
|
168
|
-
const runtimeMetadata = new Map();
|
|
169
|
-
for (const entry of caseInput.runtimeMetadata ?? []) {
|
|
170
|
-
runtimeMetadata.set(entry.seq, entry.metadata);
|
|
171
|
-
}
|
|
172
|
-
const pushScript = [...(caseInput.pushScript ?? [])];
|
|
173
|
-
const snapshotScript = new Map();
|
|
174
|
-
for (const entry of caseInput.snapshotScript ?? []) {
|
|
175
|
-
const queue = snapshotScript.get(entry.turnId) ?? [];
|
|
176
|
-
queue.push(entry);
|
|
177
|
-
snapshotScript.set(entry.turnId, queue);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const pipeline = createSessionPipeline({
|
|
181
|
-
instanceId: caseInput.instanceId ?? 'instance-parity',
|
|
182
|
-
threadKey: caseInput.threadKey ?? 'thread-parity',
|
|
183
|
-
persistDir: undefined,
|
|
184
|
-
push: async (event, payload, _timeoutMs, onSent) => {
|
|
185
|
-
trace.push({ t: 'push', event, payload });
|
|
186
|
-
onSent?.();
|
|
187
|
-
const step = pushScript.shift() ?? { kind: 'ack' };
|
|
188
|
-
if (step.delayMs !== undefined) {
|
|
189
|
-
await sleep(step.delayMs);
|
|
190
|
-
}
|
|
191
|
-
if (step.kind === 'ack') {
|
|
192
|
-
trace.push({ t: 'ack' });
|
|
193
|
-
return step.reply ?? { ok: true };
|
|
194
|
-
}
|
|
195
|
-
trace.push({ t: 'pushFail', mode: step.mode ?? 'plain' });
|
|
196
|
-
if (step.mode === 'wait') {
|
|
197
|
-
throw phoenixPushErrors.connectionWaitTimeout(5, event);
|
|
198
|
-
}
|
|
199
|
-
if (step.mode === 'lost') {
|
|
200
|
-
throw phoenixPushErrors.socketClosed();
|
|
201
|
-
}
|
|
202
|
-
throw new Error(step.message ?? 'scripted push failure');
|
|
203
|
-
},
|
|
204
|
-
wire: () => wires[wireIndex],
|
|
205
|
-
runnerPayload: scriptedEnvelope(caseInput),
|
|
206
|
-
runtimeMetadataForSourceSeq: (seq) =>
|
|
207
|
-
seq === undefined ? undefined : runtimeMetadata.get(seq),
|
|
208
|
-
sourceSeqForTurn: (turnId) => turnSeqs.get(turnId),
|
|
209
|
-
autoRetryAttemptsForSeq: (seq) => retryAttempts.get(seq) ?? 0,
|
|
210
|
-
midStreamResumeAttemptAtMsForSeq: (seq) => resumeAttempts.get(seq),
|
|
211
|
-
ladderHistoryForSeq: (seq, fate) => ladders.get(seq + ':' + fate),
|
|
212
|
-
isRecoveredTurn: (turnId) => recovered.has(turnId),
|
|
213
|
-
resolveSnapshot: async (turnId) => {
|
|
214
|
-
const queue = snapshotScript.get(turnId) ?? [];
|
|
215
|
-
const step = queue.shift() ?? { ok: true, items: [] };
|
|
216
|
-
trace.push({ t: 'resolveSnapshot', turnId, ok: step.ok === true });
|
|
217
|
-
if (step.delayMs !== undefined) {
|
|
218
|
-
await sleep(step.delayMs);
|
|
219
|
-
}
|
|
220
|
-
if (step.ok === true) {
|
|
221
|
-
return { items: step.items ?? [] };
|
|
222
|
-
}
|
|
223
|
-
throw new Error(step.message ?? 'scripted snapshot failure');
|
|
224
|
-
},
|
|
225
|
-
onTurnTerminal: (
|
|
226
|
-
turnId,
|
|
227
|
-
outcome,
|
|
228
|
-
reason,
|
|
229
|
-
retryableEmptyTurn,
|
|
230
|
-
autoResume,
|
|
231
|
-
fate,
|
|
232
|
-
freshSessionResume
|
|
233
|
-
) => {
|
|
234
|
-
trace.push({
|
|
235
|
-
t: 'terminal',
|
|
236
|
-
turnId,
|
|
237
|
-
outcome,
|
|
238
|
-
reason: reason ?? null,
|
|
239
|
-
retryableEmptyTurn: retryableEmptyTurn === true,
|
|
240
|
-
autoResumeMidStreamStall: autoResume === true,
|
|
241
|
-
// #3455 leg 4 (Greptile P2): the second-stall fresh-session flag is
|
|
242
|
-
// part of the compared terminal surface, so a future divergence in
|
|
243
|
-
// the ReScript reducer goes red here, not just in the TS e2e tests.
|
|
244
|
-
freshSessionResumeMidStreamStall: freshSessionResume === true,
|
|
245
|
-
fate: fate ?? null,
|
|
246
|
-
});
|
|
247
|
-
},
|
|
248
|
-
log: (event, fields) => {
|
|
249
|
-
trace.push({ t: 'log', event, fields });
|
|
250
|
-
},
|
|
251
|
-
linzumiAgentSession: caseInput.linzumiAgentSession === true,
|
|
252
|
-
outboxRetryDelaysMs: caseInput.outboxRetryDelaysMs ?? [1, 2],
|
|
253
|
-
outboxMaxInFlightPushes: caseInput.maxInFlightPushes ?? 1,
|
|
254
|
-
snapshotRetryDelaysMs: caseInput.snapshotRetryDelaysMs ?? undefined,
|
|
255
|
-
// Determinism: the periodic stats interval is disabled; the reporter
|
|
256
|
-
// still stops on close in the same order as production.
|
|
257
|
-
statsIntervalMs: 0,
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
for (const op of caseInput.ops ?? []) {
|
|
261
|
-
if (op.op === 'submit') pipeline.submitNotification(op.method, op.params ?? undefined);
|
|
262
|
-
else if (op.op === 'mapTurn') turnSeqs.set(op.turnId, op.seq);
|
|
263
|
-
else if (op.op === 'retryAttempts') retryAttempts.set(op.seq, op.attempts);
|
|
264
|
-
else if (op.op === 'resumeAttemptAt') resumeAttempts.set(op.seq, op.atMs);
|
|
265
|
-
else if (op.op === 'ladder') ladders.set(op.seq + ':' + op.fate, op.ladder);
|
|
266
|
-
else if (op.op === 'recover') recovered.add(op.turnId);
|
|
267
|
-
else if (op.op === 'notifyReady') pipeline.notifyTurnMappingReady(op.turnId);
|
|
268
|
-
else if (op.op === 'notifyFailed') pipeline.notifyTurnMappingFailed(op.turnId, op.reason);
|
|
269
|
-
else if (op.op === 'noteActivity') pipeline.noteTurnActivity(op.turnId, op.kind);
|
|
270
|
-
else if (op.op === 'lifecycle') pipeline.submitLifecycle(op.kind, op.reason);
|
|
271
|
-
else if (op.op === 'pause') pipeline.pause();
|
|
272
|
-
else if (op.op === 'resume') pipeline.resume();
|
|
273
|
-
else if (op.op === 'rebind') pipeline.rebindThreadKey(op.threadKey);
|
|
274
|
-
else if (op.op === 'setWire') wireIndex = op.index;
|
|
275
|
-
else if (op.op === 'sleep') await sleep(op.ms);
|
|
276
|
-
else if (op.op === 'metrics') {
|
|
277
|
-
const metrics = pipeline.metrics();
|
|
278
|
-
trace.push({
|
|
279
|
-
t: 'metrics',
|
|
280
|
-
value: {
|
|
281
|
-
depth: metrics.depth,
|
|
282
|
-
totalEnqueued: metrics.totalEnqueued,
|
|
283
|
-
totalAcked: metrics.totalAcked,
|
|
284
|
-
totalRetried: metrics.totalRetried,
|
|
285
|
-
totalDroppedBestEffort: metrics.totalDroppedBestEffort,
|
|
286
|
-
totalPermanentFailures: metrics.totalPermanentFailures,
|
|
287
|
-
paused: metrics.paused,
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
} else if (op.op === 'flush') {
|
|
291
|
-
try {
|
|
292
|
-
await pipeline.flushOutbox(op.timeoutMs ?? undefined);
|
|
293
|
-
trace.push({ t: 'flushed', ok: true });
|
|
294
|
-
} catch (error) {
|
|
295
|
-
trace.push({
|
|
296
|
-
t: 'flushed',
|
|
297
|
-
ok: false,
|
|
298
|
-
message: error instanceof Error ? error.message : String(error),
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
} else if (op.op === 'close') {
|
|
302
|
-
await pipeline.close(op.timeoutMs ?? undefined);
|
|
303
|
-
trace.push({ t: 'closed' });
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return { trace };
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Spec: spec/adt-final-answer-identity-rules.md, rules 1–3.
|
|
310
|
-
// Actual producer/outbox boundary; assertions remain in the ReScript owner.
|
|
311
|
-
async function runFinalCheckpointIdentity(input) {
|
|
312
|
-
const adoption = adoptAdtStreamBinding({session_id: 3600, lease_epoch: 1, next_frame_index: 37,
|
|
313
|
-
checkpoint_config: {version: 3, thresholds: {max_bytes: 1, max_deltas: 1, max_interval_ms: 2000}}}, 44, Date.now());
|
|
314
|
-
if (adoption.kind !== 'accepted') throw new Error('fixture_adoption_refused');
|
|
315
|
-
const pushes = [];
|
|
316
|
-
const logs = [];
|
|
317
|
-
let finishProvider;
|
|
318
|
-
const providerTerminal = new Promise(resolve => {finishProvider = resolve;});
|
|
319
|
-
const pipeline = createSessionPipeline({
|
|
320
|
-
instanceId: 'synthetic-yc-identity', threadKey: 'synthetic-final-identity', persistDir: undefined,
|
|
321
|
-
messageStateReplyShape: {kind: 'inner_response'},
|
|
322
|
-
wire: () => ({workspaceSlug: 'fixture', channelSlug: 'office', kandanThreadId: 'fixture-thread',
|
|
323
|
-
codexThreadId: 'fixture-provider-thread', rootSeq: 1}),
|
|
324
|
-
runnerPayload: (eventType, codexThreadId, sourceSeq, extra) => ({metadata: {local_codex_runner: {
|
|
325
|
-
...extra, event_type: eventType, codex_thread_id: codexThreadId, source_message_seq: sourceSeq,
|
|
326
|
-
}}}),
|
|
327
|
-
sourceSeqForTurn: () => 44,
|
|
328
|
-
adtAuthorityForSourceSeq: seq => seq === 44 ? adoption.session : undefined,
|
|
329
|
-
resolveSnapshot: async () => ({items: mergeSnapshotItems(input.readItems, input.sessionItems)}),
|
|
330
|
-
onTurnTerminal: () => finishProvider(),
|
|
331
|
-
log: (event, fields) => logs.push({event, fields}), statsIntervalMs: 0,
|
|
332
|
-
push: async (event, payload) => {
|
|
333
|
-
pushes.push({event, payload});
|
|
334
|
-
if (event === 'terminal_attempt') return {terminal_attempt: {
|
|
335
|
-
frame: {accepted: true}, message_state: {disposition: 'applied', thread_id: 'fixture-thread', source_seq: 44},
|
|
336
|
-
}};
|
|
337
|
-
return {seq: pushes.length, accepted: true};
|
|
338
|
-
},
|
|
339
|
-
});
|
|
340
|
-
try {
|
|
341
|
-
pipeline.submitNotification('item/agentMessage/delta', {threadId: 'fixture-provider-thread',
|
|
342
|
-
turnId: 'fixture-turn', itemId: 'msg-live-final', delta: input.body});
|
|
343
|
-
pipeline.submitNotification('item/completed', {threadId: 'fixture-provider-thread', turnId: 'fixture-turn',
|
|
344
|
-
item: {id: 'msg-live-final', type: 'agentMessage', text: input.body, phase: 'final_answer'}});
|
|
345
|
-
await pipeline.flushOutbox(1000);
|
|
346
|
-
pipeline.submitNotification('turn/completed', {threadId: 'fixture-provider-thread', turn: {id: 'fixture-turn'}});
|
|
347
|
-
await providerTerminal;
|
|
348
|
-
await pipeline.flushOutbox(1000);
|
|
349
|
-
const metrics = pipeline.metrics();
|
|
350
|
-
return {
|
|
351
|
-
standalone: pushes.filter(push => push.event === 'adt_frame').map(push => push.payload),
|
|
352
|
-
terminals: pushes.filter(push => push.event === 'terminal_attempt').map(push => push.payload.terminal_frame),
|
|
353
|
-
depth: metrics.depth, failures: metrics.totalPermanentFailures,
|
|
354
|
-
faults: logs.filter(log => /rejected|refused|failed/.test(log.event)),
|
|
355
|
-
};
|
|
356
|
-
} finally { await pipeline.close(1000); }
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
async function runCase(input) {
|
|
360
|
-
switch (input.kind) {
|
|
361
|
-
// Spec: spec/commander-recovery-rules.md authenticated terminal evidence.
|
|
362
|
-
case 'terminalRepairReceipt': {
|
|
363
|
-
const remembered = [];
|
|
364
|
-
const builder = createSessionPipelineBuilders({
|
|
365
|
-
instanceId: 'terminal-repair-fixture',
|
|
366
|
-
wire: () => ({workspaceSlug: 'synthetic', channelSlug: 'synthetic',
|
|
367
|
-
kandanThreadId: 'repair-thread', codexThreadId: 'provider-thread'}),
|
|
368
|
-
runnerPayload: () => ({}),
|
|
369
|
-
messageStateReplyShape: {kind: 'full_reply'},
|
|
370
|
-
log: () => {},
|
|
371
|
-
})['adt.terminal_attempt'];
|
|
372
|
-
const context = {remember: (key, value) => remembered.push({key, value}), recall: () => undefined};
|
|
373
|
-
const verdict = builder.replyPolicy.adjudicateReply(input.data, input.reply, context);
|
|
374
|
-
if (verdict.kind === 'accept') builder.onReply(input.data, input.reply, context);
|
|
375
|
-
return {accepted: verdict.kind === 'accept', remembered};
|
|
376
|
-
}
|
|
377
|
-
case 'constants':
|
|
378
|
-
return {
|
|
379
|
-
defaultOutboxMaxInFlightPushes,
|
|
380
|
-
outboxEntryKinds,
|
|
381
|
-
};
|
|
382
|
-
case 'builders':
|
|
383
|
-
return runBuildersCase(input);
|
|
384
|
-
case 'classifier':
|
|
385
|
-
return runClassifierCase(input);
|
|
386
|
-
case 'rawItems':
|
|
387
|
-
return rawSnapshotItemsForTurn(input.response, input.turnId);
|
|
388
|
-
case 'preReduce':
|
|
389
|
-
return preReduceSnapshotItems(input.items);
|
|
390
|
-
case 'merge':
|
|
391
|
-
return mergeSnapshotItems(input.readItems, input.sessionItems);
|
|
392
|
-
case 'sessionRun':
|
|
393
|
-
return runSessionCase(input);
|
|
394
|
-
case 'finalCheckpointIdentity':
|
|
395
|
-
return runFinalCheckpointIdentity(input);
|
|
396
|
-
default:
|
|
397
|
-
return { error: 'unknown case kind ' + String(input.kind) };
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
async function runBatch() {
|
|
402
|
-
const chunks = [];
|
|
403
|
-
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
404
|
-
const cases = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
405
|
-
const results = [];
|
|
406
|
-
for (const testCase of cases) {
|
|
407
|
-
results.push(await runCase(testCase));
|
|
408
|
-
}
|
|
409
|
-
process.stdout.write(JSON.stringify(results), () => {
|
|
410
|
-
process.exit(0);
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
runBatch().then(
|
|
415
|
-
() => {},
|
|
416
|
-
(error) => {
|
|
417
|
-
process.stderr.write(String(error && error.stack ? error.stack : error) + '\\n');
|
|
418
|
-
process.exit(1);
|
|
419
|
-
}
|
|
420
|
-
);
|
|
421
|
-
`;
|
|
422
|
-
|
|
423
|
-
const outDir = join(packageRoot, '.differential');
|
|
424
|
-
const outPath = join(outDir, 'core-integration-parity-oracle.mjs');
|
|
425
|
-
|
|
426
|
-
await mkdir(outDir, { recursive: true });
|
|
427
|
-
|
|
428
|
-
await build({
|
|
429
|
-
stdin: {
|
|
430
|
-
contents: driverSource,
|
|
431
|
-
resolveDir: packageRoot,
|
|
432
|
-
sourcefile: 'core-integration-parity-driver.ts',
|
|
433
|
-
loader: 'ts',
|
|
434
|
-
},
|
|
435
|
-
bundle: true,
|
|
436
|
-
// Spec: plans/2026-09-09-ts-native-account-continuation.md. Match the
|
|
437
|
-
// production/auth-oracle ESM bridge for reachable CJS runtime dependencies;
|
|
438
|
-
// the distinct banner binding cannot collide with bundled createRequire.
|
|
439
|
-
banner: {
|
|
440
|
-
js: "import { createRequire as __coreIntegrationOracleCreateRequire } from 'node:module';\nconst require = __coreIntegrationOracleCreateRequire(import.meta.url);",
|
|
441
|
-
},
|
|
442
|
-
platform: 'node',
|
|
443
|
-
target: 'node20',
|
|
444
|
-
format: 'esm',
|
|
445
|
-
outfile: outPath,
|
|
446
|
-
minify: false,
|
|
447
|
-
sourcemap: false,
|
|
448
|
-
legalComments: 'none',
|
|
449
|
-
logLevel: 'silent',
|
|
450
|
-
external: ['ws', 'undici', 'blessed', '@anthropic-ai/claude-agent-sdk'],
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
process.stdout.write(outPath + '\n');
|