Skip to content

Choose How the Wait-Loop Rule Credits a Test Comparison (#1636) #1990

Closed

Description

@ptr727

Question

How should the gh-write-guard.py wait-loop rule (requirement 7) decide that a [, [[, or test comparison bounds a loop, now that crediting -lt/-le/-gt/-ge anywhere in the condition (#1636) is being narrowed?

The unattended lane for #1636 (handoff #1989) parked here after its two-round local review budget ran out. Branch feature/auto-1636, commits d11c3ea, 8f9f498 and d28bde0, no pull request yet. Each round made the token-level parse of a test's operands more precise, and each round's adversarial review found new shapes on the text the round before wrote. That is the non-converging pattern. Round three's open findings, all constructed cases:

  • A substitution glued to a word, [ -n x$(ls -lt out) ], is still credited as a bound.
  • A fused separator and subshell after test, test -f x;(ls -lt out), is read as test grouping and credited.
  • A case arm's ) inside $(...) unbalances the depth count (contrived).
  • A quoted literal backtick operand, [ "$c" != '' -a $i -lt 3 ]`, hides a real comparison and denies a bounded loop that develop allows today.

Options

  1. Recommended: fail closed on any opaque operand. A comparison counts only inside a [, [[, or test whose operands before it carry no substitution, backtick, or parenthesis token at all. This is short, and every unparsed shape resolves to deny rather than to a bypass. The cost is that some genuinely bounded loops that develop allows today are denied, until [ $(date +%s) -ge $end ] the common one. The deny message already names the (( SECONDS < end )) form, so the fix for the user is a one-line rewrite. The parked branch is reworked to this and driven to develop.
  2. Keep refining the operand parser. Fix round three's four findings and review again, accepting further rounds. This keeps every bounded loop develop allows today, but the last three rounds each produced about four new findings, so a converging end is not in sight. The parked branch continues as it stands.
  3. Ship the parked branch as it is and file the remaining shapes. The commits already close both shapes _BOUND_IN_CONDITION Reads an Ordinary Command Flag as an Arithmetic Guard #1636 names, ls -lt and grep -le, and many more. The remaining bypasses need a deliberate spelling, and the backtick regression is rare. The four findings become a follow-up issue, and this lane's pull request is opened from the branch unchanged.

What each choice does to the parked work

  • Option 1 replaces the operand parser in _bound_in_condition with the simpler fail-closed check, and turns some existing _WAIT_CASES allow rows into deny rows.
  • Option 2 adds a fourth commit to feature/auto-1636.
  • Option 3 opens the pull request from the branch as it stands.

Handoff: #1989. Blocks: the not-yet-opened feature/auto-1636 -> develop pull request for #1636.

Activity

  1. added
    decision
    on Sep 28, 2026
  2. ptr727 commented on Sep 28, 2026

    @ptr727
    OwnerAuthor

    Answered by the maintainer in an attended session: option 2, keep refining the operand parser. Fix round three's four findings on feature/auto-1636 and review again. Work continues under handoff #1989.

  3. removed
    decision
    on Sep 28, 2026
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