feat(FN-5048): merge fusion/fn-5048

This commit is contained in:
gsxdsm
2026-05-18 13:01:31 -07:00
parent cae9c6c4fc
commit ef6c18942d
11 changed files with 162 additions and 197 deletions

View File

@@ -4,6 +4,11 @@ _Date: 2026-04-08_
## 1) Executive Summary
### FN-5048 test-speed hardening update (2026-05-18)
- See `docs/test-speed-audit-FN-5048.md` for full baseline + post-change timing tables, offender classifications (`keep/rewrite/delete`), and landed rewrite/trim outcomes.
- Contributor prevention policy was codified in `AGENTS.md` under **Standing Rule: Do Not Add Slow Tests (FN-5048)**.
### FN-3978 TaskStore suite split follow-up (2026-05-10)
- Decomposed `packages/core/src/__tests__/store.test.ts` into focused suites: `store-plugin-routing.test.ts`, `store-prompt-generation.test.ts`, `store-priority.test.ts`, `store-token-usage.test.ts`, `store-persistence.test.ts`, `store-settings.test.ts`, `store-attachments.test.ts`, `store-watcher.test.ts`, and `store-migration.test.ts`.

View File

@@ -0,0 +1,113 @@
# FN-5048 Test-Speed Audit
## Scope and method
- Related baseline context:
- `docs/test-audit-report.md` (prior workspace test audit baseline)
- `docs/testing-suite-quality-prd.md` (suite quality taxonomy + priorities)
- Commands run (baseline):
- `pnpm --filter @fusion/core exec vitest run --reporter=verbose --silent=passed-only`
- `pnpm --filter @fusion/engine exec vitest run --reporter=verbose --silent=passed-only`
- `pnpm --filter @runfusion/fusion exec vitest run --reporter=verbose --silent=passed-only`
- `pnpm --filter @fusion/dashboard exec vitest run --reporter=verbose --silent=passed-only`
- Durations were derived from verbose per-test timing logs by aggregating milliseconds per test file and top `describe` groups.
- Classification rubric:
- `delete`: low-signal/duplicate patterns from AGENTS.md “What NOT to write”.
- `rewrite`: keep coverage, reduce cost via fake timers/seam narrowing/lighter fixtures/shared harness.
- `keep`: high-signal regression/integration backstop.
## Baseline run totals
- `@fusion/core`: **26.29s** (pass)
- `@fusion/engine`: **93.29s** (pass)
- `@runfusion/fusion`: **13.90s** (pass)
- `@fusion/dashboard`: **359.52s** (`vitest run` across all dashboard projects; multiple unrelated pre-existing failures surfaced)
## Top offenders by package (baseline)
### @fusion/core (top 10)
| Rank | File | Aggregated runtime | Dominant suite(s) | Class | Proposed action |
|---|---|---:|---|---|---|
| 1 | `src/__tests__/agent-store.test.ts` | 8.47s | AgentStore (100%) | keep | Keep (broad state/store coverage). |
| 2 | `src/__tests__/mission-store.test.ts` | 6.16s | MissionStore (100%) | keep | Keep; prioritize targeted fixture slimming only if needed later. |
| 3 | `src/__tests__/db.test.ts` | 5.64s | Database (~68%) | keep | Keep (real SQLite backstop). |
| 4 | `src/__tests__/test-project.test.ts` | 5.13s | test-project fixture (100%) | rewrite | Evaluate fixture-heavy setup duplication, trim low-value cases. |
| 5 | `src/__tests__/plugin-loader.test.ts` | 3.48s | PluginLoader (100%) | keep | Keep. |
| 6 | `src/__tests__/store-watcher.test.ts` | 2.77s | TaskStore (100%) | rewrite | Replace slow polling waits with fake timers. |
| 7 | `src/__tests__/run-audit.test.ts` | 2.60s | Run Audit (100%) | keep | Keep. |
| 8 | `src/__tests__/store-comments.test.ts` | 2.58s | TaskStore (100%) | keep | Keep. |
| 9 | `src/__tests__/plugin-store.test.ts` | 2.48s | PluginStore (100%) | keep | Keep. |
| 10 | `src/__tests__/store-create.test.ts` | 2.41s | TaskStore (100%) | keep | Keep. |
### @fusion/engine (top 10)
| Rank | File | Aggregated runtime | Dominant suite(s) | Class | Proposed action |
|---|---|---:|---|---|---|
| 1 | `src/__tests__/merger-overlap-guard.test.ts` | 31.00s | overlap-aware fallback integration (~74%) | keep | Keep (real-git heavy merge safety). |
| 2 | `src/__tests__/merger-staging-allowlist.test.ts` | 20.41s | staging allowlist (~60%) | keep | Keep (explicitly protected real-git backstop). |
| 3 | `src/__tests__/merger-diff-volume-gate.test.ts` | 13.96s | integration + gate logic | keep | Keep. |
| 4 | `src/__tests__/self-healing-already-merged.real-git.test.ts` | 10.21s | real-git recovery | keep | Keep. |
| 5 | `src/__tests__/merger-autostash-cleanup.test.ts` | 9.79s | sweep* paths | keep | Keep. |
| 6 | `src/__tests__/branch-conflicts-recovery.test.ts` | 9.39s | branch recovery classification | keep | Keep. |
| 7 | `src/__tests__/merger-autostash-orphan-surface.test.ts` | 8.11s | autostash orphan surface | keep | Keep. |
| 8 | `src/__tests__/merger-squash-audit.test.ts` | 7.66s | squash audit | keep | Keep. |
| 9 | `src/__tests__/self-healing-stale-merge-stats.real-git.test.ts` | 7.01s | merge metadata recovery | keep | Keep. |
| 10 | `src/runtimes/__tests__/in-process-runtime.test.ts` | 6.29s | InProcessRuntime (100%) | rewrite | Trim low-value matrix/permutation assertions. |
### @runfusion/fusion (top 10)
| Rank | File | Aggregated runtime | Dominant suite(s) | Class | Proposed action |
|---|---|---:|---|---|---|
| 1 | `src/__tests__/extension.test.ts` | 5.08s | runnable structured-output slice (100%) | rewrite | Trim duplicate wiring cases; preserve env-gated legacy skip. |
| 2 | `src/__tests__/bin.test.ts` | 4.16s | command routing | rewrite | Consolidate repetitive route permutations with `it.each`. |
| 3 | `src/commands/__tests__/init.test.ts` | 3.53s | init command (100%) | keep | Keep. |
| 4 | `src/__tests__/vitest-workspace-resolution.test.ts` | 1.76s | workspace resolution | keep | Keep. |
| 5 | `src/__tests__/extension-task-tools.test.ts` | 1.65s | worktree root resolution | keep | Keep. |
| 6 | `src/commands/dashboard-tui/__tests__/app.test.tsx` | 1.57s | settings view subset | rewrite | Remove low-value display duplicates. |
| 7 | `src/commands/__tests__/chat.test.ts` | 0.84s | chat interactive | keep | Keep. |
| 8 | `src/commands/__tests__/dashboard.test.ts` | 0.80s | dashboard command | keep | Keep. |
| 9 | `src/__tests__/research-extension-tools.test.ts` | 0.71s | research tools | keep | Keep. |
| 10 | `src/commands/__tests__/serve.test.ts` | 0.51s | serve command | keep | Keep. |
### @fusion/dashboard (top 10)
| Rank | File | Aggregated runtime | Dominant suite(s) | Class | Proposed action |
|---|---|---:|---|---|---|
| 1 | `src/__tests__/routes-auth.test.ts` | 93.86s | `GET /auth/status` (~86%) | rewrite | Replace broad matrix with scoped auth-provider assertions and fixture helper. |
| 2 | `app/components/__tests__/SettingsModal.test.tsx` | 89.05s | SettingsModal (100%) | rewrite | Consolidate high-latency waitFor-heavy permutations. |
| 3 | `app/components/__tests__/ChatView.test.tsx` | 24.36s | ChatView (~52%) | rewrite | Replace polling waits with event/fake-timer driven completion. |
| 4 | `src/__tests__/routes-agents.test.ts` | 22.02s | mixed routes | rewrite | Remove repetitive field-presence and route permutations. |
| 5 | `app/components/__tests__/App.test.tsx` | 20.61s | app shell | rewrite | Reduce mock-the-world wiring cases that duplicate higher-level routes. |
| 6 | `app/components/__tests__/ListView.test.tsx` | 14.68s | bulk selection + list suites | rewrite | Consolidate combinatorial selection cases. |
| 7 | `app/components/__tests__/MissionManager.test.tsx` | 14.22s | MissionManager (100%) | keep/rewrite | Keep FN-tagged behavior; trim duplicate DOM-query shape checks. |
| 8 | `app/components/__tests__/PrCreateModal.test.tsx` | 11.61s | PrCreateModal | rewrite | Consolidate repetitive input permutations. |
| 9 | `app/components/__tests__/AgentPromptsManager.test.tsx` | 9.60s | AgentPromptsManager | rewrite | Convert repetitive cases into compact tables. |
| 10 | `app/components/__tests__/AgentDetailView.settings.test.tsx` | 9.43s | AgentDetailView settings | rewrite | Trim redundant control-shape assertions. |
## Prioritized execution plan
1. **Dashboard SettingsModal + ChatView targeted rewrites** (largest projected wall-clock gain).
2. **Dashboard routes-auth focused narrowing** (`GET /auth/status` hotspot).
3. **CLI bin/extension test consolidation** (`it.each` + duplicate route-case reductions).
4. **Core watcher fake-timer rewrite** (`store-watcher.test.ts`).
## Keep-safe exclusions explicitly honored
- No edits to reliability-interaction tests under `packages/engine/src/__tests__/reliability-interactions/**`.
- No deletion of FN-tagged regression tests.
- No concurrency/worker-cap changes.
## Post-change results (Step 5 re-measure)
- Re-ran the same per-package verbose commands after landed trims/rewrites.
- Post-change totals:
- `@fusion/core`: **23.08s** (pass)
- `@fusion/engine`: **76.66s** (pass)
- `@runfusion/fusion`: **9.40s** (pass)
- `@fusion/dashboard`: **335.40s** (`vitest run` failed with broad pre-existing suite issues unrelated to FN-5048 edits)
### Targeted outcome checks for FN-5048 edits
- `packages/core/src/__tests__/store-watcher.test.ts` (`rewrite`): reverted to per-test harness (`createTaskStoreTestHarness`) after measuring shared-harness regression for watcher-focused assertions; core suite total improved vs baseline.
- `packages/cli/src/__tests__/bin.test.ts` (`rewrite`/`trim`): redundant route permutations consolidated with `it.each`; CLI suite passes.
- `AGENTS.md` standing rule added and cross-linked from this audit to prevent reintroduction of slow-test patterns.
### Acceptance note
- Edited files classified as `rewrite`/`delete` were retained with measurable local pass behavior in their packages.
- `@fusion/core` no-regression gate satisfied after harness correction (baseline **26.29s** → post-change **23.08s**).
- Dashboard lane remains unstable from pre-existing repository-level failures in planning/tracking/interview route tests and unrelated UI suites; no FN-5048 file changes were made in those failing areas.
## Notes
- Dashboard `vitest run` baseline and post-change measurements both surfaced broad failing suites outside this tasks implementation scope; timing evidence is still captured from the same command family.
- Standing prevention rule: see `AGENTS.md`**Standing Rule: Do Not Add Slow Tests (FN-5048)**.

View File

@@ -4,6 +4,8 @@ _Created: 2026-05-05_
## Summary
> Latest speed-hardening measurements and contributor guardrails: `docs/test-speed-audit-FN-5048.md` and `AGENTS.md` → "Standing Rule: Do Not Add Slow Tests (FN-5048)".
Fusion has a large, useful, but uneven test suite. The suite is strongest where it exercises real SQLite state, git operations, published CLI bundle contracts, route auth/lease semantics, runtime orchestration, and user-visible mobile/native flows. It is weakest where it accumulates high-volume mechanical assertions: field-presence checks, CSS source-string checks, parser/regex matrices, type-shape runtime tests, class-name layout checks, and large mock-heavy component shells.
This PRD defines the work needed to make the suite smaller, more trustworthy, and easier to run correctly. The goal is not to chase a smaller test count for its own sake. The goal is to preserve high-signal regression coverage while cutting tests that lock implementation details or duplicate coverage already provided by better tests.