Skip to content

refactor(checks): split the platforms.ts reader and the gate's file read - #1089

Closed
thekevinbot wants to merge 2 commits into
mainfrom
claude/1064-pm-tsgate-z8m5
Closed

thekevinbot wants to merge 2 commits into
mainfrom
claude/1064-pm-tsgate-z8m5

Conversation

@thekevinbot

Copy link
Copy Markdown
Collaborator

Fixes #1064. Step under #1020 (ratchet one_function_per_file to the tool's
default of 1). Lane C, internals/checks/src/checks/platforms_mirror/ —
PR 3 of 3. No config change: the committed max_lines stays at 12 until
every lane is clean.

Stacked on #1069 (claude/1062-pm-decide-k3v9). That PR rewrites gate.py's
failure message — it names the module holding SHARED by path, and SHARED
moved — so both PRs touch gate.py and this one bases on it rather than racing
it. GitHub retargets to main when #1069 merges.

The work list, measured

Against origin/main at f575c06, with the ceiling set to 1 in a throwaway
clone, npx -y testing-conventions@0.0.111 unit one-function-per-file --language python --config internals/checks/testing-conventions.toml internals/checks/src:

typescript_table.py:31 `_without_comments` runs 4 lines
typescript_table.py:39 `_as_json` runs 2 lines
typescript_table.py:44 `typescript_table` runs 15 lines
gate.py:23             `run` runs 22 lines

Four flagged, four moved.

What moved

typescript_table.py held the whole normalize-then-decode pipeline, and the
holder the gate picked was _requoted, so the export was the violation. Each
file keeps its export instead:

New module Holds
requoted.py requoted — one TypeScript string literal as a JSON one
without_comments.py without_comments and the _TOKENS alternation it owns
as_json.py as_json — bare keys quoted, trailing commas dropped
read.py read — the gate's default source, the only open() in the package

without_comments keeps _TOKENS and takes requoted as an import rather than
splitting 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 a
comment is not a string. The nested keep stays nested — it closes over the
match 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 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. gate_test.py gains a case pinning that both paths
go through the injected reader — the seam the read move 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-file at max_lines = 1: typescript_table.py, gate.py
    and the four new modules report zero violations. The only
    platforms_mirror findings 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, 3 packaging SKIPs (expected — needs a
    built artifact).
  • unit mutation: 19 mutants tested, 0 survivors.
  • unit coverage: clean at the 100% floor.
  • 111 unit tests pass in platforms_mirror.
  • Manual run — the reader parses the real 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

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: N/A
  • TypeScript SDK e2e: N/A
  • Rust core e2e (if applicable): N/A
  • internals/checks/e2e-attestations/claude-1064-pm-tsgate-z8m5.json receipt written (just e2e-attest-internals-checks)
  • Command(s) run: just e2e-attest-internals-checks (uv run python -m pytest tests/e2e -x -q in internals/checks)
  • Result summary: 28 passed. The receipt commit adds one file and deletes none.

Changelog / Migrations

  • Not required — changelog_gate scopes to packages/ and plugins/, so
    internals/** is out of scope. No migration, no PARITY.md change: no
    public API is involved.

`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.
Base automatically changed from claude/1062-pm-decide-k3v9 to main September 5, 2026 02:09
@thekevinbot
thekevinbot disabled auto-merge September 5, 2026 11:39
@thekevinbot

Copy link
Copy Markdown
Collaborator Author

Closing as redundant: #1102 landed the same split first.

Evidence. Against main at 3a1e427, this branch's own diff (merge-base 79ba521) creates as_json.py, read.py, requoted.py and without_comments.py, slims typescript_table.py, and moves the gate's open() behind an injected source. Every one of those modules already exists on main with the same implementation:

  • typescript_table.py and gate.py are byte-identical between this branch and main (git diff main <head> -- ... is empty for both).
  • as_json.py, read.py, requoted.py and without_comments.py differ only in docstring and comment wording — same imports, same function bodies, same signatures.

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 internals/checks/src on 3a1e427 with max_lines = 1 (config copied to a scratch file, never edited in-tree) reports zero violations under both testing-conventions@0.0.115 (current latest) and 0.0.111. A positive control — a two-function module planted inside a copy of that same tree — fails as expected, so the exit 0 is a real scan rather than an empty one.

The branch is also CONFLICTING and well behind main; merging it would drag back a tree that is missing the splits landed since. Nothing here is worth rebasing.

Closes the work of #1064 as done on main.

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.

refactor(checks): split platforms_mirror/typescript_table.py and gate.py toward max_lines = 1

1 participant