All files / src/objects systemNodes.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                                                                            44x             44x   44x   44x                                                               19x 49x 19x    
import type { KnowledgeCategoryKey } from "@/objects/Knowledge";
import type { LucideIcon } from "lucide-react";
import {
  BookMarked,
  Brain,
  CalendarClock,
  ClipboardCheck,
  Compass,
  Cpu,
  Database,
  FileInput,
  FileOutput,
  GitBranch,
  GitMerge,
  Hammer,
  Hand,
  Library,
  ListTree,
  MessageCircleQuestion,
  Radar,
  Search,
  Workflow,
} from "lucide-react";
 
/**
 * Every system node svc-ai's graph runs (and svc-core's rule nodes), named
 * and drawn once: the execution pipeline, the Activity trace, a skill run's
 * steps and "Where the tokens go" all read this. svc-ai's own list is
 * `graph.SYSTEM_NODE_IDS`; ids from older traces stay so they still draw.
 */
 
export type SystemNodeMeta = { label: string; Icon: LucideIcon };
 
/**
 * The knowledge lane for each kind, as svc-ai names it
 * (`graph.LANE_NODE_IDS`: `__<kind>_retrieval__`). Pinned to the kinds by
 * `systemNodes.test.ts`.
 */
export const LANE_NODE_IDS: Record<KnowledgeCategoryKey, string> = {
  domain: "__domain_retrieval__",
  temporal: "__temporal_retrieval__",
  reasoning: "__reasoning_retrieval__",
};
 
/** Plans a turn's knowledge search once, for every lane. */
export const KNOWLEDGE_PLAN_NODE_ID = "__knowledge_plan__";
/** Where every retrieval branch meets, once, before the answer. */
export const RETRIEVAL_JOIN_NODE_ID = "__retrieval_join__";
 
export const SYSTEM_NODES: Record<string, SystemNodeMeta> = {
  // Triage: where to get data and the task's shape, in one call.
  __gate__: { label: "Triage", Icon: GitBranch },
  // Stored traces only: triage has decided the task's shape since October 2026.
  __recon__: { label: "Reconnaissance", Icon: Radar },
  __clarify__: { label: "Scope Clarification", Icon: MessageCircleQuestion },
  __hitl__: { label: "Human Approval", Icon: Hand },
  __planning__: { label: "Planning", Icon: Cpu },
  __retrieval__: { label: "Knowledge Retrieval", Icon: Database },
  // Stored traces only: one node searched every kind before the lanes
  // (October 2026).
  __internal_retrieval__: { label: "Internal Retrieval", Icon: Database },
  [KNOWLEDGE_PLAN_NODE_ID]: { label: "Knowledge Plan", Icon: ListTree },
  [LANE_NODE_IDS.domain]: { label: "Domain Retrieval", Icon: Library },
  [LANE_NODE_IDS.temporal]: { label: "Temporal Retrieval", Icon: CalendarClock },
  [LANE_NODE_IDS.reasoning]: { label: "Reasoning Retrieval", Icon: Compass },
  __external_retrieval__: { label: "External Retrieval", Icon: Search },
  __tool_retrieval__: { label: "Tool Retrieval", Icon: Hammer },
  [RETRIEVAL_JOIN_NODE_ID]: { label: "Retrieval Join", Icon: GitMerge },
  __synthesis__: { label: "Synthesis", Icon: Workflow },
  __memory_read__: { label: "Memory Recall", Icon: Brain },
  __memory_write__: { label: "Memory Store", Icon: BookMarked },
  __evaluator__: { label: "Quality Evaluator", Icon: ClipboardCheck },
  // The rules run before the model (Access, Input) and after it (Output).
  // The node ids predate layers and stay: stored traces carry them.
  __policy__: { label: "Request Rules", Icon: FileInput },
  __audit__: { label: "Answer Rules", Icon: FileOutput },
};
 
/** The kind a lane node searches, or null for any other node. */
export function laneKind(nodeId: string): KnowledgeCategoryKey | null {
  const found = (
    Object.entries(LANE_NODE_IDS) as [KnowledgeCategoryKey, string][]
  ).find(([, id]) => id === nodeId);
  return found ? found[0] : null;
}