Skip to content

fix(state): refuse cached plugin reads after database quarantine - #173671

Merged
steipete merged 2 commits into
mainfrom
ci/fix9-plugin-runtime-20261016
Oct 16, 2026
Merged

steipete merged 2 commits into
mainfrom
ci/fix9-plugin-runtime-20261016

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #168635, #168999, #173534

What Problem This Solves

Plugin-state reads can return cached values after shared-state database acquisition has refused a persisted quarantine.

User Impact

Quarantined plugin state remains unavailable through the keyed-store cache. The existing repair owner, reader-pool routing and ordinary cache performance are preserved.

Why This Change Was Made

The terminal-refusal owner invalidated cached handles without retiring physical schema facts that acquisition could publish before discovering quarantine. Those facts could still authorize the plugin-state row cache. Revoke them at that existing owner; introduce no new latch, cache, schema, dependency or hot-path SQL.

The lookup/lookupMany cache shortcut was added in 841272e230d0 (#168999), before the latest hourly's 22-commit window. Its failure-latch/schema-admission guards intended to preserve quarantine refusals. Earlier #168635 explicitly accepted that "A cached observation may retain its last committed value after a terminal database refusal is recorded" as a follow-up; the later lookup guard and existing quarantine test require fail-closed reads. This repair completes canonical revocation without removing the cache or weakening that contract. The suggested extension cleanup and ambient UI memory-type commits do not change these owners.

The existing quarantine test forces the unsafe acquisition shape with a real read-only schema inspection followed by canonical refusal. It retains lookup, lookupMany and register rejection assertions and adds entries/count checks. The final change is only these two quarantine files (+22/−1 lines).

Evidence

  • Main hourly 38836157770 reported a fail-open bulk read. Current main 161bd95c1d22 reproduced it: 22 passed / 1 failed, resolving [{ ok: true, value: true }] instead of rejecting.
  • The forced regression fails at keyed lookup returning true when only the new revocation is omitted (64.73 s wrapper). With revocation restored, all 23 cases pass: pnpm test src/plugin-state/plugin-state-store.test.ts --maxWorkers=1 (115.57 s wrapper-reported wall, including artifact-lock cleanup wait).
  • Reader/retention/quarantine-cleanup siblings pass: plugin-state-worker 20 cases (130.56 s), database-cache retention 1 (75.14 s), quarantine cleanup 8 (122.56 s). 52 tests pass across 4 files, each run with one worker.
  • Core production types, the owning state test typegraph, targeted type-aware lint, boundary lint, formatting and diff checks pass. Full pnpm check:architecture passes, including zero runtime/Madge cycles, SQL generation and Kysely/legacy-store guards. Independent P0–P2 review is scoped-clean.
  • Main bd5f760aecae (fix(agents): honor exact NO_REPLY and drop fabricated turn-ending replies #170534) already fixes the separately reported Gateway retention-sampling fixture. Its diff and body (five borrowing cases passed) were verified; that covered hunk is omitted here. Dropping it resolves the differing-comment merge conflict without rebasing unrelated main changes. The two retained files are byte-identical to the proven/reviewed candidate; their proof is reused.

Exact-head PR CI supplies broad proof. The first run belongs to prior head 00874bc3ae59; it is not claimed as CI for the conflict-repair head. No CI rerun, timeout increase, skip or assertion removal. The follow-up push changes source solely to remove the landed peer fix and resolve a real merge conflict.

A refused shared-state acquisition invalidated cached handles but left
physical schema facts available to the plugin-state row cache. Retire those
facts at the existing terminal-refusal owner so a quarantined database
cannot become readable through that cache after schema inspection.

Strengthen the existing quarantine test with a real read-only schema
inspection and canonical refusal, and retain its rejection checks for
lookup, lookupMany and register while adding entries/count coverage.
Omitting only the new revocation reproduces a lookup resolving true;
restoring it passes all 23 cases. No new latch, cache or repeated hot SQL.

Settle the existing startup catalog owner before sampling the Gateway
visitor run's shared retention counter, and again before exact disposal
comparison. All output, positive retention and release assertions stay.
This narrow fixture repair also appears in broad PRs #173523 and #173481.

Proof: pnpm test src/plugin-state/plugin-state-store.test.ts --maxWorkers=1
passes 23 cases (115.57s wrapper-reported wall); its forced negative control
fails at the rejection assertion (64.73s). The changed Gateway file passes
all 5 cases with one worker (243.58s pnpm wall, mostly cold transforms).
Core production and both owning test typegraphs, targeted typed lint,
boundary lint, formatting and diff checks pass. Final P2: scoped-clean.
Additional reader/retention and architecture checks continue in parallel;
PR CI owns broad proof. No retries, longer timeouts or assertions removed.
@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Oct 16, 2026
@steipete
steipete marked this pull request as ready for review October 16, 2026 02:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T02:51:32.829382Z 00874bc Draft marked ready
ℹ️ 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR revokes physical schema facts after terminal database refusal and strengthens quarantine and Gateway lease tests.

Example: Plugin state contains key k with value true, and schema inspection precedes a persisted quarantine refusal.

  • Before: A subsequent cached lookup can return true despite the refusal.
  • After: The lookup rejects with the existing database repair guidance.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful integration regression coverage; supplied behavioral evidence remains test-based.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored exemption applies; supplied evidence covers real schema inspection, canonical refusal, and plugin-state operations in an integration test, with no shipped-entry-point demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Plugins can receive cached values from a database whose persisted quarantine has already caused acquisition to refuse access.
Reason: This restores the documented quarantine contract with a small shared-owner change; the supplied maintainer-authored classification establishes direction.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it repairs a current quarantine/cache inconsistency at the shared admission owner, with no introduced defect found.

Priority: P2
Reviewed head: 00874bc3ae5956778ea3751497d8a41f0c975fff

Before merge

  • Complete next step - Resolve GitHub’s reported conflict, preserve both retained-work settlement checks, and validate the affected Gateway fixture after reconciliation.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped CLI or Gateway quarantine-to-cached-read demonstration is supplied; ordinary live proof is exempt for this maintainer-authored PR.
Agent review details

How this fits together

Plugin-state callers use cached observations or reader workers; the shared database admission owner determines whether physical schema facts remain valid and propagates terminal refusal.

flowchart TD
  A[Plugin state caller] --> B[Plugin state facade]
  B --> C[Cached observations]
  C --> D[Physical schema admission]
  B --> E[Reader workers]
  E --> F[Shared state database]
  G[Quarantine refusal owner] --> D
  G --> E
Loading

Technical review

Best possible solution:

Retire schema facts at the existing terminal-refusal owner while preserving canonical quarantine recovery and reader routing.

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

Source establishes the stale-schema-facts path, and the supplied regression reports the expected failure when only revocation is removed; no target code was executed during this review.

Is this the best way to solve the issue?

The patch repairs invalidation at its existing producer using an established revocation primitive, without adding another latch, repeated SQL, or competing state owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 49ecf7082730.

Provenance checked

  • Terminal database failure cleanup keeps the original intent (4269cd4: Centralize database failure cleanup and resource invalidation; subsequent failure publication and admission refactors retained that responsibility.)
  • Shared physical schema facts keeps the original intent (c828f7e: Reuse admitted schema facts while consolidating initialization, refresh, and terminal failures without changing quarantine semantics.)
  • Gateway retained-work fixture keeps the original intent (7df94d8: Consolidate tests while retaining lifecycle and regression coverage; the added waits preserve visitor output, positive run retention, and exact release assertions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit d996f7b adds src/state/openclaw-state-db-runtime-failure.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d996f7b36ec1; files: src/state/openclaw-state-db-runtime-failure.ts)
  • Galin Iliev: Raw commit 4269cd4 adds src/state/openclaw-state-db-runtime-failure.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 4269cd4e1afb; files: src/state/openclaw-state-db-runtime-failure.ts)

PR surface

Source +3, Tests +21. Total +24 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 0 +3
Tests 2 22 1 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 25 1 +24

Labels

Label changes:

  • add P2: Cached plugin-state reads can bypass an established database-integrity refusal; the repair is focused and affects quarantined databases.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Cached plugin-state reads can bypass an established database-integrity refusal; the repair is focused and affects quarantined databases.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • 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 15, 2026, 11:08 PM ET / October 16, 2026, 03:08 UTC.

Main bd5f760 (#170534) landed the pre-sample startup-catalog join
that fixes the reported visitor retention assertion. Its PR records all
five plugin borrowing cases passing. Drop our already-covered Gateway
hunk, resolving the differing-comment merge conflict without integrating
unrelated main changes or weakening an assertion.

The final PR delta is only the two quarantine files. Their reviewed
source and regression are byte-identical to the proven candidate; retain
the 52 focused safety/reader/retention/quarantine-cleanup passes, types,
lint, full architecture and scoped-clean P2. The earlier five Gateway
passes remain prior-candidate evidence; main owns that fixture repair.
@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label Oct 16, 2026
@steipete
steipete merged commit e51c322 into main Oct 16, 2026
142 checks passed
@steipete
steipete deleted the ci/fix9-plugin-runtime-20261016 branch October 16, 2026 03:36
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…nclaw#173671)

* fix(state): refuse cached plugin reads after database quarantine

A refused shared-state acquisition invalidated cached handles but left
physical schema facts available to the plugin-state row cache. Retire those
facts at the existing terminal-refusal owner so a quarantined database
cannot become readable through that cache after schema inspection.

Strengthen the existing quarantine test with a real read-only schema
inspection and canonical refusal, and retain its rejection checks for
lookup, lookupMany and register while adding entries/count coverage.
Omitting only the new revocation reproduces a lookup resolving true;
restoring it passes all 23 cases. No new latch, cache or repeated hot SQL.

Settle the existing startup catalog owner before sampling the Gateway
visitor run's shared retention counter, and again before exact disposal
comparison. All output, positive retention and release assertions stay.
This narrow fixture repair also appears in broad PRs openclaw#173523 and openclaw#173481.

Proof: pnpm test src/plugin-state/plugin-state-store.test.ts --maxWorkers=1
passes 23 cases (115.57s wrapper-reported wall); its forced negative control
fails at the rejection assertion (64.73s). The changed Gateway file passes
all 5 cases with one worker (243.58s pnpm wall, mostly cold transforms).
Core production and both owning test typegraphs, targeted typed lint,
boundary lint, formatting and diff checks pass. Final P2: scoped-clean.
Additional reader/retention and architecture checks continue in parallel;
PR CI owns broad proof. No retries, longer timeouts or assertions removed.

* test(gateway): defer startup custody fixture repair to main

Main f35773f (openclaw#170534) landed the pre-sample startup-catalog join
that fixes the reported visitor retention assertion. Its PR records all
five plugin borrowing cases passing. Drop our already-covered Gateway
hunk, resolving the differing-comment merge conflict without integrating
unrelated main changes or weakening an assertion.

The final PR delta is only the two quarantine files. Their reviewed
source and regression are byte-identical to the proven candidate; retain
the 52 focused safety/reader/retention/quarantine-cleanup passes, types,
lint, full architecture and scoped-clean P2. The earlier five Gateway
passes remain prior-candidate evidence; main owns that fixture repair.
tideclaw-bot pushed a commit that referenced this pull request Nov 6, 2026
…3671)

* fix(state): refuse cached plugin reads after database quarantine

A refused shared-state acquisition invalidated cached handles but left
physical schema facts available to the plugin-state row cache. Retire those
facts at the existing terminal-refusal owner so a quarantined database
cannot become readable through that cache after schema inspection.

Strengthen the existing quarantine test with a real read-only schema
inspection and canonical refusal, and retain its rejection checks for
lookup, lookupMany and register while adding entries/count coverage.
Omitting only the new revocation reproduces a lookup resolving true;
restoring it passes all 23 cases. No new latch, cache or repeated hot SQL.

Settle the existing startup catalog owner before sampling the Gateway
visitor run's shared retention counter, and again before exact disposal
comparison. All output, positive retention and release assertions stay.
This narrow fixture repair also appears in broad PRs #173523 and #173481.

Proof: pnpm test src/plugin-state/plugin-state-store.test.ts --maxWorkers=1
passes 23 cases (115.57s wrapper-reported wall); its forced negative control
fails at the rejection assertion (64.73s). The changed Gateway file passes
all 5 cases with one worker (243.58s pnpm wall, mostly cold transforms).
Core production and both owning test typegraphs, targeted typed lint,
boundary lint, formatting and diff checks pass. Final P2: scoped-clean.
Additional reader/retention and architecture checks continue in parallel;
PR CI owns broad proof. No retries, longer timeouts or assertions removed.

* test(gateway): defer startup custody fixture repair to main

Main bd5f760 (#170534) landed the pre-sample startup-catalog join
that fixes the reported visitor retention assertion. Its PR records all
five plugin borrowing cases passing. Drop our already-covered Gateway
hunk, resolving the differing-comment merge conflict without integrating
unrelated main changes or weakening an assertion.

The final PR delta is only the two quarantine files. Their reviewed
source and regression are byte-identical to the proven candidate; retain
the 52 focused safety/reader/retention/quarantine-cleanup passes, types,
lint, full architecture and scoped-clean P2. The earlier five Gateway
passes remain prior-candidate evidence; main owns that fixture repair.

(cherry picked from commit e51c322)

Co-authored-by: RomneyDa <[email protected]>
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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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