Skip to content

fix(gateway): never reclaim locks from unverifiable owners - #178076

Merged
steipete merged 4 commits into
mainfrom
fix/gateway-unverifiable-owner
Oct 20, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/gateway-unverifiable-owner

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A paused Gateway or an owner in an unreadable/foreign PID namespace could lose its state lock after its heartbeat aged past 90 seconds. A missing process observation is not proof that its owner stopped.

Refs #174895.

User Impact

Unverifiable owners retain their locks regardless of heartbeat age. After confirming that a crashed foreign owner has stopped, operators run openclaw gateway recover-lock, then the exact --confirm <fingerprint> command it prints. Crashed foreign owners now require this explicit recovery; waiting alone no longer authorizes takeover. Records lacking usable namespace identity are also preserved.

Same-namespace exited processes, changed process-start identities, and verified comparable host boot changes still recover automatically. Windows boot disagreement continues to use process identity. No schema migration or release is included.

Why This Change Was Made

File-lock admission and SQLite Gateway leases now share the conservative namespace policy; lease expiry and command-line differences cannot independently prove death. Heartbeats remain useful for diagnostics and waiting. Existing inode/record checks allow a paused owner to resume while its physical lock remains intact. Startup-migration, managed-worktree capacity/pending-slot, and process-bound SQLite lease producers now record namespace identity too, preserving verified local crash recovery for every caller of the shared policy.

Explicit recovery fingerprints startup's exact owner/state/current-config records, including file identity, contents and heartbeat, plus the SQLite lease. It uses fs-safe's remove-if-unchanged protocol, retains exclusive state custody while comparing/deleting the matching lease, and refuses a verified live local holder. It preserves profile selection in its printed command. Documentation covers CLI and Docker recovery.

Evidence

  • 157 focused tests passed: namespace admission, SQLite Gateway leases, explicit recovery, file/state ownership, heartbeat lifecycle, and CLI startup policy. Combined wrapper time: 146.09 s. The timer-free final recovery rerun passed 8/8 (87.37 s including cold compilation).
  • Follow-up consumer proof: 269 cases across 21 affected infra, daemon, CLI, Doctor, state-lease, and worktree suites are covered by the consolidated run plus the repaired two-file rerun (36/36 passed). The consolidated run found two macOS service-platform fixture issues; both were fixed by preserving actual host process observations while simulating service selection. Startup-migration, capacity/pending-slot, and process-bound lease crash recovery passed.
  • CI fixture corrections: configuration preflight supplies namespace identity for its temporary local schema owner (red before correction; full file 20/20 afterward). A complete audit of 90 direct test calls also corrected 32 live-owner payloads across 29 files. The two failing local-workspace authority cases passed after correction; 55 additional cross-worker/consumer cases passed, and the update service-unavailable suite passed 14/14 with real host identity preserved during simulated service-platform selection. Its non-OpenClaw command case now preserves unknown ownership; verified disjoint OpenClaw installations remain supported.
  • Negative control: restoring only the base classifier made all four selected expired/unreadable namespace regressions fail because the old code acquired the protected locks (87.16 s). The fixed source was restored immediately.
  • pnpm install --frozen-lockfile, full pnpm build (10m 41s), core typecheck, six relevant test-type graphs (agents, infra, state, CLI, commands, services), targeted lint, formatting, and git diff --check passed. The default pinned runtime and dependency lockfile are unchanged.
  • The changed-test type planner's existing shard-root budget failure reproduces identically on clean main a8bc87f1c5b134f1fe978bf0db8cb169695d326b: gateway-root 726 > 720 and plugins-platform 727 > 720. The guard/budget was not changed; relevant canonical type graphs passed separately.
  • Independent Codex review is clean at P0–P2 after removing unnecessary historical-directory scanning. A hosted review also identified missing namespace evidence in worktree capacity reservations; the producer audit now covers startup migrations, capacity reservations, pending worktree slots, and process-bound SQLite leases.
  • Live Docker proof passed on runtime commit (abe58c1e010c19c77f8a9b0cb24db4b054d9047e), using two containers with separate PID namespaces, one shared state volume, and synthetic configuration. Both containers and the volume were removed afterward. The post-live follow-up changes only test fixtures and one stale source comment; runtime logic is unchanged, so this live proof is retained.

Live transcript summary

The image reported OpenClaw 2026.10.5 (abe58c1). Gateway readiness was checked through /healthz (200, {"ok":true,"status":"live"}). Commands used node /app/openclaw.mjs as the installed CLI entry point.

Scenario Commands / observation Result
A: live foreign holder Run Gateway in A; run the same Gateway command in B against /state. B exited 1, identified holder PID, host and PID namespace, heartbeat age, and printed openclaw gateway recover-lock. A retained its lock.
B: stalled holder docker pause A; wait 150 seconds; start B; docker unpause A. B still exited 1 with a 155-second-old heartbeat. A returned healthy with the same lock inode and owner ID.
C: crashed foreign holder docker kill A; start B; inspect with gateway recover-lock --json; execute the returned gateway recover-lock --confirm <fingerprint> --json; start B. B initially refused the unknown holder. Explicit recovery returned {"recovered":true,"removed":3}; B then became healthy with a new owner.
D: verified local death SIGKILL B's Gateway PID inside the surviving B container; start Gateway again in that same PID namespace. Restart became healthy automatically with a new owner, without any recovery command.

All four scenarios passed. The unchanged-record regression also verifies that a refreshed or replaced record rejects an earlier confirmation fingerprint.

Keep foreign, missing and unreadable namespace owners unknown regardless of heartbeat age. Only comparable process death or verified boot change permits automatic recovery, including the SQLite Gateway owner lease. Add explicit fingerprint-confirmed gateway recover-lock for crashed owners that cannot be verified locally, preserving fs-safe remove-if-unchanged and exclusive state custody.

Refs #174895
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes docker Docker and sandbox tooling size: L labels Oct 20, 2026
@steipete
steipete marked this pull request as ready for review October 20, 2026 05:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T06:17:16.592201Z 922066f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bb4c2c7fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/state-lease-process-owner.ts Resolved
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR preserves unverifiable Gateway owners indefinitely and adds fingerprint-confirmed recovery for stopped holders.

Example: Container A pauses while holding shared Gateway state, leaving a 156-second-old heartbeat.

  • Before: Container B can reclaim A's ownership after the 90-second heartbeat threshold.
  • After: B refuses takeover, and A can resume with its original lock; a crashed foreign holder requires explicit recovery.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful direction with shipped-entry-point evidence, but the shared-consumer regression and attributable CI failures block merge.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 5 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A paused Gateway can lose exclusive state ownership because another process mistakes an old heartbeat for proof of death.
Reason: The maintainer-authored direction protects a concrete ownership invariant and explicitly accepts manual recovery for crashed foreign holders.

Merge readiness

⛔ Blocked before merge - 7 items remain

Keep this PR open: protecting paused Gateway owners is valuable and maintainer-approved, but the shared classifier change breaks non-Gateway lease recovery and leaves concrete CI failures to repair.

Priority: P1
Reviewed head: 1bb4c2c7fa3f88496b55914365916f187c16022a

Before merge

  • Migrate shared lease producers before requiring namespace identity (P1) - Returning unknown for every missing namespace also affects readStateLeaseProcessOwnerStatus. createWorktreeDiskAdmission and reservePendingWorktree still publish only pid, host, and startedAt; their non-expiring rows are reclaimed only when this reader returns dead. After a crash, capacity debt and pending slots therefore remain indefinitely, potentially blocking later worktree creation. Startup-migration leases also lose immediate dead/reused-PID recovery and wait for expiry. This confirms and extends the existing review at fix(gateway): never reclaim locks from unverifiable owners #178076 (comment). Complete the producer and existing-record recovery changes, or scope the stricter policy to Gateway ownership.
  • Update consumer fixtures to exercise their intended ownership boundary (P2) - The stricter classifier changes existing Doctor, update, and restart fixtures that seed namespace-less owners. Exact-head CI now stops at GatewayLockNamespaceError instead of reaching their service-stop, schema-conflict, and finalization assertions; update-command-service-maintenance-native.test.ts:181 also receives unknown instead of live. Update valid-owner fixtures with coherent namespace observations and preserve the existing assertions, while keeping explicit legacy-owner cases separate.
  • Make the rewrite regression tolerate filesystem timestamp resolution (P2) - The test assumes two immediate writes and utimesSync must change ctimeNs. CI job https://github.com/openclaw/openclaw/actions/runs/39373075898/job/118465493152 records identical values, so the new test fails before exercising recovery. Establish a distinct filesystem timestamp deterministically before asserting fingerprint invalidation, without weakening the changed-record rejection.
  • Classify the recovery SQL under its actual CLI execution owner (P2) - The new executeSqliteQuerySync call is in an unclassified src/infra module, so scripts/database-worker-inventory.mjs counts it as T1 runtime SQL and the required database-worker ratchet fails. Its verified production caller is the recover-lock CLI one-shot. Record that caller evidence in the existing CLI classification map rather than adding a worker or relaxing the ratchet.
  • Use the existing errno guard in recovery inspection (P2) - This new production type assertion has no per-file allowance or safety invariant, causing assertion-safety growth in the failing baseline job. Replace it with the existing hasErrnoCode or extractErrorCode helper so missing-file handling uses the established error contract without increasing the baseline.
  • Complete next step - Classify the remaining diagnostic-process-siblings CI failure against the base; its cause was not established from the available annotations.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Migrate shared lease producers before requiring namespace identity — src/infra/gateway-lock-payload.ts:106-108
  • [P2] Update consumer fixtures to exercise their intended ownership boundary — src/infra/gateway-lock-payload.ts:106-115
  • [P2] Make the rewrite regression tolerate filesystem timestamp resolution — src/infra/gateway-lock-recovery.test.ts:89-93

Tests

  • Missing end-to-end proof: Show an upgrade from v2026.10.5 with existing settings, state, and lease records preserved, including recovery after a foreign-owner crash.
Agent review details

How this fits together

Gateway startup, Doctor, and shared lease consumers classify recorded process ownership before admitting state access; the recovery CLI replaces confirmed sidecars and removes the matching SQLite Gateway lease under exclusive custody.

flowchart TD
  A[Gateway startup or Doctor] --> B[Namespace and process classifier]
  B --> C[File lock admission]
  B --> D[SQLite lease admission]
  E[Recovery CLI confirmation] --> C
  C --> F[Exclusive state custody]
  F --> D
  D --> G[Gateway state access]
Loading

Technical review

Best possible solution:

Keep the existing Gateway classifier and lock owners, complete the shared-lease producer and existing-record cutover, and repair the affected tests and static checks.

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

Current-main source permits expired foreign heartbeats to authorize reclamation, and the supplied exact-head Docker transcript demonstrates the repaired paused-owner scenario; no target code was executed during this review.

Is this the best way to solve the issue?

The conservative Gateway policy and explicit recovery are coherent, but changing a classifier shared with namespace-less lease producers requires a complete consumer cutover.

Full review comments:

  • [P1] Migrate shared lease producers before requiring namespace identity — src/infra/gateway-lock-payload.ts:106-108
    Returning unknown for every missing namespace also affects readStateLeaseProcessOwnerStatus. createWorktreeDiskAdmission and reservePendingWorktree still publish only pid, host, and startedAt; their non-expiring rows are reclaimed only when this reader returns dead. After a crash, capacity debt and pending slots therefore remain indefinitely, potentially blocking later worktree creation. Startup-migration leases also lose immediate dead/reused-PID recovery and wait for expiry. This confirms and extends the existing review at fix(gateway): never reclaim locks from unverifiable owners #178076 (comment). Complete the producer and existing-record recovery changes, or scope the stricter policy to Gateway ownership.
    Confidence: 0.99
  • [P2] Update consumer fixtures to exercise their intended ownership boundary — src/infra/gateway-lock-payload.ts:106-115
    The stricter classifier changes existing Doctor, update, and restart fixtures that seed namespace-less owners. Exact-head CI now stops at GatewayLockNamespaceError instead of reaching their service-stop, schema-conflict, and finalization assertions; update-command-service-maintenance-native.test.ts:181 also receives unknown instead of live. Update valid-owner fixtures with coherent namespace observations and preserve the existing assertions, while keeping explicit legacy-owner cases separate.
    Confidence: 0.99
  • [P2] Make the rewrite regression tolerate filesystem timestamp resolution — src/infra/gateway-lock-recovery.test.ts:89-93
    The test assumes two immediate writes and utimesSync must change ctimeNs. CI job https://github.com/openclaw/openclaw/actions/runs/39373075898/job/118465493152 records identical values, so the new test fails before exercising recovery. Establish a distinct filesystem timestamp deterministically before asserting fingerprint invalidation, without weakening the changed-record rejection.
    Confidence: 1
  • [P2] Classify the recovery SQL under its actual CLI execution owner — src/infra/gateway-lock-recovery-lease.ts:89-92
    The new executeSqliteQuerySync call is in an unclassified src/infra module, so scripts/database-worker-inventory.mjs counts it as T1 runtime SQL and the required database-worker ratchet fails. Its verified production caller is the recover-lock CLI one-shot. Record that caller evidence in the existing CLI classification map rather than adding a worker or relaxing the ratchet.
    Confidence: 0.98
  • [P2] Use the existing errno guard in recovery inspection — src/infra/gateway-lock-recovery.ts:28
    This new production type assertion has no per-file allowance or safety invariant, causing assertion-safety growth in the failing baseline job. Replace it with the existing hasErrnoCode or extractErrorCode helper so missing-file handling uses the established error contract without increasing the baseline.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/infra/gateway-lock-recovery.test.ts src/infra/gateway-lock.namespace.test.ts src/infra/gateway-owner-lease.test.ts src/infra/startup-migration-checkpoint.test.ts --maxWorkers=1
  • pnpm test src/cli/update-cli/update-command-service-maintenance-native.test.ts src/commands/doctor-maintenance.serving-owner.test.ts src/commands/doctor-sqlite-maintenance-lock.test.ts src/cli/daemon-cli/lifecycle.restart-intent.test.ts src/cli/daemon-cli/lifecycle.restart-intent-legacy.test.ts --maxWorkers=1
  • node scripts/check-database-worker-ratchet.mts --base b8daeb2
  • node scripts/check-assertion-safety-ratchet.mts --base b8daeb2
  • git diff --check

What I checked:

  • Current main still uses heartbeat reclamation: Fetched main retains the foreign-owner heartbeat fallback; this PR changes that policy rather than duplicating an implementation already on main. (src/infra/gateway-lock-payload.ts:140, 578578cdeca9)
  • Accepted operator recovery tradeoff: The maintainer-authored PR explicitly replaces automatic foreign-owner crash recovery with the recover-lock command because a paused owner can resume; this direction needs no additional product approval. (1bb4c2c7fa3f)
  • Shared lease producers remain incompatible: Worktree capacity, pending-slot, and startup-migration producers omit processNamespace, while their recovery consumers use readStateLeaseProcessOwnerStatus; requiring namespace identity now prevents their dead-owner classification. (src/agents/worktrees/capacity.ts:86, 1bb4c2c7fa3f)
  • Changed consumer fixtures fail in CI: Exact-head CI reports live-to-unknown lease classification in update-command-service-maintenance-native.test.ts and namespace refusals before existing Doctor/update assertions. (src/cli/update-cli/update-command-service-maintenance-native.test.ts:181, 1bb4c2c7fa3f)
  • New recovery regression fails on timestamp resolution: CI records identical ctimeNs values before and after the immediate rewrite at the new test's line 93. (src/infra/gateway-lock-recovery.test.ts:93, 1bb4c2c7fa3f)
  • Introduced static-check failures: The new recovery SQL module lacks CLI-only inventory classification, and its companion adds an unannotated assertion with no per-file allowance; the baseline job reports database-worker and assertion-safety failures. Detailed job-log retrieval was blocked by the artifact host allowlist. (src/infra/gateway-lock-recovery-lease.ts:90, 1bb4c2c7fa3f)

PR surface

Source +301, Tests +209, Docs +69. Total +579 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 11 418 117 +301
Tests 6 335 126 +209
Docs 3 82 13 +69
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 835 256 +579

Review metrics

Metric Value Why it matters
Production versus test changes Production +418/-117; tests +335/-126 The recovery command accounts for most production growth and reuses existing custody primitives; the shared-consumer cutover remains incomplete.
New recovery control One new mutation flag: --confirm <fingerprint> The maintainer explicitly selected confirmation-based recovery to replace heartbeat-authorized foreign takeover.

Labels

Label changes:

  • add P1: The change addresses live Gateway ownership loss, while its shared-classifier regression can permanently block managed-worktree allocations after a crash.
  • add merge-risk: 🚨 compatibility: Existing namespace-less lease producers lose dead-owner recovery; the intentional foreign-Gateway recovery change is accepted, but this additional impact is not.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: The change addresses live Gateway ownership loss, while its shared-classifier regression can permanently block managed-worktree allocations after a crash.
  • merge-risk: 🚨 compatibility: Existing namespace-less lease producers lose dead-owner recovery; the intentional foreign-Gateway recovery change is accepted, but this additional impact is not.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 1:30 AM ET / 05:30 UTC.

Record process namespaces for startup migrations, worktree reservations and process-bound leases. Update consumer fixtures for conservative ownership, and use the canonical lease release helper for explicit recovery.
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: XL and removed size: L labels Oct 20, 2026
@steipete
steipete enabled auto-merge (squash) October 20, 2026 05:53
@steipete
steipete disabled auto-merge October 20, 2026 06:01
Align live Gateway fixtures and update admission expectations with conservative owner classification. Keep host PID and namespace observations real while simulating service platforms. Correct the stale command-inspection comment.

Refs #174895

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 922066f4d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +21 to +23
if (isStatePostgres()) {
throw new Error("Gateway lock recovery requires a local SQLite state database.");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Provide a recovery path for PostgreSQL-backed state

When a Gateway using PostgreSQL crashes in a foreign PID namespace, the new conservative owner classification preserves its PostgreSQL gateway-owner lease indefinitely, but the only recovery command always rejects that configuration here. The operator therefore cannot clear the lease through the documented workflow, and every subsequent Gateway startup remains blocked unless they manually edit PostgreSQL. Recovery needs to inspect and conditionally remove the matching lease through the configured state engine, or provide an equally safe supported PostgreSQL procedure.

Useful? React with 👍 / 👎.

Comment on lines +196 to +199
commandPath: ["gateway", "recover-lock"],
exact: true,
// Recovery must reach the lock before config preflight can request state ownership.
policy: { configGuard: "skip", loadPlugins: "never", networkProxy: "bypass" },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bypass early config validation for lock recovery

For gateway recover-lock with a malformed or unreadable config, this policy does not actually let the action reach the lock: run-main.ts calls prepareCliDatabaseEngine before Commander pre-actions, and because gateway recover-lock is absent from OWNED_DATABASE_SELECTION, that function reads and rejects the config first. This leaves the advertised recovery command unusable precisely when config damage accompanies a stale lock; route this command around the early engine-selection preflight or otherwise make that selection recovery-safe.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit edea119 into main Oct 20, 2026
171 of 173 checks passed
@steipete
steipete deleted the fix/gateway-unverifiable-owner branch October 20, 2026 06:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…178076)

* fix(gateway): never reclaim locks from unverifiable owners

Keep foreign, missing and unreadable namespace owners unknown regardless of heartbeat age. Only comparable process death or verified boot change permits automatic recovery, including the SQLite Gateway owner lease. Add explicit fingerprint-confirmed gateway recover-lock for crashed owners that cannot be verified locally, preserving fs-safe remove-if-unchanged and exclusive state custody.

Refs openclaw#174895

* fix(gateway): preserve verified lease recovery across consumers

Record process namespaces for startup migrations, worktree reservations and process-bound leases. Update consumer fixtures for conservative ownership, and use the canonical lease release helper for explicit recovery.

* test(gateway): record namespace in temporary schema fixture

* test(gateway): qualify live owner fixtures with namespace identity

Align live Gateway fixtures and update admission expectations with conservative owner classification. Keep host PID and namespace observations real while simulating service platforms. Correct the stale command-inspection comment.

Refs openclaw#174895
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…78229)

Record the Windows host namespace without the unused PowerShell boot observation, so CLI and portable-worker state admission can verify their own owners. Keep native process-start checks and conservative foreign-owner refusal. Accept validated timestamps from existing lock records.

Regression exposed by openclaw#178076. Verified 156 ownership tests and 23 portable-worker build tests, targeted types, lint, format, and P2 review. Native Windows execution remains pending.
steipete added a commit that referenced this pull request Nov 5, 2026
* fix(state): reduce lease heartbeat write contention

Renew long-lived state leases at TTL/3 without the obsolete 30-second cap. Keep Gateway SQL renewal aligned with ordinary leases while preserving FULL durability, conditional expiry checks, and closure-bound authority.

The SQL heartbeat age is diagnostic after #178076; the separate filesystem owner heartbeat remains unchanged. Native delayed-fsync evidence shows fewer commits and lower cumulative foreground writer wait, with one-commit stalls still possible.

* test(state): use explicit worker transfer lists in lease benchmark
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
* fix(state): reduce lease heartbeat write contention

Renew long-lived state leases at TTL/3 without the obsolete 30-second cap. Keep Gateway SQL renewal aligned with ordinary leases while preserving FULL durability, conditional expiry checks, and closure-bound authority.

The SQL heartbeat age is diagnostic after openclaw#178076; the separate filesystem owner heartbeat remains unchanged. Native delayed-fsync evidence shows fewer commits and lower cumulative foreground writer wait, with one-commit stalls still possible.

* test(state): use explicit worker transfer lists in lease benchmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant