fix: migrate QQBot credential backups to SQLite KV#89597
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a05199de90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| stateDir: string; | ||
| }): CredentialBackupCandidate[] { | ||
| const roots = new Set<string>([path.join(params.stateDir, "qqbot", "data")]); | ||
| const home = params.env.HOME || params.env.USERPROFILE; |
There was a problem hiding this comment.
Scan OS-home QQBot backups when HOME is unset
When OpenClaw runs with a custom OPENCLAW_HOME/OPENCLAW_STATE_DIR but without HOME or USERPROFILE exported, this only scans the active state dir and an env-derived home. The legacy runtime path this replaces used getQQBotDataPath()/getHomeDir(), which checks os.homedir() first, so existing credential backups under the real OS home are no longer migrated; since runtime now reads SQLite only, QQBot accounts with empty credentials will not be restored. Include the same OS-home resolver (or os.homedir()) in these candidate roots.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 2:59 PM ET / 18:59 UTC. Summary PR surface: Source -49, Tests +100, Docs -1. Total +50 across 16 files. Reproducibility: yes. Source inspection shows the PR removes runtime JSON fallback while Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the SQLite-only runtime direction, add QQBot credential-backup markers to the read-only preflight detector with focused coverage, and require redacted real migration proof before maintainer approval. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows the PR removes runtime JSON fallback while Is this the best way to solve the issue? No. Moving imports out of runtime is the right boundary, but the current patch still needs read-only preflight detection and real migration proof before it is the safest merge path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5db7c3797de3. Label changesLabel justifications:
Evidence reviewedPR surface: Source -49, Tests +100, Docs -1. Total +50 across 16 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7a41d64f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| legacyStateMigrations: { | ||
| specifier: "./legacy-state-migrations-api.js", | ||
| exportName: "detectQQBotLegacyStateMigrations", |
There was a problem hiding this comment.
Wire QQBot backup migration into external doctor path
This exposes the migration only through the bundled-channel setup-entry path, but the doctor collector calls listBundledChannelLegacyStateMigrationDetectors for these setup-entry migrations while external/plugin-installed migrations come from listPluginDoctorStateMigrationEntries; QQBot is also excluded from the core bundled dist (EXCLUDED_CORE_BUNDLED_PLUGIN_DIRS contains qqbot). In a packaged install where @openclaw/qqbot is installed externally, openclaw doctor --fix therefore never loads this detector, and since this commit removed the runtime JSON fallback, legacy qqbot/data/credential-backup*.json files are not imported and wiped credentials stay unrecovered. Add a QQBot doctor contract migration or teach the doctor migration collector to include external setup-entry detectors.
Useful? React with 👍 / 👎.
c7a41d6 to
e375f37
Compare
|
Rebased onto current
Land-ready proof on head
Known proof gap: no live QQBot network call with real credentials; the migration proof used the real built doctor path with synthetic data. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer decision on the new read-only preflight finding: explicit doctor/Gateway recovery is the intended boundary; no core QQBot file marker should be added.
Therefore a pure The PR body now states this trigger boundary explicitly. It already includes redacted real built-CLI proof: @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
* fix: migrate qqbot credential backups to sqlite kv * fix: complete qqbot sqlite migration cleanup * fix: harden qqbot doctor state migration
* fix: migrate qqbot credential backups to sqlite kv * fix: complete qqbot sqlite migration cleanup * fix: harden qqbot doctor state migration
* fix: migrate qqbot credential backups to sqlite kv * fix: complete qqbot sqlite migration cleanup * fix: harden qqbot doctor state migration
* fix: migrate qqbot credential backups to sqlite kv * fix: complete qqbot sqlite migration cleanup * fix: harden qqbot doctor state migration
What Problem This Solves
QQBot still carried four legacy file-backed runtime paths after its SQLite conversion:
The caches are disposable and should not have compatibility readers. Credential backups are persistent recovery data, so deleting their JSON runtime path without a doctor migration would strand existing backups.
This is a follow-up to #84314 and the isolation issue #84313.
Why This Change Was Made
doctor-contract-apiinstead of coupling core or setup code to QQBot.OPENCLAW_STATE_DIRlegacy path; never search other profiles or the ambient home directory.0600.The session, known-user, and ref-index files are caches and intentionally receive no migration. They rebuild in SQLite.
User Impact
After upgrading and running
openclaw doctor --fix, existing active-profile QQBot credential backups move into theqqbot/credential-backupsSQLite namespace. Migrated JSON sources remain as.migratedarchives with mode0600.QQBot runtime no longer reads or writes legacy cache files. Failed or capacity-constrained credential imports leave their source files in place for a safe retry.
Migration trigger boundary is intentional: upgrade installs, explicit doctor runs, Gateway startup, and state-mutating CLI commands run state migration preflight. A pure read-only
openclaw statusinvocation does not mutate state when a QQBot backup is its only legacy marker; status does not need credential recovery. This avoids adding an external plugin's file names to the core config guard.No config or environment-variable contract changes.
QQBOT_DATA_DIRsupport remains separate work in #39461 / #78253.Evidence
Automated validation
pnpm test extensions/qqbot -- --reporter=dot— 69 files, 597 tests passed.pnpm build— passed on rebased heade375f378e764b354eda2bfff0a03de96f4fdff44.tbx_01kwfg2v7tfn8371rwsbkw7c7f— extension typechecks/tests, lint, database-first guard, docs, and import-cycle checks passed: https://github.com/openclaw/openclaw/actions/runs/28540114567git diff --check— passed.Real doctor migration proof
Ran the built CLI against an isolated HOME and state directory with one synthetic legacy credential backup:
Post-run verification:
No real credential or QQBot network call was used.
Compatibility / Migration
openclaw doctor --fix.CHANGELOG.mdduring releases.