From 9287159cccf19af30d79df1ca488f0eaac62860b Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 8 Apr 2026 20:44:56 +0000 Subject: [PATCH] lints --- packages/core/src/context/contextManager.ts | 8 ++++---- packages/core/src/context/eventBus.ts | 6 +++--- packages/core/src/context/historyObserver.ts | 2 +- packages/core/src/context/ir/projector.ts | 2 +- packages/core/src/context/ir/toIr.ts | 6 +++--- packages/core/src/context/pipeline.ts | 2 +- .../processors/blobDegradationProcessor.test.ts | 5 +++++ .../processors/blobDegradationProcessor.ts | 9 +++++++-- .../processors/emergencyTruncationProcessor.ts | 2 +- .../processors/historySquashingProcessor.test.ts | 5 +++++ .../processors/historySquashingProcessor.ts | 13 +++++++++---- .../semanticCompressionProcessor.test.ts | 5 +++++ .../processors/semanticCompressionProcessor.ts | 13 +++++++++---- .../processors/stateSnapshotProcessor.test.ts | 5 +++++ .../context/processors/stateSnapshotProcessor.ts | 9 +++++++-- .../processors/toolMaskingProcessor.test.ts | 5 +++++ .../context/processors/toolMaskingProcessor.ts | 9 +++++++-- packages/core/src/context/sidecar/builtins.ts | 7 ++++++- packages/core/src/context/sidecar/inbox.ts | 11 ++++++++--- .../core/src/context/sidecar/orchestrator.ts | 16 ++++++++-------- packages/core/src/context/sidecar/testProfile.ts | 5 +++++ .../src/context/utils/contextTokenCalculator.ts | 2 +- 22 files changed, 106 insertions(+), 41 deletions(-) diff --git a/packages/core/src/context/contextManager.ts b/packages/core/src/context/contextManager.ts index 20040239c3..7e41fdcde1 100644 --- a/packages/core/src/context/contextManager.ts +++ b/packages/core/src/context/contextManager.ts @@ -20,8 +20,8 @@ import { ProcessorRegistry } from './sidecar/registry.js'; export class ContextManager { // The stateful, pristine flat graph. - private pristineShip: ReadonlyArray = []; - private currentShip: ReadonlyArray = []; + private pristineShip: readonly ConcreteNode[] = []; + private currentShip: readonly ConcreteNode[] = []; private readonly eventBus: ContextEventBus; // Internal sub-components @@ -154,7 +154,7 @@ export class ContextManager { * Useful for internal tool rendering (like the trace viewer). * Note: This is an expensive, deep clone operation. */ - getPristineGraph(): ReadonlyArray { + getPristineGraph(): readonly ConcreteNode[] { return [...this.pristineShip]; } @@ -163,7 +163,7 @@ export class ContextManager { * up to the configured token budget. * This is the view that will eventually be projected back to the LLM. */ - getShip(): ReadonlyArray { + getShip(): readonly ConcreteNode[] { return [...this.currentShip]; } diff --git a/packages/core/src/context/eventBus.ts b/packages/core/src/context/eventBus.ts index 9b7d3c7729..1507b09457 100644 --- a/packages/core/src/context/eventBus.ts +++ b/packages/core/src/context/eventBus.ts @@ -8,18 +8,18 @@ import { EventEmitter } from 'node:events'; import type { ConcreteNode } from './ir/types.js'; export interface PristineHistoryUpdatedEvent { - ship: ReadonlyArray; + ship: readonly ConcreteNode[]; newNodes: Set; } export interface ContextConsolidationEvent { - ship: ReadonlyArray; + ship: readonly ConcreteNode[]; targetDeficit: number; targetNodeIds: Set; } export interface IrChunkReceivedEvent { - ship: ReadonlyArray; + ship: readonly ConcreteNode[]; targetNodeIds: Set; } diff --git a/packages/core/src/context/historyObserver.ts b/packages/core/src/context/historyObserver.ts index bcb87a5bbb..c92b343e33 100644 --- a/packages/core/src/context/historyObserver.ts +++ b/packages/core/src/context/historyObserver.ts @@ -45,7 +45,7 @@ export class HistoryObserver { this.tokenCalculator, ); - const ship: import('./ir/types.js').ConcreteNode[] = []; + const ship: Array = []; for (const ep of pristineEpisodes) { if (ep.concreteNodes) { for (const child of ep.concreteNodes) { diff --git a/packages/core/src/context/ir/projector.ts b/packages/core/src/context/ir/projector.ts index c281a08c85..757eeb504c 100644 --- a/packages/core/src/context/ir/projector.ts +++ b/packages/core/src/context/ir/projector.ts @@ -21,7 +21,7 @@ export class IrProjector { * applies the Immediate Sanitization pipeline, and enforces token boundaries. */ static async project( - ship: ReadonlyArray, + ship: readonly ConcreteNode[], orchestrator: PipelineOrchestrator, sidecar: SidecarConfig, tracer: ContextTracer, diff --git a/packages/core/src/context/ir/toIr.ts b/packages/core/src/context/ir/toIr.ts index 5e72aedeaa..4c8b2b747c 100644 --- a/packages/core/src/context/ir/toIr.ts +++ b/packages/core/src/context/ir/toIr.ts @@ -159,7 +159,7 @@ function parseToolResponses( if (callId) pendingCallParts.delete(callId); } } - return currentEpisode as Partial; + return currentEpisode; } function parseUserParts( @@ -231,7 +231,7 @@ function parseModelParts( ]; } } - return currentEpisode as Partial; + return currentEpisode; } function finalizeYield(currentEpisode: Partial) { @@ -247,7 +247,7 @@ function finalizeYield(currentEpisode: Partial) { }, }; const existingNodes = - currentEpisode.concreteNodes as import('./types.js').ConcreteNode[]; + currentEpisode.concreteNodes as Array; currentEpisode.concreteNodes = [...existingNodes, yieldNode]; } } diff --git a/packages/core/src/context/pipeline.ts b/packages/core/src/context/pipeline.ts index 12fc59808c..70a700f3ee 100644 --- a/packages/core/src/context/pipeline.ts +++ b/packages/core/src/context/pipeline.ts @@ -54,7 +54,7 @@ export interface ContextWorker { onInboxTopics?: string[]; }; execute(args: { - targets: ReadonlyArray; + targets: readonly ConcreteNode[]; inbox: InboxSnapshot; }): Promise; } diff --git a/packages/core/src/context/processors/blobDegradationProcessor.test.ts b/packages/core/src/context/processors/blobDegradationProcessor.test.ts index 7bd0cb11a6..09d538a722 100644 --- a/packages/core/src/context/processors/blobDegradationProcessor.test.ts +++ b/packages/core/src/context/processors/blobDegradationProcessor.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import { describe, it, expect, vi } from 'vitest'; import { BlobDegradationProcessor } from './blobDegradationProcessor.js'; import { diff --git a/packages/core/src/context/processors/blobDegradationProcessor.ts b/packages/core/src/context/processors/blobDegradationProcessor.ts index 566048678d..442fb9bb6a 100644 --- a/packages/core/src/context/processors/blobDegradationProcessor.ts +++ b/packages/core/src/context/processors/blobDegradationProcessor.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import type { ProcessArgs, ContextProcessor } from '../pipeline.js'; import type { ConcreteNode, UserPrompt } from '../ir/types.js'; import type { ContextEnvironment } from '../sidecar/environment.js'; @@ -22,7 +27,7 @@ export class BlobDegradationProcessor implements ContextProcessor { this.env = env; } - async process({ targets, state }: ProcessArgs): Promise> { + async process({ targets, state }: ProcessArgs): Promise { if (state.isBudgetSatisfied) { return targets; } @@ -58,7 +63,7 @@ export class BlobDegradationProcessor implements ContextProcessor { continue; } - const prompt = node as UserPrompt; + const prompt = node; let modified = false; const newParts = [...prompt.semanticParts]; diff --git a/packages/core/src/context/processors/emergencyTruncationProcessor.ts b/packages/core/src/context/processors/emergencyTruncationProcessor.ts index cf4e38b8db..aa1fb176e3 100644 --- a/packages/core/src/context/processors/emergencyTruncationProcessor.ts +++ b/packages/core/src/context/processors/emergencyTruncationProcessor.ts @@ -50,7 +50,7 @@ export class EmergencyTruncationProcessor implements ContextProcessor { async process({ targets, state, - }: ProcessArgs): Promise> { + }: ProcessArgs): Promise { // Calculate how many tokens we need to remove based on the configured knob let targetTokensToRemove = 0; const strategy = this.options.target ?? 'max'; diff --git a/packages/core/src/context/processors/historySquashingProcessor.test.ts b/packages/core/src/context/processors/historySquashingProcessor.test.ts index 5b195c1aca..ec7afe07a8 100644 --- a/packages/core/src/context/processors/historySquashingProcessor.test.ts +++ b/packages/core/src/context/processors/historySquashingProcessor.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import { describe, it, expect, vi } from 'vitest'; import { HistorySquashingProcessor } from './historySquashingProcessor.js'; import { diff --git a/packages/core/src/context/processors/historySquashingProcessor.ts b/packages/core/src/context/processors/historySquashingProcessor.ts index 9d1624f0b0..e390048f91 100644 --- a/packages/core/src/context/processors/historySquashingProcessor.ts +++ b/packages/core/src/context/processors/historySquashingProcessor.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import type { ContextProcessor, ProcessArgs } from '../pipeline.js'; import type { ContextEnvironment } from '../sidecar/environment.js'; import { truncateProportionally } from '../truncation.js'; @@ -67,7 +72,7 @@ export class HistorySquashingProcessor implements ContextProcessor { return null; } - async process({ targets, state }: ProcessArgs): Promise> { + async process({ targets, state }: ProcessArgs): Promise { if (state.isBudgetSatisfied) { return targets; } @@ -86,7 +91,7 @@ export class HistorySquashingProcessor implements ContextProcessor { // 1. Squash User Prompts if (node.type === 'USER_PROMPT') { - const prompt = node as UserPrompt; + const prompt = node; let modified = false; const newParts = [...prompt.semanticParts]; @@ -126,7 +131,7 @@ export class HistorySquashingProcessor implements ContextProcessor { // 2. Squash Model Thoughts if (node.type === 'AGENT_THOUGHT') { - const thought = node as AgentThought; + const thought = node; const squashResult = this.tryApplySquash(thought.text, limitChars, currentDeficit); if (squashResult) { @@ -152,7 +157,7 @@ export class HistorySquashingProcessor implements ContextProcessor { // 3. Squash Agent Yields if (node.type === 'AGENT_YIELD') { - const agentYield = node as AgentYield; + const agentYield = node; const squashResult = this.tryApplySquash(agentYield.text, limitChars, currentDeficit); if (squashResult) { diff --git a/packages/core/src/context/processors/semanticCompressionProcessor.test.ts b/packages/core/src/context/processors/semanticCompressionProcessor.test.ts index cf7209956d..dc482d8653 100644 --- a/packages/core/src/context/processors/semanticCompressionProcessor.test.ts +++ b/packages/core/src/context/processors/semanticCompressionProcessor.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import { describe, it, expect, vi } from 'vitest'; import { SemanticCompressionProcessor } from './semanticCompressionProcessor.js'; import { diff --git a/packages/core/src/context/processors/semanticCompressionProcessor.ts b/packages/core/src/context/processors/semanticCompressionProcessor.ts index 71c97f0d48..98cd9c0ded 100644 --- a/packages/core/src/context/processors/semanticCompressionProcessor.ts +++ b/packages/core/src/context/processors/semanticCompressionProcessor.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import type { ContextProcessor, ProcessArgs } from '../pipeline.js'; import type { ContextEnvironment } from '../sidecar/environment.js'; import { debugLogger } from '../../utils/debugLogger.js'; @@ -74,7 +79,7 @@ export class SemanticCompressionProcessor implements ContextProcessor { } } - async process({ targets, state }: ProcessArgs): Promise> { + async process({ targets, state }: ProcessArgs): Promise { if (state.isBudgetSatisfied) { return targets; } @@ -95,7 +100,7 @@ export class SemanticCompressionProcessor implements ContextProcessor { // 1. Compress User Prompts if (node.type === 'USER_PROMPT') { - const prompt = node as UserPrompt; + const prompt = node; let modified = false; const newParts = [...prompt.semanticParts]; @@ -140,7 +145,7 @@ export class SemanticCompressionProcessor implements ContextProcessor { // 2. Compress Model Thoughts if (node.type === 'AGENT_THOUGHT') { - const thought = node as AgentThought; + const thought = node; if (thought.text.length > thresholdChars) { const summary = await this.generateSummary(thought.text, 'Agent Thought'); const newTokens = this.env.tokenCalculator.estimateTokensForParts([{ text: summary }]); @@ -171,7 +176,7 @@ export class SemanticCompressionProcessor implements ContextProcessor { // 3. Compress Tool Observations if (node.type === 'TOOL_EXECUTION') { - const tool = node as ToolExecution; + const tool = node; const rawObs = tool.observation; let stringifiedObs = ''; diff --git a/packages/core/src/context/processors/stateSnapshotProcessor.test.ts b/packages/core/src/context/processors/stateSnapshotProcessor.test.ts index bc7453482b..c795361f4e 100644 --- a/packages/core/src/context/processors/stateSnapshotProcessor.test.ts +++ b/packages/core/src/context/processors/stateSnapshotProcessor.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import { describe, it, expect } from 'vitest'; import { StateSnapshotProcessor } from './stateSnapshotProcessor.js'; import { diff --git a/packages/core/src/context/processors/stateSnapshotProcessor.ts b/packages/core/src/context/processors/stateSnapshotProcessor.ts index 57df8e9b6f..032fe80f1d 100644 --- a/packages/core/src/context/processors/stateSnapshotProcessor.ts +++ b/packages/core/src/context/processors/stateSnapshotProcessor.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import type { ContextProcessor, ProcessArgs, BackstopTargetOptions, ContextWorker } from '../pipeline.js'; import type { ContextEnvironment } from '../sidecar/environment.js'; import type { ConcreteNode, Snapshot } from '../ir/types.js'; @@ -32,7 +37,7 @@ export class StateSnapshotProcessor implements ContextProcessor, ContextWorker { } // --- ContextWorker Interface (Proactive Accumulation) --- - async execute({ targets, inbox }: { targets: ReadonlyArray; inbox: import('../pipeline.js').InboxSnapshot }): Promise { + async execute({ targets, inbox }: { targets: readonly ConcreteNode[]; inbox: import('../pipeline.js').InboxSnapshot }): Promise { // We only care about nodes that have aged out past retainedTokens // To calculate this precisely, we'd need the ContextAccountingState, but for V0 @@ -46,7 +51,7 @@ export class StateSnapshotProcessor implements ContextProcessor, ContextWorker { } // --- ContextProcessor Interface (Sync Backstop / Cache Application) --- - async process({ targets, state, inbox }: ProcessArgs): Promise> { + async process({ targets, state, inbox }: ProcessArgs): Promise { if (state.isBudgetSatisfied) { return targets; } diff --git a/packages/core/src/context/processors/toolMaskingProcessor.test.ts b/packages/core/src/context/processors/toolMaskingProcessor.test.ts index 690eb0fe29..5c09da0d1f 100644 --- a/packages/core/src/context/processors/toolMaskingProcessor.test.ts +++ b/packages/core/src/context/processors/toolMaskingProcessor.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import { describe, it, expect, vi } from 'vitest'; import { ToolMaskingProcessor } from './toolMaskingProcessor.js'; import { diff --git a/packages/core/src/context/processors/toolMaskingProcessor.ts b/packages/core/src/context/processors/toolMaskingProcessor.ts index 496eb8c96b..fb866886f9 100644 --- a/packages/core/src/context/processors/toolMaskingProcessor.ts +++ b/packages/core/src/context/processors/toolMaskingProcessor.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import type { ContextProcessor, ProcessArgs } from '../pipeline.js'; import type { ConcreteNode, ToolExecution } from '../ir/types.js'; import type { ContextEnvironment } from '../sidecar/environment.js'; @@ -91,7 +96,7 @@ export class ToolMaskingProcessor implements ContextProcessor { return text.includes(''); } - async process({ targets, state }: ProcessArgs): Promise> { + async process({ targets, state }: ProcessArgs): Promise { const maskingConfig = this.options; if (!maskingConfig) return targets; if (state.isBudgetSatisfied) return targets; @@ -148,7 +153,7 @@ export class ToolMaskingProcessor implements ContextProcessor { continue; } - const step = node as ToolExecution; + const step = node; const toolName = step.toolName; if (toolName && UNMASKABLE_TOOLS.has(toolName)) { returnedNodes.push(node); diff --git a/packages/core/src/context/sidecar/builtins.ts b/packages/core/src/context/sidecar/builtins.ts index 6d998a59ff..3dd2f651f6 100644 --- a/packages/core/src/context/sidecar/builtins.ts +++ b/packages/core/src/context/sidecar/builtins.ts @@ -1,4 +1,9 @@ -import { ProcessorRegistry } from './registry.js'; +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ +import type { ProcessorRegistry } from './registry.js'; import { EmergencyTruncationProcessor, type EmergencyTruncationProcessorOptions } from '../processors/emergencyTruncationProcessor.js'; import { BlobDegradationProcessor } from '../processors/blobDegradationProcessor.js'; import { HistorySquashingProcessor, type HistorySquashingProcessorOptions } from '../processors/historySquashingProcessor.js'; diff --git a/packages/core/src/context/sidecar/inbox.ts b/packages/core/src/context/sidecar/inbox.ts index faf18c10ce..828cf6b31c 100644 --- a/packages/core/src/context/sidecar/inbox.ts +++ b/packages/core/src/context/sidecar/inbox.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import type { InboxMessage, InboxSnapshot } from '../pipeline.js'; export class LiveInbox { @@ -12,7 +17,7 @@ export class LiveInbox { }); } - getMessages(): ReadonlyArray { + getMessages(): readonly InboxMessage[] { return [...this.messages]; } @@ -22,10 +27,10 @@ export class LiveInbox { } export class InboxSnapshotImpl implements InboxSnapshot { - private messages: ReadonlyArray; + private messages: readonly InboxMessage[]; private consumedIds = new Set(); - constructor(messages: ReadonlyArray) { + constructor(messages: readonly InboxMessage[]) { this.messages = messages; } diff --git a/packages/core/src/context/sidecar/orchestrator.ts b/packages/core/src/context/sidecar/orchestrator.ts index e552b621ab..ec4e267d8a 100644 --- a/packages/core/src/context/sidecar/orchestrator.ts +++ b/packages/core/src/context/sidecar/orchestrator.ts @@ -58,7 +58,7 @@ export class PipelineOrchestrator { const instance = factory.create( this.env, procDef.options || {}, - ) as ContextProcessor; + ); this.instantiatedProcessors.set(procDef.processorId, instance); } } @@ -153,10 +153,10 @@ export class PipelineOrchestrator { } applyProcessorDiff( - ship: ReadonlyArray, - targets: ReadonlyArray, - returnedNodes: ReadonlyArray, - ): ReadonlyArray { + ship: readonly ConcreteNode[], + targets: readonly ConcreteNode[], + returnedNodes: readonly ConcreteNode[], + ): readonly ConcreteNode[] { const mutableShip = [...ship]; const targetSet = new Set(targets.map((n) => n.id)); const returnedMap = new Map(returnedNodes.map((n) => [n.id, n])); @@ -204,10 +204,10 @@ export class PipelineOrchestrator { async executeTriggerSync( trigger: PipelineTrigger, - ship: ReadonlyArray, + ship: readonly ConcreteNode[], triggerTargets: ReadonlySet, state: ContextAccountingState, - ): Promise> { + ): Promise { let currentShip = ship; const pipelines = this.config.pipelines.filter((p) => p.triggers.includes(trigger), @@ -262,7 +262,7 @@ export class PipelineOrchestrator { private async executePipelineAsync( pipeline: PipelineDef, - ship: ReadonlyArray, + ship: readonly ConcreteNode[], triggerTargets: Set, state: ContextAccountingState, ) { diff --git a/packages/core/src/context/sidecar/testProfile.ts b/packages/core/src/context/sidecar/testProfile.ts index 7ba1cd9088..60ca215c11 100644 --- a/packages/core/src/context/sidecar/testProfile.ts +++ b/packages/core/src/context/sidecar/testProfile.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ import type { SidecarConfig } from './types.js'; export const testTruncateProfile: SidecarConfig = { diff --git a/packages/core/src/context/utils/contextTokenCalculator.ts b/packages/core/src/context/utils/contextTokenCalculator.ts index fa25980cc4..d8b6a20b14 100644 --- a/packages/core/src/context/utils/contextTokenCalculator.ts +++ b/packages/core/src/context/utils/contextTokenCalculator.ts @@ -36,7 +36,7 @@ export class ContextTokenCalculator { * Calculates the total token count for a flat array of ConcreteNodes (The Ship). * This is fast because it relies on pre-computed metadata where available. */ - calculateConcreteListTokens(ship: ReadonlyArray): number { + calculateConcreteListTokens(ship: readonly ConcreteNode[]): number { let tokens = 0; for (const node of ship) { tokens += node.metadata.currentTokens;