Skip to content

fix: prevent Telegram migration no-op loops - #108744

Merged
steipete merged 4 commits into
mainfrom
codex/fix-108286-telegram-migration
Jul 16, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/fix-108286-telegram-migration

Conversation

@steipete

@steipete steipete commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

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 --fix could 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.
  • Path-scoped pnpm check:changed — format, typechecks, core/extension lint, database-first guards, import-cycle checks, and related static gates passed (21m13s, Testbox).
  • Source-blind openclaw doctor --fix --non-interactive proof: TTL-boundary source archived without a cap warning; a full namespace with one missing row warned room for 0 of 1, left the source in place, and produced the same warning on rerun.
  • git diff --check passed.
  • Fresh local autoreview: no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram commands Command implementations size: S maintainer Maintainer-authored PR labels Jul 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread CHANGELOG.md Outdated

### 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +328 to +331
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`,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@steipete
steipete merged commit 13a52cf into main Jul 16, 2026
116 checks passed
@steipete
steipete deleted the codex/fix-108286-telegram-migration branch July 16, 2026 08:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
* fix(state): prevent partial legacy imports

* chore: drop release-owned changelog edit

* test(telegram): consolidate TTL migration coverage

* style(telegram): format migration fixture
clawsweeper Bot pushed a commit that referenced this pull request Jul 17, 2026
…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]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* fix(state): prevent partial legacy imports

* chore: drop release-owned changelog edit

* test(telegram): consolidate TTL migration coverage

* style(telegram): format migration fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram commands Command implementations maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram sent-message-cache legacy-state migration silently no-ops forever when entries are expired and the plugin-state namespace is at cap

1 participant