summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/hooks/diffstate.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/security-guidance/hooks/diffstate.py')
-rw-r--r--plugins/security-guidance/hooks/diffstate.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/security-guidance/hooks/diffstate.py b/plugins/security-guidance/hooks/diffstate.py
index 3ce9da1b..8d0665dd 100644
--- a/plugins/security-guidance/hooks/diffstate.py
+++ b/plugins/security-guidance/hooks/diffstate.py
@@ -71,7 +71,7 @@ def record_touched_path(session_id, file_path):
with_locked_state(session_id, _record)
-def consume_stop_state(session_id):
+def consume_stop_state(session_id, clear=True):
"""Atomically snapshot all state the Stop hook needs and clear touched_paths.
The Stop hook is asyncRewake — it runs in the background after Claude's
@@ -102,17 +102,27 @@ def consume_stop_state(session_id):
"fire_count": 0 if expired else state.get("stop_hook_fire_count", 0),
"fire_count_expired": expired and state.get("stop_hook_fire_count", 0) > 0,
"previous_findings": [] if findings_expired else list(state.get("previous_findings", [])),
+ "reviewed_diff_hash": state.get("reviewed_diff_hash"),
}
- state["touched_paths"] = []
+ if clear:
+ state["touched_paths"] = []
+ state.pop("reviewed_diff_hash", None)
return snap
return with_locked_state(session_id, _snap) or {
"touched_paths": [], "baseline_sha": None, "head_at_capture": None,
"untracked_at_baseline": {},
"fire_count": 0, "fire_count_expired": False, "previous_findings": [],
+ "reviewed_diff_hash": None,
}
+def record_reviewed_diff(session_id, diff_hash):
+ def _save(state):
+ state["reviewed_diff_hash"] = diff_hash
+ with_locked_state(session_id, _save)
+
+
def restore_unreviewed_stop_state(session_id, paths, baseline_sha):
"""Put consumed touched_paths back so the next Stop reviews them.