Skip to content

chore(build): make turbo's typecheck inputs self-verifying, and lock two runtime assumptions into tsc - #9853

Merged
JSONbored merged 2 commits into
mainfrom
chore/build-hygiene
Jul 29, 2026
Merged

chore(build): make turbo's typecheck inputs self-verifying, and lock two runtime assumptions into tsc#9853
JSONbored merged 2 commits into
mainfrom
chore/build-hygiene

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

The find

turbo.json's //#typecheck inputs is a hand-maintained approximation of tsc's real transitive surface, and its own comment admits the hazard:

"a snapshot of test/'s real cross-package reach as of the audit that added it, not a structural guarantee — a future test file importing from a NOT-yet-listed package/app would reopen the same silent-stale-cache gap." … "Re-run the same grep … before trusting this list again."

Nobody re-runs a grep on request. It had already drifted — four statically-imported paths were unhashed:

unhashed path imported by
packages/loopover-mcp/lib/** mcp-cli-error, mcp-gateway tests
packages/loopover-mcp/bin/** mcp-cli-completion-spec (imports CLI_COMMAND_SPEC)
packages/loopover-miner/scripts/** miner-benchmark, miner-env-reference tests
packages/discovery-index/scripts/** validate-posthog-release test

Editing any of them could leave a stale cache HIT on a typecheck a real tsc --noEmit would fail — precisely the #5082 class this list exists to prevent.

The bin/** case is worse than an omission: it falsifies the comment's own stated reason for excluding it ("every test reference to it is a runtime path string … never a static import"). That was true when written; a later test made it false, and nothing noticed. Comment corrected rather than left misleading.

The fix

scripts/check-turbo-typecheck-inputs.ts — run that grep every CI instead of remembering it. This is the maintainability point directly: a computed list rather than a remembered one.

Two precision details that matter:

  • dependsOn counts as coverage. @loopover/engine#build means turbo already hashes the engine's inputs, so engine/contract sources aren't false-positived. A checker that cried wolf here would be ignored within a week.
  • Paths must exist on disk. The checker-testing files embed import statements inside fixture strings naming packages/engine/..., a workspace renamed away. A naive scan reported those as real reach — a false positive whose "fix" would have been hashing a directory that doesn't exist.

Also: two free tsc flags

isolatedModules and verbatimModuleSyntax, both measured at zero errors today. They turn assumptions the runtime already makes into compile-time guarantees: per-file transpilability (what --experimental-strip-types and esbuild already require) and type-only imports that can never be silently elided from — or dragged into — the self-host bundle that must have zero cloudflare:* imports.

Deliberately not enabling noImplicitReturns despite it costing only 3 errors: two are documented, intentional implicit-undefined switch arms ("Every other case implicitly returns undefined"). Churn against deliberate code for marginal value.

Verification

Guard mutation-tested via 8 unit cases (drift reported, dependsOn coverage, glob-narrower-than-reach, fixture-string exclusion, plus an invariant asserting this repo's own turbo.json stays covered so a turbo.json edit fails the suite too). turbo run typecheck --dry still resolves the graph. Full suite 25,332 passed; tsc, dead-source-files, import-specifiers green.

…two runtime assumptions into tsc

turbo.json's //#typecheck `inputs` list is a hand-maintained approximation of
tsc's real transitive surface. Its own comment says so -- "a snapshot ... not a
structural guarantee" -- and asks a human to "re-run the same grep ... before
trusting this list again".

Nobody re-runs a grep on request, and it HAD drifted. Four paths that src/+test/
statically import were unhashed:

  packages/loopover-mcp/lib/**        (mcp-cli-error, mcp-gateway tests)
  packages/loopover-mcp/bin/**        (mcp-cli-completion-spec imports CLI_COMMAND_SPEC)
  packages/loopover-miner/scripts/**  (miner-benchmark, miner-env-reference tests)
  packages/discovery-index/scripts/** (validate-posthog-release test)

Editing any of them could leave a stale cache HIT on a typecheck a real
`tsc --noEmit` would fail -- the #5082 class this list exists to prevent. The
bin/** case also falsified the comment's own stated reason for excluding it
("never a static import"), which is now corrected rather than left misleading.

Add scripts/check-turbo-typecheck-inputs.ts: compute the reach every CI run
instead of remembering it. A path is covered by a glob OR by a dependsOn build
(turbo hashes a dependency's own inputs), so engine/contract sources are not
false-positived. Paths that do not exist on disk are ignored -- the checker-test
fixtures embed import statements inside STRINGS naming a package renamed away,
which a naive scan reports as real reach.

Also enable isolatedModules + verbatimModuleSyntax: both cost ZERO errors today
(measured) and turn assumptions the runtime already makes into compile-time
guarantees -- per-file transpilability for `--experimental-strip-types` and
esbuild, and type-only imports that can never be silently elided from (or
dragged into) the self-host bundle.

Deliberately NOT enabling noImplicitReturns: 3 errors, and two are documented,
intentional implicit-undefined switch arms. Churn for marginal value.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui b69fa14 Commit Preview URL

Branch Preview URL
Jul 29 2026, 03:16 PM

@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Important

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏳ LoopOver is waiting…

LoopOver has seen this pull request and is waiting on CI checks to finish before reviewing it. This comment will update once the review runs.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟨 Waiting

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 29, 2026
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.65%. Comparing base (a65655c) to head (b69fa14).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9853      +/-   ##
==========================================
- Coverage   91.74%   91.65%   -0.09%     
==========================================
  Files         917      917              
  Lines      112894   112840      -54     
  Branches    27153    27131      -22     
==========================================
- Hits       103576   103429     -147     
- Misses       8034     8125      +91     
- Partials     1284     1286       +2     
Flag Coverage Δ
backend 95.68% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

@JSONbored
JSONbored merged commit 39239df into main Jul 29, 2026
5 checks passed
@JSONbored
JSONbored deleted the chore/build-hygiene branch July 29, 2026 15:24
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant