lietzsche;stokes

updated 2026-11-26·3 min read

Parallel AST Analyzers Reference

Five-worker parallel analyzer layout, analyzer_progress_event.json wire schema, and domain-isolated analysis pipeline.

A single generalist linter chokes on mixed SQL, Python, Rust, and Protobuf files. Stokes gives each language toolchain its own isolated worker and fans their findings into an asyncio.Queue event bus with a 16.6 ms (60 FPS) render coalescer.

Stokes parallel analyzers dashboard showing stokes-sql, stokes-python, stokes-rust, stokes-proto, and stokes-verify worker cards and live event bus
stokes audit --parallel: five concurrent workers reporting over the event bus.

Five-Worker Analyzer Layout

Each worker scans only its own file types and emits typed findings upward to the coordinator (BobMultiplexer):

WorkerRuntime ScopeDomain FocusTypical Drift Finding
stokes-sqlClickHouse / SQLSchema queries & catalog reflectionevents_r0 / r1 matched (280 cols)
stokes-pythonPython ETLDynamic dict unpacking & slice boundspriority = 0 shadow admission without cap
stokes-rustRust ProxyFixed buffer capacity & .try_into().unwrap()TryFromSliceError risk (Risk = 1.40)
stokes-protoProtobuf v2/v3repeated field bounds & tagsMissing stokes.max_items option
stokes-verifySandbox HarnessCriterion JSON & IEEE-754 float fuzzingValidates 10,000 float cases and seals lockfile

Four-Step Analysis Pipeline

  1. Domain-Isolated Parsing

    Each worker inspects only its target language (SQL, Python, Rust, Protobuf) to prevent mixed-grammar parse errors.

  2. In-Memory Event Queue & Wire Framing

    Workers push typed diagnostics into asyncio.Queue with cooperative backpressure and 16.6 ms coalescing; external integrations use 4-byte big-endian uint32 framing.

  3. Automated Patch Generation

    On drift detection, Stokes emits parameterized unified diffs (database qualification in SQL, in-place quickselect in Rust) with 0 B heap allocation.

  4. Clean Verification Gate

    Requires all active language workers and property tests to pass before sealing stokes.lock and CONFORMANCE.md.

Typed Event Schema (analyzer_progress_event.json)

Length-Prefixed Analyzer Progress Event Payload
{
  "event_id": "c7a8e291-f0b4-4e2a-92b1-8d2e82110c4a",
  "timestamp_ns": 1727282400012000000,
  "analyzer_id": "stokes-rust",
  "phase": "invariant_evaluation",
  "target_file": "crates/cloudflame-proxy/src/engine/feature_ingest.rs",
  "line_offset": 98,
  "ast_node_type": "call_expression",
  "ast_symbol_name": "try_into().unwrap()",
  "status_message": "fatal tryfromsliceerror: 280 elements exceed [feature; 200]",
  "severity": "contract_violation",
  "remediation_patch": {
    "action": "dual_zone_quickselect",
    "heap_allocation_limit_bytes": 0,
    "core_reserved_slots": 128,
    "adaptive_slots": 72,
    "algorithm": "select_nth_unstable_by"
  }
}
Analyzer Architecture FAQ
  • Why run separate language workers instead of one generalist linter? Polyglot stacks have conflicting syntax rules; keeping each language in its own worker avoids parse collisions while still letting Stokes cross-reference SQL projections, Python loops, and Rust stack arrays.
  • How do workers communicate inside the CLI? Events stream into an asyncio.Queue throttled to a 16.6 ms render tick (60 FPS); external IPC uses 4-byte big-endian length-prefixed frames.
  • What happens when a worker flags drift? It emits file path, line offset, and node metadata, then triggers patch generation and stokes-verify checks.
  • How do AI agents consume worker findings? Via stokes mcp over stdio or stokes remediate --agent claude|bob|aider.

See Parallel Language Workers & Event Bus for IPC internals and Multi-Language AST & Regex Analysis Engine for .scm queries.

Search wiki and portfolio

type to search across all entries.