Skip to content

fix(test): prevent ClawHub fixtures from polluting sandbox hashes - #139902

Closed
steipete wants to merge 1 commit into
mainfrom
fix/test-workspace-isolation
Closed

steipete wants to merge 1 commit into
mainfrom
fix/test-workspace-isolation

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where unrelated pull requests and main CI fail the sandbox browser config-hash test when the ClawHub test shard runs first. The failure appeared in main CI and the avatar repair CI.

Why This Change Was Made

ClawHub's install mock returned a shared /tmp/workspace/skills/agentreceipt destination while the real provenance writer created files there. The browser fixture then discovered that directory as a protected skill mount, although its expected hash assumed no mounts.

ClawHub tests now allocate and clean an owned workspace for each case, and the install mock returns its actual requested destination. The browser epoch case also uses its existing tracked temporary-directory helper. Three redundant mock overrides are removed.

User Impact

Developers get deterministic CI across concurrently scheduled shards. Runtime behavior and sandbox security policy are unchanged.

Evidence

Superseded by #139894, merged as 9532052c47d87c2d2ea3eb7161bf49b7b8d18d52. The landed repair isolates both owners, including every browser fixture. On captured main 83d1f53c51a262cf8cec0fce14548514daee4d35, both repaired files match the canonical merge and all 144 relevant tests passed. The checkout is clean. The canonical PR's exact-head CI passed. This candidate is retained for its diagnostic evidence and will not be merged.

The retained remote proof below applies to original candidate 64bcdb99e4f3dc9a7f5075fbb35ea64f0e78adb4. It must not be mistaken for a remote run of the separately landed implementation. The later unchanged-patch rebase to e0feeaf8dcc17d655acdb427a10e92f7105720ee became redundant; its second Testbox acquisition was stopped before tests ran.

Local focused suites passed: 117 ClawHub tests and 27 sandbox browser tests. The original 63-file agents envelope also passed when run without the ClawHub writer, confirming the missing cross-shard interference in a narrow retry.

Remote proof ran on Blacksmith Testbox lease tbx_01m1tt706weysfrjgwx9wf97qy, run 34019498275, comparing baseline ba3a6cb5f690789e0824c7c92618579743b9cade with candidate 64bcdb99e4f3dc9a7f5075fbb35ea64f0e78adb4 in separate detached worktrees. The exact source trees were verified before execution.

The ordered replay used the original installs ClawHub skills from flat-root archives and includes the explicit env policy epoch in the browser config hash when needed cases via node scripts/run-vitest.mjs:

baseline browser, clean workspace: PASS
baseline ClawHub writer: PASS; shared origin.json exists
baseline browser, after writer: EXPECTED FAIL at browser.create.test.ts:606
candidate browser, with old residue: PASS
candidate ClawHub writer: PASS; shared workspace absent
original browser, after candidate writer: PASS
candidate complete focused suites: 117 + 27 tests PASS
candidate full changed gate: PASS
lease cleanup: completed/stopped (independently verified)

The original browser passing after the repaired writer independently proves the producer repair. The full remote changed gate passed, including the agents-other and services test type graphs, formatting, lint, declaration, dependency, and repository guards. Original-head CI is green. The lease is independently confirmed completed/stopped. A portal metadata-sync timeout occurred after successful proof and cleanup.

The local changed gate had rejected declaration inputs from its read-only linked dependency checkout before typechecking; the complete remote gate used owned prepared dependencies. This is test-harness proof with real filesystem effects; existing Docker and network mocks remain in place.

Independent local and committed-branch reviews found no actionable P0–P2 findings.

git diff --numstat:

Scope Added Removed Net
Production 0 0 0
Tests 66 68 -2

No changelog change: this is a test-fixture CI repair.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 07:34
@steipete
steipete requested a review from a team as a code owner September 6, 2026 07:34
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 3:41 AM ET / 07:41 UTC.

ClawSweeper review

What this changes

The PR gives ClawHub installation tests isolated workspaces and moves the sandbox hash test to a tracked temporary directory, preventing filesystem fixtures from interfering across suites.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, focused repair: the shared fixture destination persists on reviewed main, and no introduced correctness defect was found. The protected, maintainer-authored PR should remain open.

Priority: P2
Reviewed head: 64bcdb99e4f3dc9a7f5075fbb35ea64f0e78adb4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, maintainable fixture repair with preserved assertions and reported focused validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test-only PR; its reported focused passes support fixture behavior, while original-order replay remains a validation follow-up.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test-only PR; its reported focused passes support fixture behavior, while original-order replay remains a validation follow-up.
Evidence reviewed 7 items Introduced scope: The pinned merge-base-to-head patch changes only the two test fixtures. Host-verified test-merge evidence also limits the result to those files; unrelated endpoint drift is not attributed to this PR.
Filesystem pollution mechanism: The installation owner writes skill origin metadata to install.targetDir and tracking metadata to the supplied workspace. The test mocks installation but leaves these writes real; returning the requested destination confines them to the owned workspace.
Hash failure mechanism: Sandbox browser creation includes discovered read-only skill mounts in its hash, while the test helper expects an empty mount list. The changed epoch test passes its fresh directory to both the expected-hash helper and browser creation, preserving the assertion.
Findings None None.
Security None None.

How this fits together

ClawHub installation tests invoke real tracking-file writes behind mocked downloads and installation. Sandbox browser tests discover workspace skill directories when computing container hashes, so shared test directories can connect otherwise unrelated suites.

flowchart TD
 A[ClawHub test case] --> B[Owned temporary workspace]
 B --> C[Mocked installation destination]
 C --> D[Real tracking file writes]
 D --> E[Per-test cleanup]
 F[Sandbox browser test] --> G[Separate temporary workspace]
 G --> H[Skill discovery and config hash]
Loading

Before merge

  • Resolve merge risk (P1) - The captured evidence does not yet show the ClawHub-writer-before-browser-reader replay completing; isolated suite passes do not establish that execution-order regression.
  • Complete next step (P2) - Add the promised original-order before/after replay result to the PR evidence before landing.
Agent review details

Security

None.

PR surface

Tests -2. Total -2 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 66 68 -2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 66 68 -2

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep filesystem writes inside owned test workspaces while retaining real provenance writes, mount discovery, and the existing hash assertions.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep filesystem writes inside owned test workspaces while retaining real provenance writes, mount discovery, and the existing hash assertions.

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

Yes, from source: running ClawHub installs first writes into the shared workspace, after which browser skill discovery contradicts the fixture’s empty-mount hash expectation. This review did not execute that sequence.

Is this the best way to solve the issue?

Yes. Correcting the fixture destination and using existing temporary-directory helpers repairs the test-owned state without mocking away provenance writes or weakening sandbox assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against bed5042933bb.

Labels

Label changes:

  • add P2: This is a bounded test-isolation defect affecting developer validation without changing shipped runtime behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test-only PR; its reported focused passes support fixture behavior, while original-order replay remains a validation follow-up.

Label justifications:

  • P2: This is a bounded test-isolation defect affecting developer validation without changing shipped runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test-only PR; its reported focused passes support fixture behavior, while original-order replay remains a validation follow-up.

Evidence

What I checked:

  • Introduced scope: The pinned merge-base-to-head patch changes only the two test fixtures. Host-verified test-merge evidence also limits the result to those files; unrelated endpoint drift is not attributed to this PR. (src/skills/lifecycle/clawhub.test.ts:330, 64bcdb99e4f3)
  • Filesystem pollution mechanism: The installation owner writes skill origin metadata to install.targetDir and tracking metadata to the supplied workspace. The test mocks installation but leaves these writes real; returning the requested destination confines them to the owned workspace. (src/skills/lifecycle/clawhub-install-core.ts:650, 64bcdb99e4f3)
  • Hash failure mechanism: Sandbox browser creation includes discovered read-only skill mounts in its hash, while the test helper expects an empty mount list. The changed epoch test passes its fresh directory to both the expected-hash helper and browser creation, preserving the assertion. (src/agents/sandbox/browser.create.test.ts:588, 64bcdb99e4f3)
  • Cleanup contracts: The ClawHub helper allocates unique child directories under owned temporary roots and removes their contents during awaited afterEach cleanup. The browser helper allocates synchronously and registers recursive cleanup, so its make call correctly needs no await. (src/test-utils/tracked-temp-dirs.ts:39, 64bcdb99e4f3)
  • Still necessary on reviewed main and release: Reviewed main still returns /tmp/workspace/skills/agentreceipt from the installation mock. Inspection of v2026.9.2 finds the same shared destination at line 448; neither inspected revision contains this isolation repair. (src/skills/lifecycle/clawhub.test.ts:448, bed5042933bb)
  • Validation and related discussion: The captured PR body reports 117 ClawHub and 27 browser tests passing, but explicitly leaves the original-order remote before/after replay pending. Supplied checks include successful changed-test and test-type lanes. fix(ui): restore configured agent avatars in chat #139873 identifies this fixture interference as a separate CI failure, not part of its avatar repair. No tests were executed during this read-only review. (64bcdb99e4f3)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the pending before/after replay with ClawHub writes preceding sandbox hash evaluation.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

ClawHub mocked installs returned a shared /tmp/workspace destination while real provenance writes populated its skills directory. Concurrent sandbox browser tests then discovered an unexpected skill mount and computed a different container hash. Allocate tracked workspace roots per test and return the actual install destination; keep the browser epoch proof on an owned workspace.
@steipete
steipete force-pushed the fix/test-workspace-isolation branch from 64bcdb9 to e0feeaf Compare September 6, 2026 07:49
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #139894, merged as 9532052. That repair puts the ClawHub producer and all sandbox browser fixtures in tracked per-test workspaces, covering the same filesystem isolation invariant.

Verified the merge is an ancestor of captured main 83d1f53c51a262cf8cec0fce14548514daee4d35, with both repaired files unchanged. On that main checkout, node scripts/run-vitest.mjs src/skills/lifecycle/clawhub.test.ts src/agents/sandbox/browser.create.test.ts passed all 117 ClawHub and 27 browser tests; the checkout remains clean. The canonical PR's exact-head CI run 34019118162 also passed.

The earlier Blacksmith replay retained in this PR independently reproduced the original writer-before-reader failure and proved the equivalent isolation repair on the original candidate. Both task-owned leases are stopped; the redundant second acquisition was cancelled before tests ran.

Closing this duplicate without merging or further rebasing. The canonical implementation and credit remain in #139894.

@steipete steipete closed this Sep 6, 2026
@RomneyDa
RomneyDa deleted the fix/test-workspace-isolation branch October 22, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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