Usage state
A top-level :usage key that stops usage logging for a model: popular sites grow the table without bound and pay a per-request write on the hot path, and prometheus/grafana already covers aggregate usage. :usage (:state :off) makes record-usage a no-op (no write, no dedup read); everything else stays — the table is never dropped, the tab remains, history freezes rather than vanishes (admin-only visibility unchanged). Absent key or (:state :on) means on. Unknown :state values are a compile error. Fully reversible by model edit + reload. Design settled in conversation with Donnie 2026-11-04; :state vocabulary chosen because the model language is moving off raw nil==/=t flags (separate future item).
Rider (same commit): the :ip field gains :sortable t — omitted in the usage-ip pass; text-column lexicographic sort is accepted (no IP-aware collation).
Plan: usage-state-plan.org.
Implemented per the plan, one deviation. model.lisp: :usage appended to *top-level-keys*; *usage-states* (defvar, the *valid-permissions* precedent) + valid-usage (plist whose only key is :state ∈ (:on :off); presence via u:plist-keys so (:state nil) signals rather than defaulting to :on; unknown keys signal; () and (:state :on) both legal; report-e, the valid-api-roles family); valid-top-level-field :usage case; model-usage-state (u:tree-get + (or … :on), the model-api-roles defaulting pattern) after model-api-roles; :ip field gains :sortable t (fresh DBs get ix_usage_usage_ip natively; existing tables do not, the usage_ip stop-at-present precedent — manual CREATE INDEX if wanted). backend.lisp: record-usage gates at the top, before the handler-case — (eq (model-usage-state) :off) returns nil before any work (no normalization bindings, no dedup read, no insert); docstring says the unknown-event report-e fires only when logging is on. Deviation: the plan's valid-top-level-field shape ((when (member :usage model) (valid-usage value))) cannot reject (:usage nil) — u:plistp nil is t (the legal empty plist), so valid-usage alone accepts present-nil. The case rejects nil-valued :usage explicitly with its own report-e ("omit the key entirely"), member-gated so an absent key still defaults. Tests: al-compile-field-flags :ip flipped to sortable; al-compile-wire extended (:ip :sortable reaches fe-fields, so the React column header appears on the next npm run build — none in this commit, no FE change); al-usage-state-validator (accept/reject matrix on valid-usage + end-to-end top-level-settings probes on th-al-usage-model, a complete legal skeleton with a :usage-p splice flag so present-nil stays present; also rejects (:usage nil) through the real entry point and pins the absent-key → :on accessor default); al-usage-state-off-stops-writes (rebind *top-level-settings* via shallow copy-list + setf, usage-recent-p stubbed to signal — the gate must not read — then writes resume after the binding restores). Docs: model-reference.md top-level-keys spelling + table row + the :usage paragraph gains :state prose and :ip "searchable and sortable". Full suite green (2842 checks, 50 groups).
- Slot
- 4600
- Status
- 60 Done
- Tags
- backend, model
- Contributors
- Donnie
- Plans
- Usage state — :usage (:state :off) plus :ip sortable