[Bug]: v2 session-layout migration bricks resumed sessions — "Canonical history target is missing after migration" retry loop (checkpoint says migrated, but messages.jsonl was never written)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- sqlite, typescript
Hướng nghiên cứu
Start in the ensureCanonicalHistoryMaterialized() function in the local-runtime-v2 session-system history code (canonical-history-materializer.js), focusing on the early-return path taken when a row exists in local_runtime_pi_history_file_migrations. Also check where that checkpoint row is upserted relative to writing messages.jsonl. Done means a session whose checkpoint exists but whose target file is missing re-materializes instead of throwing, with a test covering that state.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report Draft (for MiniMax-AI/minimax-code)
Labels: bug, desktop
Title
[Bug]: v2 session-layout migration bricks resumed sessions — "Canonical history target is missing after migration" retry loop (checkpoint says migrated, but messages.jsonl was never written)
Product or interface
Desktop app (the same code path is shared with local-runtime-v2 used by the CLI)
Version and platform
- MiniMax Code desktop: 3.1.7
- OS: macOS 26.6.2 (Apple Silicon)
- Log upload ID: available on request (Settings → General → Upload logs)
Summary
After the app migrated session storage to the new dated layout (~/.minimax/v2/sessions/YYYY/MM/DD/…-session_…, layout: "v2-final-dated-session"), a large fraction of sessions are permanently stuck in a preflight retry loop when resumed:
Agent preflight failed. — Canonical history target is missing after migration: mvs_…
Root cause
ensureCanonicalHistoryMaterialized() (in @mavis/local-runtime-v2/dist/service/session-system/messages/history/canonical-history-materializer.js) throws when:
- a checkpoint row exists in
local_runtime_pi_history_file_migrations(so it takes the "already migrated" early-return path), and - the target
messages.jsonldeclared in the session'smanifest.jsondoes not exist on disk.
That is exactly the state the migration left behind. On an affected install:
- 115 of 119 checkpoint rows exist, while the corresponding dated session directories contain only
manifest.json— the declaredmessages.jsonl/ledger.jsonl/display.jsonl/snapshot.jsonwere never written. - The two sessions whose checkpoints were removed were re-materialized successfully on the next resume, which confirms the rest of the pipeline works — only the checkpoint/file invariant is broken.
Evidence sketch (per-affected-session directory):
manifest.json <- present (declares messages.jsonl, ledger.jsonl, snapshot.json, …)
messages.jsonl <- MISSING
ledger.jsonl <- MISSING
snapshot.json <- MISSING
Note: local_runtime_message_rows still holds a display-layer subset of the messages (e.g. for one healthy session: 194 sqlite rows vs 425 messages in the canonical file), and local_runtime_messages is an empty legacy table. So the checkpoint claims migration completed, the canonical file is absent, and sqlite alone cannot fully restore the original history.
Impact
- Any affected session cannot be resumed; every turn fails at preflight and the app retries indefinitely.
- On one machine, 115/119 sessions were affected (sessions created between Oct 13 and Oct 30).
- Because the canonical file was never written and the sqlite store is a strict subset, the lost portion of history is not recoverable locally.
Steps to reproduce
- Desktop 3.1.7 on macOS, with sessions that predate the v2 layout migration.
- Resume an affected session (checkpoint row present, dated dir contains only
manifest.json). - Send any message → preflight fails with
Canonical history target is missing after migration, repeats on every retry.
Workaround (verified)
Delete the affected rows from local_runtime_pi_history_file_migrations. On the next resume the materializer takes the non-checkpoint path, selects the sqlite source and materializes a fresh messages.jsonl. Confirmed working on 2 sessions (files regenerated, sessions resume normally). Caveat: the rebuilt history is the sqlite subset, not the full original file history.
Suggested fixes
- Fail-safe direction: when a checkpoint exists but the target file is missing, fall back to re-materialization (treat the checkpoint as invalid) instead of throwing. The current throw is unrecoverable for users without manual DB surgery.
- Ordering: write the target artifacts atomically before upserting the checkpoint, so the invariant "checkpoint ⇒ target exists" can never be violated.
- Optionally: a startup consistency sweep that detects checkpoint-without-target and self-repairs.
Related issues
Possibly adjacent to #490 (compaction lineage validation), #536 (in-flight turn dropped during V2 cutover migration) and #547 (bricked v2 session among other data-integrity bugs) — but this is a distinct invariant failure with a precise repro and root cause.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.3k
- Fork
- 315
- Merge trung bình
- 3 giờ 54 phút
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MiniMax-AI/minimax-code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MiniMax-AI/minimax-code#639 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
MiniMax-AI/minimax-code#636 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MiniMax-AI/minimax-code#615 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
MiniMax-AI/minimax-code#556 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MiniMax-AI/minimax-code#507 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MiniMax-AI/minimax-code
Issue tương tự
-
area:api bug good first issue priority:high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Doezer/Questarr#1486 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:import difficulty:good-first good first issue help wanted priority:P1 roadmap size:S type:test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Sergey-Bar/Penny#245 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mihazs/lazysh#3377 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Approve the Cloudflare agent plugin for harness sessionsCó thể đã có người làm @joshtsch đã nhận hôm nay. Đang mởenhancement ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày