The system. A collaborative project tracker: organisations with users and roles; projects containing tasks with parent, child and dependency relationships; comments and attachments; a full activity stream; full-text search across tasks and comments; and live updates so that a change one user makes appears on every other viewer's screen without a refresh. Multi-tenant, with users in one organisation unable to see any other's data.
This is a good capstone for this engine specifically because it uses all three models for the reasons they exist: tasks and comments are documents, dependencies and memberships are graph edges carrying their own data, and the collaborative requirement is what live queries are for. A tracker built this way on a conventional stack is a database, a search index, a message bus and a websocket layer; here it is one engine, and demonstrating that honestly - including where it falls short - is the point.
Three invariants must hold:
- Tenant isolation holds for every access path, verified by a denial suite in CI covering every table, every edge table, search results, live query notifications and vector similarity results - and the service must connect as a record user, proven by a test.
- Every live-query client converges with the database, including across a dropped connection with concurrent mutations, verified by a reconciliation check that diffs client state against the database after a deliberate interruption.
- The system is rebuildable within a stated RTO, from a durable source of record, verified by a timed drill ending in the full verification suite - counts, dangling links, edge endpoints, constraints and permissions.
Invariant 2 is this capstone's distinguishing requirement. Live queries make a realtime collaborative application genuinely straightforward to build and the subscription is lost with the connection, with no replay - so a client that does not resubscribe and refetch shows stale data to some users some of the time, with nothing reporting it. A capstone that has not deliberately killed the connection mid-stream and then diffed the client against the database has not demonstrated invariant 2 - it has demonstrated that live queries work when nothing goes wrong.
What is assessed. 20% knowledge checks, 35% laboratory portfolio, 15% troubleshooting practical, 30% capstone. Three things carry the capstone.
The tenant denial suite, in CI, covering the paths people forget. Not "permissions are configured" - a test per denial, including the four that are easy to miss: search results, live query notifications, vector similarity results, and traversals that arrive at another tenant's records through an edge. Plus the test that fails if the service's connection is a system user.
Live query convergence under interruption, demonstrated. The four-part client pattern, the deliberate interruption with concurrent mutations, and the diff showing convergence. Include the before version that diverged, because the contrast is the evidence.
A timed rebuild and the version behaviour log. The measured rebuild RTO against a stated target, and the version behaviour log maintained from Module 1 onward - which is what makes the upgrade a half-day rehearsal rather than an adventure, and what demonstrates you understood the central fact about this engine.
Deliverables: architecture diagram showing what one engine replaced; the data model with every link-against-edge decision justified by the rule; schema definitions with assertions and permissions; source code including the four-part live query client, the traversal limits and the tenant key handling; the dataset generator; benchmark report with versions recorded; security review including the tenant denial suite and the root-connection test; recovery runbook with the measured rebuild time; the version behaviour log; and a short design defence that states honestly where a conventional stack would have been the better choice.
-- ================= Invariants, as runnable checks ==================
-- 1. *** TENANT ISOLATION HOLDS FOR EVERY ACCESS PATH. *** Not
-- "permissions are configured" - A TEST PER DENIAL, IN CI.
--
-- as a record user in org:acme, every one of these must be
-- EMPTY or DENIED:
SELECT count() FROM task WHERE org != $auth.org GROUP ALL; -- 0
SELECT count() FROM project WHERE org != $auth.org GROUP ALL; -- 0
SELECT count() FROM comment WHERE org != $auth.org GROUP ALL; -- 0
SELECT count() FROM user WHERE org != $auth.org GROUP ALL; -- 0
-- *** THE EDGE TABLES TOO - they are records, and they are the
-- *** path people forget: ***
SELECT count() FROM assigned WHERE out.org != $auth.org GROUP ALL; -- 0
SELECT count() FROM depends_on WHERE out.org != $auth.org GROUP ALL; -- 0
SELECT count() FROM member_of WHERE out.org != $auth.org GROUP ALL; -- 0
-- *** AND THE FOUR THAT ARE EASY TO MISS: ***
-- (a) SEARCH RESULTS:
SELECT id, title, org FROM task
WHERE title @1@ "ingest" ORDER BY search::score(1) DESC LIMIT 50;
-- -> *** EVERY ROW org = $auth.org. *** A search index that
-- returns another tenant's title is a leak even if the
-- record body is withheld - the TITLE IS THE DATA.
-- (b) VECTOR SIMILARITY RESULTS:
SELECT id, title, org FROM task
WHERE embedding <|10,40|> $qv ORDER BY vector::distance::knn();
-- -> *** EVERY ROW org = $auth.org. *** Test with a query
-- vector built from ANOTHER TENANT'S text, which is the
-- case that finds the bug.
-- (c) TRAVERSALS ARRIVING AT ANOTHER TENANT THROUGH AN EDGE:
SELECT ->depends_on->task.org AS orgs FROM task WHERE org = $auth.org;
-- -> *** every value = $auth.org. *** An edge created across
-- tenants is a bridge, and a traversal will cross it.
-- (d) LIVE QUERY NOTIFICATIONS:
-- LIVE SELECT * FROM task;
-- -> mutate another tenant's task and assert *** NO
-- NOTIFICATION ARRIVES. *** The one nobody tests, and the
-- one that leaks continuously once it is wrong.
-- *** AND THE SERVICE MUST CONNECT AS A RECORD USER: ***
-- a test that FAILS if the connection's identity is a system
-- user. Without it, every check above passes for the wrong
-- reason - because root bypasses them all.
-- 2. *** EVERY LIVE-QUERY CLIENT CONVERGES WITH THE DATABASE,
-- *** INCLUDING ACROSS A DROPPED CONNECTION WITH CONCURRENT
-- *** MUTATIONS. THIS CAPSTONE'S DISTINGUISHING REQUIREMENT. ***
--
-- THE DRILL:
-- 1. client subscribes, then fetches (IN THAT ORDER)
-- 2. drive 10,000 concurrent mutations
-- 3. *** KILL THE WEBSOCKET MID-STREAM. MUTATIONS CONTINUE. ***
-- 4. reconnect after 30 s; resubscribe AND REFETCH
-- 5. *** DIFF CLIENT STATE AGAINST THE DATABASE: ***
SELECT id, state, version, updated FROM task
WHERE project = $p ORDER BY id;
-- -> compare field by field with the client's store.
-- *** EXPECTED: IDENTICAL. ***
--
-- *** AND KEEP THE BEFORE VERSION THAT DIVERGED, because the
-- *** CONTRAST IS THE EVIDENCE: ***
-- naive client: *** 1,847 of 24,000 records stale. No error
-- anywhere. ***
-- four-part client: 0 stale.
--
-- *** A CAPSTONE THAT HAS NOT DELIBERATELY KILLED THE CONNECTION
-- *** MID-STREAM AND THEN DIFFED HAS NOT DEMONSTRATED THIS *** -
-- it has demonstrated that live queries work WHEN NOTHING GOES
-- WRONG.
-- 3. *** THE SYSTEM IS REBUILDABLE WITHIN A STATED RTO. ***
-- After the timed drill, the FULL verification suite:
SELECT count() FROM task GROUP ALL; -- vs the source of record
SELECT id FROM task WHERE assignee != NONE AND assignee.id = NONE; -- 0
SELECT id FROM depends_on WHERE in.id = NONE OR out.id = NONE; -- 0
SELECT state, count() FROM task GROUP BY state; -- all in the ASSERT set
INFO FOR TABLE task; -- permissions CAME BACK
-- then *** RE-RUN THE WHOLE DENIAL SUITE *** - permissions are
-- schema, and a restore that silently dropped a PERMISSIONS
-- clause is a TENANCY BREACH, not a restore defect.
-- ================= Declare the baseline BEFORE measuring ==========
--
-- *** VERSION: ______ (recorded with EVERY number below) ***
-- Backend: file-backed single node; *** and what that commits
-- us to: no PITR, backup = export + snapshot,
-- rebuild is the recovery path ***
-- Tenancy: one database + org key + record permissions
-- (many small tenants) *** with the denial suite in
-- CI *** - or a namespace each, stated either way
-- Model: LINKS task.assignee, task.project, comment.author
-- EDGES assigned (who, when), depends_on (kind),
-- member_of (role, since)
-- *** each justified by the rule: would we ever ask a
-- *** question about the relationship itself? ***
-- Schema: SCHEMAFULL on user, project, task, membership,
-- comment; FLEXIBLE object for integration payloads
-- org set by VALUE $auth.org READONLY
-- Search: BM25 on task.title and comment.body, snowball
-- English *** - assessed on 20 real queries and
-- judged sufficient / insufficient, stated ***
-- Vectors: HNSW 768-d cosine, *** recall@10 measured against
-- brute force: ______ ***
-- Traversal: *** depth limit 3, enforced in the service ***,
-- filtered at every hop
-- Live: four-part client; subscriptions closed on unmount;
-- live query count alerted
-- Recovery: event log as the source of record; export daily;
-- snapshot hourly
--
-- Claim:
-- task list, one project, filtered p99 < 25 ms
-- a user's tasks across projects p99 < 40 ms
-- dependency chain, depth 3, filtered p99 < 120 ms
-- full-text search, scored p99 < 60 ms
-- vector similarity, filtered, k=10 p99 < 35 ms
-- write throughput, events active > 10,000/s
-- live notification latency p99 < 150 ms
-- tenant leakage, ALL paths = 0, tested in CI
-- client divergence after interruption = 0, drilled
-- *** rebuild RTO, MEASURED ______ h ***
-- RPO = the event log's
--
-- *** AND THE VERSION BEHAVIOUR LOG, maintained from Module 1: ***
-- UPDATE CONTENT semantics ______
-- transaction rollback on failure ______
-- duplicate CREATE behaviour ______
-- index use for equality filters ______
-- unbounded traversal behaviour ______
-- ... plus every entry added since.
-- *** THAT LOG IS WHAT MAKES THE UPGRADE A HALF-DAY REHEARSAL
-- *** RATHER THAN AN ADVENTURE, AND IT IS HOW YOU DEMONSTRATE YOU
-- *** UNDERSTOOD THE CENTRAL FACT ABOUT THIS ENGINE. ***
-- ================= Failure modes ==================================
-- *** a dropped websocket THE SUBSCRIPTION IS GONE AND
-- EVENTS ARE NOT REPLAYED.
-- Clients show stale data.
-- Invariant 2. ***
-- subscribing AFTER fetching a lost event in the gap.
-- *** the service connecting as EVERY PERMISSION BYPASSED, and
-- a system user every denial test passes for
-- the wrong reason. ***
-- *** a leak through search, the four paths nobody tests.
-- vectors, a cross-tenant Invariant 1. ***
-- edge, or live notifications
-- a client-supplied tenant key not a tenant key. VALUE it.
-- UPDATE ... CONTENT silently replaces the record.
-- a typo on a schemaless table a new field; the query misses
-- the record. No error.
-- an unbounded traversal an availability incident.
-- a permission clause with a that subquery on every row of
-- subquery every query. Measure it.
-- an event writing to a table recursion.
-- with its own event
-- live subscriptions not closed server-side accumulation until
-- on unmount something breaks.
-- a metric mismatch on the plausible, wrong neighbours.
-- vector index Nothing errors.
-- an export taken under load an inconsistent snapshot;
-- dangling links on import.
-- *** a major upgrade attempted the on-disk format may not be
-- in place compatible. EXPORT, STAND UP
-- SEPARATELY, IMPORT, RUN ALL
-- FOUR ARTEFACTS. ***
-- trusting documentation over *** the engine is right. Test
-- the engine it, log it, date it. ***
--
-- Verify after every recovery with the three invariants - counts,
-- links, edges, constraints and the whole denial suite. A rebuilt
-- database with the right record counts and broken links looks
-- exactly like a correct one.
--
-- *** AND THE DESIGN DEFENCE MUST SAY HONESTLY WHERE A CONVENTIONAL
-- *** STACK WOULD HAVE BEEN THE BETTER CHOICE. *** A capstone that
-- finds nothing has not looked.
Discussion
No questions on this topic yet. Sign in to ask the first one.