fix: address review — enrich block reasons, clean up tests
- Add parenthetical hints to block reasons so AI knows what each tool saves (session summary, quotes/decisions/code) - Remove dead config file creation from test_stop_hook_disabled_by_config - Add missing test for MEMPALACE_HOOKS_AUTO_SAVE=no env var - Replace bare except: with except Exception: in shell scripts
This commit is contained in:
parent
49a8c868fa
commit
8fc06b96e2
|
|
@ -85,7 +85,7 @@ import json, sys
|
|||
try:
|
||||
cfg = json.load(open(sys.argv[1]))
|
||||
print(str(cfg.get('hooks', {}).get('auto_save', True)).lower())
|
||||
except: print('true')
|
||||
except Exception: print('true')
|
||||
" "$CONFIG_FILE" 2>/dev/null)
|
||||
if [ "$AUTO_SAVE" = "false" ]; then
|
||||
echo "{}"
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ import json, sys
|
|||
try:
|
||||
cfg = json.load(open(sys.argv[1]))
|
||||
print(str(cfg.get('hooks', {}).get('auto_save', True)).lower())
|
||||
except: print('true')
|
||||
except Exception: print('true')
|
||||
" "$CONFIG_FILE" 2>/dev/null)
|
||||
if [ "$AUTO_SAVE" = "false" ]; then
|
||||
echo "{}"
|
||||
|
|
|
|||
|
|
@ -102,14 +102,16 @@ _RECENT_MSG_COUNT = 30 # how many recent user messages to summarize
|
|||
|
||||
STOP_BLOCK_REASON = (
|
||||
"MemPalace auto-save checkpoint. "
|
||||
"Use mempalace_diary_write and mempalace_add_drawer to save session content. "
|
||||
"Use mempalace_diary_write (session summary) and mempalace_add_drawer "
|
||||
"(quotes, decisions, code) to save session content. "
|
||||
"Do NOT use native auto-memory files."
|
||||
)
|
||||
|
||||
PRECOMPACT_BLOCK_REASON = (
|
||||
"MemPalace emergency save — compaction imminent. "
|
||||
"Use mempalace_diary_write and mempalace_add_drawer to save ALL content "
|
||||
"before context is lost. Do NOT use native auto-memory files."
|
||||
"Use mempalace_diary_write (thorough summary) and mempalace_add_drawer "
|
||||
"(ALL quotes, decisions, code, context) to save ALL content before context is lost. "
|
||||
"Do NOT use native auto-memory files."
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -598,6 +598,15 @@ def test_hooks_auto_save_env_override_zero():
|
|||
del os.environ["MEMPALACE_HOOKS_AUTO_SAVE"]
|
||||
|
||||
|
||||
def test_hooks_auto_save_env_override_no():
|
||||
os.environ["MEMPALACE_HOOKS_AUTO_SAVE"] = "no"
|
||||
try:
|
||||
cfg = MempalaceConfig(config_dir=tempfile.mkdtemp())
|
||||
assert cfg.hooks_auto_save is False
|
||||
finally:
|
||||
del os.environ["MEMPALACE_HOOKS_AUTO_SAVE"]
|
||||
|
||||
|
||||
def test_hooks_auto_save_env_override_true():
|
||||
"""Env var set to 'true' overrides config file even if config says false."""
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
|
|
|
|||
|
|
@ -1487,10 +1487,6 @@ def test_run_hook_dispatches_precompact(tmp_path):
|
|||
|
||||
def test_stop_hook_disabled_by_config(tmp_path):
|
||||
"""When hooks.auto_save is false in config, stop hook passes through."""
|
||||
config_dir = tmp_path / "config"
|
||||
config_dir.mkdir()
|
||||
(config_dir / "config.json").write_text(json.dumps({"hooks": {"auto_save": False}}))
|
||||
|
||||
transcript = tmp_path / "t.jsonl"
|
||||
_write_transcript(
|
||||
transcript,
|
||||
|
|
|
|||
Loading…
Reference in New Issue