Skip to content

refactor(commands): deslop commands - #158487

Merged
steipete merged 5 commits into
mainfrom
deslop/l53-commands3
Sep 26, 2026
Merged

steipete merged 5 commits into
mainfrom
deslop/l53-commands3

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The command subsystem still repeats migration traversal, command orchestration, and output projection after the earlier cleanup passes. This third pass removes 1,879 net production lines while retaining the existing command contracts.

User Impact

The cleanup preserves command names, flags, help text, JSON shapes, exit-code conventions, config keys, and Doctor repair order. Three accompanying fixes prevent duplicate session deletions from reporting false partial failures, skip malformed legacy media-model entries during migration, and keep unchanged plugins valid when runtime selects source artifacts.

Why This Change Was Made

This accumulates the sound simplifications found while reading the production subtree, largest files first. It builds on #156622 and #156931 without recreating their consolidations.

  • Doctor provider normalization shares one copy-on-write traversal; model selectors, object-key checks, hashes, and count formatting reuse their existing owners.
  • Doctor cron repair parses delivery hints once, applies one field projection, and uses ordered field/diagnostic tables instead of repeated branches. Repair counts and preview wording stay intact.
  • Auth migration shares target enumeration and config-profile initialization. Session repair removes unused intermediate records and repeated lookup/formatting code while retaining its archive and publication guards.
  • Workshop migration and update rehearsal read proposal sidecars through one owner. Plugin discovery, release install repair, shell completion, sandbox migration, and configuration diagnostics share their duplicate branches.
  • Setup invokes its lazy owners directly instead of maintaining default dependency wrappers and duplicate types.
  • Onboarding shares plugin-install progress, health-failure context, provider credential types, and warning handling; removes redundant normalization and forwarding functions.
  • Channel setup shares trusted catalog lookup. Account removal, binding results, capability formatting, and sandbox deletion use a single flow for their common work.
  • Gateway cancellation shares the retry loop while preserving active-connection versus reconnected failure reporting. Gateway capability priority and display use the same small table.
  • Status credential summaries share paired/single-token flows while preserving HTTP/socket warning precedence. Runtime collection and report projection use their existing owners directly.
  • Migration plan/apply share selection order and reference matching; output grouping uses one rendering loop. Backup commands remove one-use output wrappers and duplicate result types.
  • Cleanup uses its existing preservation-aware removal owner. Session/task commands reuse canonical result types and remove redundant guards and forwarding layers.
  • Completes the migration-selection cutover: skill/plugin helpers become internal functions, and existing tests exercise the shared production entry.
  • Removes comments that restate code and redundant copies/casts throughout these same flows.

Fixes found along the way

  • Repeated or whitespace-equivalent session keys caused repeated delete RPCs and a false partial failure after a successful deletion. Archive/delete now normalize unique keys once at command entry, retaining first-occurrence order. The existing artifact-preservation regression includes duplicate arguments and asserts one describe, one delete, and no failure exit.

  • Retired media migration compared getRecord() with undefined, although invalid records produce null. The canonical record predicate now excludes malformed entries; a regression covers mixed invalid and valid lists.

  • Plugin runtime fingerprinting had a hard-coded built preference while source-mode inference executed source. The original guided onboarding suite reproduced four failures on the starting base; a passive observer confirmed the built-to-source fingerprint switch. Upstream fix(test): restore CLI and Doctor release-validation contracts #157780 subsequently aligned that release fixture with packaged artifacts. The separate loader regression in this PR protects real source/build policy and explicit source overrides. Verification now consumes the runtime preference and the canonical explicit-source selection fact, and continues hashing selected content to reject real replacements. Fingerprinting reads that preference through the existing lightweight registry-state reader, keeping extracted maintainer wrappers free of runtime-preparation and logging imports. No stored metadata or config schema changes.

  • Corrects the sandbox CLI page: agent exec preserves an inherited/configured sandbox. Configless modes use the sandbox-off default, as the existing implementation and tests already establish.

Evidence

Current candidate: 0a209ea3142843a383fb23d4cf586d276603a0df. Exact-head CI passed: 169 checks successful, 45 conditionally skipped, including openclaw/ci-gate. The PR is mergeable and ready to land; it remains unmerged with auto-merge disabled. Independent review completed through P2 with no actionable findings. The diff removes 1,879 net production lines across 112 production files; all 619 starting production files were read, including every file over 200 lines. No shared expected-error predicate changed.

Complete remote proof passed on d08fcdae0de8b4cae54c9471ccc6b4f92d5edcbe (tree 5b7a200c966360a47989e375ca13affa8caec28d). The final upstream integration preserves all 122 changed source/documentation files byte-for-byte and the exact assertion-baseline removals. The successful hosted CI run validates that integration. The refresh also retains upstream TaskFlow Webhooks retirement and its restrictive-allowlist repair unchanged; the obsolete allow/deny consolidation was removed from this PR.

Remote proof used Blacksmith Testbox tbx_01m3e42r07kvfeew5g3skp83fn through node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --id <lease> --timing-json, with source/tree attestation and pnpm install --frozen-lockfile. Every command phase and the wrapper returned zero. The lease is stopped.

  • node scripts/check-changed.mjs --base origin/main: passed in 25m 27s, including core types, all 25 test-type shards, lint, dead exports, and boundary/schema guards.
  • pnpm build: passed in 8m 51s. pnpm plugin-sdk:check-exports and pnpm plugin-sdk:surface:check: passed in 1s and 3s.
  • Focused/cross-shard node scripts/run-vitest.mjs selection: 350 files, 6,667 tests passed, 3 existing skips, 16m 2s. This includes command callers, migration/lifecycle siblings, plugin artifact/inference consumers, the extracted-wrapper contract, and guided onboarding E2E.
  • Real pnpm openclaw doctor and pnpm openclaw doctor --fix, both non-interactive against isolated synthetic legacy config: exit zero in 6s and 5s. Persisted assertions confirm canonical agent entries, the idle-reset policy, removal of malformed media rows, and valid model order/capabilities. The isolated diagnostic invocation correctly reported its absent Gateway.

The media, artifact-preference, and duplicate-session regressions failed before their respective fixes. Initial hosted CI also exposed an eager import into the extracted maintainer wrapper. Reading the existing lightweight registry-state owner fixes that boundary; the unchanged extraction contract now passes all 15 tests (16s standalone). The extraction test and its production inventory remain unchanged.

Two upstream failures encountered during integration already have canonical repairs: da8149b8ba7d corrects the retained-assets UI E2E type import (the exact type graph subsequently passed in 48s), and 66b812f26e72 removes a chained assertion introduced on main in Gateway progress normalization. The latter broke the previous CI merge ref; this branch incorporates its repair, and fresh CI passed. Neither failure required a duplicate fix PR.

Changed-test cost

Serial wall time was measured on the validated Testbox source with pnpm test <file> --maxWorkers=1; the media E2E uses the already-built distribution. CI seconds come from the successful current-head run and sum Vitest's reported case durations, excluding shared runner setup; zero reflects the logger's timing resolution.

Test file Serial wall CI test seconds
src/commands/channels.adds-non-default-telegram-account.test.ts 20s 1.895
src/commands/status-all/channels.mattermost-token-summary.test.ts 2s 0.000
src/plugins/plugin-runtime-artifact-resolution.test.ts 19s 1.153
src/system-agent/verified-inference.test.ts 23s 0.710
src/commands/migrate/selection.test.ts 16s 0.002
src/commands/sessions-lifecycle.test.ts 1s 0.105
src/commands/doctor/shared/legacy-config-migrate.e2e.test.ts 19s 4.342

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations docker Docker and sandbox tooling size: XL labels Sep 26, 2026
@steipete
steipete marked this pull request as ready for review September 26, 2026 00:33
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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: 🦪 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. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 26, 2026, 3:19 AM ET / 07:19 UTC (Revision 7).

ClawSweeper review

What this changes

The branch consolidates CLI and Doctor command flows, deduplicates session lifecycle requests, repairs malformed legacy media migration, and aligns plugin identity checks with the artifact selected for execution.

Merge readiness

⛔ Blocked before merge - 8 items remain

Keep open. Current main lacks distinct changes from this PR. The reported Doctor run and green exact-head CI support the patch, but the prior review’s final-write authority and published-updater compatibility proof requests remain unresolved.

Priority: P3
Reviewed head: 0a209ea3142843a383fb23d4cf586d276603a0df

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The consolidation has broad validation and a real Doctor run, while two consequential boundary proofs remain open.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports real Testbox openclaw doctor and doctor --fix runs with persisted results on source matching the reviewed Doctor paths. Those runs do not exercise the changed plugin identity through an allowed system-agent persistent write and a replaced-owner refusal. The Doctor cron and config repair paths rewrite stored state, and no published-driver upgrade preservation result is posted; data-model compatibility remains insufficient. 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 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports real Testbox openclaw doctor and doctor --fix runs with persisted results on source matching the reviewed Doctor paths. Those runs do not exercise the changed plugin identity through an allowed system-agent persistent write and a replaced-owner refusal. The Doctor cron and config repair paths rewrite stored state, and no published-driver upgrade preservation result is posted; data-model compatibility remains insufficient. 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 11 items Distinct session fix: The PR normalizes and deduplicates keys before session lookup and mutation; fetched main still trims keys without deduplicating them at command entry.
Current-main session behavior: Fetched main still has new Set(keys) only in the describe path and sends the original trimmed list through later mutation.
Legacy media repair: The introduced filter excludes malformed media-model entries before migration; fetched main retains the older getRecord(value) !== undefined check.
Findings None None.
Security Needs attention Prove stale plugin ownership is rejected before persistence: Artifact selection now affects the fingerprint bound to an inference owner. Existing tests show fingerprint changes, but no final-effect trace shows a replaced or reassigned owner being refused before a setup write.

How this fits together

OpenClaw commands take CLI options, configuration, and stored state to run Doctor repairs and Gateway session operations. Conversational setup also uses a plugin artifact identity check before persistent changes.

flowchart LR
  A[CLI options and config] --> B[Command handlers]
  C[Legacy state] --> D[Doctor repair]
  B --> D
  B --> E[Gateway session requests]
  D --> F[Persisted state]
  G[Plugin runtime files] --> H[Inference owner check]
  B --> H
  H --> F
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports real Testbox openclaw doctor and doctor --fix runs with persisted results on source matching the reviewed Doctor paths. Those runs do not exercise the changed plugin identity through an allowed system-agent persistent write and a replaced-owner refusal. The Doctor cron and config repair paths rewrite stored state, and no published-driver upgrade preservation result is posted; data-model compatibility remains insufficient. 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 security concern: Prove stale plugin ownership is rejected before persistence - Artifact selection now affects the fingerprint bound to an inference owner. Existing tests show fingerprint changes, but no final-effect trace shows a replaced or reassigned owner being refused before a setup write.
  • Resolve merge risk (P1) - The changed plugin artifact identity participates in persistent setup authority, but no final-write trace shows an allowed owner succeeding and a replaced or reassigned owner being refused before the write.
  • Resolve merge risk (P1) - The refactored Doctor paths rewrite existing config and cron state; the posted synthetic Doctor run does not establish preservation when a published updater drives the candidate over saved state.
  • Complete next step (P2) - Add redacted terminal or log evidence for the allowed and replaced-owner final writes and a published-updater upgrade preserving saved config and cron state. Redact private endpoints, addresses, and credentials. Updating the PR body should trigger re-review; if it does not, ask a maintainer to comment @clawsweeper re-review.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [medium] Prove stale plugin ownership is rejected before persistence — src/plugins/plugin-runtime-artifact-identity.ts:143
Agent review details

Security

Needs attention: The changed plugin identity feeds a persistent authority check; rejection of a replaced owner at the final write remains unproven.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Changed-test cost 7 files measured; 1–23s serial wall each The PR body accounts for the changed tests' recurring CI cost under repository policy.

Stored data model

Persistent data-model change detected: migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: src/commands/doctor-auth-flat-profiles.ts, migration/backfill/repair: src/commands/doctor-auth-oauth-sidecar.ts, migration/backfill/repair: src/commands/doctor-auth-profile-config.ts, migration/backfill/repair: src/commands/doctor-claude-cli.ts, migration/backfill/repair: src/commands/doctor-completion.ts, and 22 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove both affected boundaries (recommended)
    Show final-write acceptance and replaced-owner refusal, then run a published-updater-to-candidate upgrade that checks saved config and cron rows.

Technical review

Best possible solution:

Keep the command and plugin owners consolidated while preserving CLI contracts, current owner authority, and existing state across fresh installations and upgrades.

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

Not applicable to the cleanup as a whole. Source and regression cases identify the included session and media defects, but this read-only review did not run a failing current-main reproduction.

Is this the best way to solve the issue?

Yes in approach: the branch reuses existing command and plugin owners. Its merge safety still needs final-effect authority and installed-state upgrade evidence.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is primarily command cleanup with bounded fixes, rather than a reported urgent user regression.
  • merge-risk: 🚨 compatibility: Doctor migration and repair refactors can affect existing configuration and automation rows during upgrade.
  • merge-risk: 🚨 security-boundary: The selected plugin artifact fingerprint is part of the inference-owner check before persistent setup effects.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports real Testbox openclaw doctor and doctor --fix runs with persisted results on source matching the reviewed Doctor paths. Those runs do not exercise the changed plugin identity through an allowed system-agent persistent write and a replaced-owner refusal. The Doctor cron and config repair paths rewrite stored state, and no published-driver upgrade preservation result is posted; data-model compatibility remains insufficient. 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

Security concerns:

  • [medium] Prove stale plugin ownership is rejected before persistence — src/plugins/plugin-runtime-artifact-identity.ts:143
    Artifact selection now affects the fingerprint bound to an inference owner. Existing tests show fingerprint changes, but no final-effect trace shows a replaced or reassigned owner being refused before a setup write.
    Confidence: 0.76

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Null Arbitrage: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Show an allowed system-agent persistent apply and a replaced or reassigned plugin owner refused before the final write.
  • Run a published-driver-to-candidate upgrade with saved config and cron state, including preservation checks.

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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-26T00:40:39.097Z sha 1966095 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-26T03:00:22.955Z sha ae3ee33 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-26T04:24:02.667Z sha ae3ee33 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-26T04:54:57.869Z sha 0e943b3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-26T05:53:16.456Z sha d08fcda :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-26T07:03:01.329Z sha 0a209ea :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the deslop/l53-commands3 branch from 289f720 to ae3ee33 Compare September 26, 2026 02:51
Consolidate command orchestration, Doctor migration traversal, status projection, and migration selection while preserving CLI contracts. Repair malformed legacy media rows and align inference owner fingerprints with runtime artifact selection.
Normalize session keys once before describe and mutation so repeated arguments cannot cause false partial failures. Preserve public error formatting and optional auth fields while resolving the final cleanup lint findings.
Read the existing bound artifact preference through the canonical runtime-state getter so extracted maintainer wrappers do not import runtime preparation and logging. Preserve the current writer, selection policy, and wrapper inventory.
@steipete
steipete force-pushed the deslop/l53-commands3 branch from ae3ee33 to 0e943b3 Compare September 26, 2026 04:44
@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 26, 2026
@steipete
steipete merged commit cd8a86e into main Sep 26, 2026
229 checks passed
@steipete
steipete deleted the deslop/l53-commands3 branch September 26, 2026 07:33
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
* refactor(commands): deslop commands

Consolidate command orchestration, Doctor migration traversal, status projection, and migration selection while preserving CLI contracts. Repair malformed legacy media rows and align inference owner fingerprints with runtime artifact selection.

* fix(commands): handle duplicate session lifecycle keys

Normalize session keys once before describe and mutation so repeated arguments cannot cause false partial failures. Preserve public error formatting and optional auth fields while resolving the final cleanup lint findings.

* fix(plugins): keep artifact identity on lightweight runtime state

Read the existing bound artifact preference through the canonical runtime-state getter so extracted maintainer wrappers do not import runtime preparation and logging. Preserve the current writer, selection policy, and wrapper inventory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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