Database sharing · reviewed 3 December 2026

Share one whole database.

A publisher owns each shared database. Read grants permit reading. Submit members send proposals for the publisher to decide. Write members publish direct changes on their own signed streams.

01 · Contract

Purpose, inputs, outputs, guarantees, and limits.

Purpose. Give other nodes access to one shared database.

Inputs and outputs. The owner creates a database and link. The recipient accepts it. The publisher signs grants; whether a member submits a proposal or publishes direct records depends on the member’s signed grants.

Guarantees. Signed log entries authenticate grants. Submit members propose changes; Write members publish direct changes on their own streams.

Limits. The cloud service is a central encrypted relay, not peer-to-peer. The publisher must be online to process proposals. This shares a whole database.

Merged source review at 5eb6a3a63. Released versions may expose different behavior. Read grants permit reading, Submit grants permit publisher-reviewed proposals, and Write grants permit direct changes on the member’s signed stream. The publisher owns grants, snapshots, and cleanup.

App API sharing contract →

02 · Prerequisites

Know both node identities.

  • The publisher has a running node and owns the database.
  • The recipient has a LastDB node. Its public node key identifies it to the publisher.
  • Exchange and verify public keys through a channel the people already trust. Contact files are optional; an open link alone does not grant relay access.
  • Each participant has cloud relay access set up for that node. Production cloud writes require the paid service.

A share contact file can help verify the recipient's public key. It contains public identity data, not a permission grant.

04 · Grant

The publisher signs a role grant.

The app API extension accepts a grant action. This example runs from a registered publisher app whose manifest grants the databases extension. Set grantee to the recipient's 64-character lowercase node-key hex.

POST /v1/x/databases · grant action
socket="$HOME/.lastdb/apps.sock"
[ -S "$socket" ] || socket="$HOME/.lastdb/data/apps.sock"
curl --fail-with-body --unix-socket "$socket" \
  -X POST http://localhost/v1/x/databases \
  -H 'X-LastDB-App: family-owner' \
  -H 'Content-Type: application/json' \
  -d '{"action":"grant","database":"family-notes","grantee":"RECIPIENT_64_CHAR_NODE_KEY_HEX","role":"submit","period_ms":86400000,"renew_until_ms":RENEWAL_END_UNIX_MS}'

Replace RENEWAL_END_UNIX_MS with a future Unix time in milliseconds, or omit that field for the default policy. The example period is one day. Each grant period is at least one second and at most 366 days. until_ms, when used, cannot exceed one period from signing.

Read grants reading only.

Submit permits proposals to create records and change records the member created.

Write permits direct changes and attachment uploads on the member’s own stream.

All roles permit reading. The strongest active grant determines the write path. Public any access permits Read only.

05 · Read and propose

Submit members use proposals.

Use POST /v1/read and POST /v1/write with database set to the shared database id. Reads return records after the local shared log has applied them.

A Submit member sends a condition-checked write. The member node checks the current grant and record rules, signs a proposal, and returns HTTP 202 with status: pending and a mutation id. The change appears on the member node only after the owner publishes an accepted entry.

A proposal write is limited to one mutation and cannot include a file. The member node checks the cited grant and record rules before signing. The signed proposal order must be earlier than the grant expiry. The owner decides proposals one record at a time and in signed order. Send one proposal at a time for a shared member write. Several separate proposals do not form one atomic change.

Poll the write status route using its mutation id. A result can be pending, published, not_accepted, or unknown. Direct writes return applied and have no proposal receipt.

06 · Direct writes

Write members publish on their own streams.

Give a named member a Write grant to permit direct changes. The same database can also have Read and Submit members.

A Write member’s condition-checked change commits locally and is signed by that member’s node key on its own stream. Direct writes support ordinary batches and attachments. A successful local response means the local commit completed; other nodes see it after relay sync.

The publisher remains responsible for grants, snapshots, and relay cleanup. Members do not publish the database snapshot or trim or delete shared relay data.

This describes the reviewed LastDB source. It does not establish that a particular deployed cloud relay has adopted these grant rules. LastDB uses whole-database stream discovery only when the relay announces revision 7 or newer; older relays use writer-scoped discovery.

07 · Expiry

Expiry and renewal are separate.

Each signed grant has an end time. The default period is 24 hours. A renewal horizon can permit the publisher's node to extend an active grant up to the stated time. An explicit until_ms is the current grant end and must be within one period.

Use the remove_member action to stop renewal. It does not shorten a grant already issued. Access ends when the active grant reaches its end time. The publisher can issue a later grant if access should resume.

08 · Relay and decision

The relay carries encrypted entries.

The cloud relay stores and forwards encrypted database data. It cannot read the database contents. The publisher's LastDB downloads each proposal, checks it against the signed role at the proposal’s order and the current record rules, then publishes accepted changes using the publisher's key. It discards refusals and marks processed proposals.

Published changes and pending proposals keep independent positions under the same database identity. Write members publish direct entries to their own signed streams. The publisher alone publishes snapshots and directs relay cleanup. LastDB owns recovery and cleanup decisions; the relay removes data only under those instructions.

The publisher must be online to process new proposals. A relay upload or pending response does not mean the owner accepted a proposal. Direct writes have no proposal acceptance step.

Back to the developer guide → · Publishing apps →