summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/hooks/diffstate.py
diff options
context:
space:
mode:
authorMohamed Hegazy <8000722+mhegazy@users.noreply.github.com>2026-10-15 15:28:02 -0700
committerGitHub <noreply@github.com>2026-10-15 15:28:02 -0700
commit7b2259ba542c313099b1f00be8b670f7aa0c63bb (patch)
treee26f409d318bcc7421859702e50db708daca9a42 /plugins/security-guidance/hooks/diffstate.py
parent1ce3d5f2d27fd379efcdf98803c1fcdca4a5cd70 (diff)
parentf1a98c9d629ae161d9e5f037983dee84a57b6e6a (diff)
Merge pull request #6605 from anthropics/mhegazy/sg-state-file-save
security-guidance: keep the session state when a save is cut short
Diffstat (limited to 'plugins/security-guidance/hooks/diffstate.py')
-rw-r--r--plugins/security-guidance/hooks/diffstate.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/security-guidance/hooks/diffstate.py b/plugins/security-guidance/hooks/diffstate.py
index af8f2a78..7725cdd9 100644
--- a/plugins/security-guidance/hooks/diffstate.py
+++ b/plugins/security-guidance/hooks/diffstate.py
@@ -104,17 +104,22 @@ def consume_stop_state(session_id, clear=True):
"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 lost or overwritten since the last Stop (session_state).
+ "state_resets": state.get("state_resets", 0),
+ "state_overwrites": state.get("state_overwrites", 0),
}
if clear:
state["touched_paths"] = []
state.pop("reviewed_diff_hash", None)
+ state.pop("state_resets", None)
+ state.pop("state_overwrites", 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,
+ "reviewed_diff_hash": None, "state_resets": 0, "state_overwrites": 0,
}