updated 2026-11-26·9 min read
Introduction & Overview
Cross-boundary contract checker for SQL, Python, Protobuf, and Rust pipelines, built solo for an IBM Bob 2.0 hackathon.
Stokes came out of an IBM Bob hackathon, only the second or third hackathon I had joined, I think, and got its name mainly so I wouldn’t ship yet another generic two-word AI project title (Stokes’ theorem connects boundary behavior to interior guarantees, albeit mostly here as a cool name). Anyway, building it solo meant I forgot to prepare slides until late, spent roughly ten hours filming and editing the demo video, and found out the hard way that per-person credit limits give a six-person team 6x the runway of a solo builder rather than one fixed pool per team.
That budget ceiling shaped how the repo was split: solo participants got 40 Bobcoins (versus 240 for a 6-person squad), and the first session alone burned 27.18 Bobcoins getting the core AST scanner, five language workers, and test suite off the ground. Ergo, I built the MCP bridge, the Cloudflame testbed, and the web demo shell with external tooling so the remaining Bobcoins could stay on the core engine.
In multi-language stacks, each repo can look clean on its own: sqlfluff passes the SQL, mypy passes the Python, and rustc compiles the edge proxy, yet the moment a schema migration emits 280 columns into a 200-slot stack buffer, production panics with TryFromSliceError. Stokes catches that boundary drift in CI and over MCP before anything ships.

How Untyped Seams Break in Production
Across a three-tier microservice pipeline, each compiler signs off on its own piece while a runtime collision builds across the wire:
- Tier 1: SQL Analytics (ClickHouse DDL)
migrations/004_stats.sql emits 280 columns across canonical and shard tables. sqlfluff reports PASS.
- Tier 2: Feature Extractor (Python Worker)
services/etl/worker.py reflects and serializes all 280 items into a dynamic KV mesh payload. mypy reports PASS.
- Tier 3: Reverse Proxy (Rust Edge)
crates/proxy/src/intake.rs decodes into a fixed stack buffer [Feature; 200]. rustc reports PASS, but production panics with TryFromSliceError.
Why Compilers Miss Boundary Drift
Multi-tier pipelines usually split data contracts across three layers that never share a type system. ClickHouse, PostgreSQL, or Snowflake run DDL migrations and expose columns through virtual introspection tables like system.columns or information_schema. Python, Node.js, or Go workers query that catalog metadata, pack dynamic dictionaries, and push payloads onto Redis, Kafka, or distributed KV stores. At the edge, L7 reverse proxies in Rust (Pingora) or C++ (Envoy) decode those payloads straight into fixed-size stack arrays to skip heap allocations and keep packet intake off the allocator.
When an upstream team adds shard replica tables or new feature flags, the downstream proxy crashes on deserialization even though every repo passes local CI, simply because sqlfluff, mypy, and rustc each only inspect their own files and never see what sits downstream.
Stokes bridges that gap by pulling interface signatures out of isolated source files and linking producer counts directly to downstream buffers.
How the Checker Runs
Stokes runs the same boundary graph in two places, without spinning up Docker containers or invoking rustc:
Static CI Gate
Runs as a zero-dependency Python CLI in CI (stokes verify --strict). It probes for native Tree-sitter bindings if installed, falls back to compiled regex rules (_PATTERNS) out of the box, checks emitted column counts against buffer slots, and verifies normalized AST digests against stokes.lock.
MCP Bridge & Patch Generation
Streams boundary shapes, buffer limits, and schema constraints over JSON-RPC 2.0 (stokes mcp) to IBM Bob 2.0, Claude Code, Cursor, and Windsurf. Also emits Dual-Zone stack layouts (128 core + 72 adaptive slots via select_nth_unstable_by) through stokes codegen.
Because it skips containers and full compiler passes, a local check finishes well under a tenth of a second on small workspaces, with zero code injected into the compiled proxy binary.
Checking Column Counts Against Buffer Slots
The core check Stokes enforces at every boundary is plain: does the upstream producer ever emit more fields than the downstream array or struct can hold? Internally the engine tracks upstream_count / buffer_capacity (reported as risk_ratio in CLI output), failing CI whenever emitted columns exceed buffer slots or an unscoped reflection loop leaves the wire length unbounded:
| Condition | Buffer Check | Operational Outcome |
|---|---|---|
| Within Bounds | Emitted fields <= buffer capacity (risk_ratio <= 1.0) | Safe stack allocation; no slice length mismatch. |
| Overflow Drift | Emitted fields > buffer capacity (e.g. 280 > 200, risk_ratio = 1.40) | Direct .try_into().unwrap() is guaranteed to panic in production. |
| Unbounded Wire | Unscoped SELECT * or reflection without limits | Unbounded payload growth and OOM / crash risk. |
Core Diagnostic Rules
Stokes enforces five primary rules across mixed boundaries (plus LINT-006 for wildcard projections in Projection Isolation):
| Rule Code | Severity | Trigger Condition | Root Cause & Failure Mode |
|---|---|---|---|
LINT-001 | FATAL | system.columns without database = currentDatabase() | Ingestion of replica shard tables (r0, r1), inflating column projection count. |
LINT-002 | FATAL | Dynamic dictionary serialization without slice guards | Unbounded feature reflection loop bypasses Python type check, overflowing downstream buffers. |
LINT-003 | WARNING | Unbounded repeated Protobuf field | Missing [(stokes.max_items) = N] option lets upstream producers send arbitrary slice lengths. |
LINT-004 | FATAL | Direct .try_into().unwrap() on fixed stack buffer | Immediate TryFromSliceError panic or 502 drop when upstream cardinality exceeds capacity N. |
LINT-005 | WARNING | Heap allocations on microsecond intake hot path | Cache line evictions degrading packet evaluation latency. |
Parallel Language Workers
Inside the CLI, Stokes splits scanning across five focused Python workers coordinated over an asyncio.Queue (and 4-byte length-prefixed binary frames for external IPC):
stokes-sql: Catches unqualifiedsystem.columnsqueries and wildcard catalog reflections.stokes-proto: Flags unboundedrepeatedfields withoutstokes.max_itemsbounds.stokes-python: Spots unguarded dictionary append loops and missing slice ceilings.stokes-rust: Flags.try_into().unwrap()calls on fixed stack buffers and heap allocations.stokes-verify: Runs the 10,000-case IEEE-754 float fuzz battery and Criterion regression checks.


Demo Video, Sprites & Zundamon TTS
For the hackathon submission video, I wanted that brisk sketched-avatar style from SoiriLab on YouTube, so my girlfriend drew the whole sprite set from scratch (right down to the whiteboard prop and pixel sunglasses). For the voiceover, I figured out how to set up a local Zundamon TTS model myself and learned pretty quickly just how loud my laptop fans can scream running a local neural voice model nonstop during an edit (gosh, if only I could get a new laptop).
I would link the finished video here too, I guess, except lablab rebranded to Starfield Labs and removed my submission once the hackathon ended (or something like that), and I’m honestly too lazy to re-upload it on YouTube when I wasn’t even that proud of how it came out anyway.








Documentation Map
Why monolingual linters create false confidence and why declarative manifests beat intrusive IDLs.
Install Stokes, initialize stokes.toml, lock stokes.lock digests, and wire GitHub Actions and MCP.
Untyped seams, panic resilience, sparse boundary graphs, poly-repo staging, and projection isolation.
Multi-language AST/regex engine, parallel worker bus, IEEE-754 fuzz harness, and Nov 18 reproduction.
Continue to Architecture Vision or Quickstart & CLI Guide to run Stokes locally.