graphrefly_core/lib.rs
1//! `GraphReFly` handle-protocol core dispatcher.
2//!
3//! This crate is the heart of the protocol: dispatcher, message tiers,
4//! batch coalescing, wave engine, dep tracking, equals-substitution,
5//! first-run gate, PAUSE/RESUME with lockIds, INVALIDATE broadcast,
6//! versioning lifecycle, atomic dep mutation (`set_deps`).
7//!
8//! It operates entirely on opaque [`HandleId`](handle::HandleId) integers —
9//! user values `T` never enter the core. Per-language bindings (napi-rs for
10//! JavaScript, pyo3 for Python, wasm-bindgen for WASM) hold the
11//! value-to-handle registry. Equals-substitution under
12//! `EqualsMode::Identity` is a `u64` compare with zero FFI; user-fn
13//! invocation is the only mandatory boundary crossing per fn fire.
14//!
15//! # Status
16//!
17//! M1 complete (dispatcher, batch/wave engine, PAUSE/RESUME, `set_deps`,
18//! lifecycle, partitioned concurrency). Track progress in
19//! `docs/migration-status.md`. TS reference prototype:
20//! `~/src/graphrefly-ts/src/__experiments__/handle-core/`.
21//!
22//! # Safety
23//!
24//! No `unsafe` is permitted in this crate or anywhere in the workspace.
25//! Enforced by `#![forbid(unsafe_code)]` at the root. See `CLAUDE.md`
26//! Rust invariant 1.
27
28#![forbid(unsafe_code)]
29#![cfg_attr(not(feature = "std"), no_std)]
30#![warn(rust_2018_idioms, unreachable_pub)]
31#![warn(clippy::pedantic)]
32// `clippy::pedantic` includes a few that are too noisy for this codebase.
33#![allow(
34 clippy::module_name_repetitions,
35 clippy::missing_errors_doc,
36 // Some Core methods take `&self` for architectural consistency (they're
37 // conceptually Core methods even if they don't read self state directly,
38 // since the state lives in CoreState behind self.state.lock()). The lint
39 // would force them into associated fns, breaking the consistent API.
40 clippy::unused_self,
41 // doc_markdown false-positives on protocol identifiers like `T`, `JS`, etc.
42 clippy::doc_markdown,
43)]
44
45mod batch;
46pub mod boundary;
47pub mod clock;
48pub mod handle;
49pub mod hash;
50pub mod mailbox;
51pub mod message;
52pub mod node;
53pub(crate) mod op_state;
54pub mod owned;
55#[cfg(feature = "tokio")]
56pub mod timer;
57pub mod topology;
58
59pub use batch::BatchGuard;
60
61pub use boundary::{BindingBoundary, CleanupTrigger, DepBatch, FnEmission, FnResult};
62pub use clock::{monotonic_ns, wall_clock_ns};
63pub use handle::{FnId, HandleId, LockId, NodeId, NO_HANDLE};
64pub use hash::sha256_hex;
65pub use mailbox::{CoreMailbox, DeferFn, DeferQueue, MailboxOp, SendDeferFn};
66pub use message::{Message, Messages};
67pub use node::{
68 Core, CoreFull, EqualsMode, NodeFnOrOp, NodeKind, NodeOpts, NodeRegistration, OperatorOp,
69 OperatorOpts, PausableMode, PauseError, RegisterError, ResumeReport, SetDepsError,
70 SetPausableModeError, Sink, SubscribeError, SubscriptionId, TerminalKind, UpError,
71};
72pub use owned::OwnedCore;
73pub use topology::{TopologyEvent, TopologySink, TopologySubscriptionId};