Skip to main content

Module carry_forward

Module carry_forward 

Source
Expand description

A new version starts with the data of the version before it (docs/specs/SPEC_UPGRADE_FOR_USERS_AND_AGENTS_2026_10_15.md §6).

Installed and portable builds keep their databases per version (channels/<ch>/versions/<v>/data/db/), so without this an upgrade starts with an empty objects.db: no windows, no layouts, and no pane’s agent:sessionid to resume. On the first start of a version, before its pre-migration snapshot and migrations, each database is copied from the newest older version in the same channel; migrations then bring it up to date as they would after an in-place upgrade.

Each copy is VACUUM INTO a temporary file, renamed into place: a consistent snapshot even if the older version is still running (two portable folders side by side), and never a half-written file. Any failure leaves the new version to start fresh, as it did before. Dev builds keep their data per branch, and local task package builds get a channel of their own, so neither has an older version to copy from.

This is the only thing that seeds a version’s databases. A channel whose install predates per-version data still has its old channels/<ch>/data/db/; it is copied only while no version has data yet. The launcher used to copy that folder into every new version before srv started, so srv found an objects.db in place and carried nothing forward: each upgrade started from that old data, without the layout the previous version’s quit had saved (docs/incident/RCA_UPGRADE_LOSES_LAYOUT_2026_10_22.md). Each copy records where it came from ([CARRIED_FROM_FILE]), and the first start after an upgrade checks it ([continuity_problem]).

Functions§

from_previous_version
On the first start of version (no objects.db in db_dir yet), copy the databases of the newest older version in the same channel (or the channel’s pre-versioning ones, [source_for]), and record where they came from ([CARRIED_FROM_FILE]). Returns the version directory copied from, or None when there was nothing to do or the copy failed (logged; the version then starts fresh).
stop_message
The message a start that cannot carry the previous version’s data forward stops with: the cause in plain words, that the previous version’s data was not touched, and that this version did not start empty. error is what try_from_previous_version returned; it goes last, for the log.
try_from_previous_version
from_previous_version, telling “nothing to copy” (Ok(None)) apart from “there was data to copy and copying it failed” (Err), which migrate --prepare must not treat as a fresh start: that would relaunch the new version without the user’s data (migrations/prepare.rs). Copies that failed are removed again, so a retry starts clean.