Skip to content

fix(scripts): derive usage() header ranges instead of hardcoded sed - #3646

Merged
kyle-sexton merged 2 commits into
mainfrom
cursor/fix-3424-usage-sed-ranges-df93
Sep 2, 2026
Merged

fix(scripts): derive usage() header ranges instead of hardcoded sed#3646
kyle-sexton merged 2 commits into
mainfrom
cursor/fix-3424-usage-sed-ranges-df93

Conversation

@kyle-sexton

Copy link
Copy Markdown
Contributor

Closes #3424

Summary

--help for scripts/affected-tests.sh and datamuse.sh extracted a hardcoded sed -n range that had drifted behind the header, so the printed usage cut off mid-block. The listed babysit scripts already use derived extraction.

Fix

Replace the hardcoded ranges with the babysit-readiness-gate.sh awk (shebang to first non-comment line). datamuse.sh also accepts --help / -h (exit 0). songwriting 1.4.20.

Verification

scripts/affected-tests.sh --run from the worktree: 129 shell suites passed. Exit 3 is the documented NOT RUN for 7 selected Python suites. New assertions pin the last header sentence and the datamuse Examples block.

Related

N/A

Open in Web Open in Cursor 

Hardcoded sed -n ranges truncated --help as headers grew. Extract to the
first non-comment line, matching babysit-readiness-gate.sh.

Closes #3424

Co-authored-by: ksextonmelodic <ksextonmelodic@gmail.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T08:57:56.675128Z b1eee28 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 52s —— View job


Code review complete

  • Gather context (PR diff, CLAUDE.md, skip gate)
  • Review changed files for correctness and maintainability
  • Adversarial verification of candidate finding
  • Post findings (inline comments + summary)

Skip gate: PR is open, not a draft, and has a real review surface (two usage() extraction fixes + tests) — proceeded with full review.

Summary

The core fix is sound: replacing the hardcoded sed -n line ranges in scripts/affected-tests.sh and datamuse.sh with the awk-derived header extraction (shebang → first non-comment line) matches the existing convention in plugins/source-control/scripts/babysit-readiness-gate.sh, and I traced both header blocks line-by-line to confirm the derived range now reaches the intended content (the "Both stages fail loud" sentence in affected-tests.sh, and the full Examples block through LIMIT=50 datamuse.sh near grief in datamuse.sh) without an early exit on a stray blank line. datamuse.sh's new --help/-h handling (exit 0, no request issued) is correctly placed before the mode/arg validation.

One finding, posted inline:

  • plugins/songwriting/context/pat-pattison/scripts/datamuse.test.sh:193 — the new --help test block (lines 188–192) was inserted between two assertions that used to both cover the same "no arguments" run_datamuse call. Since run_datamuse overwrites the global $OUT/$RC/$ERR on every invocation, the assertion at line 193 (still labeled "no arguments writes nothing to stdout") now actually checks the --help call's stdout, not the no-args call's. It still passes today (both paths produce empty stdout), so this won't fail CI, but the original "no arguments → empty stdout" invariant is no longer covered by anything, and the label is misleading. Verified independently via a second pass before posting.

Nothing else surfaced — the plugin.json/CHANGELOG.md version bump and changelog wording match the actual line ranges affected, and scripts/affected-tests.test.sh's new end-of-header assertion is consistent with how the suite is always invoked (CWD at repo root).

Branch: cursor/fix-3424-usage-sed-ranges-df93

@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 58s —— View job


Security review

  • Gather context (PR diff, changed files)
  • Apply skip gate
  • Review changed files for security-relevant surface
  • Report findings

Skip gate: no security-relevant surface. This PR only changes how usage()/--help text is
extracted in two shell scripts (scripts/affected-tests.sh,
plugins/songwriting/context/pat-pattison/scripts/datamuse.sh), replacing a hardcoded sed -n
line range with an awk scan that reads the script's own header (shebang → first non-comment
line) via ${BASH_SOURCE[0]}. There's no user-controlled input into the new awk/usage() code
path, no auth/access-control logic touched, no secrets/token handling, and no GitHub Actions
workflow or permissions changes — the remaining diff is a version bump, changelog entry, and test
assertions.

No security issues found.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Last security-reviewed head: b1eee280fadb8189ec9e8180880f179a1bdccdf9. On the next push, the relevance gate compares only the commits since this SHA; delete this comment to force a full re-review.

Comment thread plugins/songwriting/context/pat-pattison/scripts/datamuse.test.sh Outdated
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Claude has reviewed this PR 2 times. The lane skips further automatic reviews after 5; deleting this comment resets the count.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1eee280fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/songwriting/context/pat-pattison/scripts/datamuse.test.sh
…uced it

Move the no-args empty-stdout check above --help, and assert --help
stdout separately so $OUT is not overwritten first.

Co-authored-by: ksextonmelodic <ksextonmelodic@gmail.com>
@kyle-sexton
kyle-sexton merged commit 71d5ef1 into main Sep 2, 2026
63 checks passed
@kyle-sexton
kyle-sexton deleted the cursor/fix-3424-usage-sed-ranges-df93 branch September 2, 2026 09:31
@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Claude finished @cursor[bot]'s task in 2m 18s —— View job


Code review complete

  • Gather context (PR diff, CLAUDE.md, skip gate)
  • Review changed files for correctness and maintainability
  • Adversarial verification of candidate findings
  • Post findings (inline comments + summary)

Skip gate: PR has a real review surface and is receiving pushes (synchronize event) — proceeded with review.

Summary

This push (8bdaf64) contains exactly one change since the last-reviewed commit (b1eee28): datamuse.test.sh.

That change fixes the finding both this lane and Codex flagged on the prior commit: the "no arguments writes nothing to stdout" assertion was mislabeled because it ran after the newly-inserted run_datamuse --help block had already overwritten the shared $OUT/$RC/$ERR globals, so it was silently checking the --help invocation instead of the no-args one.

The fix moves that assertion to line 187, immediately after the no-args run_datamuse call (line 175) and before reset_stub/run_datamuse --help (lines 189–190), and gives the --help block its own correctly-labeled stdout assertion at line 194 ("--help writes nothing to stdout"). Both invariants are now independently covered under the invocation they actually name — I traced the global-overwrite ordering line-by-line to confirm no other assertion in this file reads $OUT/$RC/$ERR across a reset_stub/run_datamuse boundary the way this one used to.

No new findings. The rest of the PR (the awk-derived usage() header extraction in scripts/affected-tests.sh and datamuse.sh, the new --help/-h handling, and the pinned header/Examples-block assertions) was already reviewed on the prior commit and is unchanged here.

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.

scripts: self-extracting usage() sed ranges drifted behind their headers, truncating --help

2 participants