Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。
Cross-Restart Room Recovery
- Research date: 2026-08-26; permanent-room revision reviewed 2026-09-10
- Status: SQLite authority verified; current behavior is owned by rooms/access
Current Conclusion
SQLite has one cohesive current consumer: the room authorization aggregate. It is justified when application releases should retain not only a preferred code, but the exact Host ownership, existing Viewer invitation, authorization generation, code-entry policy and password verifier. It is not a generic store for future features.
Hosted defaults to SQLite over the same RoomStore contract. Process-only mode remains an explicit composition. Persistence is independent of the optional empty-room retention policy: the default keeps authority indefinitely; public sites may reclaim abandoned codes.
Stored Authority
| Field | Restart value |
|---|---|
roomId |
Retains the exact four-digit allocation. |
| Host-token SHA-256 | Lets a browser that still holds the raw token reclaim Host authority. |
| Viewer-grant SHA-256 | Keeps an existing invitation usable without persisting its raw grant. |
| Viewer authorization generation | Prevents rotate/revoke from rolling back across restart. |
| `open | private` |
| 48-byte scrypt material | Preserves optional password admission without plaintext. |
These values form one atomic row. Create, password/policy update, rotate/revoke, abandon and room replacement update the row in the same RoomStore mutation that changes memory authority.
Deliberately Ephemeral State
SQLite does not store raw Host tokens, raw Viewer grants, room passwords, site access credentials, participants, display names, client/peer/session IDs, sharing generation, pause, quality settings, codec decisions, route graph, pending operation, connection/revision, first-frame proof, SFU token/resource or LiveKit room, SDP, ICE candidate/address, RTCStats, quality evidence, diagnostic snapshot or log event.
Those facts describe a current process or media generation. Restoring them would grant stale sockets or media false authority and could undercount physical sender or SFU resources.
Restart Behavior
After an application restart, the database restores room authorization only. Surviving Host and Viewer pages reconnect with their existing raw credentials, receive fresh session/peer/connection/route generations, and recommit media on a newly decoded frame. A surviving Host capture track may therefore recover with a bounded interruption; a page/browser restart still requires a new capture gesture.
The application rebuilds embedded SFU publications, subscriptions and the process resource ledger. SQLite does not make a media-process restart seamless. LiveKit's separate Redis/distributed/draining architecture is not part of this embedded composition.
Why Not A Signed Recovery Capsule
A signed Host capsule is smaller only when recovery may issue a new invitation. It cannot prove that an older capsule is not replaying a Viewer grant revoked by a newer one. Stable old invitations plus strong rotate/revoke therefore require a durable current authorization generation. Once that durable owner exists, keeping the code, credential digests, policy and verifier in the same SQLite row is simpler than a client capsule, signing key and second truth path.
Storage And Deployment Boundary
The accepted implementation uses one embedded SQLite driver, one exact schema, one process connection and transactional low-frequency room writes. No ORM, event table, stats writer, compatibility reader or migration chain is added. Unknown schema, wrong application identity, corrupt row, inaccessible file or a second owner fails before signaling or SFU resource mutation.
Production activation is not an app-only cutover. It requires an access-restricted writable directory, configuration backup, database backup/restore procedure and rollback that restores matching data, environment and application together. Old database backups can revive revoked credentials, so restoring one later requires an explicit credential-invalidating decision.
For the permanent-room revision, an offline DROP COLUMN transaction on a
copy of the prior synthetic database preserved both active and formerly expired
rooms. All six remaining authority fields matched exactly; the source backup
was unchanged. The current reader accepted the converted schema without a
compatibility path. The completed cutover is retained in Git; current
deployment recovery owns the operational boundary.
Acceptance Matrix
- Both storage modes pass identical room behavior within one process.
- Stable restart preserves code, token/grant validation, password, policy, generation while restoring zero participants or media state.
- A grant revoked before restart remains revoked afterward.
- Default presence and elapsed time do not mutate durable authority; opt-in retention retires only empty rooms and resets the empty interval on restart.
- Explicit deletion/replacement releases codes; the allocation bound is unchanged.
- Corrupt/mismatched/multiply owned state fails before accepting traffic.
- Surviving Host/Viewer tabs reauthenticate and rebuild a fresh route; no test labels that bounded rebuild as uninterrupted media.
SQLite I/O Failure Boundary
On 2026-10-07, the current pure-Go driver was exercised in an isolated Linux VM
with 600 synthetic rooms. Syscall fault injection rejected journal/database
pwrite64 and fsync during commit and rollback, including spilled dirty pages
and sustained failures. Rejected writes did not become accepted authority;
while the fault persisted, further writes failed. After removing the fault,
reads, a new mutation and reopening the database retained the expected rows.
Read-only, page-capacity and deferred-constraint failures are also covered by
the ordinary room tests. This is not power-loss or filesystem-durability proof.
SQLite can roll back automatically after an I/O or capacity error, so a separate application transaction flag cannot reliably describe it. The owner now issues one best-effort rollback on failure, preserves the original error and adds no retry/reopen mechanism. This follows SQLite's transaction error guidance; the experiment used strace syscall fault injection on disposable files, not production data.