Skip to content

[Bug]: Feature.json corruption on crash loses task progress and makes features disappear #518

@Seonfx

Description

@Seonfx

Operating System: Linux (but affects all OS)

Run Mode: Electron (Desktop App) / Web (all modes affected)

App Version: Current development version


Bug Description:

When Automaker crashes (out of memory, disk full, process kill) during feature execution in Auto Mode, the feature.json file gets corrupted or truncated to 0 bytes. This causes:

  1. Features to disappear from the Kanban board (JSON.parse fails silently)
  2. Loss of all task progress (tasksCompleted counter reset)
  3. No automatic recovery mechanism to restore progress

The root cause is that feature.json uses non-atomic direct writes (secureFs.writeFile()) instead of the atomic write pattern (temp file + rename) that's already used for settings/credentials elsewhere in the codebase.


Steps to Reproduce:

  1. Start a feature in Auto Mode with multiple tasks
  2. Let it progress through several tasks (e.g., 8/12 completed)
  3. Simulate a crash: kill -9 the Automaker server process, OR fill up disk during execution
  4. The feature immediately disappears from the Kanban board
  5. Check .automaker/features/{featureId}/feature.json - it's 0 bytes (empty)

Expected Behavior:

  1. feature.json should be written atomically (using temp file + rename) to prevent corruption
  2. If feature.json is corrupted, system should auto-recover from backup
  3. Task progress (tasksCompleted) should be preserved across crashes
  4. Features should remain visible on Kanban board even after crashes

Actual Behavior:

  • feature.json gets truncated to 0 bytes
  • Features disappear from Kanban board (hidden due to JSON parse failure)
  • All task progress is lost
  • Manual intervention required to reconstruct feature.json

Relevant Logs:

```

  • When feature.json is 0 bytes:

  • No error logged, feature is simply skipped in getAll()

  • Console shows feature count is lower than expected:

  • "Loaded 15 features" (should be 16)

  • File system shows:
    $ ls -la .automaker/features/file-upload-system/
    -rw-r--r--. 1 seon seon 0 Jan 16 07:54 feature.json # EMPTY!
    -rw-r--r--. 1 seon seon 15000 Jan 16 07:14 agent-output.md # Intact
    ```


Additional Context:

Affected Code Locations:

  1. apps/server/src/services/feature-loader.ts - create(), update() methods
  2. apps/server/src/services/auto-mode-service.ts - updateFeatureStatus(), updateFeaturePlanSpec()
  3. apps/server/src/routes/app-spec/parse-and-create-features.ts - direct write

Existing Pattern to Follow:
The codebase already implements atomic writes for settings/credentials using temp file + rename pattern in apps/server/src/services/settings-service.ts. We should apply this same pattern to feature.json writes.

Proposed Solution:

  1. Create shared atomic write utility in libs/utils/src/atomic-writer.ts
  2. Add backup rotation (keep last 3 versions as .bak1, .bak2, .bak3)
  3. Add automatic recovery (detect corrupted JSON and restore from backup)
  4. Replace all feature.json writes with atomic writes

Impact:

  • High: Affects any Auto Mode feature execution that crashes
  • Recurring: Happens multiple times per week during heavy usage
  • Data loss: Loses valuable task progress and API conversation history

Checklist:

  • I have searched existing issues to ensure this bug hasn't been reported already
  • I have provided all required information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions