Skip to content

fix(config): resolve deep config nesting on an explicit work stack - #152889

Merged
altaywtf merged 8 commits into
openclaw:mainfrom
ruel225:fix/config-include-object-depth
Sep 27, 2026
Merged

altaywtf merged 8 commits into
openclaw:mainfrom
ruel225:fix/config-include-object-depth

Conversation

@ruel225

@ruel225 ruel225 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #152847: deeply nested configuration can fail during include resolution with a stack overflow, even without an include directive.

User Impact

Deep configuration values remain accepted without a new nesting cap. Include-file chain limits, cycle detection, path restrictions, and sibling overrides remain enforced.

Why This Change Was Made

Store suspended traversal frames on the heap and carry each include's relative path and ancestry with it. Linked logical paths avoid copying the entire path at every nested value.

Evidence

  • Independent 5,000-level object, array, and nested-include cases all failed with RangeError on pinned main 1d109710cd982f2201dc2712060c0362a9263fee; the shallow sibling-override control passed.
  • At e74d9945f3a70846277fa06f1469c9ad47728e22, 75 tests passed in 7.51 seconds on personal Cloudflare: node scripts/run-vitest.mjs src/config/includes.review.test.ts src/config/includes.top-level-key.test.ts src/config/includes.test.ts --maxWorkers=1. This covers the identical independent controls, authored 100,000-level object/array regressions, and existing include behavior. includes.review.test.ts was a temporary independent fixture.
  • Based on 18b0130a21b9b9aa6856b419ca0d22897f960c25; the QA catalog reference check also passed in 5.14 seconds.
  • oxfmt --check and git diff --check passed on the changed files.
Production CLI observations

The contributor recorded isolated pnpm openclaw config get runs at 5df3d43d34d with synthetic config state. A minimal config returned its model; existing configs with 600-level and 2,000-level values under agents.defaults.params returned the expected leaves with exit code 0. The 600-level case preserves a configuration accepted before this repair. Separate detector, cloning, and serialization stages can still limit deeper end-to-end operations.

@clawsweeper

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

@ruel225
ruel225 marked this pull request as ready for review September 19, 2026 13:14
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 6:17 AM ET / 10:17 UTC (Revision 15).

ClawSweeper review

What this changes

The branch makes configuration include resolution traverse nested objects and arrays on an explicit work stack and adds deep-nesting regression tests.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. Current main still walks nested configuration recursively during include resolution, and the branch addresses that distinct failure. The separate pre-scan, later load, and write limitations are tracked in related items; review found no definite defect introduced by this patch.

Priority: P2
Reviewed head: 96b61013c392d51c8a430ae81a86d15a32a0760d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused owner-level repair, regression coverage, and recorded CLI behavior support a normal good PR rating.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The changed production owner is the config include resolver. The contributor records after-fix openclaw config get output from an isolated synthetic setup at 600 and 2,000 levels, alongside baseline failures and changed-branch deep resolver results; the CLI trace demonstrates usable config loading at the exercised depths. The final commit changes test descriptions, and no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed production owner is the config include resolver. The contributor records after-fix openclaw config get output from an isolated synthetic setup at 600 and 2,000 levels, alongside baseline failures and changed-branch deep resolver results; the CLI trace demonstrates usable config loading at the exercised depths. The final commit changes test descriptions, and no stored-data contract changes.
Evidence reviewed 7 items Current main still has the reported recursion: The current-main resolver calls itself for array items and object values, so the central fix is not already on main.
Introduced traversal: The introduced patch moves suspended container traversal onto a work stack while retaining a separate include-chain limit.
Existing include safeguards: The branch still checks include ancestry and depth, resolves paths relative to the including file, and keeps path-containment checks in the file-loading path.
Findings None None.
Security None None.

How this fits together

OpenClaw parses configuration files and resolves $include directives before later loading stages validate and use the result. The include resolver receives parsed values and included files, then produces a combined configuration and include-ownership events.

flowchart LR
  A[Parsed configuration] --> B[Include resolver]
  C[Included files] --> B
  B --> D{Include directive?}
  D -->|Yes| E[Check path and include chain]
  E --> F[Resolved configuration]
  D -->|No| F
  F --> G[Later config loading]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +79, Tests +67. Total +146 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 179 100 +79
Tests 1 68 1 +67
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 247 101 +146

Review metrics

Metric Value Why it matters
Production and test delta production +79 lines net; tests +67 lines net The production growth supports explicit traversal frames; the added tests target the reported depth failure.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #152847
Summary: This PR is a candidate repair for the original include-resolver crash. Related open items cover either a competing depth-cap approach or distinct recursive stages of config handling.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land the stack-safe include resolver as its own repair while the separately owned config pre-scan, load, and write stages are reviewed through their linked work.

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

Yes, with high confidence from current-main source: nested objects and arrays recurse once per level in the include resolver. The contributor also records failing deep controls on a pinned main revision; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Moving traversal frames into the existing resolver repairs its stack limit without imposing a new configuration depth cap or changing the documented include-chain limit.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded configuration-loading crash fix with a clear owner, limited surface, and related follow-up work for other stages.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed production owner is the config include resolver. The contributor records after-fix openclaw config get output from an isolated synthetic setup at 600 and 2,000 levels, alongside baseline failures and changed-branch deep resolver results; the CLI trace demonstrates usable config loading at the exercised depths. The final commit changes test descriptions, and no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the config include resolver. The contributor records after-fix openclaw config get output from an isolated synthetic setup at 600 and 2,000 levels, alongside baseline failures and changed-branch deep resolver results; the CLI trace demonstrates usable config loading at the exercised depths. The final commit changes test descriptions, and no stored-data contract changes.

Evidence

What I checked:

  • Current main still has the reported recursion: The current-main resolver calls itself for array items and object values, so the central fix is not already on main. (src/config/includes.ts:190, 6e5577f6f3d1)
  • Introduced traversal: The introduced patch moves suspended container traversal onto a work stack while retaining a separate include-chain limit. (src/config/includes.ts:221, 96b61013c392)
  • Existing include safeguards: The branch still checks include ancestry and depth, resolves paths relative to the including file, and keeps path-containment checks in the file-loading path. (src/config/includes.ts:381, 96b61013c392)
  • Regression coverage: The new tests exercise deep objects, deep arrays, and nesting across an included file; existing include tests cover merging, ownership events, and path guards. (src/config/includes.top-level-key.test.ts:89, 96b61013c392)
  • Contributor runtime evidence: The reviewed PR body records isolated openclaw config get runs on the iterative branch: synthetic 600-level and 2,000-level values returned the expected leaves. Its separate baseline and changed-branch resolver cases report the deep failure and recovery; those tests supplement the CLI observation. (96b61013c392)
  • Feature history: The include path has prior merged work on ownership reporting and nested include writes; this supports routing to those area contributors without assigning fault for the stack overflow. (src/config/includes.ts, 66714b862267)

Likely related people:

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

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (14 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T04:30:43.480Z sha 5df3d43d34d71546b0a982c063af7e7ad1d39755 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-23T09:54:48.765Z sha 5df3d43d34d71546b0a982c063af7e7ad1d39755 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T12:00:29.066Z sha ec24316a366d31fa7677e9abd026523c260b06ff :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T12:26:32.322Z sha e74d9945f3a70846277fa06f1469c9ad47728e22 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T21:03:45.782Z sha ee4fac4a357eb57eea6663ee13c3c6301d590181 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T21:55:42.006Z sha ca74e83c5460b4d51b30f4faf41e573c453c1b87 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T07:27:37.847Z sha 971fe2143f1c88ae3db4405b5fdfb9e20bac00c2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T08:21:30.723Z sha 292e084d89fa245374b836c6f764c23fdfd28d03 :: needs maintainer review before merge. :: none

@ruel225 ruel225 changed the title fix(config): reject config object nesting past the resolver's depth budget fix(config): resolve deep config nesting on an explicit work stack Sep 19, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 19, 2026
@altaywtf
altaywtf force-pushed the fix/config-include-object-depth branch from 5df3d43 to ec24316 Compare September 26, 2026 11:40
@altaywtf
altaywtf marked this pull request as draft September 26, 2026 11:53
@altaywtf
altaywtf marked this pull request as ready for review September 26, 2026 11:53
@altaywtf
altaywtf force-pushed the fix/config-include-object-depth branch 4 times, most recently from ca74e83 to 971fe21 Compare September 27, 2026 07:21
@altaywtf
altaywtf force-pushed the fix/config-include-object-depth branch from 971fe21 to 292e084 Compare September 27, 2026 08:15
ruel225 and others added 8 commits September 27, 2026 13:10
…udget

resolveConfigIncludes recurses one frame per object/array level inside a
document. The $include file chain has a depth cap, but the traversal within a
single file has none, so a deeply nested config (no $include required) dies
with RangeError: Maximum call stack size exceeded during config load. Give the
resolver a single nesting budget - shared across the include file chain so
chained files cannot re-accumulate frames - and answer pathological documents
with a ConfigIncludeError naming the depth and logical path instead of a stack
overflow. Real-world configs sit in the tens of levels, far under the cap.

Fixes openclaw#152847

Co-Authored-By: Claude <[email protected]>
…-large-10

The music-generation runtime.resources test failed with a duplicate
'database is not open' hook error on identical code that passed the same
shard three hours earlier; no production file in this PR touches that
suite.

Co-Authored-By: Claude <[email protected]>
The include resolver walked containers recursively, so deeply nested
config documents died with RangeError instead of loading, and the fixed
512 budget answered that with a compat regression of its own, rejecting
schema-valid documents the recursive resolver had accepted (600- and
2000-level values under agents.defaults.params load on main today).

Traverse on an explicit work stack instead: each container becomes a
suspended generator frame resumed by the process() driver, so document
depth costs heap rather than call frames. The objectDepth counter and
its cap are gone; the $include file chain keeps MAX_INCLUDE_DEPTH plus
cycle detection. Include events, error ordering, circular detection,
and relative-path resolution against the including file are preserved.

Co-Authored-By: Claude <[email protected]>
…test file

The dedicated deep-config spec file pushed the config-cli tsgo shard to
701 test roots, one over its 700 cap, breaking the shard partition check.
Fold the five deep-nesting cases into includes.top-level-key.test.ts,
which already owns the resolver mock helpers, so the shard returns to its
budget without losing coverage.

Co-Authored-By: Claude <[email protected]>
…-large-27

sessions-reset-subagent-cleanup leaked-residual-roots assertion is
unrelated to this config-include change (touches src/config only).

Co-Authored-By: Claude <[email protected]>
@altaywtf
altaywtf force-pushed the fix/config-include-object-depth branch from 292e084 to 96b6101 Compare September 27, 2026 10:10
@altaywtf
altaywtf merged commit 4a56758 into openclaw:main Sep 27, 2026
201 checks passed
@altaywtf

Copy link
Copy Markdown
Member

Merged as 4a56758 from 96b6101. Deep config resolution uses an explicit work stack. CI and ClawSweeper were green; source autoreview and scoped proof were clean. Contributor credit is preserved.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
…#152889) thanks @ruel225

Resolve deeply nested configuration with an explicit work stack while preserving include handling and error behavior.

CI and ClawSweeper passed on the merged head. Source autoreview and scoped proof remain valid for the unchanged reviewed patch.

Co-authored-by: ruel225 <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Altay <[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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Config $include resolution recursively walks nested JSON with no depth limit

2 participants