Skip to content

feat: readMany bulk read on VaultStore and Router - #44

Merged
vreshch merged 1 commit into
masterfrom
feature/read-many
Aug 22, 2026
Merged

feat: readMany bulk read on VaultStore and Router#44
vreshch merged 1 commit into
masterfrom
feature/read-many

Conversation

@vreshch

@vreshch vreshch commented Aug 22, 2026

Copy link
Copy Markdown
Member

Contract ADDITION (no behavior change to any existing verb): readMany(paths, opts?) on VaultStore and Router.

S-D item 1 of the simplification plan: the host's project/enrich paths read a whole folder page one doc at a time, so one REST default forks ~200 git processes. This gives them the bulk verb; the host fan-out is the consumer's follow-up.

Semantics - element-wise identical to read

  • same order, a null wherever read would answer null (missing doc, unsafe path)
  • a duplicated path repeats in place, it is not collapsed
  • same clamp, { clamp: false } included
  • infra failure still throws unavailable for the WHOLE call - no element is ever degraded to a null
  • Router: refs may span vaults (one store call per contributing vault), outputs tagged @vault/path as usual, permission-gated exactly like read - every ref is parsed and authorized before any container call, so one bad ref refuses the batch at zero IO

Implementations

  • bare-git: one cat-file --batch through the existing batchRead - warm budget 1 spawn, whatever N is. read and readMany now share one viewOf so they cannot drift.
  • memory store: the loop, which IS the reference semantics.

Conformance-first

New readMany block in the shipped contract suite - order/nulls, N-read equivalence, duplicates, clamp parity, empty request, unsafe paths, no mutation, and router parity. Both stores pass it unchanged.

ConformanceTarget gains an optional makeCounted (store + live round-trip counter), so the kit PROVES the budget instead of trusting the implementation: readMany(N) costs no more than a single read, and an empty request costs nothing. The security suite now fires the hostile-path corpus at readMany too, and the differential fuzz replays it against both stores.

Perf (harness, PERF_SCALE=1000)

New gate row - 200 docs out of a 1000-note vault:

metric measured budget
bare readMany 200 docs 18.3ms 150ms
bare readMany 200 vs 200x read (526ms), 20% ceiling 18.3ms 105ms

~29x, and 1 git process instead of 200. The second row is a ratio against a measured single read in the same run, so it stays honest on a slow runner.

Version

Minor-bump territory (1.1.0) - a consumer implementing VaultStore must add the verb. NOT bumped here; the coordinator owns the release.

Verify: type-check + lint + format + 249 tests + coverage + build + dist smoke green locally.

One `cat-file --batch` for N docs instead of N forks, with an answer that is
element-wise indistinguishable from the reads it replaces.

The conformance kit carries the guarantee: order, in-place nulls, duplicate
paths, clamp parity, no mutation, router tagging, and - via a new optional
round-trip counter on the target - the one-round-trip budget itself. Both
stores pass it, and the differential fuzz now replays readMany too.
@vreshch
vreshch marked this pull request as ready for review August 22, 2026 19:42
@vreshch
vreshch merged commit 05006de into master Aug 22, 2026
1 check passed
@vreshch
vreshch deleted the feature/read-many branch August 22, 2026 21:14
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