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
- New unit R1b, feed and sync: the hard part, keeping every Roll up current. It is its own L unit on the critical path.
- R5 reads the feed instead of querying across Contexts live, so scrolling costs the same at any size.
- Roll up tags are an aggregate of their Contexts' tags. The
rollup_tagtable is gone from R1. - Patterns are recomputed: one full set per run, and they rerun only when the feed's watermark moves.
- Sort order decided later: v1 sorts by priority then age. A different ranking later is a job that rewrites the sort column.
Units
| # | Unit | Files | Size | Owner | Depends on |
|---|---|---|---|---|---|
| R0 | Design 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. | ~6 | S | Rig A | none (blocks UI details in R7–R10, not R1) |
| R1 | Storage 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. | ~18 | L | Rig B | U1 |
| R1b | Feed 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. | ~20 | L | Rig B | R1 |
| R2 | Access. 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. | ~16 | L | Rig B | R1, U5 |
| R3 | Routes. 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. | ~16 | M | Rig C | R1, R2 |
| R4 | Sharing routes. Member CRUD, transfer, make private, hide for me, access preview, the switch, audit kinds, notices through U5's writer. | ~12 | M | Rig B | R2, U5, U1 |
| R5 | Item 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. | ~12 | M | Rig B | R1b, R2, R3 |
| R6 | Patterns 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. | ~20 | L | Rig B | U8, R1b, R3 |
| R7 | UI 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. | ~20 | L | Rig B, then Rig C parity slice | R3, R5, U6, R0 |
| R8 | UI 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. | ~14 | M | Rig C | R4, U5 UI, U3, R7 |
| R9 | Patterns UI. Card on Summary and beside each tab, all job states, feedback buttons, /ws subscription. | ~10 | M | Rig C | R6, R7 |
| R10 | Parity and docs. Parity scenes, functional rows, ledger rows, intended deviations, feature docs, roadmap. | ~14 | M | Rig C | R7–R9 |
Order
- Now: R0 and R1.
- After R1: R1b and R2 together.
- After R2: R3 and R4. R6 also starts once U8 lands.
- After R1b, R2 and R3: R5.
- Then: R7.
- Then: R8 and R9 together.
- 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
- R3: deletes
/context-tag, and the Python edge hop for the new route prefixes. - R5: deletes the client-side hiding of chosen rows.
- R7: deletes the Contexts list call that
directoryreplaces. - R10: deletes the "Not built" ledger rows for the Roll up screens.
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
| Q | Question | Recommendation |
|---|---|---|
| Q1 | One list for Contexts and Roll ups: a new /directory, or kind on /context | /directory |
| Q2 | Who sees Roll up Patterns | Everyone who can read the Roll up |
| Q3 | Does the switch also open Contexts to AI tools | Yes, through the same rule |
| Q4 | What an Editor can do | Share and add Contexts; Owner-only for rename, the switch, private and delete |
| Q5 | Items raised in two Contexts: show as two rows, or one row with "+N" | Two rows in v1 |
| Q6 | "Suggested" Contexts in Add Contexts | Later |
| Q8 | The reference for Pattern copy | The design's sample patterns |
| Q9 | Paid-plan gate | Ship ungated; gating comes with billing |