/** * hmem v2 — Chunk 6c: checkpoint-pipeline orchestration core. * * Ties Chunk 6a (segment selection) + 6b (extraction agent) together and is the * function the CLI handler (`src/cli-v2-checkpoint.ts`) calls once the v2 store is * open. After this chunk, `hmem v2-checkpoint` does real work. * * Pipeline (one pass per invocation): * 1. Resolve the current session's project (open binding). No project → no-op. * 2. Gate (`shouldRunV2Extraction`): run iff `checkpointMode === 'auto'` OR a * free `claude -p` extraction route exists. `checkpointMode` has only two * values today (`'remind' | 'auto'`) — there is NO explicit off/never value, * so there is nothing to early-return for. Gate fails → no-op. * 3. Select eligible segments (6a). Empty → no-op. * 4. For each segment, fetch its unextracted events. * 5. DETERMINISTIC summary-refresh + marker (BEFORE the LLM call): * - Refresh `sessions.summary` via `fallbackSummarize` (cheap, no network) * for every segment that is NOT the current OPEN segment. The live * summarizer owns the current open segment's summary — refreshing it * would clobber. * - Write the `segment_extractions` marker (UPSERT, `last_extracted_seq = * toSeqInclusive`) REGARDLESS of the LLM outcome — so a transient Haiku * failure never causes perpetual re-processing of the same segments. * 6. ONE best-effort agent call (6b) for ALL selected segments together. A * throw is logged and swallowed — never propagated. * * The whole pass (deterministic refresh + agent) is gated together (spec: a * future "always deterministically refresh" split is out of scope for 6c). */ import type { HmemConfig } from '../hmem-config.js'; import type { V2Store } from './store-facade.js'; import { type RunExtractionOptions } from './checkpoint-agent.js'; import { type ExtractionPathProbes } from '../cli-checkpoint-agent.js'; /** Options for {@link runV2Checkpoint}. */ export interface RunV2CheckpointOptions extends RunExtractionOptions { /** * Probes for the FREE-path gate (`hasFreeExtractionPath`). Injectable in tests * so the gate decision can be forced without env manipulation. Distinct from * `opts.probes`, which the agent runner uses for its own spawn-vs-noop routing. */ gateProbes?: ExtractionPathProbes; } /** * The whole-pass gate. The v2 extraction pass runs iff: * - `checkpointMode === 'auto'` (user explicitly opted into auto-extraction), OR * - a FREE `claude -p` extraction route exists (default-on-when-free, D0324). * * `checkpointMode` allowed values are only `'remind' | 'auto'` (see hmem-config.ts) — * there is no off/never value, so nothing is early-returned for an explicit disable. */ export declare function shouldRunV2Extraction(config: HmemConfig, gateProbes?: ExtractionPathProbes): boolean; /** * Run one checkpoint-extraction pass for the current session. * * @param store an OPEN v2 store (the agent runner may close it on the * real spawn path; the test seam keeps it open). * @param currentSessionId the active session whose open binding defines "current". * @param config hmem config (gate + cadence + prompt schema). * @param hmemPath absolute path to the .hmem file (for MCP config build). * @param opts optional test seams (agent `invoke`, gate/agent probes). */ export declare function runV2Checkpoint(store: V2Store, currentSessionId: string, config: HmemConfig, hmemPath: string, opts?: RunV2CheckpointOptions): Promise;