fix(sync): allowlist Sky memory wall and Assembly testimony for cross-device sync
Both are public, author-attributed community boards (their own UI already shows every entry's author to other residents) that were silently excluded from PUSH_TYPE_ALLOWLIST alongside genuinely private data (mood, symptoms). On a one-phone-per-resident deployment this meant each resident's wall/board only ever showed their own posts - the exact defect the user flagged for Sky's memory wall, confirmed to generalize via a full cross-device sync audit (.omo/evidence/service-sync-reevaluation.md). Also wires the missing export/share half of testimony's manual sneakernet path (TestimonyBoard.tsx): only paste-import existed before; a Share button now reveals the serializeTestimonyEntry() blob for the primary relay sync path's offline fallback. sky.morale.pulse and healthpost.symptomReport stay excluded - those carry a real health/wallet correlation risk via the raw identity pubkey; the audit recommends a domain-separated pseudonym design for those two, not a plain allowlist entry, which is a larger privacy-preserving mechanism still to be decided/built.
This commit is contained in:
1 parent
725701c72d
commit
a33b3b5061
5 files changed
+254
-5
No files matched your search
@@ -193,4 +193,66 @@ describe("trySyncWithBackend", () => {
|
||||
expect(types).toContain("governance.proposal.enacted");
|
||||
expect(types).not.toContain("healthpost.symptomReport");
|
||||
});
|
||||
|
||||
it("pushes the Sky memory wall and Assembly testimony board (public, author-attributed community data), still never morale/symptom", async () => {
|
||||
// Both the memory wall and testimony board already show each entry's
|
||||
// author to every other resident in their own UI - the sync
|
||||
// re-evaluation (.omo/evidence/service-sync-reevaluation.md) found that
|
||||
// excluding them broke the exact cross-device purpose their UI already
|
||||
// claims. Mood and symptom reports stay excluded: those still carry a
|
||||
// real health/wallet correlation risk the public boards don't.
|
||||
await append({ type: "sky.memoryWall.entry", text: "Saw stars through the vent today.", postedAt: 1 });
|
||||
await append({ type: "testimony.statement", text: "East wall looks stable.", rating: 4, postedAt: 2 });
|
||||
await append({ type: "sky.morale.pulse", mood: "okay" });
|
||||
await append({ type: "healthpost.symptomReport", symptom: "cough" });
|
||||
|
||||
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("sky.memoryWall.entry");
|
||||
expect(types).toContain("testimony.statement");
|
||||
expect(types).not.toContain("sky.morale.pulse");
|
||||
expect(types).not.toContain("healthpost.symptomReport");
|
||||
expect(result.pushed).toBe(2);
|
||||
});
|
||||
|
||||
it("pulls another resident's memory-wall entry and testimony statement into the local replay", async () => {
|
||||
// The flip side of the allowlist change: a peer's own-signed wall/board
|
||||
// entries must actually land in THIS device's log via appendEntry's
|
||||
// normal pull path, proving the end-to-end fix (not just "not filtered
|
||||
// on push").
|
||||
const wallWire = await signedWireEntry(
|
||||
{ type: "sky.memoryWall.entry", text: "The horizon glowed orange tonight.", postedAt: 5 },
|
||||
1,
|
||||
);
|
||||
const testimonyWire = await signedWireEntry(
|
||||
{ type: "testimony.statement", text: "Tunnel 4 is clear.", rating: 5, postedAt: 6 },
|
||||
2,
|
||||
);
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn().mockResolvedValue(
|
||||
okResponse({ stored: 0, entries: [wallWire, testimonyWire], cursor: 2 }),
|
||||
),
|
||||
);
|
||||
|
||||
const result = await trySyncWithBackend({ endpoint: "http://relay/api/sync" });
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.pulled).toBe(2);
|
||||
|
||||
const stored = await readAll();
|
||||
const types = stored.map((e) => (e.payload as { type?: string }).type);
|
||||
expect(types).toContain("sky.memoryWall.entry");
|
||||
expect(types).toContain("testimony.statement");
|
||||
});
|
||||
});
|
||||
+29
-4
@@ -45,10 +45,22 @@ import { entryIdentity } from "./ledgerConflicts.ts";
|
||||
* 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.
|
||||
* NOT. Still strictly local and NEVER pushed: `healthpost.symptomReport` and
|
||||
* `sky.morale.*` (both carry health/mood correlatable to the same identity
|
||||
* key - see the cross-device sync re-evaluation at
|
||||
* .omo/evidence/service-sync-reevaluation.md for why these two specifically
|
||||
* stay excluded pending a domain-separated-pseudonym design, not a plain
|
||||
* allowlist entry), and `lightclock.*` (purely personal, no community claim
|
||||
* at all - see README's "never wired to ration anything"). `sky.memoryWall.*`
|
||||
* and `testimony.*` were ALSO excluded here originally, but both are
|
||||
* public-by-design community data whose own UI already displays the
|
||||
* author's account id on every entry (SkyScreen.tsx's memory-wall list,
|
||||
* TestimonyBoard.tsx's statement cards) - excluding them only broke their
|
||||
* stated cross-resident purpose (a "wall"/"board" nobody else's device ever
|
||||
* populates) without adding any real privacy protection, since the exposure
|
||||
* is already inherent to the feature. They are allowlisted below. 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.
|
||||
@@ -95,6 +107,19 @@ export const PUSH_TYPE_ALLOWLIST: readonly string[] = [
|
||||
// Fair Draw commit/reveal are public-by-design (a verifiable lottery for an
|
||||
// indivisible good): peers need them to independently audit the draw.
|
||||
"fairdraw",
|
||||
// Assembly's public testimony board: tamper-evident civic observations
|
||||
// (surface-safety ratings) explicitly meant for every resident to read -
|
||||
// directly comparable to `waterwatch.reading.report`/`tunnelsafety.hazard`
|
||||
// above. No PII-correlation concern beyond what TestimonyBoard.tsx already
|
||||
// displays (the author's account id on every statement).
|
||||
"testimony",
|
||||
// Sky's memory wall: a genuinely communal board (SkyScreen.tsx's UI already
|
||||
// shows every entry's author to other residents) - excluding it only broke
|
||||
// its own stated purpose on a one-phone-per-resident deployment, since each
|
||||
// device's wall then showed only its own posts. `postMemoryWallEntry`
|
||||
// already calls `trySyncWithBackend()`; this allowlist entry is what makes
|
||||
// that call actually leave the device.
|
||||
"sky.memoryWall",
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -163,3 +163,50 @@
|
||||
color: var(--color-accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.shareToggle {
|
||||
align-self: flex-start;
|
||||
margin-top: 0.3rem;
|
||||
padding: 0.3rem 0.6rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: var(--color-ink-faint);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.shareBlock {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
padding: 0.6rem;
|
||||
border-radius: 10px;
|
||||
background: var(--color-surface-muted, #f4f6f8);
|
||||
}
|
||||
|
||||
.shareJson {
|
||||
margin: 0;
|
||||
padding: 0.5rem;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
border: 1px solid var(--color-border);
|
||||
font-size: 0.68rem;
|
||||
line-height: 1.3;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
user-select: all;
|
||||
}
|
||||
|
||||
.copyButton {
|
||||
align-self: flex-start;
|
||||
padding: 0.3rem 0.7rem;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: var(--color-accent);
|
||||
color: #ffffff;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -7,7 +7,12 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { db } from "../../lib/db";
|
||||
import { appendEntry } from "../../lib/eventlog";
|
||||
import { init } from "../../lib/identity";
|
||||
import { CONSENSUS_DISCLAIMER_TEXT, serializeTestimonyEntry, type TestimonyStatementPayload } from "../../lib/testimony";
|
||||
import {
|
||||
CONSENSUS_DISCLAIMER_TEXT,
|
||||
importTestimonyStatement,
|
||||
serializeTestimonyEntry,
|
||||
type TestimonyStatementPayload,
|
||||
} from "../../lib/testimony";
|
||||
import { TestimonyBoard } from "./TestimonyBoard";
|
||||
|
||||
afterEach(cleanup);
|
||||
@@ -105,3 +110,47 @@ describe("TestimonyBoard (failure path - tampered signature rejected at post-tim
|
||||
expect(screen.getByTestId("testimony-consensus")).toHaveTextContent("No statements yet.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("TestimonyBoard (share/export - the sneakernet counterpart to the paste-import form)", () => {
|
||||
it("produces a share blob that genuinely round-trips through importTestimonyStatement on another device, byte for byte", async () => {
|
||||
const entry = await signedExternalEntry(5, "North corridor is dry and lit.", 0);
|
||||
await appendEntry(entry);
|
||||
|
||||
const user = userEvent.setup();
|
||||
const view = render(<TestimonyBoard />);
|
||||
|
||||
const cards = await screen.findAllByTestId(/^testimony-statement-\d+$/);
|
||||
expect(cards).toHaveLength(1);
|
||||
const id = cards[0].dataset.testid!.replace("testimony-statement-", "");
|
||||
|
||||
// Collapsed by default - no share JSON visible until toggled.
|
||||
expect(screen.queryByTestId(`testimony-share-json-${id}`)).not.toBeInTheDocument();
|
||||
|
||||
await user.click(screen.getByTestId(`testimony-share-toggle-${id}`));
|
||||
const shareJson = screen.getByTestId(`testimony-share-json-${id}`).textContent ?? "";
|
||||
expect(shareJson.length).toBeGreaterThan(0);
|
||||
|
||||
// Toggling again collapses it (checked while the component is still
|
||||
// mounted, before the db swap below tears the DOM down).
|
||||
await user.click(screen.getByTestId(`testimony-share-toggle-${id}`));
|
||||
expect(screen.queryByTestId(`testimony-share-json-${id}`)).not.toBeInTheDocument();
|
||||
|
||||
// The genuine proof: this isn't just "some text appeared" - the exact
|
||||
// blob the UI revealed is fed through the real importTestimonyStatement
|
||||
// path and must be accepted, signature-verified, and reproduce the
|
||||
// identical statement. Unmount first (a live-querying component kept
|
||||
// mounted across a DB wipe/recreate is not what a real second resident's
|
||||
// device looks like, and risks the hook observing a half-torn-down DB).
|
||||
view.unmount();
|
||||
indexedDB.deleteDatabase(db.name);
|
||||
db.close();
|
||||
await db.open();
|
||||
await init();
|
||||
|
||||
const stored = await importTestimonyStatement(shareJson);
|
||||
expect((stored.payload as TestimonyStatementPayload).text).toBe("North corridor is dry and lit.");
|
||||
expect((stored.payload as TestimonyStatementPayload).rating).toBe(5);
|
||||
expect(Array.from(stored.authorPubkey)).toEqual(Array.from(entry.authorPubkey));
|
||||
expect(Array.from(stored.signature)).toEqual(Array.from(entry.signature));
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
extractTestimonyStatements,
|
||||
importTestimonyStatement,
|
||||
postTestimony,
|
||||
serializeTestimonyEntry,
|
||||
TestimonyImportError,
|
||||
type TestimonyRating,
|
||||
type TestimonyStatement,
|
||||
@@ -69,6 +70,46 @@ export function TestimonyBoard() {
|
||||
const [importStatus, setImportStatus] = useState<"idle" | "importing" | "rejected">("idle");
|
||||
const [importError, setImportError] = useState<string>("");
|
||||
|
||||
// Sneakernet export - the counterpart to the paste-import form above.
|
||||
// Holds, per statement id, the JSON blob `importTestimonyStatement` on
|
||||
// another resident's device accepts verbatim (same wire format, produced
|
||||
// by `serializeTestimonyEntry`). `null` means "not expanded"; toggling a
|
||||
// second time collapses it again.
|
||||
const [sharedJsonById, setSharedJsonById] = useState<Record<number, string | null>>({});
|
||||
const [copyStatusById, setCopyStatusById] = useState<Record<number, "idle" | "copied">>({});
|
||||
|
||||
function handleToggleShare(statement: TestimonyStatement) {
|
||||
setSharedJsonById((prev) => {
|
||||
const isOpen = prev[statement.id] != null;
|
||||
if (isOpen) {
|
||||
return { ...prev, [statement.id]: null };
|
||||
}
|
||||
const json = serializeTestimonyEntry({
|
||||
payload: {
|
||||
type: "testimony.statement",
|
||||
text: statement.text,
|
||||
rating: statement.rating,
|
||||
postedAt: statement.postedAt,
|
||||
},
|
||||
authorPubkey: statement.entry.authorPubkey,
|
||||
signature: statement.entry.signature,
|
||||
lamportTs: statement.lamportTs,
|
||||
});
|
||||
return { ...prev, [statement.id]: json };
|
||||
});
|
||||
}
|
||||
|
||||
async function handleCopyShare(statementId: number, json: string) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(json);
|
||||
setCopyStatusById((prev) => ({ ...prev, [statementId]: "copied" }));
|
||||
} catch {
|
||||
// Clipboard access can be unavailable (insecure context, permission
|
||||
// denied); the JSON is already visible and selectable in the <pre>
|
||||
// below, so this is a convenience failure, not a blocker.
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePost(event: FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
if (text.trim().length === 0) {
|
||||
@@ -215,6 +256,31 @@ export function TestimonyBoard() {
|
||||
<span className={styles.statementRating} data-testid={`testimony-rating-${statement.id}`}>
|
||||
{RATING_LABEL[statement.rating]}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.shareToggle}
|
||||
data-testid={`testimony-share-toggle-${statement.id}`}
|
||||
onClick={() => handleToggleShare(statement)}
|
||||
>
|
||||
{sharedJsonById[statement.id] != null ? "Hide share text" : "Share (sneakernet)"}
|
||||
</button>
|
||||
{sharedJsonById[statement.id] != null && (
|
||||
<div className={styles.shareBlock}>
|
||||
<pre className={styles.shareJson} data-testid={`testimony-share-json-${statement.id}`}>
|
||||
{sharedJsonById[statement.id]}
|
||||
</pre>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.copyButton}
|
||||
data-testid={`testimony-share-copy-${statement.id}`}
|
||||
onClick={() =>
|
||||
void handleCopyShare(statement.id, sharedJsonById[statement.id] as string)
|
||||
}
|
||||
>
|
||||
{copyStatusById[statement.id] === "copied" ? "Copied" : "Copy"}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
Reference in new issue
Block a user