Skip to content

serve: prune collapsed (xn-) bundle names precisely on revalidation - #26

Merged
dalkia merged 1 commit into
mainfrom
fix/precise-xn-prune
Jul 23, 2026
Merged

serve: prune collapsed (xn-) bundle names precisely on revalidation#26
dalkia merged 1 commit into
mainfrom
fix/precise-xn-prune

Conversation

@dalkia

@dalkia dalkia commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Problem

prune_stale_bundles deliberately over-invalidates xn- entries (storage names over the 200-byte cap, collapsed to a hash of themselves) because they can't be parsed back to their source content hash. On production corpora that class is empty — real hashes are short. But on SDK preview scenes the ids are base64-of-path-plus-hostname, and a scene with moderately deep folders sits right at the cap: on Genesis Plaza's central-plaza, 1,186 of ~2,000 cache entries are xn-, so a one-file edit made hot reload reconvert half the corpus (~1,900 files rewritten, a wall of ABGEN_BUILD, tens of seconds), every single time.

Change

The corpus build already knows each (storage name → source hash) pair at write time. It now records the collapsed ones in a names index (<digests>/<key>.names.json, merged incrementally, atomic rename) and revalidation's prune resolves xn- entries through it — they prune exactly like verbatim names, .br sidecars included. Names the index doesn't know keep the old wholesale sweep: that covers true orphans, and doubles as a one-time self-heal when upgrading past this commit (first revalidation rebuilds the class once and populates the index; every edit after that reconverts only what changed).

Verification

  • Unit test: indexed xn- entries prune iff their hash changed (dep-changed GLB path included), unknown xn- names are swept, verbatim names unaffected.
  • cargo test -p abgen --lib: live + abcdn suites green (the 15 gpu::wgpu_bc7 golden failures on this machine reproduce on unmodified main — pre-existing Metal divergence).
  • Live before/after on central-plaza is in flight on the consumer side (feat: serve asset bundles in preview through an abgen sidecar js-sdk-toolchain#1498 hot-reload testing) — before: 1,935 cache writes per one-file edit; expected after: the edited file's bundle + manifest + bookkeeping.

Every content change swept the entire xn- class — names over the
storage cap can't be parsed back to their source hash, so they were
over-invalidated wholesale. On a preview scene whose path-based ids sit
near the cap that meant reconverting half the corpus (1186 of ~2000
entries) for a one-file edit, turning hot reload into a near-full
rebuild.

The corpus build now records collapsed-name → source-hash in a names
index next to the digest record, and prune resolves xn- entries through
it, falling back to the old sweep only for names the index does not
know (true orphans, and one final sweep when upgrading past this
commit).
@dalkia
dalkia merged commit 5b2ecfc into main Jul 23, 2026
2 checks passed
@eordano
eordano deleted the fix/precise-xn-prune branch July 24, 2026 05:20
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