Skip to content

fix(gateway): derive lock and coordinator paths from the resolved state dir - #120110

Merged
steipete merged 1 commit into
mainfrom
codex/fix-118371-statedir-locks-v2
Aug 7, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-118371-statedir-locks-v2

Conversation

@steipete

@steipete steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway lock and coordination files were written under the process temp dir (os.tmpdir()/openclaw-<uid>) even when OPENCLAW_STATE_DIR pointed elsewhere, so a fully sandboxed second instance littered — and in principle contended with — the live instance's tmp tree. On macOS the service env pins TMPDIR into the default state tree, which is exactly where the reported leak landed.

Fixes #118371 (reported by @peterkaynie).

Why This Change Was Made

resolveGatewayLockDir() owned the location but never received the resolved state dir. It now derives $OPENCLAW_STATE_DIR/tmp/openclaw-<uid> from the canonical state dir, so gateway state/config locks, device-identity coordinator DBs, and transient reclaim guards are all state-local — total isolation for sandboxed instances.

This is a deliberate clean break (maintainer decision): older binaries keep using process temp and do not mutually exclude a state-local binary during a mixed-version upgrade window. The tradeoff is recorded at the lock-dir owner (src/config/paths.ts) and in docs/gateway/gateway-lock.md. Old process-temp locks are neither migrated nor cleaned (transient state; OS tmp cleanup owns them). Hash simplification: the state-dir hash in lock filenames is now redundant (the directory is the state identity) and was removed; the config hash (distinguishes explicit configs sharing one state) and device database hash (arbitrary DB paths) remain.

User Impact

Sandboxed/canary instances with OPENCLAW_STATE_DIR set no longer write anything into the real ~/.openclaw; isolation is total. Net −14 production LOC.

Evidence

  • New regression suites (gateway-lock.state-dir.test.ts, device-identity.state-dir.test.ts): with OPENCLAW_STATE_DIR overridden, every lock/coordinator path resolves under the override and nothing is created under the default home.
  • Focused: 4 shards, 268 tests passed across gateway-lock, device-identity, state-migrations, backup-filter, paths, and doctor-maintenance suites (re-verified independently after review).
  • node scripts/check-deadcode-exports.mjs: clean. Local changed gate: exit 0. Docs MDX 768 files + 6,401 links: clean.
  • Codex autoreview (gpt-5.6-sol, high), worker closeout + independent coordinator pass on the frozen diff: clean both times, "patch is correct (0.95)".
  • Production +36/−50 (net −14); tests +143/−46; docs +14/−12 (docs/gateway/gateway-lock.md, docs/install/fly.md).

@steipete
steipete marked this pull request as ready for review August 7, 2026 02:16
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Aug 7, 2026
@steipete
steipete merged commit 70abd88 into main Aug 7, 2026
76 of 79 checks passed
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 7, 2026
@steipete
steipete deleted the codex/fix-118371-statedir-locks-v2 branch August 7, 2026 02:16
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 7, 2026
* origin/main: (58 commits)
  fix(test): restart shared gateway after migration convergence (openclaw#120089)
  fix(ui): make active-run steering reliable (openclaw#120083)
  fix(telegram): preserve voice fallback text
  test(swift): preserve queued websocket frames (openclaw#120106)
  fix: reject missing oxlint shard selectors (openclaw#120096)
  test(channels): align prerelease fallback catalog spec (openclaw#120092)
  fix(node-cli): warn when systemd user lingering is disabled after install (openclaw#118430)
  fix(diagnostics): preserve CLI turn usage totals (openclaw#120100)
  fix(gateway): derive lock and coordinator paths from the resolved state dir (openclaw#120110)
  fix(release): isolate private Telegram QA harness (openclaw#120088)
  test(agents): exercise execution attribution ingress guard
  fix(gateway): defer attribution until admission succeeds
  refactor(agents): centralize exact execution attribution
  fix(google): accept base64url provider media (openclaw#116204)
  fix(plugins): warn when registerHook uses a typed hook event name (openclaw#118601)
  fix(canvas): serve Content-Length on A2UI HEAD responses (openclaw#117961)
  fix(gateway): make doctor dreaming timestamp comparators NaN-safe (openclaw#118749)
  fix(heartbeat): explain target-none skips (openclaw#119689)
  fix(security): stop recommending retired install-policy bypasses (openclaw#120011)
  fix(plugins): preserve startup release during repair (openclaw#120085)
  ...

# Conflicts:
#	CHANGELOG.md
#	src/config/sessions/session-accessor.sqlite-transcript-write.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway lock/tmp files ignore OPENCLAW_STATE_DIR override (sandbox isolation leak)

1 participant