Repository navigation
fix(config): reject auto-managed meta.lastTouched* paths in config set/unset - #80856
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Source inspection on current main shows config writes are stamped after CLI mutations, and the PR discussion includes terminal output showing the false-success behavior before the patch. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the CLI-boundary rejection after the branch is made mergeable and targeted config CLI/config metadata tests pass on the final head, while preserving automatic stamping as the system-owned writer for Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows config writes are stamped after CLI mutations, and the PR discussion includes terminal output showing the false-success behavior before the patch. Is this the best way to solve the issue? Yes. Rejecting user edits to documented auto-managed fields at the CLI boundary is narrower than changing stamping semantics, and the latest diff covers direct, descendant, and ancestor clobber paths without changing unrelated config writes. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against da23f4572da7. |
Review: Needs ChangesOverall direction is correct. Rejecting auto-managed paths at the CLI boundary — rather than trying to preserve user values through That said, the implementation is incomplete and the ClawSweeper review findings still need to be addressed before merge. What's good
What needs to changeThe parent-path bypass is not closed. Both
This is the same defect class the PR is trying to eliminate — success-shaped output with silently overwritten state. Recommended fix:
ClawSweeper findingsThe ClawSweeper review flagged the same parent-path gap at P2 confidence 0.88 and rated the patch as incorrect. That finding hasn't been resolved yet. I'm supportive of the fix — just need the parent-path case handled so the false-success class is fully closed. |
f855f8e to
152ea9a
Compare
152ea9a to
1111b29
Compare
1111b29 to
3fdc433
Compare
|
Verified end-to-end against the live config from #80849. Linux 6.8.0-110-generic, Node 22.22.2. PR head: Test matrix
Error message shape (Test 1, verbatim)Ancestor-clobber rejection (Test 10, verbatim)Multi-path rendering correctly names both managed leaves when an ancestor mutation would clobber both. Boundary sanity (Tests 7 and 11)Both errors are from the schema validator, not the auto-managed check. Disk preservation
Sanity — unrelated path still writes (Test 5)Full live capture — 12 tests, verbatim CLI output, exit codes, disk inspectionsCloses #80849. |
…t/unset openclaw config set meta.lastTouchedVersion <value> and the matching meta.lastTouchedAt write printed Updated ... Restart the gateway to apply. and produced a new config sha256, but stampConfigVersion in src/config/io.ts re-stamped both fields on every write so the user's value never reached disk. Reject the write at the CLI boundary instead, mirroring the existing precedent for plugins.installs: operations whose requestedPath sits at, below, OR ABOVE an auto-managed leaf now throw a clear auto-managed error. Ancestor-path mutations are inspected for the auto-managed children — a merge with an auto key in the payload is rejected, a replace or set-at-ancestor that would clobber every descendant is rejected, and config unset of the meta parent is rejected because deleting it removes the managed leaves. config patch / batch operations route through the same runConfigOperations gate; config unset routes through runConfigUnset with the equivalent check. Covers @hxy91819's parent-path bypass review (#80856).
…t/unset openclaw config set meta.lastTouchedVersion <value> and the matching meta.lastTouchedAt write printed Updated ... Restart the gateway to apply. and produced a new config sha256, but stampConfigVersion in src/config/io.ts re-stamped both fields on every write so the user's value never reached disk. Reject the write at the CLI boundary instead, mirroring the existing precedent for plugins.installs: operations whose requestedPath sits at, below, OR ABOVE an auto-managed leaf now throw a clear auto-managed error. Ancestor-path mutations are inspected for the auto-managed children — a merge with an auto key in the payload is rejected, a replace or set-at-ancestor that would clobber every descendant is rejected, and config unset of the meta parent is rejected because deleting it removes the managed leaves. config patch / batch operations route through the same runConfigOperations gate; config unset routes through runConfigUnset with the equivalent check. Covers @hxy91819's parent-path bypass review (openclaw#80856).
71f74eb to
a574312
Compare
|
Merged via squash.
Thanks @ai-hpc! |
…t/unset (openclaw#80856) Merged via squash. Prepared head SHA: a574312 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
…t/unset (openclaw#80856) Merged via squash. Prepared head SHA: a574312 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
…t/unset (openclaw#80856) Merged via squash. Prepared head SHA: a574312 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
…t/unset (openclaw#80856) Merged via squash. Prepared head SHA: a574312 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
…t/unset openclaw config set meta.lastTouchedVersion <value> and the matching meta.lastTouchedAt write printed Updated ... Restart the gateway to apply. and produced a new config sha256, but stampConfigVersion in src/config/io.ts re-stamped both fields on every write so the user's value never reached disk. Reject the write at the CLI boundary instead, mirroring the existing precedent for plugins.installs: operations whose requestedPath sits at, below, OR ABOVE an auto-managed leaf now throw a clear auto-managed error. Ancestor-path mutations are inspected for the auto-managed children — a merge with an auto key in the payload is rejected, a replace or set-at-ancestor that would clobber every descendant is rejected, and config unset of the meta parent is rejected because deleting it removes the managed leaves. config patch / batch operations route through the same runConfigOperations gate; config unset routes through runConfigUnset with the equivalent check. Covers @hxy91819's parent-path bypass review (openclaw#80856).
Summary
openclaw config set meta.lastTouchedVersion <value>andopenclaw config set meta.lastTouchedAt <value>printUpdated meta.lastTouched…. Restart the gateway to apply.and produce a new config sha256, but the on-disk value is never the user's value —stampConfigVersionatsrc/config/io.ts:897-908is called unconditionally atsrc/config/io.ts:2114and re-stamps both fields with the current packageVERSIONand a fresh ISO timestamp on every write. Theconfig setandconfig unsetCLI handlers don't gate against these auto-managed paths, so the success indicator is decoupled from whether the user's value actually persisted.#79856(config set returns success while discarding values that match schema defaults), but a distinct code path that#79856's fix (#80106) did not touch. The schema help (src/config/schema.help.ts:6-7) already documents these fields as auto-managed; the CLI just doesn't honor that contract.src/cli/config-cli.ts, declare a newAUTO_MANAGED_META_PATHSconstant coveringmeta.lastTouchedVersionandmeta.lastTouchedAt, and add three helpers (isAutoManagedMetaPath,findAutoManagedMetaTargets,formatAutoManagedMetaError). Wire an early-throw check into both write entry points:runConfigOperations(coversopenclaw config setvalue mode,openclaw config patch,openclaw config set --batch-file, JSON-merge mode, and the batch-modedeleteoperation) andrunConfigUnset(coversopenclaw config unset). Mirrors the existing precedent forplugins.installsatsrc/cli/config-cli.ts:1453. The error message names the rejected path and explains that the value would be overwritten on the next write.stampConfigVersionitself. Auto-stamping is intentional behavior; the fix is to surface the contract at the CLI boundary, not to disable the stamp.metaparent path. Settingmetawholesale (e.g.openclaw config set meta '{"foo":"bar"}'via--strict-json) is not rejected because schema validation already gates unknown sub-keys. Only the two leaf-or-deeper paths thatstampConfigVersionactually overrides are rejected.wizard.lastRun*fields. Despite the "auto-set" wording in schema help, those are stamped only when the setup wizard runs (applyWizardMetadatainsrc/commands/onboard-helpers.ts:112), not on every write. A userconfig setofwizard.lastRunCommandlegitimately persists until the next wizard run, so including these would break correct behavior.config patch/config setruntime semantics for non-auto-managed paths. No existing behavior changes outside the two rejected paths.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
openclaw config set meta.lastTouchedVersionandmeta.lastTouchedAtreportUpdated …success whilestampConfigVersionsilently overrides the value at write time — reproduces onv2026.5.7andv2026.5.10-beta.1#80849config set(andconfig patch) returns success while discarding values that match schema defaults — silent data loss #79856Real behavior proof (required for external PRs)
Behavior or issue addressed:
openclaw config set meta.lastTouchedVersion <value>andopenclaw config set meta.lastTouchedAt <value>printUpdated …and produce a new config sha256, but the on-disk value is always the auto-stamped value fromstampConfigVersion, not the user's input.Real environment tested: Ubuntu 24.04, openclaw
v2026.5.10-beta.1(commit033ecc944d), Node 22.22.2, against~/.openclaw/openclaw.jsoncarrying a populatedmetablock.Exact steps or command run after this patch:
pnpm install && pnpm build).metablock:unsetcommands to confirm symmetric rejection:stampConfigVersioncontinues to populate both fields on legitimate writes (e.g.pnpm openclaw config set gateway.port 19002).Evidence after fix: live terminal capture of the four commands above (and a legitimate
gateway.portwrite to prove unrelated paths still write correctly) on the patched branch will be attached as a follow-up comment on this PR. The before-fix capture fromv2026.5.10-beta.1is included below.Observed result after fix: each
config set/config unsetinvocation againstmeta.lastTouchedVersionormeta.lastTouchedAtexits non-zero with the auto-managed error message, noUpdated …line is printed, no new sha256 is produced, and the config file is untouched. A subsequentconfig setagainst an unrelated path (e.g.gateway.port) still succeeds andstampConfigVersioncontinues to refresh bothmeta.lastTouchedVersionandmeta.lastTouchedAton that legitimate write.What was not tested:
config set meta '{"lastTouchedVersion":"X"}'with--strict-json). The current fix only inspects the operation'srequestedPath, not the value tree. Themetaparent path is intentionally out of scope (see Summary).replaceConfigFileoutside theconfigCLI surface. The bug surfaces specifically throughconfig set/config patch/config unset; other writers don't expose user-controlledmeta.lastTouched*input.Before evidence (optional but encouraged): real
pnpm openclaw config setrun onv2026.5.10-beta.1(commit033ecc944d) showing the silent-override defect:Root Cause (if applicable)
stampConfigVersionatsrc/config/io.ts:897-908always overwritesmeta.lastTouchedVersion(with the packageVERSIONconstant) andmeta.lastTouchedAt(with the current ISO timestamp) via a key spread that sequences...cfg.metabefore the two explicit overrides. It is called unconditionally atsrc/config/io.ts:2114on every config-write pipeline, including the path used byopenclaw config set. The CLI handler insrc/cli/config-cli.tsprintedUpdated …based on the fact that a write happened (sha256 changed becauselastTouchedAtwas re-stamped), not whether the user's intended write was persisted.meta.*paths actually persisted. The earlier#79856regression (default-equal silent drop) was fixed by#80106with theexplicitSetPathsmechanism, but that mechanism operates inside the write pipeline beforestampConfigVersionruns and so cannot protect against the auto-stamp override.plugins.installsrejection (src/cli/config-cli.ts:1448-1454) already establishes the precedent of rejecting auto-managed paths at the CLI boundary instead of trying to make the write path preserve user input.Regression Test Plan (if applicable)
src/cli/config-cli.test.tsopenclaw config set meta.lastTouchedVersion <value>exits non-zero with an auto-managed error and writes nothing.openclaw config set meta.lastTouchedAt <value>exits non-zero with an auto-managed error and writes nothing.openclaw config unset meta.lastTouchedAtexits non-zero with an auto-managed error and writes nothing.stampConfigVersionre-stamps, on both the write code path (runConfigOperations) and the unset code path (runConfigUnset).#80106's regression tests cover theexplicitSetPathsmechanism (default-equal drop) but not the auto-stamp override class.(#80849).User-visible / Behavior Changes
openclaw config set meta.lastTouchedVersion <value>,openclaw config set meta.lastTouchedAt <value>, andopenclaw config unsetagainst either path now exit with a clear error explaining the field is auto-managed, instead of printingUpdated …and silently dropping the value. Legitimate writes to other paths are unchanged;stampConfigVersioncontinues to refresh bothmeta.lastTouched*fields on every successful write.Diagram (if applicable)
N/A
Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
~/.openclaw/openclaw.jsonwith an existingmetablock.Steps
pnpm openclaw config set meta.lastTouchedVersion 'BOGUS-NOT-A-VERSION'.pnpm openclaw config set meta.lastTouchedAt '1999-01-01T00:00:00.000Z'.pnpm openclaw config unset meta.lastTouchedAt.pnpm openclaw config set gateway.port 19002to confirm unrelated writes still succeed andstampConfigVersionstill refreshes bothmeta.lastTouched*fields on legitimate writes.Expected
Updated …line; config file untouched.gateway.port, and refreshesmeta.lastTouchedVersionandmeta.lastTouchedAtas part of the legitimate write.Actual
Updated …and a new sha256, while the on-diskmeta.lastTouched*values were the auto-stamped values rather than the user's input (see Before evidence above).Evidence
src/cli/config-cli.test.tscoverset meta.lastTouchedVersion,set meta.lastTouchedAt, andunset meta.lastTouchedAt.v2026.5.10-beta.1capture above.Human Verification (required)
pnpm test src/cli/config-cli.test.ts— 79 tests pass, including the three new regression tests for [Bug]:openclaw config set meta.lastTouchedVersionandmeta.lastTouchedAtreportUpdated …success whilestampConfigVersionsilently overrides the value at write time — reproduces onv2026.5.7andv2026.5.10-beta.1#80849.pnpm test src/cli/config-cli.integration.test.ts— 5 integration tests pass.runConfigOperationscoversconfig setvalue mode,config patch,config set --batch-fileJSON mode, JSON-merge mode, and the batchdeleteoperation — all funnel through the same early-throw check.runConfigUnsetis a separate code path not routed throughrunConfigOperations, hence its own guard with the same helper.requestedPathextends an auto-managed path (e.g. a deeper key undermeta.lastTouchedVersion) are also rejected viapathStartsWith, matching the precedent set byplugins.installs.requestedPathstarts with one of the two registered auto-managed paths.config set meta '{"lastTouchedVersion":"X"}'with--strict-json --merge). The current fix inspectsrequestedPath, not the value tree, so a deeply-nested override of an auto-managed leaf via a parent-path merge is not blocked. Themetaparent is intentionally out of scope (see Summary).config set --batch-filewith mixed operations (some auto-managed, some not) — the early-throw rejects the whole batch as soon as one operation matches, matching theplugins.installsprecedent.Review Conversations
Compatibility / Migration
Risks and Mitigations
openclaw config set meta.lastTouchedVersion …expecting silent success (even though the value was always dropped). Those scripts would now fail with a non-zero exit.stampConfigVersionis forgotten inAUTO_MANAGED_META_PATHSand re-introduces the silent-override class for the new field.src/config/io.ts. A linked follow-up could add a contract test asserting that every field stamped bystampConfigVersionis registered inAUTO_MANAGED_META_PATHS; out of scope for this PR.