Skip to content

fix(test): exclude browser cache and profile directories from live auth staging (fixes #91893) - #92570

Closed
zenglingbiao wants to merge 1 commit into
openclaw:mainfrom
zenglingbiao:fix/issue-91893-test-env-cache-filter
Closed

zenglingbiao wants to merge 1 commit into
openclaw:mainfrom
zenglingbiao:fix/issue-91893-test-env-cache-filter

Conversation

@zenglingbiao

Copy link
Copy Markdown
Contributor

Summary

  • Problem: test/test-env.ts copyDirIfExists uses unfiltered fs.cpSync to copy LIVE_EXTERNAL_AUTH_DIRS (which includes .gemini) into a temp home during live test setup. On machines where .gemini contains browser profile data (e.g. Antigravity browser), this copies multi-GB caches and fills /tmp with ENOSPC.
  • Root Cause: copyDirIfExists calls fs.cpSync with { recursive: true, force: true } but no filter option. When .gemini contains browser caches (antigravity-browser-profile, browser_recordings, Service Worker directories), the entire multi-GB tree is copied blindly.
  • Fix: Add a filter to copyDirIfExists that skips known browser cache and profile directories. Auth files (.gemini/auth.json) and other legitimate config are still copied.
  • What changed:
    • test/test-env.ts — new COPY_EXCLUDE_PATTERNS constant and filter option on fs.cpSync
    • test/test-env.test.ts — new test case verifying cache directories are excluded from live auth staging
  • What did NOT change (scope boundary):
    • LIVE_EXTERNAL_AUTH_DIRS list is unchanged — .gemini is still staged
    • Non-cache .gemini content (auth tokens, config) is still copied as before
    • Other callers of copyDirIfExists (credentials, external-plugins) are unaffected

Reproduction

  1. Install a browser that populates .gemini/antigravity-browser-profile/Default/Cache/ with several GB of data
  2. Set OPENCLAW_LIVE_TEST=1 and run live tests that call stageLiveTestState
  3. Before this PR: fs.cpSync recursively copies the entire .gemini tree including multi-GB browser cache → ENOSPC on /tmp
  4. After this PR: browser cache and profile directories are filtered out; only auth/config files are staged

Real behavior proof

Behavior or issue addressed (91893): copyDirIfExists in live test staging copies multi-GB browser cache and profile directories from .gemini, causing ENOSPC on /tmp.

Real environment tested: Linux, Node 22 — temp-directory fixture exercising the stageLiveTestState code path through installTestEnv.

Exact steps or command run after this patch: node scripts/run-vitest.mjs test/test-env.test.ts

Evidence after fix:

 RUN  v4.1.7 /home/0668001395/openclawProject1

 Test Files  1 passed (1)
      Tests  5 passed (5)
   Start at  09:57:36
   Duration  1.96s

[test] passed 1 Vitest shard in 10.24s

Observed result after fix: The new excludes browser cache and profile directories from live auth staging case confirms that antigravity-browser-profile, browser_recordings, and Service Worker directories are fully excluded from the staged temp home, while legitimate auth files (.gemini/auth.json) are still correctly copied. The 4 pre-existing installTestEnv cases continue to exercise config/auth staging without regression.

What was not tested: Live ENOSPC reproduction was not driven — that requires a macOS machine with multi-GB .gemini browser cache. The source-code path through fs.cpSync with the new filter is verified via the temp-directory test fixture.

Repro confirmation: The new test case creates a temp home containing .gemini with both auth files and simulated browser cache directories, then verifies the cache directories are absent from the staged output. Before this patch, the same fixture would copy all directories without filtering.

Risk / Mitigation

  • Risk: The exclusion patterns are string-based and could theoretically match a legitimate path name.
    Mitigation: Patterns target names that are specific to browser internals (antigravity-browser-profile, Service Worker/CacheStorage, GPUCache, Cache_Data). These are extremely unlikely to appear in auth/config paths. The filter only applies to the live test staging path, not production runtime.
  • Risk: A future browser version could use different cache directory names.
    Mitigation: The patterns are easy to extend. The filter is non-destructive — at worst, a new cache directory would not be excluded until the pattern list is updated.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • test infrastructure

Regression Test Plan

  • node scripts/run-vitest.mjs test/test-env.test.ts
  • The new test case verifies: auth files are copied, cache directories are excluded

Review Findings Addressed

N/A (initial submission)

Linked Issue/PR

Fixes #91893

@openclaw-barnacle openclaw-barnacle Bot added size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 13, 2026
@clawsweeper

clawsweeper Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 12, 2026, 10:59 PM ET / 02:59 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Tests +62. Total +62 across 2 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: persistent cache schema: test/test-env.test.ts, persistent cache schema: test/test-env.ts, serialized state: test/test-env.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🌊 off-meta tidepool
Proof: 🌊 off-meta tidepool
Patch quality: 🌊 off-meta tidepool
Result: rating does not apply to this item.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against ded3a9305876.

Label changes

Label justifications:

  • rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
Evidence reviewed

PR surface:

Tests +62. Total +62 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 62 0 +62
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 62 0 +62

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Codex review failed for this PR with exit 1.
  • codex stderr: ),\n+ "cache\n",\n+ );\n+ writeFile(\n+ path.join(\n+ realHome,\n+ ".gemini",\n+ "antigravity-browser-profile",\n+ "Default",\n+ "GPUCache",\n+ "gpu-data",\n+ ),\n+ "gpucache\n",\n+ );\n+ writeFile(\n+ path.join(realHome, ".gemini", "antigravity", "browser_recordings", "recording.json"),\n+ "recording\n",\n+ );\n+ writeFile(path.join(realHome, ".gemini", "Service Worker", "CacheStorage", "sw-cache"), "sw\n");\n+\n+ process.env.HOME = realHome;\n+ process.env.USERPROFILE = realHome;\n+ process.env.OPENCLAW_LIVE_TEST = "1";\n+ process.env.OPENCLAW_LIVE_TEST_QUIET = "1";\n+\n+ const testEnv = installTestEnv();\n+ cleanupFns.push(testEnv.cleanup);\n+\n+ const tmpGemini = path.join(testEnv.tempHome, ".gemini");\n+ // Auth files should be copied\n+ expect(fs.existsSync(path.join(tmpGemini, "auth.json"))).toBe(true);\n+ // Cache directories should NOT be copied\n+ expect(fs.existsSync(path.join(tmpGemini, "antigravity-browser-profile"))).toBe(false);\n+ // antigravity/ parent dir is not in the exclusion list, but browser_recordings inside it should be excluded\n+ expect(fs.existsSync(path.join(tmpGemini, "antigravity", "browser_recordings"))).toBe(false);\n+ expect(fs.existsSync(path.join(tmpGemini, "Service Worker"))).toBe(false);\n+ });.
  • codex stdout: No stdout captured.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label Jun 13, 2026
@zenglingbiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

proof: supplied External PR includes structured after-fix real behavior proof. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test-env.ts: copyDirIfExists copies multi-GB browser cache causing ENOSPC in live tests

1 participant