Repository navigation
Stabilize QA tests and correct the manual runbooks - #1404
Merged
ymichael merged 7 commits intoAug 12, 2026
Merged
Conversation
The watcher test wrote a real file and waited for a native FSEvents callback plus the 250ms debounce, so it failed whenever the watch-vaults service had not attached before the write or the host was busy enough to delay the event past the assertion window. Give the Docs plugin a watcher injection seam that defaults to the native `fs.watch` implementation, and have the test supply a fake watcher it can trigger directly. The test now asserts the watched root, the published `vault-changed` signal, and watcher cleanup on abort without depending on filesystem event timing. Production behavior is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The @bb/server vitest project runs with `isolate: false`, so every test file in a worker shares the module-level `lastDatabaseMaintenanceCheckAt` in periodic-sweeps.ts. periodic-sweeps.test.ts drives the real sweep registry at `Date.now()`, which parks that timestamp at wall time. This file then swept from a hardcoded 1_000_000_000_000 (2001), so whenever it happened to run after periodic-sweeps.test.ts in the same worker its synthetic sweeps looked "too soon" and every assertion failed. Start the synthetic clock a day ahead of wall time so it always leads any real timestamp another file may record. Reproduced the failure with `--no-file-parallelism --sequence.shuffle.files --sequence.seed=3` and confirmed the fix passes on the same ordering. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
buildDaemonRestartCommand baked the daemon PID captured at build time into the shutdown step, so the string only worked for the first restart. Running it a second time left the daemon started by the first run alive and then raced a second daemon against it on the same port and data dir. Resolve the PID from the daemon PID file at run time, keeping the build-time PID as a fallback for the first restart before the file exists, and refuse to run at all when the resolved value is not a positive integer so a corrupt PID file cannot turn into a stray `kill`. An empty PID stays valid and simply skips the shutdown step. Extend the standalone restart test to run the command twice and assert the first daemon is gone and a new PID is recorded. Verified the new assertions fail against the previous implementation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Exercise the supported contract deterministically: let a setup hook fail once, wait for the failure to settle, then send a new auto-mode message to start a fresh provisioning attempt. Remove the server-restart scenario and guard the runbook against reintroducing restart recovery or persisted provisioning-attempt semantics. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ymichael
force-pushed
the
bb/split-flaky-test-and-qa-fixes-into-pr-thr_7vjjsfxsns
branch
from
August 12, 2026 21:07
603561a to
27f7583
Compare
ymichael
deleted the
bb/split-flaky-test-and-qa-fixes-into-pr-thr_7vjjsfxsns
branch
August 12, 2026 21:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Test-determinism and QA/runbook maintenance only, extracted from #1385.
watch-vaultsservice had not attached yet or the host was busy.fs.watch, and have the test drive a fake watcher directly. It now asserts the watched root, the publishedvault-changedsignal, and watcher cleanup on abort — with no filesystem-event timing.@bb/servervitest project runs withisolate: false, so files share the module-levellastDatabaseMaintenanceCheckAt.periodic-sweeps.test.tsparks it at wall time, while this file swept from a hardcoded1_000_000_000_000(2001) — every sweep then looked "too soon".buildDaemonRestartCommandbaked in the PID captured at build time, so a second run left the first replacement daemon alive and raced a second one onto the same port and data dir.kill.MANAGED_ENVIRONMENT_RETIRE_GRACE_MS), so the old expectation was wrong.retiringplus a preserved worktree first, then permanently delete the archived thread and wait for destruction.DAEMON_PID=$!aftereval "$RESTART_DAEMON_COMMAND"captures the shell's job, not the detached daemon..paths.daemonRestartPidPath) exported by the standalone harness after each restart.readonlyandworkspace-writeare not accepted by the CLI (public modes areaccept-edits,auto,full), and Codex sandboxes commonly permit the OS temp dir, so/tmpprobes were not reliably outside the workspace.$HOME. A new contract test rejects stale mode names and pins the probe targets..bb-env-setup.shhook fails exactly once, the thread and environment settle inerrorwiththread_provisioning_failed, and one explicitbb thread tell ... --mode autostarts a fresh provisioning attempt that reachesreadybefore the turn runs. A contract test keeps the restart scenario from returning.Scope
No product behavior, database schema, migration, Drizzle snapshot, provisioning implementation, host-daemon wire contract, or protocol-version change.
The full diff is 8 files. Only two are non-test sources:
plugins/docs/server.ts— adds the watcher injection seam; the default parameter is the existing nativefs.watchimplementation, so production behavior is unchanged.tests/qa/src/shared.ts— QA-harness helper in thetests/qapackage.Deliberately omitted: the provider-interaction integration commit from #1385 (
0fc13d45e). It deletes roughly 750 lines of live-provider scenarios coveringautopermission mode plus theauto-ask/auto-denyharness presets. Its premise does hold on current main —autopairs withapprovalReviewer: "automatic", which the Codex adapter maps toauto_reviewrather than routing toonInteractiveRequest— so it is not strictly coupled to the excluded Codex runtime commits. It is omitted because it is a coverage deletion rather than a flaky-test or QA fix, and it cannot be validated here:src/integration*.test.tsis excluded from the defaulttesttask and only runs viatest:integrationagainst real providers. Removing unverifiable integration coverage does not belong in a no-product-change PR; it is left as a follow-up.Validation
Run on this branch rebased onto current
main:turbo run typecheck test --filter=bb-plugin-simple-notes --filter=@bb/qa --force— 5/5 tasks; Docs 59 tests, QA 25 tests.turbo run typecheck test --filter=@bb/server --force— 161 files, 1450 tests passed.--no-file-parallelism --sequence.shuffle.files --sequence.seed=3(4 failures), and passing on that same ordering after.buildDaemonRestartCommand.turbo run linton the touched packages — no lint tasks are defined for them.Runbook claims were checked against
mainrather than assumed:thread_provisioning_failed,errorinthreadStatusValues,bb thread wait --status,bb thread delete --yes,bb thread tell --mode auto,PROJECT_ROOTexported by the QA harness, andMANAGED_ENVIRONMENT_RETIRE_GRACE_MS = 5 * 60_000.Pre-existing macOS-only failure, not from this PR
packages/agent-runtime/src/runtime.process-lifecycle.test.ts > bounds provider stderr while data arrives without a newlinefails on cleanorigin/mainon macOS. Its fake child writes 100KB to stderr and immediately callsprocess.exit(42). Pipe writes are asynchronous on macOS, so the child exits without flushing bytes that never reach the parent; this is distinct from the real parent-sideexit-before-closedrain bug. CI'sTests (packages)shard runs on Ubuntu, where the fixture passes.#1402 fixes both issues separately: the fixture uses
process.exitCode = 42so Node flushes naturally, while the runtime waits for stream close before finalizing provider exit. Those provider-runtime changes are explicitly out of scope here, and this branch touches noagent-runtimefiles.