(params: {
store: MemxStoreBundle;
ctx: MemoryOperationContext;
objective: MemorySelectionObjective;
graph: GraphEvidence;
supportObjects: MemoryObject[];
graphHypotheses: AbstractionCandidateRecord[];
seedEntityIds: string[];
prioritySeedEntityIds?: string[];
})
| 1951 | } |
| 1952 | |
| 1953 | function augmentGraphWithSupportObjects(params: { |
| 1954 | store: MemxStoreBundle; |
| 1955 | ctx: MemoryOperationContext; |
| 1956 | objective: MemorySelectionObjective; |
| 1957 | graph: GraphEvidence; |
| 1958 | supportObjects: MemoryObject[]; |
| 1959 | graphHypotheses: AbstractionCandidateRecord[]; |
| 1960 | seedEntityIds: string[]; |
| 1961 | prioritySeedEntityIds?: string[]; |
| 1962 | }): GraphEvidence { |
| 1963 | const hasDurableGraph = params.graph.edges.length > 0 || params.graph.pathCandidates.length > 0; |
| 1964 | const nodes = new Map<string, GraphEvidenceNode>( |
| 1965 | params.graph.nodes.map((node) => [node.nodeId, node]), |
| 1966 | ); |
| 1967 | const edges = new Map<string, GraphEvidenceEdge>( |
| 1968 | params.graph.edges.map((edge) => [edge.edgeId, edge]), |
| 1969 | ); |
| 1970 | const objectNodes = new Map<string, GraphEvidenceNode>(); |
| 1971 | const linkedEntityIdsByObject = new Map<string, Set<string>>(); |
| 1972 | const taskNodesByTaskId = new Map<string, GraphEvidenceNode>(); |
| 1973 | |
| 1974 | for (const object of params.supportObjects) { |
| 1975 | const node = memoryGraphNodeFromObject(object); |
| 1976 | if (!node) { |
| 1977 | continue; |
| 1978 | } |
| 1979 | ensureGraphNode(nodes, node); |
| 1980 | objectNodes.set(object.objectId, node); |
| 1981 | if (object.kind === "task" && object.attributes.taskId) { |
| 1982 | taskNodesByTaskId.set(object.attributes.taskId, node); |
| 1983 | } |
| 1984 | } |
| 1985 | |
| 1986 | for (const candidate of params.graphHypotheses) { |
| 1987 | const metadata = parseGraphHypothesisCandidate(candidate); |
| 1988 | if (!metadata) { |
| 1989 | continue; |
| 1990 | } |
| 1991 | const hasStoredEquivalent = [...edges.values()].some( |
| 1992 | (edge) => |
| 1993 | edge.sourceKind === "stored" && |
| 1994 | edge.relType === metadata.relationType && |
| 1995 | edge.relationSlot === metadata.relationSlot && |
| 1996 | edge.srcNodeId === metadata.sourceNodeId && |
| 1997 | edge.dstNodeId === metadata.targetNodeId, |
| 1998 | ); |
| 1999 | if (hasStoredEquivalent) { |
| 2000 | continue; |
| 2001 | } |
| 2002 | ensureGraphNode(nodes, { |
| 2003 | nodeId: metadata.sourceNodeId, |
| 2004 | nodeKind: "entity", |
| 2005 | name: metadata.sourceName, |
| 2006 | type: metadata.sourceType, |
| 2007 | sourceObjectId: `abstraction_candidate:${candidate.candidateId}`, |
| 2008 | observedAt: candidate.updatedAt, |
| 2009 | confidence: candidate.confidence, |
| 2010 | }); |
no test coverage detected