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 / docs / persistent-kv / CUTS.md

192 lines · 28908 bytes Raw Blame History Source

Persistent KV program: implementation cuts

Binding design: docs/adr/0003-persistent-kv-identity-storage-contract-and-ownership.md (ADR 0003, revised after the independent review, ADR section 17). Issues: sovereign-core #484, #485; aienos #367. Each cut is one reviewable PR with its own red-before-green tests. "Red" means the test is committed first and fails for the stated reason; "green" is the implementation commit in the same PR. Acceptance boxes are quoted by id from the tables at the end. Every test name below is PLANNED (designed, no receipt yet) unless a line says it exists. C1 exists (merged at ce5d9eb, red tests at 288c18c); everything else is not started.

Plan corrections (against ~/handoffs/2026-10-13-persistent-kv-program.md)

  1. The order "P2 all of #484, then P3 #485" is wrong at the runtime seam. Parking and restoring in the runtime (#484 scope) cannot be wired without the bounded queue, the worker and the residency state machine (#485 scope): a park that blocks the spine or a restore with no incarnation check would be thrown away later. So the trait and the deterministic fake adapter (C2) come right after identity (C1), the worker and queues (C5) come before the runtime wiring (C6), and C6 is where #484 and #485 meet. The handoff's note that #485 "may start in parallel against a fake adapter" is kept and made concrete: C5 and C8 develop against C2's fake.
  2. The #484 "core" PR in the plan is too big to review (identity + trait + adapter + recovery + park/restore + recompute + metrics). It is split into C1, C3, C4, C6, C7. Every cut stays under roughly 1500 changed lines including tests.
  3. The native pin goes in aienos, not in sc, and it pins bytes, not a crate: the header codec and slot header test vectors (section "Pin").
  4. Recompute-on-miss is not a separate feature: a miss or a failed restore leaves prompt_tokens_prefilled = 0, which is today's prefill path (ADR 0003 section 6.3). It is tested in C6, not built.
  5. Benchmarks (C9) run on the host CPU backend by default; the GB10 leg is a separate, optional evidence run that must not take the GB10 lock away from the OWN-30B and 8B lanes named in the handoff.
  6. Review corrections (this revision). (a) C1 as merged does not bind the compute configuration (finding 1) and has a 256-byte file header; C1b changes it before anything builds on it (ADR section 12). (b) The park cannot hook the spine's Finished branch because the scheduler frees KV first (finding 2); the scheduler and backend seam is its own cut, C6a, ahead of the runtime wiring in C6. (c) Holders need fork_range and assemble_table, not fork_sequence (finding 6), so C3 grows. (d) Native performance work (ADR section 15) and the Pi 5 physical lane (ADR section 16) are new cuts X1 to X7 and P1 to P3 at the end of this file. (e) The labelled guarantee matrix is a deliverable of C7, not prose.

Dependency graph

sovereign-core (arrow means "must merge first"):
C1 -> C1b -> C2 -> C5 -> C6
C1b -> C3 -> C6a -> C6
C2 -> C4 -> C6
C6 -> C7, C6 -> C8 -> C9
C9 + C4 -> X1 -> X2 -> X5
C6 + C8 -> X6;  C6 + C3 -> X6b

aienos:
C1b -> N1 -> N2 -> N3 -> N4 -> N5
N4 -> X3 -> X4 -> X7 (conditional, needs X5 and a profile)
N2 + N4 -> P1 -> P2 -> P3 (Drake authorizes; Pi must be free)

Parallel lanes once C2 is merged: {C3, C4} and {C5} in parallel; {N1, N2} in parallel with C3..C5. C6a can start as soon as C3 lands (it needs fork_range) and in parallel with C4/C5. C8 and C9 after C6. N3..N5 need only C1b's vectors, not any later sc cut.

sovereign-core cuts

C1: identity, header codec, validation (#484) (MERGED at ce5d9eb, VERIFIED)

C1b: compute-config digest and 4096-byte header region (#484, review finding 1, ADR section 12)

C2: KvStore trait and deterministic fake adapter (#484, #485 shared; ADR section 13)

C3: kv-cache ownership primitives (#484, findings 5 and 6)

C4: host filesystem adapter and recovery (#484; ADR sections 2.4, 4.1)

C5: storage worker, bounded queues, fairness, coalescing, drain (#485; ADR section 7)

C6a: scheduler and backend seam (#484, findings 2, 3, 4)

C6: runtime park at the finish transaction, restore at submit, residency states (#484 + #485 seam)

C7: real restart, greedy equality, metrics and settings, labelled matrix (#484)

C8: concurrency proof through scheduler and backend (#485)

C9: benchmark (#485)

aienos cuts

N1: native header codec, slot header, and golden vectors (the pin) (#367)

N2: slab format, header-last write order, bounded recovery (#367)

N3: native adapter, sealing, fault injection (#367)

N4: ownership, cancellation, pump between steps and idle, session restore (#367, findings 13 and 14)

N5: QEMU store, reboot on the same image, restore, continuation (#367)

Native performance track cuts (ADR section 15)

cutcontentdepends onred tests
X1Linux baseline harness: four labelled modes, device ceiling, CPU time per MiB, peak RSS (15.1)C4, C9bench_refuses_mixed_cache_state_summary, cache_state_device_requires_verified_zero_residency, baseline_reports_fraction_of_device_ceiling
X2O_DIRECT host path, payload at 4096, aligned reads straight into pool blocks, buffered fallback with counter (15.3)X1, C1bodirect_read_lands_in_pool_block_without_intermediate_copy, misaligned_destination_falls_back_and_counts
X3native region state machine and zero-copy DMA ownership proof, emulator first; GB10 rules read via spark-hardware-manual and docs-read recorded before any driver change (15.2)N4dma_target_region_not_reused_until_terminal_completion, cancel_while_dma_pending_keeps_region_reserved, verify_failure_never_exposes_rows_to_session, region_state_transitions_are_exclusive
X4native paged KV, backend_format 3, on-disk chunk equals in-memory chunk; refuses to merge if decode throughput drops more than 2 percent on the PI5-6 golden run (15.3)X3, N5native_paged_chunk_bytes_equal_disk_bytes, native_paged_decode_matches_strided_decode_bitwise, kv_restore_copy_bytes_is_zero_for_payload
X5pipelined per-segment verification and the SHA-256 vs BLAKE3 vs per-block receipt (15.4)X2, N3pipelined_verify_never_adopts_before_root_checked, corrupt_segment_k_detected_while_segment_k_plus_1_in_flight, pipelining_does_not_reorder_digest_checks_before_header_checks, verify_cpu_time_per_mib_reported
X6predictive restore from application/Interplane hints; first reads the real Interplane signal list (15.5)C6, C8prefetch_hint_never_blocks_step, unused_prefetch_expires_and_frees_holder, prefetch_respects_restore_bound, real_request_adopts_prefetched_prefix_without_second_read
X6bstreaming park of immutable full chunks during decode, host first, native after X4 (15.6)C6, C3streaming_park_publishes_full_chunks_before_finish, streaming_park_never_reads_rows_that_decode_still_writes, cancel_after_streamed_chunks_keeps_them_valid, streaming_park_respects_park_bound
X7multi-command NVMe window; only if the profile shows the single-command contract is the bottleneck (15.7); otherwise closed REJECTED with the profile as evidenceX3, X5, profile from X1/N5command_ids_are_unique_among_inflight_commands, command_id_wraparound_never_aliases_an_inflight_command, dma_buffer_lifetime_covers_every_inflight_command, controller_reset_fails_every_inflight_job_terminal_once_and_releases_regions_after_reset_ack, cancel_with_commands_inflight_waits_for_their_completions_before_release, flush_ordering_header_flush_issued_only_after_all_payload_completions, power-cut injector re-run with more than one command in flight

Target ratios and which cut earns each are in ADR 15.8; none is a result until its cut has a receipt.

Pi 5 physical lane cuts (ADR section 16)

cutcontentdepends onred tests
P1128 MiB (32768 unit) slab inside the AIENOS partition view, KV.MAP on the ESP written by the pi5-run.sh path, Store shrink and one reformat plan, state record; aarch64 emulation of the card layoutN2, N4slab_lies_inside_partition_view, kv_map_stale_or_missing_means_no_slab, state_record_roundtrip_across_reformat_plan, existing_store_gates_pass_with_pi_layout
P2native CPU park and restore in the pi5-agent session, emulator run reproducing the golden 17 ids and 8 output idsP1, N4pi_agent_parks_after_reply_and_restores_on_next_boot_emulated, pi_restore_prefills_only_suffix, pi_flipped_superblock_byte_refuses_restore
P3the physical run: park, real cold boot via tryboot, restore, golden continuation, negative control; labelled "native physical (Pi 5)"; kept separate from Spark-native (NOT_RUN under aienos#336) and hosted results. Drake authorizes it because it reformats the test card's Store and occupies the PiP2, Pi free per the Pi lane ownergolden_ids_equal_after_cold_boot, restored_tokens_greater_than_zero, restored_prefill_time_below_cold_control, corrupted_slab_falls_back_to_prefill; receipt recorded in docs/evidence/kv-native.md

Pin: where it goes and what it pins

native/kv/CONTRACT.lock in aienos:

format_version = 1
sc_commit = <sha of the sc commit whose C1b generated the vectors>
sc_adr = docs/adr/0003-persistent-kv-identity-storage-contract-and-ownership.md
vectors_sha256 = <sha256 of tests/golden/kv_record_v1.json>
slot_vectors_sha256 = <sha256 of native/kv/tests/golden/kv_slot_v1.json>

It pins the 256-byte header layout, the 4096-byte region rule, the namespace field order including the compute-config digest, the key derivation strings, the validation error order, the native slot header and envelope mapping, and the test vectors. It does not pin a crate, a Rust version or any runtime behaviour. N1's test refuses to run if a vectors file hash differs from the lock. The sc side records the same hash in crates/aien-kv-store/tests/golden/README.md so a vector change is a deliberate two-repo bump. The pin is created by N1 only after C1b merges; the C1 vectors at ce5d9eb (7c532a54...b89c) are superseded by C1b and must not be pinned.

Acceptance ids

#484: A1 store, real restart, rediscover, restore identical bytes. A2 greedy continuation equals baseline (stochastic separately specified: not claimed, ADR 6.4). A3 wrong model/layout/position/namespace and truncated/corrupt payloads cannot be reused. A4 disk-full, interruption, failed writes never discard the last usable KV/history. A5 shared-prefix owners remain valid on park/cancel. A6 resident, staging and disk budgets bounded including restart accounting. A7 tests distinguish adapter recreation, process restart, clean reboot, power loss. A8 metrics.

#485: B1 slow-I/O progress proof. B2 concurrent park/restore and fork/cancel preserve payloads and refcounts. B3 duplicate loads, stale completions, queue-full, disk-full, mid-transfer cancel. B4 memory pressure: bounded, progress, no deadlock. B5 real routing through scheduler/backend. B6 benchmark 1/2/4/8. B7 resident vs cold vs restore, page-cache vs device, hosted vs native. B8 NOT_RUN recorded.

#367: D1 host fault injection (partial writes, flush failure, bad length/checksum, disk-full, exhausted queues). D2 emulator store, reboot on the same disk, restore, continuation. D3 existing Store/Cortex/boot/update/recovery tests valid. D4 buffers/blocks retained until device completion incl. cancel/shutdown. D5 progress evidence distinguishing inference during I/O from queueing; native limitations documented. D6 report allocated memory, staging bytes, persisted bytes, transfer latency, restart recovery; physical only from an authorized run.

Review coverage: boxes the review found uncovered

boxclosed bytest
A4C4fault_at_each_publication_boundary_leaves_consistent_outcome
A6C4recovery_keeps_admission_closed_until_walk_completes, used_bytes_counts_header_region_and_physical_blocks
B3 (sibling cancel)C5, C6restore_txn_holder_survives_sibling_failure_until_all_jobs_terminal, multi_chunk_restore_failure_does_not_free_destination_in_use
B4C5sustained_restores_cannot_starve_parks, completion_queue_never_overflows_at_max_inflight, coalesced_waiters_are_bounded
B6C9bench_output_requires_completed_requests_latency_percentiles_and_peaks
D3N2, N5n2_existing_store_gates_pass_with_slab_present, n5_existing_gates_pass_with_slab_present
D4N4park_snapshot_survives_next_prompt_reset, session_close_with_queued_park_keeps_staging_until_job_terminal, reset_between_pump_calls_leaves_only_whole_slots
D6N3, N4, N5staging_report_lists_export_cipher_env_plain_scratch_bounce_peak_separately, staging_peaks_reported_in_kv_line