feat(agent): improve investigation contracts and runtime readiness
This commit is contained in:
@@ -50,7 +50,7 @@ describe("task agent isolation", () => {
|
||||
|
||||
it("selects the profile from trusted purpose on every prompt including resumed sessions", async () => {
|
||||
const selected: string[] = [];
|
||||
const runtime = Object.assign(Object.create(OpencodeRuntimeAdapter.prototype), { ensureClient: async () => ({ session: {
|
||||
const runtime = Object.assign(Object.create(OpencodeRuntimeAdapter.prototype), { ensureSessionToolsReady: async () => undefined, ensureClient: async () => ({ session: {
|
||||
switchAgent: async ({ agent }: { agent: string }) => { selected.push(agent); }, prompt: async () => {},
|
||||
} }) }) as OpencodeRuntimeAdapter;
|
||||
for (const purpose of ["ordinary_chat", "task_execution", "task_collaboration"] as const) {
|
||||
@@ -71,6 +71,19 @@ it("allows calculations to project coordinators but never delegated readers or p
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps burst event handling separate from SCADA candidate location", () => {
|
||||
const context = { sessionId: "event-handler", clientSessionId: "event-chat", actorKey: "a", projectKey: "p",
|
||||
projectId: "p", taskId: "t", traceId: "test", purpose: "task_execution" as const,
|
||||
taskWorkflow: "burst_report", taskReplay: false };
|
||||
expect(allowedQueryTools(context)).not.toContain(queryMcpToolId("run_burst_location"));
|
||||
expect(allowedQueryTools(context)).toContain(queryMcpToolId("analyze_valve_isolation"));
|
||||
expect(allowedQueryTools(context)).toContain(queryMcpToolId("analyze_valve_closure"));
|
||||
expect(allowedQueryTools({ ...context, purpose: "task_collaboration" })).not.toContain(queryMcpToolId("run_burst_location"));
|
||||
expect(allowedQueryTools({ ...context, taskReplay: true })).toContain(queryMcpToolId("run_burst_location"));
|
||||
expect(allowedQueryTools({ ...context, taskWorkflow: "scada_anomaly" })).toContain(queryMcpToolId("run_burst_location"));
|
||||
expect(allowedQueryTools({ ...context, taskId: undefined, purpose: "ordinary_chat" })).toContain(queryMcpToolId("run_burst_location"));
|
||||
});
|
||||
|
||||
|
||||
it("keeps administrator denials for product MCP queries in both primary and reader permissions", () => {
|
||||
const denied = serviceOpencodeConfig({ permissions: [{ action: "mcp_tjwater_*", resource: "*", effect: "deny" }] });
|
||||
|
||||
Reference in New Issue
Block a user