build(nix): fill in the real npmDepsHash, fix nodePackages.npm removal; flake validated end-to-end (nix build, nix flake check, module eval, live server from the real store output)

Also commits the full cross-device sync architecture re-evaluation across all 13 mini-apps (.omo/evidence/service-sync-reevaluation.md), which found 4 broken community features (Sky memory wall/morale, Health Post symptom tally, Assembly testimony) caused by the same local-only-sync root cause the user flagged.
This commit is contained in:
OmO Orchestrator committed 2026-11-20 17:08:13 -05:00
1 parent 8308878ec5
commit 725701c72d
3 files changed
+311 -9

No files matched your search

+241
View File
@@ -0,0 +1,241 @@
# THE COMMONS — Cross-Device Sync Re-evaluation (all 13 mini-apps)
**Type:** Advisory architecture review (read-only, no code changes)
**Date:** 2026-11-20
**Scope:** For every mini-app, does its *community-facing* value proposition
require cross-device data sharing, and does the current architecture actually
deliver that sharing — via (a) the generic relay push allowlist, (b) a
dedicated real-time channel, or (c) neither (a genuine gap)?
---
## 1. The lens, and why the Sky memory-wall concern generalizes
Every mini-app writes signed events to one **per-device** Event Log
(Dexie/IndexedDB) and derives all state by **local replay**. The *only* way
one resident's event reaches another resident's device is one of:
1. **The generic relay** (`/api/sync`, client helper `src/lib/sync.ts`) —
but it pushes **only** payload types whose first dot-segment matches
`PUSH_TYPE_ALLOWLIST`. Default-DENY: an unlisted type is **never** pushed.
2. **A mini-app's own dedicated WebRTC channel** — Assembly's Yjs CRDT
(`assemblySync.ts`), Find Family's PSI relay (`findFamilySync.ts`), Sky's
presence Awareness (`useSkyPresence.ts` → `connectAssemblySync`).
3. **Manual sneakernet** — testimony JSON copy/paste, or Assembly's QR
(`qrSneakernet.ts`, which carries **only Yjs CRDT deltas**).
If a community feature's payload is on none of these, then on the README's
stated deployment ("installable, **mobile-first**", one resident = one phone)
**each resident's view only ever contains events they themselves posted.**
A "wall" / "tally" / "mood gauge" that nobody else's device feeds is not a
community feature — it degenerates to a private journal. That is exactly the
Sky memory-wall defect, and the review confirms it recurs in **3 mini-apps /
4 features**.
### The current allowlist (`src/lib/sync.ts`)
```
wallet.issue, wallet.transfer,
seed, fairshare,
waterwatch.reading.report, tunnelsafety.hazard, theclimb.plan, housing,
governance.qvBallot, governance.proposal.enacted,
healthpost.referral, // (covers healthpost.referral.resolve)
mentor.skillReview, mentor.match,
theclimb.tiebreak,
fairdraw
```
Explicitly **excluded** (comment: "strictly local and NEVER pushed"):
`healthpost.symptomReport`, `sky.morale.*`, `sky.memoryWall.*`,
`lightclock.*`, `testimony.*`.
### Admin dashboard sees only what was pushed
`api/admin/aggregate.ts` calls `pullEvents(0)` on the relay's **own
server-side store** and runs `buildRelayAggregate` over it. The relay store
only ever contains events a **client pushed** — i.e. allowlisted types. So the
admin monitor is **blind to every non-allowlisted type**: it can never show
symptom tallies, Sky activity, or testimony, even in principle. This means the
broken features below are invisible to admin monitoring *as well as* to peer
devices — the same root cause, two blast radii.
---
## 2. Verdict table (all 13 mini-apps)
| Mini-app | Payload type(s) | README's claimed mechanism (quoted) | Actual sync status | VERDICT |
|---|---|---|---|---|
| **Fair Share** | `fairshare.need/floor/contribution/allocation.cycle`, `seed.*` | "CEEI allocator across power, water, food, and cooling; envy-free, Pareto-efficient, with a real allocation-history trend as the honest early-warning signal" | relay-allowlisted (`seed`, `fairshare`) | **Works as claimed** — cross-resident needs/contributions/floors replay identically on every device. |
| **Water Watch** | `waterwatch.reading.report` (writes `seed.resource.water`, `fairshare.allocation.cycle`) | "CUSUM/EWMA change-point detection over **corroborated resident water readings**, feeding Fair Share's water number" | relay-allowlisted (`waterwatch.reading.report`; the `seed`/`fairshare` it emits are also allowlisted) | **Works as claimed** — corroboration keys on `sensorId` in the synced reading; other residents' readings arrive via relay. |
| **Tunnel Safety** | `tunnelsafety.hazard.report`, `tunnelsafety.hazard.resolve` | "**Crowd-sourced hazard reports** plus A* routing around closed tunnel segments" | relay-allowlisted (`tunnelsafety.hazard` covers both via dot-segment) | **Works as claimed.** |
| **Housing** | `housing.space.report/preference/assignment` (+ `wallet.issue`) | "Constraint-based assignment engine … with a fairness-debt ledger carried across cycles" | relay-allowlisted (`housing`) | **Works as claimed.** |
| **Assembly — voting** | `governance.qvBallot`, `governance.proposal.enacted` (Event Log); proposals/roster (Yjs CRDT) | "Yjs CRDT for offline-first proposals/rosters/votes with liquid-democracy tally, a 3-layer resilience model (local-first, WebRTC partition-and-heal, QR-sneakernet)" | ballots/enactment = relay-allowlisted; proposals/roster = **dedicated WebRTC CRDT** (`assemblySync.ts`, opt-in + shared code) | **Works as claimed** — two independent cross-device paths; correct. |
| **Assembly — testimony** | `testimony.statement` (Event Log) | "a signed public testimony board **reusing the same event-log infrastructure** as group voting" | **NONE.** Not allowlisted; **not** in the Yjs CRDT (`qrSneakernet.ts` carries only Yjs deltas, never Event-Log entries); only a **manual JSON paste import** is wired (`importTestimonyStatement`) — the **export side is not wired into the UI** (`serializeTestimonyEntry` appears only in tests). | **BROKEN as claimed** on multi-device — see §3.4. |
| **Find Family** | PSI blinded points over WebRTC; directory = local `SEED_DIRECTORY` | "Private-set-intersection search so neither the relay nor the other party learns who searched unless there's a real match" | **dedicated WebRTC PSI channel** (`findFamilySync.ts`, opt-in "Search nearby devices"); default channel is **same-device** `createLocalDirectoryChannel(SEED_DIRECTORY)` | **Works as designed** (dedicated channel exists), with two caveats: cross-device requires opt-in + a shared room, and the directory is a **hardcoded seed fixture** — residents cannot register themselves, so a real PSI search matches only against seed entries. (Seed-directory limitation is a separate gap from the sync question.) |
| **Health Post — referral** | `healthpost.referral`, `healthpost.referral.resolve` | "WHO-IMCI protocol-guided triage chat …" (referral loop reaches a clinician on another device) | relay-allowlisted (`healthpost.referral`) | **Works as claimed** — deliberate consent-bearing handoff syncs. |
| **Health Post — symptom tally** | `healthpost.symptomReport` | "backed by **real crowd symptom self-reports aggregated into a dispatch-facing tally**" | **NONE** (deliberately excluded for privacy) | **BROKEN as claimed** on multi-device — see §3.3. Genuine privacy tension; needs an anonymized aggregation path, **not** a raw relay push. |
| **Light Clock** | `lightclock.*` (actigraphy/sleep log) | "a personal wellness tracker only, never wired to ration anything" | none (excluded) | **Correctly private — no sync needed.** The one feature with no community-facing claim; exclusion is right. |
| **Farms** | writes `fairshare.contribution`, `fairshare.allocation.cycle` | "GDD model plus an LP planting optimizer … **feeding Fair Share's food number**" | relay-allowlisted (`fairshare`) | **Works as claimed** — its output is Fair Share events, which sync. |
| **Fair Draw** | `fairdraw.commit`, `fairdraw.reveal` | "Commit-reveal lottery engine … a provably unriggable draw" | relay-allowlisted (`fairdraw`) | **Works as claimed** — commit/reveal are public-by-design so peers can audit. |
| **The Climb** | `theclimb.plan.propose/commit`, `theclimb.tiebreak.commit/reveal` | "Min-cost-flow scheduling plus a congestion simulation … calling Fair Draw for contested wave slots" | relay-allowlisted (`theclimb.plan`, `theclimb.tiebreak`) | **Works as claimed.** |
| **Mentor** | `mentor.skillReview`, `mentor.match` (reads `seed.skillHolder`) | "Skill-criticality-ranked knowledge feed with FSRS spaced-repetition scheduling" | relay-allowlisted (`mentor.skillReview`, `mentor.match`) | **Works as claimed** — the community matching signal syncs. (FSRS review schedule is inherently personal and local, which is fine.) |
| **Sky — memory wall** | `sky.memoryWall.entry` | "shared memory wall" (UI: "Share what you noticed…", `aria-label="Memory wall"`, a list of other residents' entries) | **NONE** (excluded). `postMemoryWallEntry` even **calls** `trySyncWithBackend()`, but `isPushableType` drops it. | **BROKEN as claimed** — see §3.1. The originating concern, confirmed. |
| **Sky — morale** | `sky.morale.pulse` | aggregated "mood pulse" count presented as community morale | **NONE** (excluded). Presence counter beside it is a **separate** live WebRTC Awareness channel and does work. | **BROKEN as claimed** — the morale aggregate reflects only the viewing device's own pulses — see §3.2. |
**Summary:** 9 mini-apps fully work as claimed; 1 (Light Clock) is correctly
private; 1 (Find Family) works via a dedicated channel with caveats; **4
community features across 3 mini-apps are BROKEN on a real per-resident-device
deployment: Sky memory wall, Sky morale, Health Post symptom tally, Assembly
testimony.**
---
## 3. BROKEN items — root cause + exact fix
### 3.1 Sky memory wall (`sky.memoryWall.entry`)
**Why broken.** The UI (`SkyScreen.tsx`) renders a shared list of entries with
each author's account id — unambiguously a communal artifact, not a private
journal. But the payload is excluded from the allowlist and has no dedicated
channel. `postMemoryWallEntry` already fires `trySyncWithBackend()`; the
allowlist silently no-ops it. On one-phone-per-resident, every wall shows only
its own device's posts.
**Fix.** Add `"sky.memoryWall.entry"` (or the `"sky.memoryWall"` prefix) to
`PUSH_TYPE_ALLOWLIST` in `src/lib/sync.ts`.
**Rationale.** A memory wall is public-by-intent community data, on par with
the already-pushed `waterwatch.reading.report` / `tunnelsafety.hazard` /
`testimony` civic posts. Pulled entries ingest through `appendEntry()`, which
re-verifies the Ed25519 signature, so a forged entry can never be persisted.
**Trade-off to accept consciously:** the entry text + author pubkey become
relay-readable — but the UI already displays the author pubkey on every entry,
so this exposure is inherent to the feature, not new. No new machinery needed;
the sync call is already in place.
### 3.2 Sky morale (`sky.morale.pulse`)
**Why broken.** `aggregateMoraleCounts` tallies pulses per mood from the local
replay only. Excluded from the allowlist and from any WebRTC channel (the
presence counter is a *separate* Awareness roster that carries no mood data).
So the "community mood" gauge is just this device's own pulses.
**The real tension.** The allowlist comment deliberately groups
`sky.morale.*` with health as sensitive PII: pushing raw pulses stamped with
the author's one identity key lets a relay-puller join a resident's *mood* to
their *wallet* and *health* by the same pubkey. That concern is legitimate.
**Fix — pick one, by product intent:**
- **Option A (simplest, if morale is a genuine community signal):** add
`"sky.morale.pulse"` to the allowlist. Accept that mood becomes semi-public
and pubkey-correlatable — note that the optional free-text `note` is already
posted publicly, so the structured `mood` enum is arguably no more sensitive.
- **Option B (preserves the privacy boundary):** the gauge only needs *counts*
per mood, never per-author pulses. Push pulses under a **domain-separated
ephemeral/pseudonymous key** (sign a morale pulse with a key derived as
`H(identity || "sky-morale")` instead of the raw wallet pubkey) so counts
aggregate across devices but the mood↔wallet↔health join is broken. This is
the same mechanism §3.3 needs and is the honest way to keep the stated
privacy guarantee while making the aggregate real.
**Recommendation:** Option B if the morale/health privacy boundary is meant to
hold (it is explicitly drawn in the code); Option A only if the team decides
mood is as public as the memory wall. Do **not** leave it silently local while
presenting it as community morale.
### 3.3 Health Post symptom tally (`healthpost.symptomReport`) — the hardest
**Why broken.** `extractSymptomReports` + `tallySymptoms` count only the local
device's reports. Worse, `countDistinctSymptomReporters` gates a *consequential
cross-app action* — the waterborne-outbreak → Fair Share water-floor interop —
on the number of **distinct `authorPubkey`s** that reported a symptom. With no
cross-device sync, every device sees only its own pubkey, so that count is
**always ≤ 1**: the multi-resident corroboration gate is **structurally
unreachable** on a per-resident-device deployment. The "dispatch-facing tally"
and the admin monitor (which only sees pushed events) are both blind. This is
the memory-wall bug class **plus** a broken safety-critical interop.
**Why you cannot just allowlist it.** `symptomReport` is the *exact* case the
allowlist's privacy rationale was written to prevent: raw per-pubkey health
events on a shared relay let anyone join a resident's symptoms to their mood
and wallet. Adding `"healthpost.symptomReport"` to the list would re-introduce
precisely that correlation attack on the most sensitive data in the app.
**Fix — anonymized aggregation, not raw relay push.** Introduce a
health-domain reporting path that is unlinkable to the wallet identity:
- Each report is signed under a **domain-separated pseudonymous reporter key**,
e.g. `reporterId = H(identityPubkey || "healthpost-reporter")`, carried in
place of the raw `authorPubkey`. This is *stable per resident within the
health domain* (so `countDistinctSymptomReporters` still dedups honest
double-reports and the water-floor gate stays meaningful) but **cannot be
joined** to `wallet.*`, `sky.morale.*`, or any other domain that uses the raw
pubkey.
- Push these pseudonymous reports through the relay (a new allowlist entry for
the pseudonymous type, or a dedicated `api/` aggregation endpoint that
returns only `{ perSymptomCount, distinctReporterCount }` and never the raw
reports). A count-only server endpoint is the stronger privacy posture and
fits the "relay never holds application truth" design because the counts are
still derived, not authoritative.
**Rationale.** This is deliberately more than one line *because the exclusion
was principled*: the fix must keep the health↔wallet↔mood unlinkability while
making the community tally and the distinct-reporter safety gate actually
function cross-device. A domain-separated pseudonym is the minimal mechanism
that satisfies both.
**If the intended deployment is one shared clinic/kiosk device per shelter**
(not one phone per resident), the current design is already correct — but the
README explicitly markets the app as per-resident "installable, mobile-first",
so that assumption must be stated and the two claims reconciled; today they
contradict.
### 3.4 Assembly testimony (`testimony.statement`)
**Why broken.** The testimony board is plain Event Log, **not** the Assembly
Yjs CRDT. `assemblySync.ts` syncs the `AssemblyDoc` (proposals/roster/votes);
`qrSneakernet.ts` encodes **only Yjs state-vector deltas** — neither carries
Event-Log `testimony.statement` entries. The only cross-device path is the
manual `importTestimonyStatement` JSON paste, and **only the import half is
wired** in `TestimonyBoard.tsx` (the paste box); there is no export/share
button calling `serializeTestimonyEntry` (that symbol appears only in tests).
So on multi-device, each board shows its own statements plus whatever someone
hand-pasted — no automatic community consensus. Same bug class as the memory
wall, mitigated only by a half-wired manual path.
**Fix.** Add `"testimony"` to `PUSH_TYPE_ALLOWLIST`.
**Rationale.** Testimony is public, tamper-evident civic data (surface-safety
ratings) explicitly *meant* to be read by everyone — directly comparable to
the already-pushed `waterwatch.reading.report` and `tunnelsafety.hazard`. There
is **no PII-correlation concern beyond what is already public** (authors are
shown on the board by design). Pulled statements ingest via `appendEntry()`,
which re-verifies each signature — the very guarantee the board already relies
on for the manual import path, so relay sync is exactly as safe. Optionally
also finish the sneakernet by wiring a `serializeTestimonyEntry` "share"
button so the air-gapped QR/paste layer the README advertises is real — but
allowlisting is the primary fix; the manual path alone does not deliver the
claimed aggregation.
---
## 4. One-line fixes vs. the one that needs design
| Feature | Fix | Effort |
|---|---|---|
| Sky memory wall | add `sky.memoryWall.entry` to allowlist | one line (sync call already present) |
| Assembly testimony | add `testimony` to allowlist; optionally wire export button | one line (+ optional UI) |
| Sky morale | allowlist it (Option A) **or** domain-pseudonym push (Option B) | one line, or small crypto change — product decision |
| Health Post symptom tally | **domain-separated pseudonymous reporter key + count-only aggregation** — NOT a raw allowlist push | real design work; privacy rationale is genuine |
**Net:** The Sky memory-wall concern is correct and generalizes to **4 broken
community features across Sky, Health Post, and Assembly-testimony.** Three are
public-data types wrongly excluded (one/near-one-line allowlist fixes, each
safe because `appendEntry` re-verifies signatures on pull). The fourth
(symptom tally) is the only one whose exclusion was *principled* — it needs an
anonymized aggregation path that preserves health↔wallet unlinkability while
restoring both the dispatch tally and the distinct-reporter water-floor gate.
Light Clock is the only excluded feature that is correctly private. Fixing the
allowlist also restores the admin dashboard's visibility into these same
features, since admin aggregates only what clients push.
Generated
+61
View File
@@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1794427683,
"narHash": "sha256-o7ey9gEilsxaifqJWnBDlYSKbNWYQYtKwDyXeZU2kaU=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cd489559845d81f673a12885576016c65cbe9363",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1795085501,
"narHash": "sha256-S5keGWzaKpuXo9MNoIC2FfTIuTyTnx8P4NhYJMEsTLI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0bb8272318b4ca41bf0edc6224df3e3e3046b70d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1791244623,
"narHash": "sha256-uuanbkFk8a313Zfrxdcz8Us/yQtaxNnKJtX8v0ZPpd8=",
"owner": "nix-systems",
"repo": "default",
"rev": "d36eeed142f88b5a636f2e3856a53c61654cf29b",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+9 -9
View File
@@ -39,11 +39,11 @@
# not ship or fetch a native binary.)
npmFlags = [ "--ignore-scripts" ];
# Computed from package-lock.json, not knowable ahead of time on a
# machine without `nix` installed. Run `nix build .#frontend` once:
# it fails with "hash mismatch ... got: sha256-XXXX=" - paste that
# value here and rebuild.
npmDepsHash = pkgs.lib.fakeHash;
# Computed via `nix build .#frontend` against package-lock.json as
# committed at the time this flake was written. If package-lock.json
# changes, this hash goes stale - re-run `nix build .#frontend`, it
# fails with "got: sha256-XXXX=", paste that value in.
npmDepsHash = "sha256-RQAKbVaJMRVANpXB9n5XX3YT7nePjJOEIPFET6trjf8=";
npmBuildScript = "build";
@@ -69,10 +69,10 @@
};
devShells.default = pkgs.mkShell {
packages = [
nodejs
pkgs.nodePackages.npm
];
# `nodejs_24` already bundles npm - no separate `nodePackages.npm`
# (that attribute set was removed from recent nixpkgs; most of what
# it held now lives at the top level, per the nixpkgs manual).
packages = [ nodejs ];
};
}
)