Skip to content

feat(store): interval length and step, members-gated create, projected readers (#929) - #943

Merged
jimhoyd merged 3 commits into
mainfrom
claude/store-trial-929
Sep 29, 2026
Merged

jimhoyd merged 3 commits into
mainfrom
claude/store-trial-929

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #929

The three store requests from the scheduling/credits agent trial (#902 item 6), all declarative, no application code.

1. Fixed-length, aligned slots: intervals.length and intervals.step

intervals: {start: start, end: end, within: [room], when: {status: booked}, length: PT1H, step: PT1H}
  • length: end must be exactly start + length. step: both bounds must be whole multiples of step, counted from 1970-01-01T00:00:00Z (so PT1H = on the hour, UTC). Alone, step gives "a whole number of slots"; with both, activation requires length to be a multiple of step.
  • Date-time bounds take an ISO 8601 duration of whole days/hours/minutes/seconds (PT1H, PT30M, P1DT12H; no years, months or fractions). integer bounds take a positive integer. number bounds take neither, because a fraction has no exact multiple.
  • Enforced in the existing intervalIssues rule, so it runs on every write path: create, PUT, PATCH, transitions, StoreExports and host transactions. It answers 422 invalid_record with keyword intervals, and the message names the declaration, never the submitted value (must be exactly PT1H after start, must be a whole multiple of PT1H from 1970-01-01T00:00:00Z). Activation refuses stored records that break it.
  • Described in the config schema (oneOf duration pattern / positive integer) and in the OpenAPI 422. The authoring surface gains length/duration/hour/aligned goals, so plan-feature for "one-hour slots" finds it.

2. Members-gated create: create: {members: <membership collection>}

  • This reuses the admit() gate that transitions and transfers use. POST <mount> answers 401 principal_required when there is no principal (a shared collection included). Otherwise it answers 403 membership_required, and that check is the first statement of the write transaction, after the fence. It runs before the body is judged, before the retained Idempotency-Key is read and before any record is counted. So a non-member gets the same 403 whatever the body, and a removed member's retry is refused rather than replayed.
  • createIn checks the gate too, so StoreExports and host transactions pass it with the principal they are given.
  • It gates create only. Activation refuses it on a membership collection or a readOnly one, and refuses a members that doesn't name a membership collection. OpenAPI lists the 401/403 on the create operation.

3. Finding a transfer recipient without exposing balances: readers.properties

wallets:
  ...
  filterable: [name]
  readers: {mount: /api/directory, properties: [name]}   # GET /api/directory?name=bob -> {items: [{id, name}]}

Design. A projection on the existing readers mount. I chose it over a new "directory" mount type, or transfers addressed by owner or handle, for two reasons: it reuses one read path, gate and set of query rules, and it keeps transfers addressed by record id, so a transfer never resolves an owner inside its transaction. What makes the balance actually private:

  • Answer: only id, the listed properties and (with showOwner) _owner. createdAt and updatedAt are dropped too, because they reveal activity.
  • Sort and filter: only listed properties. Anything else is 400 invalid_query, even if the collection declares it sortable or filterable, because sort=-balance would rank every wallet.
  • may: lists only transitions whose from names only shown properties. A from on a hidden property would disclose its value.
  • ETag: the ETag and the etags entries are a hash of the projection, not the record's own ETag. The record's ETag moves on every write, including a transfer, and would tell every reader when a hidden balance moved. The docs state it is not usable as If-Match.
  • Members: with properties, members becomes optional. The route's principal is still required (401). That is what makes it a directory every signed-in user can search. A readers declaration with neither members nor properties is refused, so an ungated mount must list what it shows.

Documented as disclosed: the listed values, total, and which ids exist. Limitation: one readers mount per collection, so a collection can't have both a full reviewer view and a directory.

Constraints kept

Docs and artifacts

docs/STORE.md (membership section, intervals, transfers, ordering, OpenAPI, the not-covered table), docs/FRAMEWORK.md (the trial gaps are marked fixed), the store README, SECURITY, CHANGELOG and llms.txt, the root llms.txt and the regenerated llms-full.txt, store urlcode.json, artifacts/store-schema/schemas/config.json, EXTENSION-REFERENCE, and the authoring.ts surfaces.

Package budgets were raised. Store: 141531 packed / 548781 unpacked on Node 26, budgets 142 / 540 KiB. Core: 1010336 / 3979515, budgets 991 / 3891 KiB. Both leave +800 bytes for Node 24 and about 3 KiB of headroom.

Evidence

  • packages/store/test/trial-929.test.ts (8 tests) covers:
    • the trial's 08:00 to 20:00 booking and off-grid and misaligned slots, via POST, PATCH, PUT, a transition and a host transaction, plus the integer grid, activation over a stored violation, declaration refusals and the fingerprint;
    • the create gate over HTTP (owned and shared), a removed member's retry, StoreExports and a transaction, activation refusals and OpenAPI;
    • the directory: lookup by name, no balance, timestamps or status, refused hidden sort and filters, may filtering, an ETag that is stable across a transfer and changes on rename, 401 and 405, the gated projection with showOwner, and the OpenAPI projection.
  • The tests use no cross-connection timing (Windows-safe).
  • Locally: npm run verify green (core 1226 tests, store 194), and npm run test:package green.

Not verified: CI's Node 24 package sizes (estimated at +800 bytes) and Windows. CI passing is not a security review.

🤖 Generated with Claude Code

…d readers (#929)

- intervals.length fixes every slot's length and intervals.step puts both
  bounds on a grid (ISO 8601 durations for date-time bounds, counted from the
  epoch in UTC; positive integers for integer bounds). A write that breaks
  either is 422 invalid_record on every path; activation refuses stored
  records that break it and a length that is not a multiple of step.
- create: {members} admits only a membership collection's principals to
  create: 401 without a principal, 403 membership_required as the first
  statement of the write transaction (before the body, the Idempotency-Key
  or any record), on HTTP, StoreExports and host transactions.
- readers.properties makes a readers mount a projection: id and the listed
  properties only, sort and filters on those only, may limited to
  transitions over shown properties, and an ETag of the projection so a
  hidden balance moving is not observable. With properties, members is
  optional: a directory for finding a transfer recipient's record id
  without exposing any balance.

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.

Store requests from the scheduling/credits trial: fixed-length interval slots, members-gated create, recipient lookup for transfers

1 participant