Skip to content

feat(session-ingest): clone and export a session up to a message - #7439

Merged
iscekic merged 6 commits into
mainfrom
igor/fork-cut-ingest
Oct 13, 2026
Merged

iscekic merged 6 commits into
mainfrom
igor/fork-cut-ingest

Conversation

@iscekic

@iscekic iscekic commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

bot: Adds an inclusive message cut to the session clone and export. This supports "Fork from here" in the mobile app.

Summary

  • createSessionForCloudAgent accepts cloneUpToMessageId. GET /api/session/:id/export accepts upToMessageId.
  • One shared filter (util/message-cut.ts) keeps the session row, messages with ID <= the cut, and the parts of those messages. It drops session_diff. The filter reads only item IDs, so R2-backed rows need no body read.
  • The clone copy, resume, and digest steps use the same filter. The resume cursor now counts rows that the cut skipped.
  • The clone stage identity includes the cut. A different cut resets an unfinished stage, or returns destination_conflict for a published one.
  • An unknown cut returns clone_cut_not_found (RPC) or 404 clone_cut_not_found (export).
  • A clone or export without a cut is unchanged.

Related

Verification

  • Ran on a VM: the session-ingest test suite passes, and the typechecks for session-ingest and session-ingest-contracts are clean.
  • The new tests cover these cases: an inclusive cut with a late part in ingest order, the dropped diff, no cut, an unknown cut, a stage with a different cut, a resume after the size limit, and the export route.

@kilo-code-bot

kilo-code-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

I re-reviewed the incremental commits and verified both prior findings are resolved: rollback now recognizes a cut-built stage by source + destination, and stageCloneBatch clears cloneUpToMessageId on a full clone; no new issues in the changed lines.

Files Reviewed (4 files)
  • services/session-ingest/src/dos/SessionIngestDO.ts - verified fix: full-clone staging deletes the stale cut key
  • services/session-ingest/src/dos/SessionIngestDO.test.ts - test mock + new stale-cut test, clean
  • services/session-ingest/src/session-ingest-rpc.ts - verified fix: mismatch on the same source + destination is treated as this clone
  • services/session-ingest/src/session-ingest-rpc.test.ts - new rollback test for a cut stage, clean
Previous Review Summary (commit c76fc53)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c76fc53)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The message-cut clone/export feature is otherwise well-tested and correct; the highest-risk gap is that the clone rollback RPC cannot match a message-cut stage, so a failed cut clone's destination row, DO stage, and R2 bodies are left behind.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/dos/SessionIngestDO.ts 1557 Clone rollback (deleteSessionForCloudAgent) omits the cut, so it can no longer match a cut stage; rollback silently no-ops and leaves the destination row, stage, and R2 bodies behind.

SUGGESTION

File Line Issue
services/session-ingest/src/dos/SessionIngestDO.ts 1533 cloneUpToMessageId is written but never cleared; the "absent <=> full clone" invariant relies entirely on whole-table ingestMeta wipes.
Files Reviewed (13 files)
  • packages/session-ingest-contracts/src/rpc-contract.ts - 1 suggestion area (contract)
  • services/session-ingest/src/app.ts - clean
  • services/session-ingest/src/clone/session-clone.ts - verified correct (resume cursor / digests)
  • services/session-ingest/src/dos/SessionIngestDO.test.ts - clean
  • services/session-ingest/src/dos/SessionIngestDO.ts - 1 warning, 1 suggestion
  • services/session-ingest/src/routes/api.test.ts - clean
  • services/session-ingest/src/routes/api.ts - clean
  • services/session-ingest/src/services/session-export.ts - clean
  • services/session-ingest/src/session-ingest-rpc.test.ts - clean
  • services/session-ingest/src/session-ingest-rpc.ts - clean (see warning)
  • services/session-ingest/src/util/message-cut.test.ts - clean
  • services/session-ingest/src/util/message-cut.ts - verified correct
  • services/session-ingest/test/integration/session-ingest-do.test.ts - clean

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 51K · Output: 10.5K · Cached: 572.4K

Review guidance: REVIEW.md from base branch main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants