Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 0 additions & 126 deletions mcp/src/graph/neo4j.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1131,126 +1131,6 @@ class Db {
}
}

// === EvalRequirement + EvalSet system ===

async upsert_eval_requirement(params: {
name: string;
description: string;
prompt_snippet: string;
positive_cases: string[];
negative_cases: string[];
}): Promise<{ ref_id: string; node_key: string }> {
const session = this.resilientSession();
const node_key = create_node_key({
node_type: "EvalRequirement",
node_data: {
name: params.name,
file: "eval://generated",
start: 0,
},
} as Node);
try {
const result = await session.run(Q.UPSERT_EVAL_REQUIREMENT_QUERY, {
node_key,
name: params.name,
description: params.description,
prompt_snippet: params.prompt_snippet,
positive_cases: params.positive_cases,
negative_cases: params.negative_cases,
ts: Date.now() / 1000,
});
const n = result.records[0].get("n");
return { ref_id: n.properties.ref_id, node_key };
} finally {
await session.close();
}
}

async upsert_eval_set(params: {
name: string;
description: string;
}): Promise<{ ref_id: string; node_key: string }> {
const session = this.resilientSession();
const node_key = create_node_key({
node_type: "EvalSet",
node_data: {
name: params.name,
file: "eval://generated",
start: 0,
},
} as Node);
try {
const result = await session.run(Q.UPSERT_EVAL_SET_QUERY, {
node_key,
name: params.name,
description: params.description,
ts: Date.now() / 1000,
});
const n = result.records[0].get("n");
return { ref_id: n.properties.ref_id, node_key };
} finally {
await session.close();
}
}

async create_has_requirement_edge(
eval_set_ref_id: string,
eval_req_ref_id: string,
order: number,
): Promise<void> {
const session = this.resilientSession();
try {
await session.run(Q.CREATE_HAS_REQUIREMENT_EDGE_QUERY, {
eval_set_ref_id,
eval_req_ref_id,
order,
});
} finally {
await session.close();
}
}

async create_eval_run_edge(
eval_req_ref_id: string,
session_id: string,
): Promise<void> {
const session = this.resilientSession();
try {
await session.run(Q.CREATE_EVAL_RUN_EDGE_QUERY, {
eval_req_ref_id,
session_id,
});
} finally {
await session.close();
}
}

async get_eval_set_with_requirements(eval_set_ref_id: string): Promise<{
evalSet: any;
requirements: { requirement: any; order: number; runs: any[] }[];
}> {
const session = this.resilientSession();
try {
const result = await session.run(
Q.GET_EVAL_SET_WITH_REQUIREMENTS_QUERY,
{ eval_set_ref_id },
);
if (result.records.length === 0) {
return { evalSet: null, requirements: [] };
}
const record = result.records[0];
const evalSet = record.get("es");
const requirements = record.get("requirements").map((r: any) => ({
requirement: r.requirement,
order: r.order,
runs: r.runs,
}));
return { evalSet, requirements };
} finally {
await session.close();
}
}

async createIndexes(): Promise<void> {
let session: ResilientSession | null = null;
try {
Expand All @@ -1270,12 +1150,6 @@ class Db {
await session.run(
"CREATE INDEX agent_session_id_index IF NOT EXISTS FOR (n:AgentSession) ON (n.node_key)",
);
await session.run(
"CREATE INDEX eval_requirement_node_key_index IF NOT EXISTS FOR (n:EvalRequirement) ON (n.node_key)",
);
await session.run(
"CREATE INDEX eval_set_node_key_index IF NOT EXISTS FOR (n:EvalSet) ON (n.node_key)",
);
} finally {
if (session) {
await session.close();
Expand Down
50 changes: 0 additions & 50 deletions mcp/src/graph/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,56 +1122,6 @@ CALL gds.graph.drop($graphName, false)
YIELD graphName
`;

// === EvalRequirement + EvalSet system ===

export const UPSERT_EVAL_REQUIREMENT_QUERY = `
MERGE (n:EvalRequirement:${Data_Bank} {node_key: $node_key})
ON CREATE SET n.ref_id = randomUUID(), n.date_added_to_graph = $ts,
n.namespace = 'default', n.file = 'eval://generated', n.start = 0, n.end = 0,
n.created_at = $ts
SET n.name = $name, n.body = $description, n.description = $description,
n.prompt_snippet = $prompt_snippet,
n.positive_cases = $positive_cases, n.negative_cases = $negative_cases,
n.updated_at = $ts
RETURN n
`;

export const UPSERT_EVAL_SET_QUERY = `
MERGE (n:EvalSet:${Data_Bank} {node_key: $node_key})
ON CREATE SET n.ref_id = randomUUID(), n.date_added_to_graph = $ts,
n.namespace = 'default', n.file = 'eval://generated', n.start = 0, n.end = 0,
n.created_at = $ts
SET n.name = $name, n.body = $description, n.description = $description,
n.updated_at = $ts
RETURN n
`;

export const CREATE_HAS_REQUIREMENT_EDGE_QUERY = `
MATCH (es:EvalSet {ref_id: $eval_set_ref_id})
MATCH (er:EvalRequirement {ref_id: $eval_req_ref_id})
MERGE (es)-[r:HAS_REQUIREMENT]->(er)
ON CREATE SET r.ref_id = randomUUID()
SET r.order = $order
RETURN r
`;

export const CREATE_EVAL_RUN_EDGE_QUERY = `
MATCH (er:EvalRequirement {ref_id: $eval_req_ref_id})
MATCH (s:AgentSession {node_key: $session_id})
MERGE (er)-[r:EVAL_RUN]->(s)
ON CREATE SET r.ref_id = randomUUID()
RETURN r
`;

export const GET_EVAL_SET_WITH_REQUIREMENTS_QUERY = `
MATCH (es:EvalSet {ref_id: $eval_set_ref_id})
OPTIONAL MATCH (es)-[rel:HAS_REQUIREMENT]->(er:EvalRequirement)
OPTIONAL MATCH (er)-[:EVAL_RUN]->(session:AgentSession)
WITH es, er, rel.order AS req_order, collect(session) AS runs
ORDER BY req_order ASC
RETURN es, collect({requirement: er, order: req_order, runs: runs}) AS requirements
`;

export const GET_TOP_NODES_BY_IMPORTANCE_QUERY = `
MATCH (n)
WHERE n.pagerank IS NOT NULL
Expand Down
16 changes: 2 additions & 14 deletions mcp/src/graph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ export type NodeType =
| "Mock"
| "Learning"
| "Scope"
| "UserObjective"
| "EvalRequirement"
| "EvalSet";
| "UserObjective";

export type EdgeType =
| "CALLS"
Expand Down Expand Up @@ -101,9 +99,7 @@ export type EdgeType =
| "MODIFIES"
| "REFERENCES"
| "HAS_SCOPE"
| "MEMBER_OF"
| "HAS_REQUIREMENT"
| "EVAL_RUN";
| "MEMBER_OF";

export interface EdgeTypeInterface {
edge_type: EdgeType;
Expand Down Expand Up @@ -190,8 +186,6 @@ export function relevant_node_types(): NodeType[] {
"Topic",
"Feature",
"UserObjective",
"EvalRequirement",
"EvalSet",
];
}

Expand Down Expand Up @@ -235,8 +229,6 @@ export function all_node_types(): NodeType[] {
"Learning",
"Scope",
"UserObjective",
"EvalRequirement",
"EvalSet",
];
}

Expand All @@ -263,8 +255,6 @@ export function all_edge_types(): EdgeType[] {
"METADATA_FOR",
"MOCKS",
"MEMBER_OF",
"HAS_REQUIREMENT",
"EVAL_RUN",
];
}

Expand Down Expand Up @@ -329,8 +319,6 @@ export function node_type_descriptions(): { [k in NodeType]: string } {
Learning: "A rule or guideline capturing knowledge about the codebase, linked to scopes that define where it applies.",
Scope: "A scope label that groups related learnings, such as a technology, pattern, or area of the codebase.",
UserObjective: "A specific goal or objective that a user wants to achieve within the application.",
EvalRequirement: "An evaluation requirement defining a prompt snippet with positive and negative test cases for assessing AI agent behavior.",
EvalSet: "A named collection of evaluation requirements used to assess AI agent capabilities.",
};
}

Expand Down
Loading