/** * Nexus Ingester — Tier-2 proposal candidate source. * * Queries nexus.db for structural anomalies and returns ranked * ProposalCandidate[]. Five query patterns: * * A. Orphaned callees: functions that have many callers but make no calls * themselves (zero-import, high-in-degree). Suggests dead-end sinks * that may be candidates for abstraction or documentation. * * B. Over-coupled nodes: symbols with total degree (in + out edges) > 20, * suggesting high coupling that should be refactored. * * C. Community fragmentation: community's symbol count dropped >20% since * last snapshot → potential broken module boundary. * * D. Entry-point erosion: process node where `entry_point_of` source is * now unexported → potential dead process definition. * * E. Cross-community coupling spike: symbol with degree > 30 and * cross_community_edge_count > 15 → extract-module candidate. * * Design principles: * - NO LLM calls. All data comes from structured SQL queries. * - Title is template-generated: `[T2-NEXUS] ...`. Prompt-injection defence. * - Failures are swallowed: returns empty array + pushes a non-fatal warning * (`W_SENTIENT_INGESTER_DEGRADED`) into the active LAFS envelope (T9773). * Nexus.db absence must never crash the propose tick. * - Community snapshots stored in nexus_schema_meta (k/v) with key * `community_snapshot_json`. First analyze run has no baseline. * * @task T1008 * @task T1070 * @see ADR-054 — Sentient Loop Tier-2 */ import type { DatabaseSync } from 'node:sqlite'; import type { ProposalCandidate } from '@cleocode/contracts'; /** Row shape for cross-community detector (T1070 follow-up, not yet wired). */ export interface CrossCommunityRow { id: string; name: string; file_path: string; degree: number; cross_community_edge_count: number; } /** Base weight for all nexus candidates (structural signals, lower priority than brain). */ export declare const NEXUS_BASE_WEIGHT = 0.3; /** Weight for community fragmentation detection (Query C). */ export declare const NEXUS_COMMUNITY_FRAGMENTATION_WEIGHT = 0.4; /** Weight for entry-point erosion detection (Query D). */ export declare const NEXUS_ENTRY_EROSION_WEIGHT = 0.5; /** Weight for cross-community coupling spike detection (Query E). */ export declare const NEXUS_CROSS_COUPLING_WEIGHT = 0.35; /** Minimum caller count for orphaned-callee detection (Query A). */ export declare const NEXUS_MIN_CALLER_COUNT = 5; /** Minimum total degree for over-coupling detection (Query B). */ export declare const NEXUS_MIN_DEGREE = 20; /** Minimum degree for cross-community coupling detection (Query E). */ export declare const NEXUS_MIN_CROSS_COUPLING_DEGREE = 30; /** Minimum cross-community edge count for coupling spike detection (Query E). */ export declare const NEXUS_MIN_CROSS_COMMUNITY_EDGES = 15; /** Threshold for community symbol count drop (Query C). */ export declare const NEXUS_COMMUNITY_SHRINK_THRESHOLD = 0.2; /** Maximum results per query. */ export declare const NEXUS_QUERY_LIMIT = 5; /** * Run the Nexus ingester against the provided DatabaseSync handle. * * Returns candidates from five detection patterns: * - Query A: orphaned callees (many callers, zero outbound calls) * - Query B: over-coupled nodes (high-degree symbols) * - Query C: community fragmentation (symbol count drop >20%) * - Query D: entry-point erosion (unexported process entry points) * - Query E: cross-community coupling spike (degree > 30 with >15 cross-edges) * * Merged without duplication. Returns an empty array if the database has no * matching entries or if any error occurs. * * @param nativeDb - Open DatabaseSync handle to nexus.db. May be null if * nexus.db has not been initialised; this is treated as zero candidates. * @returns Ranked ProposalCandidate array (may be empty). */ export declare function runNexusIngester(nativeDb: DatabaseSync | null): ProposalCandidate[]; //# sourceMappingURL=nexus-ingester.d.ts.map