/** * Typed utilities for querying the commit log. * * The commitLog is an ordered array of CommitBundle — one per stage commit. * These helpers provide type-safe queries without (b: any) casts. */ import type { CommitBundle } from './types.js'; /** Find the first commit by stageId, optionally filtering by a written key. */ export declare function findCommit(commitLog: CommitBundle[], stageId: string, key?: string): CommitBundle | undefined; /** Find all commits by stageId. */ export declare function findCommits(commitLog: CommitBundle[], stageId: string): CommitBundle[]; /** Find the last commit that wrote a specific key (for backtracking). */ export declare function findLastWriter(commitLog: CommitBundle[], key: string, beforeIdx?: number): CommitBundle | undefined; /** * Reconstruct the FULL value of `key` as of commit array index `idx` * (inclusive) — the migration helper for the "read `bundle.overwrite[key]` * as the full value written" pattern (#13c-B). * * Under `commitValues: 'delta'`, an `append` bundle's `overwrite[key]` holds * only the TAIL of the array; this helper folds the verbs back together: * it scans `commitLog[0..idx]` for trace entries on `key`, anchors at the * latest full-value write (`set` — or `delete`, which resets to absent), and * replays forward (`append` → concat, `merge` → `deepSmartMerge`) — exactly * the per-key slice of `applySmartMerge`'s replay, O(key's commit span) * instead of a full `materialise()`. * * Works on full-mode logs too (every `set` is its own anchor — equivalent to * `findLastWriter(...).overwrite[key]`). * * @param key Matched against `TraceEntry.path` exactly (same contract as * `findLastWriter`) — DELIM-joined for nested paths. * @param idx CommitBundle ARRAY index (the `bundle.idx` position), * inclusive. NOT the executionIndex from a runtimeStageId. * @returns The reconstructed value (a detached clone), or `undefined` when * the key was never written in `commitLog[0..idx]` or its last write was a * delete. Caveat: values derived purely from the run's INITIAL state (no * `set` anchor in the log — e.g. merges onto a seeded key) fold from * absent; the commit log alone cannot see the pre-run base (the same blind * spot `findLastWriter` has). */ export declare function commitValueAt(commitLog: CommitBundle[], idx: number, key: string): unknown;