Skip to content

Count Only Real Heredoc Openers in the Guard's In-Order Reading #2201

Description

@ptr727

Problem

The #2112 fix (handoff #2123) adds, on the ordinary path of host-setup/agent-safety/claude/gh-write-guard.py, a reading that strips every heredoc body a line opens in order. It builds that reading from every << token the line yields, including one bash never queues a body for, such as a quoted '<<' or a << inside a comment. That reading strips real command lines up to the false tag, and where the tag line sits inside a later document's body, the rest of the document is read as commands, so a document quoting a wait loop is denied rather than written. Develop allows it.

Reproduce (constructed)

cat <<A >/dev/null; echo '<<' B
a
A
cat > doc.md <<EOF
B
while [ ! -f /x ]; do sleep 1; done
EOF

Bash writes the loop into doc.md and runs nothing. The branch denies the command, and develop allows it. Writing the first line as cat <<A >/dev/null # like <<B behaves the same.

Done looks like

The in-order reading counts only openers bash queues a body for, the commands above are allowed, and self-test rows pin both as allows.

Found by the local strict review of the #2112 fix, and filed as a follow-up under decision #2126, which shipped that fix with its known false denies filed rather than fixed.

Activity

  1. added
    bugSomething isn't working
    agentsAgents instructions
    on Oct 1, 2026
  2. ptr727 commented on Oct 8, 2026

    @ptr727
    OwnerAuthor

    Declined per #2517, approved by the maintainer, under GOVERNANCE.md "Trust Boundaries and Hardening Effort": The guard backstops an agent's own mistakes, and this is a command shape built to defeat it rather than one an agent session writes, so a miss does not realistically occur. See #2517 for the per-issue reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsAgents instructionsbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions