interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / TEST_INFRA.md

372 lines · 24504 bytes Raw Blame History Source

Test Infrastructure Specification: AIEN Sovereign Core Real-Model Execution

1. Architectural Overview and Verification Principles

This document defines the opaque-box test infrastructure and four-tier test methodology for the AIEN Sovereign Core TinyLlama real-model execution system. The test suite exercises the system through public interfaces, binary CLIs, and boundary contracts without accessing internal private states or facade mocks.

Core Testing Invariants

  1. Opaque-Box Requirement-Driven Verification: All test assertions derive directly from PROJECT.md, ORIGINAL_REQUEST.md, Hugging Face reference architectures, and hardware specifications. Tests inspect observable outputs (return types, stdout, stderr, exit codes, tensor buffers, generated tokens).
  2. Authoritative Ground Truth: Expected values originate from the Hugging Face Transformers CPU FP32 reference execution of TinyLlama/TinyLlama-1.1B-Chat-v1.0, official tokenizer manifests, and mathematical properties of transformers.
  3. Loud Failure Contract: System components must fail loudly on invalid inputs with descriptive error variants (MissingTensor, ShapeMismatch, DtypeMismatch, OffsetOutOfBounds, InvalidHeader). Silent fallbacks to synthetic or random weights are strictly forbidden.
  4. Zero Disk Secrets: Tests verify that zero plaintext secret files (.env, .env.*) exist in working directories. Secrets resolve exclusively from the hardware TPM vault (atlas-vault).
  5. Zero Unhandled Panics: Negative tests assert that malformed inputs produce graceful error results or non-zero exit codes with clean error diagnostics, never segmentation faults or unexpected panics.

2. Four-Tier Testing Methodology

The test matrix covers all 18 features across four structured tiers:

+-----------------------------------------------------------------------------------+
| Tier 1: Feature Coverage (>= 5 per feature, 90 test cases)                        |
| Direct validation of functional requirements, happy paths, and primary behaviors. |
+-----------------------------------------------------------------------------------+
| Tier 2: Boundary & Corner Cases (>= 5 per feature, 90 test cases)                 |
| Extreme values, empty inputs, malformed headers, off-by-one indices, type drift.  |
+-----------------------------------------------------------------------------------+
| Tier 3: Cross-Feature Interactions (>= 18 pairwise combinations)                  |
| End-to-end data pipeline combinations spanning checkpoint, tokenizer, and compute.|
+-----------------------------------------------------------------------------------+
| Tier 4: Real-World Scenarios (>= 9 operational workflows)                         |
| Complete production journeys: single prompt, multi-turn, benchmark, doctor, PR.   |
+-----------------------------------------------------------------------------------+

3. Feature Matrix and Test Inventory

Feature Inventory Mapping (N=18)


Tier 1: Feature Coverage (5 Test Cases per Feature = 90 Tests)

Feature F1: Strict Safetensors Loader

Feature F2: Loud Validation & Catalog

Feature F3: Dual Weight Storage

Feature F4: Pure Rust Tokenizer

Feature F5: Chat Template & Special Tokens

Feature F6: Encode & Decode Engine

Feature F7: Reference Oracle Script

Feature F8: Deterministic Oracle Fixtures

Feature F9: Algorithmic Core Alignment

Feature F10: Multi-Stage Parity Test

Feature F11: Decoupled TensorBackend Trait

Feature F12: ReferenceCpuBackend

Feature F13: Mojo GB10 C-ABI Kernels

Feature F14: MojoGb10Backend Implementation

Feature F15: Neutral Benchmark Driver

Feature F16: Concurrency Sweeps & Telemetry

Feature F17: Hardware & Secrets Compliance

Feature F18: PR Lifecycle & Cortex Receipt


Tier 2: Boundary & Corner Cases (5 Test Cases per Feature = 90 Tests)

Feature F1 (Safetensors Loader Boundaries)

Feature F2 (Validation Boundaries)

Feature F3 (Dual Storage Boundaries)

Feature F4 (Tokenizer Boundaries)

Feature F5 (Chat Template Boundaries)

Feature F6 (Encode/Decode Boundaries)

Feature F7 (Oracle Script Boundaries)

Feature F8 (Oracle Fixture Boundaries)

Feature F9 (Algorithmic Alignment Boundaries)

Feature F10 (Parity Test Boundaries)

Feature F11 (TensorBackend Trait Boundaries)

Feature F12 (ReferenceCpuBackend Boundaries)

Feature F13 (Mojo GB10 Kernels Boundaries)

Feature F14 (MojoGb10Backend Boundaries)

Feature F15 (Neutral Benchmark Driver Boundaries)

Feature F16 (Concurrency Sweeps Boundaries)

Feature F17 (Compliance Boundaries)

Feature F18 (PR Lifecycle Boundaries)


Tier 3: Cross-Feature Interactions (>= 18 Pairwise Combinations)

  1. Pair P1 (F1 + F2): Safetensors loading of a file missing 1 of 201 tensors triggers loud CheckpointError::MissingTensor without entering execution.
  2. Pair P2 (F1 + F3): Safetensors loading with valid BF16 weights populates both decoded FP32 weights and raw BF16 weights in LoadedCheckpoint.
  3. Pair P3 (F2 + F9): Validating tensor catalog shapes enforces [out_dim, in_dim] layout used directly by aligned matmul_vec.
  4. Pair P4 (F4 + F5): Pure Rust tokenizer loading tokenizer.json formats chat template and pins BOS=1, EOS=2, UNK=0.
  5. Pair P5 (F4 + F6): Pure Rust tokenizer encodes prompt string, then decode reverses the token sequence back to original text.
  6. Pair P6 (F5 + F6): Chat formatted prompt encoded to tokens terminates on EOS token ID 2 during autoregressive decode.
  7. Pair P7 (F7 + F8): Reference Python oracle script execution produces tinyllama_oracle.safetensors matching tinyllama_oracle_manifest.json hashes.
  8. Pair P8 (F8 + F10): Multi-stage parity test loads oracle safetensors fixture and validates Stage 1 through Stage 5 sequentially.
  9. Pair P9 (F9 + F10): Aligned RoPE rotate_half and row-major matmul pass Stage 3 activation parity (cosine > 0.9999) without layer drift.
  10. Pair P10 (F9 + F12): Reference CPU backend executing aligned math passes all 5 parity stages against Hugging Face oracle.
  11. Pair P11 (F3 + F13): removed 2026-10-15 with Mojo.
  12. Pair P12 (F11 + F12): ReferenceCpuBackend implements TensorBackend trait and processes full forward pass token evaluation.
  13. Pair P13 (F11 + F14): removed 2026-10-15 with Mojo.
  14. Pair P14 (F13 + F14): removed 2026-10-15 with Mojo.
  15. Pair P15 (F10 + F14): removed 2026-10-15 with Mojo.
  16. Pair P16 (F15 + F16): Neutral benchmark driver executes concurrency sweep C=1..64 on AIEN collecting TTFT and ITL.
  17. Pair P17 (F16 + F17): Telemetry collection records GPU power and memory while maintaining zero disk secrets in memory.
  18. Pair P18 (F15 + F18): Benchmark completion writes structured results and triggers autonomous PR squash merge with Cortex memory receipt.

Tier 4: Real-World Scenarios (>= 9 Workflows)

  1. Scenario SC-01 (Golden Prompt Single-Turn Inference): End user submits golden operating system prompt. System loads checkpoint, tokenizes chat prompt, executes forward pass on ReferenceCpuBackend, and emits greedy next token 2744 ("An"), matching Hugging Face oracle 100%.
  2. Scenario SC-02 (16-Step Autoregressive Generation): End user initiates 16-step text generation. System autoregressively decodes tokens [2744, 13598, 1788, 313, 3267, 29897, 338, 263, 7047, 393, 767, 1179, 278, 12837, 322, 7047], outputting text "An operating system (OS) is a software that manages the hardware and software".
  3. Scenario SC-03 (Corrupted Checkpoint Recovery & Rejection): End user supplies a safetensors file with missing layer weights. System catches CheckpointError::MissingTensor at initialization, logs descriptive error, and aborts startup cleanly without panicking.
  4. Scenario SC-04 (CLI Doctor Inspection): Operator executes aien-cli --doctor. System validates platform context, execution surface detection, filesystem structure, and reports operational health.
  5. Scenario SC-05 (CLI Status & Version Check): Operator executes aien-cli --version and aien-cli --status. System detects host surface, confirms release tag, and prints formatted status without launching background daemons.
  6. Scenario SC-06 (Automated Parity Gate): CI or operator runs cargo test -p aien-inference-abi --test tinyllama_parity --verbose. System validates Stages 1 to 5 against oracle fixture and reports zero regressions.
  7. Scenario SC-07 (Apples-to-Apples Multi-Engine Benchmark): Operator launches neutral benchmark orchestrator. System pauses for thermal cool-down, tests AIEN, and outputs TTFT/ITL telemetry.
  8. Scenario SC-08 (Zero-Disk-Secrets Invariant Audit): Automated auditor scans workspace. Verifies zero .env files, tests in-memory TPM vault resolution, and verifies compliance.
  9. Scenario SC-09 (Sovereign Voice & Git PR Lifecycle): System verifies branch naming, validates zero em/en dashes and zero banned words across code and docs, opens public PR, and records merge receipt in Cortex memory.

4. Test Execution Architecture & Single Command Runner

The complete E2E test suite resides in e2e_tests/ and is executable via a single top-level runner command:

bash e2e_tests/run_e2e_tests.sh

Or via direct Cargo invocation:

cargo test --manifest-path e2e_tests/Cargo.toml -- --nocapture

The runner executes tests in progressive phases:

  1. Environment & Invariant Checks (Zero Secrets, Sovereign Voice, User identity).
  2. Checkpoint Loader & Validation Tests (Positive, Negative, Boundaries).
  3. Tokenizer & Chat Template Tests (Encode, Decode, Special Tokens).
  4. Tensor Math & Backend Integration Tests (RoPE, MatMul, RMSNorm, SwiGLU).
  5. CLI Entry Point & Negative Argument Tests (aien-cli commands, zero panics).
  6. Parity Verification & Oracle Contract Tests.