kernel/origin.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! Where a session branched off.
7//! The part `crates/kernel/spec/Event.lean` specifies this module together
8//! with `kernel::event`.
9
10use serde::{Deserialize, Serialize};
11
12use crate::event::{RunId, Seq};
13
14/// Where a session branched off: one run of this city, and the line in
15/// it that the branch starts after.
16///
17/// **The pair has one home, and its older spelling stays where it is.**
18/// A `run_forked` record spells this same pair as `{from, at_seq}`,
19/// because a ledger already written cannot be re-spelled; a value this
20/// build passes around is the type below. A reader holding a `RunForked`
21/// builds an `Origin` from it rather than keeping both.
22///
23/// `at_seq` is the line itself and not the line after it: a branch
24/// inherits through that line, and the safe point the rebuild settles on
25/// is that value or an earlier one (`runtime::fork::inherited_indexed`).
26#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
27#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
28pub struct Origin {
29 /// The run the branch came from.
30 pub run: RunId,
31 /// The last line of it the branch inherits.
32 pub at_seq: Seq,
33}