Skip to content

Commit 2342b9f

Browse files
felipetrumanclaude
authored andcommitted
test: remove attempt-cap tests obsoleted by develop's pass-through approach
PR MemPalace#863 on develop eliminated precompact blocking entirely. After rebasing, the attempt-cap tests (test_precompact_first_two_attempts_block, test_precompact_passes_through_after_cap, test_precompact_counter_is_per_session) would always fail because hook_precompact now mines synchronously and passes through unconditionally. Remove them to keep the suite green. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 50f5305 commit 2342b9f

1 file changed

Lines changed: 0 additions & 80 deletions

File tree

tests/test_hooks_cli.py

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pytest
1010

1111
from mempalace.hooks_cli import (
12-
MAX_PRECOMPACT_BLOCK_ATTEMPTS,
1312
SAVE_INTERVAL,
1413
_count_human_messages,
1514
_extract_recent_messages,
@@ -60,85 +59,6 @@ def test_sanitize_empty_returns_unknown():
6059
assert _sanitize_session_id("!!!") == "unknown"
6160

6261

63-
# --- hook_precompact attempt cap (regression for #955 deadlock fix) ---
64-
65-
66-
def _call_precompact(session_id: str) -> dict:
67-
"""Invoke hook_precompact with a deterministic session_id, capture stdout.
68-
69-
Returns the parsed JSON decision emitted by the hook.
70-
"""
71-
stdout = io.StringIO()
72-
with contextlib.redirect_stdout(stdout):
73-
hook_precompact({"session_id": session_id}, "claude-code")
74-
raw = stdout.getvalue().strip()
75-
return json.loads(raw) if raw else {}
76-
77-
78-
def test_precompact_first_two_attempts_block(tmp_path, monkeypatch):
79-
"""First MAX_PRECOMPACT_BLOCK_ATTEMPTS calls must block with a reason."""
80-
monkeypatch.setenv("HOME", str(tmp_path))
81-
monkeypatch.delenv("MEMPAL_DIR", raising=False)
82-
83-
import mempalace.hooks_cli as hooks_cli
84-
monkeypatch.setattr(
85-
hooks_cli, "STATE_DIR", tmp_path / "hook_state", raising=False
86-
)
87-
88-
sid = "test-session-block"
89-
for i in range(MAX_PRECOMPACT_BLOCK_ATTEMPTS):
90-
decision = _call_precompact(sid)
91-
assert decision.get("decision") == "block", (
92-
f"attempt {i + 1}/{MAX_PRECOMPACT_BLOCK_ATTEMPTS}: expected block, "
93-
f"got {decision}"
94-
)
95-
assert decision.get("reason") == PRECOMPACT_BLOCK_REASON
96-
97-
98-
def test_precompact_passes_through_after_cap(tmp_path, monkeypatch):
99-
"""After the cap is reached, the hook must stop blocking (fix for #955)."""
100-
monkeypatch.setenv("HOME", str(tmp_path))
101-
monkeypatch.delenv("MEMPAL_DIR", raising=False)
102-
103-
import mempalace.hooks_cli as hooks_cli
104-
monkeypatch.setattr(
105-
hooks_cli, "STATE_DIR", tmp_path / "hook_state", raising=False
106-
)
107-
108-
sid = "test-session-passthrough"
109-
for _ in range(MAX_PRECOMPACT_BLOCK_ATTEMPTS):
110-
_call_precompact(sid) # exhaust the budget
111-
112-
# Next call must pass through (empty JSON decision)
113-
decision = _call_precompact(sid)
114-
assert decision == {}, (
115-
f"after {MAX_PRECOMPACT_BLOCK_ATTEMPTS} attempts, hook must pass "
116-
f"through to avoid deadlock; got {decision}"
117-
)
118-
119-
120-
def test_precompact_counter_is_per_session(tmp_path, monkeypatch):
121-
"""A fresh session_id must get a fresh attempt budget."""
122-
monkeypatch.setenv("HOME", str(tmp_path))
123-
monkeypatch.delenv("MEMPAL_DIR", raising=False)
124-
125-
import mempalace.hooks_cli as hooks_cli
126-
monkeypatch.setattr(
127-
hooks_cli, "STATE_DIR", tmp_path / "hook_state", raising=False
128-
)
129-
130-
sid_a = "session-a"
131-
sid_b = "session-b"
132-
133-
# Exhaust session A
134-
for _ in range(MAX_PRECOMPACT_BLOCK_ATTEMPTS):
135-
_call_precompact(sid_a)
136-
assert _call_precompact(sid_a) == {} # A is done blocking
137-
138-
# Session B must still block on its first call — isolation between sessions
139-
assert _call_precompact(sid_b).get("decision") == "block"
140-
141-
14262
# --- _count_human_messages ---
14363

14464

0 commit comments

Comments
 (0)