Skip to content

feat: neuroglancer view (1/6): data model — views + view_layers tables - #422

Draft
allison-truhlar wants to merge 7 commits into
mainfrom
ngviews-01-model
Draft

feat: neuroglancer view (1/6): data model — views + view_layers tables#422
allison-truhlar wants to merge 7 commits into
mainfrom
ngviews-01-model

Conversation

@allison-truhlar

Copy link
Copy Markdown
Collaborator

Neuroglancer Views — PR 1 of 6 (stacked)

Foundation of the Neuroglancer Views feature: a Neuroglancer View becomes a
first-class saved object (NG state + the datasets it shows + sharing settings).
This PR is the bottom of a 6-PR stack and is pure-additive — new tables,
models, and DB helpers only. No routes, no behavior change.

Design spec and plan (included in this PR):

  • docs/superpowers/specs/2026-08-07-neuroglancer-views-design.md
  • docs/superpowers/plans/2026-08-07-ngviews-01-model.md

(Scope note: this stack ships read-only Views; editable Views are a later
stack. edit_key is reserved in the schema now so that stack needs no second
migration.)

What's in this PR

  • views table (ViewDB): short_key, read_key, edit_key (reserved,
    unused), name, ng_state (JSON), sharing_mode (private|read),
    owner, timestamps.
  • view_layers table (ViewLayerDB): the many-to-many join between a View
    and a Data Link (proxied_paths). data_link_id is nullable and each row has
    a broken flag, so a future "mark broken" Data-Link deletion can null the
    link without deleting the View.
  • DB helpers (mirroring the existing neuroglancer_states helpers):
    create_view, get_view_by_short_key, get_view_by_read_key, get_views,
    update_view, delete_view (cascades to layers), and
    get_views_for_data_link (dependent-Views lookup, powers the delete guard and
    the "Appears in N Views" discovery in later PRs).
  • Pydantic models View / ViewLayer / ViewResponse. View deliberately
    does not expose edit_key.
  • Alembic migration 1e8dc304b4f2 creating both tables (FK-safe, reversible),
    chained off the current head e7b2a9c4f130.

Testing

pixi run -e test test-backend777 passed. New tests cover the
create/get/list/update round-trip, owner-scoping on update/delete, the cascade
delete (asserts join rows are removed), the get_views_for_data_link DISTINCT
path (two layers → one View), and the Pydantic from-ORM round-trip incl.
edit_key being absent.

Stack

  1. This PR — data model
  2. API (Views CRUD, /ngview/{key} read link, dependent-views endpoint, Data-Link delete modes)
  3. Multi-select in the file browser
  4. Views page (Saved Views + Layer Cart, replaces NG Links)
  5. Browser entry points (row menu, selection bar, cart rail/drawer, consent)
  6. Read-only embedded viewer

Design spec for the Neuroglancer Views feature, scoped to read-only
Views with editable Views deferred to a follow-up stack. Covers the
data model, API, frontend architecture, and a six-PR gh stack
breakdown. Distills the .scratch decision log, ADR-0001, and wireframes.
The design docs cited c1f9a4e7b2d8 as the current Alembic head; on main
that revision already has a child and the true sole head is e7b2a9c4f130.
Correct the spec and plan references and note that the head advances as
PRs merge, so it must be verified live before generating a migration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant