import type { CortexStore } from '../db/store.js'; import { computeRootCensus, type RootCensus } from './census.js'; import { type DigestCache } from './digest.js'; export interface ReadArgs { file: string; lines?: string; /** * Per-batch digest memo. Supplied by the spool flush so one file is hashed * once per batch; absent for one-off calls, which hash directly. */ digestCache?: DigestCache; /** * The hot path replaced this read's output (Story 4.5). Set only by the spool * replay, from the `subst` field the PostToolUse hook writes onto the read * line. Optional and defaulting to false, so the three other callers — * `cli log read`, `hook-entry postToolUse`, and direct use — are unchanged. */ substituted?: boolean; /** * Whether the digest recorded for this read will describe the bytes the read * RETURNED — see `ParsedContentDigest.refundEligible`. Defaults to true, * which is correct for direct callers (digest computed at event time); the * spool flush passes its batch pre-pass verdict. */ refundEligible?: boolean; } export interface EditArgs { file: string; lines?: string; } export interface WriteArgs { file: string; } export interface CmdArgs { exit?: string; cmd?: string; stdout?: string; stderr?: string; } export interface AgentArgs { desc: string; } /** * Parse a "start-end" line range string into discrete fields. * Returns an empty object if lines is undefined or unparseable. */ export declare function parseLineRange(lines?: string): { line_start?: number; line_end?: number; }; export declare function handleReadEvent(store: CortexStore, sessionId: string, args: ReadArgs): void; export interface SearchCaptureDeps { census: typeof computeRootCensus; /** Flush-time HEAD of the recording worktree; null when unresolvable. */ headOid: (worktreePath: string) => string | null; /** * Which of `paths` git ignores, relative to `worktreePath`. Returns null when * the question cannot be answered (no git, error) — which must be treated as * "not ignored", never as "ignored". */ ignored: (worktreePath: string, paths: string[]) => Set | null; } export interface SearchArgs { pattern: string; /** Raw, as the tool reported it: '' (the scope root) or an absolute path. */ root: string; glob?: string; type?: string; caseInsensitive?: boolean; multiline?: boolean; /** * The flush pre-pass's verdict (`computeSearchEligibility`): nothing after * this search in its batch could have rewritten the tree under its root. * False means NOTHING is recorded — an uncertifiable negative has no * consumer and a stored one would assert about a tree the search never saw. */ certified: boolean; deps?: SearchCaptureDeps; /** Per-batch memo (see `createSearchCaptureCache`). */ cache?: SearchCaptureCache; } /** * Per-flush memo for the two expensive, batch-invariant facts: the worktree's * HEAD (one `git` spawn) and a root's census (a full walk). Both were computed * once per certified search inside the flush's write transaction, so N searches * over one root cost N walks and N spawns while holding the SQLite write lock. * Created per batch and discarded with it, exactly like the digest cache — a * module-level cache would serve a stale fingerprint for the life of the * process. */ export interface SearchCaptureCache { heads: Map; censuses: Map; ignored: Map | null>; } export declare function createSearchCaptureCache(): SearchCaptureCache; /** * Record a certified zero-result search as a negative-cache entry (FR-12, * Story 4.3). Deliberately writes NO `events` row: the negative record is the * durable artifact, and a new event type would leak into branch-snapshot * summaries and session tails this story has no license to change. * * Every exit is silent (AD-12): this runs on the capture path, where a memory * failure must never break the turn. The gates, in order — certification * (computed by the flush, which can see the whole batch), the certifiability * class (`isCertifiableSearch`: patterns that cannot be an invalid regex, so * a pre-2.1.208 host's zero-shaped error response can never record a negative * for a search that never ran), root resolution (scope-relative or the scope * root itself; a root outside the scope or an unresolvable scope root records * nothing — never a cwd-anchored walk), then the census at the environment * ceilings. The stored pattern is redacted (people grep for secrets; PRD * §11.1 routes negative-result capture through the existing redaction) while * the KEY hashes the raw pattern, so distinct secret-bearing searches stay * distinct without the secret persisting. */ export declare function handleSearchEvent(store: CortexStore, sessionId: string, args: SearchArgs): void; /** * Record a file-edit event. */ export declare function handleEditEvent(store: CortexStore, sessionId: string, args: EditArgs): void; /** * Record a file-write event. */ export declare function handleWriteEvent(store: CortexStore, sessionId: string, args: WriteArgs): void; /** * Record a command-execution event with classification and redaction. */ export declare function handleCmdEvent(store: CortexStore, sessionId: string, args: CmdArgs): void; /** * Record a sub-agent delegation event. */ export declare function handleAgentEvent(store: CortexStore, sessionId: string, args: AgentArgs): void; //# sourceMappingURL=hooks.d.ts.map