FN-5695: sync feature assertions for late-added mission features

Close the assertion-graph gap by making mission feature assertions store-managed and automatically synchronized.

- add `sourceFeatureId` to contract assertions (types, schema migration, persistence, snapshot restore)
- auto-create/update/delete managed assertions when features are added, edited, or removed in `MissionStore`
- remove duplicate/manual assertion creation from mission routes and rely on centralized store behavior
- expand core, dashboard, engine, and plugin tests plus docs to cover validator behavior for later-added features

Files changed:
 docs/missions.md                                   | 11 ++-
 docs/storage.md                                    |  2 +-
 packages/core/src/__tests__/db-migrate.test.ts     | 12 ++--
 packages/core/src/__tests__/db.test.ts             | 34 ++++-----
 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  | 82 +++++++++++++++++++---
 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                            | 11 ++-
 packages/core/src/mission-store.ts                 | 69 ++++++++++++++++--
 packages/core/src/mission-types.ts                 |  4 ++
 .../dashboard/src/__tests__/mission-e2e.test.ts    | 70 ++++++++++++------
 packages/dashboard/src/mission-routes.ts           | 16 +----
 .../src/__tests__/mission-execution-loop.test.ts   | 46 +++++++++++-
 .../src/store/__tests__/roadmap-store.test.ts      |  4 +-
 18 files changed, 288 insertions(+), 97 deletions(-)

Fusion-Task-Id: FN-5695
Fusion-Task-Lineage: 337f030c-e883-41aa-b982-13ebe45bd5ee
This commit is contained in:
gsxdsm
2026-05-29 13:19:51 -07:00
parent c5d03ae9de
commit bac12d1e28
18 changed files with 288 additions and 97 deletions

View File

@@ -129,10 +129,14 @@ Mission interview draft endpoints:
### Auto-Generated Assertions
When missions are created through the interview planning workflow, Fusion automatically generates contract assertions for each feature:
Fusion keeps a canonical per-feature assertion invariant in `MissionStore`:
- **Assertion text source priority**: `acceptanceCriteria``feature.description` → fallback text (`"Verify implementation of: {feature.title}"`)
- **Assertions are linked to features**: Each auto-generated assertion is automatically linked to its feature, enabling mission validation rollup and enriched planning context
- `addFeature()` creates exactly one store-managed assertion for each feature and links it.
- `updateFeature()` keeps that assertion synchronized when `title`, `description`, or `acceptanceCriteria` change.
- `deleteFeature()` removes the store-managed assertion to avoid orphaned rows.
- This applies to all creation paths (interview import, API, CLI, tools).
Assertion text source priority is: `acceptanceCriteria``feature.description` → fallback text (`"Verify implementation of: {feature.title}"`).
- **Verification fields**: Milestone and slice verification criteria from the interview are stored in dedicated `verification` fields rather than concatenated into descriptions
- **Milestone acceptanceCriteria derivation**: explicit `milestone.acceptanceCriteria` from interview output is authoritative. When omitted/blank, Fusion derives a deterministic bulleted summary from child features after creation: prefer `feature.acceptanceCriteria`, fall back to `feature.description`, skip empty contributors, and leave milestone acceptance empty when nothing contributes
- **Partial plans handled**: Auto-generation is robust to partial plans (missing slices/features or empty criteria) without throwing errors
@@ -233,6 +237,7 @@ Contract assertions (`MissionContractAssertion`) formalize what must be true for
interface MissionContractAssertion {
id: string; // e.g., "CA-A3B7CD-E9F2"
milestoneId: string; // Parent milestone
sourceFeatureId?: string;// Store-managed feature assertion owner
title: string; // Human-readable title
assertion: string; // Behavioral plan
status: AssertionStatus; // pending | passed | failed | blocked

View File

@@ -366,7 +366,7 @@ The `tasks.githubTracking` JSON column stores per-task GitHub tracking state (`e
| `chat_room_members` *(migration-created)* | Room membership map with composite PK `(roomId, agentId)` and role (`owner`/`member`). |
| `chat_room_messages` *(migration-created)* | Room message history with `senderAgentId`, JSON `mentions`, attachments/metadata blobs, ordered by `createdAt`. |
| `runAuditEvents` *(migration-created)* | Run audit trail events across database/git/filesystem mutation domains. |
| `mission_contract_assertions` *(migration-created)* | Milestone contract assertions used by mission validator workflows. |
| `mission_contract_assertions` *(migration-created)* | Milestone contract assertions used by mission validator workflows, including nullable `sourceFeatureId` for the store-managed per-feature assertion owner. |
| `mission_feature_assertions` *(migration-created)* | Many-to-many links between mission features and contract assertions. |
| `mission_validator_runs` *(migration-created)* | Validator run records for mission feature loop execution. |
| `mission_validator_failures` *(migration-created)* | Assertion failure records captured during validator runs. |