chore(context): remove dead initialization trigger and unawaited promise

This commit is contained in:
Your Name
2026-05-13 00:54:24 +00:00
parent cdd482c2e0
commit 78a0e5d457
9 changed files with 309 additions and 4 deletions
@@ -7,7 +7,6 @@
import type { ContextProcessor, AsyncContextProcessor } from '../pipeline.js';
export type PipelineTrigger =
| 'initialization'
| 'new_message'
| 'retained_exceeded'
| 'gc_backstop'
+1 -1
View File
@@ -437,7 +437,7 @@ export class ContextManager {
return SnapshotStateHelper.exportState(this.buffer.nodes);
}
async restoreState(state: ContextEngineState): Promise<void> {
restoreState(state: ContextEngineState): void {
if (!state) return;
SnapshotStateHelper.restoreState(state, this.env.inbox);
}
@@ -90,6 +90,9 @@ export function createStateSnapshotProcessor(
const isValid = consumedIds.every((id) => targetIds.has(id));
if (isValid) {
debugLogger.log(
`[StateSnapshotProcessor] Successfully spliced PROPOSED_SNAPSHOT from Inbox into Graph. Consumed ${consumedIds.length} nodes.`,
);
// If valid, apply it!
const newId = randomUUID();
@@ -120,6 +123,10 @@ export function createStateSnapshotProcessor(
inbox.consume(proposed.id);
return returnedNodes;
} else {
debugLogger.log(
`[StateSnapshotProcessor] Rejected PROPOSED_SNAPSHOT from Inbox because one or more target IDs were missing from the current graph window.`,
);
}
}
}
@@ -82,12 +82,21 @@ export function findLatestSnapshotBaseline(
import type { LiveInbox } from '../pipeline/inbox.js';
import type { ContextEngineState } from '../../services/chatRecordingTypes.js';
import { debugLogger } from '../../utils/debugLogger.js';
export const SnapshotStateHelper = {
exportState(nodes: readonly ConcreteNode[]): ContextEngineState {
const baseline = findLatestSnapshotBaseline(nodes);
if (!baseline) return {};
if (!baseline) {
debugLogger.log(
'[SnapshotStateHelper] exportState: No snapshot baseline found in current nodes.',
);
return {};
}
debugLogger.log(
`[SnapshotStateHelper] exportState: Exporting snapshot ID ${baseline.id} representing ${baseline.abstractsIds.length} consumed nodes.`,
);
return {
snapshot: {
text: baseline.text,
@@ -98,18 +107,30 @@ export const SnapshotStateHelper = {
},
restoreState(state: ContextEngineState, inbox: LiveInbox): void {
if (!state.snapshot) return;
if (!state.snapshot) {
debugLogger.log(
'[SnapshotStateHelper] restoreState: No snapshot found in provided ContextEngineState.',
);
return;
}
if (
typeof state.snapshot.text === 'string' &&
Array.isArray(state.snapshot.consumedIds)
) {
debugLogger.log(
`[SnapshotStateHelper] restoreState: Publishing hydrated snapshot to LiveInbox with ${state.snapshot.consumedIds.length} consumed IDs.`,
);
inbox.publish('PROPOSED_SNAPSHOT', {
newText: state.snapshot.text,
consumedIds: state.snapshot.consumedIds,
type: 'accumulate',
timestamp: state.snapshot.timestamp ?? Date.now(),
});
} else {
debugLogger.log(
'[SnapshotStateHelper] restoreState: Invalid snapshot structural format.',
);
}
},
};