Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions apps/desktop/src/main/e2e-fixture.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { mkdir, rm } from 'node:fs/promises';
import { join } from 'node:path';
import type { E2eFixtureScenario, E2eFixtureState, UiLocale } from '@maka/core';
import {
backfillSessionProjects,
createFileCredentialStore,
createProjectCatalog,
createSessionStore,
} from '@maka/storage';
import { createFileCredentialStore } from '@maka/storage';
import type { CredentialStore } from '@maka/storage';
import { resolveStorageRoot } from '@maka/storage/root-authority';
import {
Expand Down Expand Up @@ -228,16 +223,4 @@ export async function seedE2eFixture(input: {
await writeSession(input.workspaceRoot, seed.header, seed.messages);
}
}
await seedSessionProjects(input.workspaceRoot);
}

async function seedSessionProjects(workspaceRoot: string): Promise<void> {
const sessions = createSessionStore(workspaceRoot);
const catalog = createProjectCatalog(workspaceRoot);
try {
await backfillSessionProjects({ sessions, catalog });
} finally {
await sessions.close?.();
catalog.close();
}
}
38 changes: 0 additions & 38 deletions packages/cli/src/__tests__/pi-transcript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3986,44 +3986,6 @@ describe('Maka Pi TUI transcript', () => {
});

describe('transcript entry render memoization', () => {
test('re-renders live progress after the bounded buffer reaches a stable length', () => {
const state = createMakaPiTranscriptState();
applyMakaSessionEventToTranscript(
state,
event({
type: 'tool_start',
toolUseId: 'progress-cache',
toolName: 'Workflow',
args: {},
}),
);
for (let i = 0; i < 512; i += 1) {
applyMakaSessionEventToTranscript(
state,
event({
type: 'tool_progress',
toolUseId: 'progress-cache',
chunk: `progress-${i}\n`,
}),
);
}
assert.equal(toggleAllToolExpansion(state), true);
const before = renderMakaPiTranscript(state, meta(), 100).map(stripAnsi).join('\n');
assert.match(before, /progress-511\b/);

applyMakaSessionEventToTranscript(
state,
event({
type: 'tool_progress',
toolUseId: 'progress-cache',
chunk: 'progress-512\n',
}),
);
const after = renderMakaPiTranscript(state, meta(), 100).map(stripAnsi).join('\n');
assert.match(after, /progress-512\b/);
assert.doesNotMatch(after, /progress-0\b/);
});

test('re-renders thinking when a same-length final replaces the streamed text', () => {
const state = createMakaPiTranscriptState();
applyMakaSessionEventToTranscript(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ import {
import {
AGENT_GRAPH_RESULT_MAX_BYTES,
decodeAgentGraphClientSnapshot,
decodeAgentGraphOperatorInspection,
} from '../protocol/index.js';
import {
HostAgentGraphCoordinator,
projectAgentGraphClientSnapshot,
projectAgentGraphOperatorInspection,
} from '../server/agent-graph-coordinator.js';
import type { ConnectionContext } from '../server/operation-dispatcher.js';

Expand Down Expand Up @@ -210,51 +208,6 @@ describe('Host Agent Graph coordinator', () => {
assert.equal(cursor.recordId, projected.terminalHistory.records.at(-1)?.recordId);
});

test('bounds a large operator inspection without changing its identity', () => {
const snapshot = graphSnapshot();
const source = operatorInspection(snapshot);
source.inboundEdges = Array.from({ length: 100 }, (_, index) => ({
edgeId: `edge-in-${index}`,
fromOperatorId: `upstream-${index}`,
toOperatorId: 'operator-1',
}));
source.outboundEdges = Array.from({ length: 100 }, (_, index) => ({
edgeId: `edge-out-${index}`,
fromOperatorId: 'operator-1',
toOperatorId: `downstream-${index}`,
}));
source.recentRecords = Array.from({ length: 128 }, (_, index) => activity(index));

const projected = projectAgentGraphOperatorInspection(source);
assert.ok(Buffer.byteLength(JSON.stringify(projected), 'utf8') <= AGENT_GRAPH_RESULT_MAX_BYTES);
assert.equal(projected.operator.operatorId, 'operator-1');
assert.equal(
projected.inboundEdges.length + projected.omitted.inboundEdges,
source.inboundEdges.length,
);
assert.equal(
projected.outboundEdges.length + projected.omitted.outboundEdges,
source.outboundEdges.length,
);
assert.equal(
projected.recentRecords.length + projected.omitted.records,
source.recentRecords.length,
);
assert.deepEqual(
projected.inboundEdges.map((edge) => edge.edgeId),
source.inboundEdges
.slice(source.inboundEdges.length - projected.inboundEdges.length)
.map((edge) => edge.edgeId),
);
assert.deepEqual(
projected.recentRecords.map((record) => record.recordId),
source.recentRecords
.slice(source.recentRecords.length - projected.recentRecords.length)
.map((record) => record.recordId),
);
assert.doesNotThrow(() => decodeAgentGraphOperatorInspection(projected));
});

test('projects only allowlisted Runtime fields onto the wire', () => {
const source = graphSnapshot();
Object.assign(source.operators[0]!, { privatePrompt: 'operator-secret' });
Expand Down
53 changes: 8 additions & 45 deletions packages/runtime/src/__tests__/history-compact-checkpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,26 @@ import { estimateRuntimeEventsTokens } from '../context-budget.js';
import { applyRuntimeEventHistoryCompact } from '../history-compact.js';

describe('history compact checkpoint', () => {
test('keeps 10K-event coverage bounded and validates the exact ordered prefix', () => {
const events = Array.from({ length: 10_000 }, (_, index) => textEvent(index));
test('validates the exact ordered source prefix', () => {
const events = Array.from({ length: 4 }, (_, index) => textEvent(index));
const checkpoint = buildHistoryCompactCheckpoint({
sessionId: 'session-1',
coveredRuntimeEvents: events,
summary: 'A bounded continuation summary.',
summary: 'Continuation summary.',
now: 1_800_000_010_000,
});

assert.equal(validateHistoryCompactCheckpointShape(checkpoint, 'session-1'), true);
assert.ok(Buffer.byteLength(JSON.stringify(checkpoint), 'utf8') < 64 * 1024);
assert.equal(checkpoint.coverage.eventCount, 10_000);
assert.equal(checkpoint.coverage.turnCount, 5_000);
assert.equal(checkpoint.coverage.through.runtimeEventId, 'event-9999');
assert.equal(checkpoint.source?.policyVersion, 'maka.compactable_runtime_event_projection.v1');
assert.deepEqual(checkpoint.source?.coverage, {
lowWater: {
ledger: 'runtime_event_projection',
streamId: 'session-1',
sequence: 0,
eventId: 'event-0',
},
highWater: {
ledger: 'runtime_event_projection',
streamId: 'session-1',
sequence: 9_999,
eventId: 'event-9999',
},
eventCount: 10_000,
});
const prefixMatch = matchHistoryCompactCheckpointPrefix(checkpoint, [
...events,
textEvent(10_000),
]);
assert.equal(prefixMatch.coveredEventCount, 10_000);
const prefixMatch = matchHistoryCompactCheckpointPrefix(checkpoint, [...events, textEvent(4)]);
assert.equal(prefixMatch.coveredEventCount, 4);
assert.deepEqual(
prefixMatch.successorRuntimeEvents.map((event) => event.id),
['event-10000'],
['event-4'],
);
const replay = applyRuntimeEventHistoryCompact(
[...events, textEvent(10_000)],
{
enabled: true,
mode: 'read_write',
checkpoint,
highWaterRatio: 0.000001,
tailEstimatedTokens: 1,
},
1,
1_000_000,
);
assert.equal(replay.checkpoint?.checkpointId, checkpoint.checkpointId);
assert.ok(Buffer.byteLength(JSON.stringify(replay.diagnosticPatch), 'utf8') < 16 * 1024);

const changed = [...events];
changed[4_999] = {
...changed[4_999]!,
changed[1] = {
...changed[1]!,
content: { kind: 'text', text: 'changed source fact' },
};
assert.equal(
Expand Down
28 changes: 0 additions & 28 deletions packages/runtime/src/__tests__/shell-run-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1559,34 +1559,6 @@ describe('ShellRunProcessManager', () => {
await manager.stopBackgroundTask('session-1', run.ref, NO_ABORT);
});

test('coalesces high-volume PTY renderer deltas without dropping bytes', async () => {
const cwd = await workspace();
const events: ShellRunPtyDataEvent[] = [];
const manager = createManager(createSqliteShellRunStore(cwd), undefined, {
onPtyData: (event) => events.push(event),
});
const run = await manager.runBackgroundBash(
shellInput({
cwd,
command: `node -e "process.stdout.write('x'.repeat(1024 * 1024))"`,
pty: true,
timeoutMs: 5_000,
}),
);
assert.equal(run.kind, 'shell_run');
await waitForTerminalShellRun(manager, run.ref);

const bytes = events.reduce((total, event) => total + Buffer.byteLength(event.data, 'utf8'), 0);
assert.equal(bytes, 1024 * 1024);
assert.equal(
events.every((event) => Buffer.byteLength(JSON.stringify(event.data), 'utf8') <= 40 * 1024),
true,
);
for (let index = 1; index < events.length; index += 1) {
assert.ok(events[index]!.sequence > events[index - 1]!.sequence);
}
});

test('keeps concurrent PTY control and Read persistence in parser-cut order', async () => {
const updates: ShellRunUpdate[] = [];
const store = createSqliteShellRunStore(await workspace());
Expand Down
Loading
Loading