Skip to content

lds-scan: a failed line count fails the scan - #483

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:fix-review-bot-issue-452-lds
Oct 19, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:fix-review-bot-issue-452-lds

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

What and why

Fixes #452. tools/lds-scan.sh read three line counts with wc -l and never checked the status: the entry count, an entry's PTX body lines and its SASS listing lines. When the SASS read failed, slines was empty and the scan printed a row with sass lines= and exited 0. When the PTX read failed, the next [ "$lines" -gt 0 ] errored and the scan failed as body=none(<entry>), which names the wrong cause. Each read now calls fail on error, so the scan ends with entries=unread, lines-unread=<entry> or sass-lines-unread=<entry> and scan=failed, and prints no row.

Release notes: internal: an LDS scan that cannot count an entry's PTX or SASS lines ends as a failed scan that names the entry, instead of printing a row with an empty count.

Code shape

  • No second copy. The self-test reuses read_stubs from tools/ref/read-stubs.sh for its wc stand-in. No new helper.
  • Model code holds only architecture facts. No model code changes.
  • Dead code is gone.
  • No silent failure. All three wc reads in the script end in || fail. pipefail is on, so a failed wc in wc | tr counts.
  • Comments state what is true now. The self-test's header comment describes the new cases.
  • No relaxed gate.
  • cargo fmt and cargo clippy: no Rust changes (shell only).

Duplication found or removed (path:line), or "none": none.

What changed:

  • tools/lds-scan.sh: the three reads and their failure fields as above.
  • tools/lds-scan.sh self-test: scan() takes SCAN_STUBS (puts the stand-ins first on PATH) and SCAN_FIX (another fixture folder). A fix-wc copy of the fixture has a fail-wc line at the end of mod1.ptx (inside the up_down body) and of up_mix_4x320.sass. Three new cases: read-stubs-pass (a control scan under the stand-ins that keeps its row), sass-count-unread and ptx-count-unread.
  • tools/ref/read-stubs.sh: the stand-ins now fail when their input holds the word fail-md5 or fail-wc (grep -qw), not only when the whole input is that word. An entry's PTX body or SASS listing always holds more than one word. The existing users (tools/ptx-scan.sh, tools/ref/dump-dequant.sh, crates/tokenizer/tools/oracle.sh) pass the bare word, so they behave as before; their self-tests pass below.

The entry count read has no failure case. Its input lines are <module> <entry>, and an entry name has no -, so it cannot hold the word fail-wc that makes the stand-in fail.

What I ran

All on an RTX 5090 machine.

  • FAIL-first: the new self-test cases on the base code (test-only commit d6e4fdeb). bash tools/lds-scan.sh --self-test ended lds-scan: self-test FAIL (10 cases, 2 failed). sass-count-unread failed with rc 0 (want 1) and a row reading | sass lines= STL=3, which is the issue's symptom. ptx-count-unread failed with body=none(up_down) scan=failed. The control case read-stubs-pass passed.
  • Self-tests with the fix: lds-scan: self-test ok (10 cases, 0 failed), ptx-scan: self-test ok (30 cases, 0 failed), dump-dequant self-test: ok (0 failures), oracle self-test: ok (0 failures) and ptx-spill-check: self-test ok.
  • LC_ALL=C just contrib-check --tier t0 with the fix: DONE tier=t0 total=94 red=0 wall=285s. Its check-recipes unit runs these self-tests (check-recipes rc=0 101s).

The checks with the fix ran on 77503e59, this same commit on main 7b31f231. The PR head 169b1a75 is that commit on f9b38060; the main commits between the two bases change only the 0.3.5 version strings, and git range-diff shows the commit unchanged.

I did not run just lds-scan against a real gate binary, since that needs a full GPU build. The existing fixture cases run the success path with the real wc, and the row format is unchanged.

What I ran into

None of this blocks the PR. tools/lds-scan.sh:196 reads NMOD=$(grep -c ...) without checking its status. A failure there already fails the scan, but as modules=0, which names the wrong cause. This PR leaves it alone.

Hardware (if the change is for a machine)

Not a hardware change.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

The entry count, an entry's PTX body line count and its SASS line count were read with wc pipelines whose status
nothing checked: a wc that failed without output left an empty count, and a failed SASS read still printed the row
with an empty `sass lines=` and exit 0. Each count now fails the scan by name when its read fails: entries=unread,
lines-unread=<entry> or sass-lines-unread=<entry>, with no row. The md5sum and wc stand-ins of
tools/ref/read-stubs.sh fail on a text that holds the word fail-md5 or fail-wc, not only on a text that is that
word, so the self-test fails the PTX and the SASS count read of a whole entry.
@github-actions github-actions Bot added the tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo label Oct 19, 2026

@github-actions github-actions Bot 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.

Verdict: CLEAN: All three line-count reads now report named failures; the remaining test gap is non-blocking.

Non-blocking

⚠ Cover entry-count failure: tools/lds-scan.sh:218.
No self-test injects a failed entry-count read, so removing this guard leaves the cases unchanged. After the PTX/SASS cases, overwrite the existing wc stand-in with one that consumes stdin and exits 1; assert exit 1 and the exact lds-scan bin=target/release/gate_x entries=unread scan=failed banner.

Checked

Duplicates: 0 new functions, types or constants; Grep confirms reuse of the existing read_stubs owner. No dryer pairs were available.
Complexity: no Rust functions changed; the shell self-test adds three independent cases.
Silent failure: 3 production reads followed to their consumers; failed pipelines exit 1 with a named banner before emitting the affected row.
Tests: PTX/SASS failure cases assert exit 1 and exact named banners. Removing the stand-in PATH prefix (:99), PTX guard (:231), or SASS guard (:238) defeats those assertions. Entry-count failure has no regression assertion. The PR reports passing scanner and manifest-writer self-tests; validation here used source inspection.
Gates: no pins, thresholds or cases relaxed or removed. The PR supplies FAIL-first output for the PTX/SASS cases.
Escape catalog: C1 checked; pipefail and guarded assignments preserve wc failures. No C2–C4 matches.

Notes

Dryer and crapper did not run because no Rust file changed.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

Filed outside this PR: #484

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 24436fe into midagedev:main Oct 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lds-scan: a failed SASS line count still exits successfully

1 participant