Skip to content

feat(prism-id): relay bus, link QR codes, public log for hosts, refreshing cadence - #2

Merged
afflom merged 8 commits into
claude/project-thread-nkgrlbfrom
claude/project-thread-i4vn2z
Nov 14, 2026
Merged

afflom merged 8 commits into
claude/project-thread-nkgrlbfrom
claude/project-thread-i4vn2z

Conversation

@afflom

@afflom afflom commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Additions to Prism id on top of claude/project-thread-nkgrlb, now including 4166b87 (hybrid ML-DSA signatures, passkey approvals, log-free recovery, cover traffic). Foundry's frame pins stitch's Prism id and runs on it alone, with no server of its own.

createRelayBus implements the bus contract (publish, subscribe, retained) on stitch's own transport. Across devices and origins it uses stitch's warm relay with stitch's relay framing; within one origin it uses BroadcastChannel. The relay topic is a domain-separated hash of the prism topic. retained(topic) is what the relay still holds (the warm lifetime, 30 min), so offline catch-up and log-free recovery read the relay.

linkQr(uri) returns the QR code for a link offer as {size, modules}: ISO/IEC 18004, byte mode, level M, the smallest version, the lowest-penalty mask. It was checked against jsQR 1.4.0 over versions 1 to 38, and the test pins one vector.

Public log (logTopic, publishLog, heardLog): a topic derived from the prism id alone that carries the signed public records. With verifyAction(..., {bus}), a host merges what that topic retains before deciding. A removed device that never syncs is therefore refused once another device has published its removal. Forged records, other prisms' logs and junk on the topic count for nothing (tested).

createSyncCadence({refresh}): every refresh ticks, the cadence sends a real sync and the public log. While any member is online, the warm relay then always holds a recent copy.

resolvePrism takes any genesis of the prism whose signature verifies. ECDSA malleability had made a copied genesis able to break resolution.

Still open (listed in docs/prism-id.md, under "Open"):

  • A replayed old recovery forks the recovery chain. Set union alone cannot order it; the proposed fix uses the threat model's D4 witnessed time.
  • Retention while every member is offline.

The threat model doc is left unchanged, because it is a Product.Security source and editing it would invalidate the retained proof evidence. Those rows should move there in the next attested revision.

Tests: tests/prism-bus.test.js has 7 tests. npm test passes 453 of 454. The one failure is source-authoring, because prism-code/src/axioms.mjs is missing; it fails identically on the base. No .lex.tex changed; only product/contracts.json rebinds.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T

Prism id's next milestone: a recovery device is an ordinary prism/device/1
linked by the ordinary link flow, whose private keys are sealed (AES-GCM,
HKDF from a 32-byte seed) in a public-safe prism/recovery-escrow/1 object
with the private boundary and the log. The owner keeps the seed as a
56-character Crockford recovery code with three check bytes. recoverOnto
opens the escrow and links the new browser's own non-extractable device
through createLinkOffer/acceptLinkRequest/completeLink, so Stitch.PrismId
decides it like any link; a recovery device revoked in a newer log links
nothing. No model rule is added. Lives in src/prism-id.js so the product
register's modeled artifacts are unchanged (contracts.json regenerated).

tests/prism-recovery.test.js: code round trip and typo refusal, recovery
onto a new device with the private boundary, escrow bound to its code,
revoked recovery refused. node --test tests/prism-*.test.js: 15 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
A recovery device (class recovery) is linked through the ordinary link flow;
its keys, keyring and log are sealed under a key derived from a 56-char
Crockford recovery code. recoverOnto links the new browser's own device;
later rotations reach the recovery device as a member, so old codes keep
opening newly sealed content. Revoked recovery devices link nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
ECDSA signatures are malleable and envelopes are keyed by their own kappa,
so anyone could add a second genesis envelope for a prism (same body, other
signature) and resolvePrism refused every log that held both. Resolution now
takes any genesis of the prism whose signature verifies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T

afflom commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

The model check fails here with PP5007: application-lean timed out in scripts/check-model-sdk.sh --check. It isn't this PR's failure. The base branch's own run (43519002885, on claude/project-thread-nkgrlb) fails at the same step with the same timeout. This PR doesn't touch any LexLean module or tests/prism-id.test.js. Locally, npm test passes 437 tests, with the same one source-authoring failure the base has, and model:check, facets:check and product:check are fresh.


Generated by Claude Code

… resolve

- createRelayBus implements the prism bus contract (publish, subscribe) on
  stitch's own transport: the warm relay with stitch's relay framing across
  devices and origins, BroadcastChannel within one origin. The relay topic is
  a domain-separated hash of the prism topic (at most 64 characters), every
  message names its prism topic, a subscriber delivers only that topic, and a
  bus never hears itself. subscribe first delivers what the relay still holds
  (the warm lifetime), then live messages; fetch returns what it holds.
  Effects (fetch, WebSocket, BroadcastChannel) are injectable.
- resolvePrism takes any genesis of the prism whose signature verifies.
  ECDSA signatures are malleable and envelopes are keyed by their own kappa,
  so a second genesis envelope (same body, other signature) made every log
  that held both unresolvable.

tests/prism-bus.test.js: framing and hashed topics over an ntfy-shaped relay,
a multi-frame message, two devices linking over the rendezvous topic with the
six-digit code then syncing a removal, and the copied genesis. npm test 445
of 446; the one failure (source-authoring, prism-code axioms.mjs missing in
this checkout) fails identically on the base commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
…rsedes recovery codes (drops b85ef0d)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
@afflom afflom changed the title Prism id: recovery codes, so a prism outlives its devices feat(prism-id): substrate bus on stitch's relay; copied geneses resolve Nov 14, 2026
afflom pushed a commit to UOR-Foundation/template that referenced this pull request Nov 14, 2026
…eploy

prism/identity/4. The id page at id.uor.foundation and the registry mailbox
are gone. The frame runs stitch's Prism id in the app's own page, so a Prism
app needs no server of Prism's own:

- Each app origin keeps its own device of the id (IndexedDB prism-id),
  made with no prompt. Create a Prism id is createPrism, then stitch's
  threshold recovery with one paper share, downloaded as a recovery kit
  (the share and the log).
- Another app or device joins by stitch's link offer: the signed-in app
  shows a prism-link: URI, the new one answers on the rendezvous topic and
  shows six digits, and the person types them into the first. A wrong code
  is refused and the offer stays usable.
- Use a recovery kit is recoverPrism with rotateRecovery: this browser
  becomes the device, every other device is removed, a new kit replaces the
  old. A kit that what the devices shared shows was already used is refused.
- Devices lists the id's devices; Remove is revokeDevice. Sign-in first takes
  in the sync messages, so a removed device stops.
- Devices meet on stitch's relay through Prism id's createRelayBus. The frame
  exports PRISM_RELAY, and the page build adds it and its wss: origin to
  connect-src in place of frame-src for the old accounts origin.

identity/stitch-sync.mjs now copies prism-id.js with the stitch modules it
imports (relay framing and what that imports), each in its own scope, and
the 37 model decisions they call. Pinned to stitch e3efc6e (afflom/stitch#2).

npm run test:identity: 16 of 16, the eight session checks and the flow in
Chromium across two app origins with an in-memory relay standing in for
the real one (create, reload, sign out and in, non-extractable keys, join by
link and code, remove, recover from the kit, old kit refused).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T

afflom commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

A gap in threshold recovery that Foundry's frame ran into. It isn't fixed here, because the fix belongs in Stitch.PrismId.

A used recovery share still works when replayed against the log it came with. Say recoverPrism runs once with rotateRecovery, producing device D1 and recovery R2. Then the same share runs again against the original records (the log saved beside the share), producing D2 and R2'. Each run's self-revocation of R1 keeps the bind R1 just made (keep). So when the two logs merge, D1, D2, R2 and R2' are all active: 4 active devices, 2 of them recovery. A member can't revoke the extra recovery device (recoveryBindAllowed / revocationCounts).

Reproduce: createRecovery(createPrism(), {threshold: 1, guardians: [{paper: true}]}), then call recoverPrism twice with the same share and records, then resolvePrism on mergeLogs of the two.

Foundry's frame refuses this on the recovering device once its sync shows a newer recovery device. Other devices still accept it. One possible model rule: a recovery device's binds made after it was replaced don't count, or a recovery device may revoke itself only once.


Generated by Claude Code

… recovery); relay bus implements retained

The bus contract now names retained(topic). createRelayBus's poll of the
warm relay becomes retained, so log-free recovery and offline catch-up read
stitch's relay. docs/prism-id.md says the relay's 30-minute warm lifetime
bounds both. product/contracts.json rebinds the implementation hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
…ocations from, refreshing cadence

linkQr(uri) encodes a prism-link URI as an ISO/IEC 18004 QR code (byte
mode, level M, smallest version, lowest-penalty mask) and returns
{size, modules}. Checked against jsQR 1.4.0 over versions 1 to 38; the test
pins one vector's module digest and the finder patterns.

logTopic(prism) is a public topic derived from the prism id alone.
publishLog puts the signed public records there; heardLog merges what the
bus retains on it, skipping other prisms, oversize and malformed messages.
verifyAction takes { bus } and merges heardLog first, so a removed device
that never syncs is refused once another device published its removal.

createSyncCadence({ refresh }) sends a real sync and the public log every
refresh ticks, so the warm relay (30 minutes) keeps a recent copy while any
member is online.

docs/prism-id.md documents all three and lists what stays open (a replayed
old recovery, retention when every member is offline). The threat model is
left unchanged so the retained proof evidence holds; product/contracts.json
rebinds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NdLCxdzL1iQw9rg5T
@afflom afflom changed the title feat(prism-id): substrate bus on stitch's relay; copied geneses resolve feat(prism-id): relay bus, link QR codes, public log for hosts, refreshing cadence Nov 14, 2026
@afflom
afflom merged commit 696c37e into claude/project-thread-nkgrlb Nov 14, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants