FN-5759: inject active-goal context across engine lanes

Enable always-on active-goal prompt injection and diagnostic wiring across triage/executor flows.

- Refactor goal-context injection so agent heartbeat, executor, and triage all apply the active-goal seam consistently.
- Extend goal injection diagnostics implementation and exports, plus anchoring audit touchpoints.
- Add and update tests for goal context injection behavior and diagnostics wiring.
- Update architecture and diagnostics docs to describe the new always-on seam.

Files changed:
 docs/architecture.md                               |  2 +-
 docs/diagnostics.md                                |  2 +-
 .../src/__tests__/goal-context-injection.test.ts   | 19 ++++-
 .../goal-injection-diagnostics-wiring.test.ts      | 98 +++++++++++++++++++++-
 packages/engine/src/agent-heartbeat.ts             | 31 ++-----
 packages/engine/src/executor.ts                    | 32 ++-----
 packages/engine/src/goal-anchoring-audit.ts        |  2 +-
 packages/engine/src/goal-injection-diagnostics.ts  | 42 +++++++++-
 packages/engine/src/index.ts                       |  2 +
 packages/engine/src/triage.ts                      | 28 +++++--
 10 files changed, 191 insertions(+), 67 deletions(-)

Fusion-Task-Id: FN-5759

Fusion-Task-Lineage: 1419de34-2e86-4459-bcd4-426f15c067fe
This commit is contained in:
gsxdsm
2026-05-30 21:54:06 -07:00
parent c9b159f4e5
commit d98ff8780c
10 changed files with 191 additions and 67 deletions

View File

@@ -436,7 +436,7 @@ Hybrid evaluator pipeline (FN-3389/FN-3391):
- `reviewer`
- `heartbeat`
- Integration points append the built plugin section to the role-specific system/task prompt only when contributions exist, preserving existing prompts when no plugins contribute.
- Executor and heartbeat system prompts also inject a shared `goalContext` dynamic layer via `buildGoalContextSection(...)`; when no active goals exist, no goal section is emitted.
- Executor, heartbeat, and planning (triage) system prompts inject a shared `goalContext` dynamic layer via the canonical `resolveAndEmitGoalContext(...)` seam (which uses `buildGoalContextSection(...)`); when no active goals exist, no goal section is emitted.
### Agent Permissions

View File

@@ -2,7 +2,7 @@
## Goal injection diagnostics (`[goal-injection]`)
Executor and heartbeat runs emit one goal-injection diagnostic with outcome `applied`, `no-goals`, or `disabled-or-failed`.
Executor, heartbeat, and planning runs emit one goal-injection diagnostic with outcome `applied`, `no-goals`, or `disabled-or-failed`.
- Run-audit event: `prompt:goal-injection` (`database` domain, target lane) with metadata `{ lane, outcome, goalCount, goalIds, truncated, reason?, errorClass?, runId?, agentId?, taskId? }`.
- Task log (executor lane with `taskId`): `[goal-injection] <outcome> count=<n> ids=<json-array> truncated=<bool> ...`.