Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/aien-sovereign-core-mv/blob/main/TEST_INFRA.md
# 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
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`aien-sovereign-core-mv / TEST_INFRA.md`
372 lines ยท 24504 bytes Raw Blame History Rendered
1 # Test Infrastructure Specification: AIEN Sovereign Core Real-Model Execution
2
3 ## 1. Architectural Overview and Verification Principles
4
5 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.
6
7 ### Core Testing Invariants
8 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).
9 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.
10 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.
11 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`).
12 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.
13
14 ---
15
16 ## 2. Four-Tier Testing Methodology
17
18 The test matrix covers all 18 features across four structured tiers:
19
20 ```
21 +-----------------------------------------------------------------------------------+
22 | Tier 1: Feature Coverage (>= 5 per feature, 90 test cases) |
23 | Direct validation of functional requirements, happy paths, and primary behaviors. |
24 +-----------------------------------------------------------------------------------+
25 | Tier 2: Boundary & Corner Cases (>= 5 per feature, 90 test cases) |
26 | Extreme values, empty inputs, malformed headers, off-by-one indices, type drift. |
27 +-----------------------------------------------------------------------------------+
28 | Tier 3: Cross-Feature Interactions (>= 18 pairwise combinations) |
29 | End-to-end data pipeline combinations spanning checkpoint, tokenizer, and compute.|
30 +-----------------------------------------------------------------------------------+
31 | Tier 4: Real-World Scenarios (>= 9 operational workflows) |
32 | Complete production journeys: single prompt, multi-turn, benchmark, doctor, PR. |
33 +-----------------------------------------------------------------------------------+
34 ```
35
36 ---
37
38 ## 3. Feature Matrix and Test Inventory
39
40 ### Feature Inventory Mapping (N=18)
41 - F1: Strict Safetensors Loader
42 - F2: Loud Validation & Catalog
43 - F3: Dual Weight Storage
44 - F4: Pure Rust Tokenizer
45 - F5: Chat Template & Special Tokens
46 - F6: Encode & Decode Engine
47 - F7: Reference Oracle Script
48 - F8: Deterministic Oracle Fixtures
49 - F9: Algorithmic Core Alignment
50 - F10: Multi-Stage Parity Test
51 - F11: Decoupled TensorBackend Trait
52 - F12: ReferenceCpuBackend
53 - F13: Mojo GB10 C-ABI Kernels (removed 2026-10-15)
54 - F14: MojoGb10Backend Implementation (removed 2026-10-15)
55 - F15: Neutral Benchmark Driver
56 - F16: Concurrency Sweeps & Telemetry
57 - F17: Hardware & Secrets Compliance
58 - F18: PR Lifecycle & Cortex Receipt
59
60 ---
61
62 ### Tier 1: Feature Coverage (5 Test Cases per Feature = 90 Tests)
63
64 #### Feature F1: Strict Safetensors Loader
65 - TC-F1-01: Load valid safetensors header with valid JSON metadata and verify tensor count.
66 - TC-F1-02: Verify rejection of empty file (0 bytes) with descriptive error.
67 - TC-F1-03: Verify rejection of truncated safetensors header (bytes < 8).
68 - TC-F1-04: Verify rejection of invalid JSON within safetensors header boundary.
69 - TC-F1-05: Verify header length prefix larger than actual file size fails with InvalidHeader.
70
71 #### Feature F2: Loud Validation & Catalog
72 - TC-F2-01: Verify detection of missing tensor `model.embed_tokens.weight` returning `CheckpointError::MissingTensor`.
73 - TC-F2-02: Verify detection of missing layer projection `model.layers.0.self_attn.q_proj.weight`.
74 - TC-F2-03: Verify shape mismatch on `lm_head.weight` (expected [32000, 2048], actual [32000, 1024]) returns `ShapeMismatch`.
75 - TC-F2-04: Verify dtype mismatch (tensor stored as F32 instead of BF16) returns `DtypeMismatch`.
76 - TC-F2-05: Verify out-of-bounds byte range (data_offsets exceed file length) returns `OffsetOutOfBounds`.
77
78 #### Feature F3: Dual Weight Storage
79 - TC-F3-01: Verify loaded checkpoint contains populated FP32 weight map for reference execution.
80 - TC-F3-02: Verify loaded checkpoint retains raw BF16 byte vectors for GPU acceleration.
81 - TC-F3-03: Verify FP32 decoded values correctly represent BF16 bit patterns (bit shift `u16 << 16` to `f32`).
82 - TC-F3-04: Verify tensor shapes in checkpoint match both FP32 and BF16 allocations.
83 - TC-F3-05: Verify memory isolation between FP32 and BF16 buffers (modifying one does not mutate the other).
84
85 #### Feature F4: Pure Rust Tokenizer
86 - TC-F4-01: Instantiate `TinyLlamaTokenizer` from valid `tokenizer.json` file.
87 - TC-F4-02: Verify tokenizer loads without invoking Python runtime or child processes.
88 - TC-F4-03: Verify vocabulary size equals 32,000.
89 - TC-F4-04: Verify rejection of missing `tokenizer.json` path with descriptive file error.
90 - TC-F4-05: Verify rejection of corrupt JSON in `tokenizer.json` with descriptive parse error.
91
92 #### Feature F5: Chat Template & Special Tokens
93 - TC-F5-01: Verify special token ID BOS equals 1 (``).
94 - TC-F5-02: Verify special token ID EOS equals 2 (``).
95 - TC-F5-03: Verify special token ID UNK equals 0 (``).
96 - TC-F5-04: Format chat prompt with system message and user message, asserting exact template structure.
97 - TC-F5-05: Format chat prompt with None system message, asserting default user-only template structure.
98
99 #### Feature F6: Encode & Decode Engine
100 - TC-F6-01: Encode canonical test string `"Hello world"` to token IDs.
101 - TC-F6-02: Decode token IDs back to original text `"Hello world"`.
102 - TC-F6-03: Verify EOS token (ID 2) terminates autoregressive generation sequence.
103 - TC-F6-04: Verify round-trip encoding and decoding across multilingual and ASCII inputs.
104 - TC-F6-05: Verify decode of empty token slice returns empty string without error.
105
106 #### Feature F7: Reference Oracle Script
107 - TC-F7-01: (retired) the oracle generator is no longer kept in AIEN; only its recorded outputs remain, as test fixtures. This repo holds no Python.
108 - TC-F7-02: Verify script CLI options `--model-dir` and `--output-dir`.
109 - TC-F7-03: Verify script specifies CPU device and FP32 torch precision.
110 - TC-F7-04: Verify script registers hooks on all 22 layers (RMSNorm, RoPE, Attention, SwiGLU, final norm).
111 - TC-F7-05: Verify script exports JSON manifest with SHA-256 digests.
112
113 #### Feature F8: Deterministic Oracle Fixtures
114 - TC-F8-01: Verify `tinyllama_oracle_manifest.json` schema and field presence.
115 - TC-F8-02: Verify manifest references 46 prompt token IDs matching canonical golden sequence.
116 - TC-F8-03: Verify greedy next token ID in manifest equals 2744 (`"An"`).
117 - TC-F8-04: Verify top-5 tokens in manifest match rank order `[2744, 1576, 6716, 7094, 797]`.
118 - TC-F8-05: Verify 16-step greedy decode text in manifest matches golden operating system definition.
119
120 #### Feature F9: Algorithmic Core Alignment
121 - TC-F9-01: Verify RoPE implementation pairs coordinate `i` with `i + half_dim` (canonical `rotate_half`).
122 - TC-F9-02: Verify RoPE does NOT pair adjacent coordinates `2*i` and `2*i + 1`.
123 - TC-F9-03: Verify matrix multiplication computes dot products against row slices of shape `[out_dim, in_dim]`.
124 - TC-F9-04: Verify decode step sequence position matches current token index (not offset by +1).
125 - TC-F9-05: Verify RMSNorm epsilon defaults to `1e-5` for TinyLlama.
126
127 #### Feature F10: Multi-Stage Parity Test
128 - TC-F10-01: Verify Stage 1 tokenizer parity asserts 100% token ID match against oracle.
129 - TC-F10-02: Verify Stage 2 shape parity asserts exact dimensions across all 22 layers.
130 - TC-F10-03: Verify Stage 3 activation parity verifies absolute tolerance <= 1e-4.
131 - TC-F10-04: Verify Stage 3 activation parity verifies cosine similarity > 0.9999.
132 - TC-F10-05: Verify Stage 4 greedy parity asserts top-1 token ID equals oracle top-1.
133
134 #### Feature F11: Decoupled TensorBackend Trait
135 - TC-F11-01: Verify `TensorBackend` trait exposes `rmsnorm` method with explicit buffer slices.
136 - TC-F11-02: Verify `TensorBackend` trait exposes `apply_rope` with head and position arguments.
137 - TC-F11-03: Verify `TensorBackend` trait exposes `matmul_vec` with `[out_dim, in_dim]` contract.
138 - TC-F11-04: Verify `TensorBackend` trait exposes `swiglu` activation method.
139 - TC-F11-05: Verify `TensorBackend` trait exposes `gqa_attention` supporting 8:1 query-to-KV ratio.
140
141 #### Feature F12: ReferenceCpuBackend
142 - TC-F12-01: Instantiate `ReferenceCpuBackend` and verify backend name reporting.
143 - TC-F12-02: Execute RMSNorm on unit vector and verify mathematical correctness.
144 - TC-F12-03: Execute SwiGLU forward pass with known inputs and verify output values.
145 - TC-F12-04: Execute GQA attention with single query token against cached KV vectors.
146 - TC-F12-05: Execute `compute_logits` and verify output dimension matches vocabulary size (32000).
147
148 #### Feature F13: Mojo GB10 C-ABI Kernels
149 - Removed on 2026-10-15 with Modular MAX and Mojo; its tests were deleted.
150
151 #### Feature F14: MojoGb10Backend Implementation
152 - Removed on 2026-10-15 with Modular MAX and Mojo; its tests were deleted.
153
154 #### Feature F15: Neutral Benchmark Driver
155 - TC-F15-01: Verify benchmark crate `benchmarks/crates/bench_apples_to_apples` exists in workspace.
156 - TC-F15-02: Verify benchmark driver accepts `--engines` argument (AIEN only since 2026-10-15).
157 - TC-F15-03: Verify benchmark driver accepts `--concurrency` sweep argument.
158 - TC-F15-04: Verify benchmark driver executes engines sequentially with cool-down pauses.
159 - TC-F15-05: Verify benchmark driver verifies output token correctness against reference oracle.
160
161 #### Feature F16: Concurrency Sweeps & Telemetry
162 - TC-F16-01: Verify concurrency levels sweep through C = 1, 2, 4, 8, 16, 32, 64.
163 - TC-F16-02: Verify prompt length is fixed at 128 input tokens and generation at 128 output tokens.
164 - TC-F16-03: Verify TTFT metric collection computes p50, p95, and p99 percentiles.
165 - TC-F16-04: Verify ITL metric collection computes p50, p95, and p99 percentiles.
166 - TC-F16-05: Verify telemetry records resident memory (RSS GB), GPU power (W), and energy (J/token).
167
168 #### Feature F17: Hardware & Secrets Compliance
169 - TC-F17-01: Verify absence of plaintext `.env` or `.env.*` files across the workspace.
170 - TC-F17-02: Verify secrets resolution directs to `atlas-vault` in-memory lookup.
171 - TC-F17-03: Verify codebase contains zero em dashes (`\u2014`) and zero en dashes (`\u2013`).
172 - TC-F17-04: Verify absence of banned AI buzzwords (`delve`, `tapestry`, `testament`, `beacon`, `pivotal`).
173 - TC-F17-05: Verify execution user check requires `drakestapleton` on DGX Spark.
174
175 #### Feature F18: PR Lifecycle & Cortex Receipt
176 - TC-F18-01: Verify active git branch is `feat/real-model-execution-tinyllama`.
177 - TC-F18-02: Verify PR automation uses GitHub CLI (`gh pr create`, `gh pr merge`).
178 - TC-F18-03: Verify squash merge strategy is enforced (`--squash --delete-branch`).
179 - TC-F18-04: Verify Cortex memory integration target is `http://127.0.0.1:18080` in space `atlas-memory`.
180 - TC-F18-05: Verify post-merge receipt schema includes commit SHA, timestamp, and benchmark summary.
181
182 ---
183
184 ### Tier 2: Boundary & Corner Cases (5 Test Cases per Feature = 90 Tests)
185
186 #### Feature F1 (Safetensors Loader Boundaries)
187 - TC-F1-B01: Safetensors file with 0-byte header length field (8 zero bytes).
188 - TC-F1-B02: Header JSON containing extra unknown metadata fields (must ignore gracefully).
189 - TC-F1-B03: Header length field specifying `u64::MAX` bytes (must reject without memory allocation panic).
190 - TC-F1-B04: Safetensors header with trailing junk bytes after valid JSON.
191 - TC-F1-B05: File path pointing to directory instead of regular file.
192
193 #### Feature F2 (Validation Boundaries)
194 - TC-F2-B01: Tensor with shape containing zero dimension (e.g. `[0, 2048]`).
195 - TC-F2-B02: Layer index out of bounds (e.g. `model.layers.99.input_layernorm.weight`).
196 - TC-F2-B03: Byte range offset where `begin == end` (0 elements for non-empty shape).
197 - TC-F2-B04: Byte range offset where `begin > end`.
198 - TC-F2-B05: Header specifying 200 out of 201 required tensors (exact catalog boundary).
199
200 #### Feature F3 (Dual Storage Boundaries)
201 - TC-F3-B01: Conversion of BF16 subnormal floating point values to FP32.
202 - TC-F3-B02: Conversion of BF16 positive and negative infinity to FP32.
203 - TC-F3-B03: Conversion of BF16 NaN values preserving NaN semantics.
204 - TC-F3-B04: Alignment verification: raw BF16 buffer starts at 2-byte aligned address.
205 - TC-F3-B05: Allocation of maximum single tensor buffer (`lm_head.weight`, 32000 * 2048 * 2 bytes = 131 MB).
206
207 #### Feature F4 (Tokenizer Boundaries)
208 - TC-F4-B01: Tokenizing empty string `""` returns empty token array.
209 - TC-F4-B02: Tokenizing string of 100,000 continuous whitespace characters.
210 - TC-F4-B03: Tokenizing string with invalid UTF-8 byte sequences gracefully handled or replaced.
211 - TC-F4-B04: Tokenizing string containing only emojis and zero-width joiners.
212 - TC-F4-B05: Tokenizing text exceeding max sequence length (2048 tokens).
213
214 #### Feature F5 (Chat Template Boundaries)
215 - TC-F5-B01: System prompt with empty string `""`.
216 - TC-F5-B02: User prompt with empty string `""`.
217 - TC-F5-B03: User prompt containing raw template tokens (`<|system|>`, `<|user|>`, ``).
218 - TC-F5-B04: Deep multi-turn conversation with 50 alternating turns.
219 - TC-F5-B05: Chat prompt containing newlines and escape characters (`\r\n`, `\t`, `\0`).
220
221 #### Feature F6 (Encode/Decode Boundaries)
222 - TC-F6-B01: Decoding token ID sequence containing unknown ID (e.g. `u32::MAX`).
223 - TC-F6-B02: Decoding single token ID corresponding to partial multi-byte UTF-8 character.
224 - TC-F6-B03: Decoding consecutive EOS tokens (`[2, 2, 2]`).
225 - TC-F6-B04: Encoding string with single character repeated 2048 times.
226 - TC-F6-B05: Stopping check on sequence where EOS appears at position 0.
227
228 #### Feature F7 (Oracle Script Boundaries)
229 - TC-F7-B01: Oracle generation invoked with non-existent model path fails with exit code 1.
230 - TC-F7-B02: Oracle generation with read-only output directory reports permission error.
231 - TC-F7-B03: Oracle generation with batch size > 1 asserts unsupported configuration.
232 - TC-F7-B04: Oracle generation with float16 precision instead of float32 asserts validation error.
233 - TC-F7-B05: Oracle generation interrupt (SIGINT) cleans up partial temporary files.
234
235 #### Feature F8 (Oracle Fixture Boundaries)
236 - TC-F8-B01: Manifest with modified SHA-256 hash fails integrity check.
237 - TC-F8-B02: Oracle safetensors file truncated by 1 byte fails hash verification.
238 - TC-F8-B03: Oracle logits tensor contains zero NaN or Infinite values.
239 - TC-F8-B04: Oracle top-10 logits strictly descending in value.
240 - TC-F8-B05: Oracle intermediate activations have zero NaN values across all 22 layers.
241
242 #### Feature F9 (Algorithmic Alignment Boundaries)
243 - TC-F9-B01: RoPE execution at sequence position 0 (angles evaluate to 0, cos=1, sin=0).
244 - TC-F9-B02: RoPE execution at maximum sequence position 2047.
245 - TC-F9-B03: Matrix multiplication with all-zero input vector produces all-zero output.
246 - TC-F9-B04: Matrix multiplication with identity-like weights preserves inputs.
247 - TC-F9-B05: RMSNorm with all-zero input vector handles epsilon without division by zero.
248
249 #### Feature F10 (Parity Test Boundaries)
250 - TC-F10-B01: Parity check with absolute difference at exactly 1e-4 passes.
251 - TC-F10-B02: Parity check with absolute difference at 1.0001e-4 fails with descriptive message.
252 - TC-F10-B03: Parity check with cosine similarity at exactly 0.9999 passes.
253 - TC-F10-B04: Parity check with cosine similarity at 0.99989 fails.
254 - TC-F10-B05: Early divergence detection: inject deliberate delta at Layer 3, verify failure logs Layer 3.
255
256 #### Feature F11 (TensorBackend Trait Boundaries)
257 - TC-F11-B01: `rmsnorm` with slice length 0 handled without panic.
258 - TC-F11-B02: `matmul_vec` with dimensions `[1, 1]`.
259 - TC-F11-B03: `gqa_attention` with single key-value token (seq_len = 1).
260 - TC-F11-B04: `swiglu` with negative input values verifying SiLU non-linearity.
261 - TC-F11-B05: `compute_logits` with hidden dimension 2048 and vocab 32000.
262
263 #### Feature F12 (ReferenceCpuBackend Boundaries)
264 - TC-F12-B01: Extreme float values in input vector (`1e30`, `-1e30`) checking overflow safety.
265 - TC-F12-B02: Attention with identical query and key producing uniform attention weights.
266 - TC-F12-B03: Attention with large negative score masking out non-attended tokens.
267 - TC-F12-B04: KV cache with capacity exactly at max sequence length (2048).
268 - TC-F12-B05: Argmax sampling with uniform logits selecting lowest index deterministically.
269
270 #### Feature F13 (Mojo GB10 Kernels Boundaries)
271 - Removed on 2026-10-15 with Modular MAX and Mojo; its tests were deleted.
272
273 #### Feature F14 (MojoGb10Backend Boundaries)
274 - Removed on 2026-10-15 with Modular MAX and Mojo; its tests were deleted.
275
276 #### Feature F15 (Neutral Benchmark Driver Boundaries)
277 - TC-F15-B01: Target engine endpoint unreachable reports connection error and moves to next.
278 - TC-F15-B02: Target engine returns HTTP 500 reports server error without driver crash.
279 - TC-F15-B03: Concurrency sweep with C=0 rejected by CLI argument parser.
280 - TC-F15-B04: Output generation truncated early by server recorded as partial sample.
281 - TC-F15-B05: Cool-down timer interrupted by signal terminates gracefully.
282
283 #### Feature F16 (Concurrency Sweeps Boundaries)
284 - TC-F16-B01: Concurrency C=64 under thread pool exhaustion maintains queue ordering.
285 - TC-F16-B02: Request latency exceeding 60 seconds triggers timeout telemetry event.
286 - TC-F16-B03: Power telemetry query failure during benchmark recorded as null, not zero.
287 - TC-F16-B04: GPU temperature above 80 C triggers thermal warning log.
288 - TC-F16-B05: Telemetry calculations with 1 single request sample calculate percentiles accurately.
289
290 #### Feature F17 (Compliance Boundaries)
291 - TC-F17-B01: Hidden `.env` files in nested subdirectories detected and flagged.
292 - TC-F17-B02: Vault lookup for non-existent key returns clean None without panic.
293 - TC-F17-B03: String containing em dash Unicode character rejected by style checker.
294 - TC-F17-B04: String containing en dash Unicode character rejected by style checker.
295 - TC-F17-B05: Execution under unauthorized username terminates with exit code 1.
296
297 #### Feature F18 (PR Lifecycle Boundaries)
298 - TC-F18-B01: Attempting direct push to `main` branch rejected by repository policy.
299 - TC-F18-B02: PR creation with unstaged git modifications prevented.
300 - TC-F18-B03: Cortex write to unreachable IP address logs warning and continues.
301 - TC-F18-B04: Cortex write with invalid bearer token logs authentication error.
302 - TC-F18-B05: Git squash merge on branch with failing CI prevented.
303
304 ---
305
306 ### Tier 3: Cross-Feature Interactions (>= 18 Pairwise Combinations)
307
308 1. Pair P1 (F1 + F2): Safetensors loading of a file missing 1 of 201 tensors triggers loud `CheckpointError::MissingTensor` without entering execution.
309 2. Pair P2 (F1 + F3): Safetensors loading with valid BF16 weights populates both decoded FP32 weights and raw BF16 weights in `LoadedCheckpoint`.
310 3. Pair P3 (F2 + F9): Validating tensor catalog shapes enforces `[out_dim, in_dim]` layout used directly by aligned `matmul_vec`.
311 4. Pair P4 (F4 + F5): Pure Rust tokenizer loading `tokenizer.json` formats chat template and pins BOS=1, EOS=2, UNK=0.
312 5. Pair P5 (F4 + F6): Pure Rust tokenizer encodes prompt string, then decode reverses the token sequence back to original text.
313 6. Pair P6 (F5 + F6): Chat formatted prompt encoded to tokens terminates on EOS token ID 2 during autoregressive decode.
314 7. Pair P7 (F7 + F8): Reference Python oracle script execution produces `tinyllama_oracle.safetensors` matching `tinyllama_oracle_manifest.json` hashes.
315 8. Pair P8 (F8 + F10): Multi-stage parity test loads oracle safetensors fixture and validates Stage 1 through Stage 5 sequentially.
316 9. Pair P9 (F9 + F10): Aligned RoPE `rotate_half` and row-major matmul pass Stage 3 activation parity (cosine > 0.9999) without layer drift.
317 10. Pair P10 (F9 + F12): Reference CPU backend executing aligned math passes all 5 parity stages against Hugging Face oracle.
318 11. Pair P11 (F3 + F13): removed 2026-10-15 with Mojo.
319 12. Pair P12 (F11 + F12): `ReferenceCpuBackend` implements `TensorBackend` trait and processes full forward pass token evaluation.
320 13. Pair P13 (F11 + F14): removed 2026-10-15 with Mojo.
321 14. Pair P14 (F13 + F14): removed 2026-10-15 with Mojo.
322 15. Pair P15 (F10 + F14): removed 2026-10-15 with Mojo.
323 16. Pair P16 (F15 + F16): Neutral benchmark driver executes concurrency sweep C=1..64 on AIEN collecting TTFT and ITL.
324 17. Pair P17 (F16 + F17): Telemetry collection records GPU power and memory while maintaining zero disk secrets in memory.
325 18. Pair P18 (F15 + F18): Benchmark completion writes structured results and triggers autonomous PR squash merge with Cortex memory receipt.
326
327 ---
328
329 ### Tier 4: Real-World Scenarios (>= 9 Workflows)
330
331 1. Scenario SC-01 (Golden Prompt Single-Turn Inference):
332 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%.
333 2. Scenario SC-02 (16-Step Autoregressive Generation):
334 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"`.
335 3. Scenario SC-03 (Corrupted Checkpoint Recovery & Rejection):
336 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.
337 4. Scenario SC-04 (CLI Doctor Inspection):
338 Operator executes `aien-cli --doctor`. System validates platform context, execution surface detection, filesystem structure, and reports operational health.
339 5. Scenario SC-05 (CLI Status & Version Check):
340 Operator executes `aien-cli --version` and `aien-cli --status`. System detects host surface, confirms release tag, and prints formatted status without launching background daemons.
341 6. Scenario SC-06 (Automated Parity Gate):
342 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.
343 7. Scenario SC-07 (Apples-to-Apples Multi-Engine Benchmark):
344 Operator launches neutral benchmark orchestrator. System pauses for thermal cool-down, tests AIEN, and outputs TTFT/ITL telemetry.
345 8. Scenario SC-08 (Zero-Disk-Secrets Invariant Audit):
346 Automated auditor scans workspace. Verifies zero `.env` files, tests in-memory TPM vault resolution, and verifies compliance.
347 9. Scenario SC-09 (Sovereign Voice & Git PR Lifecycle):
348 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.
349
350 ---
351
352 ## 4. Test Execution Architecture & Single Command Runner
353
354 The complete E2E test suite resides in `e2e_tests/` and is executable via a single top-level runner command:
355
356 ```bash
357 bash e2e_tests/run_e2e_tests.sh
358 ```
359
360 Or via direct Cargo invocation:
361
362 ```bash
363 cargo test --manifest-path e2e_tests/Cargo.toml -- --nocapture
364 ```
365
366 The runner executes tests in progressive phases:
367 1. Environment & Invariant Checks (Zero Secrets, Sovereign Voice, User identity).
368 2. Checkpoint Loader & Validation Tests (Positive, Negative, Boundaries).
369 3. Tokenizer & Chat Template Tests (Encode, Decode, Special Tokens).
370 4. Tensor Math & Backend Integration Tests (RoPE, MatMul, RMSNorm, SwiGLU).
371 5. CLI Entry Point & Negative Argument Tests (`aien-cli` commands, zero panics).
372 6. Parity Verification & Oracle Contract Tests.