Skip to content

fix(tests): pin plugin temp-dir assertions to resolvePreferredOpenClawTmpDir() (#101876)#101884

Closed
SymbolStar wants to merge 1 commit into
openclaw:mainfrom
SymbolStar:fix/issue-101876-tmp-dir-tests
Closed

fix(tests): pin plugin temp-dir assertions to resolvePreferredOpenClawTmpDir() (#101876)#101884
SymbolStar wants to merge 1 commit into
openclaw:mainfrom
SymbolStar:fix/issue-101876-tmp-dir-tests

Conversation

@SymbolStar

Copy link
Copy Markdown
Contributor

Refs #101876

Scope

The issue lumps three separate test failures together, but only one of them is actually the os.tmpdir() assertion mismatch described in the title. This PR fixes that one. The other two failures have unrelated root causes (details below) and I recommend splitting them into their own issues.

What this PR fixes

src/plugins/git-install.test.ts > installPluginFromGitSpec > falls back to OS temp when target workspace creation fails hard-coded os.tmpdir() in its assertion:

expect(path.dirname(fallbackPrefix)).toBe(await fs.realpath(os.tmpdir()));

withTempDir (src/infra/install-source-utils.ts) actually defaults its root to resolvePreferredOpenClawTmpDir() (src/infra/tmp-openclaw-dir.ts), which on POSIX prefers /tmp/openclaw whenever ownership/permissions are safe and only falls back to os.tmpdir() when unsafe. The assertion therefore only holds on hosts where /tmp/openclaw resolves unsafe, i.e. it encodes the environment rather than the contract.

Fix: pin the assertion (and add the import) to the same resolver the production code uses:

import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
// ...
expect(path.dirname(fallbackPrefix)).toBe(
  await fs.realpath(resolvePreferredOpenClawTmpDir()),
);

Verification

node scripts/run-vitest.mjs src/plugins/git-install.test.ts
# Test Files  1 passed (1)
#      Tests  23 passed (23)

Repro'd the original failure on macOS with /tmp/openclaw present, applied the fix, all 23 tests pass.

What this PR does NOT fix (please split into separate issues)

Both of these fail on the same host but are not os.tmpdir() assertion errors — they surface only because vitest keeps running past the git-install failure:

1. src/plugins/manifest-model-id-normalization.test.ts > manifest model id normalization > reuses manifest metadata while file fingerprints are unchanged

AssertionError: expected [ Array(140) ] to have a length of 1 but got 140
  at src/plugins/manifest-model-id-normalization.test.ts:341
      expect(listOpenClawPluginManifestMetadata(process.env)).toHaveLength(1);

Root cause: the test seeds a per-test OPENCLAW_STATE_DIR and disables bundled plugins, but listOpenClawPluginManifestMetadata also calls listSourceCheckoutPluginDirs, which uses import.meta.url / process.argv[1] to find the OpenClaw package root and enumerates every child of its extensions/ dir (140 on a source checkout). Nothing to do with /tmp/openclaw. Fix would need to either mock resolvePackageRootsForSourceManifestMetadata (or the fs of openclaw-root) or add an env/option to opt out of source-checkout scanning during tests.

2. src/plugins/tools.optional.test.ts > resolvePluginTools optional tools > reloads when gateway binding would otherwise reuse a default-mode active registry (line 2863)

TypeError: Cannot read properties of undefined (reading 'length')
  at registryHasPluginHostCleanupWork src/plugins/runtime.ts:66:32
      registry.sessionExtensions.length > 0 ||
  at cleanupRetiredPluginHostRegistry ← setActivePluginRegistry ← setRegistry ← setOptionalDemoRegistry

Root cause: the test's mock registry is { plugins: [], tools: [], diagnostics: [] } — the retirement/cleanup path in runtime.ts reads sessionExtensions.length, runtimeLifecycles.length, etc. without null-guarding. Either the test should provide those arrays, or the production predicate should tolerate missing fields (arguably both). Also nothing to do with /tmp/openclaw.

Suggestion

Once this PR lands, please close the os.tmpdir part of #101876 and open two separate issues for the two failures above so they can be triaged independently.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 5:42 PM ET / 21:42 UTC.

Summary
The PR updates src/plugins/git-install.test.ts to assert the git staging fallback temp root against resolvePreferredOpenClawTmpDir() instead of os.tmpdir().

PR surface: Tests +3. Total +3 across 1 file.

Reproducibility: yes. source-reproducible: current main’s test asserts fs.realpath(os.tmpdir()), while withTempDir uses resolvePreferredOpenClawTmpDir() and may choose /tmp/openclaw. I did not execute Vitest in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #101876
Summary: This PR is a candidate fix for the git-install temp-root assertion portion of the linked issue; the PR body and linked issue discussion identify two other failures as separate follow-up work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] I did not rerun the focused Vitest command in this read-only review; the PR body provides after-fix terminal output and exact-head CI/Testbox should remain the merge gate.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow test-only assertion fix for the git-install temp-root case, then track the two other failures from the linked report separately.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed because the PR already makes the focused change and has no review finding.

Security
Cleared: The diff is test-only and does not change dependencies, workflows, scripts, secrets handling, or runtime security boundaries.

Review details

Best possible solution:

Land the narrow test-only assertion fix for the git-install temp-root case, then track the two other failures from the linked report separately.

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

Yes, source-reproducible: current main’s test asserts fs.realpath(os.tmpdir()), while withTempDir uses resolvePreferredOpenClawTmpDir() and may choose /tmp/openclaw. I did not execute Vitest in this read-only review.

Is this the best way to solve the issue?

Yes. Matching the assertion to the production resolver is the narrowest maintainable test-only fix; changing runtime temp-root selection or hardcoding a host-specific path would be the wrong layer.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority test reliability fix with limited blast radius and no runtime behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes copied terminal output for node scripts/run-vitest.mjs src/plugins/git-install.test.ts passing after the fix and states the original failure was reproduced on macOS with /tmp/openclaw present.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied terminal output for node scripts/run-vitest.mjs src/plugins/git-install.test.ts passing after the fix and states the original failure was reproduced on macOS with /tmp/openclaw present.
Evidence reviewed

PR surface:

Tests +3. Total +3 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 4 1 +3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 4 1 +3

What I checked:

Likely related people:

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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-07T21:34:51.619Z sha 9c2b482 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@vincentkoc vincentkoc self-assigned this Jul 9, 2026
@vincentkoc

Copy link
Copy Markdown
Member

This is already fixed on main by #101896, merged as f2c6a0eda6f1e626f6b7fc7a6beb1be6ff02b22c.

That canonical fix contains the same resolvePreferredOpenClawTmpDir() assertion in src/plugins/git-install.test.ts and also repairs the two sibling plugin temp-directory failures tracked by #101876. Closing this narrower superseded PR with thanks for identifying the correct helper.

@vincentkoc vincentkoc closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants