/** * Per-session projection facts: what this plugin cannot re-derive from the * session's derived history, tracked in memory for the plugin's lifetime. * * - `cacheEvidence` records that a model call reported cache-read tokens, which * only the `assistant/message` event carries: `AssistantMessage` has no * `usage` field, so no derived-history read can answer it. It is observed as * events commit and deliberately not persisted: after a plugin restart the * first refinement of a resumed session uses the layered summary (Route B) * until a cache-read message lands. That is the documented, correctness-neutral * cost of keeping this plugin free of log scans and extra files. * - `harnessStateSeq` is the sequence of the block this plugin wrote, the fast * path for shadowing it in place. When it is unknown — a block written before * this process started, an upgraded plugin, a fresh store — the block is * located from current surface state instead (see {@link harnessStateSeqToReplace}). * * dsh 0.1.7 prohibits new synchronous history reads * (`snapshotEvents`/`eventAt`/`ownEvents`); nothing here reads the log. * @module dsh-continual-harness */ import type { Context } from '@deepseek-ai/cordis'; import type { Session, SessionSeq } from '@deepseek-ai/dsh-session'; import type { HarnessStore } from './store.ts'; /** Facts tracked per session; each field is latest-wins or monotonic. */ export interface SessionProjectionState { /** Sequence of this plugin's harness-state block, latest observed. */ harnessStateSeq?: number; /** Set once a recorded model call reported cache-read tokens. */ cacheEvidence?: true; } /** * Register the incremental observer. Every committed event flows through one * listener that writes only on change, so the steady-state cost is a comparison * per event. */ export declare function registerSessionProjectionObserver(ctx: Context, store: HarnessStore): void; /** True when a recorded model call in this session reported cache-read tokens. */ export declare function hasSessionCacheEvidence(session: Session, store: HarnessStore): boolean; /** * The sequence an update must shadow, or undefined when the session holds no * visible harness-state block. * * Fast path: the sequence tracked as the block committed. * * Fallback: locate it from current surface state. The node list and the derived * history describe the same surface in the same order, so the two arrays are * index-aligned exactly when they have equal length — they differ only if a * surface event derived to no message, and only an empty-content * system/developer/assistant message does that. Equal length therefore proves * that index `i` of one array is the same event as index `i` of the other, * which covers a block written before this process started without a log scan. */ export declare function harnessStateSeqToReplace(session: Session, store: HarnessStore): SessionSeq | undefined; //# sourceMappingURL=session-state.d.ts.map