Skip to content

fix: allow plugin state values up to 1 MiB - #130387

Merged
steipete merged 3 commits into
mainfrom
codex/plugin-state-1mib-global
Aug 26, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/plugin-state-1mib-global

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Related: #129597, #128362, #126986. Separate follow-up: #105002.

What Problem This Solves

Fixes an issue where users starting or resuming Codex-backed conversations could fail before model execution when the frozen workspace instruction snapshot exceeded the plugin keyed-state limit of 65,536 bytes. The workspace bootstrap budget is measured in characters, but the saved JSON is measured in UTF-8 bytes, so a permitted multibyte instruction file can cross that limit.

Why This Change Was Made

Maintainer decision: raise the shared plugin keyed-state JSON value limit to 1 MiB (1,048,576 bytes) for all plugins. Keep the existing single-row binding and its atomic mutation/lifecycle ownership. No Codex-specific exception, new store, migration, schema change, or blob lifecycle is necessary for this decision.

The limit includes JSON encoding overhead. Namespace entry limits, the plugin-wide entry fuse, TTL behavior, and the separate 64 KiB blob-metadata limit are unchanged. Larger individual values increase the existing eager-enumeration memory ceiling; aggregate/paged enumeration remains the separately tracked #105002 concern, not a claim resolved by this PR.

CI repair included: the test merge picked up #130335 from main, whose package-mode normalization passed absolute Windows archive paths to GNU tar. Windows CI failed with Cannot connect to C: resolve failed. The three existing system-tar archive operations now use an archive basename with its containing directory as cwd, retaining the extraction destination and platform-independent system-tar contract. This covers both package normalization and the sibling bundled-runtime extraction; no package dependency or GNU-only flag was added.

User Impact

Plugins can persist larger JSON values through both synchronous and asynchronous keyed APIs. Codex can retain larger frozen instruction snapshots without truncation or changing its restart/resume semantics. Values over 1 MiB still fail explicitly, and a rejected update leaves the prior value intact.

Evidence

  • Before the fix, the strengthened UTF-8 boundary regression failed with PLUGIN_STATE_LIMIT_EXCEEDED: plugin state value exceeds 65536 byte limit.
  • After the fix, 129 focused tests passed: 70 plugin-state unit tests, 50 Codex session-binding tests, and 9 storage E2E tests. Both keyed APIs accept exactly 1,048,576 UTF-8 JSON bytes and reject one additional byte across register, register-if-absent, and update; reopening preserves accepted values and rejected updates preserve prior values.
  • A real SQLite blob-metadata probe still accepts 65,536 bytes and rejects 65,537 bytes, confirming that this separate limit did not change.
  • Fresh isolated Codex autoreview reported no actionable findings at the default P0 threshold.
  • Authenticated live proof passed through the compiled openclaw agent --local CLI using openai/gpt-5.6-luna, isolated temporary state, and the configured Codex runtime with no fallback. A 72,496-byte frozen developer-instruction snapshot was persisted in an 81,164-byte binding. After the CLI/native runtime exited, the workspace file was changed and a second CLI process resumed the same native thread. It returned the original marker (which had not appeared in the first assistant reply), and the saved instruction SHA-256 remained identical. Both turns exited 0; no tools were called.
  • Repeated after integration on final head 4557e92aa4b1fa116862aa3d4d6e7002f8f65262: all 129 focused tests passed again, and the authenticated cold-resume proof passed again. Native rollout metadata confirmed Codex 0.149.1. The final run retained thread 01a03fe5-9d1d-7010-ac99-b175fc66417b and instruction hash 60af6696d3a26faa9c201e0e5d297b6bb4f8b8a1cedfdc28f66c0e923b0cc00e across the restart.
  • Testbox acquisition was unavailable because its CLI was not signed in; no remote lease was created. This is local authenticated CLI proof, not Testbox proof. An initial raw-source startup was interrupted before a model response; the compiled branch was used for the successful run.
  • The first full check found a test-helper return-type error; the helper was corrected and the affected typecheck and 9 E2E tests passed. The complete corrected plugin-state changed-file gate subsequently passed with exit 0.
  • Windows CI job 98320848762 reproduced the unrelated tar archive-path failure. After the bounded repair, local packaging E2E passed 37 tests (3 platform skips), script lint/typecheck passed, and fresh autoreview was clean. Both Windows jobs passed on final head in CI run 33013729851. GNU tar's archive-file contract documents the colon-as-remote-host behavior; using a local basename also works with macOS bsdtar.

Direct dependency contract checked against Codex rust-v0.149.1 (ff29a44391deccde0aba0f8390337d7f3c319ea4), matching the plugin pin: codex-rs/app-server-protocol/src/protocol/v2/thread.rs:103,392 accepts developer instructions on start and resume; codex-rs/core/src/session/mod.rs:657,695 restores base instructions from history but takes developer instructions from the supplied configuration; codex-rs/protocol/src/protocol.rs:2871 does not persist a developer-instruction field in session metadata. OpenClaw therefore still owns preserving and resupplying its exact frozen snapshot.

Plugin runtime delta: +1/-1, net zero. Tests: +36/-22, net +14; docs: +1/-1. The bounded packaging-tooling repair is +28/-12, mostly formatter wrapping around the three changed archive arguments/cwd pairs; the additional behavior is required for Windows path correctness. No new production abstraction was added.

Release-note context: Plugin state now accepts JSON values up to 1 MiB, allowing larger frozen Codex workspace instructions to persist across restarts.

AI-assisted: yes.

Named follow-up: the existing multi-session probe in src/gateway/gateway-codex-harness.live.test.ts still supplies the retired untrusted app-server approval-policy value. The live probe above uses the current on-request value. This unrelated test-fixture cleanup is not included in the storage-limit change.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: file-transfer size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 20:34
@steipete steipete self-assigned this Aug 26, 2026
@steipete
steipete force-pushed the codex/plugin-state-1mib-global branch from 20e2e66 to 4557e92 Compare August 26, 2026 21:05
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts docker Docker and sandbox tooling labels Aug 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 26, 2026, 5:13 PM ET / 21:13 UTC.

ClawSweeper review

What this changes

The branch raises plugin keyed-state JSON values to 1 MiB, updates boundary tests and SDK documentation, and makes package tar operations use local archive paths on Windows.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this maintainer-authored, maintainer-labeled PR open. Raising the shared value cap multiplies the already-known unbounded entries() memory exposure from about 3 GiB to 48.8 GiB per plugin, so it needs a maintainer decision and bounded-read plan before merge.

Priority: P2
Reviewed head: 4557e92aa4b1fa116862aa3d4d6e7002f8f65262
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused boundary coverage and claimed live proof are useful, but the branch widens a known whole-namespace memory hazard that needs a maintainer decision.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository-member, maintainer-labeled PR is exempt from the external-contributor proof gate; its body reports a local authenticated CLI run, but this review could not independently inspect the required upstream Codex source contract.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository-member, maintainer-labeled PR is exempt from the external-contributor proof gate; its body reports a local authenticated CLI run, but this review could not independently inspect the required upstream Codex source contract.
Evidence reviewed 8 items Changed global storage limit: The PR changes the shared keyed-state maximum from 65,536 to 1,048,576 bytes; every plugin namespace uses this facade-level bound.
Unbounded enumeration contract: The public async and sync keyed-store contracts expose whole-namespace entries() arrays, and the SQLite implementation maps every selected row; 50,000 permitted rows at 1 MiB each permit 52,428,800,000 raw bytes before JavaScript object overhead.
Existing canonical availability work: #105002 already documents the same eager-enumeration owner boundary and explains that a silent LIMIT would break the shipped complete-array contract.
Findings 1 actionable finding [P1] Bound enumeration before raising the shared value limit
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/plugin-state/plugin-state-store.test.ts src/plugin-state/plugin-state-store.e2e.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs src/plugin-state/plugin-state-store.test.ts src/plugin-state/plugin-state-store.e2e.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs src/plugin-state/plugin-state-store.test.ts src/plugin-state/plugin-state-store.e2e.test.ts"

[test] starting test/vitest/vitest.unit.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130387-KyBPM5/target

 ✓  unit  src/plugin-state/plugin-state-store.test.ts (42 tests) 1488ms

 Test Files  1 passed (1)
      Tests  42 passed (42)
   Start at  21:14:04
   Duration  10.86s (transform 7.33s, setup 964ms, import 8.04s, tests 1.49s, environment 0ms)

[test] starting test/vitest/vitest.e2e.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130387-KyBPM5/target

[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
  - tsdown:deps (50%)
  - rolldown-plugin-dts:generate (21%)
  - rolldown-plugin-dts:fake-js (18%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

[tsdown-build] invocation 1/11 finished in 4.6s

Assertions:

  • FAIL expect_output: passed

How this fits together

Plugin keyed state is SQLite-backed durable JSON storage used by trusted plugins; Codex thread bindings are one consumer. Its public entries() API reads a namespace into an in-memory array, while the separate packaging helper invokes the system tar tool to build release artifacts.

flowchart LR
A[Plugin or Codex binding] --> B[Keyed state write]
B --> C[JSON byte limit]
C --> D[SQLite state row]
D --> E[Plugin entries read]
E --> F[In-memory JSON array]
G[Package tarball] --> H[System tar helper]
H --> I[Package artifact]
Loading

Decision needed

Question Recommendation
Should OpenClaw raise the shared plugin keyed-state value limit to 1 MiB before the existing unbounded entries() contract has a bounded-read migration? Bound reads before raising the cap: Add a compatibility-reviewed paginated or aggregate-bounded read path and migrate consumers before landing the global 1 MiB limit.

Why: The cap affects all trusted plugin namespaces, while changing entries() semantics is a shipped Plugin SDK compatibility decision rather than a mechanical patch choice.

Before merge

  • Bound enumeration before raising the shared value limit (P1) - entries() still selects and parses every row in a namespace, while the plugin-wide fuse permits 50,000 rows. Raising each permitted JSON value to 1 MiB expands the possible one-call materialization from roughly 3 GiB to 48.8 GiB, turning the known availability problem in Plugin-state entries() can materialize over 3 GiB of JSON in one call #105002 into a substantially larger allowed state. Add a compatibility-reviewed bounded read path and migrate callers, or obtain an explicit maintainer decision to accept this increased ceiling before merging.
  • Resolve merge risk (P1) - A permitted 50,000-row plugin namespace can now make entries() materialize up to 48.8 GiB of raw JSON, before SQLite, string, array, and parsed-object overhead; the existing whole-array API has no aggregate-byte or pagination boundary.
  • Resolve merge risk (P1) - The direct upstream Codex protocol source required by repository policy was unavailable for independent inspection, so the asserted start/resume contract remains unverified by this review.
  • Complete next step (P2) - A maintainer must choose the Plugin SDK-compatible bounded-read direction or explicitly accept the enlarged trusted-plugin memory ceiling; this is not a safe mechanical repair lane.

Findings

  • [P1] Bound enumeration before raising the shared value limit — src/plugin-state/plugin-state-store.sqlite.ts:33
Agent review details

Security

None.

PR surface

Source 0, Tests +14, Docs 0, Other +16. Total +30 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 2 36 22 +14
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 28 12 +16
Total 5 66 36 +30

Review metrics

Metric Value Why it matters
Production vs test delta production +29/-13, tests +36/-22, docs +1/-1 The storage-cap change itself is net-neutral; the additional production growth is the Windows tar-path repair, while focused tests expand boundary coverage.

Merge-risk options

Maintainer options:

  1. Bound namespace reads first (recommended)
    Resolve the complete-array enumeration exposure with an API-compatible bounded-read plan before increasing every plugin's per-value ceiling.
  2. Own the increased memory ceiling
    Maintainers may deliberately accept the larger trusted-plugin memory exposure and land the cap while retaining Plugin-state entries() can materialize over 3 GiB of JSON in one call #105002 as the explicit follow-up.

Technical review

Best possible solution:

Introduce a compatibility-reviewed bounded or paginated enumeration path, migrate relevant consumers, and only then raise the shared keyed-state value limit or document an explicit accepted availability tradeoff.

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

Yes, by source: the PR allows 1 MiB JSON values while the documented 50,000-row plugin fuse and whole-array entries() implementation permit approximately 48.8 GiB of raw JSON in one read. I did not execute the memory-exhaustion scenario in this read-only review.

Is this the best way to solve the issue?

No: a global write-cap increase without a bounded enumeration plan worsens the known availability boundary tracked by #105002.

Full review comments:

  • [P1] Bound enumeration before raising the shared value limit — src/plugin-state/plugin-state-store.sqlite.ts:33
    entries() still selects and parses every row in a namespace, while the plugin-wide fuse permits 50,000 rows. Raising each permitted JSON value to 1 MiB expands the possible one-call materialization from roughly 3 GiB to 48.8 GiB, turning the known availability problem in Plugin-state entries() can materialize over 3 GiB of JSON in one call #105002 into a substantially larger allowed state. Add a compatibility-reviewed bounded read path and migrate callers, or obtain an explicit maintainer decision to accept this increased ceiling before merging.
    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 high; reviewed against 771336481e41.

Labels

Label changes:

  • add P2: This is a shared plugin-storage bug fix with a material but trusted-plugin-scoped availability concern.
  • add merge-risk: 🚨 availability: The new 1 MiB per-row allowance materially increases the memory that the unchanged eager entries() API can load in one call.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The repository-member, maintainer-labeled PR is exempt from the external-contributor proof gate; its body reports a local authenticated CLI run, but this review could not independently inspect the required upstream Codex source contract.

Label justifications:

  • P2: This is a shared plugin-storage bug fix with a material but trusted-plugin-scoped availability concern.
  • merge-risk: 🚨 availability: The new 1 MiB per-row allowance materially increases the memory that the unchanged eager entries() API can load in one call.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The repository-member, maintainer-labeled PR is exempt from the external-contributor proof gate; its body reports a local authenticated CLI run, but this review could not independently inspect the required upstream Codex source contract.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Authored this branch and the related merged package-tooling repair; current blame attributes the changed global limit to this head. (role: recent area contributor; confidence: medium; commits: 4557e92aa4b1, fc2724d831c8; files: src/plugin-state/plugin-state-store.sqlite.ts, scripts/package-openclaw-for-docker.mts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve the bounded-enumeration decision before merge.
  • Verify the pinned Codex 0.149.1 start/resume developer-instruction contract from a direct sibling source checkout.

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

Copy link
Copy Markdown
Contributor Author

Maintainer decision and review closeout:

  1. Proceed with the explicitly requested global 1 MiB keyed-state limit. The increased whole-namespace materialization ceiling is an accepted availability tradeoff for this change, not a claim that eager enumeration is now bounded. With the unchanged 50,000-entry fuse, the theoretical raw JSON ceiling is 48.8 GiB before overhead. Keep Plugin-state entries() can materialize over 3 GiB of JSON in one call #105002 as the canonical compatibility-reviewed pagination/aggregate-read follow-up. Do not silently truncate the shipped complete-array entries() contract or introduce an unapproved store migration in this PR.

  2. The required direct upstream inspection was completed personally from sibling ../codex at rust-v0.149.1, commit ff29a44391deccde0aba0f8390337d7f3c319ea4, not inferred from OpenClaw wrappers. Checked codex-rs/app-server-protocol/src/protocol/v2/thread.rs:103,392, codex-rs/core/src/session/mod.rs:657,695, codex-rs/protocol/src/protocol.rs:2871, and codex-rs/app-server/src/request_processors/thread_processor.rs:3556,3612. Start/resume accept developer instructions; cold session configuration takes them from the supplied configuration rather than restoring a session-metadata developer-instruction field. Exact snapshot preservation remains OpenClaw-owned.

  3. The reported review command did not produce a failing assertion: 42 unit tests passed, then the E2E wrapper started a build that exceeded the review runner's 30-second observation window. Our completed proof uses OPENCLAW_E2E_SKIP_BUILD=1 for the storage E2E file after building separately: 129 focused tests passed, the full corrected changed-file gate passed, and the final head's CI run is green, including both Windows jobs. The real authenticated CLI start/cold-resume test also passed twice; final proof and exact byte counts are in the PR body. Native rollout metadata independently verified Codex 0.149.1.

Both rank-up items are addressed: the bounded-enumeration decision is explicitly recorded with its named follow-up, and the direct pinned Codex contract plus real behavior were verified. No further production change is requested for these findings.

@steipete
steipete merged commit 820d167 into main Aug 26, 2026
236 checks passed
@steipete
steipete deleted the codex/plugin-state-1mib-global branch August 26, 2026 21:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S 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