Skip to content

Home: bound the key table and share it with memory() (#395) - #413

Merged
GLinnik21 merged 1 commit into
mainfrom
fix/395-pr6-home-key-table-bounded
Oct 4, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
fix/395-pr6-home-key-table-bounded

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What

Home's key table (HomeScreen::items / groups) never shrank, was deep-cloned whole by every memory() and written whole to canon. This bounds it and shares it with memory().

Prune rule

At the end of every new projection in sync_catalog (was = the previous projection's shown elems, now = the new one):

  1. A volatile key (a Slot item, or an item of an Ephemeral hub; both carry their generation and can never match again) is dropped when it is in neither now nor was and is not the focused elem.
  2. If the table still holds more than 2 * now + 256 keys, keys in neither now nor was and not the focus are dropped, lowest elem first (elems are minted monotonically, so the newest survive).
  3. Ephemeral groups of an older generation are dropped.
  4. Both indexes (item_index, group_index) are rebuilt from the tables after any drop.

Stated consequence: a remembered cursor older than the retained window recovers to the first row (reconcile's existing fallback).

A Home whose hubs all carry stable identifiers and whose cards all have rating keys, and which stays under the cap, drops nothing: items is bit-for-bit what it was (a_stable_home_under_the_cap_prunes_nothing).

Sharing

HomeScreen::items and HomeMemory::items are Arc<Vec<HomeItemKey>>. memory() clones the Arc; every write goes through Arc::make_mut, and last_row/last_col are written only when they differ, so an unchanged republication leaves the table shared. No serde is involved (canon walks the slice), so Cargo.toml is untouched.

Pruned keys in the focus engine

Every use of a remembered elem goes through the owner's reconcile (FocusEngine::enter on restore, reconcile after each landing, Seat::ProjectedFrom). For Home, a pruned key makes reconcile fall through to the first row, the same fallback an unknown elem already gets. Elems are never reused (next_elem is monotonic, restored on restore), so a pruned elem cannot alias another card.

Tests

  • volatile_keys_do_not_accumulate_across_publications: red before (240 keys after 20 publications), green after.
  • the_focused_vanished_key_survives_a_prune: red before on its "unfocused key was kept" half.
  • stable_keys_are_bounded_oldest_first: red before (400 keys, cap 264).
  • a_stable_home_under_the_cap_prunes_nothing, focus_recovers_to_the_same_row_after_its_card_rotates_out, memory_shares_the_key_table: guards, green before and after.

Gates (committed tree, git status --short empty before and after)

  • cargo +nightly test -p plxnative-modules --lib screens::home: test result: ok. 95 passed; 0 failed
  • cargo +nightly check --lib --no-default-features: clean
  • make check: test result: ok. 4956 passed; 0 failed; 8 ignored and test result: ok. 5034 passed; 0 failed; 8 ignored (plus the smaller suites, all ok), exit 0
  • make (ARM cross-build): exit 0
  • make check-replay not run locally; CI's simulator job is the replay evidence.

Part of #395

🤖 Generated with Claude Code

The Home key table never shrank, was deep-cloned by every memory() and written whole to canon.
After each projection, sync_catalog now prunes it: a volatile key (a Slot item, an item of an
Ephemeral hub) goes once it is in neither the shown nor the previous projection and is not the
focus; past 2 x shown + 256 keys the oldest unshown, unfocused keys go too; Ephemeral groups of
an older generation go. Both indexes are rebuilt after a drop. A Home with stable hubs and rating
keys under the cap drops nothing. A remembered cursor older than the retained window recovers to
the first row.

HomeScreen::items and HomeMemory::items are Arc<Vec<HomeItemKey>>; memory() clones the Arc and
last_row/last_col are written only when they change, so an unchanged republication stays shared.

Part of #395

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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