# The Six-Stage Resource-Aware Search Engine

**Status:** DESIGN — unified pipeline integrating all SilverSight components
**Date:** 2026-07-04
**Integrates:** BraidStorm, TreeBraid, AngrySphinx, MultisurfacePacker, COUCH, CRTSidon
**Framework:** "Filter, don't compress" (Hutter Prize lesson, conservation law 8× measured)

> **Note (2026-07-04):** The BraidStorm stage's premise — that chirality εᵢ ∈ {+1,−1}
> yields 256 *distinct* configurations — is killed by the C3 result
> (run 019f2f07, see `ENCODE_ENGINE_NECESSITY.md`, `CHIRAL_INVARIANCE_FINDING.md`):
> chiral permutation is position-invariant, so the 2^k "chiral variants" are not
> distinct channels. The pipeline's downstream reduction factors (256→128→64→…)
> are unmeasured estimates and collapse to a single channel under C3. Only the
> CRT-Sidon wrapping stage has a receipt (collisions → 0). Treat the chiral
> stages of this design as rejected; the CRT/Sidon filter core stands.

---

## The Pipeline

```
BraidStorm (256 chiral configs)
    ↓  generate 2^k configurations from k crossings
TreeBraid (factorize: 256 → ~64-128 unique)
    ↓  σ_i σ_j = σ_j σ_i when |i-j| ≥ 2 (independent groups)
AngrySphinx (resource allocation: 64-128 → ~32-64)
    ↓  compute budget per channel (E_solve ≥ 2^depth)
MultisurfacePacking (spatial: 32-64 → ~16-32)
    ↓  geometric fit without overlap
COUCH (geometric filter: 16-32 → ~8-16)
    ↓  can navigate corridor? O(1) per config
Sidon filter (algebraic: 8-16 → ~4-8)
    ↓  unique dual quaternion products? O(n²) per config
    ↓
~4-8 structurally meaningful configs per run
```

## What Each Stage Does

### Stage 1: BraidStorm — Generate

**Module:** `formal/CoreFormalism/BraidEigensolid.lean`
**Input:** 8-strand braid with Sidon labels {1,2,4,8,16,32,64,128}
**Operation:** Each crossing σ_i has chirality εᵢ ∈ {+1, -1}. With k=8 crossings, 2^8 = 256 chiral configurations encoded in ONE braid structure.
**Output:** 256 raw chiral configurations
**Cost:** O(1) — structure is generated once, chiral variants are implicit

### Stage 2: TreeBraid — Factorize

**Module:** Tree-organized braid (from `braid_group_action.md`)
**Input:** 256 chiral configurations
**Operation:** Identify independent crossing groups via braid relations:
- σ_i σ_j = σ_j σ_i when |i-j| ≥ 2 (commuting crossings = independent)
- σ_i σ_{i+1} σ_i = σ_{i+1} σ_i σ_{i+1} (Yang-Baxter = dependent)
Factorize into independent groups, process each separately.
**Output:** ~64-128 unique configurations (after removing equivalences)
**Cost:** O(k²) — pairwise independence check

### Stage 3: AngrySphinx — Resource Allocation

**Module:** `formal/SilverSight/AngrySphinx.lean`
**Input:** ~64-128 unique configurations
**Operation:** Allocate compute budget to each chiral channel:
- E_solve ≥ 2^depth (exponential cost bound from AngrySphinx theorem)
- High-priority channels get deeper search (more compute)
- Low-priority channels get shallow search (less compute)
- Channels exceeding budget are pruned
**Output:** ~32-64 configurations within compute budget
**Cost:** O(n) — budget check per configuration
**Formal guarantee:** E_attack = n ⟹ E_solve ≥ 2^n (proven, 0 sorries)

### Stage 4: MultisurfacePacking — Spatial Allocation

**Module:** `formal/SilverSight/PIST/MultiSurfacePacker.lean`
**Input:** ~32-64 configurations within budget
**Operation:** Determine which configurations physically fit in available geometric space:
- Pack configurations into available surfaces without overlap
- Lagrangian decision logic (from the formal module)
- Configurations that don't fit are pruned
**Output:** ~16-32 configurations that fit spatially
**Cost:** O(n log n) — packing algorithm
**Formal guarantee:** Lagrangian packing decision (proven, 0 sorries)

### Stage 5: COUCH — Geometric Filter

**Module:** `formal/SilverSight/GCCL.lean` (couchStable gate)
**Input:** ~16-32 spatially-valid configurations
**Operation:** Check if the shape can navigate the L-corridor:
- COUCH_stable = pressure/hysteresis stability
- "Apartment constraint" x_i(t) ∈ Ω = moving sofa constraint
- Cheap O(1) check per configuration
- In HCMR terms: self_loop_prob < threshold (contention check)
**Output:** ~8-16 configurations that can navigate
**Cost:** O(1) per configuration
**Formal guarantee:** GCCL Admit pipeline (proven, 0 sorries)

### Stage 6: Sidon Filter — Algebraic Filter

**Module:** `formal/CoreFormalism/CRTSidon.lean` + `CRTSidonN.lean`
**Input:** ~8-16 geometrically-valid configurations
**Operation:** Check which configurations have unique dual quaternion products:
- For each pair (i,j), compute Q_{ij} = q_i ⊛ q_j
- Sidon-clean: all Q_{ij} distinct (unique interaction signatures)
- Degenerate: some Q_{ij} = Q_{kl} (collision, ambiguous)
- Algebraic equality — NO tolerance band (fixes v2/v3 EPS problem)
**Output:** ~4-8 structurally meaningful configurations
**Cost:** O(n²) per configuration
**Formal guarantee:** Sidon orthogonality theorem (proven, 0 sorries in CRTSidon.lean)

## The Full Stack

```
Theory (continuous):
  Rendering equation (Kajiya 1986)
    = observerless observer (fixed-point recursion)
    = 16D chiral framework (Neumann series = eigensolid convergence)

Algebraic (discrete):
  CRTSidon.lean → Sidon orthogonality (non-interference theorem)
  CRTSidonN.lean → n-moduli generalization
  CHIRAL_CRT_MULTIPLEXING.md → n/2 orthogonal channels

Physical (measured):
  HCMR.lean → self-loop = Sidon collision rate
  Measured: SUBLEQ=0.823, AVX-512=0.885, ring=0.0
  Throughput = base_rate × Sidon_pass_rate

Computational (pipeline):
  BraidStorm → TreeBraid → AngrySphinx → MultisurfacePacker → COUCH → Sidon
  256 → 64-128 → 32-64 → 16-32 → 8-16 → 4-8

Performance (distributed):
  YangMillsPerformance.lean → 5-layer stack (cache+memory+sync+compression+network)
  WorkloadTestbench.lean → workload → op → cache state
  CacheSieve.lean → admission control (Stable→Rising→Unstable→Reset)
  Blitter6502OISC.lean → concrete SUBLEQ execution

Lesson:
  Compression is dead (conservation law, 8× measured)
  Filtering is alive (Sidon orthogonality, n/2 channels)
  CRT replaces the CMIX mixer algebraically (O(n²) not O(n²×models))
```

## General Applicability

The pipeline applies to any problem with:
1. **Combinatorial explosion** (configurations, states, assignments)
2. **Resource constraints** (compute, energy, time — AngrySphinx)
3. **Geometric constraints** (space, packing, navigation — MultisurfacePacker + COUCH)
4. **Algebraic uniqueness requirements** (signatures, identifiers — Sidon)

Examples:
- **Protein folding:** chiral amino acid configurations, steric constraints, unique folding pathways
- **Circuit design:** chiral gate configurations, routing constraints, unique signal paths
- **Network routing:** chiral path configurations, capacity constraints, unique routing signatures
- **Moving sofa:** chiral boundary configurations, corridor navigation, unique interaction signatures

## Performance Model

From HCMR + YangMillsPerformance:

| Stage | Input | Output | Cost | Bottleneck |
|-------|-------|--------|------|-----------|
| BraidStorm | 1 structure | 256 configs | O(1) | Generation |
| TreeBraid | 256 configs | 64-128 unique | O(k²) | Independence check |
| AngrySphinx | 64-128 | 32-64 | O(n) | Budget check |
| MultisurfacePacker | 32-64 | 16-32 | O(n log n) | Packing |
| COUCH | 16-32 | 8-16 | O(1)/config | Geometric check |
| Sidon | 8-16 | 4-8 | O(n²)/config | Algebraic check |

Total: O(n²) dominated by Sidon filter (the most expensive stage).
With TreeBraid factorization: O(groups × 2^{group_size}) instead of O(2^k).

## claim_boundary

```
six-stage-search-engine:unified-pipeline:design
```

This document defines the six-stage resource-aware search engine integrating
all SilverSight formal components:
1. BraidStorm (generate 256 chiral configs)
2. TreeBraid (factorize to ~64-128 unique)
3. AngrySphinx (resource allocation → ~32-64)
4. MultisurfacePacker (spatial allocation → ~16-32)
5. COUCH (geometric filter → ~8-16)
6. Sidon (algebraic filter → ~4-8)

Each stage is a FILTER, not a compressor. The pipeline embodies the
"filter, don't compress" principle from the Hutter Prize work.
All formal guarantees are proven (0 sorries across the stack except
2 known blocked sorries in CacheSieve and YangMillsPerformance).
