Hylix: From Stable Bytes to Records

What the viewer will understand

What does a service touch when its module uses Hylix? The viewer can already find a module and follow an allocation into main memory. Here they should be able to trace a retained record descriptor to stable bytes, distinguish a decoded record from a cached byte segment, and explain what an update flushes and what a query discards. Allow roughly three minutes plus holds on the copy and the flush.

The worked example

Use the V1 engine-composition probe. The root attaches payloads and records, and records selects Hylix for entries, blob and revision. After seeding 256 entries, mutate(1) rewrites Payloads first and Records second in one update. Both revisions change from 0 to 1. Records repopulates its map and blob, and Payloads replaces its vector and reuses its slot with a new generation. The probe checks byte-for-byte equality around repeated snapshot queries at the seeded and final states. The storyboard's closing query uses the intervening revision 1 snapshot. Root and provider wiring · Records declaration · Mutation entry · Lifecycle test

Give the byte-cache close-up its own small native provider test label. In hot_rows_load_once_flush_one_span_and_reopen_cold, a 128-byte allocation starts zeroed. The test writes and reads back values 1 through 1000 at payload byte offset 64 in one write frame. It uses 4,096-byte segments, a four-segment capacity, and retain_clean: false. The counted interval records one segment read and one write of eight bytes. A cold read after reopening verifies 1000. The counts are provider calls in this native test. Hylix WorkingSet tests

The story in one pass

Follow records from its retained descriptor to the stable bytes and the fields Store decodes. A separate native test shows a segment load, a thousand edits to the same range and one span flush. Back in the probe, follow mutate(1) through both owners and the Hylix finalization path. After the closing snapshot, the rewritten Payloads vector is ready for Minima's read.

Components and views

Use the shared visual language. Keep payloads on the left and records on the right below the one root. Draw the retained Record<Data> descriptor inside records' private Data compartment. Its locator reaches a HylixBlock in the Hylix virtual image. Keep the image grounded in the stable-memory band, with room below it for the physical mapping in lesson five. Put the decoded fields in a Store frame tray above Hylix's WorkingSet, with a Codec conversion between the fields and their bytes. Use the existing WorkingSet geometry with the native test's segment and byte-range assertions. The solid, immobile attachment edges represent Store ownership.

View Camera anchor and visible machinery
composed_root One actor root and both attached owners. Runtime and retained claims stay identifiable in the shared main-memory band, with stable memory below.
record_access records.Data, the retained descriptor, the encoded fields, and the frame's decoded Data rows in one frame.
stable_segment The native provider test's source segment and its temporary copy, with both transfer routes and the byte window at offset 64 legible.

Scene hylix_record — Follow a record into stable memory

Enters with The engine-composition probe already in composed_root from lesson three. Both owners have completed seed(256) and show revision 0.

Beat locate_records — Find the Hylix owner

View and focus composed_root, on the attachment from the root to records.

Narration

Start with Records on the right. When the canister takes a snapshot, this service opens its Hylix record. Follow the retained descriptor down to the bytes it will read.

Cue and animation On “Records on the right”, emphasize the already attached owner. On “takes a snapshot”, send snapshot() in and follow its Records read. On “Follow the retained descriptor”, move the camera down the Record<Data> locator into the Hylix image with the owner still visible.

Leaves with The rooted descriptor and the stable block both visible.

Beat decode_record — Open the fields for one actor frame

View and focus record_access, on the fields of the temporary decoded Data and the encoded block they came from.

Narration

The encoded record holds a revision and handles for the entries map and the blob. Hylix's working set holds encoded bytes. When the service opens the record, Store decodes its fields into the actor frame. A later access in that frame reuses the decoded record.

Cue and animation On “working set holds encoded bytes”, highlight the cache segment. On “Store decodes its fields”, take the encoded record through Codec into the frame's entries, blob and revision rows. The two collection handles lead to their own payloads. At “A later access”, show how a second access would point to the same frame fields. The snapshot itself opens the record once.

Leaves with One decoded record in the frame and its encoded source still in the image.

Scene hylix_working_set — Watch one segment through a thousand edits

Enters with The seeded snapshot has returned and its read frame has closed. Cut from the stable side of the decode path to the separate native test before giving its counts.

Beat load_segment — Copy one segment into main memory

View and focus stable_segment, on the read route and the transient copy.

Narration

Watch the byte cache in a small native test. The first access loads a four-kibibyte segment into the Working Set. The test changes eight bytes inside that segment and reads them back from the same copy.

Cue and animation At “a small native test”, switch to the labeled test view with the 128-byte allocation initialized to zero. On “loads a four-kibibyte segment”, copy the same segment outline across the read route. At “changes eight bytes”, write 1 to the cached payload range 64…71 and replay its read locally. Stable bytes stay zero during this beat.

Leaves with The cell value 1 in the cache and the eight-byte range marked dirty.

Beat repeat_hot_edits — Reuse coherent bytes

View and focus stable_segment, on the resident payload window.

Narration

The next write hits that resident segment. It changes the same eight bytes, and the next read sees the new value. Repeat the loop up to one thousand. All those edits leave just one span to flush.

Cue and animation On “hits that resident segment”, show the write and local read of 2. On “up to one thousand”, compress the loop 3…1000 and settle on 1000 in the cached window. The read route remains quiet and the dirty range stays the same size.

Hold After 1000 is readable, freeze the camera and machinery for “All those edits leave just one span to flush.” Point PauseAndExplain at bytes 64…71 in the cache with the balloon Dirty span · 8 B. Resume on “When the write frame ends” in the next beat.

Leaves with Eight dirty bytes in the transient segment with the backing bytes still zero.

Beat flush_span — Publish eight bytes to the provider

View and focus stable_segment, following the write route back to the provider.

Narration

When the write frame ends, the provider gets one eight-byte write. The test counted one segment read and that one write. Reopen the arena and read the allocation again. The saved value is one thousand.

Cue and animation On “one eight-byte write”, send only bytes 64…71 to their stable location. Clear the dirty mark once they arrive, then remove the transient segment because this test uses retain_clean: false. On “Reopen the arena”, show a separate descriptor read followed by a payload read and reveal 1000 from backing. Keep the reopen reads outside the earlier write frame's count.

Leaves with 1000 visible at the stable source and the test complete.

Scene hylix_frame_end — Publish the record, close the frame

Enters with The native test finished. Return to the composition probe with both owners at revision 0.

Beat rewrite_both — Follow one update through both owners

View and focus Start in composed_root at payloads, then follow the call to records and move into record_access.

Narration

Back in the probe, one update rewrites both modules. Payloads replaces its fixed vector first. Records then rewrites the map and blob and sets its revision to one. The collection writes reach the byte cache during the call.

Cue and animation On “one update rewrites both modules”, send mutate(1) in. At “Payloads replaces its fixed vector”, update its values descriptor and show its revision moving to 1. On “Records then rewrites”, follow the call into Records. Show the map and blob writes touching the working set, then set the decoded record's revision to 1 at “sets its revision to one”.

Leaves with The rewritten Payloads values and the new Records fields in the active update. The final Hylix flush still follows Store's record encoding.

Beat publish_record — Finish the Store update

View and focus record_access, with the decoded revision field and stable record visible.

Narration

At the end of the frame, Store encodes the dirty record into the cache. The arena publishes its allocation metadata and flushes the remaining dirty spans to the provider.

Cue and animation On “Store encodes the dirty record”, add the encoded module record to the cache beside the dirty collection spans. Drop the decoded rows when Store finishes with them. On “publishes its allocation metadata”, add the metadata writes. On “flushes the remaining dirty spans”, send the final spans toward the stable provider. The native test supplies the exact byte lengths and provider call counts for its own frame.

Leaves with The composition probe's updated record in stable memory. Any segment retained after the commit is clean according to the engine's policy.

Beat discard_query — Follow a read without a write

View and focus record_access, on the temporary copy and the stable source side by side.

Narration

A snapshot query can read those committed bytes. When the query closes, its temporary decoded record and cache are discarded. The stable image stays as it was before the query.

Cue and animation On “can read those committed bytes”, open a read-only frame and collect revision 1 in the owned snapshot result. At “are discarded”, release the decoded record and clear the cache backing. Keep the provider write route dim and the stable record fixed. The reply leaves in the next beat.

Leaves with The original descriptor and the same committed stable bytes as at query entry.

Beat widen_to_payloads — Return to the shared root

View and focus composed_root, ending on payloads.Data and the route down to stable memory.

Narration

The snapshot returns both owners at revision one. Payloads has a new set of values in stable memory. Follow its retained vector descriptor for the next read.

Cue and animation On “both owners at revision one”, let the snapshot reply leave and widen along the ownership edges into composed_root. On “retained vector descriptor”, settle on the replacement values field in payloads.Data, with the Hylix locator still visible. Lesson five starts on this framing and state.

Leaves with The two post-mutate(1) owners, with the replacement FixedVec selected under Payloads.

Review notes

  • Verify decode_record against FrameRecords::get and FrameRecords::finish. Decoded records are scoped to one actor frame. The segment cache holds encoded bytes and can reuse clean update segments. The two have separate lifetimes. Store record buffering · Hylix byte-cache and finalization rules
  • Before animation, derive the native segment and raw provider offsets from the selected test capture. The 64 label is within the test allocation. The arena's cold reopen may load descriptor metadata as well as payload. Keep that cold-read traffic outside the count shown for the write frame.
  • Check that Payloads rewrites first and that both revised owners carry into lesson five. The map and blob rebuild can touch several segments, and mutable eviction can flush earlier in the call. The final flush covers spans still dirty at frame completion. The probe's separate trap case checks IC rollback of both owners and the stable image. Store record finalization · Arena finalization · Trap assertions
  • Review the freeze after repeat_hot_edits. The byte mark and camera stay still while the balloon speaks. On resuming, the cached bytes travel to the source before the stable value changes. Review discard_query on a frame where both temporary layers have left and the stable record remains.