Skip to content

Stabilize changed-declaration bridge lifecycle test - #2084

Merged
ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-runtime-changed-declaration-bridge-thr_438y6f3ic3
Aug 20, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-runtime-changed-declaration-bridge-thr_438y6f3ic3

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

What was wrong

The packages CI shard runs nearly every package test concurrently on a 4-vCPU runner. This lifecycle test serially starts three real bridge processes, but it used the shared TypeScript fake provider, so every launch paid a fresh tsx transform under that CPU contention. The process-key assertions were already synchronous and correct; the avoidable fixture compilation pushed the test past Vitest's 5-second default in run 32420576377 and run 32293912651.

What changed

The test now reuses this file's existing plain-JavaScript thread-scoped provider fixture. It still starts and shuts down three real bridge processes and exercises the same runtime process-key behavior, but does not compile a TypeScript fixture for each launch. Assertions and timeouts are unchanged. This is test-only; there are no wire, runtime-product, CLI, guide, or documentation changes.

How you verified

  • Reproduced before the change under controlled CPU contention: the focused test failed with the same 5000ms timeout (reported duration 5005ms).
  • Repeated the identical contention after the change: passed in 2812ms.
  • Ran 25 fresh-process focused repetitions: 25/25 passed.
  • pnpm exec turbo run test --filter=@bb/agent-runtime --force --output-logs=full -- --project '@bb/agent-runtime:isolated' src/runtime.process-lifecycle.test.ts -t 'gives a changed declaration its own bridge process at the same artifact hash' (1 passed; 85ms test time).
  • pnpm exec turbo run test --filter=@bb/agent-runtime --force --output-logs=full (31 files, 422 tests passed).
  • pnpm exec turbo run typecheck --filter=@bb/agent-runtime --force --output-logs=full (passed).
  • pnpm exec turbo run build --filter=@bb/agent-runtime --force --output-logs=full (upstream generation tasks passed; this source-only package has no build task).
  • pnpm exec turbo run lint --filter=@bb/agent-runtime --force --output-logs=full (the package has no lint task), plus pnpm exec eslint packages/agent-runtime/src/runtime.process-lifecycle.test.ts (passed).

AGENT GENERATED: by GPT-5.6-Sol

@bb-slop-cop

bb-slop-cop Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am SlopCop. I am reviewing this pull request for security, code quality, performance, duplication, architecture, and test behavior.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain English summary

This PR gives one lifecycle test its own small provider fixture. The test avoids three TypeScript loader starts.

This change reduces timing sensitivity under CPU load. It does not change production behavior.

Findings

I found no blocking security, quality, architecture, duplication, or performance issue.

The fixture stays in the per-test temporary directory. The existing cleanup removes it after each test.

The file-local helper now has nine related uses. I found no useful duplicate code or extraction for this PR.

The new CommonJS fixture removes loader work. The test still starts three provider processes and checks the same lifecycle behavior.

Verification

  • The focused test passed.
  • All 36 lifecycle tests passed.
  • The agent-runtime type check passed.
  • The package review passed all 31 files and 422 tests.
  • All current GitHub checks passed.
  • A browser test did not apply because this PR changes no server or UI route.

I left a comment-only review. I did not approve or request changes.

@ymichael
ymichael merged commit 914e875 into main Aug 20, 2026
13 checks passed
@ymichael
ymichael deleted the bb/ci-flake-fix-runtime-changed-declaration-bridge-thr_438y6f3ic3 branch August 20, 2026 22:20
ymichael added a commit that referenced this pull request Aug 24, 2026
## What was wrong

PR #2084 removed avoidable TypeScript fixture transforms from this test,
but the unified provider-harness work in #2325 later moved it back onto
the TypeScript scripted-echo bridge while preserving three serial
real-process launches. The packages shard makes each tsx-backed startup
compete with many other workers; the redundant third launch pushed the
test over its unchanged 15-second cap. Under controlled contention, the
request log reached the third process's initialize request but timed out
before its thread/start request, confirming cumulative process startup
as the cause rather than a polling deadline. No bridge process remained
after the timed-out worker exited.

## What changed

Successive capability-declaration fingerprints at one artifact hash now
have deterministic coverage in bridge-launch-process-key.test.ts. The
end-to-end lifecycle test retains the minimum real-process boundary: two
equal declarations share one initialized bridge, then one changed
declaration initializes a distinct second bridge. This keeps assertions
for hangs, process reuse, and process distinction while removing the
third serial launch. The 15-second timeout is unchanged. This is
test-only; there is no production, wire, CLI, guide, or protocol-version
change.

I rejected a timeout increase because scheduler contention is only the
reproduction condition. I also kept two real bridges instead of
replacing the lifecycle boundary with an injected process factory,
because two processes are the minimum needed to prove end-to-end
distinction.

## How you verified

- Unchanged baseline, unloaded: focused test passed in 596ms.
- Unchanged baseline under 192 and 384 CPU competitors: passed in 7.484s
and 11.895s.
- Unchanged baseline under 576 CPU competitors: reproduced the exact
failure at 15.009s with Test timed out in 15000ms.
- Changed test under the identical 576-competitor condition: passed in
11.052s with the same timeout; no scripted bridge process remained
afterward.
- Changed test, unloaded: 330ms; 10/10 fresh Turbo/Vitest repetitions
passed (about 0.31s when reported).
- pnpm exec turbo run test --filter=@bb/agent-runtime --force
--output-logs=full -- src/bridge-launch-process-key.test.ts (2 passed).
- pnpm exec turbo run test --filter=@bb/agent-runtime --force
--output-logs=full -- --project '@bb/agent-runtime:isolated'
src/runtime.process-lifecycle.test.ts (35 passed).
- pnpm exec turbo run test --filter=@bb/agent-runtime --force
--output-logs=full (21 files, 317 tests passed).
- pnpm exec turbo run typecheck --filter=@bb/agent-runtime --force
--output-logs=full (passed).
- pnpm exec turbo run build --filter=@bb/agent-runtime --force
--output-logs=full (upstream generation passed; this package has no
build task).
- pnpm exec turbo run lint --filter=@bb/agent-runtime --force
--output-logs=full (this package has no lint task), plus targeted
oxlint, oxfmt --check, and git diff --check (passed).

> AGENT GENERATED: by GPT-5.6-Sol
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