Commit Graph

419 Commits

Author SHA1 Message Date
gsxdsm
4bbd42c88e fix(engine): recover already-merged tasks stuck in in-review
When a merge completes but auto-recovery moves the task back to
in-review, the retry gating (mergeRetries >= 3) blocked re-processing.
Now canMergeTask always accepts mergeConfirmed tasks and drainMergeQueue
fast-paths them directly to done without re-running the merge agent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 07:49:54 -07:00
gsxdsm
bbe2542362 Read provider settings from fusion fallback 2026-04-13 07:05:01 -07:00
gsxdsm
18cdeceebf fix(engine): keep executor prompts scoped to worktrees 2026-04-13 00:03:16 -07:00
gsxdsm
79fdb691cf feat(FN-1492): fix workspace file operation route collision
- Fix Express route ordering where wildcard POST /files/{*filepath} was capturing operation routes
- Move operation routes (delete, copy, move, rename) before the generic write route to ensure proper matching
- Add missing ProjectEngine methods (getHeartbeatTriggerScheduler) for dashboard compatibility
- Add 189 regression tests verifying operation routes work correctly with nested paths
- Document Express wildcard route ordering pitfall in memory
2026-04-12 23:58:49 -07:00
gsxdsm
ca87a96cb4 Fix dashboard startup blocking on recovery 2026-04-12 23:50:51 -07:00
gsxdsm
f88d04ae03 fix non-node worktree agent startup 2026-04-12 22:34:46 -07:00
gsxdsm
3fc577fb5e feat: multi-project engine runtime improvements
- Update project manager and runtime interfaces for multi-project coordination
- Add project engine configuration to core types and settings schema
- Enhance child-process worker tests for signal handling coverage
- Extend in-process runtime with per-project engine lifecycle hooks

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-04-12 19:59:12 -07:00
gsxdsm
d14cba949b fix: add projectId to remaining unscoped API functions
- GitHub import functions: apiImportGitHubIssue, apiBatchImportGitHubIssues, apiImportGitHubPull
- Task file operations: fetchFileList, fetchFileContent, saveFileContent
- AI title summarization: summarizeTitle
- Terminal command execution: execTerminalCommand
- Wire projectId through GitHubImportModal, AppModals, useFileBrowser, useFileEditor hooks

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-04-12 19:34:22 -07:00
gsxdsm
2562814518 fix: project-scope terminal, file browser, agent execution, and heartbeat monitor
- TerminalService: use per-project instance map instead of destructive singleton
- File browser: thread projectId through API functions, hooks, and components
- Workspace file editor: pass projectId to read/write operations
- Agent heartbeat: guard execution with project scope validation
- Agent runs/stop: validate heartbeatMonitor matches scoped project
- CLI dashboard/serve: pass rootDir to heartbeatMonitor via server options
- Add getRootDir() to HeartbeatMonitor for scope comparison

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-04-12 18:38:26 -07:00
gsxdsm
860d3c29fe feat(FN-1646): add stale-spec guard to prevent execution of outdated tasks
- Add spec-staleness evaluator to check task specification age before execution
- Guard executor startup and resume to prevent running tasks with stale specs
- Guard scheduler dispatch to skip stale tasks and move them back to triage
- Add comprehensive tests for spec staleness detection (7d/14d thresholds)
- Add getFusionDir mock for executor staleness check tests
2026-04-12 17:49:22 -07:00
gsxdsm
1c577176ea fix(FN-1619): convert remaining engine execSync calls to async execAsync
- Replace blocking execSync calls with async execAsync in executor.ts for user-configured commands
- Convert self-healing.ts worktree status checks to async to avoid blocking the event loop
- Update step-session-executor.ts to use async worktree operations
- Refactor worktree-pool.ts for fully async worktree creation, cleanup, and listing
- Convert pi.ts agent session handling to async execution
- Update all corresponding tests with async/await patterns
- Add changeset for @gsxdsm/fusion patch release
2026-04-12 17:21:24 -07:00
gsxdsm
e8d0740d0d feat(FN-1643): add context-limit recovery for step-session execution
- Add context-overflow detection and recovery in step-session executor with same parity as single-session
- Implement step resumption from overflow checkpoints with accumulated context replay
- Add overflow state tracking and recovery logging for diagnostics
- Harden single-session executor overflow recovery with improved state management
- Update appendAgentLog parameter signatures across executors
- Add comprehensive tests for context overflow scenarios in both execution modes
- Add memory entry documenting the unified context-limit recovery approach
2026-04-12 15:50:09 -07:00
gsxdsm
59edac4ce2 feat(FN-1632): merge fusion/fn-1632 2026-04-12 15:28:10 -07:00
gsxdsm
a34ba41ad1 Harden architecture hot paths 2026-04-12 15:13:27 -07:00
gsxdsm
8c1f6a19b1 fix(FN-1623): add eslint-disable comments for kept functions
- Add eslint-disable comments for unused parameters in truncateVerificationOutput and summarizeVerificationOutput
- Preserve functions that may be useful for future diagnostics while silencing no-unused-vars warnings
2026-04-12 13:56:11 -07:00
gsxdsm
724bb7931a test: reduce default runner noise and contention 2026-04-12 13:41:10 -07:00
gsxdsm
b019ef2c8c feat(FN-1617): add verification output summarization for concise test failure reports
- Add summarizeVerificationOutput helper function to condense test output
- Update runVerificationCommand to use summarization for cleaner merge reports
- Improve readability of test failure summaries in the dashboard
2026-04-12 13:31:27 -07:00
gsxdsm
52f1f77369 test: remove waits from slow tests 2026-04-12 12:52:32 -07:00
gsxdsm
31815e0fba fix(FN-1600): complete async conversion of hasRecoverableGitWork
- Convert hasRecoverableGitWork from sync execSync to async execAsync
- Update recoverNoProgressNoTaskDoneFailures caller to await the method
- Update self-healing tests to work with async method and execAsync mock
- Add exec and promisify imports to self-healing.ts
- Fix mock to include exec export for promisify compatibility
2026-04-12 12:24:54 -07:00
gsxdsm
494b7da5f1 fix(FN-1473): recover no-progress task_done failures 2026-04-12 12:13:06 -07:00
gsxdsm
e82736a171 fix(FN-1600): update merger tests for -X theirs escalation strategy
The FN-1598 merger.ts async conversion introduced an escalation strategy where
attempt 3 uses -X theirs and succeeds when AI fails. The tests were expecting
the merge to fail after 3 AI attempts, but now attempt 3 succeeds via the
theirs strategy.

This commit fixes the test mocks to make the -X theirs merge fail so all
3 attempts exhaust and the function throws as expected.
2026-04-12 11:47:27 -07:00
gsxdsm
86f1f93de9 feat(FN-1599): merge fusion/fn-1599 2026-04-12 06:50:53 -07:00
gsxdsm
db4badcae7 feat(FN-1598): merge fusion/fn-1598 2026-04-12 06:50:45 -07:00
gsxdsm
003ef625ab fix blocking hot path operations 2026-04-11 21:23:36 -07:00
gsxdsm
d423dfcff6 fix: suppress execution output on stdout 2026-04-11 21:13:16 -07:00
gsxdsm
9a242c46b5 fix engine build and test resolution 2026-04-11 20:42:26 -07:00
gsxdsm
67d2222202 Harden dashboard worktree shutdown handling 2026-04-11 20:28:34 -07:00
gsxdsm
f6ba5aa75a test(FEAT-004-FIX-002): add comprehensive unit tests for MissionExecutionLoop
Tests cover:
- parseValidationResult with JSON extraction from markdown code blocks and malformed responses
- handleValidationPass verifying feature marked 'passed' and autopilot notified
- handleValidationFail verifying fix feature generated and retry budget decremented
- handleValidationBlocked verifying feature marked 'blocked' without fix generation
- Retry budget enforcement preventing further implementations when exhausted
- recoverActiveMissions verifying actual processTaskOutcome calls for features in validating/needs_fix states

Added 23 new tests (1916 total, up from 1893).
2026-04-11 20:13:47 -07:00
gsxdsm
98bf55c356 fix(FEAT-004-FIX-001): fix MissionExecutionLoop validation parsing and recovery
- Implement actual AI response parsing in parseValidationResult() with JSON extraction
  from markdown code blocks, repair for common JSON issues, and assertion result parsing
- Fix notifyValidationComplete to pass feature.taskId instead of featureId to
  handleTaskCompletion() in in-process-runtime, dashboard, and serve
- Fix recoverActiveMissions() to actually transition validating features back to
  implementing and call processTaskOutcome for features with completed tasks
- Add comprehensive unit tests for MissionExecutionLoop lifecycle, processTaskOutcome,
  recoverActiveMissions, and error handling
2026-04-11 19:48:53 -07:00
gsxdsm
bc3688badf fix(engine): run user commands via async exec to avoid blocking event loop
The merger's test/build verification, executor's worktreeInitCommand,
setupScript, and script-mode workflow steps all used execSync, which
blocks Node's event loop until the child process exits. A hanging
pnpm test could freeze the entire engine (no logs, heartbeats, or
other task progress) for the full 5-minute timeout.

Switch these call sites to promisify(exec) with awaited calls so the
engine keeps running while user-configured commands execute. Short
internal git plumbing (rev-parse, branch -d, worktree remove) still
uses execSync since those commands are bounded and measured in ms.

Document the rule in AGENTS.md under a new "Engine process rules"
section so future agents don't reintroduce blocking behavior.

Tests: update child_process mocks in merger.test, executor.test, and
restart.integration.test to route the new async exec through the
existing execSync mock and expose promisify.custom so destructuring
{ stdout, stderr } matches real child_process.exec semantics.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 18:28:05 -07:00
gsxdsm
46fff0d33f feat(FEAT-004): add MissionExecutionLoop class and wiring
- Create MissionExecutionLoop class for validation cycle orchestration
- Wire loop into dashboard.ts and serve.ts startup/shutdown alongside MissionAutopilot
- Integrate processTaskOutcome into scheduler's task:moved handler for mission-linked tasks
- Implement validation pass/fail/blocked/error handling with fix feature generation
- Implement retry budget exhaustion handling via createGeneratedFixFeature
- Implement recoverActiveMissions on startup to re-enqueue pending validations
- Wire loop into InProcessRuntime lifecycle
- Add AI session integration with createKbAgent and promptWithFallback
- Implement autopilot coordination via notifyValidationComplete callback
- Add error handling for AI/store failures with graceful loop continuation
- Extend SchedulerOptions with optional missionExecutionLoop field
- Export MissionExecutionLoop from engine barrel

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-04-11 18:04:21 -07:00
gsxdsm
429d5855ee feat(FEAT-001): add loop state columns and validator run tables for mission execution loop
This commit adds the schema migration and types for the mission execution loop validation system:
- Adds loop state tracking columns to mission_features table (loopState, implementationAttemptCount, validatorAttemptCount, lastValidatorRunId, lastValidatorStatus, generatedFromFeatureId, generatedFromRunId)
- Creates mission_validator_runs table for tracking validation runs
- Creates mission_validator_failures table for assertion failure records
- Creates mission_fix_feature_lineage table for tracking fix feature relationships
- Adds workflowStepRetries column to tasks table for retry tracking
- Adds FEATURE_LOOP_STATES and VALIDATOR_RUN_STATUSES enums
- Updates TaskStore to support workflowStepRetries field
- Updates TaskExecutor to handle workflow step failures with retry logic

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-04-11 17:06:41 -07:00
gsxdsm
12c38ef0ea feat(FN-1588): add truncated-prompt retry for merger context-limit recovery
- Detect when merge prompt exceeds context limit and gets truncated
- Retry merge with compacted prompt when truncation is detected
- Create fresh session after context limit recovery
- Add comprehensive tests for truncation detection and recovery flow
- Update merge prompt generation to include truncation signal
2026-04-11 11:39:50 -07:00
gsxdsm
fee27abb56 feat(FN-1571): merge fusion/fn-1571 2026-04-11 11:04:04 -07:00
gsxdsm
6dd66f6a31 fix(merger): truncate verification output and retry via in-progress
Deterministic verification failures were embedding the raw stderr/stdout
(up to 50MB per VERIFICATION_COMMAND_MAX_BUFFER) in a second log entry,
flooding logs/stdout and crashing the app. The runVerificationCommand
helper already wrote a truncated summary, so verifyDeterministicBuild
now just references it.

When the failure surfaces in the dashboard merge handler, kick the task
back to in-progress with a steering comment so the agent can fix the
failing test/build instead of parking it in in-review with a fatal
error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 06:56:18 -07:00
gsxdsm
c8831f7b3b feat(FN-1553): reduce memory bloat with selective save behavior
- Update project memory instructions to encourage selective writes instead of unconditional appends
- Instruct agents to consolidate existing entries rather than add duplicates
- Add guidance to skip memory updates when no durable learnings were discovered
- Clarify what qualifies as durable learnings vs task-specific trivia
- Update user-facing memory documentation to reflect new selective behavior
- Add test coverage for selective memory write instructions
2026-04-11 00:38:42 -07:00
gsxdsm
33cfef2592 feat(FN-1426): add tests for prompt override edit/reset/save behavior 2026-04-10 22:33:29 -07:00
gsxdsm
34b2af26a7 Fix task card step progress 2026-04-10 21:46:06 -07:00
gsxdsm
39ffb4b456 feat(FN-1562): merge fusion/fn-1562 2026-04-10 21:22:59 -07:00
gsxdsm
ed700ba1d1 fix(dashboard): restore jest-dom matchers in QuickEntryBox/InlineCreateCard tests
Changed @testing-library/jest-dom import to @testing-library/jest-dom/vitest
in vitest.setup.ts to properly provide type definitions for jest-dom matchers
like toBeInTheDocument, toHaveClass, toBeDisabled, and toHaveAttribute in the
vitest environment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 21:22:34 -07:00
gsxdsm
1a3ff011d3 chore: snapshot WIP across dashboard, engine, and core
Bundles staged work-in-progress modifications across multiple packages
(routes, store, agent-instructions, self-healing, QuickEntryBox, etc.)
plus the dashboard theme-data.css preload fix.

Note: an unstaged 621-line deletion in .fusion/memory.md was deliberately
NOT committed — it appears to be an accidental overwrite of architecture
notes and is left in the working tree for review.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 21:12:40 -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