Skip to content

fix: restore owner-only commands after legacy identity migration - #137780

Merged
steipete merged 3 commits into
mainfrom
fix/legacy-owner-identity-migration
Sep 4, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/legacy-owner-identity-migration

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #137749. Reported by @shakkernerd (Shakker).

What Problem This Solves

Fixes an issue where configured owners could no longer use owner-only slash commands after an upgrade when commands.ownerAllowFrom still contained legacy entries such as discord:user:123.

Why This Change Was Made

Doctor now persists unambiguous channel:user:id entries as channel:id, including Discord, Telegram, and Slack, and reports each rewritten list position. Discord uses one lightweight global-owner selector for native commands, voice, and owner-derived exec approvers, so the retired envelope cannot remain an alternate runtime authorization path. The migration is absorbed by simplifying owner selection and removing redundant matching wrappers.

The shared command-owner selector removes the channel envelope, but the real channel formatter leaves user: intact; that value cannot match a native sender ID. Earlier agent-roster migrations (#134706, #134758) do not own this list. The precise introducing commit is unknown; the formatter behavior also exists in the inspected July/August stable tags.

Shipped bare Discord target forms (user:, pk:, mentions, and configured name matching) retain their existing matcher and wildcard rules. Exec approvals retain the owner-only normalization pass and explicit-target behavior. These are existing contracts in v2026.8.1, not substitutes for the retired channel-qualified form. Doctor does not guess a channel for an unqualified entry: Signal and Slack interpret some of the same strings differently.

User Impact

Running openclaw doctor --fix repairs legacy command owners once and explains the affected entries. Canonical, numeric, unknown-channel, wildcard, malformed, and colon-bearing native IDs remain unchanged. A second repair makes no further config write.

Ordinary channel allowlists, message targets, and explicitly configured exec-approval targets retain their syntax. An unrepaired legacy Discord owner list cannot fall back to a broader channel allowlist.

Evidence

  • Disk-backed doctor regression fails on the original tree: all three legacy entries remain unchanged. After the fix, it persists canonical owners, reports each position, and proves the next run leaves the file byte-identical, including with bundled plugins disabled.
  • Discord voice regression fails on the original tree because the retired envelope still grants runtime ownership. Compatibility tests caught six bare/mention regressions in the earlier candidate; the correction preserves those shipped targets and keeps user:*/pk:* from becoming wildcard admission.
  • The exec-approval regression fails before shared owner selection because a retired global owner still becomes an approver. Explicit approval target syntax and nested normalization retain their existing results.
  • Focused doctor/native/voice/approval tests: 163 passed across nine files (27 doctor/config and 136 Discord).
  • The full node scripts/check-changed.mjs run passed on the final source, including typechecks, lint, dead exports, and architectural guards.
  • Independent P0–P2 branch review is clean on the final source. A status-call-count finding was disproved against the complete voice command flow and the passing cases; re-review confirmed it.

Crabbox process proof passed on final source 024ac64b6257b089efd405cfb64c46d0fe86f96f, with all 18 changed files verified by SHA-256 before a full build. The real CLI/Gateway and Discord plugin used synthetic Crabline REST/Gateway endpoints and isolated state on port 46551. Doctor received the legacy agents.list roster and legacy owners together, and persisted both repairs. Final Testbox workflow. All 30 broader voice runtime E2E tests passed on the same machine; the wrapper completed with exit 0 and the lease was stopped. This exercises a text slash command through the shared owner-only guard; native commands, approvals, and voice have focused integration coverage. Authenticated Discord interactions or audio are not claimed.

BEFORE: You are not authorized to use this owner-only command.
DOCTOR_INPUT: legacy agents.list roster and unchanged channel:user:id owners.
DOCTOR: all three channel owners rewritten; each list position reported; second repair byte-identical.
AFTER: Config commands.ownerAllowFrom:
["discord:100000000000000001", "telegram:123", "slack:U123"]
verdict=pass; transport=real Discord plugin -> Crabline REST/Gateway MESSAGE_CREATE

The broader voice E2E run exposed a preexisting assertion against the room coordinator's removed private lifecycle field after #137433. The test now observes the real provider audio boundary across close, delayed connect completion, and late readiness. Production voice lifecycle behavior is unchanged.

Exact-head CI passed on attempt 2. The initial audit timed out at npm's bulk advisory endpoint, also observed on main and locally; one lint shard stopped during pnpm bootstrap on a registry timeout before lint ran. Both passed on an unchanged retry. No dependency or timeout workaround is included.

git diff --numstat classification: production +68/-69 (net -1), tests +129/-15 (net +114), docs +3. The shared selection helper replaces duplicated selection and owner wrappers while preserving public target contracts.

ClawSweeper's bare-target finding and Rank-up move are addressed by preserving shipped formats and adding compatibility coverage. Broader normalization of unqualified global owners remains a separate channel/authority policy question; this repair deliberately does not infer namespaces.

NO-FOLLOW-UP: the useful adjacent refactor is included in shared owner selection; another refactor would broaden authority policy without established migration semantics.

Rewrite legacy channel:user:id command owners before runtime consumes them, report each repaired entry, and remove duplicate Discord owner-prefix parsing. Preserve canonical IDs and unrelated channel policies.

Fixes #137749. Reported by Shakker (@shakkernerd).
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord commands Command implementations size: M maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 01:47
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 11:00 PM ET / September 4, 2026, 03:00 UTC.

ClawSweeper review

What this changes

The PR makes Doctor rewrite legacy channel:user:id command-owner entries and makes Discord native commands, voice, and owner-derived exec approvals consume the canonical owner form.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

No blocking introduced defect was found in the pinned patch. This member-authored, maintainer-labeled compatibility repair should remain open for explicit maintainer acceptance of its documented one-time Doctor migration boundary.

Priority: P1
Reviewed head: 024ac64b6257b089efd405cfb64c46d0fe86f96f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A well-scoped compatibility repair with direct migration, consumer, regression, and isolated runtime evidence; only the intentional upgrade boundary needs maintainer acceptance.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its supplied body nevertheless records a real isolated CLI/Gateway upgrade replay through the Discord plugin and focused authorization coverage.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its supplied body nevertheless records a real isolated CLI/Gateway upgrade replay through the Discord plugin and focused authorization coverage.
Evidence reviewed 6 items Doctor migration owner: The new migration recognizes only unambiguous known-channel channel:user:id entries, records each rewrite, and persists channel:id while preserving colon-bearing native identifiers.
Canonical runtime consumers: Discord’s shared selector removes the retired envelope while preserving established bare, user:, pk:, and mention forms; native authorization, voice access, and exec approvers import that selector.
Persistence and authorization coverage: The disk-backed Doctor test verifies the three supported channel rewrites, preservation of ambiguous values, reported positions, and byte-identical second repair; Discord tests cover retired, canonical, bare, mention, wildcard, and approval forms.
Findings None None.
Security None None.

How this fits together

Doctor is OpenClaw’s configuration repair flow; it persists canonical owner identities before runtime authorization reads them. Discord then uses those identities to decide who may invoke privileged native and voice commands or approve execution requests.

flowchart LR
  A[Legacy owner configuration] --> B[Doctor repair]
  B --> C[Canonical channel owner]
  C --> D[Discord owner selection]
  D --> E[Native and voice commands]
  D --> F[Exec approvals]
Loading

Decision needed

Question Recommendation
Should this PR land with openclaw doctor --fix as the required one-time upgrade path for legacy channel:user:id command owners? Land the canonical migration: Accept the documented Doctor repair as the upgrade path and keep retired runtime owner parsing unavailable.

Why: The patch intentionally removes a divergent runtime interpretation of persisted authorization data; accepting that compatibility boundary requires maintainer judgment even though the migration and documentation are present.

Before merge

  • Resolve merge risk (P1) - Existing configurations retaining channel:user:id must run the documented openclaw doctor --fix; until then the PR deliberately prevents Discord from treating that retired spelling as an alternate owner authorization path.
  • Resolve merge risk (P1) - The local promisor checkout could not materialize fetched-main source objects after DNS failure, so only the pinned base and PR head received direct source comparison.
  • Complete next step (P2) - Obtain maintainer acceptance of the documented Doctor-only upgrade boundary before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source -1, Tests +114, Docs +3. Total +116 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 10 68 69 -1
Tests 7 129 15 +114
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 200 84 +116

Review metrics

Metric Value Why it matters
Production vs test delta production net -1; tests net +114; docs +3 The repair replaces duplicated owner-selection logic while adding migration and authorization compatibility coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-command-owner.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-core-migrate.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137749
Summary: This PR is the explicit candidate fix for the legacy command-owner migration defect described by the canonical issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the Doctor upgrade boundary (recommended)
    Merge the documented one-time repair and retain canonical owner interpretation across Discord authorization surfaces.
  2. Pause for compatibility policy
    Hold the PR if maintainers want to support retired owner syntax at runtime rather than require Doctor repair.

Technical review

Best possible solution:

Land the Doctor-owned, idempotent canonicalization after a maintainer accepts the documented upgrade boundary, keeping retired runtime parsing unavailable rather than preserving divergent authorization semantics.

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

Yes—source-reproducible: the persisted Doctor migration and Discord owner-selection path directly establish the legacy-to-canonical scenario, although this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: persisting the repair at Doctor’s compatibility boundary and using one Discord selector avoids a runtime legacy fallback while retaining established target forms.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The patch addresses a post-upgrade failure of owner-only Discord commands.
  • merge-risk: 🚨 compatibility: It changes how persisted command-owner identities are repaired and interpreted during upgrade.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its supplied body nevertheless records a real isolated CLI/Gateway upgrade replay through the Discord plugin and focused authorization coverage.

Evidence

What I checked:

  • Doctor migration owner: The new migration recognizes only unambiguous known-channel channel:user:id entries, records each rewrite, and persists channel:id while preserving colon-bearing native identifiers. (src/commands/doctor-command-owner.ts:12, 024ac64b6257)
  • Canonical runtime consumers: Discord’s shared selector removes the retired envelope while preserving established bare, user:, pk:, and mention forms; native authorization, voice access, and exec approvers import that selector. (extensions/discord/src/command-owners.ts:3, 024ac64b6257)
  • Persistence and authorization coverage: The disk-backed Doctor test verifies the three supported channel rewrites, preservation of ambiguous values, reported positions, and byte-identical second repair; Discord tests cover retired, canonical, bare, mention, wildcard, and approval forms. (src/commands/doctor-config-flow.workspace-persistence.test.ts:24, 024ac64b6257)
  • Introduction provenance: The migration was introduced by the first PR commit directly atop the pinned base; raw commit metadata confirms its recorded parent, and blame attributes the new source lines to that commit. (src/commands/doctor-command-owner.ts:12, 50822a7c749e)
  • Still unmerged: The pinned PR head is not an ancestor of local current main; the latest main commit shown locally is a release-flow change. The local promisor checkout could not materialize current-main tree objects because DNS resolution for its remote failed, so this review does not claim a separate current-main source read. (d84cdc5c03d3)
  • Maintainer-provided behavior evidence: The PR body records an isolated CLI/Gateway upgrade replay with a denied legacy owner before repair, persisted canonical owners and byte-identical second Doctor run afterward, plus focused Discord authorization coverage and exact-head CI. (024ac64b6257)

Likely related people:

  • unknown: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-04T01:55:40.681Z sha 50822a7 :: blocked before merge. :: [P1] Preserve bare user: and pk: command-owner entries
  • reviewed 2026-09-04T02:40:59.491Z sha 024ac64 :: blocked before merge. :: none
  • reviewed 2026-09-04T02:51:10.191Z sha 024ac64 :: blocked before merge. :: none

Keep bare user, pk, mention, and name matching contracts while doctor owns the retired channel:user:id envelope. Unqualified identities have different meanings across channel owners, so migration must not guess a Discord namespace.

Remove redundant owner matching wrappers and repair the stale realtime close-race test to observe the provider audio boundary after late readiness.
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Final source 024ac64b6257b089efd405cfb64c46d0fe86f96f now has a passing Crabbox build and upgrade replay: the legacy owner is denied before doctor, all three channel identities and the legacy roster are persisted correctly, each rewrite is reported, the second doctor run is byte-identical, and the owner-only command succeeds afterward. All 30 voice runtime E2E cases passed on the same machine. Testbox evidence.

The bare-target finding and Rank-up move are addressed: shipped user:, pk:, mention and name matching are preserved; global owners retain their existing approval normalization; explicit approval targets retain their syntax. A shared selector removes the retired global discord:user: runtime path from native commands, voice, and owner-derived approvers. The focused suite passes 163 cases, the full changed-file check passes, and P0–P2 branch review is clean. Production delta remains -1 line.

CI still needs its registry-timeout failures retried and queued jobs completed; no audit or lint gate was weakened.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 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 exact_review_queue).
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 proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Sep 4, 2026
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer acceptance: the documented one-time openclaw doctor --fix migration is the intended upgrade contract for legacy channel:user:id command owners. Keep the retired global-owner runtime parsing unavailable. This is the explicitly approved repair scope; shipped bare targets and explicit approval targets remain supported as documented in this PR.

The current-main source gap is also resolved. I fetched 00c6efb256f1739600bcc367e19316742622c405 and directly compared every changed path against the pinned base: none has intervening main changes. The two newer main commits affect model fallback and UI panel tabs, outside this repair. The previously failing main audit passed on attempt 4, and exact-head PR CI passed on attempt 2.

ClawSweeper reports no code or security findings on 024ac64b6257b089efd405cfb64c46d0fe86f96f. Its remaining upgrade-boundary decision and source-verification requests are satisfied. Final Crabbox migration and authorization proof, 30 voice E2E cases, 163 focused cases, full changed-file checks, and independent branch review are complete. Proceeding with the prepared merge.

@steipete
steipete merged commit 8b8fb1f into main Sep 4, 2026
336 of 339 checks passed
@steipete
steipete deleted the fix/legacy-owner-identity-migration branch September 4, 2026 03:04
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…nclaw#137780)

* fix(doctor): migrate legacy channel command owners

Rewrite legacy channel:user:id command owners before runtime consumes them, report each repaired entry, and remove duplicate Discord owner-prefix parsing. Preserve canonical IDs and unrelated channel policies.

Fixes openclaw#137749. Reported by Shakker (@shakkernerd).

* fix(discord): preserve shipped owner target syntax

Keep bare user, pk, mention, and name matching contracts while doctor owns the retired channel:user:id envelope. Unqualified identities have different meanings across channel owners, so migration must not guess a Discord namespace.

Remove redundant owner matching wrappers and repair the stale realtime close-race test to observe the provider audio boundary after late readiness.

* refactor(discord): share command owner selection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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.

Bug: Doctor leaves legacy channel owner identities unresolved after upgrade

1 participant