/** * v2.11.0 Group F (Tier 9) — D7: post-compact auto-resume detector. * * Per `.peaks/memory/2026-06-26-v2-11-post-compact-resume.md` §D7.a, * post-compact auto-resume triggers when ALL of the following hold: * * 1. `.peaks/_runtime//` is bound * 2. Latest checkpoint mtime is from today (UTC date) * 3. Latest checkpoint has a parseable `mode` field * 4. The peak-code skill is the active skill * 5. Exactly one session has a today's checkpoint (no ambiguity) * * On a hit, the LLM MUST auto-resume (D7.b override of "never silently * auto-resume") and emit a one-line log entry. On any miss, fall * through to the normal Step 0.7 flow. * * Karpathy §3: the detector is the only place that decides "is this * a post-compact resume?" — no inline `isPostCompact()` checks * scattered across SKILL.md or other services. * * IO: readdir + readFile on `.peaks/_runtime//checkpoints/`. * No writes (caller logs the decision via the auto-decisions channel). */ import { type SkillPresenceMode } from '../skills/skill-presence-service.js'; import { type CodeMode } from './mode-gate.js'; export type PostCompactResumeReason = 'post-compact-match' | 'sid-unbound' | 'runtime-dir-missing' | 'no-checkpoint-today' | 'no-mode-field' | 'stale-checkpoint' | 'multiple-checkpoints-ambiguous' | 'active-skill-mismatch' | 'checkpoint-read-failed'; export declare const POST_COMPACT_RESUME_REASONS: readonly PostCompactResumeReason[]; export interface PostCompactResumeProbe { readonly shouldAutoResume: boolean; readonly reason: PostCompactResumeReason; readonly mode?: CodeMode; readonly checkpointPath?: string; readonly checkpointMtime?: string; readonly task?: string; readonly openQuestions?: readonly string[]; readonly recentDecisions?: readonly string[]; readonly warnings: readonly string[]; } export interface DetectPostCompactResumeOptions { readonly sessionId: string; readonly projectRoot: string; /** Injectable clock for deterministic tests; defaults to `new Date()`. */ readonly now?: (() => Date) | undefined; /** Override the active-skill check (test seam; defaults to read presence). */ readonly activeSkill?: string | undefined; /** Override mode read from presence (test seam). */ readonly presenceModeOverride?: SkillPresenceMode | undefined; } /** * Detect whether the current invocation is a same-day post-compact * resume. The LLM-side caller invokes this in Step 0.7 / Step 0.75 * after anchoring. Pure-ish: only filesystem reads of the checkpoint * dir; no LLM calls. */ export declare function detectPostCompactResume(opts: DetectPostCompactResumeOptions): Promise; /** * One-line auto-decisions log entry. Pure formatter; no IO. The LLM * appends to `.peaks/_runtime//txt/auto-decisions.md` so * the existing audit channel picks it up (D7.e). */ export declare function formatPostCompactResumeLogLine(probe: PostCompactResumeProbe): string;