Repository navigation
fix: prevent Telegram migration no-op loops - #108744
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e46a2c1189
ℹ️ 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".
|
|
||
| ### Fixes | ||
|
|
||
| - **Legacy plugin-state migrations:** preflight namespace capacity before importing, keep capped sources intact with a clear warning instead of partially migrating, and drop Telegram sent-message entries at the TTL boundary. Fixes #108286. Thanks @jamiezigelbaum. |
There was a problem hiding this comment.
Remove the normal-fix changelog entry
This commit is a normal fix, but the root AGENTS.md says CHANGELOG.md is release-only and must not be edited for normal PRs or direct main fixes because release generation owns it. Keeping this manual entry risks duplicating or skewing generated release notes for #108286; put the release-note context in the PR/commit metadata instead and leave CHANGELOG.md unchanged.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c901ebd5a
ℹ️ 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".
| if (missingEntryCount > namespaceRemainingCapacity) { | ||
| warnings.push( | ||
| `Skipped migrating ${plan.label} because plugin state namespace ${plan.namespace} has room for ${namespaceRemainingCapacity} of ${missingEntryCount} missing entries; left legacy source in place`, | ||
| ); |
There was a problem hiding this comment.
Deduplicate missing target keys before capacity checks
When a legacy source emits duplicate rows for the same target key and the namespace has room for the unique key but not for every duplicate row, this preflight now skips the entire migration and leaves the source in place even though store.register() would cover the data. This can happen with append-log imports such as extensions/imessage/src/state-migrations.ts:198-208, which maps each sent-echo JSONL row directly to resolveIMessageSentEchoEntryKey(...) without deduping; with 255 existing rows and two duplicate legacy echoes, the single missing key fits a 256-entry namespace, but missingEntryCount is 2 so this check warns forever instead of importing/archiving.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
* fix(state): prevent partial legacy imports * chore: drop release-owned changelog edit * test(telegram): consolidate TTL migration coverage * style(telegram): format migration fixture
…r-nothing PR #108744 (13a52cf) made the startup preflight skip a legacy plugin-state import entirely whenever the target namespace (or the per-plugin cap) could not fit every missing entry, and rolled back the whole import when a mid-import cap eviction was detected. For caches whose migration targets the same namespace the live cache writes to (e.g. the Telegram sent-message cache), a busy install keeps the namespace near-full, so the migration became a permanent no-op that retried on every startup until legacy entries aged out. - Import newest-first up to the remaining capacity (namespace and per-plugin) instead of skipping everything; entries carry an optional timestamp (falling back to remaining TTL) for recency ordering. - On a mid-import cap eviction, roll back only the entry whose write triggered the eviction, restore the evicted live row when its value is still known, and keep everything imported so far. - Leave the legacy source in place while entries remain deferred so later startups import the remainder as capacity frees; archival of fully-covered or empty sources is unchanged. - Preflight now uses the effective per-plugin cap so capacity math matches store enforcement. Requested by obviyus: startup/upgrade must never be blocked and the migration must not permanently no-op. Co-Authored-By: Claude Fable 5 <[email protected]>
* fix(state): prevent partial legacy imports * chore: drop release-owned changelog edit * test(telegram): consolidate TTL migration coverage * style(telegram): format migration fixture
Closes #108286
AI-assisted: yes. I understand the migration and cache behavior changed here.
What Problem This Solves
Fixes an issue where operators running
openclaw doctor --fixcould repeatedly retain a Telegram legacy sent-message source when plugin-state capacity was exhausted, without a clear explanation that none of the remaining records fit.Why This Change Was Made
Legacy plugin-state imports now preflight all genuinely missing rows against namespace and plugin capacity. An import either has room for the full missing set or is skipped with an explicit warning; already covered sources remain eligible for cleanup. Telegram sent-message migration also drops records at the exact TTL boundary instead of manufacturing a one-millisecond lifetime.
User Impact
Expired Telegram sent-message rows no longer consume migration capacity. Capacity-blocked migrations stay retryable, avoid partial progress, and tell operators exactly how many missing records fit. Fully covered sources can still be archived.
Evidence
src/commands/doctor-state-migrations.test.ts— 89 tests passed on Blacksmith Testbox (run).node scripts/run-vitest.mjs extensions/telegram/src/state-migrations.test.ts— 9 tests passed on the current head.pnpm check:changed— format, typechecks, core/extension lint, database-first guards, import-cycle checks, and related static gates passed (21m13s, Testbox).openclaw doctor --fix --non-interactiveproof: TTL-boundary source archived without a cap warning; a full namespace with one missing row warnedroom for 0 of 1, left the source in place, and produced the same warning on rerun.git diff --checkpassed.