Skip to content

fix: prevent plugin state open failures after read-only inspection - #150236

Merged
steipete merged 1 commit into
mainfrom
upd/flake-plugin-state-admission
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/flake-plugin-state-admission

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes plugin state writes failing to open a fresh database when the filesystem reuses an inode from a deleted file that OpenClaw previously inspected read-only. Observed in the unchanged plugin-state tests on #149913 (failed hosted job).

User Impact

Fresh plugin state remains writable after completed or refused read-only inspection of an unrelated database. Storage formats, schema versions, update/rollback behavior, and operator configuration are unchanged.

Why This Change Was Made

The lifecycle owner's advisory identity lookup was creating persistent admission records without owning a cached database. A closed read-only file could be deleted while its inode remained recorded. If that inode was reused, publication of a new worker-created file collided with the stale record and invalidated its own admission.

Inspect unowned paths without recording them, and bind first creation through native aliases at actual publication. Existing captures and published owners retain their cached identity, generation checks, and close/exclusion behavior. No retry, timeout, or consumer fallback is added.

Evidence

The new regression exercises real read-only inspection, file deletion, worker opening, and plugin register/lookup. It controls only the inode allocator outcome; both successful and schema-refused read cases fail on the original production code with the same hosted stack:

PluginStateStoreError: Failed to open the plugin state database.
code: PLUGIN_STATE_OPEN_FAILED
Caused by: Error: OpenClaw state database read admission changed
  Object.assertCurrent (openclaw-state-db-async-lifecycle.ts:405)
  publishOpenClawStateDatabaseWorkerAdmission (openclaw-state-db-cache.ts:572)
code: STATE_DATABASE_READ_ADMISSION_INVALIDATED
  • Original six-file hosted neighborhood: 30/30 baseline iterations passed (4,320 test executions), using one fork worker per run and --cache=false for hosted file order.
  • Deterministic pre-fix regression: 2/2 cases failed with the stack above.
  • Complete repair: 165/165 focused tests passed, including lifecycle, native cleanup, and the original neighborhood.
  • All four new cases passed 30 executions each (--repeats=29): 120/120, covering inode reuse, native alias publication, and replacement exclusion.
  • Changed-scope formatting, production and test typechecks, lint, and repository guards passed for all three changed files. Existing line-count warnings remain confined to unchanged files.
  • Fresh pre-commit and committed-branch Codex reviews through P1: scoped-clean (--mode branch --base origin/main --max-priority P1).

Production delta: +3/-4 (net -1); tests and test support: +105/-0. Head: b9ca85fe564daa498488610be0783304e34e42e4.

Native Linux inode reuse is modeled deterministically; the repeated neighborhood runs execute on macOS with Node 26.8.2. The hosted test uses isolated fork workers, so cross-file module leakage is not needed to explain this failure.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 18:49
@clawsweeper

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

@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 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 6:48 PM ET / 22:48 UTC (Revision 4).

ClawSweeper review

What this changes

Prevents read-only database inspection from leaving stale identity records that block later plugin-state writes, with regression coverage for inode reuse, alias publication, and replacement exclusion.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still needs this focused repair. No introduced correctness or security blocker was found, and the related PRs address distinct failures.

Priority: P2
Reviewed head: 447c77d2d00b04f29873e8ddc22cee12387a97f2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no actionable defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor proof gate does not apply to this verified repository administrator. Reported boundary tests exercise real read-only inspection and plugin-state worker register/lookup with controlled inode reuse; they are supplemental evidence, not a claimed native Linux reproduction.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor proof gate does not apply to this verified repository administrator. Reported boundary tests exercise real read-only inspection and plugin-state worker register/lookup with controlled inode reuse; they are supplemental evidence, not a claimed native Linux reproduction.
Evidence reviewed 8 items Introduced repair and current-main necessity: The comparison shows that fetched main retains all three old behaviors: advisory identity lookup records ownership, prepared identities cannot bypass a mismatched cached path, and publication creates a separate record instead of reconciling pending first creation. The complete host-pinned introduced patch identifies these same three hunks.
Production lifecycle and dispatch checks: Read the complete lifecycle, cache, and shared-worker owners. Advisory identity reads serve native-open checks and exact-path cleanup; worker publication checks admission before and after binding. Worker operations retain current-admission checks after asynchronous opening and before dispatch. The patch does not alter persisted schemas, plugin APIs, authorization policy, or transaction kernels.
Regression coverage and retained safeguards: The four added cases exercise successful and schema-refused read-only inspection followed by plugin register/lookup, native-alias publication during first creation, and replacement exclusion. Only the inode allocator outcome is substituted in the first two cases. Existing lifecycle tests retain close, failed-close, alias, restart, and exclusion coverage; the new suite is registered in the forked database-worker inventory.
Findings None None.
Security None None.

How this fits together

Plugins store persistent values through OpenClaw’s shared SQLite worker. The database lifecycle owner tracks physical files and controls admission so opening, closing, and replacing a database remain coordinated.

flowchart TD
  A[Read-only inspection] --> B[Inspect file identity]
  B --> C[Return identity without retaining ownership]
  D[Plugin state operation] --> E[Capture lifecycle admission]
  E --> F[Open SQLite worker and publish identity]
  F --> G{Admission still current}
  G -->|Yes| H[Read or write plugin state]
  G -->|No| E
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1, Tests +105. Total +104 across 3 files.

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

Review metrics

None.

Technical review

Best possible solution:

Keep advisory inspection free of retained lifecycle ownership, and reconcile first creation through the existing owner while preserving close and replacement invalidation.

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

Yes, from source: read-only inspection retains an inode record on current main, and reuse can invalidate a fresh worker’s admission during publication. The PR supplies a deterministic regression; this review did not execute it.

Is this the best way to solve the issue?

Yes. Repairing identity bookkeeping at the existing lifecycle owner addresses the cause without retries, competing state, or consumer-specific workarounds.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs a concrete plugin-state opening failure under filesystem inode reuse without evidence of a widespread outage.
  • 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 ordinary external-contributor proof gate does not apply to this verified repository administrator. Reported boundary tests exercise real read-only inspection and plugin-state worker register/lookup with controlled inode reuse; they are supplemental evidence, not a claimed native Linux reproduction.

Evidence

What I checked:

  • Introduced repair and current-main necessity: The comparison shows that fetched main retains all three old behaviors: advisory identity lookup records ownership, prepared identities cannot bypass a mismatched cached path, and publication creates a separate record instead of reconciling pending first creation. The complete host-pinned introduced patch identifies these same three hunks. (src/state/openclaw-state-db-async-lifecycle.ts:285, 447c77d2d00b)
  • Production lifecycle and dispatch checks: Read the complete lifecycle, cache, and shared-worker owners. Advisory identity reads serve native-open checks and exact-path cleanup; worker publication checks admission before and after binding. Worker operations retain current-admission checks after asynchronous opening and before dispatch. The patch does not alter persisted schemas, plugin APIs, authorization policy, or transaction kernels. (src/state/openclaw-state-db-cache.ts:566, 447c77d2d00b)
  • Regression coverage and retained safeguards: The four added cases exercise successful and schema-refused read-only inspection followed by plugin register/lookup, native-alias publication during first creation, and replacement exclusion. Only the inode allocator outcome is substituted in the first two cases. Existing lifecycle tests retain close, failed-close, alias, restart, and exclusion coverage; the new suite is registered in the forked database-worker inventory. (src/state/openclaw-state-db-read-admission.test.ts:24, 447c77d2d00b)
  • Captured validation and review continuity: The supplied body reports two deterministic pre-fix failures, 165 passing focused tests, and 120 repeated executions of the new cases on macOS with Node 26.8.2. It explicitly models Linux inode reuse and identifies the earlier evidence head b9ca85f; these results are not represented as reviewer-run tests of the current head. The prior completed review retains no findings or published rank-up moves. Comparison with its earlier SHA could not complete because that object was unavailable. (b9ca85fe564d)
  • Relevant merged history: Current-main file history includes shared-worker admission, maintenance cleanup, and typed admission-error work by Peter Steinberger. GitHub commit metadata maps the latest relevant author to steipete and shows the added admission-error declaration. Local blame could not complete because an older blob was unavailable, so no feature-introduction claim is made. (src/state/openclaw-state-db-async-lifecycle.ts:13, a4c84661baad)
  • Author role and protected review status: The PR remains open at the pinned head and carries the protected maintainer label. Although supplied association fields disagree, the live repository permission endpoint independently confirms steipete has the admin role.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-16T18:55:32.759Z sha b9ca85f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T20:21:11.974Z sha b7a7259d5b2a01ee9b0eac92f28a86b3c639d959 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T21:57:28.341Z sha 6dc5e7026e8347c28a5a8d0869f69691b4309d18 :: needs maintainer review before merge. :: none

steipete added a commit that referenced this pull request Sep 16, 2026
Keep incomplete and mixed annotation indexing coverage while timing the historical backtracking witness at the parser owner. Related: #150236, #138995.
@steipete
steipete force-pushed the upd/flake-plugin-state-admission branch from b9ca85f to b7a7259 Compare September 16, 2026 20:15
@steipete
steipete force-pushed the upd/flake-plugin-state-admission branch from b7a7259 to 6dc5e70 Compare September 16, 2026 21:50
steipete added a commit that referenced this pull request Sep 16, 2026
Honor existing force requests after a closing receipt only when control,
output, lineage and kernel group-disappearance facts permit reclaiming the
retained direct relay. Confirm actual exit within the original hard deadline
and retain timing, signal-delivery errors and observed exit facts.

Keep stop() compatible and expose the optional cleanup result without
reviving a retired connection. Fresh driver executions remain available.

Related: #150236
Keep advisory database identity reads out of the lifecycle admission map. Bind first creation through aliases at publication while preserving physical replacement and exclusion checks.
@steipete
steipete force-pushed the upd/flake-plugin-state-admission branch from 6dc5e70 to 447c77d Compare September 16, 2026 22:41
@steipete
steipete merged commit cea9c9c into main Sep 16, 2026
206 checks passed
@steipete
steipete deleted the upd/flake-plugin-state-admission branch September 16, 2026 23:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 17, 2026
Honor existing force requests after a closing receipt only when control,
output, lineage and kernel group-disappearance facts permit reclaiming the
retained direct relay. Confirm actual exit within the original hard deadline
and retain timing, signal-delivery errors and observed exit facts.

Keep stop() compatible and expose the optional cleanup result without
reviving a retired connection. Fresh driver executions remain available.

Related: #150236
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…150260)

Keep incomplete and mixed annotation indexing coverage while timing the historical backtracking witness at the parser owner. Related: openclaw#150236, openclaw#138995.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…penclaw#150236)

Keep advisory database identity reads out of the lifecycle admission map. Bind first creation through aliases at publication while preserving physical replacement and exclusion checks.
steipete added a commit that referenced this pull request Sep 17, 2026
Honor existing force requests after a closing receipt only when control,
output, lineage and kernel group-disappearance facts permit reclaiming the
retained direct relay. Confirm actual exit within the original hard deadline
and retain timing, signal-delivery errors and observed exit facts.

Keep stop() compatible and expose the optional cleanup result without
reviving a retired connection. Fresh driver executions remain available.

Related: #150236
steipete added a commit that referenced this pull request Sep 17, 2026
Service-child cleanup could report an unavailable MCP driver when a retired relay or anchor remained alive after the closing receipt and pipe closure. Retain pending force requests in the existing cleanup owner, reap a live anchor through its relay, then retire the retained relay handle. Confirm actual exit and group disappearance within the original hard deadline, preserving signal-delivery errors and forced-cleanup diagnostics. Fresh driver executions can connect afterward.

The CUA proxy cleanup-deadline flake on hosted runners was a symptom of this cleanup gap. The accompanying shell-test fix narrows whole-module child_process autospy to native-backed spawnSync, preventing shared-worker prototype contamination and recursive kill calls without relaxing cleanup assertions or deadlines.

Exact-head CI passed without reruns: https://github.com/openclaw/openclaw/actions/runs/35182765072
Retained proof includes real-process stall, failed-delivery, late-exit, fresh-client and ordered shared-worker replay coverage. Codex review and the exact-head ClawSweeper review have no remaining actionable findings within their stated scope.

Related: #150236
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
Service-child cleanup could report an unavailable MCP driver when a retired relay or anchor remained alive after the closing receipt and pipe closure. Retain pending force requests in the existing cleanup owner, reap a live anchor through its relay, then retire the retained relay handle. Confirm actual exit and group disappearance within the original hard deadline, preserving signal-delivery errors and forced-cleanup diagnostics. Fresh driver executions can connect afterward.

The CUA proxy cleanup-deadline flake on hosted runners was a symptom of this cleanup gap. The accompanying shell-test fix narrows whole-module child_process autospy to native-backed spawnSync, preventing shared-worker prototype contamination and recursive kill calls without relaxing cleanup assertions or deadlines.

Exact-head CI passed without reruns: https://github.com/openclaw/openclaw/actions/runs/35182765072
Retained proof includes real-process stall, failed-delivery, late-exit, fresh-client and ordered shared-worker replay coverage. Codex review and the exact-head ClawSweeper review have no remaining actionable findings within their stated scope.

Related: openclaw#150236
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