diff --git a/host-setup/agent-safety/README.md b/host-setup/agent-safety/README.md index b4c73c3c9..477646868 100644 --- a/host-setup/agent-safety/README.md +++ b/host-setup/agent-safety/README.md @@ -136,11 +136,15 @@ Requirements 1 to 7 and 11 judge a command's text, read the way a simple lexer r ```mermaid flowchart TD - cmd["Tool call: a shell/git/gh command"] --> isgit{"A git operation\nthat bypasses a\nbranch rule\nor a bypass flag?"} + cmd["Tool call: a shell/git/gh command"] --> isbig{"A git or gh command\nwhose brace expansion\npasses 64 distinct or\n1024 words in all?"} + isbig -- yes --> denybig["DENY - too large\nto read"] + isbig -- no --> isgit{"A git operation\nthat bypasses a\nbranch rule\nor a bypass flag?"} isgit -- yes --> deny4["DENY - requirement 4\n(fails closed for a\nprotected-default branch\nwith undeterminable rules)"] isgit -- no --> isprimary{"A mutating git op\ntargeting a primary\ncheckout, not exempt?"} isprimary -- yes --> deny6["DENY - requirement 6"] - isprimary -- no --> iswait{"A while, until or\narithmetic-for loop\nthat sleeps, with no\narithmetic guard, no\nwhile read,\nand (no timeout, or a\nfork out of the timeout's\nreach)?"} + isprimary -- no --> isblanket{"A blanket git add or\nstage, or a commit with\n-a or a sweeping or unread\npathspec, not a dry run,\nin a checkout with\nan origin remote?"} + isblanket -- yes --> deny11["DENY - requirement 11"] + isblanket -- no --> iswait{"A while, until or\narithmetic-for loop\nthat sleeps, with no\narithmetic guard, no\nwhile read,\nand (no timeout, or a\nfork out of the timeout's\nreach)?"} iswait -- yes --> deny7["DENY - requirement 7"] iswait -- no --> isghwrite{"A GitHub-write\ncommand at all?"} isghwrite -- no --> allow["ALLOW"] diff --git a/host-setup/agent-safety/claude/gh-write-guard.py b/host-setup/agent-safety/claude/gh-write-guard.py index 1144e9edd..2608e5c0d 100755 --- a/host-setup/agent-safety/claude/gh-write-guard.py +++ b/host-setup/agent-safety/claude/gh-write-guard.py @@ -1971,7 +1971,7 @@ def classify( } _PUSH_CASES: list[tuple[str, dict[str, set[str] | None], str, str, str]] = [ (c, _RULE_SETS[k], b, w, s) - for w, s, k, b, c in (x.split(":", 4) for x in "".join(_PUSH_PACKED).split("|")) + for w, s, k, b, c in (x.split(":", 4) for x in _PUSH_PACKED.split("|")) ] + [(_COMMIT_THEN_PUSH, _RULES, "feature/x", "deny", "R4")] _IN_PLACE_GROUPS: list[tuple[str | None, str | tuple[str, ...]]] = [ @@ -2332,7 +2332,7 @@ def _rows(packed: str, expand: str) -> list[list[str]]: {k: {"pull_request"} for k in r.split(",") if k != "-"}, w, ) - for c, r, w in (x.split(" => ") for x in "".join(_PUSH_UNREAD_PACKED).split("|")) + for c, r, w in _rows(_PUSH_UNREAD_PACKED, "@") ]