last minute tidies

This commit is contained in:
Your Name
2026-04-09 15:41:15 +00:00
parent 46c20c6d6e
commit 10ef9a6876
9 changed files with 126 additions and 127 deletions
@@ -127,6 +127,44 @@ 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 { InboxSnapshotImpl } from '../sidecar/inbox.js';
import type { ContextWorkingBuffer, InboxMessage, ProcessArgs } from '../pipeline.js';
export class FakeContextWorkingBuffer implements ContextWorkingBuffer {
readonly nodes: readonly ConcreteNode[];
private readonly nodesById = new Map<string, ConcreteNode>();
private readonly nodesByEpisode = new Map<string, ConcreteNode[]>();
constructor(nodes: readonly ConcreteNode[]) {
this.nodes = nodes;
for (const node of nodes) {
this.nodesById.set(node.id, node);
const parentId = node.logicalParentId || 'orphan';
const epNodes = this.nodesByEpisode.get(parentId) || [];
epNodes.push(node);
this.nodesByEpisode.set(parentId, epNodes);
}
}
getPristineNode(id: string): ConcreteNode | undefined {
return this.nodesById.get(id);
}
getLineage(id: string): readonly ConcreteNode[] {
const node = this.nodesById.get(id);
if (!node) return [];
return this.nodesByEpisode.get(node.logicalParentId || 'orphan') || [];
}
}
export function createMockProcessArgs(targets: ConcreteNode[], bufferNodes: ConcreteNode[] = [], inboxMessages: InboxMessage[] = []): ProcessArgs {
return {
targets,
buffer: new FakeContextWorkingBuffer(bufferNodes.length ? bufferNodes : targets),
inbox: new InboxSnapshotImpl(inboxMessages),
};
}
export function createSyntheticHistory(
numTurns: number,
tokensPerTurn: number,