Skip to content

The Guard's eval Rereads Multiply the Loop Scan's Quadratic Cost #2440

Closed as not planned

Description

@ptr727

Problem

The guard's _loop_parts scan is quadratic in the number of loop keywords on develop. The eval reading (#2080) re-reads each eval payload, which multiplies that cost on a command whose quoting the guard cannot follow. The eval read budget caps it, and none of the self-test timing rows uses many loop keywords.

Reproduce (constructed)

The Python expression below builds the command. The trailing line makes its quoting unknown:

'eval "a\'b"; ' * 5 + 'while true; ' * N + 'sleep 1\necho "$(echo "it\'s")"'

Measured by the review: at 24 KB develop takes 1.17s and the branch 4.36s, and at 48 KB develop takes 4.6s and the branch 10.8s. Both allow it.

Done looks like

The loop scan is linear, or the eval reading stops re-scanning loops it already read, and a self-test timing row with many loop keywords stays under the suite's limit.

Found by a local strict review pass on the #2080 branch.

Activity

  1. added
    bugSomething isn't working
    agentsAgents instructions
    on Oct 6, 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 cost only appears on commands of 24 KB and up with many loop keywords and unparseable quoting, which an agent session does not produce.

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