/** * Background index repair service (changes: add-zero-interaction-onboarding → * make-index-self-healing). * * Originally the cold-start self-bootstrap: if an agent wired the OpenLore MCP * server but never ran `openlore install`, the very first session had no index * and every tool returned "run analyze first." That warmed an ABSENT index once, * in the background. * * `make-index-self-healing` generalizes it: every read-path staleness signal that * today only produces a warning (integrity `mismatched`, an over-threshold stale * region, a schema reset, an aged analysis) now triggers the SAME at-most-once, * non-blocking background rebuild — so detection finally closes the loop into * repair instead of stopping at disclosure. * * Guarantees (unchanged from the bootstrap it grew out of): * - AT MOST ONCE per process per repo. A completed repair that still observes * its trigger discloses and stops — it never loops or thrashes. The guard is * cleared only on FAILURE, so a transient build error can retry. * - NEVER blocks the caller: the build runs detached from the call path; reads * during it are served from the stale index with an honest "refresh started" * disclosure, never held. * - NEVER throws: a build failure leaves the graceful guidance in place. * - Opt-out via `OPENLORE_NO_AUTO_ANALYZE` or `.openlore/config.json` `autoInit:false`. * * Deterministic, no LLM, no new dependency. */ /** * Why a background repair was started. `index-absent` is the original cold-start * case (no artifact at all); the rest are the self-healing triggers layered on by * make-index-self-healing. */ export type RepairReason = 'index-absent' | 'integrity-mismatched' | 'stale-region' | 'schema-reset' | 'analysis-age'; /** Human-facing label for each reason, used in the "refresh started" disclosure. */ export declare const REPAIR_REASON_DETAIL: Record; /** Register the process-wide repair builder (the MCP server injects install's forced buildIndex). */ export declare function registerRepairBuilder(fn: (directory: string) => Promise): void; /** True once an `openlore analyze` artifact exists for the directory. */ export declare function hasAnalysis(directory: string): boolean; export interface RepairOptions { /** * The index builder to run. Optional: when omitted, the process-wide builder * registered via {@link registerRepairBuilder} is used. Production registers * install's forced buildIndex (init + structural analyze + BM25 search corpus, * no API key) so `orient` heals to FULL parity, not just the structural graph. */ analyze?: (directory: string) => Promise; /** Opt out entirely (env OPENLORE_NO_AUTO_ANALYZE, or a caller flag). */ disabled?: boolean; /** Status sink (defaults to process.stderr). Never stdout — that is protocol. */ log?: (msg: string) => void; /** Injected at-most-once guard set (tests). */ seen?: Set; /** Injectable clock (tests). Defaults to Date.now. */ now?: () => number; } /** * Kick a one-time background repair for `directory` using the caller-supplied or * process-registered builder. Returns the in-flight build promise (so tests can * await it), or null when nothing was started (already repaired this process, * disabled, no builder available, or empty directory). NEVER throws, NEVER blocks. */ export declare function repairInBackground(directory: string, reason: RepairReason, opts?: RepairOptions): Promise | null; /** * The in-progress repair for `directory`, or undefined when none is running. The * read path threads this into the response so a stale answer is served with an * honest "background refresh started" marker — never presented as fresh. */ export declare function repairStatusFor(directory: string): { inProgress: true; reason: RepairReason; } | undefined; /** * Cold-start self-bootstrap for an ABSENT index — the original entry point, kept * as a thin wrapper over {@link repairInBackground} so existing callers/tests are * unchanged. Only fires when no analysis artifact exists yet. */ export declare function bootstrapAnalysisInBackground(directory: string, opts: RepairOptions & { analyze: (directory: string) => Promise; }): Promise | null; /** Test-only: clear the process-wide repair guards and registered builder. */ export declare function _resetRepairServiceForTesting(): void; //# sourceMappingURL=cold-start-bootstrap.d.ts.map