fix(hooks): default silent_guard=True — config-read failure must not suppress saves
Addresses bensig's review on PR #1021. silent_guard was initialized to False, so when both MempalaceConfig import and .hook_silent_save attribute access failed, silent_guard stayed False. Then `if not silent_guard:` fired and returned empty — silently dropping the save. In silent mode (the default since v3.3.0), saves should ALWAYS proceed on config-read failure. Changing the initial value to True makes that the safe default. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -241,19 +241,22 @@ def hook_stop(data: dict, harness: str):
|
|||||||
# no loop to prevent — and Claude Code's plugin dispatch sets this flag on every
|
# no loop to prevent — and Claude Code's plugin dispatch sets this flag on every
|
||||||
# fire after the first, which would otherwise suppress all subsequent auto-saves.
|
# fire after the first, which would otherwise suppress all subsequent auto-saves.
|
||||||
if str(stop_hook_active).lower() in ("true", "1", "yes"):
|
if str(stop_hook_active).lower() in ("true", "1", "yes"):
|
||||||
silent_guard = False
|
# Safe default: assume silent mode on any config-read failure so saves
|
||||||
|
# proceed rather than being silently dropped. Silent mode is the default
|
||||||
|
# (v3.3.0+), so if we can't read config, behave as if it's still on.
|
||||||
|
silent_guard = True
|
||||||
try:
|
try:
|
||||||
from .config import MempalaceConfig
|
from .config import MempalaceConfig
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
_log(
|
_log(
|
||||||
f"WARNING: could not import MempalaceConfig for stop guard: {exc}; preserving block-mode guard"
|
f"WARNING: could not import MempalaceConfig for stop guard: {exc}; defaulting to silent mode"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
silent_guard = MempalaceConfig().hook_silent_save
|
silent_guard = MempalaceConfig().hook_silent_save
|
||||||
except AttributeError as exc:
|
except AttributeError as exc:
|
||||||
_log(
|
_log(
|
||||||
f"WARNING: could not read hook_silent_save: {exc}; preserving block-mode guard"
|
f"WARNING: could not read hook_silent_save: {exc}; defaulting to silent mode"
|
||||||
)
|
)
|
||||||
if not silent_guard:
|
if not silent_guard:
|
||||||
_output({})
|
_output({})
|
||||||
|
|||||||
Reference in New Issue
Block a user