Type-level check on row writes
Type-level roles answer one question: may this user create a row of this type (be-insert's only gate). An existing row carries its own roles, so operations on it must be decided solely by the row-role intersection — a role held by the user, sitting on the row, carrying the operation. be-delete already works this way (record-level check only). But be-update checks type-level update first (valid-user-permissions, backend.lisp ~3157 — the "backend standalone safety" comment) and be-action mirrors be-update exactly (type-level update + user-allowed-resource). That's the error: consulting the type resource for an existing row. Remove the type-level check from be-update and be-action so both are row-only, matching be-delete.
Consequences (deliberate, from the 2026-10-22 blog/comments discussion): a creator with create but no type-level update can now edit rows their exclusive role sits on — the creator-edit case. This is what makes creator-only comment editing declarable without a write-carrying ambient role riding every row. Base types are unchanged (user-allowed-resource already degenerates to the type resource when the row has no resources entry); the :tokens carve-out is unchanged (no rows exist). Check tests/update-permission-tests.lisp for expectations that pin the type gate.
Plan: type-level-check-on-row-writes-plan.org
Implemented per the plan end to end:
- Backend (
lisp/backend.lisp):be-update's unconditional type-levelvalid-user-permissionsdeleted; the check moved into theopaque-type-pbranch of theuuidbinding (:tokenshas no row resource, so the type resource is the only thing to consult — live-probed: admin update still works, a non-admin on:tokensgets the type-level error). Docstring gains the permission sentence.be-action's type-level call deleted, leaving the row-onlyuser-allowed-resourcegate; docstring's "TYPE-KEY or the record" clause narrowed to the record. - Docs:
hook-registry.md(runtime invocation step 2 now record-level only),model-reference.md(button placement permission;:type-rolessection gains the create/see-type vs row-roles split paragraph),rest.md(/api/updateand/api/actionseach state the row-resource requirement). - Tests:
tests/update-permission-tests.lispunchanged — all six tests pass against the new gate (none asserted the type-level error string;be-update-peer-deniedis exactly the type-update-but-no-row-role case). New fixturemodels/test/row-write-test.lisp(new-roles (:notes-user ("create" "read"))— the split itself;:test-syncbutton reuses theaction-testsregistry). New suitetests/row-write-tests.lisp(16 checks: creator edits own row with no type-level update, peer denied update + delete-skips-not-signals,be-actionboth ways, insert still type-gated, wire:updateflag stays:falsewith the Row-click-item note). Registered indata-ui.asd;run-row-write-testsadded torun-tests(loadsaction-tests.lispfirst, therun-agg-distinct-testsprecedent). - One test deviation from the plan:
be-deleteon a denied row skips silently rather than signaling, so the denial is asserted as row-survives (is-falsedelete + row still present), notsignals error. - Live probe on the new fixture: creator with
niltype-level update edits own row("v2"); same-role peer denied with the record message; wire flag:false;:tokenscarve-out intact both ways. - Full suite via
scripts/data-ui tests: 2205 checks, 43 groups, all passed. - Known gap kept (plan-noted): the wire
updateflag stays type-level, so a creator-edit user gets no Edit control — the Row click item owns that flag.
- Slot
- 3200
- Status
- 60 Done
- Tags
- backend, bug
- Contributors
- Donnie, Rose, Grok
- Plans
- Type-level check on row writes (3), Type-level check on row writes (2), Type-level check on row writes