fix: prevent stale lock-skip signal leaking between compress_context calls

Advisor review found a critical stale-signal leak: if auto-compress
sets _compression_skipped_due_to_lock during a lock-skip, a subsequent
successful manual /compress will see the stale signal, falsely report
'Compression already in progress', and discard the compression results.

Fix:
- compress_context clears _compression_skipped_due_to_lock = None at
  entry so each call's outcome alone determines the signal.
- Unified gateway 'holder: unknown' drift to match CLI/TUI pattern
  (omit holder clause when not a descriptive string).
- Added MagicMock opt-outs in 3 sibling test files broken by the new
  signal check (test_compress_here, test_compress_focus,
  test_compress_plugin_engine).
- Added stale-signal-leak invariant test proving the fix.
This commit is contained in:
Ethan 2026-07-03 17:23:19 +10:00 committed by Teknium
parent 07cb4a697e
commit e8000b42e7
6 changed files with 74 additions and 3 deletions

View file

@ -26,6 +26,7 @@ def _wire_agent(shell, compressed_head):
shell.agent.session_id = None
shell.agent.tools = None
shell.agent._compress_context.return_value = (compressed_head, "")
shell.agent._compression_skipped_due_to_lock = False
def test_compress_here_compresses_head_only(capsys):