testRule property
The active TestCell integrity gate that governs and validates all state transitions for this node.
In the biological metaphor of the framework, the testRule acts as the Immune System or Quality Control mechanism of the Nucleus. It evaluates every incoming Pulse to ensure that only stimuli meeting the node's structural and security constraints are permitted to evolve the state.
When to use
- Integrity Validation: Defining business rules that must never be violated (e.g., "Account balance cannot be negative").
- Security Constraints: Verifying that a Pulse carries the necessary Context authority before allowing a sensitive mutation.
- State Consistency: Ensuring that complex structural changes in reactive collections maintain valid internal relationships.
How it works
The integrity gate employs a Tiered Resolution Strategy to determine the active rule for a specific cell handle:
- Local Override: It first checks for a TestCell defined explicitly in this node's local segment.
- Prototype Inheritance: If not found locally, it walks up the principal chain to inherit a rule from its prototype (Flyweight pattern).
- Causal Binding: If the resolved rule is the default TestCell.allowAll and the node is binded to an upstream source, it adopts the integrity gate of the bound cell to ensure causal parity.
- Global Default: If no rule is found in the lineage or bindings, it defaults to TestCell.allowAll.
Non‑obvious
- Forensic Rejection: When a testRule rejects a stimulus, the
mutation is aborted. The framework records a Rejection Milestone in
the forensic Pulse.trace and returns
nullrather than throwing a runtime exception, allowing for graceful self-healing logic. - Causal Consistency: The automatic inheritance from the bind target ensures that derived cells (projections) respect the same integrity constraints as their data sources by default.
- Short-circuiting: The rule is evaluated synchronously before the Receptor processes the pulse, preventing unnecessary computation or side-effects from invalid stimuli.
See also:
Implementation
TestCell get testRule;