Skip to content

[BUG] log_action() writes to memory before persistence, creating ghost actions when SQLite writes fail #267

@Ridanshi

Description

@Ridanshi

Summary

The action logging workflow updates in-memory state before confirming successful persistence.

If SQLite operations fail, actions remain present in memory despite never being committed to storage.

This creates divergence between the authoritative database state and runtime state.

Affected File

core/hybrid/action_logger.py

Root Cause

log_action() appends actions to the in-memory stack before executing the SQLite INSERT and COMMIT.

If persistence fails, the action remains in memory but is absent from the database.

Reproduction

  1. Force SQLite write failure.
  2. Call log_action().
  3. Observe that the action exists in memory.
  4. Observe that the action does not exist in SQLite.
  5. Restart the server.
  6. Observe that the action disappears entirely.

Expected Behavior

Actions should only enter runtime state after successful persistence.

Actual Behavior

Actions can exist only in memory.

Why This Is Difficult To Detect

SQLite writes rarely fail during normal testing.

Unit tests typically mock database operations successfully.

Production Impact

  • Persistence divergence
  • Ghost actions
  • Lost history after restart
  • Inconsistent undo behavior

Severity

High

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions