Skip to main content

STATE_VERSION

Constant STATE_VERSION 

Source
pub const STATE_VERSION: u32 = 5;
Expand description

The version of the state document this build writes.

A file-backed state outlives the process that wrote it and is read by the next one, which makes it a stored contract like onevcs’s own registry document — and like that document, the version a document declares decides what is done with it rather than being guessed at. STATE_VERSION is the shape the goldens in tests/golden/ hold, and those goldens are compared byte for byte, so a change to the document cannot reach a consumer without the diff saying so.

2 was what both sides learned when publishing and closing a session came through the interface: VcsState::policy, VcsState::closed_sessions, VcsState::publications, and HostState::titles. 3 is HostState::bodies, the body a change request was opened with. 4 is the two fields a Recoverable gained inside VcsState::preserved — the live session holding a branch, and the lines it would land when it removes more than it adds. 5 is one more of those: whether the branch’s work reached its base, and what says so.

Every change to the document is versioned, an added field included. A field that only ever appears when it holds something is compatible — that is what OLDEST_READABLE_VERSION is for — but compatible is not the same as unremarkable: the version is how a consumer’s checked-in scenario says which shape it was written against, and a document that gained a field without saying so leaves nothing able to tell “this build wrote no body” from “this document predates bodies”. The two answers differ for exactly the journey this crate exists to support.