Skip to content

Commit 6ac8d80

Browse files
authored
storage: retire legacy execution writer exports (#1744)
1 parent 2770730 commit 6ac8d80

20 files changed

Lines changed: 215 additions & 112 deletions

‎apps/desktop/src/main/__tests__/execution-store-wiring.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import { tmpdir } from 'node:os';
44
import { join } from 'node:path';
55
import { test } from 'node:test';
66
import type { AgentRunEvent, AgentRunHeader, ShellRunRecord } from '@maka/core';
7-
import { createAgentRunStore, createShellRunStore } from '@maka/storage';
7+
import {
8+
createLegacyAgentRunStoreForTest,
9+
createLegacyShellRunStoreForTest,
10+
} from '@maka/storage/legacy-execution-test-support';
811
import { openDesktopExecutionStoreWiring } from '../execution-store-wiring.js';
912

1013
test('Desktop cuts legacy execution state over before use and keeps later writes SQLite-only', async () => {
1114
const root = await mkdtemp(join(tmpdir(), 'maka-desktop-execution-stores-'));
1215
try {
13-
const legacyRuns = createAgentRunStore(root);
16+
const legacyRuns = createLegacyAgentRunStoreForTest(root);
1417
const firstRun = runHeader('run-1', 'turn-1');
1518
await legacyRuns.createRun(firstRun);
1619
await legacyRuns.appendEvent('session-1', 'run-1', runEvent('event-1', 'run-1', 'turn-1', 1));
@@ -24,7 +27,7 @@ test('Desktop cuts legacy execution state over before use and keeps later writes
2427
);
2528
const legacyRunBytes = await readFile(legacyRunEventsPath);
2629

27-
const legacyShellRuns = createShellRunStore(root);
30+
const legacyShellRuns = createLegacyShellRunStoreForTest(root);
2831
await legacyShellRuns.createShellRun(shellRun('shell-1'));
2932
const legacyShellPath = join(
3033
root,

‎packages/cli/src/__tests__/inspect-command.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { join } from 'node:path';
55
import { describe, test } from 'node:test';
66
import type { AgentRunHeader } from '@maka/core';
77
import { createInMemoryTaskRunStore, runTaskOnce } from '@maka/headless';
8-
import { createAgentRunStore, createRuntimeEventStore, createSessionStore } from '@maka/storage';
8+
import { createSessionStore } from '@maka/storage';
9+
import {
10+
createLegacyAgentRunStoreForTest,
11+
createLegacyRuntimeEventStoreForTest,
12+
} from '@maka/storage/legacy-execution-test-support';
913
import {
1014
openHeadlessExecutionStoresForWrite,
1115
openInteractiveExecutionStoresForWrite,
@@ -241,8 +245,8 @@ describe('inspect CLI storage authority boundary', () => {
241245

242246
type InspectCommandTestStores = {
243247
sessionStore: ReturnType<typeof createSessionStore>;
244-
agentRunStore: ReturnType<typeof createAgentRunStore>;
245-
runtimeEventStore: ReturnType<typeof createRuntimeEventStore>;
248+
agentRunStore: ReturnType<typeof createLegacyAgentRunStoreForTest>;
249+
runtimeEventStore: ReturnType<typeof createLegacyRuntimeEventStoreForTest>;
246250
taskRunStore: ReturnType<typeof createInMemoryTaskRunStore>;
247251
};
248252

@@ -283,8 +287,8 @@ async function withStores(run: (stores: InspectCommandTestStores) => Promise<voi
283287
try {
284288
await run({
285289
sessionStore: createSessionStore(root),
286-
agentRunStore: createAgentRunStore(root),
287-
runtimeEventStore: createRuntimeEventStore(root),
290+
agentRunStore: createLegacyAgentRunStoreForTest(root),
291+
runtimeEventStore: createLegacyRuntimeEventStoreForTest(root),
288292
taskRunStore: createInMemoryTaskRunStore(),
289293
});
290294
} finally {

‎packages/headless/src/__tests__/task-run-inspect.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { join } from 'node:path';
55
import { describe, test } from 'node:test';
66
import type { AgentRunEvent, AgentRunHeader, RuntimeEvent } from '@maka/core';
77
import { buildHistoryCompactCheckpoint } from '@maka/runtime';
8-
import { createAgentRunStore, createRuntimeEventStore } from '@maka/storage';
8+
import {
9+
createLegacyAgentRunStoreForTest,
10+
createLegacyRuntimeEventStoreForTest,
11+
} from '@maka/storage/legacy-execution-test-support';
912
import type { HeavyTaskSemanticSelfCheckState, TaskEvent } from '../task-contracts.js';
1013
import { taskAttemptExecutionEvidence } from '../task-execution-lineage.js';
1114
import { createInMemoryTaskRunStore } from '../task-run-store.js';
@@ -350,16 +353,16 @@ const TURN_ID = 'turn-1';
350353
async function withStores(
351354
run: (stores: {
352355
taskRunStore: ReturnType<typeof createInMemoryTaskRunStore>;
353-
agentRunStore: ReturnType<typeof createAgentRunStore>;
354-
runtimeEventStore: ReturnType<typeof createRuntimeEventStore>;
356+
agentRunStore: ReturnType<typeof createLegacyAgentRunStoreForTest>;
357+
runtimeEventStore: ReturnType<typeof createLegacyRuntimeEventStoreForTest>;
355358
}) => Promise<void>,
356359
): Promise<void> {
357360
const root = await mkdtemp(join(tmpdir(), 'maka-task-run-inspect-'));
358361
try {
359362
await run({
360363
taskRunStore: createInMemoryTaskRunStore(),
361-
agentRunStore: createAgentRunStore(root),
362-
runtimeEventStore: createRuntimeEventStore(root),
364+
agentRunStore: createLegacyAgentRunStoreForTest(root),
365+
runtimeEventStore: createLegacyRuntimeEventStoreForTest(root),
363366
});
364367
} finally {
365368
await rm(root, { recursive: true, force: true });

‎packages/runtime-host/src/__tests__/root-admission-owner.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { tmpdir } from 'node:os';
44
import { join } from 'node:path';
55
import { test } from 'node:test';
66
import {
7-
createAgentRunStore,
87
type RootTurnAdmission,
98
type RootTurnAdmissionStore,
109
type RootTurnSourceMessage,
1110
} from '@maka/storage';
11+
import { createLegacyAgentRunStoreForTest } from '@maka/storage/legacy-execution-test-support';
1212
import { RootAdmissionOwner } from '../server/root-admission-owner.js';
1313
import { SessionAdmissionGate } from '../server/session-admission-gate.js';
1414

@@ -379,11 +379,11 @@ function mutableAdmission(): RootTurnAdmission {
379379
}
380380

381381
async function withStore(
382-
run: (store: ReturnType<typeof createAgentRunStore>) => Promise<void>,
382+
run: (store: ReturnType<typeof createLegacyAgentRunStoreForTest>) => Promise<void>,
383383
): Promise<void> {
384384
const root = await mkdtemp(join(tmpdir(), 'maka-root-admission-owner-'));
385385
try {
386-
await run(createAgentRunStore(root));
386+
await run(createLegacyAgentRunStoreForTest(root));
387387
} finally {
388388
await rm(root, { recursive: true, force: true });
389389
}

‎packages/runtime/src/__tests__/agent-run-steering-recovery.test.ts‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import assert from 'node:assert/strict';
55
import { test } from 'node:test';
66
import type { AgentRunHeader, RuntimeEvent } from '@maka/core';
77
import type { SessionEvent } from '@maka/core/events';
8+
import { createLegacyFileSessionStore } from '@maka/storage';
89
import {
9-
createAgentRunStore,
10-
createLegacyFileSessionStore,
11-
createRuntimeEventStore,
12-
} from '@maka/storage';
10+
createLegacyAgentRunStoreForTest,
11+
createLegacyRuntimeEventStoreForTest,
12+
} from '@maka/storage/legacy-execution-test-support';
1313
import { AgentRun } from '../agent-run.js';
1414
import { buildStatusPatch } from '../session-projection-helpers.js';
1515

@@ -24,7 +24,7 @@ test('does not re-append atomically committed tool facts through the generic eve
2424
model: 'fake-model',
2525
permissionMode: 'ask',
2626
});
27-
const runtimeEventStore = createRuntimeEventStore(root);
27+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
2828
const runId = 'run-atomic-tool';
2929
const turnId = 'turn-atomic-tool';
3030
const run = new AgentRun({
@@ -99,8 +99,8 @@ test('acks a steering event whose canonical append preceded proof publication fa
9999
model: 'fake-model',
100100
permissionMode: 'ask',
101101
});
102-
const runStore = createAgentRunStore(root);
103-
const runtimeEventStore = createRuntimeEventStore(root);
102+
const runStore = createLegacyAgentRunStoreForTest(root);
103+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
104104
const runId = 'run-1';
105105
const turnId = 'turn-1';
106106
await runStore.createRun(makeRunHeader(session.id, runId, turnId));
@@ -154,7 +154,7 @@ test('acks a steering event whose canonical append preceded proof publication fa
154154

155155
await chmod(proofDirectory, 0o700);
156156
await rm(proofDirectory, { recursive: true });
157-
const recovered = createRuntimeEventStore(root);
157+
const recovered = createLegacyRuntimeEventStoreForTest(root);
158158
await recovered.repairImmutableSteeringMessageProofsForRecovery(session.id);
159159
assert.deepEqual(await recovered.readImmutableRuntimeEvents(session.id, runId), [runtimeEvent]);
160160
assert.deepEqual(
@@ -177,8 +177,8 @@ test('awaits canonical Run status persistence before accepting an interaction re
177177
model: 'fake-model',
178178
permissionMode: 'ask',
179179
});
180-
const runStore = createAgentRunStore(root);
181-
const runtimeEventStore = createRuntimeEventStore(root);
180+
const runStore = createLegacyAgentRunStoreForTest(root);
181+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
182182
const runId = 'run-status-barrier';
183183
const turnId = 'turn-status-barrier';
184184
await store.updateHeader(session.id, buildStatusPatch('waiting_for_user', 1));
@@ -257,8 +257,8 @@ test('required interaction resume recovers a failed best-effort Run Store latch
257257
model: 'fake-model',
258258
permissionMode: 'ask',
259259
});
260-
const runStore = createAgentRunStore(root);
261-
const runtimeEventStore = createRuntimeEventStore(root);
260+
const runStore = createLegacyAgentRunStoreForTest(root);
261+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
262262
const runId = 'run-status-latch';
263263
const turnId = 'turn-status-latch';
264264
await store.updateHeader(session.id, buildStatusPatch('waiting_for_user', 1));
@@ -372,8 +372,8 @@ test('required interaction resume stays fail-closed until a later required write
372372
model: 'fake-model',
373373
permissionMode: 'ask',
374374
});
375-
const runStore = createAgentRunStore(root);
376-
const runtimeEventStore = createRuntimeEventStore(root);
375+
const runStore = createLegacyAgentRunStoreForTest(root);
376+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
377377
const runId = 'run-status-latch-failure';
378378
const turnId = 'turn-status-latch-failure';
379379
await store.updateHeader(session.id, buildStatusPatch('waiting_for_user', 1));

‎packages/runtime/src/__tests__/context-diagnostics.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
44
import { join } from 'node:path';
55
import { test } from 'node:test';
66
import type { AgentRunEvent, AgentRunHeader, AgentRunStore } from '@maka/core';
7-
import { createAgentRunStore } from '@maka/storage';
7+
import { createLegacyAgentRunStoreForTest } from '@maka/storage/legacy-execution-test-support';
88
import { readLatestContextDiagnostics } from '../context-diagnostics.js';
99

1010
test('reads the latest completed provider request instead of a later failed attempt', async () => {
@@ -159,7 +159,7 @@ test('reports the latest history compaction that preceded the displayed request'
159159
test('reads the same diagnostics after reopening the durable run ledger', async () => {
160160
const root = await mkdtemp(join(tmpdir(), 'maka-context-diagnostics-'));
161161
try {
162-
const writer = createAgentRunStore(root);
162+
const writer = createLegacyAgentRunStoreForTest(root);
163163
const header = runHeader('run-1', 1);
164164
await writer.createRun(header);
165165
await writer.appendEvent(
@@ -168,7 +168,10 @@ test('reads the same diagnostics after reopening the durable run ledger', async
168168
attemptEvent('run-1', 'attempt-1', 10, 'completed', 'model', 40, 200),
169169
);
170170

171-
const diagnostics = await readLatestContextDiagnostics(createAgentRunStore(root), 'session-1');
171+
const diagnostics = await readLatestContextDiagnostics(
172+
createLegacyAgentRunStoreForTest(root),
173+
'session-1',
174+
);
172175

173176
assert.equal(diagnostics.status, 'available');
174177
if (diagnostics.status !== 'available') return;

‎packages/runtime/src/__tests__/conversation-copy.test.ts‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ import {
1515
decodeCanonicalToolResultContent,
1616
isSessionInlineRun,
1717
} from '@maka/core';
18+
import { createSqliteAgentRunStore, createSqliteRuntimeStore } from '@maka/storage';
1819
import {
19-
createAgentRunStore,
20-
createRuntimeEventStore,
21-
createSqliteAgentRunStore,
22-
createSqliteRuntimeStore,
23-
} from '@maka/storage';
20+
createLegacyAgentRunStoreForTest,
21+
createLegacyRuntimeEventStoreForTest,
22+
} from '@maka/storage/legacy-execution-test-support';
2423
import {
2524
archivedToolResultContainsConversationOwnedReferences,
2625
cloneConversationRuntimeLedger,
@@ -412,8 +411,8 @@ test('conversation copy turn closure includes legacy children but excludes later
412411
test('conversation copy rejects a retained AgentRun without RuntimeEvent facts', async () => {
413412
const root = await mkdtemp(join(tmpdir(), 'maka-conversation-missing-runtime-copy-'));
414413
try {
415-
const runStore = createAgentRunStore(root);
416-
const runtimeEventStore = createRuntimeEventStore(root);
414+
const runStore = createLegacyAgentRunStoreForTest(root);
415+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
417416
const rootRun = agentRunHeader({
418417
runId: 'run-root',
419418
invocationId: 'invocation-root',
@@ -693,8 +692,8 @@ test('conversation copy rewrites a complete tool recovery bundle atomically', as
693692
test('conversation copy validates operational events before persisting target ledgers', async () => {
694693
const root = await mkdtemp(join(tmpdir(), 'maka-conversation-copy-preflight-'));
695694
try {
696-
const runStore = createAgentRunStore(root);
697-
const runtimeEventStore = createRuntimeEventStore(root);
695+
const runStore = createLegacyAgentRunStoreForTest(root);
696+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
698697
await runStore.createRun(
699698
agentRunHeader({
700699
runId: 'run-source',
@@ -763,8 +762,8 @@ test('conversation copy validates operational events before persisting target le
763762
test('conversation copy clones one terminal Runtime ledger with new owned identities', async () => {
764763
const root = await mkdtemp(join(tmpdir(), 'maka-conversation-runtime-copy-'));
765764
try {
766-
const runStore = createAgentRunStore(root);
767-
const runtimeEventStore = createRuntimeEventStore(root);
765+
const runStore = createLegacyAgentRunStoreForTest(root);
766+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
768767
const sourceRun: AgentRunHeader = {
769768
runId: 'run-source',
770769
invocationId: 'invocation-source',
@@ -1130,8 +1129,8 @@ test('conversation copy clones one terminal Runtime ledger with new owned identi
11301129
test('conversation copy rebuilds an inline checkpoint without legacy child events in its prefix', async () => {
11311130
const root = await mkdtemp(join(tmpdir(), 'maka-conversation-checkpoint-copy-'));
11321131
try {
1133-
const runStore = createAgentRunStore(root);
1134-
const runtimeEventStore = createRuntimeEventStore(root);
1132+
const runStore = createLegacyAgentRunStoreForTest(root);
1133+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
11351134
const firstRun = agentRunHeader({
11361135
runId: 'run-1',
11371136
invocationId: 'invocation-1',
@@ -1306,8 +1305,8 @@ test('conversation copy rebuilds an inline checkpoint without legacy child event
13061305
test('conversation copy rebuilds a resumed child checkpoint over its child run chain', async () => {
13071306
const root = await mkdtemp(join(tmpdir(), 'maka-conversation-child-checkpoint-copy-'));
13081307
try {
1309-
const runStore = createAgentRunStore(root);
1310-
const runtimeEventStore = createRuntimeEventStore(root);
1308+
const runStore = createLegacyAgentRunStoreForTest(root);
1309+
const runtimeEventStore = createLegacyRuntimeEventStoreForTest(root);
13111310
const rootRun = agentRunHeader({
13121311
runId: 'run-root',
13131312
invocationId: 'invocation-root',

‎packages/runtime/src/__tests__/execution-inspect.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { tmpdir } from 'node:os';
44
import { join } from 'node:path';
55
import { describe, test } from 'node:test';
66
import type { AgentRunEvent, AgentRunHeader, RuntimeEvent } from '@maka/core';
7-
import { createAgentRunStore, createRuntimeEventStore, createSessionStore } from '@maka/storage';
7+
import { createSessionStore } from '@maka/storage';
8+
import {
9+
createLegacyAgentRunStoreForTest,
10+
createLegacyRuntimeEventStoreForTest,
11+
} from '@maka/storage/legacy-execution-test-support';
812
import {
913
AGENT_RUN_INSPECT_DOCUMENT_VERSION,
1014
SESSION_INSPECT_DOCUMENT_VERSION,
@@ -18,8 +22,8 @@ describe('versioned execution inspect documents', () => {
1822
test('reports unknown tool outcomes without copying Runtime payloads', async () => {
1923
await withWorkspace(async (root) => {
2024
const sessionStore = createSessionStore(root);
21-
const runStore = createAgentRunStore(root);
22-
const runtimeStore = createRuntimeEventStore(root);
25+
const runStore = createLegacyAgentRunStoreForTest(root);
26+
const runtimeStore = createLegacyRuntimeEventStoreForTest(root);
2327
const session = await sessionStore.create({
2428
cwd: '/tmp/workspace',
2529
backend: 'fake',
@@ -86,8 +90,8 @@ describe('versioned execution inspect documents', () => {
8690
test('projects a Session as bounded AgentRun documents without reading messages', async () => {
8791
await withWorkspace(async (root) => {
8892
const sessionStore = createSessionStore(root);
89-
const runStore = createAgentRunStore(root);
90-
const runtimeStore = createRuntimeEventStore(root);
93+
const runStore = createLegacyAgentRunStoreForTest(root);
94+
const runtimeStore = createLegacyRuntimeEventStoreForTest(root);
9195
const session = await sessionStore.create({
9296
cwd: '/tmp/workspace',
9397
name: 'Inspectable session',

‎packages/runtime/src/__tests__/runtime-continuation-crash.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { fileURLToPath } from 'node:url';
88
import { describe, test } from 'node:test';
99

1010
import type { AgentRunHeader, RuntimeEvent } from '@maka/core';
11-
import { createAgentRunStore, createSessionStore, createSqliteRuntimeStore } from '@maka/storage';
11+
import { createSessionStore, createSqliteRuntimeStore } from '@maka/storage';
12+
import { createLegacyAgentRunStoreForTest } from '@maka/storage/legacy-execution-test-support';
1213

1314
import { type RuntimeContinuationFailpoint } from '../agent-run.js';
1415
import { BackendRegistry, SessionManager } from '../session-manager.js';
@@ -37,7 +38,7 @@ if (process.env[CRASH_CHILD_ENV] === '1') {
3738
await crashContinuationAt(workspaceRoot, failpoint);
3839

3940
const store = createSessionStore(workspaceRoot);
40-
const runStore = createAgentRunStore(workspaceRoot);
41+
const runStore = createLegacyAgentRunStoreForTest(workspaceRoot);
4142
const runtimeEventStore = createCrashRuntimeStore(workspaceRoot);
4243
const [session] = await store.list();
4344
assert.ok(session, `${failpoint} did not persist a session`);
@@ -122,7 +123,7 @@ async function runCrashChild(): Promise<void> {
122123
'MAKA_RUNTIME_CONTINUATION_FAILPOINT',
123124
) as RuntimeContinuationFailpoint;
124125
const store = createSessionStore(workspaceRoot);
125-
const runStore = createAgentRunStore(workspaceRoot);
126+
const runStore = createLegacyAgentRunStoreForTest(workspaceRoot);
126127
const runtimeEventStore = createCrashRuntimeStore(workspaceRoot);
127128
const backends = new BackendRegistry();
128129
backends.register(
@@ -215,7 +216,7 @@ function createManager(workspaceRoot: string): {
215216
sessionStore: ReturnType<typeof createSessionStore>;
216217
} {
217218
const store = createSessionStore(workspaceRoot);
218-
const runStore = createAgentRunStore(workspaceRoot);
219+
const runStore = createLegacyAgentRunStoreForTest(workspaceRoot);
219220
const runtimeEventStore = createCrashRuntimeStore(workspaceRoot);
220221
const backends = new BackendRegistry();
221222
backends.register(

0 commit comments

Comments
 (0)