Skip to content

fix(config): write mixed include-owned catalogs and agent entries without flattening - #150348

Closed
sasan1200 wants to merge 32 commits into
openclaw:mainfrom
sasan1200:fix/include-write-through
Closed

sasan1200 wants to merge 32 commits into
openclaw:mainfrom
sasan1200:fix/include-write-through

Conversation

@sasan1200

@sasan1200 sasan1200 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

  • Mixed root settings, include-owned agent entries, and provider catalogs currently fail with CONFIG_INCLUDE_OWNERSHIP.

User Impact

  • Save mixed changes through the shared config writer while preserving $include pointers, ${VAR} references, and authored tilde paths.
  • Validate the complete change before publication; refuse revoked requesters and restore published files only while their committed bytes still match.
  • An uncatchable process interruption can leave a partial write requiring manual recovery.
  • Recoverable backup failures emit the existing recovery warning while mixed saves continue; skipOutputLogs suppresses output.

Why This Change Was Made

  • Reuse the existing include I/O owner and current config publication, Doctor receipt, runtime activation, and health-baseline compensation contracts.
  • Preserve the backup-failure recovery contract used by root and single-include writes.

Evidence

  • Head: 78c5ad6653ab5e674e14721cbf127de9502affe7.

  • Real CLI backup-failure captures below use an immutable included-catalog backup. Fixture paths are replaced by <state>; final JSON lines report driver checks of persisted files and backup bytes.

  • Baseline:

HEAD 4e5df281b9928a8425b4f884c905cae52cbc4388
OpenClaw 2026.10.9 (4e5df28)
MIXED SAVE STDOUT:
Applied 3 config update(s). Change will apply without restarting the gateway.
MIXED SAVE STDERR:
$ node scripts/run-node.mjs config patch --file <state>/patch.json
{"warningObserved": false, "mixedSavePersisted": true, "immutableBackupPreserved": true, "unlockedControlRotatedBackup": true}
  • Candidate:
HEAD 78c5ad6653ab5e674e14721cbf127de9502affe7
OpenClaw 2026.10.9 (78c5ad6)
MIXED SAVE STDOUT:
Applied 3 config update(s). Change will apply without restarting the gateway.
MIXED SAVE STDERR:
$ node scripts/run-node.mjs config patch --file <state>/patch.json
Config backup rotation failed; the config write is continuing without a guaranteed current backup. Before making further config changes, create and verify a backup with `openclaw backup create --verify`.
{"warningObserved": true, "mixedSavePersisted": true, "immutableBackupPreserved": true, "unlockedControlRotatedBackup": true}
  • The warning includes openclaw backup create --verify; the mixed save succeeds, the immutable backup remains intact, and the unlocked control creates the current backup without a warning.

  • The new regression fails on 4e5df281b9928a8425b4f884c905cae52cbc4388 because the warning is absent. It also checks persisted root/include values, path-free output, and suppression for silent writes.

  • Retained-state CLI checks use the same config, includes, and workspace files across the published and candidate binaries. Candidate client-credential preparation uses doctor --client-credentials --fix --non-interactive --json.

  • Commands: config validate --json, mixed config patch --file, invalid config patch --file, then config validate --json. The invalid patch retains existing model IDs and fails the baseUrl schema check.

  • The following assertion-driver output wraps real CLI calls; booleans report persisted JSON and SHA-256 checks of config, backups, and workspace files. Each banner comes from the invoked binary.

  • Published 2026.10.6 before:

HEAD fe06181dc5ecc01cf8904abbfc26925925efefbc
OpenClaw 2026.10.6 (fe06181)
{"publishedVersion": "2026.10.6", "existingConfigValid": true, "mixedWriteRefused": true, "configAndWorkspaceUnchanged": true}
  • Candidate using retained 2026.10.6 state:
HEAD 78c5ad6653ab5e674e14721cbf127de9502affe7
OpenClaw 2026.10.9 (78c5ad6)
{"upgradedFrom": "2026.10.6", "existingConfigLoaded": true, "mixedSavePersisted": true, "includeOwnersPreserved": true, "authoredReferencesPreserved": true, "primaryModelPreserved": true, "workspaceDataUnchanged": true, "invalidWriteAndBackupsUnchanged": true}
  • Published 2026.10.9 before:
HEAD 8b18b5578f66eab1501cba4cef2310d88bfb9a41
OpenClaw 2026.10.9 (8b18b55)
{"publishedVersion": "2026.10.9", "existingConfigValid": true, "mixedWriteRefused": true, "configAndWorkspaceUnchanged": true}
  • Candidate using retained 2026.10.9 state:
HEAD 78c5ad6653ab5e674e14721cbf127de9502affe7
OpenClaw 2026.10.9 (78c5ad6)
{"upgradedFrom": "2026.10.9", "existingConfigLoaded": true, "mixedSavePersisted": true, "includeOwnersPreserved": true, "authoredReferencesPreserved": true, "primaryModelPreserved": true, "workspaceDataUnchanged": true, "invalidWriteAndBackupsUnchanged": true}
  • Persisted checks retain root $include directives, ${PR_MODEL_NAME}, tilde workspace paths, the primary model, and workspace file bytes. Invalid writes leave config files and backups unchanged.
  • Required regression command: pnpm test src/config/config.backup-rotation.test.ts src/config/include-write-through.publish.test.ts --maxWorkers=1.
  • Focused suite: seven files, 67 cases passed at this head. Commands use --maxWorkers=1; wall times include command preparation.
Test files Cases Wall time
src/config/config.backup-rotation.test.ts, src/config/include-write-through.publish.test.ts 33 44.05 s
src/config/include-write-through.test.ts 2 7.21 s
src/config/include-write-through.restore-authority.test.ts 4 9.11 s
src/config/include-write-through.runtime-fence.test.ts 14 12.24 s
src/cli/update-cli/update-command-mixed-include-rollback.test.ts 4 10.90 s
src/gateway/server.config-security-policy.test.ts 10 28.25 s
Total 67 111.76 s
  • pnpm build: exit 0 at this head, 131.96 s; CSS/chat-boot asset budgets report nonfatal violations.
  • Targeted lint/format, core and affected test types, line-cap and test-line checks, and contribution whitespace checks passed on the committed source tree.
  • Hosted CI time is pending; current results are available in the PR checks.

Closes #150353

…hout flattening

Configure writeback was flattening or refusing $include-owned agent entries and
provider catalogs when the same persist also changed root auth or allowlists.
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 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-09-16T22:40:03.685098Z fa02648 PR opened
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

[configWritePostCommitRollback]: (assertCurrent) => {
assertCurrent();
restoreConfigSnapshotAuditRecord({
env: deps.env,
homedir: deps.homedir,
snapshot: priorSnapshotAuditRecord,
expectedSnapshot: writtenSnapshotAuditRecord,
});

P1 Badge Include keyed files in post-commit rollback

When finalizeRuntimeSnapshotWrite fails, src/config/io.runtime.ts:675-701 rolls the root config back and invokes this compensation hook, but the hook restores only audit and warning state. Any keyed agent or catalog files written earlier therefore retain their new values while the root returns to its old bytes, leaving disk and runtime in a mixed revision after a post-commit refresh failure; the include writes need guarded compensation in this rollback path as well.

AGENTS.md reference: AGENTS.md:L95-L96

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/io.write-prepare.ts Resolved
Comment thread src/config/io.write.ts Resolved
Comment thread src/config/io.write.ts Resolved
@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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR saves mixed root settings, include-owned agent entries, and provider catalogs while preserving their authored include directives.

Example: Add qwen3 to models.json5 while updating the Ollama API key and root model allowlist.

  • Before: The save fails with CONFIG_INCLUDE_OWNERSHIP and leaves the files unchanged.
  • After: The catalog receives qwen3, root settings are saved, and the root retains its $include pointer.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The supplied CLI and upgrade evidence covers the changed behavior, prior findings are addressed, and required exact-head CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Reviewed-head CLI captures exercise mixed publication and backup-warning behavior; retained-state runs cover latest-stable upgrade compatibility, while the recorded real-Gateway suite exercises token revocation before publication and verifies unchanged config and backups.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users cannot save combined root and eligible include-owned config changes through normal config commands or Doctor.
Reason: The failure remains on main, and the recorded maintainer decision accepts the implementation's bounded interruption-recovery behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a current mixed-owner config-write failure, resolves the previous backup-warning finding, and has no remaining actionable findings from this review.

Priority: P2
Reviewed head: 78c5ad6653ab5e674e14721cbf127de9502affe7

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI, Doctor, and Gateway config mutations enter the shared config writer, which validates the combined configuration, publishes owned files, and supplies guarded rollback and runtime-activation results.

flowchart TD
  A[CLI Doctor or Gateway mutation] --> B[Shared config writer]
  B --> C[Resolve ownership and stage includes]
  C --> D[Validate combined configuration]
  D --> E[Guarded include publication]
  E --> F[Root publication and runtime activation]
  E --> G[Conditional compensation]
  F --> G
Loading

Technical review

Best possible solution:

Land the shared-writer repair with its existing authority, conditional compensation, and accepted interruption-recovery contract after required CI passes.

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

The linked report gives a concrete mixed catalog/root patch, current main retains the refusing ownership path, and supplied stable-release CLI captures report the same refusal; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The implementation addresses the shared persistence boundary, reuses existing target I/O and publication guards, and preserves the maintainer-approved recovery tradeoff without adding configuration options.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Include ownership and mixed writes changes intended behavior with a stated reason (05182b6: Select the deepest sole owner while refusing ambiguous ownership and multi-owner mutations.)
  • Config I/O and audit extraction keeps the original intent (290836c: Split config I/O responsibilities while retaining the public facade and runtime contracts.)
  • Update authority and compensation keeps the original intent (1232d3f: Retain live source authority through candidate Doctor writes and identity-aware rollback.)
  • Backup-failure warnings keeps the original intent (a3283f7: Continue recoverable config writes while warning that the current backup is not guaranteed and naming a recovery command.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 290836c adds src/config/io.write.ts:71 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 290836cafd2c; files: src/config/io.write.ts)
  • Vincent Koc: Raw commit 1232d3f adds src/config/io.write.ts:536 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1232d3f13ec0; files: src/config/io.write.ts)

PR surface

Source +863, Tests +2581, Docs +20, Other +1. Total +3465 across 18 files. Added test files: 5.

View PR surface stats
Area Files Added Removed Net
Source 9 1040 177 +863
Tests 7 2587 6 +2581
Docs 1 27 7 +20
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 18 3655 190 +3465

Review metrics

Metric Value Why it matters
Production versus test LOC Production +1040/-177; tests +2587/-6 The growth covers multi-file staging, existing publication guards, compensation, and distinct config, runtime, requester-revocation, and update-rollback boundaries.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #150353
Summary: The canonical issue owns mixed include/root persistence; this PR is its open implementation.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The failure affects config saves using specific include-owned agent and provider-catalog layouts.
  • merge-risk: 🚨 compatibility: The writer now publishes multiple persisted config files; stable-upgrade evidence is supplied, and the maintainer explicitly accepted the bounded interruption window.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (39 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-06T03:57:37.020Z sha a05a17e :: needs changes before merge. :: none
  • reviewed 2026-10-18T20:09:13.006Z sha d0549fa :: needs real behavior proof before merge. :: [P1] Check requester admission before publishing each include
  • reviewed 2026-10-19T15:07:14.860Z sha a923723 :: needs changes before merge. :: [P2] Record Doctor receipts for mixed include publications
  • reviewed 2026-10-19T15:16:42.346Z sha a923723 :: needs changes before merge. :: [P2] Record Doctor receipts for mixed include publications
  • reviewed 2026-10-19T16:03:05.906Z sha 71ba37b :: needs changes before merge. :: [P2] Reuse the existing include target I/O helpers
  • reviewed 2026-10-19T16:39:01.596Z sha 25d08f6 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-22T23:30:08.385Z sha 502f7cc :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-02T18:26:43.476Z sha 4e5df28 :: needs changes before merge. :: [P2] Forward backup-failure warnings from mixed include publications

Reviewed November 2, 2026, 2:19 PM ET / 19:19 UTC (Revision 40).

Mixed root+include persists staged the include bytes to disk before
validation and preflight, from resolved config values, with no lock,
hash fence, batch unwinding, post-commit rollback, or per-effect
authority asserts. Include publication now has one owner,
src/config/include-write-through.ts: stage in memory, validate and
hash the staged bytes through an include read overlay, publish inside
the guarded commit window before the root under a per-target lock with
a hash fence and incremental restorers, restore-only-if-unchanged on
failure including runtime-finalization rollback, and project staged
values onto the authored include so env-var references survive.
mutate.ts imports the shared primitives instead of private copies.
Docs state the bounded contract.
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Sep 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Sep 17, 2026
…ilde findings

Pass the caller's live authority when acquiring the include write lock so an
authorized mixed save can publish. Track the copy-fallback removal before
publish() can throw and register a null-content restorer for it. Authorize
include restoration on the original source owner instead of active config
selection. Preserve authored tilde paths in staged agent-entry includes.
…n copy-fallback failure, align doctor docs

Post-commit include rollback now authorizes on the caller-supplied assertCurrent
(the outer, still-live lock guard) instead of sourceGuard, which is scoped to
createConfigIO's nested lock and already closed by rollback time under an
ambient guarded owner (mutation flows). The copy-fallback removal-then-throw
path now force-restores the pre-publish bytes instead of comparing against a
committed hash no partial recreate can match. Doctor docs no longer claim mixed
root/include repairs are refused as a whole.
@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 17, 2026
… the target

Remove the H3 forceRestore/force bypass: it restored unconditionally, so a
writer that saved newer content in the gap between a failed include publish
and restoration running had its save clobbered. The catch under the
still-held per-target lock now captures the actual post-failure state of the
target (missing, or whatever the copy fallback partially recreated) as the
restorer's committed hash. Restoration proceeds only if the file still
matches that captured damage; a concurrent save after the failure makes the
fence miss and survives untouched.
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 17, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 17, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@sasan1200

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 2, 2026
@sasan1200

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed 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 Nov 2, 2026
@sasan1200

Copy link
Copy Markdown
Contributor Author

Not planned.

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

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: XL 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]: Mixed config writes flatten-refuse include-owned provider catalogs

2 participants