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 (2026-05-03)
16//!
17//! M1 first slice — warm-up modules ([`message`], [`handle`], [`clock`],
18//! [`boundary`]). The dispatcher itself, batch engine, PAUSE/RESUME, and
19//! `set_deps` follow incrementally. See
20//! `~/src/graphrefly-ts/docs/implementation-plan.md` Phase 13.7 for the
21//! full slice plan; reference impl at
22//! `~/src/graphrefly-ts/src/__experiments__/handle-core/`.
23//!
24//! # Safety
25//!
26//! No `unsafe` is permitted in this crate or anywhere in the workspace.
27//! Enforced by `#![forbid(unsafe_code)]` at the root. See `CLAUDE.md`
28//! Rust invariant 1.
29
30#![forbid(unsafe_code)]
31#![cfg_attr(not(feature = "std"), no_std)]
32#![warn(rust_2018_idioms, unreachable_pub)]
33#![warn(clippy::pedantic)]
34// `clippy::pedantic` includes a few that are too noisy for this codebase.
35#![allow(
36 clippy::module_name_repetitions,
37 clippy::missing_errors_doc,
38 // Some Core methods take `&self` for architectural consistency (they're
39 // conceptually Core methods even if they don't read self state directly,
40 // since the state lives in CoreState behind self.state.lock()). The lint
41 // would force them into associated fns, breaking the consistent API.
42 clippy::unused_self,
43 // doc_markdown false-positives on protocol identifiers like `T`, `JS`, etc.
44 clippy::doc_markdown,
45)]
46
47mod batch;
48pub mod boundary;
49pub mod clock;
50pub mod handle;
51pub mod hash;
52pub mod mailbox;
53pub mod message;
54pub mod node;
55pub(crate) mod op_state;
56pub mod owned;
57#[cfg(feature = "tokio")]
58pub mod timer;
59pub mod topology;
60
61pub use batch::BatchGuard;
62
63pub use boundary::{BindingBoundary, CleanupTrigger, DepBatch, FnEmission, FnResult};
64pub use clock::{monotonic_ns, wall_clock_ns};
65pub use handle::{FnId, HandleId, LockId, NodeId, NO_HANDLE};
66pub use hash::sha256_hex;
67pub use mailbox::{CoreMailbox, DeferFn, DeferQueue, MailboxOp, SendDeferFn};
68pub use message::{Message, Messages};
69pub use node::{
70 Core, CoreFull, DeferredProducerOp, EqualsMode, NodeFnOrOp, NodeKind, NodeOpts,
71 NodeRegistration, OperatorOp, OperatorOpts, PausableMode, PauseError, RegisterError,
72 ResumeReport, SetDepsError, SetPausableModeError, Sink, SubscribeError, SubscriptionId,
73 TerminalKind, UpError,
74};
75pub use owned::OwnedCore;
76pub use topology::{TopologyEvent, TopologySink, TopologySubscriptionId};