Skip to content

Store records as JSON Schema 2020-12; extensions describe their mounts for the OpenAPI export (#861, #881) - #900

Merged
jimhoyd merged 2 commits into
mainfrom
claude/store-json-schema
Sep 29, 2026
Merged

jimhoyd merged 2 commits into
mainfrom
claude/store-json-schema

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #861 item 1 (store half; forms is deleted) and #881 item 1.

1. Store records use core's JSON Schema profile

  • schema: replaces fields:. A collection declares a JSON Schema 2020-12 object schema in core's request-body profile. It is compiled by compileBodySchema, so the validator, formats, pattern guard and limits are the same as for request bodies.
  • Store restrictions: records are flat. That means type: object with 1–64 properties, additionalProperties: false written out, and exactly one scalar type per property.
  • Annotations the store acts on:
    • default is stored on create and PUT.
    • readOnly: true replaces transitionOnly. A required readOnly property needs a default.
  • Store-owned layer: key, increments, ownership, transitions, readers, membership, sortable and filterable stay store config and refer to property names.
  • Why a declared schema rather than one derived from fields:: both call the same compiler, but a declared schema removes the private vocabulary and is the one OpenAPI publishes. The rationale is in STORE.md.
  • Errors (breaking):
    • Record failures are now 422 invalid_record with issues in core's shape, replacing 400 fields.
    • Only the first failure is reported. Store-specific rules use the same shape.
    • List queries stay 400 invalid_query, but filter values are judged by the property schema.
  • Write semantics:
    • Writes are checked as the whole resulting record, so a PATCH that clears a required property fails.
    • Stored rows are checked without required, so adding a required property doesn't stop a collection that already has data.
  • Short links: the destination is a required format: uri property. The store still enforces HTTP(S) with no credentials.
  • Removed: checkValue, FieldSpec, FieldType and the store's private validators. No DB migration is needed.

2. Extension OpenAPI contributions

  • Hook: RuntimeExtension.describe?({mount, methods, config}) → {paths, schemas} returns data only. It is called only with urlcode openapi --host-file; without a host file no extension code runs and mounts stay opaque.
  • What core checks (the export fails and names the extension otherwise):
    • at most 64 paths, each at or under the mount and not already used by another route;
    • allowed path-item keys only;
    • at most 64 schemas, with the extension's name prefix;
    • $refs only to its own schemas or core Urlcode* components;
    • 256 KiB total.
  • What core adds: the runtime headers, the sign-in gate's security with 401/403, and throttle refusals.
  • Store implementation: collection, readers, by: others transition and short-link mounts, covering list (limit, cursor, sort, filters), CRUD, increment and transitions. Headers: If-Match, Idempotency-Key, ETag, Allow-Transitions, Location. Record schemas are generated per collection.
  • auth, audit and mcp stay opaque.

Migrated

Both private-requests proofs, the store-crud recipe, the --example scaffold, the bench, the store-schema artifact, the tests and the docs: STORE, EXTENSIONS #openapi-description, TOOLING, RIM-OPENAPI-001, EXTENSION-REFERENCE, AI-AUTHORING, FRAMEWORK, the skills, the store README/llms/SECURITY/CHANGELOG, and llms.

Evidence (macOS, Node 26): one full npm run verify after merging main

  • root 1163, audit 42, auth 5, mcp 42, store 136;
  • test:addons 6, test:proof 12, test:proof:authjs 13, test:ecosystem 12;
  • npm run test:package passes.
  • Store budget raised to 96/372 KiB (measured 95,170 / 371,009 bytes).

Limits

  • A plain urlcode openapi still lists store mounts as opaque; the store's description needs the host file.
  • Records can't use nested objects, arrays, $defs or type lists.
  • The describe hook exists on the runtime registration only, not in urlcode.json.

🤖 Generated with Claude Code

jimhoyd and others added 2 commits September 29, 2026 03:35
…penAPI contributions (#861, #881)

Store collections declare `schema:`, a JSON Schema 2020-12 object schema in
core's request body profile, compiled and run by core's body-schema compiler,
instead of the private `fields:` vocabulary. The store acts on the standard
`default` and `readOnly` (replacing transitionOnly) annotations; key,
increments, ownership, transitions, readers, membership, sortable and
filterable stay a store-owned layer naming properties. Record failures are
422 invalid_record with core's body-validation issues; filters are judged by
the property schema through the same validator. checkValue, FieldSpec and
format: http-url are removed (a short link destination is format: uri plus the
store's HTTP(S)-only write rule).

Extensions gain an optional, pure `describe()` on the registration: with a
host file loaded, the OpenAPI export turns a described mount into real paths,
checks the contribution (paths at or below the mount, prefixed schemas, local
refs, bounded size), keeps only declared methods, assigns operation ids and
adds runtime headers and sign-in gate responses. The store describes its
collection, readers, transition and short-link mounts from the record schema.
The OpenAPI validity and contract-run harness moves to test/openapi-contract.ts
and runs against a served store.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve conflicts with #896-#899: keep both store CHANGELOG entries, merge the
OpenAPI mounts text in docs/TOOLING.md, and keep #897's new operator-audit
test beside the renamed filter test. Re-measured the store package budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 08:49
@jimhoyd
jimhoyd merged commit 6ef1cac into main Sep 29, 2026
25 checks passed
@jimhoyd
jimhoyd deleted the claude/store-json-schema branch September 29, 2026 08:52
jimhoyd added a commit that referenced this pull request Sep 29, 2026
…together (#903)

Main's CI failed the package audit (954811 packed > 949248) because #900 and #901
each measured the core budget on their own branch.

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.

JSON Schema profile follow-ups: store/forms vocabularies, OpenAPI export, shared HTTP+MCP+form schema, formats, workerd CI

1 participant