Skip to content

Prove the collection-narrowing idiom is gone and keep it gone #818

Description

@bencap

#812 removes the narrowing idiom from the collections router and #813 removes it from the score sets and experiment sets routers. This issue proves it is gone and keeps it gone.

Why it matters independently

Verified on PG 15.17 with SQLAlchemy 2.0.49: assigning a narrowed list to a delete-orphan collection deletes the rows you dropped. Rows hidden by RLS are safe — they were never in collection history — but rows the caller could see and chose not to display are destroyed at the next flush.

Collection.score_set_associations, Collection.experiment_associations, ScoreSet.score_calibrations, and ExperimentSet.experiments all carry cascade="all, delete-orphan". Nothing persists the staged deletes today because get_db never commits — an invariant that held by accident and had no test until test_narrowing_associations_does_not_delete_them.

Scope

  • Confirm no site assigns a filtered list to a mapped collection.
  • Confirm no site assigns None to a mapped scalar relationship for presentation (superseding_score_set), which lazy="raise" never blocked.
  • Add a check that fails if the idiom reappears. A test that greps the routers is crude but honest; an event-based assertion that no delete is staged during a read request is stronger.

Acceptance criteria

  • No presentation-driven assignment to a mapped collection or relationship anywhere in routers/ or lib/.
  • A check fails if one is reintroduced, with a comment explaining what it is protecting against.
  • test_narrowing_associations_does_not_delete_them still passes, and its docstring is updated to reflect that nothing is assigned rather than nothing being committed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    app: backendTask implementation touches the backend

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions