Skip to main content

agentmux_srv/backend/agent_session/
mod.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Agent-anchored session zones: one zone per agent definition, keyed by
5//! `definition_id` (not account or block).
6//!
7//! Zone names: active = `agent:<defId>:current`,
8//! archived = `agent:<defId>:archive:<unix_ms>`. Each zone holds
9//! `output.state.json` (full UI snapshot) and `output` (raw NDJSON stream).
10//! (This used to cite a SPEC_CONTINUATION_SESSION_PERSISTENCE_2026_05_23
11//! design doc that was never committed; the zone layout above is the
12//! contract.)
13//!
14//! ## Public API surface
15//!
16//! Every public item is reachable as `agent_session::<submod>::<item>` (the
17//! submodules are `pub`). The `pub use` re-exports below additionally preserve
18//! the pre-split flat paths (`agent_session::<item>`) that callers across the
19//! crate already import, so this reorganization changed no call site. The flat
20//! re-export set is exactly the names other modules import; the remaining public
21//! items (zone-name builders, archive internals, migration stat/marker types)
22//! stay reachable through their submodule path — and the test module reaches
23//! them there.
24
25pub mod archive;
26pub mod global_store;
27pub mod history_summary;
28pub(crate) mod helpers;
29pub mod migrations;
30pub mod session_io;
31pub mod zone_naming;
32
33// Flat re-exports preserving the pre-split `agent_session::<item>` call sites
34// used elsewhere in the crate (blockcontroller shell/ and persistent/,
35// transcript_backfill.rs, server agent_handlers/ and app_api/,
36// bootstrap/stores.rs, the migrations/ m000x steps).
37pub use archive::{archive_session, list_archives};
38pub use global_store::{
39    agent_zone_for_block_meta, global_transcript_store, set_global_transcript_store,
40};
41pub use migrations::{block_zones_look_incomplete, migrate_block_zones_v1, migrate_promote_template_sessions_v1, MIGRATION_MARKER_V1};
42pub use session_io::{
43    append_session_output, heal_global_snapshot_source_block_ids, read_session_state,
44    write_session_state, OUTPUT_FILE, SNAPSHOT_FILE, TSIDX_FILE,
45};
46pub use zone_naming::{agent_current_zone, is_valid_definition_id};
47
48#[cfg(test)]
49mod tests;