Skip to content

fix(pairing): normalize account key in legacy allowFrom filename parsing - #110415

Merged
steipete merged 5 commits into
openclaw:mainfrom
wangyan2026:fix/allowfrom-accountkey-normalize-110187
Aug 5, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
wangyan2026:fix/allowfrom-accountkey-normalize-110187

Conversation

@wangyan2026

@wangyan2026 wangyan2026 commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #110187

What Problem This Solves

Fixes an upgrade failure where a legacy account-scoped pairing allowlist file with a case-preserved account suffix, such as telegram-HY_RIN_Bot-allowFrom.json, could not be matched to the configured Telegram account. The migration left the file in place, emitted a warning, and gateway startup refused to report ready on every retry.

Why This Change Was Made

The legacy pairing migration compared the filename suffix verbatim with a normalized account key. The repair accepts case-only differences, but determines ownership from case-insensitive equality between the raw filename account suffix and the raw configured account ID.

safeAccountKey still validates configured candidates, but its lossy output is never used for equality. This matters in both directions: ops..bot must not become ops_bot, and a canonical-looking ops_bot filename must not be attributed to configured account ops.bot. When both ops/bot and ops_bot are configured, the raw ops_bot owner remains distinguishable and receives only its own file.

The migration also treats the complete set of case-equivalent source filenames as one attribution decision. If two real files differ only by account-suffix case—even when one is the exact lowercase spelling—every member remains ambiguous and untouched. This prevents multiple source allowlists from being merged and deleted on case-sensitive filesystems.

Provenance caveat: the shipped v2026.7.1 writer already used safeAccountKey and therefore emitted lowercase canonical filenames. The reported uppercase file is real observed upgrade state, but its producer has not been identified in repository history. This PR recovers bounded case-only state without broadening punctuation or multi-source attribution.

User Impact

A single case-preserved filename whose raw suffix identifies exactly one configured account can upgrade normally: Doctor/startup imports the allowlist into shared SQLite state and removes the source.

Multiple case-equivalent files remain ambiguous and untouched. Punctuation-normalized lookalikes, unknown accounts, non-canonical implicit-default spellings, and other unresolved ownership remain on disk for operator recovery rather than risking cross-account authorization.

Evidence

Exact head: 584cd74e8b8bb037587fe55fd0e67259d27c0a28

The branch is rebased onto current origin/main.

Focused proof:

$ node scripts/run-vitest.mjs src/infra/state-migrations.channel-pairing.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  11 passed (11)

$ node scripts/run-vitest.mjs src/commands/doctor-state-migrations.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  92 passed (92)

$ node scripts/run-vitest.mjs src/commands/doctor-config-preflight.state-migration.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  29 passed (29)

$ OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs -- src/infra/state-migrations.channel-pairing.ts src/infra/state-migrations.channel-pairing.test.ts src/commands/doctor-state-migrations.test.ts
# passed

$ git diff --check origin/main...HEAD
# passed

Source-blind CLI validation ran openclaw doctor --fix --non-interactive --yes with isolated state roots on a verified case-sensitive APFS volume:

Scenario Observable result
AmbiguousAcct + AMBIGUOUSACCT both files retained; reported ambiguous; no SQLite rows
exact exactacct + ExactAcct both files retained; reported ambiguous; no SQLite rows
singleton HY_RIN_Bot source removed; hy_rin_bot:user-e imported
filename ops..bot, configured ops_bot source retained; unresolved; no SQLite rows
filename ops_bot, configured ops.bot source retained; unresolved; no SQLite rows
filename Ops_Bot, configured ops/bot and ops_bot source removed; imported only as ops_bot:user-h
filename DEFAULT, configured/default candidate source retained; unresolved; no SQLite rows

The unique canonical safe-key fallback suggested during review is intentionally not retained: it would let punctuation normalization create authorization ownership between distinct raw account IDs such as ops_bot and ops.bot. The migration accepts only case differences; ambiguous or punctuation-derived ownership remains an operator decision.

The regression suite covers both punctuation-normalization directions, exact raw ownership beside a punctuation lookalike, case-folded source collision sets, singleton case recovery, and source retention/deletion.

Final branch-level Codex autoreview at maximum priority P1 reported no accepted/actionable findings.

PR surface against current base:

  • Production: +43 / -3 — records collision-set, raw-owner, and literal-default safety before import/removal.
  • Tests: +129 / -9
  • Total: +172 / -12 across 3 files

AI Assistance

  • AI-assisted: Yes
  • Human maintainer reviewed and narrowed the final attribution and migration behavior: Yes

@clawsweeper clawsweeper Bot added 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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 1:37 AM ET / 05:37 UTC.

ClawSweeper review

What this changes

The PR changes legacy pairing allowlist migration to recover case-preserved account filename suffixes while retaining ambiguous, nonliteral-default, and punctuation-confusable files for operator recovery.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open as a landable fix candidate: current main still performs the lossy filename comparison, while the final head repairs it without allowing punctuation-derived authorization reassignment. The exact-head Doctor transcript and focused boundary coverage address the prior review moves; no actionable patch defect was found.

Priority: P1
Reviewed head: 584cd74e8b8bb037587fe55fd0e67259d27c0a28

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-bounded migration repair with inspectable real Doctor output and no remaining correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The exact-head redacted Doctor transcript demonstrates import/removal and retention outcomes for the changed migration behavior; no private values are exposed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The exact-head redacted Doctor transcript demonstrates import/removal and retention outcomes for the changed migration behavior; no private values are exposed.
Evidence reviewed 7 items Current-main defect: Current main compares the raw filename suffix with safeAccountKey(accountId), which lowercases and rewrites punctuation; a case-preserved suffix therefore remains unresolved.
Repair boundary: The PR validates configured candidates but matches raw punctuation-preserving IDs case-insensitively, preserving literal-default and unresolved behavior.
Collision and cleanup protection: The PR computes full case-folded filename collision sets and retains every member before any SQLite import or source deletion.
Findings None None.
Security None None.

How this fits together

Doctor discovers legacy channel pairing allowlist files, attributes each to a configured account, then imports it into shared SQLite state and removes the source. This attribution boundary affects gateway startup and must never move an allowlist between accounts.

flowchart LR
  A[Legacy allowlist files] --> B[Doctor migration scan]
  C[Configured channel accounts] --> D[Case-only ownership check]
  B --> D
  D --> E{Unique owner with no collision?}
  E -->|yes| F[Shared SQLite allowlist]
  E -->|no| G[Warning and retain source]
  F --> H[Gateway startup]
Loading

Before merge

  • Resolve merge risk (P1) - This changes one-way upgrade behavior for authorization data: a regression could import and delete a legacy allowlist under the wrong account, so the case-only, collision-retention, and punctuation non-aliasing safeguards must remain intact through the final merge result.
  • Complete next step (P2) - No repair lane is needed; let exact-head required checks complete, then perform normal maintainer merge review.
Agent review details

Security

None.

PR surface

Source +40, Tests +120. Total +160 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 43 3 +40
Tests 2 129 9 +120
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 172 12 +160

Review metrics

Metric Value Why it matters
Production vs test delta production +43/-3; tests +129/-9 The net production growth is justified by the migration ownership and collision-safety invariant, with focused regression coverage exceeding the implementation delta.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-state-migrations.test.ts, serialized state: src/infra/state-migrations.channel-pairing.test.ts, serialized state: src/infra/state-migrations.channel-pairing.ts, unknown-data-model-change: src/infra/state-migrations.channel-pairing.test.ts, unknown-data-model-change: src/infra/state-migrations.channel-pairing.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #110187
Summary: This PR is the candidate repair for the canonical legacy allowlist filename attribution bug.

Members:

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

Merge-risk options

Maintainer options:

  1. Land the bounded migration (recommended)
    After exact-head required checks pass, accept case-only recovery while retaining collision, punctuation, and nonliteral-default sources for operator recovery.
  2. Pause for broader recovery semantics
    Do not merge if maintainers want punctuation-normalized legacy names to recover automatically, because that needs an explicit migration design that cannot cross account authorization boundaries.

Technical review

Best possible solution:

Merge the bounded case-only recovery after exact-head required checks pass, keeping ambiguous, punctuation-derived, and nonliteral-default filenames retained rather than guessing authorization ownership.

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

Yes. Current main's raw-suffix versus normalized-key comparison at src/infra/state-migrations.channel-pairing.ts:110 directly establishes the failure, and the PR provides an exact-head Doctor transcript for the repaired path.

Is this the best way to solve the issue?

Yes. Resolving only case-equivalent raw account IDs at the Doctor migration owner boundary is safer than reusing lossy safe-key equality, which would conflate punctuation-distinct authorization owners.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The exact-head redacted Doctor transcript demonstrates import/removal and retention outcomes for the changed migration behavior; no private values are exposed.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head redacted Doctor transcript demonstrates import/removal and retention outcomes for the changed migration behavior; no private values are exposed.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A failed legacy pairing migration can block an existing user's gateway from reaching ready state after upgrade.
  • merge-risk: 🚨 compatibility: The PR changes which legacy account-scoped files are eligible for migration and deletion during upgrade.
  • merge-risk: 🚨 security-boundary: Legacy allowlists authorize senders, so incorrect account attribution could grant permissions to the wrong account.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head redacted Doctor transcript demonstrates import/removal and retention outcomes for the changed migration behavior; no private values are exposed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head redacted Doctor transcript demonstrates import/removal and retention outcomes for the changed migration behavior; no private values are exposed.

Evidence

What I checked:

Likely related people:

  • steipete: The SQLite pairing migration originated in the pairing refactor and this person authored the final four commits that constrain the repair's ownership and collision behavior. (role: introduced behavior and recent area contributor; confidence: high; commits: 024b7d5aa860, bf8c238ad0be, d095c82b3bc0; files: src/infra/state-migrations.channel-pairing.ts, src/infra/state-migrations.doctor.ts, src/pairing/pairing-store-keys.ts)

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 (19 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-01T08:48:57.608Z sha 775981bfaef2e4f356eeeea734cf58d5eefa479f :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T10:21:22.791Z sha e70c4084109b4d6f0c9d09605007d78c31076bf4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-02T11:18:27.179Z sha e70c4084109b4d6f0c9d09605007d78c31076bf4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T02:26:19.153Z sha 246ca4086b0fd6651a51f6105b533da5a8229e5d :: needs real behavior proof before merge. :: [P1] Keep nonliteral default suffixes unresolved
  • reviewed 2026-08-05T03:15:23.158Z sha 246ca4086b0fd6651a51f6105b533da5a8229e5d :: needs real behavior proof before merge. :: [P1] Keep nonliteral default suffixes unresolved
  • reviewed 2026-08-05T04:05:00.490Z sha 3be786c8be2877645cc09e0de3d2f412fb855165 :: needs real behavior proof before merge. :: [P1] Keep nonliteral default suffixes unresolved
  • reviewed 2026-08-05T04:11:42.300Z sha 3be786c8be2877645cc09e0de3d2f412fb855165 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T04:37:01.118Z sha d38029ec4e144e3f265d5e112a50d14adf9e0768 :: needs real behavior proof before merge. :: [P1] Restore unique canonical safe-key migration | [P1] Reject nonliteral default filename suffixes

@wangyan2026
wangyan2026 force-pushed the fix/allowfrom-accountkey-normalize-110187 branch 3 times, most recently from f115d31 to f8cfcb9 Compare July 18, 2026 05:10
@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 Jul 18, 2026
@wangyan2026
wangyan2026 force-pushed the fix/allowfrom-accountkey-normalize-110187 branch from f8cfcb9 to ee67b5a Compare July 18, 2026 05:30
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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 Jul 18, 2026
@wangyan2026
wangyan2026 force-pushed the fix/allowfrom-accountkey-normalize-110187 branch from ee67b5a to 0180931 Compare July 18, 2026 07:05
@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. 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. labels Jul 18, 2026
@wangyan2026
wangyan2026 force-pushed the fix/allowfrom-accountkey-normalize-110187 branch 2 times, most recently from d7c6200 to 736998d Compare August 1, 2026 06:23
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 5, 2026
@steipete
steipete force-pushed the fix/allowfrom-accountkey-normalize-110187 branch from 246ca40 to 3be786c Compare August 5, 2026 03:48
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Please review exact head 3be786c8be2877645cc09e0de3d2f412fb855165. The branch is rebased onto current main, preserves complete case-folded filename collision sets, and has refreshed case-sensitive APFS CLI proof, focused suites, LOC, and provenance in the PR body.

@clawsweeper

clawsweeper Bot commented Aug 5, 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:

@steipete
steipete force-pushed the fix/allowfrom-accountkey-normalize-110187 branch from 3be786c to d38029e Compare August 5, 2026 04:27
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Please review exact head d38029ec4e144e3f265d5e112a50d14adf9e0768. The final repair matches raw account IDs by case-folding only, preserves case-colliding source sets, rejects punctuation-normalized attribution in both directions, and has refreshed APFSX CLI proof, focused suites, changed gates, LOC, and P1 autoreview evidence in the PR body.

@clawsweeper

clawsweeper Bot commented Aug 5, 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:

@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Exact-head land-readiness proof for d38029ec4e144e3f265d5e112a50d14adf9e0768.

Source-blind Doctor validation used isolated synthetic state roots on a verified case-sensitive APFS volume. Paths below are redacted to <state>.

$ openclaw doctor --fix --non-interactive --yes

# Two non-exact case-equivalent files
files: telegram-AMBIGUOUSACCT-allowFrom.json, telegram-AmbiguousAcct-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-AMBIGUOUSACCT-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-AmbiguousAcct-allowFrom.json
SQLite allow entries: []

# Exact lowercase plus case variant
files: telegram-ExactAcct-allowFrom.json, telegram-exactacct-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-ExactAcct-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-exactacct-allowFrom.json
SQLite allow entries: []

# Singleton case-only recovery
files after Doctor: []
output: Migrated 1 telegram/hy_rin_bot allowFrom entry → shared SQLite state
SQLite allow entries: [{"account_id":"hy_rin_bot","entry":"user-e"}]

# Filename punctuation must not alias configured raw account
filename ops..bot, configured ops_bot: file retained; unresolved; SQLite []
filename ops_bot, configured ops.bot: file retained; unresolved; SQLite []

# Exact raw owner beside punctuation-normalized sibling
filename Ops_Bot, configured ops/bot + ops_bot: file removed
output: Migrated 1 telegram/ops_bot allowFrom entry → shared SQLite state
SQLite allow entries: [{"account_id":"ops_bot","entry":"user-h"}]

Focused proof:

$ node scripts/run-vitest.mjs src/infra/state-migrations.channel-pairing.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  10 passed (10)

$ node scripts/run-vitest.mjs src/commands/doctor-state-migrations.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  92 passed (92)

$ OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs -- src/infra/state-migrations.channel-pairing.ts src/infra/state-migrations.channel-pairing.test.ts src/commands/doctor-state-migrations.test.ts
passed: format, typecheck core, typecheck core tests, lint changed files, pairing guards, import cycles, database-first guard, and related changed lanes

$ git diff --check origin/main...HEAD
# passed

Final Codex branch autoreview with --max-priority P1: no accepted/actionable findings.

wangyan2026 and others added 5 commits August 4, 2026 22:14
… parsing

parseAllowFromFilename extracted the account segment from filenames
without normalizing it via safeAccountKey, so non-canonical spellings
(e.g. HY_RIN_Bot vs hy_rin_bot) could never match configured accounts.
This left the file unresolved, producing a startup migration warning
that blocks gateway readiness on every restart.

Normalize accountKey via safeAccountKey before comparing so that raw
and canonical spellings resolve to the same account. Wrap in try/catch
so pathological filename segments skip safely instead of throwing.
Guard non-canonical DEFAULT segments: when safeAccountKey maps a
non-literal-default segment (e.g. "DEFAULT") to the canonical key
"default", skip the filter so the file remains unresolved instead of
being attributed to the implicit bundled default account and deleted.
Keep the implicit bundled-default fallback on the literal canonical
suffix (accountKey === DEFAULT_ACCOUNT_ID). Ambiguity detection
remains unchanged.

Related to openclaw#110187
@steipete
steipete force-pushed the fix/allowfrom-accountkey-normalize-110187 branch from d38029e to 584cd74 Compare August 5, 2026 05:30
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Exact-head land-readiness proof for 584cd74e8b8bb037587fe55fd0e67259d27c0a28.

Source-blind Doctor validation used isolated synthetic state roots on a verified case-sensitive APFS volume. Paths below are redacted to <state>.

$ openclaw doctor --fix --non-interactive --yes

# Two non-exact case-equivalent files
files: telegram-AMBIGUOUSACCT-allowFrom.json, telegram-AmbiguousAcct-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-AMBIGUOUSACCT-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-AmbiguousAcct-allowFrom.json
SQLite allow entries: []

# Exact lowercase plus case variant
files: telegram-ExactAcct-allowFrom.json, telegram-exactacct-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-ExactAcct-allowFrom.json
output: Legacy channel allowFrom channel/account is ambiguous; left in place at <state>/credentials/telegram-exactacct-allowFrom.json
SQLite allow entries: []

# Singleton case-only recovery
files after Doctor: []
output: Migrated 1 telegram/hy_rin_bot allowFrom entry → shared SQLite state
SQLite allow entries: [{"account_id":"hy_rin_bot","entry":"user-e"}]

# Filename punctuation must not alias configured raw account
filename ops..bot, configured ops_bot: file retained; unresolved; SQLite []
filename ops_bot, configured ops.bot: file retained; unresolved; SQLite []

# Exact raw owner beside punctuation-normalized sibling
filename Ops_Bot, configured ops/bot + ops_bot: file removed
output: Migrated 1 telegram/ops_bot allowFrom entry → shared SQLite state
SQLite allow entries: [{"account_id":"ops_bot","entry":"user-h"}]

# Nonliteral default remains unresolved
filename DEFAULT, configured/default candidate: file retained
output: Legacy channel allowFrom channel/account is unresolved; left in place at <state>/credentials/telegram-DEFAULT-allowFrom.json
SQLite allow entries: []

Focused proof:

$ node scripts/run-vitest.mjs src/infra/state-migrations.channel-pairing.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  11 passed (11)

$ node scripts/run-vitest.mjs src/commands/doctor-state-migrations.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  92 passed (92)

$ node scripts/run-vitest.mjs src/commands/doctor-config-preflight.state-migration.test.ts --reporter=verbose
Test Files  1 passed (1)
Tests  29 passed (29)

$ OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs -- src/infra/state-migrations.channel-pairing.ts src/infra/state-migrations.channel-pairing.test.ts src/commands/doctor-state-migrations.test.ts
passed: format, typecheck core, typecheck core tests, lint changed files, pairing guards, import cycles, database-first guard, and related changed lanes

$ git diff --check origin/main...HEAD
# passed

Final Codex branch autoreview with --max-priority P1: no accepted/actionable findings.

Maintainer decision on the remaining prior review move: do not restore punctuation-based safe-key fallback. A unique fallback can still move authorization between punctuation-distinct raw account IDs (ops_bot and ops.bot). This repair accepts case-only differences; punctuation-derived ownership stays unresolved.

@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Please review exact head 584cd74e8b8bb037587fe55fd0e67259d27c0a28. Nonliteral default suffixes now remain unresolved. The PR body and proof comment contain inspectable redacted APFSX Doctor output, focused/startup suites, changed gates, LOC, P1 autoreview, and the maintainer decision rejecting punctuation-derived safe-key ownership.

@clawsweeper

clawsweeper Bot commented Aug 5, 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 proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@steipete
steipete merged commit 20bd49d into openclaw:main Aug 5, 2026
132 of 140 checks passed
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
…ing (openclaw#110415)

* [AI] fix(pairing): normalize account key in legacy allowFrom filename parsing

parseAllowFromFilename extracted the account segment from filenames
without normalizing it via safeAccountKey, so non-canonical spellings
(e.g. HY_RIN_Bot vs hy_rin_bot) could never match configured accounts.
This left the file unresolved, producing a startup migration warning
that blocks gateway readiness on every restart.

Normalize accountKey via safeAccountKey before comparing so that raw
and canonical spellings resolve to the same account. Wrap in try/catch
so pathological filename segments skip safely instead of throwing.
Guard non-canonical DEFAULT segments: when safeAccountKey maps a
non-literal-default segment (e.g. "DEFAULT") to the canonical key
"default", skip the filter so the file remains unresolved instead of
being attributed to the implicit bundled default account and deleted.
Keep the implicit bundled-default fallback on the literal canonical
suffix (accountKey === DEFAULT_ACCOUNT_ID). Ambiguity detection
remains unchanged.

Related to openclaw#110187

* fix(pairing): constrain legacy filename recovery

Co-authored-by: WangYan <[email protected]>

* fix(pairing): preserve case-colliding legacy files

Co-authored-by: WangYan <[email protected]>

* fix(pairing): match legacy files to raw account ids

Co-authored-by: WangYan <[email protected]>

* fix(pairing): keep default suffix literal

Co-authored-by: WangYan <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations 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. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

parseAllowFromFilename in dist/state-migrations never matches safeKey'd account IDs

2 participants