gstack/docs/designs
Garry Tan 07edc70df1
feat(security): Bun-native inference research skeleton + design doc
Ships the research skeleton for the P3 "5ms Bun-native classifier" TODO.
Honest scope: tokenizer + API surface + benchmark harness + roadmap doc.
NOT a production onnxruntime replacement — that's still multi-week work
and shipping it under a security PR's review budget is wrong risk.

browse/src/security-bunnative.ts:
  * Pure-TS WordPiece tokenizer reading HF tokenizer.json directly —
    produces the same input_ids sequence as transformers.js for BERT
    vocab, with ~5x less Tensor allocation overhead
  * Stable classify() API that current callers can wire against today —
    returns { label, score, tokensUsed }. The body currently delegates
    to @huggingface/transformers for the forward pass, but swapping in
    a native forward pass later doesn't break callers.
  * Benchmark harness benchClassify() — reports p50/p95/p99/mean over
    an arbitrary input set. Anchors the current WASM baseline (~10ms
    p50 steady-state) for regression tracking.

docs/designs/BUN_NATIVE_INFERENCE.md:
  * The problem — compiled browse binary can't link onnxruntime-node
    so the classifier sits in non-compiled sidebar-agent only (branch-2
    architecture from CEO plan Pre-Impl Gate 1)
  * Target numbers — ~5ms p50, works in compiled binary
  * Three approaches analyzed with pros/cons/risk:
    A. Pure-TS SIMD — ruled out (can't beat WASM at matmul)
    B. Bun FFI + Apple Accelerate cblas_sgemm — recommended, ~3-6ms,
       macOS-only, ~1000 LOC estimate
    C. Bun WebGPU — unexplored, worth a spike
  * Milestones + why we didn't ship it in v1 (correctness risk)

Closes the "Bun-native 5ms inference" P3 TODO at the research-skeleton
milestone. Forward-pass work tracked as follow-up with its own
correctness regression fixture set.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 05:02:59 +08:00
..
BUN_NATIVE_INFERENCE.md feat(security): Bun-native inference research skeleton + design doc 2026-04-20 05:02:59 +08:00
CHROME_VS_CHROMIUM_EXPLORATION.md feat: headed mode + sidebar agent + Chrome extension (v0.12.0) (#517) 2026-03-26 11:15:24 -06:00
CONDUCTOR_CHROME_SIDEBAR_INTEGRATION.md feat: headed mode + sidebar agent + Chrome extension (v0.12.0) (#517) 2026-03-26 11:15:24 -06:00
CONDUCTOR_SESSION_API.md feat: headed mode + sidebar agent + Chrome extension (v0.12.0) (#517) 2026-03-26 11:15:24 -06:00
DESIGN_SHOTGUN.md feat: design binary — real UI mockup generation for gstack skills (v0.13.0.0) (#551) 2026-03-27 20:32:59 -06:00
DESIGN_TOOLS_V1.md feat: design binary — real UI mockup generation for gstack skills (v0.13.0.0) (#551) 2026-03-27 20:32:59 -06:00
GCOMPACTION.md docs: gstack compact design doc (tabled pending Anthropic API) (#1027) 2026-04-16 15:04:26 -07:00
GSTACK_BROWSER_V0.md feat: GStack Browser — double-click AI browser with anti-bot stealth (#695) 2026-04-04 10:17:05 -07:00
ML_PROMPT_INJECTION_KILLER.md fix: sidebar prompt injection defense (v0.13.4.0) (#611) 2026-03-28 22:10:35 -06:00
PACING_UPDATES_V0.md feat: gstack v1 — simpler prompts + real LOC receipts (v1.0.0.0) (#1039) 2026-04-18 15:05:42 +08:00
PLAN_TUNING_V0.md feat: gstack v1 — simpler prompts + real LOC receipts (v1.0.0.0) (#1039) 2026-04-18 15:05:42 +08:00
PLAN_TUNING_V1.md feat: gstack v1 — simpler prompts + real LOC receipts (v1.0.0.0) (#1039) 2026-04-18 15:05:42 +08:00
SELF_LEARNING_V0.md feat: Session Intelligence Layer — /checkpoint + /health + context recovery (v0.15.0.0) (#733) 2026-04-01 00:50:42 -06:00
SESSION_INTELLIGENCE.md feat: session intelligence roadmap + design doc (#727) 2026-03-31 17:01:22 -06:00
SIDEBAR_MESSAGE_FLOW.md feat: GStack Browser — double-click AI browser with anti-bot stealth (#695) 2026-04-04 10:17:05 -07:00
SLATE_HOST.md docs: Slate agent integration research + design doc (#782) 2026-04-03 06:42:23 -07:00
SLOP_SCAN_FOR_REVIEW_SHIP.md refactor: AI slop reduction with cross-model quality review (v0.16.3.0) (#941) 2026-04-10 17:13:15 -10:00