Model card: restore full README from GitHub, add commercial license option
Browse files
README.md
CHANGED
|
@@ -17,3 +17,97 @@ tags:
|
|
| 17 |
|
| 18 |
> Mirrored from [https://github.com/SNAPKITTYWEST/sparse-router-formal](https://github.com/SNAPKITTYWEST/sparse-router-formal) at commit `5e292ee`. Part of the **SnapKitty October 2026 main drop**.
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
> Mirrored from [https://github.com/SNAPKITTYWEST/sparse-router-formal](https://github.com/SNAPKITTYWEST/sparse-router-formal) at commit `5e292ee`. Part of the **SnapKitty October 2026 main drop**.
|
| 19 |
|
| 20 |
+
# Sparse Router β Formally Verified Locality-Aware Work-Stealing Scheduler
|
| 21 |
+
|
| 22 |
+
**License**: GPL-3.0-or-later OR Apache-2.0 (dual-licensed)
|
| 23 |
+
|
| 24 |
+
## Architecture
|
| 25 |
+
|
| 26 |
+
```
|
| 27 |
+
sparse-router-formal/
|
| 28 |
+
βββ rust/tensor-hw/ # Production Rust: tensor core + RAW_ROUTE + Kani proofs
|
| 29 |
+
β βββ src/ # 10 modules: buffer, ownership, memory, view, governance...
|
| 30 |
+
β βββ ffi/ # sparse_router.rs, kani proofs, C ABI, FFI bridge
|
| 31 |
+
βββ pascal/ # Reference implementation (independent conformance oracle)
|
| 32 |
+
βββ formal/ # Lean 4 formal proofs (convergence, invariants, scoring)
|
| 33 |
+
βββ c-reference/ # Standalone C reference (header-only, benchmarkable)
|
| 34 |
+
βββ tests/conformance/ # 52 cross-language conformance tests (7 categories)
|
| 35 |
+
βββ spec/ # Normative specifications (contract, state machine, memory model)
|
| 36 |
+
βββ src/pascal/ # Pascal transformer sources
|
| 37 |
+
βββ scripts/ # Clone-gate verification
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
## Novel Method: RAW_ROUTE
|
| 41 |
+
|
| 42 |
+
Three-phase routing with O(K) sparse-edge traversal (K β€ 16), not O(N) worker scan:
|
| 43 |
+
|
| 44 |
+
```
|
| 45 |
+
score(w, t) = locality(w,t) + memory_affinity(w,t) + queue_pressure(w)
|
| 46 |
+
+ stealability(w) - migration_cost(w,t)
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
| Phase | Path | Complexity |
|
| 50 |
+
|-------|------|-----------|
|
| 51 |
+
| 1 | Region-owner fast path | O(1) |
|
| 52 |
+
| 2 | Sparse edge traversal | O(K) |
|
| 53 |
+
| 3 | Least-loaded fallback | O(N) |
|
| 54 |
+
|
| 55 |
+
## Formal Verification
|
| 56 |
+
|
| 57 |
+
### Lean 4 Proofs (`formal/`)
|
| 58 |
+
- **Convergence**: potential function Ξ¦ = |unowned regions| strictly decreases β stable in β€ MAX_REGIONS steps
|
| 59 |
+
- **Uniqueness**: every routed task lands on exactly one worker deque
|
| 60 |
+
- **Bounded traversal**: sparse edge fan-out β€ MAX_SPARSE_EDGES
|
| 61 |
+
- **Scoring properties**: locality bonus, empty-queue bonus, zero migration cost for local tasks
|
| 62 |
+
- **Deque correctness**: push/pop identity, count invariants
|
| 63 |
+
|
| 64 |
+
### Kani Proofs (`rust/tensor-hw/ffi/sparse_router_kani.rs`)
|
| 65 |
+
- All tasks routed (progress guaranteed)
|
| 66 |
+
- Region owner consistency
|
| 67 |
+
- Locality over balance
|
| 68 |
+
- Migration cost avoidance
|
| 69 |
+
- Fallback coverage
|
| 70 |
+
- Route decision stability
|
| 71 |
+
- Score bounds (all weights finite)
|
| 72 |
+
- No deadlock (acyclic region ownership)
|
| 73 |
+
|
| 74 |
+
### Cross-Language Conformance (`tests/conformance/`)
|
| 75 |
+
52 tests across 7 categories β Rust and Pascal must agree:
|
| 76 |
+
- Buffer lifetime, ownership transitions, views, materialization
|
| 77 |
+
- Generation validation, governance, routing
|
| 78 |
+
|
| 79 |
+
## Build
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
make test # C reference tests (7 tests)
|
| 83 |
+
make bench # C benchmarks (~100M routes/sec)
|
| 84 |
+
make test-rust # Rust test suite (49 tests)
|
| 85 |
+
make verify # Lean 4 proofs (requires lake)
|
| 86 |
+
make clone-gate-check # Verify all markers present, no MIT
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Clone Gate
|
| 90 |
+
|
| 91 |
+
All source files contain `CLONE_GATE` markers. See `CLONE_GATE.md` for terms.
|
| 92 |
+
No MIT licensing permitted. See `LICENSE-GPL` and `LICENSE-APACHE`.
|
| 93 |
+
|
| 94 |
+
## Deliverables Summary
|
| 95 |
+
|
| 96 |
+
| Component | LOC | Status |
|
| 97 |
+
|-----------|-----|--------|
|
| 98 |
+
| Specifications | ~3,600 | 7 normative documents |
|
| 99 |
+
| Rust Core | ~2,670 | 10 modules + 49 tests |
|
| 100 |
+
| Pascal Reference | ~2,450 | 10 modules + 10 tests |
|
| 101 |
+
| Lean 4 Proofs | ~350 | 6 modules, convergence theorem |
|
| 102 |
+
| C Reference | ~450 | Header-only + benchmarks |
|
| 103 |
+
| Conformance Tests | ~2,800 | 52 tests + oracle |
|
| 104 |
+
| Kani Proofs | ~400 | 8 formal proofs |
|
| 105 |
+
| **Total** | **~12,700** | **Production ready** |
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
### πΌ Commercial License
|
| 110 |
+
|
| 111 |
+
This repository is published under **GPL-3.0-or-later or Apache-2.0**. Building a commercial product or service? A **proprietary commercial license** from Snapkitty Collective LLC lets you ship this code on terms other than GPL-3.0-or-later or Apache-2.0.
|
| 112 |
+
|
| 113 |
+
**[β Get a commercial license](mailto:A.parr@belespritdaccord.uk?subject=Commercial%20license:%20sparse-router-formal)** Β· A.parr@belespritdaccord.uk
|