Skip to content

test: restore fixture environments after native workers - #198998

Merged
steipete merged 1 commit into
mainfrom
test/te-env-identity
Nov 14, 2026
Merged

steipete merged 1 commit into
mainfrom
test/te-env-identity

Conversation

@steipete

@steipete steipete commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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 Bun 1.4.4-canary.1+2596ac5d3 (SHA-256 verified against its manifest); pinned fork 1.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.

file ids stock before fork stock after node control wall s
src/agents/worktrees/service.acceleration.test.ts 13 13 failed 13 passed 13 passed 13 passed same 13 failures 53.18 → 54.81
src/gateway/server-agent-database-startup.test.ts 6 6 failed 6 passed 6 passed 6 passed same 6 failures 92.36 → 96.44
src/state/openclaw-agent-execution.integrity.test.ts 5 5 failed 5 passed 5 passed 5 passed same 5 failures 79.56 → 90.53
src/flows/doctor-health.test.ts 1 1 failed 1 passed 1 passed 1 passed same 1 failures 25.74 → 21.70
test/cron-message-read.integration.test.ts 1 1 failed 1 passed 1 passed 1 passed same 1 failures 64.89 → 54.87
src/agents/worktrees/service.test-support.test.ts owner regression new passed passed passed fails with old fixture 7.88 → 10.18
src/infra/sqlite-worker-preload.test.ts owner regression new passed passed passed fails with old fixture 1.77 → 1.89

Wall times are single observations of pnpm test <file> --maxWorkers=1 on 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 null versus undefined; 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 --check pass. Fresh isolated P2 autoreview found no actionable issues. Exact-head PR CI passed on 2f52611de298f674a74ce2161d2d01a62f7a9994; the aggregate gate is green. No rerun or inherited-failure exception was needed.

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.
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Nov 14, 2026
@steipete
steipete marked this pull request as ready for review November 14, 2026 16:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T16:08:32.862528Z 2f52611 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The active environment can retain that repository override after teardown.
  • After: The shared fixture restores the original environment values before the next test.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported test repair with reported cross-runtime regression controls; validation remains harness-based and broad CI is pending.
Proof confidence 🦐 gold shrimp (3/6) Only test fixtures and a test scenario change; the body supplies runtime-specific regression and rollback results, and no shipped-entry-point proof is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers encounter later test failures because fixture environment overrides survive native-worker startup and teardown.
Reason: The scoped repair restores test isolation with existing helpers and leaves unrelated stock-runtime failures and production contracts untouched.

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
Reviewed head: 2f52611de298f674a74ce2161d2d01a62f7a9994

Before merge

None.

Findings

None.

Agent review details

How this fits together

Shared 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]
Loading

Technical review

Best 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

  • Managed worktree fixtures keeps the original intent (cfc959c: Reuse initial Git history while preserving independent repositories and real remotes for each case.)
  • Doctor health fixtures keeps the original intent (b3cd259: Split costly Doctor tests and reuse closed database templates without weakening lifecycle or migration coverage.)
  • SQLite worker preloads keeps the original intent (21eeb7c: Forward required fixture instrumentation under Bun while retaining isolation and native-worker assertions.)
  • Scheduled native creator scenario keeps the original intent (9ee5c26: Exercise recorded Discord requester authority through job creation and later scheduled edits.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced patch confines restoration to existing test fixtures and the cron scenario, using captureFullEnv, captureEnv, and withEnvAsync without changing production behavior or assertions. (src/agents/worktrees/service.test-support.ts:85, 2f52611de298)
  • Current main still lacks restoration: The four modified fixture and consumer files are unchanged between the pinned merge base and fetched main, so the repair is not already implemented there. (508dbdfe0d81)
  • Regression evidence and scope: The PR body records 26 selected failing identities repaired across stock Bun, Node, and the pinned fork, fixture rollback controls, and two owner regressions that fail against the old fixtures; unrelated stock-only failures are explicitly retained. (2f52611de298)
  • Related merged repair: test: resolve fixture temp roots from the active environment #198791 repaired stale temp-root resolution and documented the separate environment-restoration failure addressed here. (2f03a74ea8ff)
  • Runtime contract context: fix(worker): preserve process.env identity when sharing environments oven-sh/bun#44371 documents environment-object replacement on first SHARE_ENV worker startup, directly supporting this PR's runtime-dependent failure explanation. (98ca6a2066ed)
  • Exact-head CI: The reviewed head remains unchanged; dependency and sensitive-product review statuses pass, while openclaw/ci-gate is pending. (2f52611de298)

Likely related people:

  • Peter Steinberger: Raw commit 21eeb7c adds src/infra/sqlite-worker-preload.test-support.ts:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 21eeb7c93244; files: src/infra/sqlite-worker-preload.test-support.ts)
  • Vincent Koc: Raw commit 5fecd06 adds src/flows/doctor-health.fixture.test-support.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5fecd066ad5f; files: src/flows/doctor-health.fixture.test-support.ts)

PR surface

Tests +87. Total +87 across 6 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 6 113 26 +87
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 113 26 +87

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P3: This repairs developer and CI fixture isolation without changing shipped product behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This repairs developer and CI fixture isolation without changing shipped product behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 14, 2026, 11:22 AM ET / 16:22 UTC.

@steipete
steipete merged commit daaaffa into main Nov 14, 2026
227 of 229 checks passed
@steipete
steipete deleted the test/te-env-identity branch November 14, 2026 16:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant