cell_flow library

A high-performance reactive orchestration layer for the Cell framework (codename Mitosis).

cell_flow extends the core atomicity of package:cell by providing a sophisticated suite of operators designed for complex data-flow transformations, temporal logic, and asynchronous coordination.

The Mitosis Architecture

While the core Cell library handles state and synchronous pulse propagation, Mitosis (cell_flow) provides the machinery for:

Core Mechanics

  1. Unified Graph: Unlike traditional Rx wrappers, cell_flow instructions are compiled directly into the underlying Cell graph. There is no "translation" overhead; a FlowHandle is a first-class citizen of the reactive topography.
  2. Instruction-Based Composition: At its heart, the library uses FlowInstruction objects. These can be chained using the + operator to create reusable "Gate" definitions or "Receptors" independent of specific source cells.
  3. Fluent API: For rapid development, the library provides comprehensive extensions on Cell and FlowHandle, allowing for a declarative, chainable syntax similar to RxDart.

Usage Paradigms

The Fluent Path (Quick Orchestration):

final results = searchInput.cell
    .filter((q) => q.length > 2)
    .debounce(duration: const Duration(milliseconds: 300))
    .asyncMap((q) => api.fetch(q))
    .share();

The Instruction Path (Reusable Gates):

// Define a reusable logic gate
final validationGate = MapValue<String, String>((s) => s.trim()) +
    Filter<String>((s) => s.isNotEmpty) +
    Distinct<String>();

// Apply the gate to any source
final handle = validationGate.toHandle(source: myCell);

Resource Management

Operators in cell_flow automatically manage their internal state and subscriptions. When a FlowHandle is disposed, the underlying orchestration graph is pruned to prevent memory leaks and unnecessary computations.

Further Reading

  • ARCHITECTURE-Flow.md: Theoretical foundations of the Mitosis layer.
  • FEATURES-Flow.md: Detailed catalog of every available operator.
  • HowTo-Fluent_Operator.md: Best practices for method-chaining.
  • HowTo-FlowInstruction-Receptor.md: Advanced custom gate composition.

Classes

AiConfig
A JSON-shaped configuration for an HttpInterpreter.
AiTissueCommand<S>
A FlowInstruction that turns a natural-language sentence into a TissueCommand by asking an Interpreter (a live AI chatbot over HTTP, or a deterministic offline stub) to choose a verb from a closed list.
AiTissueCommandBatch<S>
A FlowInstruction that turns a batch of natural-language sentences into a batch of TissueCommands in a single port call.
AiTissueCommandWithRetry<S>
A FlowInstruction that turns a natural-language sentence into a TissueCommand, retrying the port call up to count extra times on failure.
ApplyRejected
Explicit soft-reject from Cell.apply (not the same as void → null).
ApplyTransactionScope
Async<C>
A foundational marker interface and architectural contract representing an Asynchronous Proxy or Controller for a core component C.
AsyncPriorityQueue<E>
AsyncQueueList<E>
AsyncSynapses<P extends Pulse, L extends Cell>
An Asynchronous Projection of a Synapses instance for non‑blocking signal distribution.
Box<T>
A specialized, lightweight container used to provide a mutable state anchor within the framework's immutable Record architecture.
Cell
A reactive node: holds state (or relays signals), validates every incoming change against a policy, and broadcasts accepted changes to whatever else is listening.
CellBase
The foundational abstract implementation of the Cell interface.
CollectivePulse<P>
A Collective Pulse — a flat bundle of independent pulses travelling together as a single atomic wave.
CollectivePulseBase<P>
The abstract base class for CollectivePulse implementations.
CompensationFailure
Context
Metadata describing a Cell's tier, domain, and operational boundaries — used by TestCell rules to make context-aware decisions.
ContextBase
The foundational implementation of the Operational Environment, providing the core logic for Prototype-based Inheritance and Ontological Resolution.
CycleChecker
A specialized Traversal Guard and Topology Validator, responsible for preventing infinite recursion and ensuring the reactive graph remains a Directed Acyclic Graph (DAG) during signal propagation.
DefaultValue
DefaultValue is a metadata annotation primarily used by the code generation framework (such as build_model) to define a fallback or initial value for fields in a model class.
DeputyContext
Represents the Formal Mandate and declaration of intention for a Deputy.
EmailPattern
EmailPattern is a specialized EntryPattern metadata annotation designed to validate whether a string conforms to a standard email address format.
EntryPattern
EntryPattern is a specialized TestRule metadata annotation that validates whether a string input matches a specific Regular Expression (RegExp).
EphemeralPolicy<C extends Cell>
Defines the Lifecycle Governance for transient reactive nodes.
EvolvedPulse<P>
An immutable signal derived from a previous pulse through a transformation step — a causal link in the signal's journey.
EvolvedPulseBase<P>
The abstract base class for EvolvedPulse implementations.
FilterRule<P extends Pulse>
A filter that can transform, redact, or suppress a Pulse before it is broadcast to downstream observers.
FinalBox<T>
A specialized, write-once container providing a thread-safe, immutable anchor for state that is initialized after construction.
Flow Features Architecture Walkthroughs Demo · ICU Alarm Pipeline Demo · Pharmacy Transactions Demo · Search Stability Demo · Forensic Pipeline HowTo-FlowInstructions Method Chaining (Fluent)
The Transcription Orchestrator for the Cell framework, responsible for converting (transcribing) external stimuli, persistent state, and logic into reactive Cell topographies.
FlowInstruction<C extends Cell, I extends Pulse, O extends Pulse> Demo · ICU Alarm Pipeline Demo · Pharmacy Transactions
Synthesizes a Composite Logic Blueprint—a specialized instruction wrapper designed for fluent orchestration and pipeline assembly.
FlowInstructionBase<C extends Cell, I extends Pulse, O extends Pulse>
The foundational implementation for creating custom reactive logic gates within the Mitosis topography.
FunctionObject
Simple wrapper for functions or records containing function information. Used to pass function metadata through the system.
FunctionTypeObject<T>
Lazy-evaluated version of TypeObject that executes a function to get the value. Useful for deferred initialization or expensive object creation.
Governance<V>
The foundational Authority Protocol for defining structural and behavioral guardrails within the framework's Mandate ontology.
GovernanceEntry<G extends Governance<V>, V>
A strongly-typed key-value pair that represents a single dimension of governance within the framework's Scene-Driven Ontology.
HttpInterpreter
Web/WASM stub for the live HTTP interpreter.
Identity
A utility for materializing unique identities within the somatic graph.
Inheritable
Instruction<C extends Cell, I extends Pulse, O extends Pulse>
A discrete logic unit that defines how a Receptor reacts to a Pulse.
InstructionBase<C extends Cell, I extends Pulse, O extends Pulse>
The foundational implementation and architectural base for all Instruction variants.
InstructionChain<C extends Cell, I extends Pulse, O extends Pulse>
A composite Instruction that orchestrates a sequence of processing units.
Interpreter
The interpreter port — the seam between the NL sentence and the closed verb list.
Lock
A mutual-exclusion lock: serializes access to a shared resource across asynchronous code, similar to Java's synchronized.
MaxLength
MaxLength is a specialized TestRule metadata annotation used primarily by the code generation framework (such as build_model) to enforce structural and data-integrity constraints on model fields.
Modifiable
A specialized architectural marker and base interface for objects that support controlled mutation through the framework's dynamic command pattern.
ModifiableAsync<C extends Cell>
Provides asynchronous execution of operations on a Cell.
MultiLock
A Lock that atomically acquires several other locks together.
Nucleolus
A specialized, terminal implementation of the Nucleus contract representing the framework's "zero-state" and Ontological Root.
Nucleus
The immutable blueprint underlying every Cell — its receptor, testRule, context, synapses, and lifecycle policy, stored separately from the live cell instance.
NucleusBase
The foundational base implementation of the Nucleus contract, providing a memory-optimized storage engine for reactive cell properties.
OpenCell
A specialized, interactive Cell that serves as a Reactive Bridge for external stimulus injection and dynamic topology management.
OpenCellAsync
Represents the Asynchronous Governance Interface for an OpenCell.
PriorityQueue<E>
A collection of elements that maintains a Deterministic Priority Order, serving as a specialized Ranked Execution Buffer for the reactive fabric.
PropagationPolicy
A declarative blueprint defining the Temporal Dynamics and Operational Governance of pulse propagation.
Pulse<P>
A reactive signal — the fundamental unit of communication in the framework.
PulseBase<P>
PulseContext
Represents the Causal Identity and ontological Provenance of a Pulse.
PulseEphemeralPolicy
A governance policy that defines the Lifecycle Constraints and Termination Logic for a Pulse as it traverses the reactive graph.
PulseShell<P, R extends Receptor<Cell>>
A specialized Shell providing a Perceptual Projection of a Pulse to facilitate pre-execution validation and security gating.
QueueList<E>
Receptor<C extends Cell>
The transformation pipeline that decides how a Cell responds to an incoming Pulse.
ReceptorAsync<C extends Cell>
An asynchronous execution handle for a Receptor that facilitates non‑blocking pulse processing and lifecycle synchronization.
ReceptorBase<C extends Cell>
The foundational base implementation of Receptor that provides the core synchronization and pulse propagation engine.
Reject
An interpreter refusal.
Shell<T>
A specialized Defensive Perimeter and Projection Layer representing a formal contract for Bidirectional Mutual Authorization.
StubInterpreter
A deterministic offline interpreter that simulates the HTTP traffic a live chatbot would produce.
Synapses<P extends Pulse, L extends Cell>
The distribution fabric for a Cell's outgoing signals—defining how, when, and to whom a pulse is delivered.
SynapsesBase<P extends Pulse, C extends Cell>
The foundational base implementation for Synapses, serving as the Transmission Engine of the cell.core reactive framework.
SyncBox<T>
A synchronized variant of Box providing Thread-Safe Access and facilitating Atomic State Transitions across concurrent execution boundaries.
SyncCycleChecker
A thread-safe, Synchronized Circular Dependency Guard for asynchronous reactive flows.
SyncQueue<E>
A thread-safe implementation of a PriorityQueue, providing Synchronized Access for prioritized collection-based state.
SyncSet<E>
A thread-safe implementation of a Set, providing Synchronized Access for collection-based state.
SynthesisCell
Represents a Synthesis Cell—a specialized structural node that aggregates signals from multiple source cells into a single unified stream.
TestActionRule<C extends Cell>
A specialized behavioral guard for validating imperative logic and functional action execution within the reactive graph.
TestCell<C extends Cell>
The central validation gate for a Cell – it decides what's allowed.
TestLinkRule<C extends Cell>
A specialized behavioral guard for validating Topological Synapses and graph formation within the reactive framework.
TestPasses
A sentinel implementation of TestCell that always authorises every operation.
TestPulseRule<C extends Cell>
A rule that validates incoming Pulse signals before they reach a cell.
TestRule<C>
A fundamental architectural component representing an Integrity Gate or Validation Guard, responsible for enforcing structural and business invariants across the reactive graph.
TissueCommand
A successfully interpreted command.
TrafficLog
Prints HTTP request/response traffic in a human-readable form.
TransactionBegun
Emitted when a transaction begins.
TransactionCommitted
Emitted when a transaction commits successfully.
TransactionEvent
Base class for all transaction lifecycle events.
TransactionOptions
Configuration options for a Cell.transaction.
TransactionRolledBack
Emitted when a transaction is rolled back.
TransactionTimedOut
Emitted when a transaction times out.
TransactionUpdated
Emitted when a cell is updated during a transaction.
TxApplyBegun
TxApplyCommitted
TxApplyCompensationFailed
TxApplyCompensationRetry
TxApplyEvent
TxApplyOptions
TxApplyRejected
TxApplyRolledBack
TxApplyStaged
TypeObject<T>
Wrapper class for holding typed objects. Provides type safety when working with generic containers.
Unmodifiable
A specialized Marker Interface and architectural anchor used to identify reactive nodes and data structures that have been restricted to Read-Only access.
UnmodifiableCollectivePulse<P>
UnmodifiableEvolvedPulse<P>
UnmodifiablePulse<P>
A read‑only projection of a pulse that enforces structural finality.
UnmodifiablePulseBase<P>
UnmodifiableValueCell<V>
A specialized read‑only proxy of a ValueCell that enforces immutability.
ValidationFailure
Represents a validation failure for a specific cell.
ValueCell<V>
A state‑bearing reactive node – the primary way to manage persistent state in the Cell Framework.
ValueCellAsync<V>
A specialized asynchronous controller for ValueCell, providing a thread‑safe and non‑blocking interface for state interaction.
ValueNucleus<V>
A specialized Nucleus blueprint designed to manage and propagate a discrete, persistent state value of type V.
ValueRange
ValueRange is a specialized TestRule metadata annotation designed to validate whether a numeric input falls within a specific inclusive boundary.
Values
Values is a specialized TestRule that validates whether a given input is present within a predefined collection of allowed values.
WebsiteUrlPattern
WebsiteUrlPattern is a specialized EntryPattern metadata annotation designed to validate whether a string conforms to a standard web URL format.

Enums

AuditLevel
Defines the Observability Granularity and XAI Verbosity required for a Deputy's operations.
Clearance
Defines the Sovereign Physical Laws and structural boundaries of reactive operations within the framework.
CompensationErrorPolicy
HubRouting
Defines how a Cell.hub decides which spoke (child cell) should receive an incoming signal.
Isolation
Defines the Architectural Boundary & State Visibility of a Deputy.
IsolationLevel
Defines the consistency and visibility guarantees for a transaction.
LineageArgument
Defines the specific data field to be extracted when traversing a Pulse's Causal History via the lineage method.
LockOrdering
Defines the order in which locks are acquired during commit.
Mandate<V>
Defines the Capability Profile and Authorization Scope for a Deputy.
Ontology<V>
Defines the Structural Taxonomy, Static Identity, and Architectural Shape of a Cell.
PriorityTier
Defines the Semantic Urgency Tiers for signal execution.
PropagationStrategy
Defines the tactical execution models for Pulse Propagation within the Cell framework's reactive graph.
Provenance<V>
Defines the Causal Accountability, Audit Trail, and Operational Intent of a Pulse.
ReasoningStrategy
Defines the Logical Pedigree and algorithmic origin of a Pulse.
Sensitivity
Defines the Information Classification and data-privacy tier of a Pulse.
Sovereignty
Defines the Commitment Authority and Escalation Protocol assigned to a Deputy.
TissueVerb
Domain types shared by the AI-assisted tissue-command pipeline.

Mixins

Deputy<C extends Cell>
The mixin implementing proxy behavior for Cell.deputy — you don't use this directly.
FlowInstructionMixin<C extends Cell, I extends Pulse, O extends Pulse>
Synthesizes a Materialization Engine—a specialized mixin designed to bridge stateless instructions with live reactive topographies.
GovernanceMixin<G extends Governance<V>, V>
A convenient mixin that provides default implementations for the Governance interface methods.
InstructionChainMixin<C extends Cell, I extends Pulse, O extends Pulse>
A mixin that provides the core execution engine for composite instructions.
OpenReceptorMixin
A mixin that implements the Manual Control Interface for the reactive network.
OpenSynapsesMixin
A mixin that implements the Reactive Topology Interface for OpenCell architectures.

Extensions

CellFlowOperators on Cell
Synthesizes a Fluent Topographical Ingress—a specialized orchestration extension designed to initiate pulse evolution directly from a Cell.
FlowOperators on FlowHandle
Synthesizes a Fluent Topographical Continuation—a specialized orchestration extension designed to chain pulse evolution from an existing FlowHandle.
PulseExtension on Pulse<P>
Provides a fluent, functional API for operating on individual Pulse instances.
PulseIterableExtension on Iterable<Pulse>
Fluent extensions for collections of Pulse objects.
TekartikLockExtension on Lock
Extension on Lock providing synchronous execution when possible, for synchronous computations that don't need to always go through a Future.

Constants

verbByName → const Map<String, TissueVerb>
Lookup table from a verb string to the enum value.

Functions

get<T>(Function fn, {Function? fallback, T? orElse}) → T
A robust functional utility for safely executing operations of type T with multi-stage recovery logic and hierarchical fallbacks.
mapMerge<K, V>(Map<String, dynamic> map, Map<String, dynamic> other) Map<String, dynamic>
systemPrompt(Set<String> verbs) String
Builds the system prompt sent to the live AI chatbot.
withCellLocks<T>(Iterable<Cell> cells, Future<T> body(), {int order(Cell a, Cell b)?}) Future<T>
Convenience: acquire the locks of cells in a deterministic order.
withLocks<T>(Iterable<Lock?> locks, Future<T> body()) Future<T>
Acquires locks in the given order, runs body, then releases them in reverse order (LIFO unwind of nested synchronized sections).

Typedefs

AiTissueCommandErrorHandler = void Function(Object error, StackTrace? stackTrace)
Error handler callback for the AI-bridged interpretation gates.
Arguments = ({Map<Symbol, dynamic>? namedArguments, List? positionalArguments})
Represents a tuple of positional and named arguments for function calls. Used when validating or processing function applications in cells.
EgressHandle<S extends Pulse> = ({Cell cell, void Function() start, void Function() stop})
A management handle for an Output Terminal, providing a controlled interface to manage an external side-effect listener.
FlowHandle<I> = ({Cell cell, bool Function(I input) emit, Future<bool> Function(I input) emitAsync, Future<void> Function(Pulse<I> pulse, {bool serializedCompletion}) ingest})
A specialized record representing a Topographical Ingress Handle.
FunctionType<R> = R Function()
Generic function type that takes no parameters and returns RNA. Used in FunctionTypeObject for lazy evaluation.
HubHandle = ({Pulse? Function(Pulse pulse) emit, Future<Pulse?> Function(Pulse pulse) emitAsync, Future<void> Function(Pulse pulse, {bool serializedCompletion}) ingest, Cell root, Iterable<Cell> spokes})
A management handle for a Signal Distribution Hub, providing a unified interface to control a multi-destination routing cluster.
IngressHandle<I> = ({Cell cell, bool Function(I input) emit, Future<bool> Function(I input) emitAsync, Future<void> Function(Pulse<I> pulse, {bool serializedCompletion}) ingest})
A management handle for an Input Gateway, providing a controlled interface for injecting external imperative stimuli into the reactive graph.
InheritableHandle = ({Cell? bind, Context context, EphemeralPolicy<Cell>? ephemeralPolicy, Receptor<Cell> receptor, TestCell<Cell> testRule})
A structured grouping of the Governance & Logic properties that define a node's operational identity and can be cascaded through the inheritance chain.
InterpreterReply = ({TissueCommand? command, Reject? reject})
The reply from the interpreter port.
NucleusSimplest = Nucleolus
A semantic type alias representing the framework's Zero-Overhead Root and the terminal ancestor of all reactive blueprints.
OpenCellBase = _OpenCell
Base class for all OpenCell types.
SpokeRegistration = ({DeputyContext? context, Pulse? Function(Cell cell, Pulse pulse, {dynamic user})? handler, String key, bool Function(String? type)? match, int priority, Receptor<Cell>? receptor})
A configuration record for an individual Spoke (Destination) within a Cell.hub.
StateHandle<V> = ({ValueCell<V> cell, Future<void> Function(Pulse<V> pulse, {bool serializedCompletion}) ingest, bool Function(V? value) update, Future<bool> Function(V? value) updateAsync})
A management record that bundles a ValueCell with its imperative update functions — the standard way to create and interact with a state atom.
SynthesisHandle = ({bool Function(Cell cell) add, void Function(Iterable<Cell> cells) addAll, SynthesisCell cell, bool Function() clear, bool Function() isEmpty, bool Function(Cell cell) remove, void Function(Iterable<Cell> cells) removeAll, void Function() start, void Function() stop, List<Cell> Function() toList})
An Administrative Record providing a control interface for dynamic SynthesisCell topographies.
TransactionScope = ({Future<void> Function(Iterable<Cell> cells) begin, Future<void> Function() commit, dynamic Function(Cell cell) pending, dynamic Function(Cell cell) read, Future<void> Function({Object? savepoint}) rollback, Object Function() savepoint, void Function(Cell cell, dynamic value) update})
A handle for coordinating atomic, multi‑cell transactions.

Exceptions / Errors

TransactionConflictException
Thrown when an isolation conflict is detected during commit.
TransactionTimeoutException
Thrown when a transaction exceeds its timeout duration.
TransactionValidationException
Thrown when validation of buffered writes fails during commit.
TxApplyCompensationException
TxApplyException