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
55
56
//! Arena-based generational allocation for Murk simulations.
//!
//! Provides bump-allocated arenas with generation tracking for
//! efficient, deterministic memory management. This crate is one
//! of two that may contain `unsafe` code (along with `murk-ffi`).
//!
//! # Architecture
//!
//! The arena uses a double-buffered ("ping-pong") design:
//!
//! ```text
//! PingPongArena (orchestrator)
//! ├── ArenaBuffer × 2 (alternating published/staging)
//! │ └── SegmentList → Segment[] (64MB bump-allocated Vec<f32>)
//! ├── SparseSlab + sparse SegmentList (dedicated, not ping-pong'd)
//! ├── Arc<StaticArena> (gen-0 forever, shared across vectorized envs)
//! ├── ScratchRegion (per-tick temp space)
//! └── FieldDescriptor (FieldId → FieldEntry mapping, swapped on publish)
//! ```
//!
//! # Field mutability classes
//!
//! - **PerTick:** Fresh allocation each tick in the staging buffer.
//! - **Sparse:** Copy-on-write — shared until mutated, then new allocation.
//! - **Static:** Allocated once at world creation, shared via `Arc`.
//!
//! # Phase 1 safety
//!
//! All allocations are `Vec<f32>` with zero-init. No `MaybeUninit`, no
//! `unsafe`. Phase 2 (after WP-4) will introduce bounded `unsafe` in
//! `raw.rs` for `MaybeUninit` + `FullWriteGuard` optimisation.
// Public re-exports for the primary API surface.
pub use ArenaConfig;
pub use ArenaError;
pub use ;
pub use ;
pub use ScratchRegion;
pub use ;