Skip to content

fix(crux-judge): scan_once and main back at grade B — CB-200 616 again (#5173) - #5180

Merged
noahgift merged 2 commits into
mainfrom
fix/5173-cb200-two-defs
Oct 12, 2026
Merged

noahgift merged 2 commits into
mainfrom
fix/5173-cb200-two-defs

Conversation

@noahgift

Copy link
Copy Markdown
Contributor

What

pmat comply CB-200 (TDG grade gate, min_grade = "B") went from 616 to 618 definitions below the floor between v0.70.3 and cc71bde. Of the sub-B definitions new in that range, two sit just under the floor: aprender-crux-judge pyjson::Doc::scan_once and main, both B- (TDG 74.5, cyclomatic 18). This PR refactors those two back to grade A, which returns the count to 616. The [tdg] baseline is not touched.

  • scan_once: the six bare-word constants move to scan_literal + literal_value. They are still tried before a number, so -Infinity is not read as -.
  • main: argument decoding (utf8_args), the sandbox command (sandbox_cmd) and the collect exit mapping (collect_cmd) become helpers under one run dispatch. Exit codes are unchanged.
  • New test bare_word_literals_decode covers every literal plus negative numbers. Before this PR, no test covered the literal arms.

Red before / green after (pmat 3.42.0, pmat query x then pmat comply check --format json, fresh index each)

RED   cc71bde029: CB-200: TDG Grade Gate | Fail | 618 definition(s) below minimum grade B
GREEN 5d39bff0c1: CB-200: TDG Grade Gate | Fail | 616 definition(s) below minimum grade B
GREEN 2f449abb78: CB-200: TDG Grade Gate | Fail | 616 definition(s) below minimum grade B
ref   v0.70.3   : CB-200: TDG Grade Gate | Fail | 616 definition(s) below minimum grade B

Grades after: main A+, utf8_args A+, sandbox_cmd A+, collect_cmd A, run A-, scan_once A, scan_literal A+, literal_value A-.

Checks

  • The crate is excluded from the workspace and has its own lockfile, so the commands use --manifest-path tools/aprender-crux-judge/Cargo.toml. With it: cargo fmt -- --check rc 0, cargo clippy --locked --all-targets -- -D warnings rc 0, cargo test --locked 40 passed (39 existing + 1 new).
  • cargo fmt --all -- --check rc 0.
  • Guard tree (scripts/ci_guards.sh guard-tree) on 2f449ab: 176 checks, 2 failed. The two are check_baseline_ratchets.sh and check_complexity_ratchet.sh, each refusing because its baseline was recorded under pmat 3.41.1 and the local pmat is 3.42.0 (instrument mismatch, unrelated to this diff).

Note: pmat's comply index cache is keyed per checkout and is not refreshed by a new commit. The GREEN line above was measured after dropping that cache. Without that step the count read 618 on the fixed tree.

Closes #5173

ont-delta: none — code refactor in one tool crate; no doc, spec or contract changes

🤖 Generated with Claude Code

noahgift and others added 2 commits October 12, 2026 04:49
#5173)

Two definitions added since v0.70.3 graded B- (TDG 74.5, cyclomatic 18)
and took CB-200 from 616 to 618 definitions below min_grade B.

- pyjson `scan_once`: the six bare-word constants (null, true, false,
  NaN, Infinity, -Infinity) move to `scan_literal` + `literal_value`;
  they are still tried before a number, so `-Infinity` is not read as `-`.
- main `main`: argument decoding (`utf8_args`), the `sandbox` command
  (`sandbox_cmd`) and the collect exit mapping (`collect_cmd`) become
  helpers under one `run` dispatch. Exit codes are unchanged.

The baseline is not touched.

Refs: #5173
Agent: aprender-cd
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#5173)

Refs: #5173
Agent: aprender-cd
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@noahgift noahgift left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

APPROVE seat 2, w71-e3b, 2f449ab

Read the diff at 2f449ab (2 files under tools/aprender-crux-judge).

  • main → utf8_args + run: the dispatch order is unchanged (eval/extract/lint → oracles, certify/check → certify, sandbox → sandbox_cmd, else parse → collect). collect::<Result<Vec<_>,_>> stops at the first non-UTF-8 argument, so usage_error still fires once, for the first one. The exit codes are unchanged: decline 2, crash 1, u8::try_from(rc).unwrap_or(1).
  • scan_once → scan_literal: the six words are still tried before match_number, and -Infinity before a bare -. The literals are ASCII, so idx + lit.len() advances correctly. A first char that matches no word falls through to the number path, as before. The new bare_word_literals_decode test covers every arm plus negative numbers.
  • It fixes the code and leaves the [tdg] baseline alone: no raise and no ratchet, as row P3 requires. The RED 618 → GREEN 616 lines are in the body.
  • One note, not a blocker: the two local guard-tree reds are pmat 3.41.1 vs 3.42.0 baseline mismatches and do not come from this diff. CI's guard-tree on this head is what counts.

@noahgift noahgift left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

seat 1 (P3), aprender-a7 APPROVE @ 2f449ab

Re-ran on a detached checkout of this head (pmat 3.42.0):

  • pmat query grades on this head: main A+, utf8_args A+, sandbox_cmd A+, collect_cmd A, run A-, scan_once A, scan_literal A+, literal_value A-. These match the body, and none is below B.
  • cargo fmt -- --check rc 0, cargo clippy --all-targets -- -D warnings rc 0, cargo test 40 passed, including bare_word_literals_decode. All three ran with --manifest-path tools/aprender-crux-judge/Cargo.toml. I did not reproduce the comply count of 616 myself; I checked the two definitions it names.

Behaviour, read against the old code:

  • scan_once: scan_literal tries every bare word with the same full-string starts check, before match_number. So -Infinity still wins over a number, and -1/-1.5 still fall through to match_number; the new test pins both. Exactly one literal can match at any index, so the order of the array does not matter.
  • main/run: the dispatch order is unchanged (eval/extract/lint, then certify/check, then sandbox, then parse). The sandbox extra-argument refusal, the non-UTF-8 usage exit, decline→2, crash→1 and u8::try_from(rc).unwrap_or(1) are all preserved.
  • [tdg] baseline is untouched.

Notes, none blocking:

  • Both the RED and GREEN lines in the body read CB-200 ... Fail. The fix restores the count to the v0.70.3 figure, 616; it does not turn CB-200 green. That is what this row asked for, but "GREEN" there means "back to 616".
  • The two guard-tree refusals (check_baseline_ratchets.sh, check_complexity_ratchet.sh: baseline recorded under pmat 3.41.1, local 3.42.0) are not caused by this diff. If either sits on the merge path, they need their own row.

@github-actions

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=5180 head=2f449abb786897f029da40e745b91d85d81fe659 verdict=REFUSE class=Q1 arm_rc=1

Shadow mode: this records a verdict and merges nothing. A refusal
to arm is not a block (§13 adds zero rows to §7) — the pull request is
exactly as green as it was.

@noahgift
noahgift added this pull request to the merge queue Oct 12, 2026
Merged via the queue into main with commit 1bd0b0c Oct 12, 2026
12 checks passed
@noahgift
noahgift deleted the fix/5173-cb200-two-defs branch October 12, 2026 05:22
@noahgift noahgift mentioned this pull request Oct 12, 2026
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.

CB-200: two definitions added since v0.70.3 fall below grade B (618 > 616)

1 participant