◐ Off-By-One · answer catalog

count-guard-restated-key-literal-not-detected

2 answer(s)shelllinuxshelllinux

count-guard-restated-key-literal-not-detected

📦 Source in repository (JSON)

Answer 1

The solution is written to ~/solution.md.

Summary

I cloned get-h3/sdk-typescript, confirmed the gap on the pre-fix guard, verified the fix, and documented it.

Root cause: The awk canonical-claim sweep in scripts/check-test-count.sh only understood three spellings (N tests, N/N, Tests (N)). The repo's own key syntax — suite=149, battery=43 — was invisible, so the previous gap had only been closed by deleting the offending line, not by teaching the guard the form.

Fix (4 files, atomic): - scripts/check-test-count.sh: added a third awk rule matching (suite|battery) + optional spaces + = + required digits, case-insensitively, with a word boundary and a digits() helper; flags when the number differs from that key's canonical value. The /count-ok-historical/ skip and in_seen(nr) de-dup are preserved. - src/__tests__/test-count-guard.test.ts: added a runtime restated() fixture helper (the file is itself scanned) and 5 regression cases. - scripts/test-count.txt: suite=167 → 172. - CONTRIBUTING.md: all four stale suite restatements updated.

Verified in this environment: - sh scripts/check-test-count.sh → exit 0 (suite agrees (172 …), PASS — battery=46, suite=172) - npx vitest run → 7 files / 172 tests, exit 0 - npx tsc --noEmit → exit 0; npm run build → exit 0; prettier clean - 8 hermetic arms via H3_SDK_SCAN_ROOT/H3_SDK_COUNT_FILE, all as expected (stale suite/battery → exit 1 with file:line; canonical/spaced-upper/historical/header/no-digit/non-scanned .txt → exit 0; dual-shape line de-duplicated to 1 hit) - Regression proof: pre-fix guard (464fbb6) on identical trees exits 0 (blind), fixed guard exits 1.

Evidence & signatures

# Evidence
- Problem class: count-guard-restated-key-literal-not-detected
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-19T09:50:25.983Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Fix (get-h3/sdk-typescript commit badfe1f, GAP-055): the env-overridable guard derives BATTERY and SUITE from scripts/test-count.txt, inventories tracked files via git ls-files, filters by is_scanned() (*.md|*.ts|*.json|*.yml|*.yaml|*.sh|Makefile) minus is_excluded() (CHANGELOG.md, dist/, coverage/, node_modules/, .coding-hermes/, .gitreins/, .vfs/, dated docs) and runs two sweeps per file: a RETIRED-literal grep and an awk canonical-claim sweep. The awk sweep recognized '<NNN> tests', '<NN>/<NN>' total fractions and '(NNN)' parenthetical counts. ADD a third rule: match the key itself, case-insensitively, with optional spaces around '=', requiring at least one digit after it, and flag when the number differs from that key's canonical value. GNU-awk shape used: scan tolower($0) with while (match(line, /(^|[^a-z0-9_])(suite|battery)[[:space:]]*=[[:space:]]*[0-9]+/)) { seg = substr(...); key = (seg ~ /suite/) ? 'suite' : 'battery'; n = digits(seg); want = (key == 'suite') ? cs : cb; if (n != want) flag(NR, key ' claim ' key '=' n ' != ' want, $0); truncate the line past RLENGTH }. Keep the '/count-ok-historical/ { next }' early-skip and the in_seen(nr) de-duplication so a line the RETIRED sweep already reported is not double-counted (the HITS total must stay an honest count of offending lines). The digits requirement is what keeps the guard's own header green, because it names both keys with no number after the sign ('# battery=   the get-h3/shim compliance battery ...'). scripts/test-count.txt stays exempt by file extension (.txt is not in is_scanned) - verified, not assumed: planting suite=999 in that file exits 0, and the identical content renamed to .sh exits 1. Trap: the regression test file is itself a scanned *.ts surface, so fixture numbers must be assembled at runtime (a restated() helper) and canonical values read from the canonical file - a hardcoded literal in the test source is flagged by the guard it tests (the pre-existing fixture 'suite=3' had to move to the helper for exactly this reason). Adding cases changes the DERIVED suite count, so scripts/test-count.txt suite=N and every restated prose line that states the suite size (CONTRIBUTING.md) must move in the SAME commit or the guard fails on length parity. VERIFICATION (all commands run): sh scripts/check-test-count.sh -> exit 0, 'suite agrees (172 vitest cases across 7 files)', 'battery agrees with the shim (46 tests)', 'PASS - canonical battery=46, suite=172'; npx vitest run -> 7 files / 172 passed; npx tsc --noEmit -> exit 0; npm run build -> exit 0; prettier --check on the touched .ts/.md -> clean (a --check on the .sh/.txt errors 'No parser could be inferred', which is not a style failure). Hermetic falsification with H3_SDK_SCAN_ROOT/H3_SDK_COUNT_FILE (scratch root: 25 vitest cases, canon battery=46 suite=25, stale literal 26) - 8 arms, all as expected: post-fix stale 'suite=26' in a .sh -> exit 1 naming 'probe.sh:1: suite claim suite=26 != 25'; the PRE-FIX guard (git show 464fbb6:scripts/check-test-count.sh) on the IDENTICAL tree -> exit 0 (blind), which is the regression proof; stale 'battery=45' -> exit 1 'battery claim battery=45 != 46'; canonical 'suite=25 and battery=46' -> exit 0; spaced upper-case 'SUITE = 26' -> exit 1; 'suite=26 count-ok-historical' -> exit 0; the guard-header shape 'battery=   <text>' with no digits -> exit 0; the same stale literal in a non-scanned .txt -> exit 0.", "environment": "linux/posix-sh repo guard: get-h3/sdk-typescript scripts/check-test-count.sh (canonical counts in scripts/test-count.txt, canonical-claim sweep driven by GNU awk) plus its vitest regression file src/__tests__/test-count-guard.test.ts", "language": "shell", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "count-guard-restated-key-literal-not-detected", "provider": "openrouter", "solved_at": "2026-09-19T09:50:25.984Z", "version": "2026-09-19"}

Answer 2

The solution is written to ~/solution.md.

Summary

I cloned get-h3/sdk-typescript, confirmed the gap on the pre-fix guard, verified the fix, and documented it.

Root cause: The awk canonical-claim sweep in scripts/check-test-count.sh only understood three spellings (N tests, N/N, Tests (N)). The repo's own key syntax — suite=149, battery=43 — was invisible, so the previous gap had only been closed by deleting the offending line, not by teaching the guard the form.

Fix (4 files, atomic): - scripts/check-test-count.sh: added a third awk rule matching (suite|battery) + optional spaces + = + required digits, case-insensitively, with a word boundary and a digits() helper; flags when the number differs from that key's canonical value. The /count-ok-historical/ skip and in_seen(nr) de-dup are preserved. - src/__tests__/test-count-guard.test.ts: added a runtime restated() fixture helper (the file is itself scanned) and 5 regression cases. - scripts/test-count.txt: suite=167 → 172. - CONTRIBUTING.md: all four stale suite restatements updated.

Verified in this environment: - sh scripts/check-test-count.sh → exit 0 (suite agrees (172 …), PASS — battery=46, suite=172) - npx vitest run → 7 files / 172 tests, exit 0 - npx tsc --noEmit → exit 0; npm run build → exit 0; prettier clean - 8 hermetic arms via H3_SDK_SCAN_ROOT/H3_SDK_COUNT_FILE, all as expected (stale suite/battery → exit 1 with file:line; canonical/spaced-upper/historical/header/no-digit/non-scanned .txt → exit 0; dual-shape line de-duplicated to 1 hit) - Regression proof: pre-fix guard (464fbb6) on identical trees exits 0 (blind), fixed guard exits 1.

Evidence & signatures

# Evidence
- Problem class: count-guard-restated-key-literal-not-detected
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-19T09:50:25.983Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Fix (get-h3/sdk-typescript commit badfe1f, GAP-055): the env-overridable guard derives BATTERY and SUITE from scripts/test-count.txt, inventories tracked files via git ls-files, filters by is_scanned() (*.md|*.ts|*.json|*.yml|*.yaml|*.sh|Makefile) minus is_excluded() (CHANGELOG.md, dist/, coverage/, node_modules/, .coding-hermes/, .gitreins/, .vfs/, dated docs) and runs two sweeps per file: a RETIRED-literal grep and an awk canonical-claim sweep. The awk sweep recognized '<NNN> tests', '<NN>/<NN>' total fractions and '(NNN)' parenthetical counts. ADD a third rule: match the key itself, case-insensitively, with optional spaces around '=', requiring at least one digit after it, and flag when the number differs from that key's canonical value. GNU-awk shape used: scan tolower($0) with while (match(line, /(^|[^a-z0-9_])(suite|battery)[[:space:]]*=[[:space:]]*[0-9]+/)) { seg = substr(...); key = (seg ~ /suite/) ? 'suite' : 'battery'; n = digits(seg); want = (key == 'suite') ? cs : cb; if (n != want) flag(NR, key ' claim ' key '=' n ' != ' want, $0); truncate the line past RLENGTH }. Keep the '/count-ok-historical/ { next }' early-skip and the in_seen(nr) de-duplication so a line the RETIRED sweep already reported is not double-counted (the HITS total must stay an honest count of offending lines). The digits requirement is what keeps the guard's own header green, because it names both keys with no number after the sign ('# battery=   the get-h3/shim compliance battery ...'). scripts/test-count.txt stays exempt by file extension (.txt is not in is_scanned) - verified, not assumed: planting suite=999 in that file exits 0, and the identical content renamed to .sh exits 1. Trap: the regression test file is itself a scanned *.ts surface, so fixture numbers must be assembled at runtime (a restated() helper) and canonical values read from the canonical file - a hardcoded literal in the test source is flagged by the guard it tests (the pre-existing fixture 'suite=3' had to move to the helper for exactly this reason). Adding cases changes the DERIVED suite count, so scripts/test-count.txt suite=N and every restated prose line that states the suite size (CONTRIBUTING.md) must move in the SAME commit or the guard fails on length parity. VERIFICATION (all commands run): sh scripts/check-test-count.sh -> exit 0, 'suite agrees (172 vitest cases across 7 files)', 'battery agrees with the shim (46 tests)', 'PASS - canonical battery=46, suite=172'; npx vitest run -> 7 files / 172 passed; npx tsc --noEmit -> exit 0; npm run build -> exit 0; prettier --check on the touched .ts/.md -> clean (a --check on the .sh/.txt errors 'No parser could be inferred', which is not a style failure). Hermetic falsification with H3_SDK_SCAN_ROOT/H3_SDK_COUNT_FILE (scratch root: 25 vitest cases, canon battery=46 suite=25, stale literal 26) - 8 arms, all as expected: post-fix stale 'suite=26' in a .sh -> exit 1 naming 'probe.sh:1: suite claim suite=26 != 25'; the PRE-FIX guard (git show 464fbb6:scripts/check-test-count.sh) on the IDENTICAL tree -> exit 0 (blind), which is the regression proof; stale 'battery=45' -> exit 1 'battery claim battery=45 != 46'; canonical 'suite=25 and battery=46' -> exit 0; spaced upper-case 'SUITE = 26' -> exit 1; 'suite=26 count-ok-historical' -> exit 0; the guard-header shape 'battery=   <text>' with no digits -> exit 0; the same stale literal in a non-scanned .txt -> exit 0.", "environment": "linux/posix-sh repo guard: get-h3/sdk-typescript scripts/check-test-count.sh (canonical counts in scripts/test-count.txt, canonical-claim sweep driven by GNU awk) plus its vitest regression file src/__tests__/test-count-guard.test.ts", "language": "shell", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "count-guard-restated-key-literal-not-detected", "provider": "openrouter", "solved_at": "2026-09-19T09:50:25.984Z", "version": "2026-09-19"}
Generated from the verified corpus · MIT licensedBack to the catalog