Expand description
Write-boundary primitives.
Stateless classifiers shared by the armed guard ([super::decide]) and
pipeline::detect-stray-writes: which tools write, which Bash commands
mutate state outside a sandbox, and whether a path falls under an allowed
root. Tool names come from the adapters’ cross-harness vocabulary union
(all_tool_vocabulary), so no harness’s tool naming is hardcoded here.
Functions§
- apply_
patch_ paths - Extract file paths from a Codex
apply_patchhook payload. Codex can expose patch targets as a structuredfileslist or as freeform patch text; collect both so the guard can deny unknown or out-of-bounds patches before they run. - classify_
bash - If a Bash command matches a mutation pattern and is not scoped to one of
allowed_roots, return the human reason; otherwiseNone. A command is treated as scoped when it textually references an allowed root. - is_
patch_ tool - True for an apply_patch-style tool whose payload carries patch targets
(extracted with
apply_patch_paths), in any harness’s vocabulary. - is_
shell_ tool - True for a shell-execution tool carrying a
commandargument, in any harness’s vocabulary. - is_
under - True when
targetresolves todiror a descendant of it. Relativetargets resolve againstrepo_root.Path::starts_withmatches whole path components, so.eval-magic2is correctly not under.eval-magic. - is_
under_ any - True when
targetis under any ofdirs. - is_
write_ tool - True for a tool name that writes the filesystem with a single target path argument, in any harness’s vocabulary.
- path_
arg - Pull the target path from a write tool’s arguments (
file_path→notebook_path→path). ReturnsNonewhen the input is not an object or carries no string path.