MCPcopy Create free account
hub / github.com/anthropics/claude-code / record_touched_path

Function record_touched_path

plugins/security-guidance/hooks/diffstate.py:57–71  ·  view source on GitHub ↗

Append a file path to the touched_paths list (deduped, capped at 200). Stop is the consumer and clears under the same lock it reads with; UPS no longer wipes. The cap is a defensive bound for sessions where Stop never fires (disabled mid-session, abort) — git diff naturally filters

(session_id, file_path)

Source from the content-addressed store, hash-verified

55
56
57def record_touched_path(session_id, file_path):
58 """Append a file path to the touched_paths list (deduped, capped at 200).
59
60 Stop is the consumer and clears under the same lock it reads with; UPS
61 no longer wipes. The cap is a defensive bound for sessions where Stop
62 never fires (disabled mid-session, abort) — git diff naturally filters
63 stale paths so over-retention is harmless, just wasteful.
64 """
65 def _record(state):
66 paths = state.setdefault("touched_paths", [])
67 if file_path not in paths:
68 paths.append(file_path)
69 if len(paths) > 200:
70 del paths[:len(paths) - 200]
71 with_locked_state(session_id, _record)
72
73
74def consume_stop_state(session_id):

Callers 1

mainFunction · 0.90

Calls 1

with_locked_stateFunction · 0.90

Tested by

no test coverage detected