1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Pure session-lifecycle core for swarm sessions.
//!
//! This module holds the orthogonal state dimensions, the versioned event type,
//! and a total reducer over them. It is deliberately free of scheduler,
//! database, transport, and backend dependencies: callers feed observations
//! and events, the reducer returns a verdict.
//!
//! State dimensions (docs/SWARM-REFACTOR-GRILLME.md §2.2):
//! - `AgentPhase` — process-side agent fact reported by Pi/pi-onlyne.
//! - `DeliveryPhase` — intent delivery fact for the current turn exit.
//! - `ResourcePhase` — backend resource fact (pane/tab/terminal).
//! - `RecoveryPhase` — recovery substate of an idle/draining session.
//!
//! The four phase vocabularies are the wire's own `SessionProjection` fields: one
//! definition per dimension serves both the reducer and the projection, and
//! `Display`/`FromStr` are that vocabulary's only spelling table.
//!
//! The task's result (`TaskState`: pending/done/failed/cancelled) is not a
//! dimension of this tuple. The task ledger owns it; `project` reads it as an
//! argument, so a session row no longer doubles as the task record and the
//! reducer never has to invent a receipt to go with a result.
//!
//! Public projection ([`Lifecycle`], proto's own event vocabulary) is derived on demand from the four
//! dimensions plus the caller's task state. Nothing stores it: a reader that
//! wants the public view calls `project` on the tuple it just read.
//!
//! Versioning (§2.3): every observation and event carries `(generation, seq)`.
//! The reducer gates events on the current version watermark:
//! - stale generation or stale/duplicate seq: `Ignored` with a diagnostic,
//! current state kept.
//! - same-generation duplicate event id: `Ignored` (idempotent replay).
//! - a newer generation arrives only through `AdoptNewGeneration` (old
//! generation already gone) or `Supersede` (operator repair with attested
//! dead old generation); every other newer-generation event is `Rejected`.
//! - a new generation while the previous one is still live is `Rejected`
//! (duplicate live generation); the core keeps the first generation.
//!
//! §3.3: same-task duplicate Pi processes are gated by these adoption rules;
//! post-`Gone` sessions only accept adoption, supersede, and heartbeat.
pub use crateLifecycle;
pub use ;
pub use ;
pub use ;
pub use apply;
pub use ;