Skip to content

feat(store): editable/deletable states and unique values across owners (#952, #953) - #984

Merged
jimhoyd merged 2 commits into
mainfrom
claude/store-state-gates-952
Sep 29, 2026
Merged

jimhoyd merged 2 commits into
mainfrom
claude/store-state-gates-952

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #952
Fixes #953

From the third agent trial (#961).

#952: edit and delete states

readOnlyProperties: [status, reviewedBy, reviewedAt]
editable: {status: draft}                # PUT/PATCH only while a draft
deletable: {status: [draft, rejected]}   # DELETE only a draft or a rejected request
  • Same shape as a transition's from, but each property takes a value or a list of values. Each property must be in readOnlyProperties, so a body can't move a record into or out of a state. Each value is checked against its property's schema. Both keys are refused on membership and readOnly collections.
  • Outside the states, the store answers 409 record_locked and writes nothing. The check runs inside the write's BEGIN IMMEDIATE transaction, after the scope check (404) and If-Match (412). It covers HTTP PUT/PATCH/DELETE, StoreExports.update, and a host transaction's update/remove, which roll back the whole transaction.
  • Creates are unaffected, so title and amount can still be entered: that was the problem with readOnlyProperties. Transitions, increments, transfers and the operator's ownerless-delete are also unaffected.
  • Hints: record GET/HEAD and PUT/PATCH answers carry Allow with the methods the record accepts now. A collection-mount list carries allow: {<id>: [methods]} next to may.

#953: unique values across owners

  • unique: [handle] takes up to 4 string properties. Each must have maxLength at most 128, no default, not be readOnly, not be the key, and not be set by a transition.
  • Uniqueness covers every record, across owners on an owned collection; key stays refused there, and its message now points to unique.
  • A duplicate create, PUT or PATCH answers 409 value_taken. The one issue it returns names the property, never the value or who holds it.
  • The check runs under the write lock through a partial expression index (store_unique_*). Activation builds the index and drops it once no live declaration names it. The stale-index cleanup is now shared with intervals.
  • Activation refuses stored duplicates.
  • Privacy: the 409 is an existence oracle. This is documented in docs/STORE.md and SECURITY.md: use it for public handles only, never emails, constrain case with a pattern, and throttle the mount.

Also

  • OpenAPI adds record_locked (naming the states), value_taken, the Allow header and the list's allow.
  • Updated config schema (urlcode.json, store-schema artifact), authoring surfaces (editable, unique), README, docs/STORE.md, FRAMEWORK.md, CHANGELOG, SECURITY.md, llms.txt and llms-full.txt.
  • Package budgets raised (Node 26 measurements):
    • store: 151068 packed / 596265 unpacked
    • core: 1048732 packed / 4136079 unpacked

Evidence

  • New packages/store/test/state-gates.test.ts (8 tests), covering:
    • the trial's approval workflow over HTTP;
    • StoreExports and host-transaction rollback;
    • activation refusals;
    • a unique handle across owners, including PATCH/PUT;
    • four racing creates from separate connections: exactly one 201;
    • the index being built and dropped;
    • stored duplicates refused;
    • OpenAPI.
  • npm run verify passed except one timing flake: test/body-validation-limits.test.ts, a 50 ms ReDoS bound under load. That test passed in the first verify run and on 3 isolated reruns, and verify:workspaces was then rerun green.
  • npm run test:package passed.

Limitations: not an independent security review. Uniqueness is exact-match only, so look-alike handles are the author's pattern to prevent.

🤖 Generated with Claude Code

#952, #953)

editable and deletable, in the shape of a transition's from (a value or a
list per readOnly property), refuse PUT/PATCH and DELETE outside the named
states with 409 record_locked, under the write lock after If-Match, on HTTP,
StoreExports and host transactions. Creates, transitions, increments and
transfers are unaffected. Allow on a record and allow on a list are the hint.

unique: [prop] keeps a bounded string property unique across every record,
across owners on an owned collection, with 409 value_taken through a partial
expression index; activation refuses stored duplicates. Documented as an
existence oracle: public handles only.

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

1 participant