Skip to content

fix: allow plugin state writes after database inode reuse - #154176

Merged
steipete merged 1 commit into
mainfrom
codex/maintenance-admission-publish-20260920
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/maintenance-admission-publish-20260920

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A first plugin-state write can fail when the filesystem reuses an inode from a closed and deleted state database. Task maintenance can then report that its database admission changed.

User Impact

New database operations retain valid admission without reviving retired callers or bypassing live aliases and file-exclusion seals. Schema, retention, configuration, and update behavior are unchanged.

Why This Change Was Made

The shared database lifecycle now checks whether a cold physical-identity match still belongs to a recorded alias before binding a new database. Obsolete records are revoked and removed; non-file aliases do not hide another live alias, and other lookup errors remain failures. Warm captures keep their existing path.

The original shard also exposed a Gateway test-fixture defect: native auth storage and its lazy command runtime could initialize inside the two-second hello deadline. The fixture now completes one real auth read before the measured body and discards that result. The challenged client still reads fresh auth. The real WebSocket exchange, two-second hello budget, one-second stop budget, fifteen-second polling deadline, and every cleanup assertion remain unchanged.

Evidence

The real plugin-worker regression fails before the inode fix. Controlled inode reuse reproduces the same admission boundary in three existing maintenance cases, and this exact repair makes them pass without changing assertions or guards. Historical CI did not record allocator identities, so those syscall outcomes are not claimed as directly observed.

The accepted composition passed twenty standalone task-registry runs (3,040 cases), twenty standalone Gateway fixture runs (140 cases), and three complete original-order shard runs (1,211 tests across 48 files each). All three file orders were verified against the original CI order; the final two disabled only Vitest's prior-results ordering cache. Owner sibling tests, scoped checks, and independent P0–P2 reviews passed. Those stability receipts remain attributed to their tested composition. After carrying unchanged source onto current main, 178 targeted lifecycle, admission, registry, Gateway, and newly worker-backed task/flow binding cases passed, with fresh scoped checks and review.

Current single-worker cost measurements on macOS/Node 24.21.0:

  • pnpm test src/state/openclaw-state-db-read-admission.test.ts --maxWorkers=1: six cases, 18.243s wall, 3.326s summed case durations.
  • pnpm test test/helpers/gateway-status-acquisition.test.ts --maxWorkers=1: seven cases, 17.111s wall, 8.296s summed case durations. This fixture proves real client acquisition, WebSocket exchange, authentication readiness, and joined cleanup; replacing that path with a storage or transport mock would miss the observed failure. No timer, sleep, polling loop, serial configuration, or worker pin was added.

Hosted CI results and reported case timings are recorded below. The earlier Linux diagnostic stopped during Testbox synchronization before tests; its lease was stopped. Failed actor-only preparation and the duration-reordered supplementary shard are retained as diagnostics and are not counted as qualification.

Hosted CI run 35546044977 passed on its first attempt for head fcbdd29e976eb0b95df57741a9e7f04f5c1651d7, testing merge c2341abdf24dd4d71be7f4466a87afd67669db82 against base 84a5cf931ae68b8be6dd3668b0f730e072100a91 (148 successful jobs, 15 skipped). On Linux/Node 24.19.0, admission's six cases summed to 1.455s in small-11, and Gateway's seven cases summed to 3.825s in small-14. These are reported test-case duration sums, not isolated file wall times. All 152 registry cases passed, including the three original maintenance entrypoints.

The 20 registry standalone runs remain bound to tree 7e00771d8c7232a1bd2e7a5f0f1fe5e2978d4c56; the 20 Gateway standalone and three original-order shard runs remain bound to combined tree 117f554b615b4c5eba43ddcd9a34fef066901749. The 178-case current-main validation remains bound to tree 266bae807258f96f2024c6defbb348cbd32482c5. Current hosted coverage does not establish that the historical failures recorded the inode-reuse allocator event.

Reconcile cold database identity binding against surviving aliases so a new
worker-created database keeps its captured admission. Revoke obsolete records
without reviving retired callers or bypassing active file-exclusion seals.

Prepare the Gateway status fixture through one real auth read before its
measured connection and cleanup lifetimes. The client still reads fresh auth;
all hello, stop, polling, and cleanup assertions retain their existing bounds.

Schema, retention, configuration, and update behavior remain unchanged.
@clawsweeper

clawsweeper Bot commented Sep 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.

@steipete
steipete marked this pull request as ready for review September 20, 2026 23:55
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 20, 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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 8:03 PM ET / September 21, 2026, 00:03 UTC.

ClawSweeper review

What this changes

The PR repairs plugin-state writes when a deleted database’s inode is reused, extends admission regression coverage, and prepares real authentication storage before Gateway fixture timing begins.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on fetched main, and no blocking defect was found in the introduced patch. It preserves live aliases, exclusion seals, and rejection of retired admissions.

Priority: P2
Reviewed head: fcbdd29e976eb0b95df57741a9e7f04f5c1651d7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this internal repair from the external-contributor proof gate. The body reports real plugin-worker registration and lookup under controlled inode reuse plus Gateway fixture runs; these results were not independently rerun, and no unresolved authority bypass was identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this internal repair from the external-contributor proof gate. The body reports real plugin-worker registration and lookup under controlled inode reuse plus Gateway fixture runs; these results were not independently rerun, and no unresolved authority bypass was identified.
Evidence reviewed 8 items Pinned introduction and merge scope: Reviewed the merge-base-to-head delta. The verified test merge records the pinned base followed by the exact PR head, and its result changes the same three files; unrelated endpoint drift was excluded.
Current main still retains the collision: Fetched main directly selects records by physical identity in resolve and publish. A retained closed-writer record can therefore collide with a newly created database and invalidate its captured first-creation admission.
Bounded lifecycle repair: The new lookup retains known canonical paths, sealed records, and records with a surviving physical alias. Otherwise it invalidates and forgets the obsolete record before binding the new creation. Non-file aliases are skipped through the existing identity inspector; other lookup failures still propagate.
Findings None None.
Security None None.

How this fits together

The shared SQLite lifecycle connects plugin-state operations to their database identity and controls whether captured operations remain valid. Its admission checks feed worker startup, writes, and database cleanup.

flowchart TD
  A[Plugin state operation] --> B[Capture database admission]
  B --> C[Resolve physical identity]
  C --> D{Recorded alias still live or sealed?}
  D -->|Yes| E[Retain existing lifecycle record]
  D -->|No| F[Revoke obsolete record and bind creation]
  E --> G[Check current admission before worker operation]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +23, Tests +41. Total +64 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 25 2 +23
Tests 2 46 5 +41
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 71 7 +64

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +23 net lines; tests +41 net lines Production growth is justified by cold identity reconciliation at the existing lifecycle owner, with focused coverage for reused inodes and surviving aliases.

Technical review

Best possible solution:

Keep identity reconciliation in the existing lifecycle owner, preserving valid first-creation admissions while permanently revoking obsolete records.

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

Yes, from source: close and delete a recorded writer database, then create plugin state whose physical identity reuses that inode. The focused worker regression controls that allocator outcome; this review did not execute it.

Is this the best way to solve the issue?

Yes. Repairing cold identity reconciliation at the shared lifecycle owner addresses the collision without changing plugin APIs, persisted formats, configuration, or warm admission behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs a bounded plugin-state write failure triggered by database inode reuse.
  • 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 supplied MEMBER association exempts this internal repair from the external-contributor proof gate. The body reports real plugin-worker registration and lookup under controlled inode reuse plus Gateway fixture runs; these results were not independently rerun, and no unresolved authority bypass was identified.

Evidence

What I checked:

  • Pinned introduction and merge scope: Reviewed the merge-base-to-head delta. The verified test merge records the pinned base followed by the exact PR head, and its result changes the same three files; unrelated endpoint drift was excluded. (fcbdd29e976e)
  • Current main still retains the collision: Fetched main directly selects records by physical identity in resolve and publish. A retained closed-writer record can therefore collide with a newly created database and invalidate its captured first-creation admission. (src/state/openclaw-state-db-async-lifecycle.ts:401, 729c6b1cc3d0)
  • Bounded lifecycle repair: The new lookup retains known canonical paths, sealed records, and records with a surviving physical alias. Otherwise it invalidates and forgets the obsolete record before binding the new creation. Non-file aliases are skipped through the existing identity inspector; other lookup failures still propagate. (src/state/openclaw-state-db-async-lifecycle.ts:324, fcbdd29e976e)
  • Current authority remains checked: Worker publication checks admission both before and after binding. Worker operations recheck captured admission after awaited preparation and before dispatch, while the changed lookup explicitly preserves active seals. No reachable newly authorized stale caller was found. (src/state/openclaw-state-db-cache.ts:559, fcbdd29e976e)
  • Regression coverage matches the failure: The added closed-writer case uses real plugin-worker registration and lookup with controlled identity reuse, then verifies the retired admission rejects. Additional coverage preserves a surviving hard-link alias when an earlier path becomes a directory; existing replacement-exclusion coverage remains intact. (src/state/openclaw-state-db-read-admission.test.ts:42, fcbdd29e976e)
  • Gateway fixture preserves its measured contract: The fixture performs one real device-auth read before entering the measured body and discards the result. The challenged client still obtains fresh authentication; connection, polling, stop, and cleanup assertions are unchanged. (test/helpers/gateway-status-acquisition.test.ts:142, fcbdd29e976e)

Likely related people:

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

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.

@steipete
steipete merged commit 746f306 into main Sep 21, 2026
290 checks passed
@steipete
steipete deleted the codex/maintenance-admission-publish-20260920 branch September 21, 2026 00:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…aw#154176)

Reconcile cold database identity binding against surviving aliases so a new
worker-created database keeps its captured admission. Revoke obsolete records
without reviving retired callers or bypassing active file-exclusion seals.

Prepare the Gateway status fixture through one real auth read before its
measured connection and cleanup lifetimes. The client still reads fresh auth;
all hello, stop, polling, and cleanup assertions retain their existing bounds.

Schema, retention, configuration, and update behavior remain unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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