Skip to content

test(ui-server): emit the declaration graph without the body check (#4142) - #4187

Merged
schlessera merged 1 commit into
mainfrom
fix/4142-declaration-emit-nocheck
Nov 17, 2026
Merged

schlessera merged 1 commit into
mainfrom
fix/4142-declaration-emit-nocheck

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #4142. Refs #4186 (red-main incident; this is its declared fix).

What this does

packages/ui-server/tests/declaration-surface.test.ts proves that no emitted public .d.ts names an optional backend package. It builds one TypeScript program from packages/ui-server/tsconfig.build.json (1,570 source files: ui-server, plus ui-sdk and core source through the bun condition) and emits all 414 declarations. With the full semantic check, that emit is the whole cost of the case. On a contended CI worker the case passed its 30 s deadline, most recently in main run 44096292239 at 30.6 s (#4186), and before that on #4102's candidate.

The emit now passes noCheck: true. That is still TypeScript's real declaration emit from the package's build config. It skips only the full semantic check of function bodies, which bun run typecheck owns. The deadline, the scan of every emitted .d.ts, the non-empty-emit assertion, the separate source-AST case and the type-level descriptor assertions are unchanged.

Measured boundary

Current main (146dfb4), Bun 1.4.4, TypeScript 6.0.3, this host (16 CPUs):

Program Declaration emit
Full check (before) 1.0–1.1 s 9.2–10.0 s
noCheck (after) 1.1 s 2.0–2.1 s
declarationMap/sourceMap off, full check 9.2 s (not the cost; not changed)

Same proof:

  • with and without noCheck, the same 414 files are emitted, and every file's set of from/import() specifiers (what this guard scans) is identical;
  • ten files differ only in union-member order, because the checker assigns type ids in a different order;
  • neither emit is skipped, and neither reports diagnostics.

Acceptance criteria

Criterion Proof
Real, non-empty emission from the build config; every .d.ts scanned for both specifiers; the source-AST assertion kept Unchanged code paths. noCheck is the only option added
Measured boundary and a scoped repair: the case fails on the pre-change source and completes below the unchanged deadline after, under the same conditions Bounded diagnostic below
Re-run the bounded diagnostic and a representative load, reporting source, runtime and load; the one-CPU stressor is not an exact replay of the hosted job Below
The guard stays meaningful: a backend reference escaping into a public declaration fails, and empty emission or an omitted scan cannot pass Mutations below
Normal offline, preparation and host-admission rules; reviewed cost refreshed only from measured evidence Normal bun run test wrapper and scripts/host-admission.mjs. The weight in scripts/test-shard-costs.json is left for CI's measured refresh

Proof

  • Bounded diagnostic (node scripts/host-admission.mjs run -- taskset -c 0 bun scripts/test-determinism.ts packages/ui-server/tests/declaration-surface.test.ts --repetitions 2 --burners 1, one allowed CPU, one owned burner):
    • Before (main source): repetition 1 fails no public .d.ts references an optional backend package at 45,204 ms, "this test timed out after 30000ms". Exit 1.
    • After: both repetitions pass, 28.4 s for the two. Exit 0.
  • Per-case time under the same load (one burner on CPU 0, the test on CPU 0, JUnit report): the declaration case takes 13.6 s, and the source-AST case 1.4 s.
  • Unloaded: 2 pass.
  • This load is a controlled stressor, not a replay of the hosted worker mix.
  • Mutations (each restored):
    • A backend type escapes into a public declaration (export type BackendLeak = typeof import("@schlessera/brain-backend-claude") appended to src/index.ts): the emit case fails with offenders ["dist/index.d.ts"], and the source case independently with src/index.ts: @schlessera/brain-backend-claude.
    • Empty emission (the write callback keeps no .d.ts): fails on Expected: > 0, Received: 0.
  • check:pr passes. No shipped package file changes, so no changeset.

Collisions

bun scripts/collisions.ts --json --pr 4187 at head 26941e9: closure reports only (shared test categories and workspaces) with #3059, #3069, #3581, #3622, #4002, #4151, #4168, #4173, #4175, #4177, #4179, #4181. No PR edits declaration-surface.test.ts.

{"version":1,"kind":"brain-check-pr-receipt","head":"26941e9760e90ecaef94ca3266b5e610fce37cf0","base":"origin/main","mode":"focused","startedAt":"2026-11-17T14:21:41.882Z","finishedAt":"2026-11-17T14:22:12.941Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":16597.33756},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":171.5420479999957},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":127.23467600000004},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":24.246853999997256},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":14119.675621000002}]}

🤖 Generated with Claude Code

…4142)

The optional-backend declaration guard builds one TypeScript program of
1,570 files from the build tsconfig and emits all 414 declarations. With
the full semantic check that emit took 9.5 s unloaded, and 45.2 s on one
contended CPU, past the unchanged 30 s deadline. It failed main run
44096292239 at 30.6 s (#4186). `noCheck` keeps the real declaration emit
and skips only the body check that `bun run typecheck` owns: 2.0 s
unloaded, 13.6 s under the same load, with the same files and the same
import specifiers in each.

Refs #4186

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 17, 2026
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 26941e9 against base 146dfb4. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4187,
  "head": "26941e9760e90ecaef94ca3266b5e610fce37cf0",
  "base": "146dfb4b398c5c8d313a48dbd9e745327ba5c51f",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

@schlessera
schlessera marked this pull request as ready for review November 17, 2026 14:25
@schlessera
schlessera marked this pull request as draft November 17, 2026 14:31
@schlessera
schlessera marked this pull request as ready for review November 17, 2026 14:31
@schlessera
schlessera merged commit e982c1c into main Nov 17, 2026
69 of 80 checks passed
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.

ui-server: declaration emission exceeds the test timeout under CPU load

1 participant