/** * Background NEXUS reindex after a merge into the base branch (T14010). * * The CLEO `post-merge` hook starts nothing unless the repository's git config * carries the {@link REINDEX_ON_MERGE_GIT_KEY} marker and HEAD is on the base * branch; both are checked in shell, so a disabled project pays no process * start on a merge or pull. `cleo nexus reindex-on-merge --enable` sets that * marker together with `nexus.reindexOnMerge.enabled`. * * When it runs, it is the lowest-priority heavy work on the machine: it never * joins the `cleo run` FIFO queue. It tries admission without waiting, only * when nothing is queued, and backs off between tries until its timeout * (default 300s), then records `deferred`. One runs at a time per project (a * lock file), and only real outcomes (ran, deferred, failed) are written to * `.cleo/nexus-reindex-on-merge.json` for `cleo nexus status`. * * Code placed in `packages/core/` per Package-Boundary Check — verified against AGENTS.md. * * @module nexus/reindex-on-merge * @task T14010 */ /** File under `.cleo/` holding the last real outcome (ran, deferred, failed). */ export declare const REINDEX_ON_MERGE_OUTCOME_FILE = "nexus-reindex-on-merge.json"; /** Lock file under `.cleo/`; holds the pid of the running reindex. */ export declare const REINDEX_ON_MERGE_LOCK_FILE = "nexus-reindex.lock"; /** Git config key the `post-merge` hook checks before starting anything. */ export declare const REINDEX_ON_MERGE_GIT_KEY = "cleo.nexusReindexOnMerge"; /** Default seconds to keep trying for admission before recording `deferred`. */ export declare const DEFAULT_REINDEX_TIMEOUT_SECONDS = 300; /** What a reindex-on-merge did. */ export interface ReindexOnMergeOutcome { /** `ran` (index refreshed), `skipped` (not recorded), `deferred` (machine busy) or `failed`. */ outcome: 'ran' | 'skipped' | 'deferred' | 'failed'; /** Why. */ reason: string; /** When it finished (ISO 8601). */ at: string; /** Wall-clock milliseconds. */ durationMs: number; } /** Result of one admission attempt. */ export interface ReindexRunResult { /** Exit code of `cleo run`, or `null` when it could not start. */ exitCode: number | null; /** Tail of its stderr, for the recorded reason. */ stderr: string; } /** One admission attempt of `cleo nexus analyze`; replaceable in tests. */ export type ReindexRunner = (projectRoot: string) => ReindexRunResult; /** Seams for tests: the attempt, the clock, the wait and the queue probe. */ export interface ReindexOnMergeDeps { /** One admission attempt (no `--wait`). */ runner?: ReindexRunner; /** Clock in milliseconds. */ now?: () => number; /** Wait between attempts. */ sleep?: (ms: number) => Promise; /** Whether any run is waiting in the `cleo run` queue. */ queueBusy?: () => boolean; } /** * Turn reindex-on-merge on or off: `nexus.reindexOnMerge.enabled` and the git * config marker the `post-merge` hook checks, together. * * @param projectRoot - Project to configure. * @param enabled - The new setting. * @example * ```ts * await setReindexOnMerge(root, true); * ``` */ export declare function setReindexOnMerge(projectRoot: string, enabled: boolean): Promise; /** * Reindex after a merge, when enabled, on the base branch, alone and admitted * at the lowest priority. Skips are returned, never recorded, so `nexus status` * keeps the last real outcome. * * @param projectRoot - Project whose index is refreshed. * @param deps - Test seams (attempt, clock, sleep, queue probe). * @returns The outcome. * @example * ```ts * const { outcome, reason } = await runReindexOnMerge(root); * ``` */ export declare function runReindexOnMerge(projectRoot: string, deps?: ReindexOnMergeDeps): Promise; /** * The last recorded reindex-on-merge outcome, for `cleo nexus status`. * * @param projectRoot - Project to read. * @returns The outcome, or `null` when none was recorded or it is unreadable. */ export declare function readReindexOnMergeOutcome(projectRoot: string): ReindexOnMergeOutcome | null; //# sourceMappingURL=reindex-on-merge.d.ts.map