Skip to content

Commit 2b0c821

Browse files
V48 Gate 3 (implementation-only): raw LLM I/O sidecar lands under the real run id, not a literal 'run' directory
The sidecar writer resolved the run id via findUp('pipeline', 'correlationId') — a namespace nothing writes — so every run's wire I/O piled into ~/.bitcode/logs/executions/run with a global counter, defeating per-run separation of stall evidence. createStreamingExecution now stores the run id under the canonical execution/correlationId identity key at the root, and the diagnostics context resolves that key (root execution id as fallback) from any depth. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent ca25aa4 commit 2b0c821

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

packages/agent-generics/src/diagnostics/instrumentation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ function getCtx(execution: Execution, sequence?: string) {
1010
const agentName = (execution as any).findUp?.('agent', 'name');
1111
const execId = (execution as any).id;
1212
const path = (execution as any).getPath?.() || [];
13-
const correlationId = (execution as any).findUp?.('pipeline', 'correlationId');
13+
// The run id lives at the streaming root: canonically under
14+
// execution/correlationId, with the root execution id (== runId for
15+
// createStreamingExecution roots) as the fallback.
16+
const correlationId = (execution as any).findUp?.('execution', 'correlationId')
17+
?? (execution as any).getRoot?.()?.id;
1418
// Surface any provider/model already stored on ancestors (best-effort)
1519
let providerUp: string | undefined;
1620
let modelUp: string | undefined;

packages/pipelines-generics/src/streaming/__tests__/pipeline-stream-integration.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-nocheck
22
import { Execution } from '@bitcode/execution-generics';
3-
import { enablePipelineStreaming, sourceSafeStreamEvent } from '../../streaming/pipeline-stream-integration';
3+
import { createStreamingExecution, enablePipelineStreaming, sourceSafeStreamEvent } from '../../streaming/pipeline-stream-integration';
44

55
// Mock ORM model so we can assert persistence without a real DB
66
const createdEvents: any[] = [];
@@ -48,6 +48,22 @@ describe('pipeline-stream-integration', () => {
4848
expect(createdEvents[0].run_id).toBe('run-123');
4949
expect(createdEvents[0].event_type).toBeDefined();
5050
});
51+
52+
it('createStreamingExecution stores the run id as the canonical correlationId, resolvable from deep children', () => {
53+
const exec = createStreamingExecution({
54+
runId: 'run-correlation-1',
55+
userId: 'user-1',
56+
supabase: {} as any,
57+
streamToDatabase: false,
58+
streamToSSE: false,
59+
});
60+
61+
expect(exec.get('execution', 'correlationId')).toBe('run-correlation-1');
62+
// Substep diagnostics (raw LLM I/O sidecar directory naming) resolve the
63+
// run id via findUp from arbitrarily deep child nodes.
64+
const deepChild = exec.child('phase:discovery').child('agent:search').child('step:plan');
65+
expect(deepChild.findUp('execution', 'correlationId')).toBe('run-correlation-1');
66+
});
5167
});
5268

5369
describe('pipeline-stream-integration — executions-row FK race (QA: "Failed to persist stream event" 23503)', () => {

packages/pipelines-generics/src/streaming/pipeline-stream-integration.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,12 @@ export function createStreamingExecution(
666666
config: PipelineStreamConfig & { parent?: Execution }
667667
): Execution {
668668
const execution = new Execution(config.runId, config.parent);
669-
669+
670+
// Canonical run identity: substep diagnostics (e.g. the raw LLM I/O
671+
// sidecar directory) resolve the run id via findUp('execution',
672+
// 'correlationId') from arbitrarily deep child nodes.
673+
execution.store('execution', 'correlationId', config.runId);
674+
670675
// Enable streaming
671676
enablePipelineStreaming(execution, config);
672677

0 commit comments

Comments
 (0)