When one model's output needs checking. When a decision flows through multiple validators and each one either strengthens or weakens the chain. The cascade is the mathematics of doubt — quantified, propagated, and routed.
A TypeScript library for decision confidence cascades with a three-zone model: GREEN (≥0.90), YELLOW (0.75–0.89), RED (<0.75).
Think of it like a fishing net — if any mesh tears, the whole thing is compromised. Sequential confidence multiplies; parallel confidence averages with weights.
Where CNS Bridge's EscalationEngine routes questions from cheap models to expensive ones based on confidence, Confidence Cascade provides the mathematical framework for measuring that confidence as it flows through the chain. Where emergence-engine detects synergy in group conversations, Confidence Cascade quantifies the reliability of the decisions that emerge. Where fleet-envelope wraps events, Confidence Cascade wraps the trust in those events.
The elephant feels, the deadband decides, the chain acts.
Matured from the elephant's Terrain discipline (docs/terrain-2026-08-17.md · docs/deadband-chain.md): the cascade already escalated when confidence crossed zones — now it does so with a true deadband's discipline. A Schmitt-trigger gate with hysteresis (enter/exit per zone), a moving quiet anchor (the room's resting confidence), and an explicit chain of command — host → foreman → captain — that rises one step per consecutive ring and descends only when the room genuinely quiets. Below significance, nothing rings: the room breathes, no one is disturbed. Only the moves that matter.
flowchart LR
dials["elephant dials<br/>(panic, anomaly, mood, …)"] -->|readings| bridge["readingFromDials()<br/>weighted alarm score"]
bridge -->|reading| deadband["DeadbandChain<br/>enter / exit Schmitt<br/>moving quiet anchor"]
deadband -->|ring| chain["ChainOfCommand"]
chain --> host["host"] --> foreman["foreman"] --> captain["captain"]
deadband -.->|"quiet → re-anchor"| deadband
import { readingFromDials, DeadbandChain, ChainOfCommand } from '@superinstance/confidence-cascade';
const deadband = new DeadbandChain(); // YELLOW 0.10/0.05 · RED 0.25/0.125
const chain = new ChainOfCommand(); // host → foreman → captain
const ring = deadband.check(readingFromDials({ panic: 0.71, mood: -0.4 }));
const level = chain.report(ring); // 'host' | 'foreman' | 'captain' | nullIn complex systems, decisions flow through multiple steps, validators, and signals. Confidence cascades provide a mathematical framework to:
- Track confidence degradation through sequential processes (each step multiplies)
- Combine multiple signals with weighted importance (parallel averaging)
- Route through conditional paths based on runtime conditions
- Automatically escalate when confidence drops below thresholds
npm install @superinstance/confidence-cascadeimport {
createConfidence,
sequentialCascade,
parallelCascade
} from '@superinstance/confidence-cascade';
// Create confidence values from your validators
const mlScore = createConfidence(0.95, 'ml_model');
const rulesScore = createConfidence(0.70, 'rules_engine');
const reputationScore = createConfidence(0.85, 'user_reputation');
// Combine in parallel with weights
const result = parallelCascade([
{ confidence: mlScore, weight: 0.5 },
{ confidence: rulesScore, weight: 0.3 },
{ confidence: reputationScore, weight: 0.2 }
]);
console.log(`Confidence: ${(result.confidence.value * 100).toFixed(1)}%`);
console.log(`Zone: ${result.confidence.zone}`); // GREEN | YELLOW | RED
console.log(`Escalation: ${result.escalationLevel}`); // NONE | NOTICE | WARNING | ALERT | CRITICAL| Zone | Range | Meaning |
|---|---|---|
| 🟢 GREEN | 0.90 – 1.00 | Auto-proceed — high confidence |
| 🟡 YELLOW | 0.75 – 0.89 | Proceed with caution — review recommended |
| 🔴 RED | 0.00 – 0.74 | Stop and investigate — confidence too low |
const conf = createConfidence(0.82, 'validator', {
greenThreshold: 0.85,
yellowThreshold: 0.65,
escalateOnYellow: true,
escalateOnRed: true
});Each step must succeed. Confidence degrades through the chain.
const result = sequentialCascade([
createConfidence(0.95, 'format_check'),
createConfidence(0.90, 'range_check'),
createConfidence(0.85, 'business_rules'),
createConfidence(0.80, 'risk_scoring')
]);
// 0.95 × 0.90 × 0.85 × 0.80 = 0.582 → RED zoneIndependent validators with different importance.
const result = parallelCascade([
{ confidence: createConfidence(0.95, 'ml_model'), weight: 0.5 },
{ confidence: createConfidence(0.70, 'rules_engine'), weight: 0.3 },
{ confidence: createConfidence(0.85, 'heuristics'), weight: 0.2 }
]);
// 0.5×0.95 + 0.3×0.70 + 0.2×0.85 = 0.865 → YELLOW zoneExactly one path is active; its confidence becomes the result.
const result = conditionalCascade([
{ confidence: createConfidence(0.90, 'basic'), predicate: amount < 1000, description: 'small' },
{ confidence: createConfidence(0.95, 'enhanced'), predicate: amount >= 1000 && amount < 10000, description: 'medium' },
{ confidence: createConfidence(0.99, 'manual'), predicate: amount >= 10000, description: 'large' }
]);| Level | Trigger | Recommended Action |
|---|---|---|
| NONE | GREEN zone | Auto-proceed |
| NOTICE | Upper YELLOW | Log and continue |
| WARNING | Lower YELLOW | Flag for review |
| ALERT | Upper RED | Stop, require human |
| CRITICAL | Deep RED (< half yellow threshold) | Immediate intervention |
import { fraudDetectionCascade } from '@superinstance/confidence-cascade';
const result = fraudDetectionCascade({
mlScore: 0.85,
rulesScore: 0.92,
userReputation: 0.78,
transactionAmount: 2500,
userLocationMatch: true
});
if (result.escalationTriggered) {
if (result.escalationLevel === 'ALERT' || result.escalationLevel === 'CRITICAL') {
blockTransaction();
} else {
requestAdditionalVerification();
}
} else {
approveTransaction();
}| Function | Description |
|---|---|
createConfidence(value, source, config?) |
Create a tagged confidence value with auto-zoning |
sequentialCascade(confidences[], config?) |
Multiply confidences through a chain |
parallelCascade(branches[], config?) |
Weighted average of parallel branches |
conditionalCascade(paths[], config?) |
Select the active path's confidence |
formatConfidence(confidence) |
Human-readable string |
meetsThreshold(confidence, threshold) |
Boolean check |
degradationRate(steps[]) |
Fractional confidence loss across steps |
Confidence—{ value, zone, source, timestamp }CascadeConfig—{ greenThreshold, yellowThreshold, redThreshold, escalateOnYellow, escalateOnRed }CascadeResult—{ confidence, steps, escalationTriggered, escalationLevel }ConfidenceZone— enumGREEN | YELLOW | REDEscalationLevel— enumNONE | NOTICE | WARNING | ALERT | CRITICAL
- Fraud detection — combine ML scores, rules engines, and user reputation
- Content moderation — pipeline of classifiers with varying confidence
- CI/CD pipelines — gate deployments on validation confidence
- Security scanning — aggregate multiple tool outputs
- Quality assurance — weight different QA signals
- Any multi-signal decision system with confidence scores
npm testMIT — see LICENSE file.
Confidence Cascade connects to:
- CNS Bridge — The EscalationEngine uses confidence thresholds to route between tiers. This library provides the math.
- emergence-engine — Emergent insights need verification. Confidence Cascade quantifies trust in emergence.
- fleet-envelope — Events carry confidence metadata. The envelope wraps the signal; the cascade wraps the trust.
- stigmergy — Pheromone strength is confidence. A decaying trail is a yellow-zone signal.
- the-living-minds (dead) — When the small models produce output, the cascade determines whether to trust it.
- elephant — The Terrain's deadband rings up the chain of command; this library is that chain in TypeScript (
docs/deadband-chain.md). - gossip-ping — Liveness confidence cascades through the mesh.
- collective-unconscious — The deep layer where confidence pools.
- → CNS Bridge — See confidence thresholds in the EscalationEngine
- → emergence-engine — Trust verification for emergent insights
- → fleet-envelope — The grammar that wraps confidence-tagged events
- → stigmergy — Pheromone strength as confidence signal
- stigmergy — Bio-inspired coordination for multi-agent systems
