Repository navigation
fix(test): clean up failed fixture allocations - #132282
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
da94011 to
c58ba4d
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 1:50 AM ET / 05:50 UTC. ClawSweeper reviewWhat this changesThe PR rolls back failed test-fixture allocations, lets later calls recover after a rejected shared temporary-home allocation, and classifies identical TCP endpoints as self-connections in the Gateway QA probe. Merge readinessNo introduced correctness or security defect was found. This maintainer-owned, protected PR remains necessary because current main still lacks both the fixture rollback and the TCP self-connection classification. Priority: P2 Review scores
Verification
How this fits togetherTest utilities create isolated homes, state directories, and environment variables for OpenClaw’s test suites. The Gateway QA probe then starts isolated Gateway instances and reports whether loopback binding remains inaccessible through the host LAN interface. flowchart LR
A[Test setup request] --> B[Fixture allocation owner]
B --> C[Temporary files and environment]
C --> D[Cleanup handle]
D --> E[Test execution]
F[Gateway QA scenario] --> G[TCP reachability probe]
G --> H[Loopback isolation result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +22, Tests +311. Total +333 across 8 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Merge the owner-boundary cleanup and E2E-routed probe regression after normal maintainer approval, preserving the existing Gateway scenario contract. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the added tests exercise real filesystem allocation failures and the isolated Gateway owner with a narrowly injected TCP connection; this read-only review did not execute them. Is this the best way to solve the issue? Yes. The changes repair each failure at its allocation or probe owner, preserve successful cleanup behavior, and add endpoint controls without expanding product runtime behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f0ade2dbf32b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
c58ba4d to
2d1b800
Compare
|
Updated landing evidence for The fixture repair keeps rollback with the allocator until a handle is returned, retains the raw allocated path across canonicalization failure, and lets the SDK promise creator evict a rejected root without hidden retries. Its six reviewed files are unchanged. The combined 64-test owner/companion proof preserves merged #132257 callback/staging coverage and #132208 namespace behavior. The approved adjacent CI repair fixes an independently reproduced TCP probe defect: Linux can emit The test-support probe now returns unreachable only when both connected endpoints are identical. Different address or port still fails loopback isolation; error/timeout behavior stays unchanged. Through the existing real Gateway producer, the pre-fix regression had one intended self-connect failure and two non-self passes; post-fix all three pass. The unchanged real-network file also passed all three tests and retains its unit-fast route. No private probe export, product seam, retry, skip, larger timeout, Gateway product/config/auth/schema change or routing change was added. The routing correction's exact-head CI move is satisfied. The earlier suggestion to wait for #122757 is explicitly not adopted: the maintainer declined takeover, and its routing-only rename does not repair this transport mechanism. This bounded probe repair was separately reviewed and approved. No #122757 content or YAML was copied or changed. Commands used with fresh synthetic HOME/state/TMP/XDG and a literal credential-free child environment: node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-loopback-lan-access.probe.test.ts --maxWorkers=1 --no-file-parallelism --no-isolate
node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-loopback-lan-access.test.ts test/e2e/qa-lab/runtime/gateway-loopback-lan-access.probe.test.ts --maxWorkers=1 --no-file-parallelism --no-isolate
node scripts/check-changed.mjs -- test/e2e/qa-lab/runtime/gateway-loopback-lan-access.ts test/e2e/qa-lab/runtime/gateway-loopback-lan-access.probe.test.ts
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json test/e2e/qa-lab/runtime/gateway-loopback-lan-access.ts test/e2e/qa-lab/runtime/gateway-loopback-lan-access.probe.test.tsThe combined command passed the original network file but its new tooling shard hit the existing startup watchdog during imports. One standalone regression run after concurrent checks ended passed 3/3. An extra lint attempt using the test tsconfig timed out in unnecessary SDK declaration generation before lint; the scoped command above passed with zero warnings/errors. Full changed-file gate, root-test typecheck, formatting and diff check passed. Fresh isolated Codex review found no actionable findings. Guard-required rebases were conflict-free and range-diff-identical. No full-job replay pass is claimed: the earlier unchanged 644-file selection passed 7407 tests/3 skipped, but its separate command-plugin prelude had two local failures. Product runtime +0/-0; test support +145/-117 (net +28); tests +307/-2 (net +305). All recorded task scratch roots are absent. Isolated test-managed Gateways and synthetic auth were used; no operator Gateway/state, real credentials or provider calls. Caller-wrapper follow-up remains separate. The previously failing shard now passed both groups and the unchanged real-network proof (4.433s). One non-required ClawSweeper dispatcher was canceled with zero steps under its edit/synchronize concurrency policy; the same CI workflow completed green without reruns or bypass. The current head is mergeable; GitHub reports Current E2E proof command (earlier commands above are historical pre-rename evidence): node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/e2e/qa-lab/runtime/gateway-loopback-lan-access.probe.e2e.test.ts --maxWorkers=1 --no-file-parallelism --no-isolate |
2d1b800 to
9b4824d
Compare
9b4824d to
db0d414
Compare
|
Merged via squash.
|
* fix(test): roll back failed fixture allocation * fix(test): reject self-connections as listener evidence * test: route probe regression through e2e
Related: #132257 (separate callback/environment acquisition rollback) and #132208 (managed test-runner namespace cleanup).
What Problem This Solves
Resolves a problem where failed test-fixture setup leaves directories or process environment changes behind before the caller receives a cleanup handle. A failed shared SDK home-root allocation also remains cached, so later calls using the same prefix fail even after the filesystem problem has been corrected.
Why This Change Was Made
Put rollback at the acquisition owner: the temporary-home and test-state factories retain ownership until returning their handles, including the interval between
mkdtempandrealpathand partial environment application. The shared SDK allocator evicts a rejected root promise once at its creator while propagating that failure to existing waiters; only a later explicit call starts another allocation.Successful shared-root retention, unique cases, layout/env behavior, and scoped database teardown ordering are unchanged. Failed acquisition removes only its own home/root and does not drain unrelated session work. This does not duplicate the callback/staging rollback in #132257 or the parent namespace cleanup in #132208, and adds no sweeps, options, dependencies, schema changes, test-only production seams, or hidden retries.
User Impact
No product-runtime behavior change. Developers running tests get reliable failed-acquisition cleanup and can use the same SDK prefix again after repairing an allocation fault. Successful fixture lifecycle contracts remain intact.
Production runtime LOC: 0. Test support: +28 net, establishing acquisition rollback, failed-promise eviction and correct TCP probe classification. Regression tests: +305 net relative to the base that includes #132257. Most test-state factory diff churn is indentation under its acquisition boundary.
Evidence
AI-assisted implementation and independent Codex review. Nine new regressions failed on the pre-fix source for the intended reasons: eight directory/config/canonicalization/environment rollback cases and one real
ENOENTcached-root recovery case. After the repair, all 41 focused owner/sibling tests pass on local macOS with Node 26 and in a final serial Node 24 run with isolation disabled.Every test/check child ran with freshly allocated synthetic
HOME,USERPROFILE, OpenClaw state/config paths,TMPDIR/TMP/TEMP, and XDG directories, using a literal allowlisted environment without ambient credentials. Tests use real filesystem effects plus narrow fault injection; SDK failure/recovery uses a real missing parent directory without mocks or module resets. All recorded test/check scratch roots were verified absent after child completion.Final focused command:
Full changed-file gate passed, including core/core-test/plugin/plugin-test typechecks, lint, formatting, SDK boundaries, dead-export scans, and selected architecture guards:
git diff --checkalso passed. The first isolated gate attempt could not find Corepack; correcting the allowlisted tool path and supplying the already-installed pinned pnpm package in the scratch cache allowed the full offline gate to pass. An initial environment-fault spy was corrected before the authoritative pre-fix red run; the post-fix lint correction only typed the rejection value asunknownand its SDK regression was rerun.No Windows, full Vitest suite, live-provider, or UI run is claimed. Isolated test-managed Gateway proof is described below. The changed boundary is test-fixture acquisition, exercised directly by the real-filesystem regressions; no operator Gateway or real credentials were used. Additional caller-owned staging observations in
setupAuthTestEnvandcreateOpenClawTestInstanceare recorded for a separate investigation, not included here.Post-publication integration: #132257 landed as
a9f802f773f8b0ef9b999bad28914e8ee43227be. Rebasing preserved both repairs and resolved only a shared test import conflict.git range-diffconfirms no change to this repair beyond the combined imports. A fresh independent Codex review found no P0 defects, and all 64 combined owner/sibling tests passed serially on Node 24 with isolation disabled, including the companion SDK andinstallTestEnvregressions. Targeted six-file formatting and lint passed (zero warnings/errors). The combined command addstest/test-env.test.tsto the focused command above. All test/check children used fresh synthetic state and credential-free environments; no real profile, credentials, or Gateway was used. That six-file acquisition repair is unchanged by the bounded CI probe repair below.Bounded CI probe repair
The original hosted failure was run33228943813, job99038139384: the real network proof reported loopback isolation from LAN as false. Investigation independently reproduced a defect in its TCP probe: Linux can connect an ephemeral socket to its own identical address and port, emitting
connecteven when the correctly bound listener accepts no connection. The original CI run did not record endpoint values, so this is not a conclusive attribution of that individual failure.The probe now classifies identical local/remote address and port as self-connection/unreachable. Any different endpoint still reports reachable and fails loopback isolation; errors and timeouts retain their existing behavior. No Gateway product binding, authorization, configuration, schema, or test routing changed. The earlier routing-only suggestion in #122757 does not fix this transport mechanism; that PR is not taken over or duplicated.
Credential-free Linux Node24 controls observed a natural self-connect on attempt 61 without forcing a source port, with zero listener accepts; a positive exposed-listener control accepted one connection with different endpoints. A separate three-case regression calls the existing real Gateway proof and narrowly injects only the probe connection. Against the actual pre-fix producer, the self-connect case failed for the intended isolation error while both non-self cases passed. There is no new production test seam, retry, skip, increased timeout or weakened isolation assertion. The original real-network test is unchanged and keeps its unit-fast route.
Post-fix: all three new regressions passed on Node24, and the unchanged real-network test passed all three tests in its original unit-fast route. The new regressions protect self-connect, same-address/different-port and different-address/same-port; each exercises real Gateway startup, HTTP and token-auth flow outside the narrow injected probe. The original six factory files still match their reviewed hashes and retain the 64-test combined companion proof above.
Exact local commands (each test/check child used fresh synthetic state and a literal credential-free environment):
The complete changed-file gate passed, including formatting and root-test typechecking; scoped lint reported zero warnings/errors, and
git diff --checkpassed. A fresh isolated Codex autoreview found no actionable defects. Guard-required rebases preserved both commits byte-for-byte, without conflicts or changed repair semantics.Validation limits are explicit: the first combined post-fix command passed the original network test but its new tooling shard was terminated by the unchanged 15-minute no-output watchdog during imports. A process sample showed module loading. One standalone run after all other local checks finished passed the three regressions (246.55s import, 60.42s tests). No test timeout or assertion changed and no automatic retry ran. An extra lint invocation using the test tsconfig triggered unnecessary SDK declaration generation and its existing timeout; the normal core lint configuration above passed. All recorded scratch roots were removed. Earlier replay of the original 644-file unit-fast selection passed 7407 tests/3 skipped, but a separate preceding command-plugin group had two local failures: no full CI-job replay pass is claimed.
Product runtime remains +0/-0. Total test support +145/-117 (net +28); tests +307/-2 (net +305), across eight files. Hosted CI 33233730048 completed successfully (169 successful jobs, 17 skipped) on exact head
db0d4148e0ed413e019c7e055ec70e5268f5ad1b; native prepare and merge have not run.The required openclaw/ci-gate passed. The previously failing shard passed both groups, including the real-network proof in 4.433s. One unrelated ClawSweeper dispatcher was canceled before any step under its edit/synchronize concurrency policy; it is not a required check. The documented watcher continued against the same CI workflow, which completed green; no CI job was rerun or gate bypassed. At the prior-head checkpoint, live rules required no independent approval. The late ClawSweeper routing finding is addressed in
36d916ca276e3c50e0c1b59558ddb01c17bfa7c2: only the newly added regression was renamed togateway-loopback-lan-access.probe.e2e.test.ts(100% identical contents). The original network test and QA YAML are unchanged. The suggestion to add a QA code reference is intentionally skipped under the maintainer no-YAML-change scope: existing references and scenario execution remain valid, and E2E discovery uses the suffix independently. Fresh exact-head CI33236250110 is green (169 successful jobs, 17 skipped), including the required openclaw/ci-gate. Native artifacts validated asREADY FOR /prepare-pr; prepare/merge have not run.The renamed E2E regression passed all three cases on Node24 through the standard E2E configuration, including its complete runtime/private-QA and AI build prerequisites (no build skip or retry). Test phase: 38.61s. The changed-file gate, root-test typecheck, formatting, scoped lint and diff check passed; fresh isolated Codex review found no actionable findings. The earlier red/green commands above retain their historical pre-rename filenames. Current commands:
Final parent checkpoint: current head
36d916ca276e3c50e0c1b59558ddb01c17bfa7c2is mergeable. GitHub reportsUNSTABLEonly because a non-required ClawSweeper dispatcher was canceled before any step; the required gate is green from GitHub Actions app15368, and live rules require no independent approval. Native ordinary merge verification uses the CI workflow and required checks, not optional contexts. No CI rerun or bypass was used. All 41 recorded test/check scratch roots are absent, both checkouts are clean, and native prepare/merge remain uninvoked pending parent verification.