Data UI Backlog

Action log

A built-in :usage type an admin can list, so a demo answers "who did what today" without the journal. Append-only: :create nil :update nil :delete nil :display t, :type-roles ("admin"), written only by a backend helper that inserts as admin and swallows its own errors (no transactions — a log write must not fail the user's request). Fields: nullable :user FK, :user-name (search and sort; a failed login for an unknown name has no row to point at), :event, :on, :detail, and :when (the full timestamp as fixed-width text, so a search for 2026-11-02T10: is that hour). :created-at stays the real timestamp and is not overridden. List repeats of the same user + event + type + detail inside one minute collapse; login, view, insert, update, delete, and action always write. Guest counts. The helper does not log itself.

Plan: action-log-plan.org

Implemented per the plan. model.lisp: :usage in *base-model* after :tokens (built-in, not base, displayed, category :system via :built-in t, no add/update forms, :view-form (:fields t), :list-form naming :when :user :user-name :event :on :detail, :default-sort (:created-at :desc)); compile-field honors :on-delete :set-null in the references clause (this FK only; everything else stays cascade) and copies :on-delete onto the compiled field def via a new attrs entry — not author vocabulary, no validator. backend.lisp: *usage-events* (closed vocabulary), *usage-window-seconds* (60), *usage-detail-max* (80), usage-detail (trim, cap, downcase keywords, nil for blank), usage-recent-p (raw parameterized dedup read through a:rbac-query; column names from compiled :name-sql so the :on → on_type pin cannot desync; is not distinct from for NULL :on=/:detail with :null binds), usage-insert (the sanctioned writer: a:add-resource supplies the uuid, the compiled :insert-sql :main runs through insert-main-query for side effect only — id-from-data is bypassed so two identical events in the same second both land; update-roles attach mirrors insert-normal; a:remove-resource cleanup on post-resource failure), record-usage (the only public entry: normalize → vocabulary check → self-log guard → dedup → insert, all inside a handler-case that logs and returns nil), and :usage-specific append-only gates at the top of be-update / be-delete (:tokens's internal update path untouched). rest.lisp: seven call sites — rest-list (default dedup, :detail search), rest-item (form=view-form with a non-nil :record only, :dedup nil), rest-insert (inserted only), rest-update, rest-delete (a matched uuid only), rest-actions (failed results logged too; :detail field-key), rest-login (login-failed before abort-auth for a non-empty name; login after store-token; guest takes the success path). Tests: tests/action-log-tests.lisp (three suites — action-log-compile bare, action-log-suite on test-model, action-log-guest-suite on guest-allowed-test), run-action-log-tests in helpers.lisp registered in run-tests. Harness notes: handler tests call the easy-handler functions directly under a four-stub harness (require-auth / parse-posted-json / render-output / abort-request, the last signaling a custom al-aborted condition; rest-login stubs login-user-id instead); be-rec's cap decoration reaches h:*reply*, so the rest-item test binds one; th-al-with-rows snapshots the pre-existing usage ids and cleans up every row that appeared during the body (handler-written rows are never tracked by the writer); be-update :tokens coverage runs through store-token (the real internal path). Docs: model-reference.md Built-In Types table row + paragraph (event words, :when spelling and the hour-prefix search rule, 60s list dedup, on delete set null, e-demo reset destroys the table). Full suite green (2805 checks, 50 groups).

Slot
4500
Status
60 Done
Tags
mvp, backend, model
Contributors
Donnie
Plans
Action log