Skip to content

fix(doctor): keep the owner target kind when migrating legacy channel owners - #167059

Merged
steipete merged 1 commit into
mainfrom
upd/upd-owner-migration-keep-kind
Oct 8, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-owner-migration-keep-kind

Conversation

@steipete

@steipete steipete commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes heartbeat delivery silently stopping after an update runs Doctor and rewrites a Discord owner from discord:user:<id> to discord:<id>. Closes #166724. Thanks @jaiden0 for reporting the repeated update regression.

User Impact

Updates preserve the owner's direct-message target kind and command authority. Doctor repairs an already-stripped kind only when matching config backup history records it; otherwise it leaves the owner unchanged and reports the exact correction for the operator to confirm. Warnings do not block updates, and repairs use the existing config backup/write path. No new settings are required.

Why This Change Was Made

The existing plugin messaging.directTargetStyle declaration owns whether a direct target needs user:. Discord exposes the same declaration and classifier through its setup and runtime views, so cold Doctor can consult the existing read-only installed-plugin resolver. Doctor now preserves that kind, and command authorization lets the declaring plugin normalize it to a native sender ID. Core contains no Discord-specific policy, and heartbeat's direct-target admission remains unchanged. An unavailable plugin contract also leaves the authored kind intact.

Recovery reads the existing five config backups, requires the entire owner list to match the old migration's output, and stops at changed owners, includes, unreadable files, or unsafe paths. It never invents a user kind for an ambiguous ID.

Evidence

  • Pre-fix regressions: the real Discord plugin resolves a direct route before migration and no-route afterward; the original Doctor flow neither reports the actionable warning nor restores the recorded kind.
  • The two changed suites plus Discord channel/shared suites passed three times on the completed fix: 67 tests per run, with wrapper wall times of 150.42s, 128.35s, and 88.86s including compiler preparation. Commands used node scripts/run-vitest.mjs <files> --maxWorkers=1 in isolated state. The new regression file takes 3.651–5.145s of test time and also checks command authorization, Telegram normalization, and refusal to guess from unsafe or conflicting history.
  • All 73 importer files passed once: 1,174 tests across 14 Vitest shards, 2,114.92s total including runtime build and compiler preparation. No remote compute was used.
  • Additional Discord importers passed: 32 files, 704 tests across 8 shards in 189.41s. pnpm build passed (304.3s); the final committed runtime refresh passed (pnpm build qaRuntime, 48.2s). The build emitted a UI startup-JS gzip advisory (365.1 KiB versus 364.7 KiB), with exit 0. The clean-head Discord import profile qualified successfully (98.3 MiB peak RSS).
  • Every selected check:changed step passed. The aggregate command was interrupted at extension test typechecking with exit 143 and no diagnostic; the identical typecheck passed on direct replay, then every remaining planned check passed. The termination cause is unresolved. Native extension lint passed; the direct alternative also detected the deliberate canary and passed after its removal.
  • P1 autoreview was attempted; the review service returned HTTP 401 Unauthorized and produced no report. Lead review of the PR head is pending.

Production: +195/-18 lines. Tests: +231/-6. Docs: +25/-4. CI timing is pending.

Test-cost observations

The new backup-boundary cases initially used an unnecessarily broad Doctor fixture; the first case took 21.615s. A file-only temporary directory and the existing loaded plugin registry reduced that case to 4ms. The full Doctor persistence cases retain the real flow and avoid plugin installation. The cold installed-plugin case uses the real Discord setup object through a tiny installed entry, reducing repeated source-graph loading from 84.798s to 37–67ms; it fails with the original setup contract and passes with the shared target-kind contract.

Existing slow suites were retained. Summed reported test times: doctor-config-flow.legacy-composition.test.ts 255.613s, doctor-config-flow.session-store-owner.test.ts 182.811s, doctor-config-flow.cron-owners.test.ts 166.584s, doctor-config-flow.billing-route.test.ts 160.249s, and doctor-config-flow.include-refusal.test.ts 128.147s.

Individual slow cases: July-upgrade convergence 141.858s (four built CLI processes); fleet capture reuse 47.993s (six Doctor health flows); billing deferral via run ID/result channel 37.750s/40.508s (three prepare-and-persist cycles each); explicit ACP reset 30.570s; Doctor warning sanitization 33.544s; July TTS locator preservation 30.827s. The shared cost owner is Doctor preflight and subprocess lifecycle: several suites lack a retained reader scope, while billing changes the update environment and invalidates cached children. These are source-backed cost explanations, not measured profiling attribution. No timeout, retry, or assertion changes were made to these suites.

The direct extension-lint command used both changed extension files with --tsconfig test/tsconfig/tsconfig.extensions.test.json. Canary output, followed by the clean run:

extensions/discord/src/shared.ts:40:7: error eslint(no-unused-vars): Variable 'l1495UnusedLintCanary' is declared but never used. Unused variables should start with a '_'. help: Consider removing this declaration.
extension lint exit: 0

Keep plugin-declared direct-user kinds during owner normalization and native sender authorization. Recover stripped kinds only from matching config history; otherwise report the exact correction. Share Discord target-kind metadata with its setup surface so cold Doctor can inspect installed plugins.

Fixes #166724. Reported by @jaiden0.
@clawsweeper

clawsweeper Bot commented Oct 8, 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 channel: discord Channel integration: discord gateway Gateway runtime commands Command implementations size: M labels Oct 8, 2026
@steipete
steipete marked this pull request as ready for review October 8, 2026 08:30
@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 8, 2026, 4:37 AM ET / 08:37 UTC.

ClawSweeper review

What this changes

Doctor preserves plugin-required direct-user target kinds and restores previously stripped kinds from matching config backups.

Example: Run Doctor with owner discord:user:100000000000000001.

  • Before: Doctor rewrites the owner to discord:100000000000000001, causing owner-targeted heartbeats to skip with no-route.
  • After: Doctor preserves discord:user:100000000000000001 so heartbeat routing identifies a direct-message destination.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful regression coverage supports the direction, but the incomplete persisted-owner cutover breaks established Discord workflows.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The supplied repository state identifies a member-authored area repair, outside the ordinary external-contributor proof gate. Reported validation exercises production routing and disk-backed Doctor through an in-process harness, not the installed updater. Persisted owner compatibility remains insufficient because Discord consumers reject the restored form and the required published-driver upgrade/rollback cell is absent.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Discord heartbeat alerts silently stop after an update rewrites the configured owner's direct-message target.
Reason: The linked report establishes broken shipped behavior with a clear routing mechanism. Prior area ownership and the author's explanation support the direction without introducing settings or a new plugin API.

Regression provenance

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

Merge readiness

⛔ Blocked before merge - 6 items remain

This PR addresses a current shipped regression, but its owner-format cutover is incomplete: preserved or recovered Discord owners still lose voice access and owner-derived exec approvals.

Priority: P1
Reviewed head: 08427b5c2e7dbb8b3d4fb66f73426aad44ffb964

Before merge

  • Update Discord owner consumers for the preserved target kind (P1) - Keeping discord:user:100000000000000001 here, or restoring it from a backup, now makes that form canonical. However, resolveDiscordCommandOwnerEntries() still filters out every discord:user: entry at extensions/discord/src/command-owners.ts:10. Consequently, Doctor's recovery changes a working bare owner into an empty voice admission list and removes owner-derived exec approvers. Existing voice-command and exec-approval tests explicitly assert these rejections. Update the shared Discord selector and its consumers/tests together so repairing heartbeat routing preserves these existing owner workflows.
  • Resolve merge risk (P1) - Published-driver × candidate upgrade and rollback compatibility remains unproven; the supplied disk-backed harness does not exercise the installed updater required by repository policy.
  • Complete next step (P2) - Provide the repository-required published-driver × candidate upgrade/rollback evidence after the owner-consumer repair.
  • Improve patch quality - Repair the shared Discord owner selector and verify voice access and owner-derived exec approvals after Doctor preservation and recovery.
  • Improve patch quality - Record a supported published-updater upgrade and rollback against the repaired candidate.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Update Discord owner consumers for the preserved target kind — src/commands/doctor-command-owner.ts:57-60

Tests

  • Missing end-to-end proof: The supplied tests cover routing, core authorization, and Doctor persistence, but omit Discord voice and owner-derived approval consumers after migration. No shipped published-updater upgrade/rollback scenario is supplied; reported baseline failures were not independently executed in this read-only review.
Agent review details

How this fits together

Doctor repairs persisted OpenClaw configuration during maintenance and updates. Configured channel owners feed both heartbeat destinations and privileged command authorization.

flowchart TD
  A[Current owner configuration] --> C[Doctor owner migration]
  B[Existing config backups] --> D[Recorded-kind recovery]
  E[Channel target contract] --> C
  E --> D
  C --> F[Persisted owner configuration]
  D --> F
  F --> G[Heartbeat direct-message routing]
  F --> H[Command and approval authorization]
Loading

Technical review

Best possible solution:

Complete the typed-owner cutover in Discord's shared selector while retaining native sender matching, direct-only heartbeat admission, and conservative backup recovery.

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

Yes, from source: main strips the Discord user kind before direct-only heartbeat admission, and the proposed preserved form is rejected by existing Discord owner-consumer tests. No runtime execution was performed during this read-only review.

Is this the best way to solve the issue?

No, the current patch leaves competing interpretations of the owner format; updating the existing shared Discord selector completes the otherwise appropriate plugin-owned repair.

Full review comments:

  • [P1] Update Discord owner consumers for the preserved target kind — src/commands/doctor-command-owner.ts:57-60
    Keeping discord:user:100000000000000001 here, or restoring it from a backup, now makes that form canonical. However, resolveDiscordCommandOwnerEntries() still filters out every discord:user: entry at extensions/discord/src/command-owners.ts:10. Consequently, Doctor's recovery changes a working bare owner into an empty voice admission list and removes owner-derived exec approvers. Existing voice-command and exec-approval tests explicitly assert these rejections. Update the shared Discord selector and its consumers/tests together so repairing heartbeat routing preserves these existing owner workflows.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4dc47557f10d.

Merge-risk options

Maintainer options:

  1. Complete and verify the owner-format cutover (recommended)
    Repair the shared Discord owner selector and record a supported published updater upgrading to the candidate, including owner preservation and rollback.

Provenance checked

Testing

Proof path: in-process harness. Added test files: 2.

Security

None.

Evidence

Acceptance criteria:

  • [P1] pnpm test src/commands/doctor-command-owner-route.test.ts src/commands/doctor-config-flow.workspace-persistence.test.ts --maxWorkers=1.
  • [P1] pnpm test extensions/discord/src/voice/command.test.ts extensions/discord/src/voice/speaker-context.test.ts extensions/discord/src/exec-approvals.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8b8fb1f adds extensions/discord/src/command-owners.ts:10 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8b8fb1ff3b9f; files: extensions/discord/src/command-owners.ts)

PR surface

Source +177, Tests +225, Docs +21. Total +423 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 195 18 +177
Tests 2 231 6 +225
Docs 2 25 4 +21
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 451 28 +423

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-command-owner-recovery.ts, migration/backfill/repair: src/commands/doctor-command-owner.ts, migration/backfill/repair: src/commands/doctor-config-flow.ts, unknown-data-model-change: src/commands/doctor-command-owner-recovery.ts, unknown-data-model-change: src/commands/doctor-command-owner.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #166724
Summary: This PR is the explicitly linked candidate repair for the reported Doctor-induced heartbeat routing failure.

Members:

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

Labels

Label changes:

  • add P1: An official shipped update repeatedly suppresses Discord owner heartbeats, and the proposed repair introduces another owner-workflow failure.
  • add merge-risk: 🚨 compatibility: Recovered owner configuration becomes a form that existing Discord voice and exec-approval consumers explicitly reject.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: An official shipped update repeatedly suppresses Discord owner heartbeats, and the proposed repair introduces another owner-workflow failure.
  • merge-risk: 🚨 compatibility: Recovered owner configuration becomes a form that existing Discord voice and exec-approval consumers explicitly reject.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

@steipete
steipete merged commit 24c3201 into main Oct 8, 2026
211 of 217 checks passed
@steipete
steipete deleted the upd/upd-owner-migration-keep-kind branch October 8, 2026 08:42
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
RomneyDa added a commit that referenced this pull request Oct 16, 2026
…and exec approvals (#172385)

* fix(discord): honor discord:user:<id> command owners in voice access and exec approvals

Doctor now preserves commands.ownerAllowFrom entries such as
discord:user:<id> as the canonical direct-user owner form (#167059), but
the Discord owner selector still dropped every discord:user: entry as a
retired envelope. For an owner list holding only that form the selector
returned an empty list, so /vc rejected the owner with "You are not
authorized to use this command.", voice speakers lost owner status, and
owner-derived exec approvers resolved to none, leaving execApprovals
enabled "auto" disabled.

Keep discord:user: entries in the selector. The existing allowlist and
approver normalizers already resolve user:<id> to the native sender id.

* test(discord): prove typed owner approval authority at the capability boundary

* test(discord): prove typed owner vc leave authority follows live owner policy

---------

Co-authored-by: Dallin Romney <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 16, 2026
…and exec approvals (#172385)

* fix(discord): honor discord:user:<id> command owners in voice access and exec approvals

Doctor now preserves commands.ownerAllowFrom entries such as
discord:user:<id> as the canonical direct-user owner form (#167059), but
the Discord owner selector still dropped every discord:user: entry as a
retired envelope. For an owner list holding only that form the selector
returned an empty list, so /vc rejected the owner with "You are not
authorized to use this command.", voice speakers lost owner status, and
owner-derived exec approvers resolved to none, leaving execApprovals
enabled "auto" disabled.

Keep discord:user: entries in the selector. The existing allowlist and
approver normalizers already resolve user:<id> to the native sender id.

* test(discord): prove typed owner approval authority at the capability boundary

* test(discord): prove typed owner vc leave authority follows live owner policy

---------

Co-authored-by: Dallin Romney <[email protected]>
(cherry picked from commit 2a41d1f)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…and exec approvals (openclaw#172385)

* fix(discord): honor discord:user:<id> command owners in voice access and exec approvals

Doctor now preserves commands.ownerAllowFrom entries such as
discord:user:<id> as the canonical direct-user owner form (openclaw#167059), but
the Discord owner selector still dropped every discord:user: entry as a
retired envelope. For an owner list holding only that form the selector
returned an empty list, so /vc rejected the owner with "You are not
authorized to use this command.", voice speakers lost owner status, and
owner-derived exec approvers resolved to none, leaving execApprovals
enabled "auto" disabled.

Keep discord:user: entries in the selector. The existing allowlist and
approver normalizers already resolve user:<id> to the native sender id.

* test(discord): prove typed owner approval authority at the capability boundary

* test(discord): prove typed owner vc leave authority follows live owner policy

---------

Co-authored-by: Dallin Romney <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 27, 2026
…and exec approvals (#172385)

* fix(discord): honor discord:user:<id> command owners in voice access and exec approvals

Doctor now preserves commands.ownerAllowFrom entries such as
discord:user:<id> as the canonical direct-user owner form (#167059), but
the Discord owner selector still dropped every discord:user: entry as a
retired envelope. For an owner list holding only that form the selector
returned an empty list, so /vc rejected the owner with "You are not
authorized to use this command.", voice speakers lost owner status, and
owner-derived exec approvers resolved to none, leaving execApprovals
enabled "auto" disabled.

Keep discord:user: entries in the selector. The existing allowlist and
approver normalizers already resolve user:<id> to the native sender id.

* test(discord): prove typed owner approval authority at the capability boundary

* test(discord): prove typed owner vc leave authority follows live owner policy

---------

Co-authored-by: Dallin Romney <[email protected]>
(cherry picked from commit 2a41d1f)
(cherry picked from commit 3b0a9f5)
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 gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doctor migrates discord:user:<id> owner to discord:<id>, which breaks heartbeat owner route (no-route)

1 participant