Data UI Backlog

:agg :distinct default on M2M list fields

Implemented per ~/workbench/todo-distinct-plan.org: strict compile rule in compile-field via valid-join-table-agg — on a field with :join-table, row-display :source :agg must be :distinct (omitted :agg is injected; :list and every other value report-e). :source-all untouched. Migrated *base-model* (users/resources/roles), demos (todos :tags, parts :files), fixtures (bi-m2m, compose, compose-sugar, m2m, rollup-test, static-select, test-model), and the filtered-rollup-tests inline award model. New tests/agg-distinct-tests.lisp suite (run-agg-distinct-tests) covers inject/reject/overreach compile probes plus the two-chain behavioral collapse; the backend aggregations test expectation moved to :distinct. Docs updated (model-reference, README, AGENT.md). Full suite green: 1461 checks, 24 groups. M2M list fields (:type :list + :join-table) have set semantics: one join row per (record, related-item) pair. But :agg :list is today's doc-default for the row-display :source, and on any view that joins two or more independent one-to-many chains (two M2M joiners, or an M2M plus a ratings chain), the flat LEFT JOIN view SQL yields the cross product of the chains. Every :agg :list value is then duplicated (each value appears once per sibling-chain row), even though the underlying join rows are correct. See model-reference.md → "Caution: two joiner chains in one view".

Chores :completed-by showed this live ("amanda" twice). Model audit <span class="timestamp-wrapper"><span class="timestamp">[2026-08-22 Sat]</span></span>: chores (:tags, :completed-by) and books (:authors) are fixed in the models; modelbank :images was already :agg :distinct; no other top-level model has a multi-chain view.

Decision needed: should the compiler default the row-display :agg to :distinct whenever :join-table is present (set semantics), keeping :list available for authors who truly want positional duplicates? Candidates:

Related trap, not fixed by :distinct: non-:list aggregates over a sibling chain can still be wrong. :avg / :sum / :count over the cross product double-count whenever the row's other-chain fan-out is non-uniform (book with 2 authors: each rating counted twice, and weighted 3x vs a 3-author book). books.lisp :average-rating has exactly this shape. MVP stance: accept for display, or restructure (rollup / Issue 16 subquery rules). Do not let :distinct on list fields hide this second cousin.

Plan: todo-distinct-plan.org.

Slot
26500
Status
60 Done
Tags
mvp, model, compiler
Contributors
Donnie