import type { IntentNetworkGraphDatabase } from "../ports/index.js"; import type { DebugMetaAgent } from "../../capabilities/participant-agents.debug.facade.js"; import type { IntentIndexer } from "../ports/index.js"; import { type AssignmentResult } from "./indexer.state.js"; /** * Factory class to build and compile the Intent–Network (indexer) Graph. * * Handles CRUD for the intent_indexes junction table: * - create: Assign an intent to a network (direct or LLM-evaluated) * - read: List intent–network links (by intentId or by networkId) * - delete: Unassign an intent from a network * * ## Signal assignment policy * * The `IntentIndexer` is injected at construction time from the signals public * facade via the communities ports layer — this factory never imports signals * application internals directly. * * Two assignment paths: * 1. Direct (`skipEvaluation: true`): * - Writes the link immediately with `mode: manual_override`, `score: 1`. * 2. Evaluated (`skipEvaluation: false`): * - Loads intent + network context (indexPrompt, memberPrompt). * - No-prompt fast path: if both prompts are absent, assigns with * `mode: automatic, promptPresence: 'none'` without calling the LLM. * - Otherwise invokes IntentIndexer to get indexScore + memberScore + reasoning. * - Applies `buildNetworkAssignmentDecision` to produce the threshold/metadata. * - Only writes the link when the decision's `assigned` flag is true. * * ## Membership authority for assignment * * A user may only assign their own intents. * The user must be a member (or owner) of the target network. * Assignment is rejected if membership has been revoked between intent creation * and assignment time (`assignIntentToNetworkIfMember` returns `membership_required`). * * Flow: * START → router → { * create: assignNode (direct or evaluated) → END * read: readNode → END * delete: unassignNode → END * } * * IND-546: canonical home — previously network/indexer/indexer.graph.ts. * Signals dependency consumed via capabilities/signals.facade.ts (through ports). */ export declare class IntentNetworkGraphFactory { private database; private intentNetworker; constructor(database: IntentNetworkGraphDatabase, intentNetworker: IntentIndexer); createGraph(): import("@langchain/langgraph").CompiledStateGraph<{ userId: string; networkId: string | undefined; intentId: string | undefined; operationMode: "delete" | "create" | "read"; skipEvaluation: boolean; intent: import("./indexer.state.js").IntentForIndexing | null; indexContext: import("./indexer.state.js").IndexMemberContext | null; evaluation: { reasoning: string; indexScore: number; memberScore: number; } | null; shouldAssign: boolean | undefined; finalScore: number | undefined; assignmentResult: AssignmentResult | null; queryUserId: string | undefined; readResult: { links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | undefined; mutationResult: { success: boolean; message?: string; error?: string; } | undefined; error: string | null; agentTimings: DebugMetaAgent[]; }, { userId?: string | undefined; networkId?: string | import("@langchain/langgraph").OverwriteValue | undefined; intentId?: string | import("@langchain/langgraph").OverwriteValue | undefined; operationMode?: "delete" | "create" | "read" | import("@langchain/langgraph").OverwriteValue<"delete" | "create" | "read"> | undefined; skipEvaluation?: boolean | import("@langchain/langgraph").OverwriteValue | undefined; intent?: import("./indexer.state.js").IntentForIndexing | import("@langchain/langgraph").OverwriteValue | null | undefined; indexContext?: import("./indexer.state.js").IndexMemberContext | import("@langchain/langgraph").OverwriteValue | null | undefined; evaluation?: { reasoning: string; indexScore: number; memberScore: number; } | import("@langchain/langgraph").OverwriteValue<{ reasoning: string; indexScore: number; memberScore: number; } | null> | null | undefined; shouldAssign?: boolean | import("@langchain/langgraph").OverwriteValue | undefined; finalScore?: number | import("@langchain/langgraph").OverwriteValue | undefined; assignmentResult?: AssignmentResult | import("@langchain/langgraph").OverwriteValue | null | undefined; queryUserId?: string | import("@langchain/langgraph").OverwriteValue | undefined; readResult?: { links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | import("@langchain/langgraph").OverwriteValue<{ links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | undefined> | undefined; mutationResult?: { success: boolean; message?: string; error?: string; } | import("@langchain/langgraph").OverwriteValue<{ success: boolean; message?: string; error?: string; } | undefined> | undefined; error?: string | import("@langchain/langgraph").OverwriteValue | null | undefined; agentTimings?: DebugMetaAgent[] | import("@langchain/langgraph").OverwriteValue | undefined; }, "__start__" | "read" | "assign" | "unassign", { userId: { (annotation: import("@langchain/langgraph").SingleReducer): import("@langchain/langgraph").BaseChannel, unknown>; (): import("@langchain/langgraph").LastValue; Root: (sd: S) => import("@langchain/langgraph").AnnotationRoot; }; networkId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; intentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; operationMode: import("@langchain/langgraph").BaseChannel<"delete" | "create" | "read", "delete" | "create" | "read" | import("@langchain/langgraph").OverwriteValue<"delete" | "create" | "read">, unknown>; skipEvaluation: import("@langchain/langgraph").BaseChannel, unknown>; intent: import("@langchain/langgraph").BaseChannel | null, unknown>; indexContext: import("@langchain/langgraph").BaseChannel | null, unknown>; evaluation: import("@langchain/langgraph").BaseChannel<{ reasoning: string; indexScore: number; memberScore: number; } | null, { reasoning: string; indexScore: number; memberScore: number; } | import("@langchain/langgraph").OverwriteValue<{ reasoning: string; indexScore: number; memberScore: number; } | null> | null, unknown>; shouldAssign: import("@langchain/langgraph").BaseChannel | undefined, unknown>; finalScore: import("@langchain/langgraph").BaseChannel | undefined, unknown>; assignmentResult: import("@langchain/langgraph").BaseChannel | null, unknown>; queryUserId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; readResult: import("@langchain/langgraph").BaseChannel<{ links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | undefined, { links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | import("@langchain/langgraph").OverwriteValue<{ links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | undefined> | undefined, unknown>; mutationResult: import("@langchain/langgraph").BaseChannel<{ success: boolean; message?: string; error?: string; } | undefined, { success: boolean; message?: string; error?: string; } | import("@langchain/langgraph").OverwriteValue<{ success: boolean; message?: string; error?: string; } | undefined> | undefined, unknown>; error: import("@langchain/langgraph").BaseChannel | null, unknown>; agentTimings: import("@langchain/langgraph").BaseChannel, unknown>; }, { userId: { (annotation: import("@langchain/langgraph").SingleReducer): import("@langchain/langgraph").BaseChannel, unknown>; (): import("@langchain/langgraph").LastValue; Root: (sd: S) => import("@langchain/langgraph").AnnotationRoot; }; networkId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; intentId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; operationMode: import("@langchain/langgraph").BaseChannel<"delete" | "create" | "read", "delete" | "create" | "read" | import("@langchain/langgraph").OverwriteValue<"delete" | "create" | "read">, unknown>; skipEvaluation: import("@langchain/langgraph").BaseChannel, unknown>; intent: import("@langchain/langgraph").BaseChannel | null, unknown>; indexContext: import("@langchain/langgraph").BaseChannel | null, unknown>; evaluation: import("@langchain/langgraph").BaseChannel<{ reasoning: string; indexScore: number; memberScore: number; } | null, { reasoning: string; indexScore: number; memberScore: number; } | import("@langchain/langgraph").OverwriteValue<{ reasoning: string; indexScore: number; memberScore: number; } | null> | null, unknown>; shouldAssign: import("@langchain/langgraph").BaseChannel | undefined, unknown>; finalScore: import("@langchain/langgraph").BaseChannel | undefined, unknown>; assignmentResult: import("@langchain/langgraph").BaseChannel | null, unknown>; queryUserId: import("@langchain/langgraph").BaseChannel | undefined, unknown>; readResult: import("@langchain/langgraph").BaseChannel<{ links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | undefined, { links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | import("@langchain/langgraph").OverwriteValue<{ links: Array<{ intentId: string; networkId: string; intentTitle?: string; networkTitle?: string; userId?: string; userName?: string; createdAt?: Date; relevancyScore?: number | null; }>; count: number; mode: string; note?: string; } | undefined> | undefined, unknown>; mutationResult: import("@langchain/langgraph").BaseChannel<{ success: boolean; message?: string; error?: string; } | undefined, { success: boolean; message?: string; error?: string; } | import("@langchain/langgraph").OverwriteValue<{ success: boolean; message?: string; error?: string; } | undefined> | undefined, unknown>; error: import("@langchain/langgraph").BaseChannel | null, unknown>; agentTimings: import("@langchain/langgraph").BaseChannel, unknown>; }, import("@langchain/langgraph").StateDefinition, { assign: { agentTimings: DebugMetaAgent[]; mutationResult: { success: boolean; error: string; message?: undefined; }; evaluation?: undefined; shouldAssign?: undefined; finalScore?: undefined; } | { agentTimings: DebugMetaAgent[]; mutationResult: { success: boolean; message: string; error?: undefined; }; evaluation?: undefined; shouldAssign?: undefined; finalScore?: undefined; } | { assignmentResult: AssignmentResult; mutationResult: { success: boolean; message: string; error?: undefined; }; agentTimings: DebugMetaAgent[]; evaluation?: undefined; shouldAssign?: undefined; finalScore?: undefined; } | { assignmentResult: AssignmentResult; mutationResult: { success: boolean; error: string; message?: undefined; }; agentTimings: DebugMetaAgent[]; evaluation?: undefined; shouldAssign?: undefined; finalScore?: undefined; } | { agentTimings: DebugMetaAgent[]; evaluation: null; shouldAssign: boolean; finalScore: number; mutationResult: { success: boolean; error: string; message?: undefined; }; } | { assignmentResult: AssignmentResult; mutationResult: { success: boolean; message: string; error?: undefined; }; agentTimings: DebugMetaAgent[]; evaluation: { reasoning: string; indexScore: number; memberScore: number; }; shouldAssign: boolean; finalScore: number; } | { assignmentResult: AssignmentResult; mutationResult: { success: boolean; error: string; message?: undefined; }; agentTimings: DebugMetaAgent[]; evaluation: { reasoning: string; indexScore: number; memberScore: number; }; shouldAssign: boolean; finalScore: number; }; read: { readResult: { links: never[]; count: number; mode: string; note?: undefined; }; error: string; } | { readResult: { links: { intentId: string; networkId: string; }[]; count: number; mode: string; note: string; }; error?: undefined; } | { error: string; readResult?: undefined; }; unassign: { mutationResult: { success: boolean; error: string; message?: undefined; }; } | { mutationResult: { success: boolean; message: string; error?: undefined; }; }; }, unknown, unknown, []>; }