Skip to content

fix(metal): reject missing values after repeated probe flags - #1115

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-bot-1110
Nov 2, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-bot-1110

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

metal_gemm_time에서 같은 옵션을 반복하고 마지막 옵션의 값을 빼먹으면 오류 없이 넘어가던 문제를 고쳤습니다.

What and why

metal_gemm_time checks that each value-taking flag has a value, but it looked only at the first occurrence of the flag. With a repeated flag, for example --shape 1:2:3 --shape, the first occurrence has a value, so the trailing --shape with no value was accepted and the command ran as if nothing was missing. The check now looks at whether the last argument is one of those flags, so a missing value is refused with <flag> takes a value whether or not the flag appeared earlier. This covers all 13 value flags the existing check lists.

Fixes #1110. The change is one condition in crates/metal/src/bin/metal_gemm_time/mac.rs plus a regression test that runs every value flag with and without an earlier occurrence.

Release notes: Fixed: metal_gemm_time now rejects a repeated option whose last occurrence has no value.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

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

What I ran

Base 7364a5f86917ee9f5cb8816b7cab7043bf7d65a0, PR head eb9f0073d7498811da935b882a57e877d67b98da, on a macOS machine.

Without the fix, the new regression test alone fails:

cargo test -p bloomery-metal --bin metal_gemm_time mac::tests::every_value_flag_requires_a_value_after_its_last_occurrence -- --exact
running 1 test
test mac::tests::every_value_flag_requires_a_value_after_its_last_occurrence ... FAILED
  left: Ok(())
 right: Err("--shape takes a value")
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out

With the fix (PR head):

cargo test -p bloomery-metal --bin metal_gemm_time
test mac::tests::every_value_flag_requires_a_value_after_its_last_occurrence ... ok
test mac::tests::shape_requires_exactly_three_whole_numbers ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

cargo clippy -p bloomery-metal --bin metal_gemm_time --no-deps -- -D warnings finishes with no warnings or errors.

The built binary (cargo build -p bloomery-metal --bin metal_gemm_time), run with a missing trailing value and with valid repeated values in source-only mode:

CLI PASS: --shape rc=1 metal_gemm_time: --shape takes a value
CLI PASS: --shape 1:2:3 --shape rc=1 metal_gemm_time: --shape takes a value
CLI PASS: valid repeated shapes source-only rc=0

The workspace clippy ratchet check on the PR head passes: chain-clippy: lint rc 0 (^warning: 0, the ratchet 0 in tools/lint-ratchet.txt).

AI help

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

@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: The guard rejects missing trailing values after repeated flags before parsing, file writes or device access.

Checked

Duplicates: 1 new item checked, the regression test; no duplicate contract found. Dryer reported no pairs.
Complexity: crapper flagged no functions; the existing condition is replaced.
Silent failure: 1 changed guard followed through run to the named stderr error and failure exit code.
Tests: restoring the first-occurrence check at crates/metal/src/bin/metal_gemm_time/mac.rs:439 lets the repeated shape case reach the source-only success return, contradicting the new assertion. The PR body includes FAIL-first output. A static guard check rejects all 26 missing-value cases and preserves the guard behavior for 13 valid repetitions and empty arguments.
Gates: no pins moved or cases removed.
Escape catalog: no patterns matched.
Adversarial checks: repeated source-output flags fail before writing. Sibling timing probes check values at each occurrence.

Notes

The Rust test is macOS-only and was not run here. Validation here was static; macOS test and CLI output is supplied in the PR body.

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

@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 3e31152 into midagedev:main Nov 2, 2026
7 checks passed
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.

metal CLI: a trailing repeated --shape without a value is accepted

1 participant