Repository navigation
ADR 0045 D2: substrate v2b wiring — shared base shm + handler CONTINUE arm - #165
Merged
Merged
Conversation
Picks up cortexapps/firecracker#4 — the ADR 0045 D1 fork surface: an optional uffd_base_file load param backing Uffd-restored guest memory MAP_PRIVATE on a shmem base file with MISSING|MINOR registration. Inert in this binary: engrams never sends the field yet (that's the D2 wiring PR), and the default path is byte-identical to the current fork (R2 guard verifies). The fleet roll this triggers ships a drop-in. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The engrams half of the unified memory substrate, dark behind ENGRAM_FC_UFFD_BASE_DIR (unset everywhere; D3/D4 parity gates flip it on and retire the knob): - client: SnapshotLoadBody grows uffd_base_file (skip_serializing_if — bodies stay byte-identical to stock when off). - engram-sandbox-firecracker: FirecrackerConfig.uffd_base_dir; the Uffd restore leg derives <dir>/<canonical>-v<n>.base through one helper for both the handler spawn (--base-shm) and the FC load, so the two can't diverge. - engram-uffd-handler: a BaseShm module (create+size before the UDS binds — FC's open is ordered after wait_for_socket; SEEK_HOLE populated-probe; idempotent canonical pwrites) and the substrate resolution: ResolvedPage::Canonical → ensure-base-populated + UFFDIO_CONTINUE over the chunk range (one page-cache copy shared by every same-template VM; the populated fast path skips the chunk fetch entirely), ResolvedPage::Chunk → UFFDIO_COPY as today, zero chunks → ZEROPAGE with COPY-of-zeros fallback. The prefault path routes canonical positions through the shared install too — a prefault COPY would privately duplicate exactly the hot pages the substrate shares. - host-agent env + Tiltfile plumbing. - tests/substrate_uffd_base.rs (fork-gated like stock_fork_snapshot_compat, wired into ci.yml): restore round-trips on the forked FC, the base shm is created/sized/populated by the handler, and a sibling restores against the already-warm base — green on engram-dev real KVM (21s). snapshot_uffd (stock path, base off) stays green; Linux clippy clean. Rides the fc-fork-substrate-v2-bump gitlink (cortexapps/firecracker#4). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The engrams half of the unified memory substrate (ADR 0045 D2), stacked on #164 (the fork gitlink bump it requires). Ships dark:
ENGRAM_FC_UFFD_BASE_DIRis unset everywhere; with it unset every path is byte-identical to today (load bodies omit the field, the handler runs stock Route-B). D3/D4's parity gates flip it on and retire the knob.When the env points at a tmpfs dir, Uffd restores become the v2b substrate:
wait_for_socketorders FC'sopen(O_RDONLY)after that, so the load always sees a fully-sized file. One path-derivation helper serves both the spawn and the load.Validation (engram-dev, real KVM + forked FC)
substrate_uffd_base(new, fork-gated likestock_fork_snapshot_compat, wired into ci.yml): restore round-trips on the fork, base shm created/sized/populated by the handler (SEEK_DATA finds extents), sibling restores against the already-warm base, both VMs alive — green in 21s.snapshot_uffd(stock path, base off): 2/2 green — inertness proof.-D warningsclean;just checkgreen (1047 tests).Density (PSS) parity measurement is deliberately D3's gate, not this PR.
🤖 Generated with Claude Code