Skip to content

feat(indexer): stop virtual crates at records, with stubs for linked records - #141

Merged
johnf merged 1 commit into
mainfrom
spec/139-one-level-virtual-crates
Nov 26, 2026
Merged

johnf merged 1 commit into
mainfrom
spec/139-one-level-virtual-crates

Conversation

@johnf

@johnf johnf commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #139

Summary

A virtual crate now shows everything the crate says about its entity, broken down at record boundaries: each linked record is a stub, and the walk stops there.

 virtualCrate(entity)
-  copy entity; ro-crate pulls in every linked entity, records included, transitively
+  root: the entity in full (adjustments unchanged: Dataset, conformsTo, license, display: false)
+  follow each link (not back to the entity, not to the descriptor), each entity held once:
+    record      → stub: @id, @type, name, description (+ filename for a file); not followed
+    otherwise   → its own properties; its links followed in turn
  • Each linked entity's form is built once per crate. The same stub or copy is reused in every virtual crate that holds it.
  • Inherited conformsTo is plain references. A record without its own conformsTo takes the crate root's as {"@id"} references. Before, these were live entities that dragged in the profile and everything it linked to.
  • Docs. ADR 0004's Decision and Consequences state the rule, and GLOSSARY.md updates Virtual crate and adds Stub. The README already says to run pnpm index --force when an upgrade changes what the indexes hold, so it is unchanged.
  • Tests. The seam is derive(), in src/indexer/derive.test.ts under "rule 15".

Evidence

derive() on the Australian Slang Survey Data crate (hdl10.26180~30102115, local copy of v3), before and after:

Before After
meta across 35 rows 3.4 GB 1.1 GB
Largest object row 98 MB 100 MB (#Item01-VeryGood: its participants and their postcode polygons)
Largest file row 98 MB under 0.01 MB (a stub of its object)
derive() time 45 s 0.3 s
rule 15: survey-shaped crate
  collection ─hasMember→ objects ─researchParticipant→ Persons (no row) ─homeLocation→ Place ─geo→ polygon
  object's virtual crate: collection stub, file stub, participants, postcodes, polygons
  file's virtual crate:   object stub only                     (before: the whole crate)

pnpm test: 517 passed, with 100% coverage of src/. pnpm lint (biome, knip, tsc) is clean.

Merge Danger

Door: two-way. Nothing in the repository or the schema changes, and reverting followed by pnpm index --force restores the old virtual crates.

Blast Radius: served metadata, and indexing memory.

  • Existing rows keep their old virtual crates until their crates are reindexed, so run pnpm index --force after deploying.
  • Indexing memory: holding all 35 Slang rows' meta as text locally takes the heap to 2.36 GB, which is above the worker's default heap of about 2.1 GB. The row writer batches 1,000 rows at a time, so all 35 go in one write, and the Slang crate may still run out of memory. Batching by size as well is the spec's out-of-scope "indexing memory" issue.
  • Oni's expanded panels (author, speaker, citation) show only a linked record's stub.

Follow-up

A stub's id is the deposited id, so a crate-relative one can't be fetched from the API. Whether to rewrite relative ids when building the virtual crate, or to reject them at import, is #142. The current leaning is to rewrite them.

Review findings not fixed

  • An inherited licence is served as a plain string, and the licence entity isn't included. This was already the case before this PR.
  • A linked entity whose deposited id equals the root's indexed id stops the root being renamed. It's an edge case.

…records (#139)

A virtual crate now holds its entity and everything it links to, directly or through entities that
aren't records, up to the records it reaches. Each linked record is a stub (@id, @type, name,
description, plus filename for a file), and what it links to is left out, so no record's
description is copied into another's metadata.

Before, the RO-Crate library followed every link, records included, so most rows held nearly their
whole crate. The Australian Slang Survey Data crate's 35 rows drop from 3.4 GB to 1.1 GB: its files
hold only a stub of their object, and its objects hold their participants with their postcode
polygons.
@johnf
johnf force-pushed the spec/139-one-level-virtual-crates branch from b8b644f to 3cba854 Compare November 25, 2026 23:09
@johnf johnf changed the title feat(indexer): bound virtual crates to one level, with stubs for linked records feat(indexer): stop virtual crates at records, with stubs for linked records Nov 25, 2026
@johnf
johnf merged commit b76b8b9 into main Nov 26, 2026
5 checks passed
@johnf
johnf deleted the spec/139-one-level-virtual-crates branch November 26, 2026 00:39
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.

Spec: stop virtual crates at records, with stubs for linked records

1 participant