MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _mark_session_denied

Function _mark_session_denied

graphify/cli.py:1330–1349  ·  view source on GitHub ↗

Atomically claim a one-time strict block for this session. Returns True only on the FIRST call for a given session id (O_EXCL create wins once); every later call — or any error — returns False, so a session is blocked at most once and an agent can never be stranded. Best-effort GC of mar

(session_id: str)

Source from the content-addressed store, hash-verified

1328
1329
1330def _mark_session_denied(session_id: str) -> bool:
1331 """Atomically claim a one-time strict block for this session. Returns True only
1332 on the FIRST call for a given session id (O_EXCL create wins once); every later
1333 call — or any error — returns False, so a session is blocked at most once and an
1334 agent can never be stranded. Best-effort GC of markers older than 24h."""
1335 from graphify.paths import out_path
1336 sid = re.sub(r"[^A-Za-z0-9_-]", "_", str(session_id))[:64]
1337 if not sid:
1338 return False
1339 try:
1340 d = out_path("cache", "hook_sessions")
1341 d.mkdir(parents=True, exist_ok=True)
1342 fd = os.open(str(d / f"{sid}.denied"), os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644)
1343 os.close(fd)
1344 _gc_hook_session_markers(d)
1345 return True
1346 except FileExistsError:
1347 return False
1348 except Exception:
1349 return False
1350
1351
1352_SEARCH_COMMANDS = frozenset({

Callers 1

_run_hook_guardFunction · 0.85

Calls 3

out_pathFunction · 0.90
_gc_hook_session_markersFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected