Files
vetta-infer/AGENTS.md
T
adm 7b50f1c07c [ABI][KN][LD][CC][RT][LAB][SP][NT][TM][GW][Proofs][Docs] M0.5: realign workspace to vetta-infer-* microkernel architecture
Dissolve the M0 crates (core/io/proto/telemetry/hip/cli) into the approved
service layout abi/kn/ld/cc/rt/lab/sp/nt/tm/gw (docs/ARCHITECTURE.md).

- kn: Lean-verified control bus + service registry (bus_lifecycle.lean, 14 thms)
  and SlabRing/UMA broker; rt: PrefixState + hybrid checkpoint pool.
- sp: faithful throughput-aware Adaptive-K port of clover_policy.h
  (cooldowns, probes, throughput guards) with scenario parity tests.
- gw: strata-ctl-compatible wire emitters + serve session FSM
  (serve_session.lean, 10 thms); abi::serve accepts image= (Vision delta closed).
- abi: pure contracts, checked JSON/VTC1/GEN parsers, zero-alloc sampler.
- ld/cc: checked safetensors reader + write-once VTC1 writer / O_RDONLY reader.
- tm: lock-free telemetry; nt: LyraRpc; lab shares the rt executor core.
- Docs: ARCHITECTURE.md decision-complete spec (MoE-only scope, .vbundle,
  .vplan->CompiledPlan, wire contract, migration map); AGENTS.md Lean rule
  + tandem/review workflow.

Verified live: cargo test --workspace -D warnings = 46/46 PASS;
lean proofs = 34 theorems (slab_ring_dma 10, bus_lifecycle 14, serve_session 10),
0 sorryAx, standard axioms only; vetta-infer info on Inkling = 1244 tensors,
18.18 GiB, checked bounds.
2026-11-30 00:54:00 +01:00

3.7 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
  • CPU workspace tests: cargo test --workspace
  • Commit prefixes: [ABI], [KN], [LD], [CC], [RT], [LAB], [SP], [NT], [TM], [GW], [Proofs], [Docs]