Repository navigation
refactor(checks): split the platforms.ts reader and the gate's file read - #1089
thekevinbot wants to merge 2 commits into
Conversation
`typescript_table.py` held the whole normalize-then-decode pipeline as four module-scope functions, and `gate.py` held its default reader alongside `run`. Each file keeps its named export and sheds the rest: - `requoted.py` -- one TypeScript string literal as a JSON one. - `without_comments.py` -- comments stripped and strings normalized in one pass, with the `_TOKENS` alternation that does both. The two cannot be separated: a `//` inside a string is not a comment. - `as_json.py` -- bare keys quoted, trailing commas dropped. - `read.py` -- the gate's default `source`, and the only place in the package that opens a file. `typescript_table.py` keeps `typescript_table`; `gate.py` keeps `run`. Test cases follow the code they cover: the string-form cases now drive `requoted` directly, the comment cases `without_comments`, the key and comma cases `as_json`, and the scratch-file case moves out of `gate_test.py` into `read_test.py`. The table-level tests keep the end-to-end reads and every `ParseError` contract, which is where those belong. Behavior-preserving: no message text, exit code or parse result changes.
|
Closing as redundant: #1102 landed the same split first. Evidence. Against
The briefing for this lane named 4 violations; the author of #1102 found 8 and cleared all of them, which is why the work arrived by that route instead. Verified clean. A census of The branch is also Closes the work of #1064 as done on |
Fixes #1064. Step under #1020 (ratchet
one_function_per_fileto the tool'sdefault of
1). Lane C,internals/checks/src/checks/platforms_mirror/—PR 3 of 3. No config change: the committed
max_linesstays at 12 untilevery lane is clean.
Stacked on #1069 (
claude/1062-pm-decide-k3v9). That PR rewritesgate.py'sfailure message — it names the module holding
SHAREDby path, andSHAREDmoved — so both PRs touch
gate.pyand this one bases on it rather than racingit. GitHub retargets to
mainwhen #1069 merges.The work list, measured
Against
origin/mainatf575c06, with the ceiling set to1in a throwawayclone,
npx -y testing-conventions@0.0.111 unit one-function-per-file --language python --config internals/checks/testing-conventions.toml internals/checks/src:Four flagged, four moved.
What moved
typescript_table.pyheld the whole normalize-then-decode pipeline, and theholder the gate picked was
_requoted, so the export was the violation. Eachfile keeps its export instead:
requoted.pyrequoted— one TypeScript string literal as a JSON onewithout_comments.pywithout_commentsand the_TOKENSalternation it ownsas_json.pyas_json— bare keys quoted, trailing commas droppedread.pyread— the gate's defaultsource, the onlyopen()in the packagewithout_commentskeeps_TOKENSand takesrequotedas an import rather thansplitting the pass in two: stripping comments and normalizing strings cannot be
separated, because a
//inside a string is not a comment and a quote inside acomment is not a string. The nested
keepstays nested — it closes over thematch and is invisible to the rule either way.
Test cases follow the code they cover: the string-form cases drive
requoted,the comment cases
without_comments, the key and comma casesas_json, and thescratch-file case moves out of
gate_test.pyintoread_test.py. Thetable-level tests keep the end-to-end reads and every
ParseErrorcontract,which is where those belong.
gate_test.pygains a case pinning that both pathsgo through the injected reader — the seam the
readmove is about.Red/green does not apply: this is a pure move with no behavior change. No
message text, exit code or parse result changes.
Verification
one-function-per-fileatmax_lines = 1:typescript_table.py,gate.pyand the four new modules report zero violations. The only
platforms_mirrorfindings left on this branch are the four owned by PR 2(refactor(checks): give each platforms.py reader its own module #1084), which is independent of this stack.
just preflight: 0 failing pairs, 3packagingSKIPs (expected — needs abuilt artifact).
unit mutation: 19 mutants tested, 0 survivors.unit coverage: clean at the 100% floor.platforms_mirror.packages/ts/src/platforms.ts:uv run --project internals/checks dirsql-checks platforms-mirror→ok platforms-mirror: internals/distcheck/src/distcheck/node_flow/platforms.py mirrors the shared fields of packages/ts/src/platforms.ts across 5 published target(s).E2E Verification
internals/checks/e2e-attestations/claude-1064-pm-tsgate-z8m5.jsonreceipt written (just e2e-attest-internals-checks)just e2e-attest-internals-checks(uv run python -m pytest tests/e2e -x -qininternals/checks)Changelog / Migrations
changelog_gatescopes topackages/andplugins/, sointernals/**is out of scope. No migration, noPARITY.mdchange: nopublic API is involved.