Skip to content

feat(form-records): new add-on saving a declared form into an owned store collection, with typed forms/store exports (#529) - #740

Merged
jimhoyd merged 5 commits into
mainfrom
claude/sleepy-shannon-xvazgl
Sep 25, 2026
Merged

jimhoyd merged 5 commits into
mainfrom
claude/sleepy-shannon-xvazgl

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

Closes #529. Owner decision: a separate, operator-installed add-on.

  • New workspace package @jimhoyd/urlcode-form-records (packages/form-records). It requires forms and store, and runs on Node only (targets: ['node']). It is released in lockstep with the other packages, per VERSION-ALIGNMENT, with v1 export contracts on both sides.
  • How it composes: it uses no private configuration from forms or store, only their typed exports through ctx.get:
    • forms FormsExports v1: define(name, body) returns a handle with render, submit, only(names) and confirmationPage, plus formFlowBodySchema. CSRF tokens gain an optional scope claim.
    • store StoreExports v1: records(name) returns create/get/update(principal, …). These go through the existing Collection methods, so maxRecords, maxRecordsPerOwner ([Request]: per-owner record limit for owned store collections #731), validation, ownership and ETags all apply.
    • Both exports have second-consumer fixtures (packages/forms/test/exports.test.ts, packages/store/test/records.test.ts).
  • Config: extensions.form-records.config.records.<name>: {mount, collection, form, fields?, editable?, editTitle?}.
    • The form is declared inline and validated by forms' own rules. A reference to a named forms flow would force forms to also serve it unsaved, and would make --example impossible (owner accepted).
    • Paths: <mount> (create, then 303), <mount>/<id> (confirmation) and <mount>/<id>/edit.
  • Security properties:
    • Owned collections only: activation refuses a shared or readOnly collection, or a mount without a principal-providing policy. No principal gets 401, and another user's record gives 404 everywhere.
    • Concurrency: the edit action carries the ETag, and a stale save gets a 412 page showing current values and nothing saved.
    • Editable fields: only editable fields are rendered and admitted. Any other submitted field gets 422, and saving is a partial update.
    • Forms handling: forms' admission, CSRF (scoped per page and record), the 64 KiB and 415 checks, and 422 errors apply unchanged.
  • Scaffold: a capability-only install adds no routes. --example adds an onboarding demo into the store example's owned todos collection, which needs auth.
  • Wiring:
  • Follow-ups already filed: [Request]: form-records follow-ups: clearing optional fields on edit, and a per-user list page #738 (clearing optional fields on edit, a per-user list page) and [Bug]: forms 422 for a field that is not on the page shows only "Correct the highlighted fields" #739 (a forms 422 message for fields that are not on the page). Both are being built next.

Verification

Run on Node v26.10.0:

Compatibility and security

  • Additive. A new package; forms and store gain exports only. The forms config schema bytes and forms' urlcode.json are unchanged.

  • Limitations (documented):

    • forms' onSubmit does not run for these forms.
    • The example depends on the store example's todos collection.
  • Not an independent security review.

  • Changes match the documented portable contract; docs/examples are updated where needed.

  • Relevant tests and package checks pass, or limitations are explained above.

  • No credentials, customer data or private project material are included.

  • Runtime/starter changes remain aligned where applicable.

🤖 Generated with Claude Code

https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP


Generated by Claude Code

forms' host() now returns FormsExports (contract version 1): define(name,
body) validates a flow body (the new formFlowBodySchema, a flow without a
mount) with the same rules as a declared flow, and the handle renders,
admits and confirms it on the consumer's own mount with forms' escaping,
same-origin admission, body bound, CSRF and 422 handling. CSRF tokens for
exported flows carry a scope, so a token for one consumer page is refused
on another and never admits a forms-served flow; only(names) narrows the
admitted fields for an edit page. Declared flows are unchanged.

The store's host() now returns StoreExports (contract version 1):
records(name) gives a declared collection's ownership, readOnly and
frozen fields, and create/get/partial update calls that take the request
principal and apply the JSON API's ownership scoping, validation, limits
and If-Match/412, failing with the same StoreError statuses.

Each export is proven with a synthetic consumer fixture (not form-records).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
…on (#529)

A separate, operator-installed extension that requires forms and store
and owns their composition. A record flow declares a form (a forms flow
body), an ownership: owner collection, the form-to-collection field map
and the editable fields. It serves <mount> (create), <mount>/<id> (a
confirmation read back from the saved record) and <mount>/<id>/edit (the
editable fields pre-filled, the rest read-only, saved as a partial update
with If-Match from the rendered version).

It reads neither forms' nor store's configuration: only FormsExports and
StoreExports through ctx.get. Activation refuses a shared or read-only
collection, a mount without a principal-providing policy, an unmapped or
mismatched field and forms or store declared after it. Another user's
record is 404, a stale edit is a 412 page with the current values, a
non-editable field is a 422, and forms' CSRF (scoped per page and record),
admission and 422 handling hold. Node only, like the store. The capability
install adds no route; --example (with auth) mounts a signed-in todo form
over the store example's todos collection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
… and docs (#529)

ci-plan selects form-records when ui, forms or store change and builds
ui, forms and store before it; package-audit gains its budget; the add-on
integration test expects its --example (/todo-form) beside the other
demos. EXTENSIONS, FRAMEWORK (now eight packages), README, llms.txt and
AGENTS.md name it; llms-full.txt is regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
CodeQL flagged /\/+$/ on the request path as a polynomial regex on
uncontrolled data. A single backwards scan replaces it; core already
refuses empty path segments first, and the add-on no longer relies on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
@jimhoyd
jimhoyd merged commit c002dfd into main Sep 25, 2026
24 checks passed
@jimhoyd
jimhoyd deleted the claude/sleepy-shannon-xvazgl branch September 25, 2026 11:33
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.

[Gap]: evaluate a composed durable form-record workflow for forms and store

3 participants