Files
adm fb92662106 [ABI][LD][Proofs][Docs] M1 groundwork: arena-safety proof + .vbundle contract; embedder lane (M1.5) accepted
- proofs/arena_plan.lean: memory.vplan arena safety (8 theorems + 4
  computational examples, 0 sorryAx): no overlap, checked index bounds,
  no use-before-write, overlap-rejection completeness.
- abi::arena: validator mirroring the proof, checked offset arithmetic
  (invariant #2), explicit error per violation class; 8 tests.
- abi::bundle: .vbundle manifest (ABI_VERSION=1, source+packer fingerprints,
  backend target; incompatible ABI rejected explicitly), checked
  memory.vplan/graph.vplan parsing, arena-validated compile(); 7 tests.
- ld::bundle: read-only load_bundle_plans(dir) over manifest + plan/*.vplan;
  3 tests (good bundle, missing file, ABI mismatch).
- abi::vplan: encoder-lane opcodes (layer_norm, flash_full_attn, gelu_erf,
  mean_pool_l2norm) + wire name mapping for all 22 opcodes, roundtrip test.
- Docs: utility-encoder scope carve-out (dense decoder LMs out, small
  fully-resident encoders in), embedder-lane wire proposal + characteristic
  parity vs vetta-semantics (cosine vs oracle, internal bit-exact goldens),
  16-primitive kernel set, M1.5 milestone; README/AGENTS aligned
  (65 tests, 42 theorems across 4 proof files).
- review/: tandem exchange with the strata-ctl coder (their request +
  observations, our formal reply: embedder accepted, M0 dir cleanup done).

Verified live: RUSTFLAGS="-D warnings" cargo test --workspace = 65/65 PASS;
lean proofs/{slab_ring_dma,bus_lifecycle,serve_session,arena_plan}.lean green,
standard axioms only.
2026-11-30 15:22:00 +01:00

3.8 KiB

AGENTS.md — vetta-infer

Rules and engineering standards for working on vetta-infer.

Architecture & Scope

  • MoE-first microkernel engine in Rust (edition 2024) with minimal AMD ROCm HIP kernels (gfx1150 / RDNA 3.5 primary target; UMA 96 GiB + dual NVMe).
  • Authoritative design: docs/ARCHITECTURE.md (approved 2026-11-29) — pure microkernel vetta-infer-kn + services (abi/kn/ld/cc/rt/lab/sp/nt/tm/gw), dual-step loader → .vbundle/, .vplan → CompiledPlan at boot. The crate realignment completed 2026-11-30 (M0 crates dissolved into vetta-infer-*); behavior is ported from the measured strata engines (../strata* worktrees), never re-invented from summaries.
  • Clear boundary: all control flow, parsing, caching, scheduling, speculative verification, protocol handling, and telemetry stay in safe, CPU-testable Rust crates. unsafe is isolated to rt (HIP FFI/DMA fence wrappers) and cc (io_uring / pread syscalls).
  • No silent regressions or unmeasured claims: every performance or quality claim must carry real measurements and the exact hardware/model/flags used.

Hard Invariants (Eliminate Past Audit Classes By Construction)

  1. DMA / Async Transfer Ownership: never pass a stack variable or short-lived Vec to hipMemcpyAsync or io_uring. Every in-flight transfer owns or pins its SlabSlot until its completion fence/CQE is observed (verified in proofs/slab_ring_dma.lean).
  2. Checked Bounds Everywhere: all .safetensors header offsets, slices, and NVMe disk-cache metadata counts MUST use checked integer arithmetic (checked_add, checked_sub, count <= blob.len() / MIN_REC_BYTES) before any allocation.
  3. Write-Once / O_RDONLY NVMe Caches: caches are written atomically via .tmp.<pid> + fsync + rename only on miss, and opened strictly O_RDONLY on every reload (0 SSD writes).
  4. Typestate Prefix / MTP / Checkpoint Validity: never rely on loose integer pairs (prefix_len, mtp_prefix_len) to infer device buffer initialization. Represent state via explicit enums (PrefixState), and commit pool metadata only after GPU allocations/copies succeed.
  5. Zero-Allocation Hot-Path Sampling & Explicit Non-Finite Tracking: no per-token O(V) heap allocations, no silent 256-cap truncation when top_k == 0 with top_p/min_p, centralized mask_token_id suppression, and explicit reporting of non-finite logits.
  6. Formal Verification with Lean 4 (Federico's rule): simple correctness logic is written directly with ordinary CPU tests; complex logic (non-trivial state machines, ring buffers, checkpoint pools, speculative/rollback invariants, memory-arena plans) is modeled in proofs/*.lean and verified by the Lean kernel (0 sorryAx, standard axioms only) before writing the implementation.

Tandem & Review Workflow

  • Principal consumer: strata-ctl (../strata-ctl), developed by a peer coder in tandem. The living wire contract is strata-ctl/src/engine/protocol.rs + supervisor.rs; engine-side guarantees and known deltas are tracked in docs/ARCHITECTURE.md §6.
  • Mutual reviews: each coder periodically reviews the other's work; an external reviewer audits both. Wire-protocol changes land in coordinated review cycles across the two repos — never unilaterally.
  • Parity discipline: every policy/kernel ported from strata ships a parity test against the measured reference behavior (e.g. Adaptive-K must match clover_policy.h, not a simplified sketch).

Verification Commands

  • Proofs: lean proofs/slab_ring_dma.lean, lean proofs/bus_lifecycle.lean, lean proofs/serve_session.lean, lean proofs/arena_plan.lean
  • CPU workspace tests: cargo test --workspace
  • Commit prefixes: [ABI], [KN], [LD], [CC], [RT], [LAB], [SP], [NT], [TM], [GW], [Proofs], [Docs]