FN-5758: add cited-goal audit aggregation and runtime route
Add end-to-end goal-citation audit trail plumbing across core, engine, CLI, and dashboard. - extend goal citation extraction with aggregation logic and new core coverage - expose cited-goal runtime data through dashboard routes with dedicated API tests - wire goal-citation audit details into engine diagnostics and CLI extension audit expectations - document the new audit behavior and publish a patch changeset for @runfusion/fusion Files changed: .changeset/fn-5758-goal-citation-audit.md | 9 +++ docs/dashboard-guide.md | 2 + docs/diagnostics.md | 4 ++ .../__tests__/extension-goal-tools-audit.test.ts | 6 +- packages/cli/src/extension.ts | 3 + .../goal-citation-audit-aggregation.test.ts | 63 ++++++++++++++++++ packages/core/src/goal-citation-extractor.ts | 54 ++++++++++++++- packages/core/src/index.ts | 1 + .../src/__tests__/routes-run-cited-goals.test.ts | 77 ++++++++++++++++++++++ packages/dashboard/src/routes.ts | 11 ++++ .../src/routes/register-agent-runtime-routes.ts | 49 ++++++++++++++ .../src/__tests__/goal-anchoring-audit.test.ts | 40 +++++++---- packages/engine/src/goal-anchoring-audit.ts | 4 ++ packages/engine/src/goal-injection-diagnostics.ts | 1 + 14 files changed, 308 insertions(+), 16 deletions(-) Fusion-Task-Id: FN-5758 Fusion-Task-Lineage: b077c0b7-6ca4-489d-8c36-73d80a2afdb2
This commit is contained in:
@@ -58,8 +58,8 @@ describe("extension goal tools retrieval audit", () => {
|
||||
.filter((event) => event.mutationType === GOAL_RETRIEVAL_INVOKED);
|
||||
|
||||
expect(goalAuditCalls).toHaveLength(3);
|
||||
expect(goalAuditCalls[0]).toMatchObject({ metadata: expect.objectContaining({ toolName: "fn_goal_list", count: 1 }) });
|
||||
expect(goalAuditCalls[1]).toMatchObject({ target: goalId, metadata: expect.objectContaining({ toolName: "fn_goal_show", count: 1, notFound: false }) });
|
||||
expect(goalAuditCalls[2]).toMatchObject({ target: "G-404", metadata: expect.objectContaining({ toolName: "fn_goal_show", count: 0, notFound: true }) });
|
||||
expect(goalAuditCalls[0]).toMatchObject({ metadata: expect.objectContaining({ toolName: "fn_goal_list", count: 1, goalIds: [goalId] }) });
|
||||
expect(goalAuditCalls[1]).toMatchObject({ target: goalId, metadata: expect.objectContaining({ toolName: "fn_goal_show", count: 1, goalIds: [goalId], notFound: false }) });
|
||||
expect(goalAuditCalls[2]).toMatchObject({ target: "G-404", metadata: expect.objectContaining({ toolName: "fn_goal_show", count: 0, goalIds: [], notFound: true }) });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2418,6 +2418,7 @@ export default function kbExtension(pi: ExtensionAPI) {
|
||||
emitGoalRetrievalAudit(store, fnCtx, {
|
||||
toolName: "fn_goal_list",
|
||||
resultCount: goals.length,
|
||||
goalIds: goals.map((goal) => goal.id),
|
||||
});
|
||||
|
||||
const lines: string[] = [];
|
||||
@@ -2562,6 +2563,7 @@ export default function kbExtension(pi: ExtensionAPI) {
|
||||
toolName: "fn_goal_show",
|
||||
resultCount: 0,
|
||||
goalId: params.id,
|
||||
goalIds: [],
|
||||
notFound: true,
|
||||
});
|
||||
return {
|
||||
@@ -2584,6 +2586,7 @@ export default function kbExtension(pi: ExtensionAPI) {
|
||||
toolName: "fn_goal_show",
|
||||
resultCount: 1,
|
||||
goalId: params.id,
|
||||
goalIds: [params.id],
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user