Skip to content

fix(reset): clear session-scoped tables on reset (fixes #501)#502

Open
mickume wants to merge 1 commit intodevelopfrom
fix/issue-501-reset-clear-session-state
Open

fix(reset): clear session-scoped tables on reset (fixes #501)#502
mickume wants to merge 1 commit intodevelopfrom
fix/issue-501-reset-clear-session-state

Conversation

@mickume
Copy link
Copy Markdown
Contributor

@mickume mickume commented Apr 20, 2026

Summary

After a block_limit run, reset --hard left stale data in six session-scoped DB tables. The stale runs.status='block_limit' caused load_state_from_db() to load a terminal status, making the engine loop exit immediately on every subsequent agent-fox code invocation — a self-perpetuating death-loop with no CLI recovery path.

Closes #501

Changes

File Change
agent_fox/engine/reset.py Added _clear_session_tables() helper that DELETEs rows from runs, session_outcomes, review_findings, verification_results, drift_findings, blocking_history. Called from all four reset paths: reset_all, reset_task, reset_spec, _perform_hard_reset. For scoped resets, spec-specific tables are filtered by spec_name; runs is always fully cleared.
tests/unit/engine/test_reset.py Added 11 regression tests across 3 classes verifying session table cleanup for hard reset, soft reset, and spec-scoped reset

Tests

  • TestHardResetClearsSessionTables (6 tests): each session table cleared by hard_reset_all
  • TestSoftResetClearsSessionTables (4 tests): reset_all and reset_task clear blocking state
  • TestResetSpecClearsSessionTables (1 test): spec-scoped cleanup preserves other specs' data

Verification

  • All existing tests pass: ✅ (5161 unchanged)
  • New tests pass: ✅ (11 added, total 5172)
  • Linter / formatter: ✅
  • No regressions: ✅

Auto-generated by af-fix.

…it death-loop (fixes #501)

After a block_limit run, reset --hard left stale data in runs,
session_outcomes, review_findings, verification_results, drift_findings,
and blocking_history tables. The stale runs.status='block_limit' caused
load_state_from_db() to load a terminal status, making the engine loop
exit immediately on every subsequent run — a self-perpetuating death-loop.

Add _clear_session_tables() and call it from all four reset paths
(reset_all, reset_task, reset_spec, _perform_hard_reset).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant