Repository navigation
fix(test): isolate legacy agent directory overrides - #132874
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 6:32 PM ET / 22:32 UTC. ClawSweeper reviewWhat this changesThis PR prevents isolated tests and shared test workers from inheriting the legacy PI_CODING_AGENT_DIR agent-directory selector while preserving explicit fixture overrides. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. The test-only patch repairs the legacy selector at each isolation owner and has no source-level blocking finding; the latest bot comment body was unavailable, so any earlier rank-up moves could not be rechecked. Priority: P3 Review scores
Verification
How this fits togetherTest utilities create private HOME and agent-state environments for model-status and integration tests. Their environment setup and shared-worker cleanup feed test fixtures, which must not borrow agent directories from the launching process. flowchart LR
Caller[Caller environment] --> Setup[Test environment setup]
Setup --> State[Test state builder]
Setup --> Runner[Shared test runner]
State --> Fixture[Model-status fixture]
Runner --> Fixture
Fixture --> Result[Test result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +76. Total +77 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the focused lifecycle-owner repair once the exact head satisfies the remaining repository merge gates and any prior review rank-up move is confirmed or explicitly skipped. Do we have a high-confidence way to reproduce the issue? Yes, by source: setting only PI_CODING_AGENT_DIR makes model status use that external directory, while the base test lifetime owners did not clear it. The supplied PR body also records native before/after owner-test runs, but this read-only review did not execute them. Is this the best way to solve the issue? Yes. Clearing the selector at test-environment setup, test-state spawn construction, and post-unstub shared-worker cleanup fixes the producer/lifecycle boundary without altering the retained runtime compatibility behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7781b904db87. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Source/proof review is complete for e0ca7a9fd5b57a907b46616095fc8cd30f84f684. This repairs a test-harness environment leak, not an OAuth, quarantine, routing, or persistence failure. The five support lines neutralize the inherited legacy selector at shared test-home setup/restore, post-unstub shared-worker restoration, and fixture/spawn environment construction. The shipped model-status alias and explicit fixture override precedence remain unchanged. Production LOC: +0/-0; test support +5/-0; tests +124/-52. The six changed files, complete model-status command/test, environment helper, callers, siblings, and Vitest contracts were reviewed. Native main-baseline inspection used Retained native before/after proof uses Node 24.15.0 and Vitest 4.1.11 with fresh secretless synthetic HOME/state, the legacy selector seeded, one worker, and verbose/JSON reports. The original 19-file partition moved from 539 passed / the original 3 failures to 542/542. Test-home and fixture-state owners moved from 11/15 to 15/15 and 16/20 to 20/20. The native shared-worker observer failed on the leaked alias before the fix; the final outer boundary passed 1/1, requiring 34 passing child cases plus its existing intentional collection failure. node scripts/run-vitest.mjs run --config test/vitest/vitest.commands-light.config.ts --passWithNoTests=false
node scripts/run-vitest.mjs test/test-env.test.ts
node scripts/run-vitest.mjs src/test-utils/openclaw-test-state.test.ts
node scripts/run-vitest.mjs test/non-isolated-runner.test.ts
node scripts/check-changed.mjs -- test/test-env.ts test/test-env.test.ts test/non-isolated-runner.ts test/non-isolated-runner.test.ts src/test-utils/openclaw-test-state.ts src/test-utils/openclaw-test-state.test.ts
git diff --check 8cd61f02bf48c190a439ccb53d56e9f47a87a110 e0ca7a9fd5b57a907b46616095fc8cd30f84f684The selected static/type/lint/architecture gates passed, and fresh isolated Codex P0 autoreview found no defects. The committed patch matches the successful retained proof byte-for-byte. Exact-head CI 33278578433 passed on attempt 1, and Workflow Sanity 33278513650 also passed. Native Limits remain explicit: earlier cache-enabled partition attempts stalled before assertions; a birth-bound sample showed a filesystem rename wait without pathname/root-cause attribution. Retained partition/shared-worker semantic runs disabled only the existing outer optional module cache. The child drops inherited Vitest options; its defaults, pool, isolation, assertions, and deadline were unchanged. An initial positive shared-worker attempt timed out at its existing deadline; the single authorized unchanged retry passed after exact cleanup/static gates. These timeouts and lost earlier temporary artifacts are not counted as passing proof. Model-status assertion order was preserved, but whole-partition file scheduling differed. No live-provider or operator-state success is claimed. The full ClawSweeper review, including its rank-up list, and the omitted acknowledgement were read. The omitted comment contains no findings or rank-up moves, resolving the discussion-availability concern. No actionable source finding remains. This comment records pre-merge readiness, not a completed merge. |
|
Merged via squash.
|
What Problem This Solves
Fixes model-status tests failing when the parent process exports
PI_CODING_AGENT_DIR. The shared test environment clearedOPENCLAW_AGENT_DIRbut left its still-supported legacy selector active, so an otherwise isolated status invocation selected the inherited directory instead of the fixture's mocked directory.The three recorded failures looked like masking, runtime-quarantine, and mixed-auth-route problems. Native assertion diffs instead showed one missing default-directory resolver call and two mismatched auth-store display paths.
Why This Change Was Made
Restore legacy-selector isolation at the three existing test lifetime owners: shared test-home setup/restore, shared-worker file cleanup, and integration test-state/spawn environment construction. Explicit fixture overrides retain precedence, including
agentEnv: "main", and cleanup restores absent, empty, and populated caller values.The runtime-internalization change in #85341 removed this test cleanup while model status retained the selector. The alias is also present in stable tag
v2026.7.1-2; this repair deliberately leaves production model-status behavior and assertions unchanged rather than removing the alias or teaching tests to accept leaked paths.Production LOC: +0/-0. Test support: +5/-0. Tests: +124/-52, extending existing tables and the real shared-worker producer/observer fixture rather than adding a production test seam.
User Impact
No production behavior, public configuration, schema, dependency, or persistence changes. Isolated tests no longer borrow the launcher's legacy agent directory. The existing explicitly allowed real-home test mode and explicit fixture overrides remain intact. All validation used synthetic, task-owned state; no operator Gateway, service, config, or credential state was changed.
Evidence
Current retained native proof on base
8cd61f02bf48c190a439ccb53d56e9f47a87a110, then the six-file repair, using Node 24.15.0 and Vitest 4.1.11:commands-lightpartition, 19 filestest/test-env.test.tssrc/test-utils/openclaw-test-state.test.tstest/non-isolated-runner.test.tsPI_CODING_AGENT_DIRNative commands, each run with a fresh private HOME/state/provider environment, a seeded
PI_CODING_AGENT_DIR, one worker, and verbose plus JSON reporters:The complete model-status file retains its original assertion order and both explicit environment-override cases. The full original partition was replayed, not just three selected assertions; native file scheduling differed after prior failures. Every retained run records an unchanged source diff during execution.
Execution limitations, not hidden passes: cache-enabled original-partition attempts stalled before assertions. A PID/birth-bound native sample observed a libuv filesystem worker waiting in
rename, without identifying the pathname or establishing the cause of every timeout. The retained original-partition before/after runs used the existing outerOPENCLAW_VITEST_FS_MODULE_CACHE=0option. The environment and test-state owner proofs used the default outer cache setting.The shared-worker semantic runs also disabled that optional cache on the outer runner only. Its child builder intentionally drops parent
VITEST*/OPENCLAW_VITEST*variables and keeps its existing one-worker,isolate: false, native configuration. The installed Vitest default is the forks pool; its optional module cache is unset/default-false, but temporary transformed-module copies can still be written. No nested defaults, pool, deadlines, or assertions were changed. A positive shared-worker attempt timed out at its existing 120-second test deadline; after exact cleanup and the static gates, the one bounded unchanged retry passed. No blanket signals, raised deadlines, or retries beyond the bounded attempts described above were used. Earlier lost temporary QA artifacts are not counted as current proof.Also passed:
The selected gate included core/core-test/root-test typechecks, core and script lint, format and architecture guards. Fresh isolated Codex P0 autoreview returned no findings. The committed patch is byte-identical to the patch used for the successful static gate and final native proof. Exact-head CI will be recorded after this PR is ready; no CI or live-provider success is claimed here yet.
Out of scope: the separately owned post-update service-identity fixture repair; the shell test-state helper's separate selector-cleanup gap; invocation-local strengthening of model-status mock-call assertions; and diagnosis of the host filesystem wait itself.
AI-assisted. Awaiting maintainer source/proof judgment before merge.