Roll up: implementation plan

Revised 17 Nov 2026 after the database review. Design: Roll up database design. Nothing is built yet. R1–R10 ship together in one release (Patterns included).

What changed since the first plan

Units

#UnitFilesSizeOwnerDepends on
R0Design intake. Designer draws the undrawn states (sync "Updating…" / "Couldn't update", Patterns waiting/failed, Editor header). Operator answers the open questions. Design map rows updated.~6SRig Anone (blocks UI details in R7–R10, not R1)
R1Storage and owner crate. Migration for rollup, rollup_context and their logs and capture triggers, the enums, views rollup_list_v (tags aggregated from Contexts), rollup_context_v, directory_entry_v. New crate rollup-db with set-based writers (create, edit, add/remove Contexts, delete). Classification and write-path rows, RLS tests, boundary gate, purge hook for Context and workspace delete. changed no rollup_tag.~18LRig BU1
R1bFeed and sync (new, the hard part). Tables rollup_item (order only), rollup_feed_change (day-partitioned, same-transaction trigger on context_item and rollup_context), rollup_feed_state (watermark, lag, last error). Temporal workflow per tenant (signal-with-start, coalesced batches, one parallel activity per Roll up, set-based upsert/delete by re-reading source). Backfill on add with recorded sequence. Nightly reconciliation Schedule (expects 0 repairs, logs each), one-command rebuild via ./run job. Job rows and /ws push. Proof: burst of 2,000, mid-backfill change, worker killed mid-batch, duplicate delivery, corrupted row repaired once.~20LRig BR1
R2Access. rollup_member, rollup_member_log, rollup_hidden, rollup_context_passthrough_v. context-access gets Roll up decisions, the derived branch in the four Context read scopes (live check that the adder still owns/edits), via_rollup, access_via_rollup_id. Access matrix tests.~16LRig BR1, U5
R3Routes. directory (list, filter schema), rollup (list, create, get, patch, delete, delete-preview, Context list and batch add/remove). API docs, resource-name precedents, api.ts. Deletes /context-tag if no caller remains.~16MRig CR1, R2
R4Sharing routes. Member CRUD, transfer, make private, hide for me, access preview, the switch, audit kinds, notices through U5's writer.~12MRig BR2, U5, U1
R5Item list on the feed. GET …/rollup/{id}/item reads rollup_item joined to context_item: one index range scan per page, keyset cursor (rank_version, sort_key, id), counts per kind, filters through the filter engine, sync lag returned for the "Updating…" state. Default sort: priority then age (re-sortable later by a job). Proof: 100 low Contexts + 1 high (row 1), page 1 vs page 200 same time, 10k and 100k. changed no live cross-Context query.~12MRig BR1b, R2, R3
R6Patterns job. Crate rollup-pattern-db; rollup_pattern (one full set per run, stable key carries first detected), _item, _feedback, rollup_pattern_job (input version = feed watermark, so it reruns only on change). Workflow, seeded prompt row, routes for pattern list, refresh, feedback.~20LRig BU8, R1b, R3
R7UI core. Route, Roll up page, header (Owner/Viewer), tabs, item rows with the Context chip, infinite scroll on the cursor, "Updating…" / "List updated, refresh", Contexts tab, Add Contexts drawer, New menu, directory rows and Type filter.~20LRig B, then Rig C parity sliceR3, R5, U6, R0
R8UI sharing. Manage access for a Roll up (on U5's component), the switch and confirm, Make private, Delete dialog, Hide for me, Editor header, "Roll ups that include it" on a Context.~14MRig CR4, U5 UI, U3, R7
R9Patterns UI. Card on Summary and beside each tab, all job states, feedback buttons, /ws subscription.~10MRig CR6, R7
R10Parity and docs. Parity scenes, functional rows, ledger rows, intended deviations, feature docs, roadmap.~14MRig CR7–R9

Order

  1. Now: R0 and R1.
  2. After R1: R1b and R2 together.
  3. After R2: R3 and R4. R6 also starts once U8 lands.
  4. After R1b, R2 and R3: R5.
  5. Then: R7.
  6. Then: R8 and R9 together.
  7. Last: R10.

The critical path is R1 → R1b → R5 → R7 → R9 → R10. Contexts units it depends on: U1 role checks (Rig C, in flight), U3 delete and U5 sharing (Rig B, queued), U6 directory shell, and U8 Context Patterns (Rig B, queued).

Deletions each unit must make

Net new mechanisms

One resource (rollup), one read resource (directory), one feed with its sync workflow and nightly reconciliation, one Patterns job kind, and one access branch. There is no second item store: the feed holds order only. There is no second access owner and no polling.

Still open for you

QQuestionRecommendation
Q1One list for Contexts and Roll ups: a new /directory, or kind on /context/directory
Q2Who sees Roll up PatternsEveryone who can read the Roll up
Q3Does the switch also open Contexts to AI toolsYes, through the same rule
Q4What an Editor can doShare and add Contexts; Owner-only for rename, the switch, private and delete
Q5Items raised in two Contexts: show as two rows, or one row with "+N"Two rows in v1
Q6"Suggested" Contexts in Add ContextsLater
Q8The reference for Pattern copyThe design's sample patterns
Q9Paid-plan gateShip ungated; gating comes with billing