Skip to content

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

Closed

Description

@schlessera

Context

The hosted unit (8) candidate job for #4102 timed out the case emitted declaration graph > no public .d.ts references an optional backend package in packages/ui-server/tests/declaration-surface.test.ts. Run 44023500617, job 133838750834, head fbac565eb, records 30,789.49 ms against the unchanged 30,000 ms deadline, followed by 1,131 passes and one failure in that worker. There was no optional-backend assertion failure. Concurrent worker/memory observations are context, not attribution of that historical slowdown to memory pressure.

Current source at d974052166f335cbf57b385fddc13875da1b98de creates one TypeScript program and declaration emit (emitDeclarations, packages/ui-server/tests/declaration-surface.test.ts:33-55) and calls it from exactly one test (:58-69). The second case walks source ASTs. Building the declarations once per file is already what this code does; that suggestion does not establish an optimization.

Controlled reproduction — 2026-11-17

An isolated archive of that main, Linux x64, actual Bun 1.4.2 (744846f84) and TypeScript 6.0.3 used a successful independent --force --frozen-lockfile --backend=copyfile install with an empty private cache (1,027 packages). Test/build-config/lockfile bytes matched the pinned commit. The normal test wrapper and offline preload stayed enabled, and no assertion, source or deadline was changed.

  • Unloaded bun run test packages/ui-server/tests/declaration-surface.test.ts: 2 pass, 0 fail, 4 assertions, 9.69 s total; declaration case 9,183.15 ms.
  • Bounded CPU control, through host admission: one allowed CPU, one owned CPU burner, and two requested repetitions through the delivered gate:
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 --report /tmp/declaration-load.json --json

The first repetition fails the same named case at 35,066.43 ms, explicitly this test timed out after 30000ms; exit 1, with the file and repetition identified in the structured report. It bails on that failure, so it does not claim two completed repetitions. The owned burner and test process are absent after settlement. This reproduces the timeout under controlled CPU contention; it does not reproduce the original hosted worker mix or prove that job's historical cause. An earlier missing-TypeScript bootstrap did not reach assertions and is not counted as reproduction evidence.

The reviewed weight is 20.736 s (scripts/test-shard-costs.json). The isolated pass and controlled failure are separate receipts, not a repair or a passing retry.

Scope

Profile declaration preparation/emission and relevant concurrent load, then make the existing optional-backend declaration proof complete reliably within its existing timeout under a justified hosted-like load. Reduce unnecessary compiler work or resource contention only where evidence supports it; preserve the emitted graph and the separate source-specifier check.

Out of scope

  • Raising the deadline to absorb contention, retries, skips, weakening the scan or making an optional backend mandatory.
  • Replacing real declaration emission with source spelling, stale built declarations or a predicate-only surrogate.
  • Production API/exports/dependency changes, a generic test framework, or attribution of the original job from a passing control alone.

Acceptance criteria

  • Retain real successful, nonempty declaration emission from the package build config and scan every emitted .d.ts for both optional backend specifiers. Retain the separate source-AST assertion.
  • Record the measured compiler/load boundary and a scoped repair; the actual declaration case fails on the pre-change source and completes below the unchanged deadline after repair under the same justified conditions.
  • Re-run the bounded diagnostic and representative unit-worker load, reporting the actual source, runtime, CPU/load and selected cases. Do not present the one-CPU stressor as an exact replay of the original hosted job.
  • Prove the guard remains meaningful: an optional-backend reference escaping into a real public declaration fails the intended assertion, restored afterward. Empty emission or an omitted scan must not pass.
  • Keep normal offline/preparation/host-admission rules, source/config identities and cleanup. Refresh a reviewed cost only from measured evidence.

Verification

Use the normal bun run test wrapper, focused failing-first/restored-mutation receipts and applicable hosted unit proof under the current CI policy. Compare equal source/runtime/load conditions for any timing claim. The existing test has a runtime and must actually execute.

Contract impact

None for a test-only repair. A change to shipped public declarations is outside this brief.

2026-11-17 triage: completed the brief and recorded a real failing runtime control. No unresolved design, policy, access or reproduction prerequisite remains for the scoped implementation. Preserve the explicitly filed p3 ranking and no milestone; the issue remains standalone because the open package-boundary/oracle/browser epics do not own test-cost repair, and #736 is at its direct-child limit. Closed #1849 is not reopened.

Activity

  1. added
    type: testCoverage, harness or proof work with no behaviour change.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p3Someday. Needs a driving use case before it starts.
    on Nov 17, 2026
  2. changed the title [-]test(ui-server): declaration-surface's emitted declaration graph times out on a loaded unit shard[/-] [+]ui-server: declaration emission exceeds the test timeout under CPU load[/+] on Nov 17, 2026
  3. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 17, 2026
  4. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    This failure is tracked by red-main incident #4186 (main red at 215887542f2e). Please add evidence there.

  5. self-assigned this
    on Nov 17, 2026
  6. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-d2e53957. Branch: fix/4142-declaration-emit-nocheck.

    Claimed as the fix for red-main incident #4186. Collisions: none checked yet beyond the incident record.

  7. added this to the 0.45.0 milestone on Nov 17, 2026
  8. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Delivered in #4187 (squash e982c1c). The declaration emit passes noCheck: true: TypeScript's real declaration emit from the build config, without the full body check that bun run typecheck owns. Emit went from 9.5 s to 2.0 s unloaded. Under the bounded one-CPU-plus-burner diagnostic, the case failed at 45.2 s before and takes 13.6 s after, against the unchanged 30 s deadline. The same 414 files are emitted, with the same import specifiers in each. The leak mutation and the empty-emission mutation both still fail. This was the fix for red-main incident #4186, and main run 44107659969 cleared it. The weight in scripts/test-shard-costs.json is left for CI's measured refresh.

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

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p3Someday. Needs a driving use case before it starts.type: testCoverage, harness or proof work with no behaviour change.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions