diff --git a/packages/core/src/context/sidecar/SidecarLoader.test.ts b/packages/core/src/context/config/SidecarLoader.test.ts similarity index 100% rename from packages/core/src/context/sidecar/SidecarLoader.test.ts rename to packages/core/src/context/config/SidecarLoader.test.ts diff --git a/packages/core/src/context/sidecar/SidecarLoader.ts b/packages/core/src/context/config/SidecarLoader.ts similarity index 100% rename from packages/core/src/context/sidecar/SidecarLoader.ts rename to packages/core/src/context/config/SidecarLoader.ts diff --git a/packages/core/src/context/sidecar/profiles.ts b/packages/core/src/context/config/profiles.ts similarity index 95% rename from packages/core/src/context/sidecar/profiles.ts rename to packages/core/src/context/config/profiles.ts index b02951272a..cea39819ab 100644 --- a/packages/core/src/context/sidecar/profiles.ts +++ b/packages/core/src/context/config/profiles.ts @@ -4,9 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type { SidecarConfig, PipelineDef } from './types.js'; -import type { ContextEnvironment } from './environment.js'; -import type { AsyncPipelineDef } from './types.js'; +import type { AsyncPipelineDef, SidecarConfig, PipelineDef } from './types.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; // Import factories import { createToolMaskingProcessor } from '../processors/toolMaskingProcessor.js'; diff --git a/packages/core/src/context/sidecar/registry.ts b/packages/core/src/context/config/registry.ts similarity index 57% rename from packages/core/src/context/sidecar/registry.ts rename to packages/core/src/context/config/registry.ts index f8793ff186..65b0b60dac 100644 --- a/packages/core/src/context/sidecar/registry.ts +++ b/packages/core/src/context/config/registry.ts @@ -9,44 +9,30 @@ export interface ContextProcessorDef { readonly schema: object; } -export interface ContextWorkerDef { - readonly id: string; - readonly schema: object; -} - /** * Registry for validating declarative sidecar configuration schemas. * (Dynamic instantiation has been replaced by static ContextProfiles) */ export class SidecarRegistry { private processors = new Map(); - private workers = new Map(); registerProcessor(def: ContextProcessorDef) { this.processors.set(def.id, def); } - registerWorker(def: ContextWorkerDef) { - this.workers.set(def.id, def); - } - getSchema(id: string): object | undefined { - return this.processors.get(id)?.schema || this.workers.get(id)?.schema; + return this.processors.get(id)?.schema; } - getSchemaDefs(): { id: string; schema: object }[] { - const defs: { id: string; schema: object }[] = []; + getSchemaDefs(): Array<{ id: string; schema: object }> { + const defs: Array<{ id: string; schema: object }> = []; for (const def of this.processors.values()) { if (def.schema) defs.push({ id: def.id, schema: def.schema }); } - for (const def of this.workers.values()) { - if (def.schema) defs.push({ id: def.id, schema: def.schema }); - } return defs; } clear() { this.processors.clear(); - this.workers.clear(); } } diff --git a/packages/core/src/context/sidecar/schema.ts b/packages/core/src/context/config/schema.ts similarity index 98% rename from packages/core/src/context/sidecar/schema.ts rename to packages/core/src/context/config/schema.ts index 99ec3178fb..6ca0df6123 100644 --- a/packages/core/src/context/sidecar/schema.ts +++ b/packages/core/src/context/config/schema.ts @@ -55,7 +55,7 @@ export function getSidecarConfigSchema(registry?: SidecarRegistry) { }, processorOptions: { type: 'object', - description: 'Named hyperparameter configurations for ContextProcessors and Workers.', + description: 'Named hyperparameter configurations for ContextProcessors and AsyncProcessors.', additionalProperties: processorOptionsMapping } }, diff --git a/packages/core/src/context/sidecar/types.ts b/packages/core/src/context/config/types.ts similarity index 97% rename from packages/core/src/context/sidecar/types.ts rename to packages/core/src/context/config/types.ts index 1a738bf125..c04cfc08a2 100644 --- a/packages/core/src/context/sidecar/types.ts +++ b/packages/core/src/context/config/types.ts @@ -36,7 +36,7 @@ export interface SidecarConfig { maxTokens: number; }; /** - * Dynamic hyperparameter overrides for individual ContextProcessors and Workers. + * Dynamic hyperparameter overrides for individual ContextProcessors and AsyncProcessors. * Keys are named identifiers (e.g. "gentleTruncation"). */ processorOptions?: Record; diff --git a/packages/core/src/context/context-manager-v0-design.md b/packages/core/src/context/context-manager-v0-design.md index 8fc1deabdd..061303f206 100644 --- a/packages/core/src/context/context-manager-v0-design.md +++ b/packages/core/src/context/context-manager-v0-design.md @@ -70,20 +70,20 @@ all mutations through a synchronous, blocking pipeline of pure functions, we guarantee that the context is always modified in a sane, predictable, and mathematically sound sequence. -### The "Open" Extensions: Processors, Workers, and Inboxes (The Actor Model) +### The "Open" Extensions: Processors, AsyncProcessors, and Inboxes (The Actor Model) To extend the system, developers author two types of plugins: 1. **Context Processors:** Pure, fast, synchronous functions that take an input graph and return an immutable mutated graph. They run inside Pipelines. -2. **Context Workers:** Inspired by the **Actor Model**, these are +2. **Context AsyncProcessors:** Inspired by the **Actor Model**, these are event-triggered background jobs designed for isolated, long-running async computations (e.g., asking an LLM to distill 50 turns of history). -3. **Inboxes:** Because the graph can only be mutated synchronously, Workers +3. **Inboxes:** Because the graph can only be mutated synchronously, AsyncProcessors cannot touch the graph directly (preventing race conditions). Instead, they drop their results via message-passing into point-in-time snapshots called _Inboxes_. Processors later read from these Inboxes during a synchronous - pipeline run to safely apply the worker's findings. + pipeline run to safely apply the async processor's findings. ## 4. Proofs of Construction @@ -119,7 +119,7 @@ class ToolMaskingProcessor implements ContextProcessor { } ``` -### Example B: Long-Running Summarization (Worker + Inbox + Processor) +### Example B: Long-Running Summarization (async pipeline + Inbox + Processor) _Scenario: The user has exceeded their token budget. We need to use an LLM to summarize the oldest 20 turns of conversation, but we cannot block the user from @@ -127,10 +127,10 @@ continuing to chat while the LLM generates the summary._ This requires our async-to-sync bridge. -**Step 1: The Worker (Async Analysis)** +**Step 1: The async pipeline (Async Analysis)** ```typescript -class StateSnapshotWorker implements ContextWorker { +class StateSnapshotasync pipeline implements Contextasync pipeline { // Triggers automatically in the background when the budget is exceeded async onBudgetExceeded(event: BudgetEvent, inbox: Inbox) { const agedOutNodes = event.getAgedOutNodes(); @@ -138,7 +138,7 @@ class StateSnapshotWorker implements ContextWorker { // Slow, async LLM call const summaryText = await llm.summarize(agedOutNodes); - // The worker CANNOT mutate the graph. It leaves a message in the Inbox. + // The async pipeline CANNOT mutate the graph. It leaves a message in the Inbox. inbox.deliver('SUMMARY_READY', { targetNodes: agedOutNodes, summary: summaryText, @@ -153,7 +153,7 @@ class StateSnapshotWorker implements ContextWorker { class StateSnapshotProcessor implements ContextProcessor { // Runs fast and synchronously during the next Pipeline execution apply(graph: ContextGraph, inbox: InboxSnapshot): ContextGraph { - // Check if the background worker finished its job + // Check if the async background pipeline finished its job const messages = inbox.read('SUMMARY_READY'); if (messages.isEmpty()) return graph; @@ -227,7 +227,7 @@ class MemoryExtractionProcessor implements ContextProcessor { By treating the Context Graph as an immutable ledger updated only via functional Pipelines, we have eliminated race conditions and untraceable graph corruption. -By utilizing Workers and Inboxes, we have safely bridged the gap between slow +By utilizing AsyncProcessors and Inboxes, we have safely bridged the gap between slow LLM analysis and fast, synchronous terminal UI updates. We recognize this is not the final form—future iterations may require strict diff --git a/packages/core/src/context/contextManager.ts b/packages/core/src/context/contextManager.ts index 14314d06d7..30918cafff 100644 --- a/packages/core/src/context/contextManager.ts +++ b/packages/core/src/context/contextManager.ts @@ -9,12 +9,12 @@ import type { AgentChatHistory } from '../core/agentChatHistory.js'; import type { ConcreteNode } from './ir/types.js'; import type { ContextEventBus } from './eventBus.js'; import type { ContextTracer } from './tracer.js'; -import type { ContextEnvironment } from './sidecar/environment.js'; -import type { ContextProfile } from './sidecar/profiles.js'; -import type { PipelineOrchestrator } from './sidecar/orchestrator.js'; +import type { ContextEnvironment } from './pipeline/environment.js'; +import type { ContextProfile } from './config/profiles.js'; +import type { PipelineOrchestrator } from './pipeline/orchestrator.js'; import { HistoryObserver } from './historyObserver.js'; import { IrProjector } from './ir/projector.js'; -import { ContextWorkingBufferImpl } from './sidecar/contextWorkingBuffer.js'; +import { ContextWorkingBufferImpl } from './pipeline/contextWorkingBuffer.js'; export class ContextManager { // The master state containing the pristine graph and current active graph. @@ -62,7 +62,7 @@ export class ContextManager { } /** - * Safely stops background workers and clears event listeners. + * Safely stops background async pipelines and clears event listeners. */ shutdown() { this.orchestrator.shutdown(); diff --git a/packages/core/src/context/ir/projector.ts b/packages/core/src/context/ir/projector.ts index dffb91307c..651656fe6c 100644 --- a/packages/core/src/context/ir/projector.ts +++ b/packages/core/src/context/ir/projector.ts @@ -10,9 +10,9 @@ import { debugLogger } from '../../utils/debugLogger.js'; import type { ContextEnvironment, ContextTracer, -} from '../sidecar/environment.js'; -import type { PipelineOrchestrator } from '../sidecar/orchestrator.js'; -import type { ContextProfile } from '../sidecar/profiles.js'; +} from '../pipeline/environment.js'; +import type { PipelineOrchestrator } from '../pipeline/orchestrator.js'; +import type { ContextProfile } from '../config/profiles.js'; export class IrProjector { /** diff --git a/packages/core/src/context/sidecar/contextWorkingBuffer.test.ts b/packages/core/src/context/pipeline/contextWorkingBuffer.test.ts similarity index 100% rename from packages/core/src/context/sidecar/contextWorkingBuffer.test.ts rename to packages/core/src/context/pipeline/contextWorkingBuffer.test.ts diff --git a/packages/core/src/context/sidecar/contextWorkingBuffer.ts b/packages/core/src/context/pipeline/contextWorkingBuffer.ts similarity index 100% rename from packages/core/src/context/sidecar/contextWorkingBuffer.ts rename to packages/core/src/context/pipeline/contextWorkingBuffer.ts diff --git a/packages/core/src/context/sidecar/environment.ts b/packages/core/src/context/pipeline/environment.ts similarity index 100% rename from packages/core/src/context/sidecar/environment.ts rename to packages/core/src/context/pipeline/environment.ts diff --git a/packages/core/src/context/sidecar/environmentImpl.test.ts b/packages/core/src/context/pipeline/environmentImpl.test.ts similarity index 100% rename from packages/core/src/context/sidecar/environmentImpl.test.ts rename to packages/core/src/context/pipeline/environmentImpl.test.ts diff --git a/packages/core/src/context/sidecar/environmentImpl.ts b/packages/core/src/context/pipeline/environmentImpl.ts similarity index 100% rename from packages/core/src/context/sidecar/environmentImpl.ts rename to packages/core/src/context/pipeline/environmentImpl.ts diff --git a/packages/core/src/context/sidecar/inbox.test.ts b/packages/core/src/context/pipeline/inbox.test.ts similarity index 100% rename from packages/core/src/context/sidecar/inbox.test.ts rename to packages/core/src/context/pipeline/inbox.test.ts diff --git a/packages/core/src/context/sidecar/inbox.ts b/packages/core/src/context/pipeline/inbox.ts similarity index 98% rename from packages/core/src/context/sidecar/inbox.ts rename to packages/core/src/context/pipeline/inbox.ts index b9aded9d6a..87c32c2b59 100644 --- a/packages/core/src/context/sidecar/inbox.ts +++ b/packages/core/src/context/pipeline/inbox.ts @@ -47,7 +47,7 @@ export class InboxSnapshotImpl implements InboxSnapshot { * completely erases generic type information () at runtime, the central array * can only hold `unknown` payloads. To enforce strict type safety without a central * registry (which would break decoupling) or heavy runtime validation (Zod schemas), - * we must assert the type boundary here. The contract relies on the Worker and Processor + * we must assert the type boundary here. The contract relies on the async pipeline and Processor * agreeing on the payload structure associated with the configured topic string. */ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion diff --git a/packages/core/src/context/sidecar/orchestrator.test.ts b/packages/core/src/context/pipeline/orchestrator.test.ts similarity index 95% rename from packages/core/src/context/sidecar/orchestrator.test.ts rename to packages/core/src/context/pipeline/orchestrator.test.ts index f341ac2965..b64553e614 100644 --- a/packages/core/src/context/sidecar/orchestrator.test.ts +++ b/packages/core/src/context/pipeline/orchestrator.test.ts @@ -17,7 +17,7 @@ import type { AsyncContextProcessor, ProcessArgs, } from '../pipeline.js'; -import type { PipelineDef, AsyncPipelineDef } from './types.js'; +import type { PipelineDef, AsyncPipelineDef } from '../config/types.js'; import type { ContextEventBus } from '../eventBus.js'; import type { ConcreteNode, UserPrompt } from '../ir/types.js'; @@ -180,10 +180,10 @@ describe('PipelineOrchestrator (Component)', () => { }); }); - describe('Asynchronous Worker Events', () => { + describe('Asynchronous async pipeline Events', () => { it('routes emitChunkReceived to async pipelines with nodes_added trigger', async () => { const executeSpy = vi.fn(); - const asyncProcessor = createMockAsyncProcessor('MyWorker', executeSpy); + const asyncProcessor = createMockAsyncProcessor('MyAsyncProcessor', executeSpy); setupOrchestrator([], [{ name: 'TestAsync', @@ -204,7 +204,7 @@ describe('PipelineOrchestrator (Component)', () => { expect(executeSpy).toHaveBeenCalledTimes(1); const callArgs = executeSpy.mock.calls[0][0]; - expect(callArgs.targets).toEqual([node2]); // Workers only get the target nodes + expect(callArgs.targets).toEqual([node2]); // AsyncProcessors only get the target nodes }); }); }); diff --git a/packages/core/src/context/sidecar/orchestrator.ts b/packages/core/src/context/pipeline/orchestrator.ts similarity index 99% rename from packages/core/src/context/sidecar/orchestrator.ts rename to packages/core/src/context/pipeline/orchestrator.ts index 2db51e5fa7..d92e6e3df4 100644 --- a/packages/core/src/context/sidecar/orchestrator.ts +++ b/packages/core/src/context/pipeline/orchestrator.ts @@ -5,7 +5,7 @@ */ import type { ConcreteNode } from '../ir/types.js'; -import type { AsyncPipelineDef, PipelineDef, PipelineTrigger } from './types.js'; +import type { AsyncPipelineDef, PipelineDef, PipelineTrigger } from '../config/types.js'; import type { ContextEnvironment, ContextEventBus, diff --git a/packages/core/src/context/processors/blobDegradationProcessor.ts b/packages/core/src/context/processors/blobDegradationProcessor.ts index d75a9bf1a0..f0d9a06d98 100644 --- a/packages/core/src/context/processors/blobDegradationProcessor.ts +++ b/packages/core/src/context/processors/blobDegradationProcessor.ts @@ -5,7 +5,7 @@ */ import type { ProcessArgs, ContextProcessor } from '../pipeline.js'; import type { ConcreteNode, UserPrompt } from '../ir/types.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import { sanitizeFilenamePart } from '../../utils/fileUtils.js'; export function createBlobDegradationProcessor( diff --git a/packages/core/src/context/processors/historyTruncationProcessor.ts b/packages/core/src/context/processors/historyTruncationProcessor.ts index 813a77205d..528f64e099 100644 --- a/packages/core/src/context/processors/historyTruncationProcessor.ts +++ b/packages/core/src/context/processors/historyTruncationProcessor.ts @@ -10,7 +10,7 @@ import type { ProcessArgs, } from '../pipeline.js'; import type { ConcreteNode } from '../ir/types.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; export type HistoryTruncationProcessorOptions = BackstopTargetOptions; diff --git a/packages/core/src/context/processors/nodeDistillationProcessor.ts b/packages/core/src/context/processors/nodeDistillationProcessor.ts index 53c5c3f425..93a9ed3a29 100644 --- a/packages/core/src/context/processors/nodeDistillationProcessor.ts +++ b/packages/core/src/context/processors/nodeDistillationProcessor.ts @@ -5,7 +5,7 @@ */ import type { ContextProcessor, ProcessArgs } from '../pipeline.js'; import type { ConcreteNode } from '../ir/types.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import { debugLogger } from '../../utils/debugLogger.js'; import { getResponseText } from '../../utils/partUtils.js'; diff --git a/packages/core/src/context/processors/nodeTruncationProcessor.ts b/packages/core/src/context/processors/nodeTruncationProcessor.ts index 7176d4fd17..2b3e760cd1 100644 --- a/packages/core/src/context/processors/nodeTruncationProcessor.ts +++ b/packages/core/src/context/processors/nodeTruncationProcessor.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import type { ContextProcessor, ProcessArgs } from '../pipeline.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import { truncateProportionally } from '../truncation.js'; import type { ConcreteNode } from '../ir/types.js'; diff --git a/packages/core/src/context/processors/rollingSummaryProcessor.ts b/packages/core/src/context/processors/rollingSummaryProcessor.ts index a90b35b4d6..c08960e09b 100644 --- a/packages/core/src/context/processors/rollingSummaryProcessor.ts +++ b/packages/core/src/context/processors/rollingSummaryProcessor.ts @@ -8,7 +8,7 @@ import type { ProcessArgs, BackstopTargetOptions, } from '../pipeline.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import type { ConcreteNode, RollingSummary } from '../ir/types.js'; import { SnapshotGenerator } from '../utils/snapshotGenerator.js'; import { debugLogger } from '../../utils/debugLogger.js'; diff --git a/packages/core/src/context/processors/stateSnapshotAsyncProcessor.test.ts b/packages/core/src/context/processors/stateSnapshotAsyncProcessor.test.ts index cbc0c6eb9f..ade626f93d 100644 --- a/packages/core/src/context/processors/stateSnapshotAsyncProcessor.test.ts +++ b/packages/core/src/context/processors/stateSnapshotAsyncProcessor.test.ts @@ -11,15 +11,15 @@ import { createMockProcessArgs, } from '../testing/contextTestUtils.js'; import type { InboxMessage } from '../pipeline.js'; -import type { InboxSnapshotImpl } from '../sidecar/inbox.js'; +import type { InboxSnapshotImpl } from '../pipeline/inbox.js'; -describe('StateSnapshotWorker', () => { +describe('StateSnapshotAsyncProcessor', () => { it('should generate a snapshot and publish it to the inbox', async () => { const env = createMockEnvironment(); // Spy on the publish method const publishSpy = vi.spyOn(env.inbox, 'publish'); - const worker = createStateSnapshotAsyncProcessor('StateSnapshotWorker', env, { type: 'point-in-time' }); + const worker = createStateSnapshotAsyncProcessor('StateSnapshotAsyncProcessor', env, { type: 'point-in-time' }); const nodeA = createDummyNode('ep1', 'USER_PROMPT', 50, {}, 'node-A'); const nodeB = createDummyNode('ep1', 'AGENT_THOUGHT', 60, {}, 'node-B'); @@ -47,7 +47,7 @@ describe('StateSnapshotWorker', () => { const publishSpy = vi.spyOn(env.inbox, 'publish'); const drainSpy = vi.spyOn(env.inbox, 'drainConsumed'); - const worker = createStateSnapshotAsyncProcessor('StateSnapshotWorker', env, { type: 'accumulate' }); + const worker = createStateSnapshotAsyncProcessor('StateSnapshotAsyncProcessor', env, { type: 'accumulate' }); const nodeC = createDummyNode('ep2', 'USER_PROMPT', 50, {}, 'node-C'); const targets = [nodeC]; @@ -103,7 +103,7 @@ describe('StateSnapshotWorker', () => { it('should ignore empty targets', async () => { const env = createMockEnvironment(); const publishSpy = vi.spyOn(env.inbox, 'publish'); - const worker = createStateSnapshotAsyncProcessor('StateSnapshotWorker', env, { type: 'accumulate' }); + const worker = createStateSnapshotAsyncProcessor('StateSnapshotAsyncProcessor', env, { type: 'accumulate' }); await worker.process(createMockProcessArgs([], [], [])); diff --git a/packages/core/src/context/processors/stateSnapshotAsyncProcessor.ts b/packages/core/src/context/processors/stateSnapshotAsyncProcessor.ts index 88b74bffe8..9c4db578ec 100644 --- a/packages/core/src/context/processors/stateSnapshotAsyncProcessor.ts +++ b/packages/core/src/context/processors/stateSnapshotAsyncProcessor.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import type { AsyncContextProcessor, ProcessArgs } from '../pipeline.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import type { ConcreteNode } from '../ir/types.js'; import { SnapshotGenerator } from '../utils/snapshotGenerator.js'; import { debugLogger } from '../../utils/debugLogger.js'; @@ -30,9 +30,9 @@ export function createStateSnapshotAsyncProcessor( try { let nodesToSummarize = [...targets]; let previousConsumedIds: string[] = []; - const workerType = options.type ?? 'point-in-time'; + const processorType = options.type ?? 'point-in-time'; - if (workerType === 'accumulate') { + if (processorType === 'accumulate') { // Look for the most recent unconsumed accumulate snapshot in the inbox const proposedSnapshots = inbox.getMessages<{ newText: string; @@ -80,13 +80,13 @@ export function createStateSnapshotAsyncProcessor( ...targets.map((t) => t.id), ]; - // In V2, workers communicate their work to the inbox, and the processor picks it up. + // In V2, async pipelines communicate their work to the inbox, and the processor picks it up. env.inbox.publish( 'PROPOSED_SNAPSHOT', { newText: snapshotText, consumedIds: newConsumedIds, - type: workerType, + type: processorType, }, env.idGenerator, ); diff --git a/packages/core/src/context/processors/stateSnapshotProcessor.test.ts b/packages/core/src/context/processors/stateSnapshotProcessor.test.ts index 5103d3399f..5fb508a68a 100644 --- a/packages/core/src/context/processors/stateSnapshotProcessor.test.ts +++ b/packages/core/src/context/processors/stateSnapshotProcessor.test.ts @@ -10,7 +10,7 @@ import { createDummyNode, createMockProcessArgs, } from '../testing/contextTestUtils.js'; -import type { InboxSnapshotImpl } from '../sidecar/inbox.js'; +import type { InboxSnapshotImpl } from '../pipeline/inbox.js'; describe('StateSnapshotProcessor', () => { it('should ignore if budget is satisfied', async () => { @@ -35,7 +35,7 @@ describe('StateSnapshotProcessor', () => { const targets = [nodeA, nodeB, nodeC]; - // The background worker created a snapshot of A and B + // The async background pipeline created a snapshot of A and B const messages = [ { id: 'msg-1', diff --git a/packages/core/src/context/processors/stateSnapshotProcessor.ts b/packages/core/src/context/processors/stateSnapshotProcessor.ts index 9ffc722c8f..8029dd9cd5 100644 --- a/packages/core/src/context/processors/stateSnapshotProcessor.ts +++ b/packages/core/src/context/processors/stateSnapshotProcessor.ts @@ -8,7 +8,7 @@ import type { ProcessArgs, BackstopTargetOptions, } from '../pipeline.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import type { ConcreteNode, Snapshot } from '../ir/types.js'; import { SnapshotGenerator } from '../utils/snapshotGenerator.js'; import { debugLogger } from '../../utils/debugLogger.js'; diff --git a/packages/core/src/context/processors/toolMaskingProcessor.ts b/packages/core/src/context/processors/toolMaskingProcessor.ts index c4b402ad5a..51c96ebba6 100644 --- a/packages/core/src/context/processors/toolMaskingProcessor.ts +++ b/packages/core/src/context/processors/toolMaskingProcessor.ts @@ -5,7 +5,7 @@ */ import type { ContextProcessor, ProcessArgs } from '../pipeline.js'; import type { ConcreteNode, ToolExecution } from '../ir/types.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import { sanitizeFilenamePart } from '../../utils/fileUtils.js'; import { ACTIVATE_SKILL_TOOL_NAME, diff --git a/packages/core/src/context/system-tests/SimulationHarness.ts b/packages/core/src/context/system-tests/SimulationHarness.ts index dc93d30223..6273828853 100644 --- a/packages/core/src/context/system-tests/SimulationHarness.ts +++ b/packages/core/src/context/system-tests/SimulationHarness.ts @@ -7,11 +7,11 @@ import { ContextManager } from '../contextManager.js'; import { AgentChatHistory } from '../../core/agentChatHistory.js'; import type { Content } from '@google/genai'; -import type { ContextProfile } from '../sidecar/profiles.js'; -import { ContextEnvironmentImpl } from '../sidecar/environmentImpl.js'; +import type { ContextProfile } from '../config/profiles.js'; +import { ContextEnvironmentImpl } from '../pipeline/environmentImpl.js'; import { ContextTracer } from '../tracer.js'; import { ContextEventBus } from '../eventBus.js'; -import { PipelineOrchestrator } from '../sidecar/orchestrator.js'; +import { PipelineOrchestrator } from '../pipeline/orchestrator.js'; import { debugLogger } from '../../utils/debugLogger.js'; import { DeterministicIdGenerator } from '../system/DeterministicIdGenerator.js'; import { InMemoryFileSystem } from '../system/InMemoryFileSystem.js'; diff --git a/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap b/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap index fc72e46a60..94339306ff 100644 --- a/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap +++ b/packages/core/src/context/system-tests/__snapshots__/lifecycle.golden.test.ts.snap @@ -218,7 +218,7 @@ exports[`System Lifecycle Golden Tests > Scenario 2: Under Budget (No Modificati } `; -exports[`System Lifecycle Golden Tests > Scenario 3: Worker-Driven Background GC 1`] = ` +exports[`System Lifecycle Golden Tests > Scenario 3: Async-Driven Background GC 1`] = ` { "finalProjection": [ { diff --git a/packages/core/src/context/system-tests/lifecycle.golden.test.ts b/packages/core/src/context/system-tests/lifecycle.golden.test.ts index a1bc8ea195..12dde5b790 100644 --- a/packages/core/src/context/system-tests/lifecycle.golden.test.ts +++ b/packages/core/src/context/system-tests/lifecycle.golden.test.ts @@ -7,7 +7,7 @@ import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'; import { SimulationHarness } from './SimulationHarness.js'; import { createMockLlmClient } from '../testing/contextTestUtils.js'; -import type { ContextProfile } from '../sidecar/profiles.js'; +import type { ContextProfile } from '../config/profiles.js'; import { createToolMaskingProcessor } from '../processors/toolMaskingProcessor.js'; import { createBlobDegradationProcessor } from '../processors/blobDegradationProcessor.js'; import { createStateSnapshotProcessor } from '../processors/stateSnapshotProcessor.js'; @@ -61,7 +61,7 @@ describe('System Lifecycle Golden Tests', () => { buildAsyncPipelines: (env) => [{ name: 'Async', triggers: ['nodes_aged_out'], - processors: [createStateSnapshotAsyncProcessor('StateSnapshotWorker', env, {})] + processors: [createStateSnapshotAsyncProcessor('StateSnapshotAsyncProcessor', env, {})] }], }); @@ -180,7 +180,7 @@ describe('System Lifecycle Golden Tests', () => { expect(goldenState).toMatchSnapshot(); }); - it('Scenario 3: Worker-Driven Background GC', async () => { + it('Scenario 3: Async-Driven Background GC', async () => { const gcConfig: ContextProfile = { config: { budget: { maxTokens: 200, retainedTokens: 100 }, @@ -189,7 +189,7 @@ describe('System Lifecycle Golden Tests', () => { buildAsyncPipelines: (env) => [{ name: 'Async', triggers: ['nodes_aged_out'], - processors: [createStateSnapshotAsyncProcessor('StateSnapshotWorker', env, {})] + processors: [createStateSnapshotAsyncProcessor('StateSnapshotAsyncProcessor', env, {})] }], }; @@ -201,13 +201,13 @@ describe('System Lifecycle Golden Tests', () => { { role: 'model', parts: [{ text: 'B'.repeat(50) }] }, ]); - // Turn 1 (Should trigger StateSnapshotWorker because we exceed 100 retainedTokens) + // Turn 1 (Should trigger StateSnapshotasync pipeline because we exceed 100 retainedTokens) await harness.simulateTurn([ { role: 'user', parts: [{ text: 'C'.repeat(50) }] }, { role: 'model', parts: [{ text: 'D'.repeat(50) }] }, ]); - // Give the background worker an extra beat to complete its async execution and emit variants + // Give the async background pipeline an extra beat to complete its async execution and emit variants await new Promise((resolve) => setTimeout(resolve, 50)); // Turn 2 @@ -218,7 +218,7 @@ describe('System Lifecycle Golden Tests', () => { const goldenState = await harness.getGoldenState(); - // We should see ROLLING_SUMMARY nodes injected into the graph, proving the worker ran in the background + // We should see ROLLING_SUMMARY nodes injected into the graph, proving the async pipeline ran in the background expect(goldenState).toMatchSnapshot(); }); }); diff --git a/packages/core/src/context/testing/contextTestUtils.ts b/packages/core/src/context/testing/contextTestUtils.ts index 8f177c1f8d..5a4832d155 100644 --- a/packages/core/src/context/testing/contextTestUtils.ts +++ b/packages/core/src/context/testing/contextTestUtils.ts @@ -11,19 +11,19 @@ import { InMemoryFileSystem } from '../system/InMemoryFileSystem.js'; import { DeterministicIdGenerator } from '../system/DeterministicIdGenerator.js'; import { randomUUID } from 'node:crypto'; import { ContextTracer } from '../tracer.js'; -import { ContextEnvironmentImpl } from '../sidecar/environmentImpl.js'; -import { SidecarLoader } from '../sidecar/SidecarLoader.js'; -import { SidecarRegistry } from '../sidecar/registry.js'; +import { ContextEnvironmentImpl } from '../pipeline/environmentImpl.js'; +import { SidecarLoader } from '../config/SidecarLoader.js'; +import { SidecarRegistry } from '../config/registry.js'; import { ContextEventBus } from '../eventBus.js'; -import { PipelineOrchestrator } from '../sidecar/orchestrator.js'; +import { PipelineOrchestrator } from '../pipeline/orchestrator.js'; import type { ConcreteNode, ToolExecution } from '../ir/types.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import type { Config } from '../../config/config.js'; import type { BaseLlmClient } from '../../core/baseLlmClient.js'; import type { Content, GenerateContentResponse } from '@google/genai'; -import { InboxSnapshotImpl } from '../sidecar/inbox.js'; +import { InboxSnapshotImpl } from '../pipeline/inbox.js'; import type { InboxMessage, ProcessArgs } from '../pipeline.js'; -import type { ContextProfile } from '../sidecar/profiles.js'; +import type { ContextProfile } from '../config/profiles.js'; /** * Creates a valid mock GenerateContentResponse with the provided text. @@ -172,7 +172,7 @@ export function createMockEnvironment( * Creates a block of synthetic conversation history designed to consume a specific number of tokens. * Assumes roughly 4 characters per token for standard English text. */ -import { ContextWorkingBufferImpl } from '../sidecar/contextWorkingBuffer.js'; +import { ContextWorkingBufferImpl } from '../pipeline/contextWorkingBuffer.js'; export function createMockProcessArgs( targets: ConcreteNode[], @@ -239,7 +239,7 @@ export function createMockContextConfig( } /** - * Wires up a full ContextManager component with an AgentChatHistory and active background workers. + * Wires up a full ContextManager component with an AgentChatHistory and active background async pipelines. */ export function setupContextComponentTest( @@ -281,6 +281,6 @@ export function setupContextComponentTest( chatHistory, ); - // The async worker is now internally managed by ContextManager + // The async async pipeline is now internally managed by ContextManager return { chatHistory, contextManager }; } diff --git a/packages/core/src/context/testing/testProfile.ts b/packages/core/src/context/testing/testProfile.ts index 694f5e534e..2b372c211c 100644 --- a/packages/core/src/context/testing/testProfile.ts +++ b/packages/core/src/context/testing/testProfile.ts @@ -3,9 +3,9 @@ * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -import type { ContextProfile } from '../sidecar/profiles.js'; -import type { PipelineDef } from '../sidecar/types.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextProfile } from '../config/profiles.js'; +import type { PipelineDef } from '../config/types.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import { createHistoryTruncationProcessor } from '../processors/historyTruncationProcessor.js'; export const testTruncateProfile: ContextProfile = { diff --git a/packages/core/src/context/utils/snapshotGenerator.ts b/packages/core/src/context/utils/snapshotGenerator.ts index 20865e9863..0ee316a09a 100644 --- a/packages/core/src/context/utils/snapshotGenerator.ts +++ b/packages/core/src/context/utils/snapshotGenerator.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import type { ConcreteNode } from '../ir/types.js'; -import type { ContextEnvironment } from '../sidecar/environment.js'; +import type { ContextEnvironment } from '../pipeline/environment.js'; import { LlmRole } from '../../telemetry/llmRole.js'; export class SnapshotGenerator {