TestTissue<E, C extends Tissue<E>> class

A specialised, multi‑vector Security and Validation Engine designed to govern the structural integrity and operational boundaries of Tissue containers (Lists, Sets, Maps, Queues, Values).

TestTissue is the cornerstone of the framework's Invariant Enforcement for collections. It extends the base TestCell logic to provide a comprehensive Integrity Gate that monitors every mutation, membership change, and reactive bond within the collection graph.

When to use

Use TestTissue whenever you need to enforce business rules, security boundaries, or data integrity on a reactive collection. The framework uses it internally for every mutation, but you supply your own when creating a tissue:

final list = TissueList<int>(
  testRule: TestTissue<int>((v) => v >= 0 && v <= 100),
);

You almost never need to construct a TestTissue from scratch. Start with one of the predefined policies:

To define your own, use the constructor with a simple validation function, then compose with others:

final isPositive = TestTissue<int, TissueList<int>>(
  (value, {host, ...}) => value > 0,
);
final hasPermission = TestTissue<Cell, TissueList<Cell>>(
  (_, {host, ...}) => host.context.hasRole('admin'),
);
final policy = isPositive + hasPermission;

How it works

  • The TestTissue is attached to a collection at creation time.
  • Every operation (adding an element, removing, clearing, etc.) passes through the validation pipeline.
  • The pipeline is a chain of rules; each rule returns true to allow or false to block.
  • Rules can be synchronous or asynchronous (FutureOr<bool>).
  • The + operator composes rules into a single TestTissue that evaluates them in sequence (short‑circuiting on false).

Unlike a generic TestCell, TestTissue understands collection semantics. It provides a specialised element method that validates individual members, and it integrates with the modifiable manifest to block entire categories of operations (e.g., clear).

Type Parameters:

  • E: The type of elements managed by the target Tissue.
  • C: The concrete type of the Tissue being governed (e.g., TissueList<E> or TissueSet<E>).

Example: E‑commerce product list validation

final productPolicy = TestTissue<Product, TissueList<Product>>(
  (product, {host, arguments, user}) {
    // Only allow products with positive price and non‑empty name
    return product.price > 0 && product.name.isNotEmpty;
  },
) + TestTissue<Product, TissueList<Product>>(
  (_, {host, ...}) => host.length < 100, // max 100 items
);

See also:

  • TestCell – the base validation logic for all reactive cells.
  • TestElementRule – the specific interface for membership validation.
  • TissueNucleus – where these rules are attached to the reactive blueprint.

AI Agent Guide

Layer: Tissue — the mutation rule for books. Not a Cell factory, not a Flow operator. When to use: testRule: on every Tissue constructor: append-only log, non-negative reserve, key shape, or documented allowAll. When NOT to use:

Live signature: TestTissue<E, C extends Tissue<E>>(FutureOr<bool> Function(dynamic object, {C? host, dynamic arguments, dynamic user}) rule, {TestTissue<E, C>? parent, dynamic user}) — pinned at cell_tissue: 1.2.0 Do NOT confuse with: TestCell (Cell nodes only). They are not subtypes; swapping them fails the acceptance grep. Guide: HowTo-Mitose-Tissue.md §3 "TestTissue — considering factors" (#tissue-testtissue) Example: example/cell_tissue_example.dart Cross-layer: quality rules on ingress / state / toHandle are TestCell in cell. Minimal compilable example

final gate = TestTissue<int, TissueList<int>>(
  (v, {host, arguments, user}) => (v as int) > 0,
);
final book = TissueList<int>(testRule: gate);
book.add(1);
book.add(-1); // rejected by the gate
print(book.length); // 1
Inheritance
Implemented types

Constructors

TestTissue(FutureOr<bool> rule(dynamic object, {dynamic arguments, C? host, dynamic user}), {TestTissue<E, C>? parent, dynamic user})
Creates a new TestTissue validation rule for reactive collections.
const
TestTissue.chain(Iterable<TestRule<C>> rules, {TestTissue<E, C>? parent, dynamic user, FutureOr<bool> strategy(dynamic object, {dynamic arguments, C? host, dynamic user})?})
Creates a Composite Validation Pipeline by aggregating multiple specialised rules into a single, unified Integrity Gate.
const
TestTissue.fromRecord(dynamic record)
Internal, foundational constructor that instantiates a TestTissue directly from a structured record configuration.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
purity → Purity
A rule's purity. Defaults to Purity.pure; rules that perform external I/O must override — a rule that reads external state (a clock, an environment variable, a read-only database) to Purity.readOnlyExternal, a rule that mutates external state (rare; mostly misuse) to Purity.effectful and be journalled.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
version → String
A rule's version. Defaults to '0.0.0'; subclasses should override with a stable string. See Receptor.version.
no setterinherited

Methods

action(Function action, {required C host, Arguments? arguments, ApplyCommand? command}) → FutureOr<bool>
Validates the execution of a functional action and its associated arguments on the host cell, supporting Hybrid Convergence (Sync/Async).
inherited
call(dynamic object, {covariant C? host, dynamic arguments}) → FutureOr<bool>
The primary execution entry point for the TestTissue validation engine.
override
element(covariant E? element, {required C host, Function? action}) → FutureOr<bool>
Specialised entry point for Element‑Level Governance, determining if a specific member E is authorised to be part of the Tissue host.
override
Validates the establishment of a reactive link from a candidate Cell to the host cell, supporting Hybrid Convergence (Sync/Async).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pulse(covariant Pulse pulse, {required C host}) → FutureOr<bool>
Validates an incoming pulse intended for processing by the host cell, supporting Hybrid Convergence (Sync/Async).
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator +(covariant TestRule<C> other) → TestTissue<E, C>
Composes this validation policy with another TestRule, creating a Composite Security Stack through the Composite Pattern.
override
operator ==(Object other) → bool
The equality operator.
inherited

Constants

allowAll → const _TestTissueNever
A predefined, global singleton representing an Unrestricted Permission Policy for reactive collections.
readOnly → const _TestTissueReadOnly
A predefined, immutable security policy that enforces a strict Read‑Only Mutation Barrier specifically for reactive collections.
unlimitedLength → const int
Maximum size constant used for unbounded collections.