Skip to content
Merged
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
28 changes: 28 additions & 0 deletions packages/seats/test/record-redact-stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,34 @@ test('two streams interleaved, each splitting the value, are scrubbed apart', ()
}
}));

// One character per delta: each delta is a prefix of the value, so it is held
// until the whole value has arrived (the marker) or the stream ends (the flush).
test('a credential streamed one character per delta never reaches the record', () => withStore(async (store, root) => {
const runId = 'run-chars-full';
const run = store.startRun({ runId });
run.redact([CANARY]);
for (const ch of CANARY) run.emit('agent.message_chunk', { text: ch });
run.emit('run.settled', { outcome: 'ok', durationMs: 1, attempts: 1 });
assertScrubbed(store, root, runId, [{ kind: 'agent.message_chunk', expected: '[redacted]' }]);
const events = store.readRun(runId);
const settledAt = events.findIndex((e) => e.kind === 'run.settled');
const marker = events.findIndex((e) => e.kind === 'agent.message_chunk' && e.data.text === '[redacted]');
assert.ok(marker >= 0 && marker < settledAt, 'the marker landed before run.settled');
}));

test('a credential cut one character short, streamed one character per delta, flushes as the marker before settle', () => withStore(async (store, root) => {
const runId = 'run-chars-short-of-one';
const run = store.startRun({ runId });
run.redact([CANARY]);
for (const ch of CANARY.slice(0, -1)) run.emit('agent.message_chunk', { text: ch });
run.emit('run.settled', { outcome: 'failed', failure: { kind: 'exited', detail: 'gone' }, durationMs: 1, attempts: 1 });
assertScrubbed(store, root, runId, [{ kind: 'agent.message_chunk', expected: '[redacted]' }]);
const events = store.readRun(runId);
const settledAt = events.findIndex((e) => e.kind === 'run.settled');
const marker = events.findIndex((e) => e.kind === 'agent.message_chunk' && e.data.text === '[redacted]');
assert.ok(marker >= 0 && marker < settledAt, 'the held tail flushed before run.settled');
}));

test('a stream that ends mid-value writes the marker before settle, never the prefix', () => withStore(async (store, root) => {
const run = store.startRun({ runId: 'run-held-settle' });
run.redact([CANARY]);
Expand Down
Loading