Skip to content

fix(config): reject auto-managed meta.lastTouched* paths in config set/unset - #80856

Merged
hxy91819 merged 2 commits into
openclaw:mainfrom
ai-hpc:fix/config-set-auto-managed-meta-paths
May 13, 2026
Merged

hxy91819 merged 2 commits into
openclaw:mainfrom
ai-hpc:fix/config-set-auto-managed-meta-paths

Conversation

@ai-hpc

@ai-hpc ai-hpc commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Problem: openclaw config set meta.lastTouchedVersion <value> and openclaw config set meta.lastTouchedAt <value> print Updated meta.lastTouched…. Restart the gateway to apply. and produce a new config sha256, but the on-disk value is never the user's value — stampConfigVersion at src/config/io.ts:897-908 is called unconditionally at src/config/io.ts:2114 and re-stamps both fields with the current package VERSION and a fresh ISO timestamp on every write. The config set and config unset CLI handlers don't gate against these auto-managed paths, so the success indicator is decoupled from whether the user's value actually persisted.
  • Why it matters: silent data loss with false success. Same defect class as the closed #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.
  • What changed: in src/cli/config-cli.ts, declare a new AUTO_MANAGED_META_PATHS constant covering meta.lastTouchedVersion and meta.lastTouchedAt, and add three helpers (isAutoManagedMetaPath, findAutoManagedMetaTargets, formatAutoManagedMetaError). Wire an early-throw check into both write entry points: runConfigOperations (covers openclaw config set value mode, openclaw config patch, openclaw config set --batch-file, JSON-merge mode, and the batch-mode delete operation) and runConfigUnset (covers openclaw config unset). Mirrors the existing precedent for plugins.installs at src/cli/config-cli.ts:1453. The error message names the rejected path and explains that the value would be overwritten on the next write.
  • What did NOT change (scope boundary):
    • stampConfigVersion itself. Auto-stamping is intentional behavior; the fix is to surface the contract at the CLI boundary, not to disable the stamp.
    • The meta parent path. Setting meta wholesale (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 that stampConfigVersion actually overrides are rejected.
    • wizard.lastRun* fields. Despite the "auto-set" wording in schema help, those are stamped only when the setup wizard runs (applyWizardMetadata in src/commands/onboard-helpers.ts:112), not on every write. A user config set of wizard.lastRunCommand legitimately persists until the next wizard run, so including these would break correct behavior.
    • config patch / config set runtime semantics for non-auto-managed paths. No existing behavior changes outside the two rejected paths.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: openclaw config set meta.lastTouchedVersion <value> and openclaw config set meta.lastTouchedAt <value> print Updated … and produce a new config sha256, but the on-disk value is always the auto-stamped value from stampConfigVersion, not the user's input.

  • Real environment tested: Ubuntu 24.04, openclaw v2026.5.10-beta.1 (commit 033ecc944d), Node 22.22.2, against ~/.openclaw/openclaw.json carrying a populated meta block.

  • Exact steps or command run after this patch:

    1. Apply this PR locally and build (pnpm install && pnpm build).
    2. Run the following two commands against a config with an existing meta block:
      pnpm openclaw config set meta.lastTouchedVersion 'BOGUS-NOT-A-VERSION'
      pnpm openclaw config set meta.lastTouchedAt       '1999-01-01T00:00:00.000Z'
      
    3. Run the equivalent unset commands to confirm symmetric rejection:
      pnpm openclaw config unset meta.lastTouchedVersion
      pnpm openclaw config unset meta.lastTouchedAt
      
    4. Verify on-disk state is unchanged and that stampConfigVersion continues 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.port write 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 from v2026.5.10-beta.1 is included below.

  • Observed result after fix: each config set / config unset invocation against meta.lastTouchedVersion or meta.lastTouchedAt exits non-zero with the auto-managed error message, no Updated … line is printed, no new sha256 is produced, and the config file is untouched. A subsequent config set against an unrelated path (e.g. gateway.port) still succeeds and stampConfigVersion continues to refresh both meta.lastTouchedVersion and meta.lastTouchedAt on that legitimate write.

  • What was not tested:

    • JSON-merge mode where the user passes a nested object at a higher level (e.g. config set meta '{"lastTouchedVersion":"X"}' with --strict-json). The current fix only inspects the operation's requestedPath, not the value tree. The meta parent path is intentionally out of scope (see Summary).
    • Programmatic callers of replaceConfigFile outside the config CLI surface. The bug surfaces specifically through config set / config patch / config unset; other writers don't expose user-controlled meta.lastTouched* input.
  • Before evidence (optional but encouraged): real pnpm openclaw config set run on v2026.5.10-beta.1 (commit 033ecc944d) showing the silent-override defect:

    BEFORE disk: "lastTouchedVersion": "2026.5.10-beta.1"
    
    $ pnpm openclaw config set meta.lastTouchedVersion 'BOGUS-NOT-A-VERSION'
    Config overwrite: /home/orin/.openclaw/openclaw.json (sha256 1492da9bb89… -> 43873cf614…, backup=/home/orin/.openclaw/openclaw.json.bak)
    Updated meta.lastTouchedVersion. Restart the gateway to apply.
    
    AFTER disk:  "lastTouchedVersion": "2026.5.10-beta.1"
    AFTER via 'config get meta.lastTouchedVersion':
    2026.5.10-beta.1
    
    BEFORE disk: "lastTouchedAt": "2026-05-12T00:59:11.762Z"
    
    $ pnpm openclaw config set meta.lastTouchedAt '1999-01-01T00:00:00.000Z'
    Config overwrite: /home/orin/.openclaw/openclaw.json (sha256 43873cf614… -> fc132f02b4…, backup=/home/orin/.openclaw/openclaw.json.bak)
    Updated meta.lastTouchedAt. Restart the gateway to apply.
    
    AFTER disk:  "lastTouchedAt": "2026-05-12T00:59:42.441Z"
    

Root Cause (if applicable)

  • Root cause: stampConfigVersion at src/config/io.ts:897-908 always overwrites meta.lastTouchedVersion (with the package VERSION constant) and meta.lastTouchedAt (with the current ISO timestamp) via a key spread that sequences ...cfg.meta before the two explicit overrides. It is called unconditionally at src/config/io.ts:2114 on every config-write pipeline, including the path used by openclaw config set. The CLI handler in src/cli/config-cli.ts printed Updated … based on the fact that a write happened (sha256 changed because lastTouchedAt was re-stamped), not whether the user's intended write was persisted.
  • Missing detection / guardrail: no test or runtime check asserted that user-supplied values for the documented auto-managed meta.* paths actually persisted. The earlier #79856 regression (default-equal silent drop) was fixed by #80106 with the explicitSetPaths mechanism, but that mechanism operates inside the write pipeline before stampConfigVersion runs and so cannot protect against the auto-stamp override.
  • Contributing context: the adjacent plugins.installs rejection (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)

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/cli/config-cli.test.ts
  • Scenario the test should lock in:
    • openclaw 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.lastTouchedAt exits non-zero with an auto-managed error and writes nothing.
  • Why this is the smallest reliable guardrail: it pins the CLI-boundary contract for the two paths stampConfigVersion re-stamps, on both the write code path (runConfigOperations) and the unset code path (runConfigUnset).
  • Existing test that already covers this: none — #80106's regression tests cover the explicitSetPaths mechanism (default-equal drop) but not the auto-stamp override class.
  • If no new test is added, why not: N/A; three regression tests are added in this PR, all tagged (#80849).

User-visible / Behavior Changes

  • openclaw config set meta.lastTouchedVersion <value>, openclaw config set meta.lastTouchedAt <value>, and openclaw config unset against either path now exit with a clear error explaining the field is auto-managed, instead of printing Updated … and silently dropping the value. Legitimate writes to other paths are unchanged; stampConfigVersion continues to refresh both meta.lastTouched* fields on every successful write.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Ubuntu 24.04
  • Runtime/container: Node 22.22.2 (local)
  • Model/provider: Not applicable
  • Integration/channel (if any): Not applicable
  • Relevant config (redacted): any populated ~/.openclaw/openclaw.json with an existing meta block.

Steps

  1. On the current main / patched branch, run pnpm openclaw config set meta.lastTouchedVersion 'BOGUS-NOT-A-VERSION'.
  2. Run pnpm openclaw config set meta.lastTouchedAt '1999-01-01T00:00:00.000Z'.
  3. Run pnpm openclaw config unset meta.lastTouchedAt.
  4. Run pnpm openclaw config set gateway.port 19002 to confirm unrelated writes still succeed and stampConfigVersion still refreshes both meta.lastTouched* fields on legitimate writes.

Expected

  • Steps 1–3 each exit non-zero with the auto-managed error; no Updated … line; config file untouched.
  • Step 4 exits 0, writes the new gateway.port, and refreshes meta.lastTouchedVersion and meta.lastTouchedAt as part of the legitimate write.

Actual

  • Before this PR: steps 1–3 each printed Updated … and a new sha256, while the on-disk meta.lastTouched* values were the auto-stamped values rather than the user's input (see Before evidence above).
  • After this PR: steps 1–3 are rejected with the auto-managed error and zero disk writes. Step 4 behaves identically to today.

Evidence

  • Failing test/log before + passing after — three new vitest assertions in src/cli/config-cli.test.ts cover set meta.lastTouchedVersion, set meta.lastTouchedAt, and unset meta.lastTouchedAt.
  • Trace/log snippets — see the verbatim v2026.5.10-beta.1 capture above.
  • Screenshot/recording — after-fix CLI capture will be added as a follow-up comment on this PR.
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios:
  • Edge cases checked:
    • runConfigOperations covers config set value mode, config patch, config set --batch-file JSON mode, JSON-merge mode, and the batch delete operation — all funnel through the same early-throw check.
    • runConfigUnset is a separate code path not routed through runConfigOperations, hence its own guard with the same helper.
    • Operations whose requestedPath extends an auto-managed path (e.g. a deeper key under meta.lastTouchedVersion) are also rejected via pathStartsWith, matching the precedent set by plugins.installs.
    • Operations that do not touch the auto-managed paths are unaffected — the early-throw fires only when at least one operation's requestedPath starts with one of the two registered auto-managed paths.
  • What I did not verify:
    • JSON-merge mode where the user provides a nested object at a higher path (e.g. config set meta '{"lastTouchedVersion":"X"}' with --strict-json --merge). The current fix inspects requestedPath, not the value tree, so a deeply-nested override of an auto-managed leaf via a parent-path merge is not blocked. The meta parent is intentionally out of scope (see Summary).
    • Behavior under config set --batch-file with mixed operations (some auto-managed, some not) — the early-throw rejects the whole batch as soon as one operation matches, matching the plugins.installs precedent.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes (rejecting values that already never persisted on disk; no scripted workflow can have relied on the dropped value).
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: A scripted workflow may currently call 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.
    • Mitigation: the script was already broken — the documented and observed behavior was a silent override. Surfacing the error gives operators a real signal to remove the dead call. The error message names the path and explains the auto-managed semantics.
  • Risk: A future field added to stampConfigVersion is forgotten in AUTO_MANAGED_META_PATHS and re-introduces the silent-override class for the new field.
    • Mitigation: the constant is colocated with the rejection check and the precedent comment points at src/config/io.ts. A linked follow-up could add a contract test asserting that every field stamped by stampConfigVersion is registered in AUTO_MANAGED_META_PATHS; out of scope for this PR.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S proof: supplied External PR includes structured after-fix real behavior proof. labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds CLI validation and regression tests to reject config set, config patch, batch, and config unset mutations that target or clobber auto-managed meta.lastTouchedVersion and meta.lastTouchedAt, and factors config write metadata stamping into a small helper.

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
Sufficient (terminal): Terminal proof in the PR comments shows after-fix rejection for direct, descendant, and ancestor managed meta mutations, unchanged disk state, and an unrelated config write still succeeding.

Next step before merge
No repair lane is needed because there is no discrete code defect in the latest diff; maintainer handling is needed for the dirty/mergeability state and final validation.

Security
Cleared: The diff only adds local CLI validation, a small config metadata helper, tests, and a changelog entry; no new dependency, network, secret, permission, or code-execution surface was introduced.

Review details

Best 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 meta.lastTouched*.

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:

  • pnpm test src/cli/config-cli.test.ts src/config/io.meta.test.ts -- --run
  • pnpm test src/cli/config-cli.integration.test.ts -- --run
  • pnpm check:changed

What I checked:

  • Current-main root cause: stampConfigVersion overwrites meta.lastTouchedVersion and meta.lastTouchedAt on every config write, so user-supplied values for those leaves cannot persist through the writer. (src/config/io.ts:897, da23f4572da7)
  • Current-main write path: The write pipeline calls stampConfigVersion(outputConfig) immediately before JSON serialization, after CLI mutations and unset handling have been applied. (src/config/io.ts:2114, da23f4572da7)
  • Documented contract: Schema help already describes meta as automatically maintained and the two affected leaves as auto-set fields. (src/config/schema.help.ts:5, da23f4572da7)
  • Current-main CLI gap: runConfigOperations only has an early guard for plugins.installs, and runConfigUnset loads and writes config without an auto-managed meta guard. (src/cli/config-cli.ts:1448, da23f4572da7)
  • PR implementation: The diff registers the managed meta paths, detects direct, descendant, and ancestor mutations, rejects them before loading/writing config, and keeps the stamp behavior centralized in stampConfigWriteMetadata. (src/cli/config-cli.ts:1373, 71f74ebbc606)
  • Regression coverage: The PR adds tests for direct leaf set, unset, parent merge with managed child, parent replacement, parent unset, and a non-managed meta sibling boundary case. (src/cli/config-cli.test.ts:476, 71f74ebbc606)

Likely related people:

  • steipete: Authored the merged explicit config-write preservation fix on the same CLI/write path and appears repeatedly in recent config CLI and config test history. (role: recent area contributor; confidence: high; commits: 2e400c5b76db, 18aeac86a101, df51878b0b47; files: src/cli/config-cli.ts, src/config/io.ts, src/cli/config-cli.test.ts)
  • vincentkoc: Appears in recent path history for config CLI and config IO, including adjacent config load/recovery and unset behavior work. (role: recent adjacent contributor; confidence: medium; commits: 5c844bea8807, be2f333e6f2a, fb73f2161e01; files: src/cli/config-cli.ts, src/config/io.ts, src/cli/config-cli.test.ts)
  • hxy91819: Reviewed this PR, identified the parent-path bypass, was assigned on the PR, and authored the latest follow-up commit that centralizes the managed meta path contract. (role: reviewer and follow-up owner; confidence: medium; commits: 71f74ebbc606; files: src/cli/config-cli.ts, src/config/io.meta.ts, src/config/io.meta.test.ts)

Remaining risk / open question:

  • The live PR API reports mergeable_state: dirty, so the branch needs rebase or conflict handling before it can land.
  • Latest head 71f74ebbc60691d60d7e2167e0c9bdde05802a78 adds the shared metadata helper after the terminal proof at 3fdc4333e07643f4d97572af9fd0610011e4175a; behavior is equivalent by inspection, but targeted tests should be rerun on the final head.

Codex review notes: model gpt-5.5, reasoning high; reviewed against da23f4572da7.

@hxy91819

Copy link
Copy Markdown
Member

Review: Needs Changes

Overall direction is correct. Rejecting auto-managed paths at the CLI boundary — rather than trying to preserve user values through stampConfigVersion() — is the right fix, and it mirrors the existing plugins.installs precedent cleanly. The three regression tests lock in the direct leaf-path behavior well.

That said, the implementation is incomplete and the ClawSweeper review findings still need to be addressed before merge.

What's good

  • Root cause correctly identified: stampConfigVersion() at src/config/io.ts:897-906 unconditionally overwrites meta.lastTouchedVersion and meta.lastTouchedAt on every write, so user input never persists.
  • Guard placement in runConfigOperations() and runConfigUnset() covers all direct leaf-path mutations (set, patch, --batch-file, unset).
  • Error message is clear and explains why the field can't be edited.

What needs to change

The parent-path bypass is not closed. Both isAutoManagedMetaPath() and runConfigUnset() only check whether the requestedPath starts with one of the two managed leaves. That means these commands still report success while stampConfigVersion() silently overwrites the result:

  • openclaw config set meta '{"lastTouchedVersion":"BOGUS"}' --strict-json
  • openclaw config set meta '{"lastTouchedAt":"1999-01-01T00:00:00.000Z"}' --strict-json --merge
  • openclaw config unset meta
  • Batch-file entries with "path": "meta" containing auto-managed children

This is the same defect class the PR is trying to eliminate — success-shaped output with silently overwritten state.

Recommended fix:

  1. Also reject meta parent path mutations, or inspect parent-path payloads for auto-managed descendants before allowing the write through.
  2. Add regression coverage for config set meta ..., config set meta ... --merge, batch-file path: meta, and config unset meta.

ClawSweeper findings

The 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.

@ai-hpc
ai-hpc force-pushed the fix/config-set-auto-managed-meta-paths branch from f855f8e to 152ea9a Compare May 12, 2026 11:59
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@ai-hpc
ai-hpc force-pushed the fix/config-set-auto-managed-meta-paths branch from 152ea9a to 1111b29 Compare May 12, 2026 12:08
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@ai-hpc
ai-hpc force-pushed the fix/config-set-auto-managed-meta-paths branch from 1111b29 to 3fdc433 Compare May 12, 2026 12:51
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@ai-hpc

ai-hpc commented May 12, 2026

Copy link
Copy Markdown
Member Author

Verified end-to-end against the live config from #80849. Linux 6.8.0-110-generic, Node 22.22.2. PR head: 3fdc4333e07643f4d97572af9fd0610011e4175a.

Test matrix

# Command Expected Result
1 config set meta.lastTouchedVersion 'BOGUS-NOT-A-VERSION' reject (direct leaf) ✓ exit 1, auto-managed error, disk unchanged
2 config set meta.lastTouchedAt '1999-01-01T00:00:00.000Z' reject (direct leaf) ✓ exit 1, auto-managed error, disk unchanged
3 config unset meta.lastTouchedVersion reject (direct leaf unset) ✓ exit 1, auto-managed error
4 config unset meta.lastTouchedAt reject (direct leaf unset) ✓ exit 1, auto-managed error
5 config set gateway.bind 'loopback' accept (unrelated path) ✓ exit 0, normal Updated gateway.bind. write
6 config set meta.lastTouchedVersion.foo bar reject (descendant via pathStartsWith) ✓ exit 1, auto-managed error
7 config set meta.fakeKey x NOT auto-managed-rejected (boundary sanity) ✓ rejected by schema validator (Unrecognized key: "fakeKey")
8 config set meta '{}' --strict-json reject (ancestor replace clobbers managed) ✓ exit 1, error names both managed leaves
9 config set meta '{"foo":"bar"}' --strict-json reject (ancestor replace with extra key) ✓ exit 1, error names both managed leaves
10 config unset meta reject (ancestor delete erases managed) ✓ exit 1, error names both managed leaves
11 config set meta '{"foo":"bar"}' --strict-json --merge NOT auto-managed-rejected (merge without managed key in payload) ✓ rejected by schema validator (Unrecognized key: "foo")
12 config set meta '{"lastTouchedVersion":"X"}' --strict-json --merge reject (merge naming managed leaf in payload) ✓ exit 1, auto-managed error

Error message shape (Test 1, verbatim)

$ pnpm openclaw config set meta.lastTouchedVersion 'BOGUS-NOT-A-VERSION'
Error: meta.lastTouchedVersion is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

Ancestor-clobber rejection (Test 10, verbatim)

$ pnpm openclaw config unset meta
Error: meta.lastTouchedVersion, meta.lastTouchedAt is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
exit=1

Multi-path rendering correctly names both managed leaves when an ancestor mutation would clobber both.

Boundary sanity (Tests 7 and 11)

$ pnpm openclaw config set meta.fakeKey x
Error: Config validation failed: meta: Unrecognized key: "fakeKey"

$ pnpm openclaw config set meta '{"foo":"bar"}' --strict-json --merge
Error: Config validation failed: meta: Unrecognized key: "foo"

Both errors are from the schema validator, not the auto-managed check. findAutoManagedMetaTargets fires only for lastTouchedVersion / lastTouchedAt and for ancestor mutations that would actually clobber them — schema-valid siblings of the managed leaves stay writable.

Disk preservation

$ grep -oE '"lastTouchedVersion": "[^"]+"' ~/.openclaw/openclaw.json
"lastTouchedVersion": "2026.5.10-beta.1"     ← unchanged across all 11 rejected attempts

stampConfigVersion itself is untouched. Test 5's legitimate config set gateway.bind write correctly re-stamps meta.lastTouchedAt via the normal pipeline — only the explicit config set / config unset entry points targeting the managed paths or their ancestors are blocked.

Sanity — unrelated path still writes (Test 5)

$ pnpm openclaw config set gateway.bind 'loopback'
Config overwrite: /home/orin/.openclaw/openclaw.json (sha256 a8a3d2… -> 8a8f16…, backup=…)
Updated gateway.bind. Restart the gateway to apply.
exit=0
Full live capture — 12 tests, verbatim CLI output, exit codes, disk inspections
# Verification log: PR #80856 (issue #80849)
# Captured 2026-05-12 against 3fdc4333e07643f4d97572af9fd0610011e4175a
# package.json: "version": "2026.5.10-beta.1"

## Test 1: config set meta.lastTouchedVersion (auto-managed) — expect REJECTION

BEFORE disk: "lastTouchedVersion": "2026.5.10-beta.1"

$ pnpm openclaw config set meta.lastTouchedVersion 'BOGUS-NOT-A-VERSION'
$ node scripts/run-node.mjs config set meta.lastTouchedVersion BOGUS-NOT-A-VERSION
Error: meta.lastTouchedVersion is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

AFTER disk:  "lastTouchedVersion": "2026.5.10-beta.1"

## Test 2: config set meta.lastTouchedAt (auto-managed) — expect REJECTION

BEFORE disk: "lastTouchedAt": "2026-05-12T02:06:44.233Z"

$ pnpm openclaw config set meta.lastTouchedAt '1999-01-01T00:00:00.000Z'
$ node scripts/run-node.mjs config set meta.lastTouchedAt 1999-01-01T00:00:00.000Z
Error: meta.lastTouchedAt is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

AFTER disk:  "lastTouchedAt": "2026-05-12T02:06:44.233Z"

## Test 3: config unset meta.lastTouchedVersion — expect REJECTION

$ pnpm openclaw config unset meta.lastTouchedVersion
$ node scripts/run-node.mjs config unset meta.lastTouchedVersion
Error: meta.lastTouchedVersion is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

## Test 4: config unset meta.lastTouchedAt — expect REJECTION

$ pnpm openclaw config unset meta.lastTouchedAt
$ node scripts/run-node.mjs config unset meta.lastTouchedAt
Error: meta.lastTouchedAt is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

## Test 5: sanity — a normal non-managed config set still works (gateway.bind)

$ pnpm openclaw config set gateway.bind 'loopback'
$ node scripts/run-node.mjs config set gateway.bind loopback
Config overwrite: /home/orin/.openclaw/openclaw.json (sha256 a8a3d2433c1c47e7c1a3080da20a5b08d79e15a0088b999e1bc17cf86c3e065c -> 8a8f16ad4f04477992498bf644259f53ae67c7ae6c2a35145802fe1e68f205ef, backup=/home/orin/.openclaw/openclaw.json.bak)
Updated gateway.bind. Restart the gateway to apply.
exit=0

## Test 6: nested path under meta.lastTouchedVersion (e.g. meta.lastTouchedVersion.foo) — expect REJECTION

$ pnpm openclaw config set meta.lastTouchedVersion.foo bar
Error: meta.lastTouchedVersion.foo is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
exit=1

## Test 7: unrelated meta path (sanity — should NOT be rejected by auto-managed check)

$ pnpm openclaw config set meta.fakeKey x
Error: Config validation failed: meta: Unrecognized key: "fakeKey"
exit=1   ← rejected by schema validator (not by auto-managed check) — correct

## Test 8: config set meta '{}' --strict-json (replace ancestor; would erase managed children) ---

BEFORE: "lastTouchedVersion": "2026.5.10-beta.1"

$ node scripts/run-node.mjs config set meta '{}' --strict-json
Error: meta.lastTouchedVersion, meta.lastTouchedAt is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

AFTER:  "lastTouchedVersion": "2026.5.10-beta.1"

## Test 9: config set meta '{"foo":"bar"}' --strict-json (replace ancestor with extra key) ---

$ node scripts/run-node.mjs config set meta '{"foo":"bar"}' --strict-json
Error: meta.lastTouchedVersion, meta.lastTouchedAt is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

## Test 10: config unset meta (delete ancestor; clobbers all managed children) ---

$ node scripts/run-node.mjs config unset meta
Error: meta.lastTouchedVersion, meta.lastTouchedAt is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

## Test 11: config set meta '{"foo":"bar"}' --strict-json --merge (merge mode, payload doesn't name managed field) ---

$ node scripts/run-node.mjs config set meta '{"foo":"bar"}' --strict-json --merge
Error: Config validation failed: meta: Unrecognized key: "foo"
[ELIFECYCLE] Command failed with exit code 1.
exit=1   ← rejected by schema validator — auto-managed check correctly let it through

## Test 12: config set meta '{"lastTouchedVersion":"X"}' --strict-json --merge (merge mode, payload DOES name managed field) ---

$ node scripts/run-node.mjs config set meta '{"lastTouchedVersion":"X"}' --strict-json --merge
Error: meta.lastTouchedVersion is auto-managed by OpenClaw and cannot be edited; the value would be overwritten on the next config write.

These fields are stamped on every config write to record the OpenClaw version and timestamp that produced the file.
[ELIFECYCLE] Command failed with exit code 1.
exit=1

## Final disk state
lastTouchedVersion: "lastTouchedVersion": "2026.5.10-beta.1"
lastTouchedAt:      "lastTouchedAt": "2026-05-12T12:06:51.886Z"

Closes #80849.

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
hxy91819 pushed a commit that referenced this pull request May 13, 2026
…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).
ai-hpc and others added 2 commits May 13, 2026 12:05
…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).
@hxy91819
hxy91819 force-pushed the fix/config-set-auto-managed-meta-paths branch from 71f74eb to a574312 Compare May 13, 2026 04:07
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@hxy91819
hxy91819 merged commit ecc48c6 into openclaw:main May 13, 2026
108 checks passed
@hxy91819

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @ai-hpc!

l3ocifer pushed a commit to l3ocifer/frack-openclaw that referenced this pull request May 13, 2026
…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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…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
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…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
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
…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
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes proof: supplied External PR includes structured after-fix real behavior proof. size: M

Projects

None yet

2 participants