Files
patriothacks/DEMO.md
T

12 KiB

DEMO

A judge's or first-time visitor's guide to THE COMMONS: what it is, how it works, how to run it, and how to put it through its paces live. For the full architecture, the 15-problem mapping, and build/scope boundaries, see README.md; this file is the hands-on companion.

What this is

THE COMMONS is a mobile-first super-app for one shelter in "the Hollow" - the fictional underground civilization of two billion people, per the hackathon's "Life Underground" scenario, carved into old mines and subway tunnels and stacked across levels. This single shelter (seeded with a population of 4,200 - a plausible size for one neighborhood/level of the much larger Hollow, never a claim about the whole civilization) has lost every normal civic institution at once: no power grid dashboard, no water-safety office, no housing authority, no way to vote on anything as a group. Instead of building 13 disconnected point-solutions for 13 disconnected problems, this is one app, one login, one wallet, with 13 mini-apps mounted under a single Alipay/WeChat-style launcher, all reading and writing the same record of what happened. A resident reports a bad water reading once; that report can change their water ration the same session, through the same identity, without ever touching a second system. There's no backend and no server-held state: every mini-app is a window onto the same local data, computed fresh every time it's viewed.

How it works

Everything starts with one Ed25519 keypair generated on the device and never leaving it; that's the resident's identity. Every action a resident takes, reporting a reading, casting a vote, requesting a resource, posting a testimony, gets written as one signed entry in a single append-only event log (nothing is ever edited or deleted, only added to). The wallet balance isn't a stored number anywhere; it's recomputed by replaying that log's wallet.issue/wallet.transfer entries from scratch every time it's shown, the same way every other derived value in the app works (a CEEI resource allocation, a vote tally, a trend line). All 13 mini-apps sit on top of this shared log and shared identity: a Water Watch reading can feed Fair Share's allocation, a Fair Draw commit-reveal result can resolve a tie in The Climb, because they're all just different reducers over the one log, not separate silos.

How to run it yourself

Check the README's "Live demo" section first: https://first-place-overhaul-todo6.vercel.app is a permanent vercel --prod production deployment, not a temporary preview, so it stays live and doesn't expire. It's a static frontend only (no backend behind it), so it works for a live demo but won't exercise cross-device sync. The reliable path, and the one that exercises everything including the backend-dependent flows, is still local:

npm install
npm run dev      # Vite dev server at http://localhost:5173

A fresh install has no demo data. The first time the Event Log is genuinely empty, the shell auto-seeds the Hollow demo fixture the moment you load any route, no manual step required: visit http://localhost:5173/ and the wallet card and the 13 mini-app tiles are already populated with real signed seed.* events by the time the home grid renders. You don't need to visit /admin first.

/admin still exists if you want to drive seeding manually, for example to re-seed after clearing IndexedDB or to inspect what the fixture wrote:

  1. Open http://localhost:5173/admin.
  2. Under the "Load Hollow demo" heading (marked with a gray Demo data badge), click the Load Hollow demo button.
  3. Wait for the status line under the button to read "Demo data loaded into the Event Log." (clicking it again is safe; a second click reports "Demo data already loaded - no new events appended." instead of duplicating anything).
  4. Navigate to http://localhost:5173/ (the home grid) to see it reflected.

How to demonstrate it

The two walkthroughs below are the mandatory beats from the project's own recorded demo (see "Fallback: the recorded video" below if you can't run a live demo). Every button name, field label, and route path here was checked against the actual component source, not guessed.

1. The honesty-anchor chain (Water Watch -> corroboration -> Fair Share re-solve)

This is the single proof that a real, typed civic action moves a real number elsewhere in the app, with zero mocked steps.

  1. From the home grid, tap the Water Watch tile (/miniapp/water-watch).
  2. In the Report a water reading form at the top, leave Channel on its default (pH), type sensor-A into Device / sensor ID, type 7 into Reading value, and click Submit reading. This is a baseline reading from sensor A; the status line below the form will read "Recorded - awaiting a second corroborating report."
  3. Still with sensor-A, submit a spike: type sensor-A again, type 50 into Reading value, click Submit reading. Watch the pH channel card's status light turn to Corroborating (it cannot go further on one sensor alone; a resident resubmitting under the same device ID can never self-corroborate their own alert).
  4. Switch the sensor ID: type sensor-B, type 7, submit (sensor B's own baseline).
  5. Submit sensor B's spike: type sensor-B, type 55, submit. The status light should now flip to Alert - this is the real multi-sensor corroboration gate firing, not a cosmetic color change.
  6. Navigate back to the home grid and open the Fair Share tile (/miniapp/fair-share). Point out the Water resource tile's bar and allocation figure: it has been re-solved by the real CEEI allocator because the corroborated alert fed a new water number into the engine, with no page refresh or manual trigger needed.

2. The Assembly partition-and-heal demo (two devices, genuine network split, converge on reconnect)

This proves the Assembly mini-app's CRDT sync survives a real network partition rather than faking a pause. It runs through a small browser harness at demo/assembly-sync.html, the same harness the project's own automated partition test drives; the shipped Assembly mini-app tile itself only syncs locally (via IndexedDB) in production, so the live cross-device transport is specifically this harness, not the mini-app route.

Setup (two terminals, in addition to npm run dev already running):

node node_modules/y-webrtc/bin/server.js   # local signaling server, defaults to ws://localhost:4444

Then open two separate browser windows, both at http://localhost:5173/demo/assembly-sync.html, and open the DevTools console in each.

  1. In both windows' consoles, run the same command (same room name in both, pointed at the local signaling server you just started):
    window.commons.init({ room: "demo-room", signaling: ["ws://localhost:4444"] })
    
  2. Wait for the page's own #status line in both windows to show peers=1 (or check manually with window.commons.peerCount()) - this proves the two windows found each other over real WebRTC.
  3. Prove the live link works before claiming anything about a partition: in window A's console, run window.commons.vote("prop", "warmup-voter", "yes"). Confirm window B's #tally text (or window.commons.voteCount()) now shows that vote arrived.
  4. Partition both sides for real. In each window's console, run window.commons.setConnected(false). (This is what actually tears the established WebRTC data channel; toggling the browser's network-offline throttle alone does not, on loopback, since the project's own partition test found host candidates bypass that emulation.) Confirm window.commons.peerCount() reads 0 in both windows.
  5. With both sides genuinely cut off, cast one independent vote on each: in window A, window.commons.vote("prop", "bob", "yes"); in window B, window.commons.vote("prop", "carol", "no"). Show the audience that window.commons.tally("prop") differs between the two windows right now - that's the proof the partition is real, not cosmetic.
  6. Heal the connection: run window.commons.setConnected(true) in both windows' consoles.
  7. Watch window.commons.tally("prop") (or the page's own #tally text) converge to the identical value in both windows within a few seconds: {"yes":2,"no":1,"abstain":0,"total":3} (the warm-up vote plus bob's and carol's independent votes, merged by the CRDT with no data lost and no crash).

3. A quick tour of the rest (breadth, ~30 seconds each)

To show the remaining mini-apps are real, built screens and not "coming soon" placeholders, pick two or three more tiles from the home grid, for example:

  • Fair Draw (/miniapp/fair-draw) - run a real commit-reveal draw: the commit hash is published first, then the "Verified" badge and a replay-derived "Draw integrity: valid" badge appear only after a genuine verify()/validateReveal() over the signed log returns true (a duplicate reveal would flip the integrity badge to "rejected").
  • Assembly (/miniapp/assembly) - the demo-seeded proposal already shows a live quadratic-vote tally (Yes 6.00) computed from real signed ballots; self-enroll by adding yourself to the roster, then cast a weighted QV ballot and watch the single vote control move the tally (there is one control, not two, and delegation is one global card with a Revoke button).
  • Wallet (home card) - Send credits to another resident by account id; the ledger rejects an over-spend past your credit limit, so the mutual-credit economy is a real spend path, not just a mint.
  • Fair Share (/miniapp/fair-share) - report your own need for a resource and watch the CEEI allocation re-solve live.
  • Health Post (/miniapp/health-post) - report several diarrhea symptoms; once they cluster, a one-click action offers to raise the Fair Share water floor (a real Health -> Fair Share interop for oral rehydration).
  • Housing (/miniapp/housing) - run the assignment cycle twice; the fairness-debt ledger rotates the contested slot to whoever lost it last time (credit is granted once per real placement, never per click).
  • Tunnel Safety (/miniapp/tunnel-safety) - a hazard reads "Confirmed by 2 residents" only when two distinct signers report the same segment; routing avoids confirmed hazards.

Fallback: the recorded video

If a live demo isn't possible, .omo/evidence/full-feature-demo/the-commons-hollow-full-demo.mp4 is a mechanically recorded (Playwright-driven, not hand-edited) walkthrough with real on-screen captions and a motion-graphics pass (synthetic cursor + auto-zoom derived from the real Playwright trace, not hand-keyed). It drives the REAL shipped UI of every mini-app plus the wallet, admin seed, and the upload-a-mini-app flow in one continuous tour (Scene 1), then a genuine two-device WebRTC partition-and-heal (Scene 2).

It reflects the current hardened app, including: the Water Watch corroboration gate -> Fair Share water re-solve; Farms' real forecast feeding Fair Share's food tile; Housing's fairness-debt cycle; the Mentor apprentice match; a full WHO-IMCI triage classifying "Needs treatment" and posting a real referral; Light Clock's honest sensor/manual-log fallback; Assembly's live QV tally (seeded Yes 6.00 plus a live self-enrolled Yes 3.00) with the collapsed single vote widget; Fair Draw's commit-before-reveal with the "Draw integrity: valid" badge and a live wallet credit; and the Assembly CRDT converging to an identical tally after the partition heals. Per-beat frame screenshots are in .omo/evidence/full-feature-demo/.

Regenerate it with bun e2e/demoVideoFull.e2e.mjs (use Bun, not node: Node's native TypeScript loader does not resolve this codebase's extensionless relative imports; Bun does).