FN-5663: add goal-citation audit trail to agent reasoning

Record goal citation evidence so agent reasoning can be traced end-to-end.

- add core goal citation types, extraction helper, persistence schema, and store APIs for citation create/list workflows
- add CLI support and tests for goal citation flows, including command wiring and regression coverage
- update docs and add a published changeset for @runfusion/fusion describing the new audit-trail capability

Files changed:
 .changeset/fn-5663-goal-citation-audit-trail.md    |  10 +
 docs/agents.md                                     |  15 ++
 docs/cli-reference.md                              |   6 +-
 packages/cli/src/__tests__/bin.test.ts             |   2 +
 .../cli/src/__tests__/goals-citations-cli.test.ts  |  82 ++++++++
 packages/cli/src/bin.ts                            |  19 +-
 packages/cli/src/commands/goals.ts                 |  43 +++++
 packages/core/src/__tests__/db-migrate.test.ts     |  10 +-
 packages/core/src/__tests__/db.test.ts             |  34 ++--
 .../src/__tests__/goal-citation-extractor.test.ts  |  56 ++++++
 .../src/__tests__/goal-citations-store.test.ts     | 175 +++++++++++++++++
 packages/core/src/__tests__/goals-schema.test.ts   |   2 +-
 packages/core/src/__tests__/insight-store.test.ts  |  10 +-
 packages/core/src/__tests__/mission-store.test.ts  |   2 +-
 packages/core/src/__tests__/run-audit.test.ts      |   2 +-
 packages/core/src/__tests__/secrets-schema.test.ts |   6 +-
 .../core/src/__tests__/store-merge-queue.test.ts   |   2 +-
 packages/core/src/__tests__/task-documents.test.ts |   2 +-
 packages/core/src/db.ts                            |  51 ++++-
 packages/core/src/goal-citation-extractor.ts       |  56 ++++++
 packages/core/src/index.ts                         |  13 ++
 packages/core/src/store.ts                         | 210 ++++++++++++++++++++-
 packages/core/src/types.ts                         |  51 ++++-
 .../src/store/__tests__/roadmap-store.test.ts      |   4 +-
 24 files changed, 817 insertions(+), 46 deletions(-)

Fusion-Task-Id: FN-5663

Fusion-Task-Lineage: 720f2c4b-4363-464a-a76f-472ec6aca136
This commit is contained in:
gsxdsm
2026-05-29 08:25:38 -07:00
parent 23e0593cb1
commit 71e2aec5b7
24 changed files with 817 additions and 46 deletions

View File

@@ -1504,6 +1504,21 @@ Universal baseline: available by default across executor, step-session, reviewer
- Read-only (no JS rendering, no auth flows, no POST/cookie workflows)
- Use the `agent-browser` skill when JS rendering or interactive navigation is required
## Goal-citation audit trail (Slice 2 success signal)
Agents now emit a durable goal-citation signal whenever reasoning text includes a goal ID.
- Scanned surfaces: `agent_log` and `task_document`.
- Regex contract: `GOAL_ID_PATTERN = /\bG-[0-9A-Z]+(?:-[0-9A-Z]+)*\b/g` (uppercase `G-...` only).
- Snippets are bounded windows (`GOAL_CITATION_SNIPPET_MAX = 200`) around the first match per goal ID, with whitespace collapsed.
- Query via CLI:
- `fn goals citations --since <iso> --until <iso>`
- `fn goals citations --goal G-XXXX --since <iso>`
- Example row:
- `2026-05-29T08:10:00.000Z G-1ABC-2-XYZ9 agent-ops agent_log agentLog:4821`
- ` ...anchoring this plan to G-1ABC-2-XYZ9 before execution...`
- Programmatic consumers can query the same signal through `TaskStore.listGoalCitations(...)`.
## Agent coordination tools summary
Seven coordination tools support spawning, provisioning, discovery, delegation, and direct-report config.