ADR-005: WebAssembly Integration for Browser and Mobile Deployment

Date: 2026-02-01 Status: Accepted

Context

QNTX has multiple Rust components (parser, fuzzy matching, storage, video inference) integrated into a Go server via CGO. The parser (qntx-core) is a critical component that tokenizes and parses AX query strings.

The vision for QNTX includes:

Currently, the Tauri app and web interface don't share the core parsing logic with the server, leading to potential inconsistencies.

Decision

We will integrate the qntx-core parser as a WebAssembly module, making it the first component in our gradual migration from CGO to WASM. This enables the same parser to run in:

Implementation Details

  1. WASM Runtime:

  2. Distribution: Triple strategy:

  3. Build Configuration: Always enable WASM parser by default (remove opt-in build tag requirement)

  4. Failure Handling: Log and fall back to Go implementation if WASM fails (server only)

Migration Strategy

Gradually migrate all Rust components to WASM:

  1. ✅ Parser (qntx-core) - COMPLETED (89KB)
  2. ⏳ Fuzzy matching (fuzzy-ax)
  3. ⏳ Storage (qntx-sqlite) - IndexedDB for browser, SQLite for Tauri
  4. ⏳ Video inference (vidstream) - May remain server-only due to size

Consequences

Positive

Negative

Neutral

Architecture

┌─────────────┐     ┌──────────────┐     ┌────────────┐
│   Browser   │     │ Tauri Desktop│     │  Go Server │
│   (web/ts)  │     │  (src-tauri) │     │  (cmd/qntx)│
└──────┬──────┘     └──────┬───────┘     └─────┬──────┘
       │                   │                    │
       └───────────────────┼────────────────────┘
                           │
                    ┌──────▼──────┐
                    │ qntx-core   │
                    │   (WASM)    │
                    │    89KB     │
                    └─────────────┘

Metrics

Implementation Status

Technical Debt Discovered

During WASM integration, significant parser design flaws were exposed:

See Issue #387 for detailed analysis and refactoring plan.

Future Considerations

  1. Web Integration: web/ts should import and use same WASM modules
  2. Tauri Options: Explore native Rust in Tauri vs WASM for performance
  3. Storage Strategy: IndexedDB for browser, SQLite for Tauri/server
  4. Module Loading: Lazy loading and compression for web deployment
  5. Complete Migration: Eventually eliminate all CGO dependencies
  6. Mobile Apps: React Native or Flutter could use same WASM modules

References