/** * Nexus analyze orchestrator — business logic extracted from `cleo nexus analyze`. * * Stages a replacement code graph and publishes it atomically, * refreshes the nexus-bridge, updates the multi-project registry, and sweeps * the git log for task–symbol links. Post-publication hooks are best-effort. * * @module nexus/analyze-orchestrator * @epic T9833 * @task T10062 */ import type { GraphIndexAssessment, GraphIndexRunSummary, GraphParseCacheEntry, GraphPublicationRows, ParserExecutionLimits } from '@cleocode/contracts'; import type { NodeSQLiteDatabase } from 'drizzle-orm/node-sqlite'; /** Read the parse cache committed with the current generation (T12315). */ export declare function readNexusParseCache(db: NodeSQLiteDatabase): GraphParseCacheEntry[]; /** * Persist a batch of parsed extractions outside the graph publication * (T14009), so an aborted or killed analysis keeps its parse work. Entries are * exact by path, content hash and extractor fingerprint; the next run reuses * them, and the publication keeps only its own generation's files. * * @param db - Project graph database. * @param entries - Extractions parsed since the last checkpoint. */ export declare function checkpointNexusParseCache(db: NodeSQLiteDatabase, entries: readonly GraphParseCacheEntry[]): void; /** Receipt of a graph re-bound from a moved project's recorded root to its live root (T12659). */ export interface NexusGraphRebind { /** Project root the previous graph was recorded under. */ oldRoot: string; /** Live project root the rebuilt graph is bound to. */ newRoot: string; /** Project id, identical before and after. */ projectId: string; /** Graph generation published by the re-binding rebuild. */ generation: string | null; /** Included repositories dropped because they were missing (only with `dropMissingRepositories`). */ droppedRepositories: string[]; } /** Included repositories an analysis dropped because they were missing on disk (T12659). */ export interface NexusDroppedRepositories { /** Relative paths dropped from the index scope. */ paths: string[]; /** Command that re-includes every dropped path once it exists again. */ restoreCommand: string; } /** * Atomically publish staged rows if the graph has not changed since assessment. * Failed inserts, FTS repair, or stale generations roll back the entire replacement. * Code placed in `packages/core/` per Package-Boundary Check — verified against AGENTS.md. * @param db - Owning project graph database with the canonical schema installed. * @param rows - Validated staged nodes, relations and source assessment to publish. * @param expectedGeneration - Previously observed generation; null for the first publication. * @returns The number of node and relation rows written. * @remarks The transaction rejects stale generation preconditions and restores the * prior live rows on failure. Successful replacement does not itself retain an * independently recoverable historical generation. * @example * ```ts * publishNexusGraph(db, stagedRows, expectedGeneration); * ``` */ export declare function publishNexusGraph(db: NodeSQLiteDatabase, rows: GraphPublicationRows, expectedGeneration: string | null): { nodeCount: number; relationCount: number; }; /** Parameters for {@link runNexusAnalysis}. */ export interface NexusAnalysisParams { /** Per-file parser bounds and cancellation; native RSS containment is unverified. */ parserLimits?: ParserExecutionLimits; /** * Epoch milliseconds at which the run's budget ends (T14016): uninterruptible * phases start only when their estimate fits what is left. */ deadlineAt?: number; /** Absolute path to the repository to analyze. */ repoPath: string; /** Stable identity parent; defaults to repoPath and can differ from the analyzed source. */ projectRoot?: string; /** Explicit existing identity override; otherwise require persisted parent identity. */ projectIdOverride?: string; /** * Parse every file instead of reusing the previous generation's extractions. * When omitted, an analysis reuses what is provably current (T12315) and * falls back to a full parse — reporting why — when it cannot. */ full?: boolean; /** * @deprecated Incremental reuse is the default since T12315; this flag is * accepted for compatibility and has no effect. Use `full` to force a rebuild. */ incremental?: boolean; /** Explicit relative paths of nested repositories authorized for source inclusion. */ includedRepositories?: readonly string[]; /** Refuse a run that would be a full rebuild (T13523: inline refresh from a read query). */ requireIncremental?: boolean; /** * Drop included repositories (explicit or carried over) that are missing on * disk instead of refusing. Off by default: a missing inclusion refuses and * keeps the previous graph (T12659). Dropped paths are reported with a * restore command in {@link NexusAnalysisResult.droppedRepositories}. */ dropMissingRepositories?: boolean; /** * Progress callback invoked every 50 files (and on completion). * Omit for JSON output mode. */ onProgress?: (current: number, total: number, filePath: string) => void; } /** Result of a successful {@link runNexusAnalysis} call. */ export interface NexusAnalysisResult { projectId: string; repoPath: string; /** Whether this run reused previous extractions (mode `incremental` or `unchanged`). */ incremental: boolean; /** Mode, reason, per-file counts and phase costs of this run. */ summary: GraphIndexRunSummary; nodeCount: number; relationCount: number; fileCount: number; durationMs: number; /** * Committed per-file outcomes and source provenance, as a summary: the * reference list is reported as `referenceCount` (T12348). */ assessment: GraphIndexAssessment | null; /** * Present when a `--full` run re-bound a moved project's graph (same project * id, different recorded root) to the live root (T12659). */ rebind?: NexusGraphRebind; /** * Included repositories dropped because they were missing on disk, only with * `dropMissingRepositories` (T12659), and the one command that restores them * once they are back. */ droppedRepositories?: NexusDroppedRepositories; } /** * Run the nexus code-intelligence pipeline on a repository. * * This function: * 1. Captures the existing parent identity and explicit source roots. * 2. Captures the current graph generation for concurrent-write detection. * 3. Stages and atomically publishes the `@cleocode/nexus` pipeline output. * 4. Best-effort: refreshes `nexus-bridge.md`. * 5. Best-effort: updates the multi-project registry. * 6. Best-effort: sweeps the git log for task–symbol links. * * @param params - Analysis configuration * @returns Pipeline result with node/relation/file counts and duration * @throws {Error} When identity, source preconditions or the pipeline fail. * @remarks Root revisions and file hashes are optimistic preconditions, not a * filesystem lock. Publication uses the owning store's synchronous generation CAS; * optional post-publication hooks cannot replace its committed result. * @example * ```ts * const result = await runNexusAnalysis({ repoPath: '/identity', includedRepositories: ['app'] }); * ``` */ export declare function runNexusAnalysis(params: NexusAnalysisParams): Promise; //# sourceMappingURL=analyze-orchestrator.d.ts.map