Skip to content

fix(config): make config writes stack-safe for deeply nested documents - #154268

Closed
ruel225 wants to merge 23 commits into
openclaw:mainfrom
ruel225:fix/config-write-stringify-stack
Closed

ruel225 wants to merge 23 commits into
openclaw:mainfrom
ruel225:fix/config-write-stringify-stack

Conversation

@ruel225

@ruel225 ruel225 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #153668. Fixes #154264.

The config write chain has five recursive stages that overflow on schema-valid deeply nested documents, in the order they engage during writeConfigFileFromContext:

  1. collectChangedPaths() (src/config/config-change-paths.ts) - the recursive diff walk consumed at io.write.ts:189/313/586 overflows at ~4,500 levels in this sandbox (the [Bug]: Deeply nested config change path collection crashes with RangeError #153668 reporter observed ~4,000 on Windows), and also serves management-mutations.
  2. projectRuntimeChangesOntoSource() (src/config/source-value-projection.ts) - the runtime-changes projection walks the document recursively and clones via native structuredClone, which overflows at ~1,600 levels on the full-chain probe below.
  3. The merge-patch trio (createMergePatch / applyMergePatch / mergePatchConflicts in src/config/merge-patch.ts) plus its internal clone helper, which recursed and also delegated to native structuredClone.
  4. The env-ref passes (resolveEnvVarRefsForComparison / restoreEnvVarRefsFromResolved / restoreEnvRefsFromMap in src/config/env-preserve.ts, plus the two containsAuthored*EnvTemplate probes in src/config/env-preserve-authored.ts) - recursive walks over the authored document.
  5. JSON.stringify(stampedOutputConfig, null, 2) at src/config/io.write.ts:354 - the platform serializer recurses one call frame per nesting level and overflows at ~4,400 levels (bisected: 4,457 serialize, 4,458 crash in this sandbox).

All of these stages now walk on explicit work stacks, so document nesting costs heap rather than call frames on the stages this PR repairs. The full-chain differential below verifies this at runtime-basis inputs, but the write (save) leg is not recursion-free without qualification: two retained limits stay on it - the source-input branch of projectConfigWriteSource still clones with native structuredClone before publication (io.write-prepare.ts:1590), and the array-identity/escaped-reference accounting helpers retain recursive literal-path collection and native whole-row equality (the recursive collectLiteralArrayIdentityPaths walk in env-preserve.ts) plus recursive escape-counting visits (env-preserve-authored.ts). Those are pre-existing main behavior, outside the five repaired stages. The remaining ceilings on deeply nested documents sit outside the write leg: the read chain's include resolver and include pre-scan (the repair surfaces of #152889 and #153711), and the CLI mutation runner's own tree clone (see accounting below).

What Changed

  • src/config/config-json-serialize.ts (new): serializeConfigJson(value) - a byte-identical reimplementation of JSON.stringify(value, null, 2) on an explicit work stack. It covers the platform semantics this document class exercises: toJSON re-application (bounded, like the platform's own cycle path), object members with undefined/function/symbol values vanishing while array items collapse to null, String(number) formatting with non-finite numbers as null, lone-surrogate escaping, and cycle detection (TypeError, matching the platform).
  • src/config/config-change-paths.ts: collectChangedPaths() walks both documents on an explicit work stack instead of recursion. The visited path set and its order are unchanged (asserted against a recursive reference implementation).
  • src/config/source-value-projection.ts: projectRuntimeChangesOntoSource() walks on explicit enter/exit frames; native structuredClone is replaced by the shared stack-safe clone. Sentinel semantics (UNCHANGED/ABSENT), the delete-on-projection behavior, and the allowed-key checks are unchanged.
  • src/config/merge-patch.ts: createMergePatch(), applyMergePatch(), and mergePatchConflicts() walk on explicit frames (key-list frames preserve DFS key order; an exit frame preserves the skip-when-empty patch semantics; array-by-id merging keeps its slot boxes). The internal recursive clone is replaced by an exported stack-safe cloneUnknown, which is also what removes the native structuredClone call inside mergeObjectArraysById.
  • src/config/env-preserve.ts: all three env-ref passes walk on explicit frames. restoreEnvVarRefsFromResolved keeps document key order for newly-inserted keys, keeps the template-match/escape-check ordering, and keeps EnvRefArrayMutationError fail-closed behavior; restoreEnvRefsFromMap keeps its return-original-reference-when-unchanged semantics.
  • src/config/env-preserve-authored.ts: the two containsAuthored*EnvTemplate probes share one iterative deep-search helper.
  • src/config/merge-patch.ts + src/config/env-preserve.ts (review follow-up): the rebuilt trees settle child values through one shared settleContainerValue helper, which settles an authored own __proto__ key as inert own data (the way the replaced Object.fromEntries/structuredClone walks kept it) instead of invoking the inherited setter through plain assignment.
  • src/config/deep-equal-stack-safe.ts (new): deepEqualStackSafe(a, b) - the stack-safe tree equality used wherever these modules previously reached for isDeepStrictEqual on whole documents (leaf comparison still uses isDeepStrictEqual, so leaf semantics are unchanged).
  • src/config/io.write.ts:354: the write emits serializeConfigJson(stampedOutputConfig) instead of the platform call. The bytes are identical.

Evidence

Component level (this sandbox, Node 24 stack)

Stage Recursive main This head
Write-path JSON.stringify, 4,500 levels ✅ ✅
Write-path JSON.stringify, 5,000 levels ❌ RangeError (crash ≥4,458) ✅
collectChangedPaths, 4,500-level leaf change ❌ RangeError ✅
collectChangedPaths, 5,000-level leaf / array growth ❌ RangeError ✅
Env-ref resolve + restore round-trip, 5,000 levels ❌ RangeError ✅
Env-ref map restore, 5,000 levels (changed / unchanged-ref) ❌ RangeError ✅
Merge-patch diff + apply, 5,000 levels ❌ RangeError ✅
Runtime-source projection, 2,000 levels (edit + unchanged) ❌ RangeError ✅

Full chain through writeConfigFileFromContext (save + reread)

Real entry point, isolated state dir, no test harness: createConfigIO from src/config/io.factory.ts, then io.writeConfigFile(...) followed by io.readConfigFileSnapshot(). The deep document rides under plugins.entries.probe.config (the schema's free-form record slot), so it passes schema validation and reaches the whole write chain - diff, projection, env-ref passes, merge patch, validation, serialization, publish - and then the read chain on reread. main is checked out at 103115f2f0b (current origin/main), this head is 53c0774cb93.

Document depth Recursive main This head
1,200 - save + reread ✅ ✅
1,500 - save + reread ✅ ✅
1,700 - save + reread ❌ RangeError at native structuredClone via cloneUnknown inside createMergePatch (merge-patch.ts:16/40) ✅
2,000 - save + reread ❌ same ✅ exit 0, both legs (save 7.4s, reread 138ms)
2,200 - save + reread ❌ same ❌ RangeError at IncludeProcessor.processObject (includes.ts:222) - read-chain include resolver, the #152889 surface
3,000 - save + reread ❌ same ❌ RangeError at containsConfigIncludeDirective (io.read-helpers.ts:90) - the #153711 surface

At this head the five repaired stages complete with zero tree-deep recursion on them at every depth up to the read-chain ceiling (the differential uses runtime-basis inputs, so the retained source-input and array-identity limits above are not exercised by it); both remaining failure frames are in the read chain, outside this PR's surface.

Real CLI subprocess matrix (config set + config get)

node --import scripts/tsx.mjs src/entry.ts config set plugins.entries.probe.config.leaf '"touched"' --strict-json against a pre-seeded deep document in an isolated $OPENCLAW_STATE_DIR, then config get on the same path. Each run is a fresh subprocess and state dir.

Depth Recursive main This head
600 - set + get ✅ ✅
900 - set + get ✅ ✅
1,000 - set + get ✅ ✅
1,100 - set + get ✅ ✅
1,200 - set ❌ Maximum call stack size exceeded ❌ same error
1,600 / 2,000 / 2,400 - set ❌ same error ❌ same error

Accounting for the CLI ceiling: the CLI's ceiling is below the write chain's because config set engages the mutation runner before the write chain: runConfigOperations clones the whole resolved document with native structuredClone (src/cli/config-cli-runner.ts:315), which overflows around 1,200 levels on both main and this head. That stage is not on the write chain and is not part of the issues this PR fixes, so the CLI boundary is unchanged by this PR; the write-chain recovery is proven at the writeConfigFileFromContext boundary in the table above. Beyond that, the read chain carries its own untouched recursions (include resolver at includes.ts:222, pre-scan at io.read-helpers.ts:90) which bound the reread leg independently - those are the repair surfaces of #152889 and #153711. One further limit sits inside the write leg itself: when the write runs on a source basis, projectConfigWriteSource clones with native structuredClone (io.write-prepare.ts:1590), so source-basis deep documents overflow there on both main and this head, and the array-identity/escaped-reference accounting keeps its pre-existing recursive and native-equality paths. These are main behavior, unchanged by this PR, noted so the recovery claim stays scoped to the five repaired stages.

Serialized-byte equivalence is pinned two ways: the 400-case fuzz compares serializeConfigJson against JSON.stringify(value, null, 2) directly, and the full io.write suites (361 tests) pass unchanged at this head - those suites assert written bytes through the config hash chain and reread snapshots, so any byte drift would fail them.

Authored own __proto__ key preservation (own-property compat)

The iterative rebuilds settle child values into freshly built containers. Plain assignment invokes the inherited __proto__ setter: the own key is lost and the value is grafted onto the tree's prototype, and array identity matching over the comparison tree can consequently reject unchanged rows. settleContainerValue (shared by the stack-safe clone and all three env-ref settlements) defines such keys as inert own data instead. Repros in env-preserve.test.ts (authored key built via JSON.parse), pre-fix red to post-fix green at this head:

The previously requested unchanged-array regression is now pinned: an untouched two-row array whose rows carry a JSON-parsed own __proto__: null data key. The comparison tree must settle that key as inert data, or neither row equals its resolved counterpart (matchesArrayElementAtSameIndex in env-preserve.ts) and both array identities go unmatched. Pre-fix (parent 49cd9710ccf) the restore output dropped the rows' own key — { providers: [{…(2)}, {…(2)}] } against the expected three-key rows — and the test fails; at this head it passes.

Surface Recursive main Pre-fix head This head
Comparison tree keeps the authored own __proto__ key (Object.fromEntries baseline) ✅ ❌ assignment lost the key ✅ inert own data
Array identity matching over the comparison tree ✅ ❌ could reject unchanged rows ✅
Restore / map-restore output keeps the key ❌ pre-existing setter loss ❌ carried over ✅ inert own data
Unchanged two-row array keeps its rows' keys and references ✅ ❌ rows lost the key, identities unmatched ✅

checks-node-compact-large-10 diagnosis (recorded owning repair, not this PR's surface)

The 2026-09-21T21:00Z run's single failure is src/state/openclaw-agent-db-module-identity.test.ts ("shares agent ownership, worker publication, reclamation queues, and commit observers across transformed SDK modules") at line 271: AssertionError: spawnSync <toolchain node> ETIMEDOUT: expected null to be +0. That test spawns a fresh Node child with a fixed timeout: 30_000 and JITI_FS_CACHE: "0" (source transforms re-run on every spawn); the shard executed 2,492 tests over 467s; the likely cause - inferred from the timing, not verified - is a saturated runner pushing the child past its fixed budget, which returns result.status as null. The test file is byte-identical on main and outside this PR's config-write surface, and a spawn timeout is purely load-sensitive. A plausible owning repair - proposed, not verified - would be a more generous child budget (or a spawn retry) in that test; recorded here per the review request instead of retrying for green, and this head's CI run re-runs the shard.

The 2026-09-22T12:35Z run on f7d6123142 failed the same shard on a second, unrelated signature: src/cron/service.heartbeat-busy-poll.test.ts at line 247, expected "vi.fn()" to be called once, but got 0 times inside vi.waitFor after vi.advanceTimersByTimeAsync — the heartbeat request was never observed within the wait budget (runner saturation is inferred, not verified). That file is byte-identical on main and equally outside this PR's config-write surface. Two distinct load-sensitive signatures in one shard (a spawnSync child budget on the first signature, a vi.waitFor budget on the second) are consistent with saturated-runner flake as seen from the shard's own test files; plausible owning repairs - proposals, not verified - live in those test files on main, and this PR documents them instead of retrying for green. The same run also failed compact-large-8 (gateway/embeddings-http.test.ts close-count race inside vi.waitFor, 25 vs 26, plus a cascading state-db borrower leak from the failed cleanup), compact-large-14 (cli/resume-cli.test.ts bootstrap-credential retire, helloCount 1 vs 2 inside a 5s vi.waitFor), and compact-large-18 (gateway/server.sessions.archive-worker-placement.test.ts, drainStarted never observed plus a revoked session-history read) — four shards, four signatures, all vi.waitFor-family timing waits, none in the diff.

Merge with current main (reference-intent/file-ownership landing)

Main landed #147440 (reference intent + file ownership) and #152490 (value-traversal isolation) while this PR was under review, so the branch was merged at head add3c594 (merge of 54c312971a4 into be48a677367). The conflicts resolved:

  • The iterative env-ref restoration frames are kept, and main's explicit-intent semantics are settled through them: the string-leaf explicit-template intent check, per-child explicit-path tracking on every container descent, and the escape-check fail-closed pass now also carries the stable-identity lookup plus the conditional explicit paths it feeds to containsUnaccountedActiveEscapedEnvRef.
  • Main removed the env-ref map restore path (restoreEnvRefsFromMap and the whole envRefMap collection in the writer); the merge follows that removal, so restoration flows through the one iterative restoreEnvVarRefsFromResolved with explicit intent paths. resolveStableArrayIdentityMatch is now exported from env-preserve-array-identity.ts (its body is byte-identical to main's) for the escape-check pass. (Superseded by the round-2 merge below: that module is gone and main's in-place helpers are used directly.)
  • The stack-safe containsAuthored* walkers in env-preserve-authored.ts are kept on top of main's explicit-intent additions to that module.
  • The stack-safe JSON serialization stays at the publication boundary (io.write.ts keeps serializeConfigJson on top of main's write-topology refactor), and main's io.write-values.ts restore entry (which passes explicitSetPaths) is kept.
  • The 61 remaining textual conflicts were main-side deletions of files this PR never touched (extension/package modules moved on main), resolved by taking main's deletions.

Verification at the merge head: node scripts/run-tsgo.mjs -p tsconfig.core.json is clean (checked out in a dependency-installed worktree at the merge tree; the primary sandbox carries stale packages/*/dist declarations that produce unrelated symbol-inference noise), and the merged test face is green: env-preserve.test.ts 95/95 (main's explicit-intent suite plus this PR's stack-safe and authored own __proto__ suites), merge-patch + config-json-serialize + config-change-paths + source-value-projection 26/26, and io.write-config + io.write-prepare + io.write-reread + io.write-effects 409/409, plus io.write-lock green.

Merge with current main (round 2: array-matching unification landing)

While this PR waited on review, main unified the escaped-template matcher into matchAuthoredTemplateArrayItems(arrays, "substitution" | "escaped", claimedIncomingIndexes?) and moved the array-identity helpers back into env-preserve.ts, so the branch was re-merged at head e814cf0406a (merge of main 68d49169a53 into the prior head). The conflicts resolved:

  • The iterative restoreEnvVarRefsFromResolved frames are kept and now call main's unified matcher with the mode parameter; the standalone env-preserve-array-identity.ts module is dropped (main keeps the helpers in place), and the stack-safe settleContainerValue stays exported from merge-patch.ts for both the merge-patch builders and the env-ref restore frames.
  • resolveEnvVarRefsForComparison and the authored-template probes stay on their iterative walks; resolveWriteEnvSnapshotForPath and the retained-limit recursion (collectLiteralArrayIdentityPaths, the escape-counting visits) follow main verbatim.
  • merge-patch.ts keeps the stack-safe builders on top of main's cleanups (inlined array-entry path formatting, the redundant pre-loop id-guard removal, and the applyMergePatch base passthrough, which is behavior-identical because a non-object base is normalized to an empty result either way).
  • The wrapper component list drops the removed module and keeps config-json-serialize.ts and deep-equal-stack-safe.ts.

Verification at the merge head: node scripts/run-tsgo.mjs -p tsconfig.core.json is clean in a dependency-installed worktree at the merge tree (a first cut of the merge left the escape-check frames carrying readonly unknown[] into main's mutable EnvRefArrays; TS4104 caught it in CI at env-preserve.ts 536/537 and the frames are narrowed to unknown[] at the fix head), and the merged test face is green: merge-patch + config-json-serialize + config-change-paths + source-value-projection 25/25, env-preserve + the stack-safe and authored own __proto__ suites 51/51, and io.write-config + io.write-reread + io.write-prepare 182/182.

Test timings

  • The two new test files from the first stage: node scripts/run-vitest.mjs src/config/config-change-paths.test.ts src/config/config-json-serialize.test.ts - 2 files / 10 tests pass, 1.59s wall.
  • The extended suites: src/config/env-preserve.test.ts (86 tests, including the 5,000-level round-trips, the three authored own __proto__ repros, and the unchanged two-row array repro), src/config/merge-patch.test.ts (13 tests including the 5,000-level diff/apply pair), and the new src/config/source-value-projection.test.ts (2,000-level edit + unchanged-clone) all pass, plus the full config write face (io.write-config.test.ts + io.write-reread.test.ts + io.write-prepare.test.ts, 377 tests) in 266s.

How Was This Tested

  • node scripts/run-vitest.mjs src/config/io.write-config.test.ts src/config/io.write-reread.test.ts src/config/io.write-prepare.test.ts - all pass at this head (182 across the three files at the round-2 merge head; main reorganized the suites since the first stage).
  • node scripts/run-vitest.mjs src/config/env-preserve.test.ts src/config/merge-patch.test.ts src/config/source-value-projection.test.ts src/config/config-json-serialize.test.ts src/config/config-change-paths.test.ts - all pass.
  • node scripts/run-vitest.mjs src/config/env-preserve.test.ts - the three authored own __proto__ repros are red before the settlement fix and green at this head, and the unchanged two-row array repro is red at the pre-fix parent 49cd9710ccf (rows drop their own key, identities unmatched) and green at this head.
  • The full-chain differential table above at depths 1,200-3,000, main vs this head, on the real writeConfigFileFromContext entry.
  • The real CLI config set + config get matrix above at depths 600-2,400, main vs this head.
  • node_modules/.bin/oxlint -c .oxlintrc.json and the repo formatter are clean on touched files.

Compatibility

Written bytes are unchanged (differential-tested reimplementation of the exact platform call it replaces, plus hash/reread assertions), change detection returns the same paths in the same order, merge-patch key ordering and skip-when-empty semantics are preserved, env-ref restore keeps document key order and its fail-closed error behavior, and projection keeps its sentinel/delete semantics. No schema, state, or public contract changes. The settlement fix changes one observable behavior: an authored own __proto__ key now survives the env-ref restore and map-restore output as inert own data instead of being silently dropped by the inherited setter (main dropped it as well; the replaced structuredClone/fromEntries walks kept it), and the comparison tree keeps main's own-property semantics. Documents deep enough to crash any of the five repaired stages now complete the entire write leg (runtime-basis inputs); the remaining ceilings - CLI mutation-runner clone, read-chain include resolver and pre-scan, and the retained source-input structuredClone plus array-identity/escaped-reference recursion noted above - are outside the five repaired stages and unchanged by this PR.

The write path recursively descended in two places: collectChangedPaths
walked both documents one call frame per nesting level, and the platform
JSON.stringify recursed again while rendering the stamped document, so a
schema-valid deep config that loaded fine could crash any later write
with a RangeError. collectChangedPaths now walks on an explicit work
stack and the write path serializes through an explicit-stack serializer
whose output stays byte-identical to JSON.stringify(value, null, 2);
regression coverage pairs the serializer and the path walker against the
platform behavior on randomized documents and on 5,000-level nesting.

Co-Authored-By: Claude <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: ClawSweeper could not verify the complete source for this revision.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: No contributor action is requested. Maintainers should inspect the linked workflow run.

View the workflow run.

@ruel225
ruel225 marked this pull request as ready for review September 21, 2026 01:47
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR replaces recursive configuration-write processing with explicit work stacks so deeply nested settings can be saved without overflowing the call stack.

Example: A caller saves a 2,000-level configuration under plugins.entries.probe.config.

  • Before: The recorded baseline throws RangeError while cloning values during merge-patch creation.
  • After: The recorded candidate saves the configuration and rereads it successfully.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful and coherent, with sufficient real-filesystem writer evidence but limited proof through a shipped CLI or Gateway entry point.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (live_output): The recorded isolated createConfigIO run exercises the actual writer with real filesystem publication and rereading: candidate 53c0774 saves a schema-valid 2,000-level plugin configuration where its baseline overflows. Subsequent writer coverage supports preserved bytes and existing-state compatibility. The inspected home-screen screenshots do not establish this behavior, and the unchanged CLI/source-input ceilings remain outside the demonstrated recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Saving schema-valid, deeply nested plugin settings can fail with a call-stack overflow.
Reason: The linked reports identify concrete failures in existing configuration-write behavior. The patch repairs those stages while preserving established settings and reference contracts.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and the latest release retain the config-write failures, and related read-side repairs do not supersede its work. No blocking patch defect was found.

Priority: P2
Reviewed head: 19efa787800f721a1c7edd3974c6e885af4a73b2

Before merge

None.

Findings

None.

Tests

  • Low-value test src/config/merge-patch.test.ts: reports no conflict for a deeply nested unchanged document: Remove this case: createMergePatch(base, base) produces an empty patch, so mergePatchConflicts never traverses the deep document and the test cannot detect its recursion regression.
  • Missing end-to-end proof: The recorded writer boundary succeeds, but no CLI or Gateway run demonstrates improved deep-write behavior; the CLI matrix encounters an unchanged earlier cloning limit.
Agent review details

How this fits together

OpenClaw’s configuration writer receives requested settings and an authored snapshot, preserves references and explicit values, validates the result, and publishes a configuration file.

flowchart TD
  A[Requested settings] --> C[Compare and project changes]
  B[Authored configuration] --> C
  C --> D[Merge and preserve references]
  D --> E[Validate configuration]
  E --> F[Stack-safe JSON serialization]
  F --> G[Publish configuration file]
  G --> H[Read configuration]
Loading

Technical review

Best possible solution:

Keep one configuration writer that handles deeper JSON trees while preserving authored references, patch semantics, and serialized bytes.

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

Yes: current-main source retains depth-proportional recursion, and the contributor records an isolated real-filesystem writer differential. This read-only review did not independently execute that reproduction.

Is this the best way to solve the issue?

Yes: replacing traversal within the existing owners repairs the documented failure without new settings or competing persistence paths; the recovery claim appropriately excludes unchanged depth limits.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduction inspected: Reviewed the merge-base-to-head changes, affected production modules, added tests, and original implementations. The verified test merge has the recorded base and exact PR head as parents. (19efa787800f)
  • Current main still needs the repair: Fetched main retains recursive changed-path collection and merge-patch processing, and its writer still uses native JSON.stringify. The later writer change composes existing authority assertions and does not replace serialization. (src/config/io.write.ts:326, d0fc39e87290)
  • Latest release remains affected: The supplied latest release, v2026.9.9, retains native write serialization and recursive changed-path collection. (src/config/io.write.ts:311, bcfc88812a35)
  • Captured runtime evidence: The live body matches captured SHA-256 068807d48cfdc1c97790cb457efd5e6be7e26c0064d71ca3bfaaabe03b3b8804 and contains 21,899 UTF-16 units. It records isolated createConfigIO writes and disk rereads: baseline 103115f fails at 1,700 levels, while candidate 53c0774 saves and rereads 2,000 levels. Subsequent merged-head writer-suite results supplement this historical runtime observation. (53c0774cb933)
  • Media inspected: Both prepared screenshots show the OpenClaw home screen and provide no evidence about deep configuration writes; the runtime assessment rests on the recorded writer results.
  • Compatibility and retained limits: Serialization tests compare against the platform serializer across 400 deterministic documents. Existing writer results cover hashes and rereads. No schema, default, or persisted format is added. Source-basis native cloning and array-reference accounting retain their documented pre-existing depth limits. (src/config/config-json-serialize.test.ts:88, 19efa787800f)

PR surface

Source +1031, Tests +533, Other +1. Total +1565 across 15 files. Added test files: 5.

View PR surface stats
Area Files Added Removed Net
Source 8 1324 293 +1031
Tests 6 534 1 +533
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 15 1859 294 +1565

Review metrics

Metric Value Why it matters
Production versus test growth production +1,031 LOC; tests +533 LOC Explicit traversal frames and replacement serialization explain the production growth across the existing write stages.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: Configuration saves fail for unusually deep documents, with a limited affected population and no established widespread outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

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

  • Remove the empty-patch conflict test that does not exercise deep conflict traversal.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (18 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-22T00:52:35.921Z sha be48a67 :: needs changes before merge. :: none
  • reviewed 2026-09-22T12:45:11.428Z sha f7d6123 :: needs changes before merge. :: none
  • reviewed 2026-09-22T16:41:27.976Z sha adf2840 :: needs changes before merge. :: none
  • reviewed 2026-09-22T20:37:45.286Z sha 1ce3def :: needs maintainer review before merge. :: none
  • reviewed 2026-09-22T20:54:21.905Z sha 0c9e647 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-23T00:29:13.475Z sha 0574e89 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-23T09:54:43.882Z sha 0574e89 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T23:17:10.683Z sha 0574e89 :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 4:50 PM ET / 20:50 UTC (Revision 19).

…ratchet

The fast baseline ratchet counts non-const type assertions per file and
config-json-serialize.ts shipped four new ones. Three are removable without
any behavior change: isPlainContainer already narrows to Record<string,
unknown> at the two toJSON probes, and the aliased const narrows to Function
via the existing typeof check before its call. The remaining object-vs-record
cast in collectEntries keeps a single-line SAFETY comment documenting why the
non-array remainder is a plain record.

Co-Authored-By: Claude <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 21, 2026
ruel225 and others added 2 commits September 21, 2026 17:11
The write chain resolves and restores ${VAR} references over the whole
parsed document, and those traversals kept call frames proportional to
document depth, so a schema-valid deep config crashed with a RangeError
before the writer serialized it. The comparison resolve, the authored
restore walk with its escape mutation check, the map-based restore
walk, and the authored-template probes now carry their work on explicit
stacks, so document nesting costs heap rather than call frames. Deep
object keys settle in document order and id-keyed array matching is
unchanged.

Co-Authored-By: Claude Code <[email protected]>
createMergePatch, applyMergePatch, mergePatchConflicts, and the
runtime-source projection recursed over the documents they diffed, and
they cloned values with structuredClone, whose own traversal overflows
the call stack on schema-valid deep configs before the write path
commits. The patch build, patch apply, conflict detection, and
projection now run on explicit work stacks with keys settling in
document order, the value clone walks containers iteratively, and
tree-level equality uses an explicit-stack comparison.

Co-Authored-By: Claude Code <[email protected]>
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 21, 2026
The iterative merge-patch, patch-apply, and projection walkers passed the
full frame union to their settle helpers, but the key-resolution variants
carry no container slot, so the plugin-sdk boundary dts emit rejected the
frame.container access. The helpers only ever settle enter and exit
frames; type them with Extract. The conflict walk also widened its
record guards through boolean locals, which the checker cannot flow
through; inline the guards where the narrowed record is consumed.

Co-Authored-By: Claude Code <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 21, 2026
The iterative clone assigned keys through plain bracket writes, so an
authored own __proto__ key invoked the inherited setter: the clone lost
the key as own data and grafted the value onto its prototype, where the
platform clone had kept it inert. Prototype keys now settle through
defineProperty, preserving the own-property shape that merge-patch
additions and retained projection values carry into serialization.

Co-Authored-By: Claude Code <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added security Security documentation commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: feishu Channel integration: feishu channel: twitch Channel integration: twitch extensions: device-pair labels Sep 22, 2026
ruel225 and others added 7 commits September 22, 2026 16:36
Merging main pushed env-preserve.test.ts past the 1000-line cap and
orphaned the EnvRefArrayMutationError import plus its re-export. Move the
authored own-__proto__ regressions and the stack-safe deep-restoration
suite into coherent sibling test files, drop the unused import and
re-export, and reflow the merged explicitSetPaths condition.

Co-Authored-By: Claude <[email protected]>
The 2026-09-22 f7d6123 run failed four compact-large shards on four
distinct signatures, none touching the config-write surface this PR
changes:

- compact-large-8: gateway/embeddings-http.test.ts close-count race
  (25 vs 26 inside vi.waitFor) plus a cascading state-db borrower leak
- compact-large-10: cron/service.heartbeat-busy-poll.test.ts
  vi.waitFor heartbeat request never observed (0 of 1)
- compact-large-14: cli/resume-cli.test.ts bootstrap-credential retire
  helloCount 1 vs 2 inside vi.waitFor (5s budget)
- compact-large-18: gateway/server.sessions.archive-worker-placement
  drainStarted never observed, session history read revoked

All four are timing-sensitive waits on saturated shard runners. This
empty commit re-runs the matrix.

Co-Authored-By: Claude <[email protected]>
SIGINT staging-close ordering in test/scripts/docker-all-harness.test.ts
is outside this PR's config-write surface.

Co-Authored-By: Claude <[email protected]>
compact-large-30/31 (residual registry roots teardown cross-talk across
agentic-gateway-methods-hosted shards), compact-large-32 (tasks.list
performance timing), and changed-extensions-bundle-31 (matrix
active-turn steering timeout) all fail outside the config-write surface
this PR touches. Same pattern passed on the prior head's shards.

Co-Authored-By: Claude <[email protected]>
ruel225 and others added 4 commits October 10, 2026 00:49
Resolve the env-preserve/merge-patch fusion against main's in-place
array-matching refactor: keep main's unified matchAuthoredTemplateArrayItems
semantics and the resolveWriteEnvSnapshotForPath updates, and rebuild the
stack-safe iterative walks (env-ref restore, merge patch, serialization,
change-path collection, authored template probes) on top of them.
@ruel225

ruel225 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this: it doesn't show a real user-facing problem (no report from an affected user and no natural reproduction), and it follows a pattern of small, speculative or duplicate changes split across many PRs. Please open an issue with a reproduction of real harm first; a fix can follow once the problem is confirmed.

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants