/** * Graph auto-population helpers for CLEO BRAIN. * * Provides upsertGraphNode and addGraphEdge helpers that write to the * brain_page_nodes and brain_page_edges tables whenever memory entries * are created via the legitimate write paths (storeDecision, observeBrain, * storePattern, storeLearning, and task completion). * * Design constraints: * - All writes are BEST-EFFORT — never block or fail the primary operation. * - All writes are gated on brain.autoCapture via isAutoCaptureEnabled. * - Uses INSERT OR REPLACE (onConflictDoUpdate) for upsert semantics. * - Edge inserts are idempotent via the composite PK (fromId, toId, edgeType). * * @task T537 * @epic T523 */ import type { BrainEdgeType, BrainNodeType } from '../store/schema/memory-schema.js'; export type { BrainEdgeType, BrainNodeType }; /** * Upsert a graph node for a typed table entry. * * Uses INSERT OR REPLACE to handle both new and existing entries. If the * node already exists (same id), its label, qualityScore, lastActivityAt, * updatedAt, and metadataJson are refreshed while createdAt is preserved. * * The contentHash is derived from a SHA-256 prefix of the canonical content. * External-reference nodes (task, session, epic) may pass an empty string for * content; their hash will be null so duplicates are not rejected. * * This function is gated on brain.autoCapture. If the gate is disabled or any * error occurs, it returns silently without throwing. * * @param projectRoot - Absolute path to the project root directory. * @param nodeId - Stable composite ID in the form ':'. * @param nodeType - Discriminated type from BRAIN_NODE_TYPES. * @param label - Human-readable label (title, task ID, etc.). * @param qualityScore - 0.0 (noise) to 1.0 (canonical). * @param content - Canonical text used to derive the content hash. * @param metadata - Optional type-specific metadata blob. * * @task T537 */ export declare function upsertGraphNode(projectRoot: string, nodeId: string, nodeType: BrainNodeType, label: string, qualityScore: number, content: string, metadata?: Record): Promise; /** * Add a directed, typed edge between two graph nodes (idempotent). * * The composite primary key (fromId, toId, edgeType) prevents duplicate edges * of the same type. Conflicting rows are ignored so this is safe to call * multiple times with the same arguments. * * This function is gated on brain.autoCapture. If the gate is disabled or any * error occurs, it returns silently without throwing. * * @param projectRoot - Absolute path to the project root directory. * @param fromId - Source node ID (brain_page_nodes.id). * @param toId - Target node ID (brain_page_nodes.id or external nexus ID). * @param edgeType - Typed relationship from BRAIN_EDGE_TYPES. * @param weight - Edge confidence/weight (0.0–1.0). Defaults to 1.0. * @param provenance - Human-readable note on why this edge was emitted. * * @task T537 */ export declare function addGraphEdge(projectRoot: string, fromId: string, toId: string, edgeType: BrainEdgeType, weight?: number, provenance?: string): Promise; /** * Upsert a `task:T###` graph node for a task at creation time (not completion). * * Prior to T945 Stage A, task nodes were only minted by `completeTask`, which * meant brand-new tasks were invisible in the graph until they shipped. This * hook fixes that gap by wiring `task:T###` nodes into `addTask` with a * quality score of 0.7 (provisional, not yet verified by gate evidence). * * Best-effort: any failure is swallowed so graph writes never block the * task-creation write path. * * @param projectRoot - Absolute path to the project root directory. * @param taskId - CLEO task ID in `T###` format. * @param title - Task title (used as node label). * @param metadata - Optional type-specific metadata (priority, type, etc.). * * @task T945 */ export declare function ensureTaskNode(projectRoot: string, taskId: string, title: string, metadata?: Record): Promise; /** * Upsert an `llmtxt:` graph node for an attachment blob and emit an * `embeds` edge from the owning entity to the blob. * * `cleo docs add` stores attachment blobs content-addressably; the blob's * SHA-256 becomes its canonical node ID so duplicate attachments across tasks * collapse to a single graph node with multiple incoming `embeds` edges. * * Best-effort: any failure is swallowed. * * @param projectRoot - Absolute path to the project root directory. * @param sha256 - Hex-encoded SHA-256 of the blob (content-address). * @param ownerId - Full graph node ID of the owner (e.g. `task:T123`). * @param label - Human-readable label for the blob (filename or title). * * @task T945 */ export declare function ensureLlmtxtNode(projectRoot: string, sha256: string, ownerId: string, label: string): Promise; /** * Upsert a `msg:` graph node for a CONDUIT message and, when the message * body references one or more `T###` task IDs, emit `discusses` edges from * the message to each referenced task. * * Task IDs are extracted from the message content via `TASK_ID_REGEX`. Only * unique IDs are linked; duplicates within the same message collapse. * * Best-effort: any failure is swallowed. * * @param projectRoot - Absolute path to the project root directory. * @param msgId - CONDUIT message ID (soft FK into conduit.db). * @param content - Full message body (scanned for task references). * * @task T945 */ export declare function ensureMessageNode(projectRoot: string, msgId: string, content: string): Promise; /** * Upsert a `commit:` graph node for a git commit and emit a `touches_code` * edge from the associated task to the commit node. * * Used by the Tier 3 autonomy audit trail: every commit produced by an agent * is recorded as a graph node so operators can traverse task → commit → files * touched to reconstruct the audit chain. * * Best-effort: any failure is swallowed. * * @param projectRoot - Absolute path to the project root directory. * @param sha - Full git commit SHA (40 hex chars; short SHAs accepted). * @param taskId - CLEO task ID this commit resolves (`T###`). * * @task T945 */ export declare function ensureCommitNode(projectRoot: string, sha: string, taskId: string): Promise; //# sourceMappingURL=graph-auto-populate.d.ts.map