Commit Graph

380 Commits

Author SHA1 Message Date
gsxdsm
429eb4c4f9 feat(FN-1444): complete Step 2 — include soul in agent instructions assembly 2026-04-10 20:47:04 -07:00
gsxdsm
1fe55b22f1 perf(dashboard): kill startup SSE storm and slim hot-path task scans
- TaskStore.watch() now initializes lastPollTime so the first
  checkForChanges() poll filters by "modified since now" instead of
  doing an unfiltered SELECT * and emitting a task:updated event for
  every cached task. On a 1200-task board this dropped ~60 MB of SSE
  traffic and a 1199-call setState storm one second after dashboard
  startup.
- listTasks() gains a column option so callers can filter in SQL.
- dashboard CLI auto-merge sweeps (startup + 2 unpause handlers + the
  15s periodic retry) now use listTasks({ column: "in-review" })
  instead of pulling the full table on every cycle.
- self-healing archiveStaleDoneTasks() uses slim listTasks — it only
  needs id/column/columnMovedAt to decide staleness.
- Document the listTasks() perf contract and the watch() polling
  invariant in AGENTS.md and project memory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 20:40:42 -07:00
gsxdsm
5984584d22 perf(dashboard): slim task list + auto-archive stale done tasks
GET /api/tasks was returning ~69 MB of JSON per call (67.9 MB of agent
logs across 1199 tasks), causing the dashboard to hang for 2+ minutes.

- core: extend listTasks() with slim and includeArchived options
- dashboard: GET /api/tasks now uses slim mode and excludes archived
  by default; ?includeArchived=1 opts in
- frontend: lazy-load archived tasks when the archived column is first
  expanded via new useTasks.loadArchivedTasks()
- engine: self-healing maintenance now auto-archives done tasks older
  than 48h (data stays in SQLite, column flips done -> archived)
- tests: slim mode + includeArchived coverage in store.test.ts;
  routes.test.ts assertion updated for new args

Also bundles in-progress test-setup noise filters and pre-existing
QuickEntryBox/routes test work that was already modified locally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 20:16:20 -07:00
gsxdsm
f7322ab541 fix: improve merge verification and dashboard behavior 2026-04-10 18:30:23 -07:00
gsxdsm
d9acc10c49 feat(FN-1540): add lint as inline quality gate in task prompts
- Add ESLint configuration (eslint.config.mjs) for TypeScript/JavaScript linting
- Update executor prompts to include lint instruction before code submission
- Add lint check to triage prompt validation workflow
- Update agent prompts to emphasize lint compliance as quality requirement
- Add lint tool to agent toolset with file-level rule disabling capability
- Include lint in CI workflow with non-blocking status
- Update tests to verify lint-inclusive prompt behavior
- Add documentation for lint integration in contributing.md
- Add changeset for @gsxdsm/fusion minor release
2026-04-10 12:48:27 -07:00
gsxdsm
ed396fc6b6 feat(FN-1539): add deterministic merge verification runner
- Add verification runner that executes testCommand then buildCommand before merge completion
- Verification runs on all merge paths (AI resolve, auto-resolve, -X theirs)
- If verification fails, merge is aborted and task stays out of done
- Add comprehensive tests for merger verification logic
- Fix routine-store test variable reference bug (created.id vs routine.id)
- Add changeset for @gsxdsm/fusion patch release
2026-04-10 12:20:56 -07:00
gsxdsm
5cb368d7cf feat(FN-1269): complete routine engine integration with RoutineRunner and RoutineScheduler
- Add RoutineRunner class for routine execution via heartbeat system
- Add RoutineScheduler class for cron-based routine polling
- Add triggerManual and triggerWebhook methods for API and webhook triggers
- Wire RoutineScheduler into InProcessRuntime lifecycle
- Add routine trigger and webhook API endpoints
- Fix type mismatches between PROMPT and actual FN-1519 types
2026-04-10 12:11:55 -07:00
gsxdsm
6600b0b97e feat(FN-1556): merge fusion/fn-1556 2026-04-10 12:11:27 -07:00
gsxdsm
fa4c9f8841 fix: align routine system with actual RoutineStore/Routine APIs to prevent CLI crash
The RoutineRunner and RoutineScheduler were written against a different
interface than what RoutineStore actually implements, causing TypeError
crashes as soon as any routine became due. This adds the missing
agentId/catchUpLimit fields to the Routine type and DB schema, adds
startRoutineExecution/completeRoutineExecution/cancelRoutineExecution
methods to RoutineStore, and fixes all property name mismatches
(lastExecutedAt→lastRunAt, trigger.cron→trigger.cronExpression,
policy value alignment) in the runner, scheduler, and tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 11:26:19 -07:00
gsxdsm
0a102b5e29 feat(FN-1499): add workflow step revision loop signaling
- Add WorkflowStepSignal type with 'needs-revision' support for iterative QA loops
- Extend executeWorkflowStep() to detect needs-revision signals and trigger revision sessions
- Add revision loop limit (5 iterations max) to prevent infinite loops
- Track revisionAttempts in workflow step results
- Add comprehensive tests for revision signaling, loop behavior, and limit enforcement
- Document workflow step revision behavior in docs/workflow-steps.md
2026-04-10 10:50:11 -07:00
gsxdsm
0ab37d87a6 test(FN-1414): add run-audit integration tests for core and engine
- Add core run-audit integration regression tests covering task activity logging
- Add engine run-audit integration tests covering executor lifecycle and mutations
- Stabilize run-audit ordering with inline comments for deterministic behavior
- Update memory with run-audit testing learnings and patterns
- Fix test naming and use valid GitMutationType in tests
2026-04-10 09:21:38 -07:00
gsxdsm
22370960a2 feat(FN-1461): fix stuck-task retry for step-session mode
- Add step-scoped tracking key support in StuckTaskDetector for step-session mode
- Update tracking keys to include step session IDs when runStepsInNewSessions is enabled
- Add tests for step-scoped tracking behavior in executor and stuck-task-detector
- Ensure stuck task detection works correctly with per-step retry recovery
2026-04-10 08:58:37 -07:00
gsxdsm
cdee79d8e9 feat(FN-1525): add fresh-session and compact-and-retry options for merger agent
- Add freshSession option to MergeOptions to start clean agent sessions instead of resuming
- Add compactSession option for compacting session history before retry attempts
- Implement RetryStrategy type with freshSession and compactSession variants
- Add retryWithStrategy() method that attempts merge, then retries with configured strategy on failure
- Add comprehensive tests for retry logic covering success, simple retry, and compact-and-retry paths
- Update memory documentation with merger retry strategy guidance
2026-04-10 08:48:21 -07:00
gsxdsm
97afba2f7e fix(ci): fix test failures from recent feature additions
- Add ChatStore mock to all dashboard route tests that mock @fusion/core,
  since server.ts now instantiates ChatStore(store.getFusionDir(), ...)
- Add getFusionDir to createMockStore in server.test.ts
- Gate AI session cleanup scheduling behind shouldScheduleAiSessionCleanup()
  (returns false in test env) to prevent open handle warnings
- Fix desktop tests: DASHBOARD_URL is now exported as a function alias,
  update assertions to call DASHBOARD_URL() instead of using as string
- Add node:os mocks to system-metrics.test.ts for deterministic results
- Replace hardcoded maxWorkers=16 with availableParallelism()-based
  calculation in all vitest configs to prevent OOM on 2-core CI runners
- Add --workspace-concurrency=2 to pnpm test commands
- Fix TaskCard tests: update mission badge title assertions to full titles
- Remove unused /api/mesh/state route
- Fix plugin-auto-label: add isError field, async onTaskCreated, "tests" keyword
- Fix plugin-ci-status: add module-level logger, tighten test assertions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 08:01:03 -07:00
gsxdsm
75d160e3e3 fix(engine): recover orphaned tasks at startup 2026-04-10 07:19:26 -07:00
gsxdsm
e028a57bea feat(FN-1462): fix compact-and-retry path to not mark task as failed on successful recovery
- Add return statement after successful context compaction and resume
- When compact-and-resume succeeds (promptWithFallback completes without error),
  executor now returns early instead of falling through to failure path
- This allows the finally block to clean up without marking the task as failed
- Add logging for recovery success and failure paths
- Add regression tests for context limit error detection
- Pattern is conservative: requires both 'context window' and 'exceeds' present
2026-04-10 03:05:41 -07:00
gsxdsm
f246fe4896 feat(FN-1462): add context window exceeds limit pattern to context-limit-detector
- Add new regex pattern /context\s+window\s+exceeds/i to match provider JSON error
  envelope variant: "context window exceeds limit (2013)"
- Add 4 new test cases for the variant pattern
- Pattern is conservative: requires both "context window" and "exceeds" present
2026-04-10 03:02:38 -07:00
gsxdsm
174ef490e7 feat(FN-1404): add run-audit instrumentation layer for agent run mutations
- Add shared RunAuditService in packages/engine/src/run-audit.ts for tracking agent run state transitions
- Instrument HeartbeatMonitor to log run mutations (create, complete, error, skip) with timestamps and context
- Instrument TaskExecutor to log run mutations during task execution lifecycle
- Instrument Merger to log run mutations during merge workflow
- Add run-audit pattern documentation to project memory
- Fix: remove audit calls from non-run recovery methods to avoid false positives
2026-04-10 02:56:57 -07:00
gsxdsm
bee0e399ff feat(FN-1401): integrate PluginRunner into runtime lifecycle
- Integrate PluginRunner into InProcessRuntime for plugin lifecycle management
- Wire plugin:created, plugin:updated, plugin:deleted events through runtime event bus
- Add plugin tools to StepSessionExecutor so plugins can provide tools during step execution
- Fix PluginRunner to pass PluginContext to task lifecycle hooks (onTaskCreated, onTaskUpdated, etc.)
- Add PluginRunner tests covering init/shutdown, timeout isolation, and sync event behavior
- Add InProcessRuntime tests verifying plugin integration
- Update memory documentation with plugin runner lifecycle wiring
2026-04-10 02:29:47 -07:00
gsxdsm
dfaf768601 feat(FN-1430): add worktree execution boundaries to prevent out-of-scope modifications
- Add worktree-aware path boundaries in agent factory to prevent cross-task contamination
- Sync core agent prompts with worktree boundary guidance for consistent enforcement
- Add boundary guidance to executor prompts so agents understand their scope
- Fix TypeScript types for worktree boundary wrapping
- Add comprehensive tests for boundary wrapping behavior
- Create changeset for @gsxdsm/fusion (minor)
2026-04-09 23:59:45 -07:00
gsxdsm
094db24992 fix(engine): recover stuck in-review merges 2026-04-09 22:30:41 -07:00
gsxdsm
b93c418356 fix: recover tasks stuck in review after pause 2026-04-09 22:14:44 -07:00
gsxdsm
b738019ddb feat(FN-1500): suppress per-tool triage stdout spam
- Add tool-specific toolOutput handler in triage agent to filter per-tool output
- Add test coverage for tool output suppression behavior
- Suppress console spam from read_file, Read, glob, Grep tools during triage runs
- Update memory documentation with Vitest expect.any(Number) pitfall
2026-04-09 21:28:30 -07:00
gsxdsm
34c11a7078 feat(FN-1259): add review handoff mechanism for user assignment
- Add assigneeUserId field to Task type and SQLite schema for human assignment
- Add reviewHandoffPolicy setting to control automatic handoff behavior
- Implement handoff detection in executor: detect user assignment during review and auto-transition task
- Add dashboard API routes for user assignment, handoff queries, and completion
- Add frontend API functions: getHandoffTask, assignTaskToUser, completeHandoff
- Add comprehensive tests for store methods, API routes, and executor handoff logic
- Update memory documentation with review handoff pattern
2026-04-09 21:06:19 -07:00
gsxdsm
0c845b97bc fix: force-requeue stuck task when hung subprocess blocks executor unwind
When a stuck task's session is disposed but an in-flight bash subprocess
keeps running, the executor's Promise never resolves, so the requeue
finally block never fires and the task stays stranded in-progress
indefinitely (observed with FN-1269).

Add a 60s safety-net timer in markStuckAborted: if the task is still in
executing after the grace period, force-requeue it directly by clearing
the worktree, setting status=stuck-killed, moving to todo, and removing
it from the executing set so the scheduler can re-dispatch normally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 20:12:09 -07:00
gsxdsm
7bd98d888c feat(FN-1429): enforce always-green test-suite instructions for executor agents
- Add explicit always-green test suite instructions to executor agent prompts
- Update executor to enforce test-suite validation before task completion
- Add tests for agent prompt generation and executor behavior
- Ensure test failures block merge-ready state rather than allowing broken builds
2026-04-09 19:33:44 -07:00
gsxdsm
db0d5c8dc9 feat(FN-1133): add plugin hot-reload support
- Add PluginLoader hot-load/unload with watch mode, auto-recovery, and staged loading
- Add PluginRunner reactive integration with executor dynamic tools registration
- Add dashboard reload endpoint (POST /api/plugins/reload) and PluginManager UI
- Add comprehensive tests for plugin-hot-reload (core) and plugin-runner (engine)
- Update plugin authoring docs and add memory notes
- Add changeset for @gsxdsm/fusion minor release
2026-04-09 19:15:53 -07:00
gsxdsm
ecb5baeea5 feat(FN-1113): complete Step 2 — executor integration with PluginRunner 2026-04-09 18:33:46 -07:00
gsxdsm
c9eacbfdf4 test: fix assertions broken by runContext propagation
store.logEntry, assignTask, and checkoutTask now receive an extra
runContext argument. Updated test assertions in executor.test.ts,
agent-heartbeat.test.ts, and restart.integration.test.ts to match
the current call signatures using expect.objectContaining where
appropriate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 18:31:54 -07:00
gsxdsm
c36b6d1f53 fix: use canonical task ID in stuck-task-detector for step-session mode
In step-session mode each step is registered with StuckTaskDetector
under a compound key (e.g. "FN-1452-step-1") rather than the bare
task ID. When stuck detection fired, event.taskId was that compound
key, breaking three things simultaneously:

1. beforeRequeue("FN-1452-step-1") → store.getTask() threw (no such
   task) → stuckKillCount never incremented on the real task.

2. markStuckAborted("FN-1452-step-1") → activeStepExecutors.get()
   returned undefined (keyed by "FN-1452") → terminateAllSessions()
   never called, other step sessions kept running.

3. stuckAborted.set("FN-1452-step-1") → executor checks
   stuckAborted.has("FN-1452") → miss → stuckRequeue never set
   → task never moved to todo.

Fix: add a canonicalTaskId field to TrackedTask (defaults to the
tracking key for single-session mode where they are identical).
StepSessionExecutor now passes taskDetail.id as the third arg to
trackTask(). killAndRetry() uses entry.canonicalTaskId for all
external callbacks so they always resolve to the real task ID.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 18:16:55 -07:00
gsxdsm
b682898caf feat(FN-1454): improve mission autopilot and stale recovery
- Unify slice activation and auto-triage semantics for mission progression
- Align engine progression with stale recovery logic for active missions
- Fix scheduler delegation check to use feature.missionId instead of deprecated field
- Add integration tests for stale mission recovery scenarios
- Fix mission API recovery gaps for active missions (activate on first non-done slice)
- Update README.md autopilot documentation section
2026-04-09 18:10:29 -07:00
gsxdsm
daabb51e71 feat(FN-1399): add background memory summarization after task completion
- Add MemoryInsights class in @fusion/core for AI-powered memory audit generation
- Add post-run hook to CronRunner for triggering memory summarization after scheduled tasks
- Wire memory background processing in both dashboard and serve commands
- Add memoryAuditEnabled and memoryAuditSchedule settings for configurable automation
- Fix startup ordering: sync automation before cronRunner.start() to prevent race conditions
- Add comprehensive tests for memory-insights and dashboard/serve integration
- Update contributing.md and settings-reference.md with documentation
2026-04-09 16:14:44 -07:00
gsxdsm
8ba375549c feat(FN-1453): fix mission autopilot progression and state refresh
- Fix mission autopilot slice activation when tasks complete
- Fix state refresh in MissionManager to properly reflect autopilot status
- Fix scheduler to correctly trigger autopilot progression events
- Add unit tests for mission store autopilot state transitions
- Add component tests for MissionManager autopilot toggle and state display
- Add e2e tests for mission autopilot lifecycle (enable → task completion → slice progression)
- Update documentation with autopilot state machine details
2026-04-09 16:12:58 -07:00
gsxdsm
a1e5cbce2b fix(FN-1384): increase timeouts for CI-slow agent store tests
- Increase heartbeat test timeout from 150ms to 250ms for CI environments
- Increase in-process-runtime test timeouts to handle slower CI execution
- Prevents flaky test failures in slow CI runners
2026-04-09 14:54:58 -07:00
gsxdsm
7d484dd972 feat(FN-1257): add runContext audit trail for task mutations
- Add RunMutationContext type to track which agent run caused a mutation
- Thread runContext through TaskStore.logEntry, addComment, addSteeringComment, and pauseTask
- Propagate runContext from HeartbeatMonitor.executeHeartbeat to task store operations
- Propagate runContext from TaskExecutor.execute to task store operations
- Add GET /api/agents/:id/runs/:runId/mutations endpoint to query mutations by runId
- Add createTaskLogToolWithContext for heartbeat tools with run context support
- Add comprehensive tests for RunMutationContext across store and heartbeat modules
- Update memory.md with RunMutationContext usage convention
2026-04-09 13:59:43 -07:00
gsxdsm
e26321790c refactor(FN-1353): simplify mission autopilot to single toggle
- Deprecate autoAdvance field in favor of autopilotEnabled as the sole control
- Remove autoAdvance guard logic from MissionAutopilot engine class
- Simplify MissionManager UI to use single autopilot toggle with visual state indicator
- Update MissionAutopilot tests to use autopilotEnabled instead of autoAdvance
- Update MissionManager component tests for simplified UI
- Update AGENTS.md documentation to reflect the simplified autopilot model
2026-04-09 13:45:19 -07:00
gsxdsm
008f664183 feat(FN-1224): add peer gossip protocol for mesh network synchronization
- Add peer exchange types (MeshSyncState, PeerExchangeMessage, PeerGossipConfig) to core types
- Add peer merge and sync methods to CentralCore (mergeProject, syncWithPeer, getMeshState)
- Add mesh sync API endpoints (GET /api/mesh/state, POST /api/mesh/sync)
- Implement PeerExchangeService background gossip engine for periodic peer synchronization
- Add comprehensive tests for CentralCore mesh methods and PeerExchangeService
- Update memory docs with peer gossip protocol documentation
2026-04-09 13:22:29 -07:00
gsxdsm
7ab96cc876 feat(FN-1381): add Send Back dropdown for in-progress tasks
- Add Send Back dropdown to TaskCard showing for in-progress tasks with available target columns
- Thread onMoveTask prop through Column component to BoardView
- Terminate agent sessions when tasks move away from in-progress column
- Add executor tests for move-away session termination
- Add TaskCard send-back UI tests with dropdown visibility and interaction verification
2026-04-09 13:00:37 -07:00
gsxdsm
ced3ad3be6 fix(FN-1187): integration fixes for mission health and type updates
- Add /missions/health endpoint handling to MissionManager test mocks
- Add listMissionsWithSummaries to mission-e2e test mock
- Add planState to Slice type and mock factories
- Add stuckKillCount to retry task test assertions
- Update log message for stuck-killed retry
2026-04-09 12:21:51 -07:00
gsxdsm
6328c18c9c feat(FN-1373): add mission feature reconciliation on startup
- Add reconcileAllMissionFeatures() method to sync task status with mission features
- Refresh selected mission detail when feature:updated SSE event fires
- Add unit tests for reconcileAllMissionFeatures and SSE handler
- Fix async getTask call in reconcileAllMissionFeatures (keep await)
2026-04-09 12:06:10 -07:00
gsxdsm
27dce00c17 fix(FN-1228): Update tests to match spec requirements
- DELETE /api/nodes/:id now returns 204 No Content
- GET /api/nodes/:id/metrics returns systemMetrics from node
- Added test for GET /api/mesh/state endpoint
2026-04-09 11:55:17 -07:00
gsxdsm
5e38eace77 feat(FN-1228): complete Step 1 — Backend API Routes modifications
- Modified POST /api/nodes to make type optional (defaults to 'remote')
- Changed DELETE /api/nodes/:id to return 204 No Content
- Updated GET /api/nodes/:id/metrics to return SystemMetrics from node.systemMetrics
- Added GET /api/mesh/state route for full mesh topology state
2026-04-09 11:51:03 -07:00
gsxdsm
97c6edd105 feat(FN-1373): add tests for reconcileAllMissionFeatures and feature:updated SSE handler 2026-04-09 11:34:56 -07:00
gsxdsm
7d1a16ffcd feat(FN-1373): add reconcileAllMissionFeatures() for startup reconciliation 2026-04-09 11:28:56 -07:00
gsxdsm
ac07be790b feat(FN-1348): export HeartbeatMonitor and HeartbeatTriggerScheduler from @fusion/engine 2026-04-09 09:42:21 -07:00
gsxdsm
4d1a14f49e fix: use null instead of undefined to clear worktree/branch in executor updateTask calls
The store's updateTask treats `undefined` as "no change" and `null` as
"clear field". Six places in executor.ts passed `undefined` when intending
to clear worktree/branch, leaving stale references that caused tasks to
get stuck in in-progress with no active session after stuck-kills, pauses,
and transient error retries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 08:43:14 -07:00
gsxdsm
a0606884cb fix: recover orphaned in-progress tasks even when worktree exists on disk
Previously, recoverOrphanedExecutions() skipped tasks whose worktree
directory still existed, assuming an active session. After engine crashes
where resumeOrphaned() failed, these tasks were stuck forever. Now uses
a tiered grace period: 60s for missing worktrees, 5min for existing ones
to avoid racing with startup recovery.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 07:21:14 -07:00
gsxdsm
7a9148d25d perf: speed up tests with parallel execution and fix type errors
- Add isolate: true to vitest configs for safe parallel test execution
- Simplify engine test script from 7 sequential runs to single parallel run
- Fix TypeScript type errors in Column, Board, WorktreeGroup, and App components
- Fix board-mobile test to match current TaskCard tap behavior
- Relax App deep-link test to handle React Strict Mode behavior
2026-04-08 23:53:14 -07:00
gsxdsm
6250cf4efb fix(FN-1256): auto-recover tasks with all steps done but no task_done call
When context overflow or compaction causes an agent to lose awareness of
the task_done tool, the executor now checks if all steps are complete
before failing — treating it as an implicit task_done. Also adds
self-healing recovery for tasks that already slipped through as
misclassified failures in in-review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 22:12:53 -07:00
gsxdsm
f2829c7634 fix(FN-1290): recover orphaned stuck tasks 2026-04-08 20:22:58 -07:00