Skip to content

refactor(config): split write preparation primitives - #114228

Merged
steipete merged 1 commit into
mainfrom
codex/config-write-primitives
Jul 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/config-write-primitives

Conversation

@steipete

@steipete steipete commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The config writer currently owns generic merge-patch, path-mutation, changed-path, environment-restoration, and error-formatting primitives. That makes the write-preparation module harder to reason about and blocks the approved config write-intent redesign.

Why This Change Was Made

This behavior-neutral first step moves each primitive to its natural owner while preserving the existing signatures and call behavior. It does not change config write semantics; it creates narrow ownership boundaries for the follow-up compatibility-sensitive work.

AI-assisted implementation; the maintainer-requested redesign is being delivered as a reviewed PR series.

User Impact

No user-visible behavior change. Config writes, validation text, environment reference preservation, managed unsets, and audit path reporting remain unchanged.

Evidence

  • Real isolated CLI write on Blacksmith Testbox tbx_01kygmhvxy5271c9bvv07pm8sw: starting from an authored ${OC_TEST_WORKSPACE} workspace and gateway port 18789, openclaw config set gateway.port 19001 reported Updated gateway.port. Restart the gateway to apply. The persisted redacted result was {"gatewayPort":19001,"workspace":"${OC_TEST_WORKSPACE}"}, proving the explicit change and untouched env reference both survived. Run: https://github.com/openclaw/openclaw/actions/runs/30230937093
  • Managed-unset real-setup caveat: plugins.installs is deliberately rejected by the public config schema, so it cannot be seeded into a valid authored CLI setup. A probe confirmed the expected rejection and openclaw doctor --fix remediation. The internal transient-path behavior is instead covered by the passing strips transient plugin install records from partial writes regression in src/config/io.write-prepare.test.ts.
  • node scripts/run-vitest.mjs src/config/merge-patch.test.ts — 8 tests passed
  • node scripts/run-vitest.mjs src/config/io.write-prepare.test.ts — 95 tests passed
  • node scripts/run-vitest.mjs src/config/env-preserve.test.ts — 72 tests passed
  • node scripts/run-vitest.mjs src/gateway/config-reload.test.ts — 155 tests passed after CI exposed a watcher timing flake
  • Exact-head CI run 30230182067 attempt 2 — successful, including the targeted rerun of checks-node-compact-large-2: https://github.com/openclaw/openclaw/actions/runs/30230182067/attempts/2
  • node scripts/check-changed.mjs -- <19 touched files> — remote Blacksmith Testbox run passed all selected guards, core/core-test typechecks, import-cycle checks, and core lint shards: https://github.com/openclaw/openclaw/actions/runs/30229182061
  • $HOME/.claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean, no accepted/actionable findings
  • git diff --check origin/main...HEAD — clean

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations labels Jul 27, 2026
@steipete steipete self-assigned this Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 01:36
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Jul 27, 2026
@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 9:40 PM ET / July 27, 2026, 01:40 UTC.

ClawSweeper review

What this changes

This PR moves merge-patch generation, config-path mutation, changed-path reporting, environment-reference restoration, and write-error formatting out of the config write-preparation module into focused modules while updating their callers.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 6 items remain

Keep this PR open for maintainer review. Its focused helper extraction appears consistent with the stated behavior-neutral config-write refactor, but it touches compatibility-sensitive persistence paths, has one failed compact CI shard, and the submitted evidence is test/CI-only rather than an after-fix real config-write run.

Priority: P3
Reviewed head: 36171a3c511b888bdc3c12e6e95a2e2c35652387
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused validation look solid for a refactor, but test-only evidence leaves the required real behavior proof gate unmet.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports focused tests, static checks, and CI, but it does not include an after-fix run through a real config-write setup; add a redacted CLI, gateway, or setup transcript showing the resulting persisted config and preserved environment references. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused tests, static checks, and CI, but it does not include an after-fix run through a real config-write setup; add a redacted CLI, gateway, or setup transcript showing the resulting persisted config and preserved environment references. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Extracted write-preparation ownership: The branch creates focused modules for changed-path collection, path mutation, and write-error formatting, and updates config write callers to import those primitives from their new owners.
Config writer integration: The config write path now composes path mutation, environment-reference restoration, and validation formatting from the dedicated modules while retaining orchestration in the write module.
Focused regression coverage reported: The PR body reports passing focused suites for merge patches, write preparation, and environment preservation, plus a changed-surface remote guard run; this is useful regression evidence but not real behavior proof.
Findings None None.
Security None None.

How this fits together

OpenClaw’s configuration write pipeline receives updates from CLI commands, gateway RPC, setup flows, and plugin management, then validates and persists the canonical config while preserving environment references and managed fields. This refactor separates reusable preparation steps from the write orchestrator without intending to change the persisted result.

flowchart LR
  A[CLI, gateway, setup, plugins] --> B[Config write pipeline]
  B --> C[Merge patch and path mutation]
  B --> D[Environment reference preservation]
  B --> E[Validation error formatting]
  C --> F[Validated config persistence]
  D --> F
  E --> G[Operator-facing failure output]
  F --> H[Runtime and audit snapshots]
Loading

Decision needed

Question Recommendation
Should this behavior-neutral prerequisite refactor land in the approved config write-intent series after the failed CI shard and a real config-write equivalence proof are reviewed? Require equivalence proof before merge: Resolve or explain the failed compact check and add a redacted real write transcript that demonstrates unchanged persisted output and error behavior.

Why: The PR carries the protected maintainer label and refactors compatibility-sensitive config persistence primitives, so maintainer intent is needed to confirm the series boundary and acceptable proof.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused tests, static checks, and CI, but it does not include an after-fix run through a real config-write setup; add a redacted CLI, gateway, or setup transcript showing the resulting persisted config and preserved environment references. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - This refactor changes helper ownership across config persistence, gateway patching, CLI setup, and plugin management; a subtle import or semantic drift could alter existing users’ saved configuration, managed unsets, or environment-reference preservation.
  • Resolve merge risk (P1) - The GitHub check set includes a completed failure for checks-node-compact-large-2; its cause is not present in the supplied context and should be resolved or shown unrelated before merge.
  • Resolve merge risk (P1) - The PR body provides focused tests and CI results but no real after-fix config-write transcript proving an unchanged persisted config result through an actual CLI, gateway, or setup write path.
  • Complete next step (P2) - A protected maintainer-owned config refactor needs human confirmation of the series boundary, a resolved CI result, and contributor-supplied real behavior proof rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +14, Tests -3. Total +11 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 18 379 365 +14
Tests 1 6 9 -3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 385 374 +11

Review metrics

Metric Value Why it matters
Public config surface 0 added, changed, or removed documented config keys or defaults The branch is intended as an internal ownership refactor, so preserving existing persisted-config behavior is the key merge criterion.

Merge-risk options

Maintainer options:

  1. Prove write-path equivalence before merge (recommended)
    Attach a redacted real config-write run, then resolve or document the failed compact shard so the extracted helpers are proven against both persisted output and CI.
  2. Pause the series step
    Pause this branch if maintainers do not want to accept a broad config-write ownership move without direct upgrade-equivalence evidence.

Technical review

Best possible solution:

Land the refactor only after a maintainer confirms the failed CI shard is unrelated or fixed and the PR includes a redacted before/after real config-write proof showing preserved environment references, managed unsets, and validation behavior.

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

Not applicable: this is a refactor rather than a reported bug. The relevant verification is equivalence of real config-write behavior across existing CLI, gateway, setup, and plugin-management paths.

Is this the best way to solve the issue?

Unclear: extracting primitives to focused owners is a maintainable direction, but the available evidence does not yet prove the full real write path is behaviorally equivalent or explain the failed compact CI shard.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0ac926b8fb2a.

Labels

Label changes:

  • add P3: This is a behavior-neutral internal refactor rather than a reported user-facing regression or new product capability.
  • add merge-risk: 🚨 compatibility: The changed helpers participate in persisted config updates, managed unsets, validation output, and environment-reference restoration used by existing setups.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests, static checks, and CI, but it does not include an after-fix run through a real config-write setup; add a redacted CLI, gateway, or setup transcript showing the resulting persisted config and preserved environment references. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a behavior-neutral internal refactor rather than a reported user-facing regression or new product capability.
  • merge-risk: 🚨 compatibility: The changed helpers participate in persisted config updates, managed unsets, validation output, and environment-reference restoration used by existing setups.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests, static checks, and CI, but it does not include an after-fix run through a real config-write setup; add a redacted CLI, gateway, or setup transcript showing the resulting persisted config and preserved environment references. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Extracted write-preparation ownership: The branch creates focused modules for changed-path collection, path mutation, and write-error formatting, and updates config write callers to import those primitives from their new owners. (src/config/config-path-mutation.ts:1, 36171a3c511b)
  • Config writer integration: The config write path now composes path mutation, environment-reference restoration, and validation formatting from the dedicated modules while retaining orchestration in the write module. (src/config/io.write.ts:8, 36171a3c511b)
  • Focused regression coverage reported: The PR body reports passing focused suites for merge patches, write preparation, and environment preservation, plus a changed-surface remote guard run; this is useful regression evidence but not real behavior proof. (src/config/io.write-prepare.test.ts:1, 36171a3c511b)
  • Current review-state check: GitHub context reports one completed failure for checks-node-compact-large-2 while other config-boundary and selected guard checks passed; the failing shard needs inspection before merge. (36171a3c511b)
  • Repository policy applied: The target AGENTS.md treats config writes, validation, managed paths, environment preservation, and fallback behavior as compatibility-sensitive, so this refactor needs preservation proof beyond import rewiring. (AGENTS.md:1, 0ac926b8fb2a)

Likely related people:

  • steipete: The PR context identifies steipete as the sole branch author, assignee, and the person delivering the described maintainer-requested config write-intent series; local feature-history commands were unavailable in this read-only environment. (role: current config-write refactor author and assigned review owner; confidence: low; commits: 36171a3c511b; files: src/config/io.write.ts, src/config/io.write-prepare.ts, src/config/config-path-mutation.ts)

Rank-up moves

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

  • Add a redacted real config-write before/after transcript covering environment-reference preservation and managed unsets.
  • Resolve or link the cause of checks-node-compact-large-2 before merge.

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
steipete merged commit e9ef30e into main Jul 27, 2026
311 of 323 checks passed
@steipete
steipete deleted the codex/config-write-primitives branch July 27, 2026 02:00
@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

cli CLI command changes commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant