TestLinkRule<C extends Cell> class Testing & Validation

A specialized behavioral guard for validating Topological Synapses and graph formation within the reactive framework.

TestLinkRule represents the Structural Gatekeeper of a Cell. It is designed to audit the directional relationships between nodes, governing how cells connect to one another in the global data-flow graph. It extends the base validation architecture to provide type-safe, link-aware constraints.

When to use

Use this when you need to enforce rules on which cells can observe each other – e.g., domain isolation, clearance checks, or compliance requirements.

How it works

  • The rule is attached to a cell via TestCell and evaluated whenever a link is attempted.
  • The rule function receives the candidate link cell, the host cell, and optional user data.
  • Return true to allow the link, false to block it.

Example

// Only allow linking to cells in the same domain
final sameDomainRule = TestLinkRule<Cell>((link, {host, user}) {
  return link.context.domains == host.context.domains;
});

// Block links to ValueCells (only allow standard Cells)
final noValueCellsRule = TestLinkRule<Cell>((link, {host, user}) {
  return link is! ValueCell;
});

// Allow linking only to cells with 'public' context
final publicOnlyRule = TestLinkRule<Cell>((link, {host, user}) {
  return link.context.domains?.contains('public') ?? false;
});

// Using user data for configuration
final allowedDomainsRule = TestLinkRule<Cell>((link, {host, user}) {
  final allowed = user as List<String>? ?? ['public'];
  return allowed.any((d) => link.context.domains?.contains(d) ?? false);
}, user: ['public', 'internal']);

// Domain isolation rule
final domainRule = TestLinkRule<Cell>((link, {host, user}) {
  return link.context.domains == host.context.domains;
});

// Security clearance rule
final clearanceRule = TestLinkRule<Cell>((link, {host, user}) {
  final hostClearance = host.context.clearance ?? Clearance.observational;
  final linkClearance = link.context.clearance ?? Clearance.observational;
  return linkClearance.index >= hostClearance.index;
});

// Compliance rule
final complianceRule = TestLinkRule<Cell>((link, {host, user}) {
  final hostCompliance = host.context.compliances?.split(',') ?? [];
  final linkCompliance = link.context.compliances?.split(',') ?? [];
  return linkCompliance.every((c) => hostCompliance.contains(c));
});

// Compose into a complete link policy
final linkPolicy = domainRule + clearanceRule + complianceRule;

// Use in a cell
final cell = Cell(testRule: linkPolicy);

See also:

Inheritance
Implementers

Constructors

TestLinkRule(bool rule(Cell link, {required C host, dynamic user}), {TestLinkRule<C>? parent, dynamic user})
Synthesizes a specialized TestLinkRule instance for auditing Topological Synapses and graph formation.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(dynamic object, {C? host, dynamic arguments}) → FutureOr<bool>
Executes the Validation Predicate and orchestrates the Chain of Responsibility for this rule.
inherited
Executes the topological validation logic for a candidate link attempting to connect to the host cell, supporting Hybrid Convergence.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator +(covariant TestRule<C> other) → TestRule<C>
Composes two TestRule instances into a sequential Validation Pipeline.
inherited
operator ==(Object other) → bool
The equality operator.
inherited