Repository navigation
test: restore fixture environments after native workers - #198998
Conversation
Restore the active environment in shared worktree, SQLite preload, and Doctor fixtures, and scope the scheduled-message creator override. This prevents stale Git settings, preloads, and result paths after environment identity replacement. Proves 26 stock-only regression identities on stock Bun, Node, and the pinned fork, with fixture rollback controls.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR restores fixture environment values after native-worker environment replacement and scopes the scheduled-message creator override. Example: A worktree test replaces process.env while GIT_COMMON_DIR is set to ../synthetic-repository/.git.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR provides a focused test-isolation repair that current main still needs. No actionable correctness or security findings were identified; exact-head CI remains pending. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherShared test fixtures prepare Git repositories, SQLite worker preloads, Doctor state, and scheduled-message scenarios; their environment overrides must end before subsequent tests run. flowchart TD
A[Test starts] --> B[Existing environment capture helpers]
B --> C[Shared fixtures apply overrides]
C --> D[Native worker may replace environment object]
D --> E[Fixture teardown restores active environment]
E --> F[Next test receives original values]
Technical reviewBest possible solution: Retain restoration in the existing fixture owners and the scoped cron environment helper, preserving all existing assertions. Do we have a high-confidence way to reproduce the issue? Source inspection supports the stale-environment teardown path, and the PR records before/after runs with rollback controls; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch repairs cleanup at the existing owners, retains the first preload snapshot across repeated calls, and adds focused restoration regressions without introducing another runtime path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 508dbdfe0d81. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +87. Total +87 across 6 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 14, 2026, 11:22 AM ET / 16:22 UTC. |
|
Merged via squash.
|
) Restore the active environment in shared worktree, SQLite preload, and Doctor fixtures, and scope the scheduled-message creator override. This prevents stale Git settings, preloads, and result paths after environment identity replacement. Proves 26 stock-only regression identities on stock Bun, Node, and the pinned fork, with fixture rollback controls.
Related: #198791
What Problem This Solves
Stock Bun leaves fixture environment overrides active after native-worker startup, making later worktree, database, Doctor, and scheduled-message tests fail against stale paths or settings.
User Impact
Developers can run the 26 identified cases on stock Bun, Node, and the pinned fork. There is no production behavior change.
Why This Change Was Made
The shared repository and Doctor fixtures now restore the active environment through the existing test environment helper. The SQLite preload fixture owns restoration of its four environment keys and retains the first snapshot across repeated calls. The shared cron scenario scopes its native-creator override with
withEnvAsync, so the scheduled child starts after that override ends.The existing temp-root resolver and its POSIX TMPDIR/TMP/TEMP and Windows TEMP/TMP precedence are unchanged. The change adds no resolver, runtime branch, global shim, setup-file override, sleep, retry, or assertion change.
Context: upstream oven-sh/bun#44371.
Evidence
Current-main baseline:
5e302bddf1cbf56acc94bc84061bff1eede74031. macOS arm64; Node 26.12.1; stock Bun1.4.4-canary.1+2596ac5d3(SHA-256 verified against its manifest); pinned fork1.4.4-canary.1+191755ec1(executable verified against the pin).Counts below are the 26 selected identities, not claims that every stock test in each file passes. All five complete files pass on Node and the fork.
src/agents/worktrees/service.acceleration.test.tssrc/gateway/server-agent-database-startup.test.tssrc/state/openclaw-agent-execution.integrity.test.tssrc/flows/doctor-health.test.tstest/cron-message-read.integration.test.tssrc/agents/worktrees/service.test-support.test.tssrc/infra/sqlite-worker-preload.test.tsWall times are single observations of
pnpm test <file> --maxWorkers=1on the pinned fork under the shared build lock with nice 10, not performance claims. The new-regression before timings use the new tests against the reverted fixture. Their assertions run after fixture teardown and verify active-object restoration, including two preload calls in one test; they add no worker starts or timers. Their test bodies take less than a second; cold compilation is included in wall time.Rollback controls restored only the four changed fixture/consumer files to the baseline, reproduced every selected failure, and then restored the fixed bytes exactly. Both owner regressions failed against the old fixtures. The final restored stock owner tests and six-case state startup-snapshot group passed.
Remaining stock-only results are deliberately outside this repair: the five ledger-excluded worktree template-contamination assertions still report
nullversusundefined; Gateway retains the four ledger-excluded lifecycle assertions plus two additional untargeted lifecycle assertions, all in the expected-boolean family. The complete stock state baseline took 843.59 seconds because of unrelated integrity-counter assertions and subsequent built-in timeouts. Its fixed run passed all five selected cases before reaching that separate counter failure; it was stopped there, and the complete six-case startup-snapshot group was rerun successfully in 19.77 seconds. None of these assertions or timeouts changed, and no full-stock green result is claimed.Targeted type checking, type-aware lint, formatting, and
git diff --checkpass. Fresh isolated P2 autoreview found no actionable issues. Exact-head PR CI passed on2f52611de298f674a74ce2161d2d01a62f7a9994; the aggregate gate is green. No rerun or inherited-failure exception was needed.