Skip to content

refactor(cli): inline state migration policy - #120641

Merged
steipete merged 2 commits into
mainfrom
steipete/refactor-inline-state-migration-policy-120451
Aug 8, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/refactor-inline-state-migration-policy-120451

Conversation

@steipete

@steipete steipete commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Merged PR #120451 fixed the state-migration policy, but the follow-up structure still left that policy exposed as a single-use argv helper and duplicated its coverage across argv, preaction, and lifecycle tests. This separate owner-boundary follow-up removes the extra surface without changing the behavior delivered by #120451.

Why This Change Was Made

The migration decision now lives directly in ensureConfigReady, the lifecycle owner that invokes the Doctor migration flow. The redundant exported helper and its argv/preaction assertions are removed, while the existing ensureConfigReady table becomes the canonical behavior matrix.

The preserved matrix skips migration consideration for every top-level config command, plus health, logs, sessions, gateway call, and update status. Empty, unknown, and state-mutating command paths still consider migration, while the existing status, agent, and plugin legacy-input semantics remain unchanged. Doctor remains the migration owner, and gateway startup ownership/checkpoint code is untouched.

User Impact

No user-visible behavior changes. This is the net-negative owner-boundary cleanup that follows #120451: operators retain the same migration and skip behavior with less exported policy and one lifecycle-owned test matrix.

No changelog entry is included because release generation owns CHANGELOG.md.

Evidence

  • node scripts/run-vitest.mjs src/cli/argv.test.ts src/cli/program/config-guard.test.ts src/cli/program/preaction.test.ts — 3 test files and 239 tests passed across 2 Vitest shards in 7.50s.
  • git diff --check origin/main...HEAD — clean.
  • LOC: production +8/-23 (net -15); tests +30/-46 (net -16).
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted — clean, with no accepted or actionable findings before the second commit.
  • Exact reviewed head: 68d3a9173f57335566af0e42f4ca3c8ff507592d.

Remove the single-use exported helper so migration policy now lives at ensureConfigReady, its lifecycle owner. Move duplicate argv and preaction coverage into the lifecycle-owner test table while preserving behavior. This follows #120451.
@steipete
steipete marked this pull request as ready for review August 8, 2026 16:46
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 8, 2026
Keep the ownership invariant beside the inlined gateway-call exception.
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 1:37 PM ET / 17:37 UTC.

ClawSweeper review

What this changes

The PR removes a single-use CLI state-migration helper and consolidates its unchanged command-path policy and tests in configuration readiness, the Doctor-migration lifecycle owner.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main retains the single-use helper and duplicated coverage, while this maintainer-authored PR cleanly moves the unchanged migration decision to its lifecycle owner with no actionable defect found.

Priority: P3
Reviewed head: 68d3a9173f57335566af0e42f4ca3c8ff507592d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative refactor with equivalent behavior and consolidated owner-boundary coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored behavior-neutral refactor is outside the external-contributor real-behavior-proof gate; focused tests and exact diff inspection are appropriate supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored behavior-neutral refactor is outside the external-contributor real-behavior-proof gate; focused tests and exact diff inspection are appropriate supplemental evidence.
Evidence reviewed 4 items Current main still needs this cleanup: Current main still exports the helper and has its sole production consumer in configuration readiness; the PR head is not an ancestor of current main.
Equivalent lifecycle predicate: The PR head preserves the empty-path and all six skip cases while placing the predicate beside the two migration-preflight gates.
Caller and sibling coverage: Bootstrap, route-first, and Commander preaction paths continue to pass the resolved command path unchanged; the lifecycle table covers every skip class plus empty and unknown paths.
Findings None None.
Security None None.

How this fits together

CLI bootstrap resolves a command path and sends it to configuration readiness before command execution. Configuration readiness decides whether Doctor-owned legacy-state migration may run, then continues into the requested command.

flowchart LR
  A[CLI invocation] --> B[Resolved command path]
  B --> C[Configuration readiness]
  C --> D{Consider state migration?}
  D -->|yes| E[Doctor migration preflight]
  D -->|no| F[Skip migration]
  E --> G[Requested command]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as behind current main, so any rebase should receive an exact-head validation refresh before landing.
  • Complete next step (P2) - The protected maintainer label and maintainer authorship require normal human merge handling; no mechanical repair is needed.
Agent review details

Security

None.

PR surface

Source -15, Tests -16. Total -31 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 23 -15
Tests 3 30 46 -16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 38 69 -31

Review metrics

Metric Value Why it matters
Production vs test LOC production -15, tests -16 The refactor removes a one-use export and duplicate assertions while preserving the lifecycle-owned matrix.
Config/default contract 0 config keys, defaults, schemas, flags, or migrations changed The predicate relocation does not alter an external configuration contract.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/cli/argv.test.ts, migration/backfill/repair: src/cli/program/config-guard.test.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one canonical migration decision and one lifecycle-owned behavior matrix in configuration readiness, then land after the branch is refreshed against current main.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one canonical migration decision and one lifecycle-owned behavior matrix in configuration readiness, then land after the branch is refreshed against current main.

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

Not applicable: this PR refactors an existing deterministic command-path policy rather than fixing a newly reported runtime failure.

Is this the best way to solve the issue?

Yes: source shows the helper has one production consumer, so placing the policy directly in the lifecycle that invokes Doctor removes surface area without changing behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a small behavior-neutral CLI cleanup with no reported operator-visible regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored behavior-neutral refactor is outside the external-contributor real-behavior-proof gate; focused tests and exact diff inspection are appropriate supplemental evidence.

Label justifications:

  • P3: This is a small behavior-neutral CLI cleanup with no reported operator-visible regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored behavior-neutral refactor is outside the external-contributor real-behavior-proof gate; focused tests and exact diff inspection are appropriate supplemental evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Authored both commits in this owner-boundary refactor and co-authored the merged migration-policy fix it preserves. (role: recent area contributor; confidence: high; commits: 4b289fa31a5d, 68d3a9173f57; files: src/cli/program/config-guard.ts, src/cli/argv.ts)
  • SunnyShu0925: Authored the merged policy fix whose whole-config migration exclusion this refactor retains. (role: introduced preserved policy; confidence: medium; commits: 1beb96378dba; files: src/cli/program/config-guard.ts)

Rank-up moves

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

  • If rebased, obtain one exact-head review and validation refresh 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 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 68d3a9173f57335566af0e42f4ca3c8ff507592d:

  • Focused proof: node scripts/run-vitest.mjs src/cli/argv.test.ts src/cli/program/config-guard.test.ts src/cli/program/preaction.test.ts — 239 tests passed across 2 shards in 7.50s.
  • Exact-head CI: run 31268594022 completed successfully for this SHA.
  • Native prepare: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 120641 completed successfully. It reused the hosted exact-head gate in hosted_exact_or_recent_parent mode at 2026-08-08T18:22:31Z; no separate remote Testbox lease or run was allocated. Prep head and PR head both remain 68d3a9173f57335566af0e42f4ca3c8ff507592d.
  • Review: refreshed branch and one-line-fix autoreviews are clean. The exact-head ClawSweeper review has no findings. Its prior P3 rationale move from workflow run 31267852251 was resolved by second commit 68d3a9173f57335566af0e42f4ca3c8ff507592d.
  • Diff integrity: git diff --check is clean; production is +8/-23 (net -15) and tests are +30/-46 (net -16). Config/default surfaces changed: zero.
  • Ownership: Doctor migration and gateway startup/checkpoint ownership remain untouched; the gateway-call comment records that remote RPC clients must not migrate gateway-owned state.
  • No rebase: main drift is non-conflicting, and repository policy says not to chase moving main. ClawSweeper's optional refresh is conditional on rebasing, so it is inapplicable here.

@steipete
steipete merged commit 53afc51 into main Aug 8, 2026
132 checks passed
@steipete
steipete deleted the steipete/refactor-inline-state-migration-policy-120451 branch August 8, 2026 18:23
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to IsaiahStapleton/openclaw that referenced this pull request Aug 8, 2026
…0807

* origin/main:
  fix(qa): honor Crabbox SSH fallback ports (openclaw#120539)
  refactor(core): adopt normalization-core leaf helpers across production (openclaw#120350)
  fix(release): scope upgrade plugin credentials (openclaw#120666)
  fix(ai): preserve long Responses sessions after server compaction (openclaw#120457)
  fix(test): keep fork E2E setup builds observable (openclaw#120653)
  fix(cloud-workers): retain provider operation ownership (openclaw#120661)
  docs: runners plan — one placement model for sessions, devices, and cloud (openclaw#120657)
  refactor(cli): inline state migration policy (openclaw#120641)
  feat(update): scheduled update campaigns with countdown, dev-channel auto-update, and Updates settings page (openclaw#120506)
  chore(i18n): refresh native locales (openclaw#120614)
  fix(ci): retry transient artifact API reads (openclaw#120654)
  fix(clawrouter): honor advertised reasoning efforts (openclaw#120631)
  fix(infra): unify env-truthiness, missing-path, realpath, and abort-sleep semantics (openclaw#120359)
  fix(maintainers): parse merge comment URL structurally (openclaw#120649)
  fix(ui): label only operator-pinned runtimes in model picker rows (openclaw#120646)
  docs(agents): replace exact-head re-review gate with 12-hour review window

# Conflicts:
#	src/agents/payload-redaction.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
* refactor(cli): inline state migration policy

Remove the single-use exported helper so migration policy now lives at ensureConfigReady, its lifecycle owner. Move duplicate argv and preaction coverage into the lifecycle-owner test table while preserving behavior. This follows openclaw#120451.

* refactor(cli): preserve gateway migration rationale

Keep the ownership invariant beside the inlined gateway-call exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant