diff options
| author | Claude <noreply@anthropic.com> | 2026-09-10 20:49:44 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-09-10 20:49:44 +0000 |
| commit | 8459dfc26ec93b3d7f53353a902fa2d530bcb154 (patch) | |
| tree | 9b87c6ca0f487f396d792c793a2f0ff56cf693bb /plugins/security-guidance/hooks/diffstate.py | |
| parent | 4d2a599463bf3966c368dd8bfb30cfa1682cf126 (diff) | |
| parent | 3b600518a637492d37c9877aeb49c2a55d939c04 (diff) | |
Merge remote-tracking branch 'origin/main' into tobin/add-dynatrace
# Conflicts:
# .claude-plugin/marketplace.json
Diffstat (limited to 'plugins/security-guidance/hooks/diffstate.py')
| -rw-r--r-- | plugins/security-guidance/hooks/diffstate.py | 14 |
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. |
