Skip to content

Make plugin SDK inventory test contention-safe - #2490

Merged
ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-plugin-api-inventory-5s-timeout-thr_k5jadt4yz7
Aug 26, 2026
Merged

Make plugin SDK inventory test contention-safe#2490
ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-plugin-api-inventory-5s-timeout-thr_k5jadt4yz7

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

At the independently verified merge-base 7dc6756e20ba749ad9d4d6d939b1dd7de363250b, the public SDK inventory test parsed and printed every non-internal generated declaration bundle with TypeScript inside a single 5-second Vitest case. That repeated heavyweight work was redundant because @get-bb/plugin-sdk#build:types had already parsed and normalized the declarations, and scheduler contention could stretch the case from its usual ~2 seconds in GitHub Actions to 6.46 seconds (failed run). A local 160-way contention harness reproduced the exact line-55 timeout in 158 of 160 invocations. Profiling showed declaration reads plus raw hashing took under 2 ms unloaded, while the repeated AST parse/print consumed about 160 ms unloaded and 5.4–8.8 seconds under that contention.

What changed

The inventory now scans the already-built declaration token stream and hashes each token kind, byte length, and text. This preserves the exact declaration-shape gate while continuing to ignore comments and formatting, without constructing and printing ten TypeScript ASTs inside the timed test. The committed inventory digests were regenerated for the new canonical representation, and a focused contract test proves trivia-only changes are ignored while an API token change changes the digest.

There are no timeout changes, production behavior changes, wire changes, CLI changes, or user-facing configuration changes.

How you verified

  • Before the implementation, the new focused contract test failed with hashDeclarationTokens is not a function; afterward, api-sync.test.ts passes 4/4 in 34 ms.
  • The identical 160-process stress harness changed from 158/160 exact 5-second timeouts before the fix to 0/160 after it; contended test-body time fell to 0.35–1.19 seconds without changing the timeout.
  • pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk --force
  • pnpm exec turbo run typecheck --filter=@bb/plugin-api-map --force
  • pnpm exec turbo run test --filter=@bb/plugin-api-map --force — 11 files, 75 tests passed
  • Prettier check and git diff --check

AGENT GENERATED: by GPT-5.6-Sol

@ymichael
ymichael merged commit 0639445 into main Aug 26, 2026
15 checks passed
@ymichael
ymichael deleted the bb/ci-flake-fix-plugin-api-inventory-5s-timeout-thr_k5jadt4yz7 branch August 26, 2026 18:58
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.

1 participant