Skip to content

Read a Run as No Bound Where the Quote Mask Is Unknown in the Wait-Loop Check #2307

Closed as not planned

Description

@ptr727

Problem

The wait-loop check in host-setup/agent-safety/claude/gh-write-guard.py walks back from a bash -c wrapper to the previous unquoted shell operator to find the command run the wrapper sits in. It tells a quoted operator from a real one by the quote mask. Where _quoted_mask returns None, every operator token is read as unquoted.

That happens when _operator_lex raises and _shell_tokens falls back, which an unbalanced quote anywhere in the command does, a comment included. Then a quoted ; before an inner timeout ends the run early, the outer timeout is never read, and a nested timeout whose outer signal ends the inner one before its deadline is read as bounded.

Constructed example, read as bounded:

timeout -s KILL 10 env -u ';' timeout 800 bash -c 'until [ -f x ]; do sleep 60; done' # it's

The same command without the trailing comment is denied.

Done looks like

The check reads a run as no bound wherever the quote mask is unknown and an operator stands between the wrapper and an earlier timeout on the line, or another reading closes the gap, with a self-test row for the shape above and README requirement 7 updated to match.

Found by a local strict review pass on #2117. It predates that pull request.

Activity

  1. ptr727 commented on Oct 3, 2026

    @ptr727
    OwnerAuthor

    A second trigger for the same None mask, found by a local strict review pass on #2117: a balanced command holding a backtick, which the marked lex does not model, together with a word that joins two quoted parts, such as "a"b. The quote-keeping lex then splits differently from the shell tokens, the alignment fails, and the mask is None. Constructed example, read as bounded:

    timeout -s KILL 10 env -u '(' timeout 800 bash -c 'until [ -f x ]; do sleep 60; done'; echo "a"b `true`

    Without the trailing echo, the check denies it. A fix on the None path covers both triggers.

  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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions