Skip to content

Core: versioned stores, batched diffs, UniFFI and iOS build - #4

Closed
MHohlios wants to merge 3 commits into
wiffletree/phase-0-rust-workspace-and-gpui-spike-virtualizefrom
wiffletree/core-versioned-stores-batched-diffs-uniffi-and-i
Closed

MHohlios wants to merge 3 commits into
wiffletree/phase-0-rust-workspace-and-gpui-spike-virtualizefrom
wiffletree/core-versioned-stores-batched-diffs-uniffi-and-i

Conversation

@MHohlios

Copy link
Copy Markdown
Contributor

This splits state into versioned stores, so a shell redraws only what changed (PRD §5 #5 and #7, §12). It also adds a coarse UniFFI boundary and an iOS build of the core from day one (§4 goal 5).

Linear: VYT-192 (Phase 1: Core, VYT-186). Stacked on #1 (Phase 0).

What's in it

  • store module:
    • Revisions. Versioned<S> bumps its revision only on a real change, so a no-op write does nothing.
    • The store set. It is declared once, following §12: terminal, vitals, room, map, mobs, characters, gear and settings. The payloads are placeholders until their own tickets land.
    • StoreHub. Core threads write changes, which coalesce per store. The shell drains at most one batch per frame, with one wake per batch, and can take a snapshot of any store.
    • Memory bound. Terminal appends that pile up while a shell isn't draining are capped at the store's capacity.
    • Memo<K, V>. Caches derived data against input revisions (§5 Core: plugin host (API v1, plugin.toml, merged matchers, layers) #7).
  • mudling-ffi (UniFFI 0.32):
    • Session.open(waker), subscribe, unsubscribe, snapshot, drain, sendCommand.
    • There is no per-line call: only store updates cross the boundary.
  • scripts/build-ios.sh. Builds the static libraries for aarch64-apple-ios and the simulator, the XCFramework, and the Swift bindings.
  • .github/workflows/ios.yml. Builds the core for iOS and type-checks the Swift bindings.

Numbers (release)

  • Applying one frame's batch next to a 100,000-line terminal: p99 about 3 µs.
  • A 50 lines/s burst over 2 s: 100 writes became 10–11 batches across about 233 frames. Per-frame drain and apply was p99 7–27 µs.

Verified locally

  • Both iOS targets build.
  • The XCFramework is produced with device and simulator slices.
  • swiftc -typecheck of the generated bindings against the iOS simulator SDK passes.

Follow-ups

  • Fold ios.yml into Phase 0's ci.yml.
  • build-ios.sh --debug fails under the stock bash 3.2.
  • The FFI tests cover only the terminal store.

mhohlios added 3 commits October 29, 2026 14:19
mudling-core gains a store module: the §12 store set (terminal, vitals,
room, map, mobs, characters, gear, settings), each with a revision that
bumps only on a real change. A StoreHub coalesces a frame's changes into
one batch that the shell drains on its frame tick, and wakes the shell once
per batch. Memo caches derived data against input revisions. Payloads other
than the terminal's are placeholders for later tickets.

mudling-ffi exposes a coarse UniFFI API (open, subscribe, snapshot, drain,
send a command) and builds for iOS. scripts/build-ios.sh produces the
XCFramework and Swift bindings; a CI workflow runs it on macOS.
mudling-bench measures a frame's batch apply and a 50 lines/s burst.
A shell that stops draining, such as a minimized window, no longer grows the
pending terminal diff without bound; the lines dropped are ones the terminal
would trim anyway. The terminal tests move next to the payload, and the bench
derives its frame budget from the frame length.
Keeps Phase 0's first-page find line and the stores report in the bench
output. The iOS build moves into ci.yml as its own job, replacing ios.yml,
and the stores and FFI files are formatted for the new rustfmt check.
@MHohlios

Copy link
Copy Markdown
Contributor Author

Landed on main through #15.

@MHohlios MHohlios closed this Oct 31, 2026
@MHohlios
MHohlios deleted the wiffletree/core-versioned-stores-batched-diffs-uniffi-and-i branch November 1, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant