fix(privacy): sync the deliberate healthpost.referral handoff + mentor/climb-tiebreak/fairdraw
The default-deny push allowlist was too coarse: it excluded entire families whose own code comments promise cross-device delivery, silently breaking real features. Most critically healthpost.referral(.resolve) - a resident's consent-bearing handoff of their own case to a clinician - never reached a second device, so the 'reaches real care' half of Health Post was dead cross-device (the passive healthpost.symptomReport stays local). Also allowlisted mentor.skillReview/mentor.match (community apprentice-mentor matching), theclimb.tiebreak (the audit trail must travel with its plan), and fairdraw (public-by-design verifiable lottery).
This commit is contained in:
1 parent
ac7df631cf
commit
b57a041922
2 files changed
+55
-6
No files matched your search
@@ -161,4 +161,34 @@ describe("trySyncWithBackend", () => {
|
||||
expect(await db.eventLog.count()).toBe(1);
|
||||
expect(computeBalances(await readAll()).balances["raceAcct"]).toBe(10);
|
||||
});
|
||||
|
||||
it("syncs the deliberate healthpost.referral handoff + mentor/theclimb-tiebreak/fairdraw, never the symptom tally", async () => {
|
||||
await append({ type: "healthpost.symptomReport", symptom: "diarrhea" });
|
||||
await append({ type: "healthpost.referral", urgency: "needs_treatment" });
|
||||
await append({ type: "healthpost.referral.resolve", referralId: 1 });
|
||||
await append({ type: "mentor.skillReview", skillId: "well-repair", rating: "good" });
|
||||
await append({ type: "mentor.match", apprentice: "a", mentor: "b" });
|
||||
await append({ type: "theclimb.tiebreak.commit", hash: "abc" });
|
||||
await append({ type: "fairdraw.reveal", drawId: "d1" });
|
||||
|
||||
let pushedBatch: Array<{ payload: { type?: string } }> = [];
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async (_url: string, opts: { body: string }) => {
|
||||
pushedBatch = (JSON.parse(opts.body) as { push: Array<{ payload: { type?: string } }> }).push;
|
||||
return okResponse({ stored: pushedBatch.length, entries: [], cursor: 0 });
|
||||
}),
|
||||
);
|
||||
|
||||
const result = await trySyncWithBackend({ endpoint: "http://relay/api/sync" });
|
||||
expect(result.ok).toBe(true);
|
||||
const types = pushedBatch.map((e) => e.payload.type);
|
||||
expect(types).toContain("healthpost.referral");
|
||||
expect(types).toContain("healthpost.referral.resolve");
|
||||
expect(types).toContain("mentor.skillReview");
|
||||
expect(types).toContain("mentor.match");
|
||||
expect(types).toContain("theclimb.tiebreak.commit");
|
||||
expect(types).toContain("fairdraw.reveal");
|
||||
expect(types).not.toContain("healthpost.symptomReport");
|
||||
});
|
||||
});
|
||||
+25
-6
@@ -40,12 +40,15 @@ import { entryIdentity } from "./ledgerConflicts.ts";
|
||||
* under the same pubkey.
|
||||
*
|
||||
* So this is default-DENY: we push ONLY event types that both (a) genuinely
|
||||
* need cross-device merge and (b) carry community/aggregate data rather than
|
||||
* personal PII. Everything else stays strictly local and is NEVER pushed -
|
||||
* notably `healthpost.*` (symptom reports), `sky.morale.*`/`sky.memoryWall.*`
|
||||
* (mood + personal memories), `lightclock.*` (personal light/sleep),
|
||||
* `testimony.*`, `mentor.*`, `fairdraw.*`. A new, unlisted event type is never
|
||||
* pushed by accident; adding one here is a deliberate, reviewable choice.
|
||||
* need cross-device merge and (b) carry community data or a deliberate,
|
||||
* consent-bearing handoff rather than passive personal PII. The boundary is
|
||||
* drawn WITHIN a family where needed: `healthpost.referral(.resolve)` - a
|
||||
* resident's explicit act of sending their OWN case to a clinician on another
|
||||
* device - DOES sync, while the passive `healthpost.symptomReport` tally does
|
||||
* NOT. Still strictly local and NEVER pushed: `healthpost.symptomReport`,
|
||||
* `sky.morale.*`/`sky.memoryWall.*` (mood + personal memories), `lightclock.*`
|
||||
* (personal light/sleep), and `testimony.*`. A new, unlisted event type is
|
||||
* never pushed by accident; adding one here is a deliberate, reviewable choice.
|
||||
*
|
||||
* Pull is unchanged: a device still ingests whatever a peer legitimately
|
||||
* shares - this allowlist only governs what THIS device emits.
|
||||
@@ -72,6 +75,22 @@ export const PUSH_TYPE_ALLOWLIST: readonly string[] = [
|
||||
"housing",
|
||||
// Quadratic-voting ballots: public governance tallies.
|
||||
"governance.qvBallot",
|
||||
// Health Post clinician referral: a resident's deliberate, consent-bearing
|
||||
// handoff of their OWN triage result to a clinician on another device. The
|
||||
// referral loop is cross-device by contract (see ReferralQueue.tsx). This
|
||||
// string also covers `healthpost.referral.resolve` via the dot-segment rule;
|
||||
// the passive `healthpost.symptomReport` stays local (not a child of this).
|
||||
"healthpost.referral",
|
||||
// Mentor: skill reviews (proficiency signals) + proposed matches must reach
|
||||
// other devices for community apprentice<->mentor matching to work at all.
|
||||
"mentor.skillReview",
|
||||
"mentor.match",
|
||||
// The Climb tie-break audit trail travels with the plan it belongs to, so a
|
||||
// peer can verify commit-preceded-reveal from its own synced log.
|
||||
"theclimb.tiebreak",
|
||||
// Fair Draw commit/reveal are public-by-design (a verifiable lottery for an
|
||||
// indivisible good): peers need them to independently audit the draw.
|
||||
"fairdraw",
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user