Skip to content

fix(gh-aw): scan the first non-empty line in PC-0, not record 1 (#1835) - #1841

Merged
bradygaster merged 1 commit into
devfrom
bradygaster-squad-status-assessment
Aug 23, 2026
Merged

fix(gh-aw): scan the first non-empty line in PC-0, not record 1 (#1835)#1841
bradygaster merged 1 commit into
devfrom
bradygaster-squad-status-assessment

Conversation

@bradygaster

Copy link
Copy Markdown
Owner

Closes #1835

What

PC-0 normalized the dispatched command with an awk program gated on NR==1. A value whose first character is a newline puts an empty string on that record, so:

PC0($'\nimplement')  →  EMPTY_DISPATCH

EMPTY_DISPATCH routes to the activation guard, which halts with a ::warning:: and no comment by design (PR #1777, junk issues #12/#14). A structurally valid implement dispatch therefore halted silently instead of running — the same silent-loss-of-a-valid-command class that #1824 and #1832 exist to close.

Fix

Scan the first non-empty line rather than record 1: skip blank records, take the first one carrying content, and fall through to EMPTY_DISPATCH via END only when every record was empty or whitespace-only. Genuinely empty input still reaches the silent activation-guard halt, so #1777 stays closed.

PC-1 is untouched. The asymmetry is deliberate — on the comment path a missing /squad token is the error condition, and loosening it would reopen #1824.

Acceptance (from the issue)

# Criterion Status
1 PC0($'\nimplement') yields /squad implement
2 PC0('') and PC0(' ') still yield EMPTY_DISPATCH
3 Reverting the fix turns the new test red, failure text names the input
4 Existing PC-0 cases green, PC-1 cases untouched

Mutation proof

Reverting the awk to NR==1 turns four new cases red, each naming the offending input:

× dispatching '\nimplement' reaches its mode
× dispatching '\n\n\ncast' reaches its mode
× dispatching '\n  connect org/repo  ' reaches its mode
× dispatching '\n/squad status' reaches its mode

AssertionError: PC-0 must skip leading blank lines and normalize "\nimplement"
to "/squad implement". Scanning only record 1 reads the leading newline as an
empty command and emits EMPTY_DISPATCH, halting a valid dispatch silently via
the activation guard.: expected 'EMPTY_DISPATCH' to be '/squad implement'

A status-only assertion would pass a truncating parser; these name the input, per the standing bar. Whitespace-only cases ('', ' ', '\n', '\n\n', ' \n \t \n ') pin EMPTY_DISPATCH so the fix cannot overshoot.

Tests: 27 → 36 in gh-aw-command-parse. gh-aw-quality stays green.

⚠️ Reviewer note — prompt budget is nearly exhausted

The awk one-liner is written without inter-statement spaces deliberately, and the explanatory paragraph I first wrote was removed. Both overran gh-aw-quality's reports combined bytes and headroom gate.

workflows/squad.md on dev sits ~37 bytes above the 5 KB floor of the 100 KB prompt ceiling. This PR leaves ~65 bytes. Readable spacing in that one line cost ~18 bytes; a five-line prose note cost ~430.

The next change to workflows/squad.md will fail CI on byte count regardless of its merit. That needs its own issue — I did not file one as part of this PR.

Scope

workflows/squad.md + test/gh-aw-command-parse.test.ts. No packages/*/src/ changes, so no changeset required.

Closes #1835

PC-0 normalized the dispatched command with an awk program gated on NR==1, so
a value whose first character is a newline put an EMPTY string on the scanned
record: PC0($'\nimplement') returned EMPTY_DISPATCH. That routes to the
activation guard, which halts with a ::warning:: and no comment by design (PR
#1777, junk issues #12/#14) -- so a structurally valid implement dispatch
would halt silently instead of running. Silent loss of a valid command is the
same defect class #1824 and #1832 exist to close.

Scan the first non-empty line instead: skip blank records, take the first one
carrying content, and fall through to EMPTY_DISPATCH via END only when every
record was empty or whitespace-only. Genuinely empty input still reaches the
silent activation-guard halt, so #1777 stays closed.

The one-liner is written without inter-statement spaces deliberately.
workflows/squad.md sits ~37 bytes above the 5 KB floor of the 100 KB prompt
budget asserted by gh-aw-quality's "reports combined bytes and headroom", so
the readable spacing and an explanatory paragraph both overran the gate. The
behavior is documented in the tests instead. That headroom is now ~65 bytes
and is a blocker for the next change to this file; it needs its own issue.

Tests: 27 -> 36 in gh-aw-command-parse. Reverting the awk to NR==1 turns four
of the new cases red, and each failure message names the offending input, so a
truncating parser cannot pass them. The whitespace-only cases ('', '   ',
'\n', '\n\n', ' \n \t \n ') pin EMPTY_DISPATCH so the fix cannot overshoot,
and the load-bearing PC-1 cases are untouched -- a bare token still fails on
the comment path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 23, 2026 17:07
@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit c2b0e61

PR Scope: 🔧 Infrastructure

⚠️ 1 item(s) to address before review

Status Check Details
Single commit 1 commit — clean history
Not in draft Ready for review
Branch up to date Up to date with dev
Copilot review No Copilot review yet — it may still be processing
Changeset present No source files changed — changeset not required
Scope clean No .squad/ or docs/proposals/ files
No merge conflicts No merge conflicts
Copilot threads resolved No Copilot review threads
CI passing All checks passing

Files Changed (2 files, +45 −2)

File +/−
test/gh-aw-command-parse.test.ts +43 −0
workflows/squad.md +2 −2

Total: +45 −2


This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

@github-actions

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #1841

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 2
Files added 0
Files modified 2
Files deleted 0
Modules touched 2

🎯 Risk Factors

  • 2 files changed (≤5 → LOW)
  • 2 modules touched (2-4 → MEDIUM)

📦 Modules Affected

root (1 file)
  • workflows/squad.md
tests (1 file)
  • test/gh-aw-command-parse.test.ts

This report is generated automatically for every PR. See #733 for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped to PC-0 normalization, matches the stated acceptance criteria, and is backed by targeted behavioral tests covering both the regression and non-regression cases.

Pull request overview

This PR fixes a parsing edge case in the gh-aw workflow command normalization step (PC-0) where a dispatched command value beginning with a newline was incorrectly treated as empty, causing a silent EMPTY_DISPATCH halt instead of running a valid command.

Changes:

  • Update PC-0’s awk normalization to scan the first non-empty trimmed line (rather than NR==1).
  • Add behavioral tests to ensure leading blank lines are skipped while whitespace-only inputs still yield EMPTY_DISPATCH.
File summaries
File Description
workflows/squad.md Adjusts PC-0 normalization logic to skip leading blank/whitespace-only records and only emit EMPTY_DISPATCH when all records are empty.
test/gh-aw-command-parse.test.ts Adds coverage for leading-newline dispatch inputs and guards against overshooting (whitespace-only inputs remain EMPTY_DISPATCH).
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bradygaster
bradygaster merged commit 3cb7dcb into dev Aug 23, 2026
18 checks passed
@bradygaster
bradygaster deleted the bradygaster-squad-status-assessment branch August 23, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PC-0 turns a leading-newline dispatch value into a silent EMPTY_DISPATCH halt

2 participants