@real-life/trust-protocol 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +137 -0
- package/README.md +91 -24
- package/dist/adapters/vti-mediator.d.ts +36 -8
- package/dist/adapters/vti-mediator.d.ts.map +1 -1
- package/dist/adapters/vti-mediator.js +193 -29
- package/dist/adapters/vti-mediator.js.map +1 -1
- package/dist/codec.d.ts +2 -1
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +75 -26
- package/dist/codec.js.map +1 -1
- package/dist/engine.d.ts +77 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +419 -31
- package/dist/engine.js.map +1 -1
- package/dist/entropy.d.ts +1 -1
- package/dist/entropy.d.ts.map +1 -1
- package/dist/entropy.js +1 -1
- package/dist/entropy.js.map +1 -1
- package/dist/events.d.ts +21 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/holder-api.d.ts +44 -2
- package/dist/holder-api.d.ts.map +1 -1
- package/dist/holder-api.js +40 -5
- package/dist/holder-api.js.map +1 -1
- package/dist/{holder-state-v1.d.ts → holder-state-v3.d.ts} +261 -201
- package/dist/holder-state-v3.d.ts.map +1 -0
- package/dist/holder-state-v3.js +2 -0
- package/dist/holder-state-v3.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/introduction/holder.d.ts.map +1 -1
- package/dist/introduction/holder.js +7 -0
- package/dist/introduction/holder.js.map +1 -1
- package/dist/invariants.d.ts.map +1 -1
- package/dist/invariants.js +70 -0
- package/dist/invariants.js.map +1 -1
- package/dist/membership/holder.d.ts +3 -5
- package/dist/membership/holder.d.ts.map +1 -1
- package/dist/membership/holder.js +165 -88
- package/dist/membership/holder.js.map +1 -1
- package/dist/membership.d.ts +31 -0
- package/dist/membership.d.ts.map +1 -1
- package/dist/membership.js +25 -2
- package/dist/membership.js.map +1 -1
- package/dist/message/holder.d.ts +49 -0
- package/dist/message/holder.d.ts.map +1 -0
- package/dist/message/holder.js +290 -0
- package/dist/message/holder.js.map +1 -0
- package/dist/message.d.ts +43 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +51 -0
- package/dist/message.js.map +1 -0
- package/dist/receive.d.ts +4 -3
- package/dist/receive.d.ts.map +1 -1
- package/dist/receive.js +23 -4
- package/dist/receive.js.map +1 -1
- package/dist/results.d.ts +22 -3
- package/dist/results.d.ts.map +1 -1
- package/dist/results.js.map +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +9 -6
- package/dist/schemas.js.map +1 -1
- package/dist/state.d.ts +88 -14
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +2 -1
- package/dist/state.js.map +1 -1
- package/dist/trust/continuity.d.ts.map +1 -1
- package/dist/trust/continuity.js +7 -1
- package/dist/trust/continuity.js.map +1 -1
- package/dist/trust/entries.d.ts.map +1 -1
- package/dist/trust/entries.js +103 -2
- package/dist/trust/entries.js.map +1 -1
- package/dist/views.d.ts +34 -2
- package/dist/views.d.ts.map +1 -1
- package/dist/views.js +19 -1
- package/dist/views.js.map +1 -1
- package/dist/wire.d.ts +47 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js.map +1 -1
- package/package.json +6 -4
- package/schemas/{holder-state-v1.schema.json → holder-state-v3.schema.json} +300 -12
- package/dist/holder-state-v1.d.ts.map +0 -1
- package/dist/holder-state-v1.js +0 -2
- package/dist/holder-state-v1.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,142 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
Takes up Delivery Contract 0.83: the holder keeps custody of what waits
|
|
6
|
+
for transport, and only an open, resumed opening hands anything over.
|
|
7
|
+
|
|
8
|
+
- **Custody** (RLTP-DEL-6120 to 6135): `pendingTransport(when)` names
|
|
9
|
+
what the holder keeps for transport, after this opening's first
|
|
10
|
+
completed resume (else `{ok: false, code: 'not-resumed'}`): every
|
|
11
|
+
outbox document neither terminal nor accepted, the ones the adapter
|
|
12
|
+
reported `awaiting-transport` included, and every unsent ack, each with
|
|
13
|
+
its envelope, recipient, `since` (first submission), `notAfter` (the
|
|
14
|
+
horizon or the type's sender lifetime, whichever first), `held` and
|
|
15
|
+
`nextAttemptAt`; none past its deadline, whether or not a resume has
|
|
16
|
+
recorded the give-up. Entries are deep-frozen and issued to the
|
|
17
|
+
opening. `handOver(entry, when, start)` re-reads the store and, for an
|
|
18
|
+
entry this opening issued that is still pending, unchanged and before
|
|
19
|
+
its deadline, calls `start` inside the holder's queue: the check and the
|
|
20
|
+
start of the deposit are one step. `mayHandOver(entry, when)` is the
|
|
21
|
+
check alone, and authorizes nothing afterwards. Both read at
|
|
22
|
+
max(when, lastWhen): the holder's time never runs back. A resume that throws, the settling of an earlier commit
|
|
23
|
+
included, withdraws the opening's authority until one completes. One
|
|
24
|
+
opening per store at a time is the app's to keep: two openings are not
|
|
25
|
+
serialized with each other.
|
|
26
|
+
- **A duplicate's answer** (RLTP-DEL-6330): a duplicate makes an answer
|
|
27
|
+
due, stored with the ack (`answers`, `answerDue`) and so kept across a
|
|
28
|
+
lock; `pendingTransport` offers it as a `resend` entry numbered by it,
|
|
29
|
+
beside the ack's retries and independent of their state, with the
|
|
30
|
+
effect's retention as deadline. The begun hand-over ends it (a commit);
|
|
31
|
+
a duplicate arriving while one is due is answered by it (the same
|
|
32
|
+
bytes), the next one after it makes the next due. A duplicate therefore
|
|
33
|
+
commits that answer (else, as before, lastWhen only).
|
|
34
|
+
- **The opening ends**: `await close()` (a lock, the end of a process),
|
|
35
|
+
resolved once the operation running at the call has finished; only then
|
|
36
|
+
may the next opening start. Every
|
|
37
|
+
later call rejects with `InfraError('closed')` (a new code),
|
|
38
|
+
`mayHandOver` answers false, `closed` says so. The next opening is a new
|
|
39
|
+
`createHolder` over the same store.
|
|
40
|
+
- **Acks** (RLTP-DEL-6330, 6335): an `awaiting-transport` report on an
|
|
41
|
+
ack no longer marks it sent; it records `held`, resume stops re-offering
|
|
42
|
+
it and `pendingTransport` keeps it. `accepted` or `delivered` marks it
|
|
43
|
+
sent (`sentBy: 'accepted'`), `failed` gives it up (`'failed'`), the
|
|
44
|
+
horizon ends its retries (`'horizon'`). Sent or not, it stays with its
|
|
45
|
+
effect until the effect's retention; a duplicate re-sends it once
|
|
46
|
+
without new retries.
|
|
47
|
+
- **Codec 3, a clean cut**: `StoredAck.sentBy` is `accepted | failed |
|
|
48
|
+
horizon`, present exactly when sent, `held` only while unsent, and the
|
|
49
|
+
answers (`answers`, `answerDue`). Codec 3 replaces codecs 1 and 2
|
|
50
|
+
without a migration: neither ever held a rolled-out app's state, so a
|
|
51
|
+
state of either is refused as `codec-unknown`. Removed: the migrations
|
|
52
|
+
1 → 2 and 2 → 3 (`MIGRATIONS` is empty), the codec-1 and codec-2
|
|
53
|
+
validators, `schemas/holder-state-v1.schema.json`,
|
|
54
|
+
`schemas/holder-state-v2.schema.json`, the types `HolderStateV1` and
|
|
55
|
+
`HolderStateV2`, and their fixtures and generators. New:
|
|
56
|
+
`schemas/holder-state-v3.schema.json`, `HolderStateV3`, fixtures
|
|
57
|
+
`state-v3*.json` (generated, reproduced in `npm test`).
|
|
58
|
+
- **`./adapters/vti-mediator`**: `reconcile(view, gate, now)` replaces
|
|
59
|
+
`submitOutbound`. It files the entries of the view not yet filed and
|
|
60
|
+
withdraws every submission before the trias whose digest the view no
|
|
61
|
+
longer names; each deposit starts inside `gate.handOver` (the holder),
|
|
62
|
+
after the adapter's own re-check (retired, withdrawn, past the trias,
|
|
63
|
+
past the entry's deadline or its horizon): the holder's no withdraws,
|
|
64
|
+
an error skips the attempt. Its give-up horizon counts from the entry's
|
|
65
|
+
`since`; an entry taken over past it is given up at once, never
|
|
66
|
+
attempted. A `resend` entry is a submission of its own. One adapter
|
|
67
|
+
serves one opening: bound to the holder of its first reconcile, it
|
|
68
|
+
refuses another, and the next opening gets a new adapter. It keeps no
|
|
69
|
+
custody of its own.
|
|
70
|
+
- Tests: the custody scenarios (`test/transport-custody.test.mjs`, among
|
|
71
|
+
them the open counter-probes of the store-launch reviews) and seeded
|
|
72
|
+
interleavings of locks, the end of a process, hand-overs and acks with
|
|
73
|
+
every cell reached (`test/transport-interleavings.test.mjs`).
|
|
74
|
+
|
|
75
|
+
## 0.5.0
|
|
76
|
+
|
|
77
|
+
Takes up Message Tasks 0.1, Delivery Contract 0.82 and Membership Tasks
|
|
78
|
+
0.20.
|
|
79
|
+
|
|
80
|
+
- **Messages** (Message Tasks 0.1): `sendMessage(contactId, text,
|
|
81
|
+
{when, actId, replyTo?})` sends a `message@1` on a ready, unblocked
|
|
82
|
+
relationship (refused as `not-ready`, `blocked` or `message-invalid`;
|
|
83
|
+
event `message.sent` with the mid and the document digest). Reception
|
|
84
|
+
runs the stages of Delivery 6.2: the MAC under `k_msg`, the age bound
|
|
85
|
+
(`failed(stale-issuance)`) and the future bound on the holder's time
|
|
86
|
+
mark, the completion record per tuple (no new effect for a known body,
|
|
87
|
+
equivocation refused), the inbox entry committed with the cache entry
|
|
88
|
+
and the acknowledgement. `inbox()` lists the messages not yet taken
|
|
89
|
+
over, in display order; `takeMessages(ids, {when})` takes them over.
|
|
90
|
+
`ContactView.canMessage`. The pure forms (`messageKeyOf`,
|
|
91
|
+
`messageMac`, `messageProblem`, `MESSAGE_TYPE`, …) are exported from the
|
|
92
|
+
root.
|
|
93
|
+
- **The block** (Message Tasks 6): `block(contactId)` and
|
|
94
|
+
`unblock(contactId)`, chain-level state of every relationship of the
|
|
95
|
+
entry, kept through chaining, merge and split; event `contact.blocked`,
|
|
96
|
+
`ContactView.blocked`. Under a block messages are discarded and
|
|
97
|
+
invitations declined into the register of declined invitations,
|
|
98
|
+
silently and acknowledged; the holder's own messages, invitations and
|
|
99
|
+
introduction acts toward a blocked relationship are refused. The
|
|
100
|
+
treatment of the Trust Layer's types waits for that layer's next
|
|
101
|
+
casting.
|
|
102
|
+
- **Invitations** (Membership Tasks 0.20 §3.1): attributed to the
|
|
103
|
+
relationship of their prelude binding, or to none; at most 20 new
|
|
104
|
+
credential digests per relationship and day; one surfacing per
|
|
105
|
+
credential digest, decided with the register and the permanent record
|
|
106
|
+
of surfaced invitations.
|
|
107
|
+
- **The prelude** (Membership §3.5): the registered types
|
|
108
|
+
`membership-prelude-request/0.1` and `membership-prelude-reply/0.1` with
|
|
109
|
+
the binding `membership-inviter@1`, kept per relationship for its life;
|
|
110
|
+
genesis digests compared by their bytes. **Breaking:** a holder of 0.4.0
|
|
111
|
+
sends `x-membership-prelude-*`, which 0.5.0 refuses as `unknown-type`.
|
|
112
|
+
- The inviter admits without a human act only before
|
|
113
|
+
`validUntil + membership-skew + P90D` (Membership 3282).
|
|
114
|
+
- **Delivery 0.82**: the transient disposition `failed(rate-limited)`
|
|
115
|
+
(nothing committed, no ack, no cache entry, evaluated afresh when
|
|
116
|
+
delivered again); an outbound may carry its type's sender lifetime,
|
|
117
|
+
after which resume moves it to `failed(task-expired)` and never hands it
|
|
118
|
+
out again — for a message `sentAt + P179D`, after any retry horizon
|
|
119
|
+
(at most P90D), so an undelivered message fails as
|
|
120
|
+
`failed(expired-by-adapter-policy)` first.
|
|
121
|
+
- `./adapters/vti-mediator`: `conclude(collection, now, {keep})` leaves
|
|
122
|
+
transient items unconcluded and offers them again; `concludable(result)`.
|
|
123
|
+
- **State codec 2**, with a pure migration from codec 1 (no block, no
|
|
124
|
+
rate, no record, no inbox; the ready tuples read from the state; every
|
|
125
|
+
received invitation counted as surfaced), its non-normative schema
|
|
126
|
+
`schemas/holder-state-v2.schema.json` and the type `HolderStateV2`, and
|
|
127
|
+
golden fixtures reproduced in `npm test`. The codec 1 fixtures are
|
|
128
|
+
frozen as 0.4.0 wrote them and migrated in the tests.
|
|
129
|
+
- Closed unions grown: `ActError` (`blocked`, `not-ready`,
|
|
130
|
+
`message-invalid`), `ReceiveFailure` (`rate-limited`), `HolderEvent`
|
|
131
|
+
(`contact.blocked`, `message.sent`, `message.received`), the outbox's
|
|
132
|
+
failure reasons (`task-expired`), the entropy purposes (`message.mid`).
|
|
133
|
+
- Engine (for modules): `keepKeys(state, when)` gets the tick's time; the
|
|
134
|
+
module hook `accepted` runs in the stage-9 transaction of every unique
|
|
135
|
+
document.
|
|
136
|
+
- Tests: the scenario set of Message Tasks §10.2, the race of #103 on two
|
|
137
|
+
engines over one store, and a seeded interleaving generator over
|
|
138
|
+
messages, the block, take-over and the record's retention.
|
|
139
|
+
|
|
3
140
|
## 0.4.0
|
|
4
141
|
|
|
5
142
|
- `createHolder`: one person's device state behind typed human acts
|
package/README.md
CHANGED
|
@@ -49,6 +49,53 @@ const { outbound, nextDueAt } = await holder.resume(Date.now())
|
|
|
49
49
|
holder.subscribe(async () => render(await holder.contacts(), await holder.prompts()))
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
**Custody and the lock** (Delivery 0.83, RLTP-DEL-6120 to 6135). The
|
|
53
|
+
holder keeps every outbound document until a service takes it or the
|
|
54
|
+
holder gives it up, across a lock and the end of a process; a transport
|
|
55
|
+
takes what it hands over from the holder, never from a store of its own.
|
|
56
|
+
One `createHolder` is one opening of the store:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
await holder.resume(Date.now()) // the opening's first resume comes first
|
|
60
|
+
const view = await holder.pendingTransport(Date.now())
|
|
61
|
+
if (view.ok) for (const entry of view.entries) {
|
|
62
|
+
// entry: digest, kind ('document' | 'ack'), envelope, recipient,
|
|
63
|
+
// since (first submission), notAfter (deadline), held?, nextAttemptAt?, resend?
|
|
64
|
+
// the check and the start of the send are one step of the holder
|
|
65
|
+
await holder.handOver(entry, Date.now(), () => { transport.send(entry); return true })
|
|
66
|
+
}
|
|
67
|
+
// a lock or the end of the process: nothing issued before authorizes anything;
|
|
68
|
+
// it resolves once the operation running at the call has finished
|
|
69
|
+
await holder.close()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`pendingTransport` answers `{ok: false, code: 'not-resumed'}` until a
|
|
73
|
+
resume of this opening has completed (a resume that throws withdraws it
|
|
74
|
+
again). It names every outbox document neither terminal nor accepted
|
|
75
|
+
(held ones included) and every unsent ack, none past its deadline.
|
|
76
|
+
`handOver(entry, when, start)` checks an entry and calls `start` inside
|
|
77
|
+
the holder's queue, so nothing of this holder runs between the check and
|
|
78
|
+
the start of the send; it says yes only for an entry this opening issued
|
|
79
|
+
that is still pending, unchanged and before its deadline (`mayHandOver`
|
|
80
|
+
is the check alone). A document missing from the view is not to be sent.
|
|
81
|
+
A duplicate makes an answer due, stored with the ack and kept across a
|
|
82
|
+
lock: a `resend` entry beside the ack's retries, independent of their
|
|
83
|
+
state, ended by the begun hand-over; a duplicate while one is due is
|
|
84
|
+
answered by it (the same bytes). The check is the opening's:
|
|
85
|
+
two openings over one store at once are not serialized with each other,
|
|
86
|
+
so an app keeps one opening per store (its writer lock), and releases
|
|
87
|
+
that lock, or starts the next opening, only after `await holder.close()`:
|
|
88
|
+
until then the operation running at the close may still commit. After `close()` every call rejects with
|
|
89
|
+
`InfraError('closed')` and `mayHandOver` answers false; the next opening
|
|
90
|
+
is a new `createHolder` over the same store. An ack is sent once a
|
|
91
|
+
service took it (`accepted`/`delivered` report), the adapter reports it
|
|
92
|
+
failed, or its horizon passes; an `awaiting-transport` report records
|
|
93
|
+
that the adapter holds it and ends nothing (RLTP-DEL-6330), and it stays
|
|
94
|
+
retained with its effect for a duplicate (6335).
|
|
95
|
+
`./adapters/vti-mediator` reconciles from the view
|
|
96
|
+
(`reconcile(view, holder, now)`); one adapter serves one opening, so the
|
|
97
|
+
next opening creates a new one.
|
|
98
|
+
|
|
52
99
|
**The timer.** Every act, receive and resume may name `nextDueAt`: the
|
|
53
100
|
earliest time something is due, delivery work (retries, duties, acks)
|
|
54
101
|
and expiry work (a prompt's expiry, an act's timeout or lifetime, an aging
|
|
@@ -67,10 +114,12 @@ The human acts: `show`, `scan`, `captureSentCard`, `counter` (the encounter),
|
|
|
67
114
|
`decide` (a prompt: confirm an encounter, accept an invitation, take up or
|
|
68
115
|
consent to an introduction), `trust`, `untrust`, `pauseTrust`, `setClass`,
|
|
69
116
|
`setGroupClass`, `merge`, `depart`, `setProfile`, `foundGroup`, `invite`,
|
|
70
|
-
`vouchFor`, `introduce`, `
|
|
71
|
-
|
|
72
|
-
`
|
|
73
|
-
`
|
|
117
|
+
`vouchFor`, `introduce`, `sendMessage`, `block`, `unblock`, `rotateAnchor`,
|
|
118
|
+
`addDevice`, `revokeDevice`. Not
|
|
119
|
+
human: `receive`, `report`, `resume`, `tick`, `recover`, `takeMessages`.
|
|
120
|
+
Reads: `contacts`, `contact`, `groups`, `profile`, `prompts`, `inbox`,
|
|
121
|
+
`deliveryStatus`, `deviceKey`, `snapshot`, `subscribe`. Custody:
|
|
122
|
+
`pendingTransport`, `handOver`, `mayHandOver`, `close`, `closed`.
|
|
74
123
|
|
|
75
124
|
## What the root exports
|
|
76
125
|
|
|
@@ -80,14 +129,17 @@ human: `receive`, `report`, `resume`, `tick`, `recover`. Reads: `contacts`,
|
|
|
80
129
|
`RetryPolicy`, `DeliveryReport`, `Outbound`; `seedKeys(seed)` is the
|
|
81
130
|
default KeyProvider, `randomEntropy` the default Entropy.
|
|
82
131
|
- The views: `ContactView`, `GroupView`, `PromptView`, `ProfileView`,
|
|
83
|
-
`DeliveryStatusView` and their parts.
|
|
132
|
+
`InboxMessageView`, `DeliveryStatusView` and their parts.
|
|
84
133
|
- The results and events: `ActResult`, `ReceiveResult`, `ResumeResult`,
|
|
85
134
|
`InfraError`, `CryptoUnavailableError`, `HolderEvent`.
|
|
86
135
|
- The state as an opaque type (`HolderState`), `decodeState`, `CODEC`,
|
|
87
136
|
`StateCodecError`, and `storeContract`, the suite a Store adapter passes.
|
|
88
137
|
- The pure wire builders and verifiers of every layer (`core`, `crypto`,
|
|
89
|
-
`identity`, `profile`, `encounter`, `membership`, `
|
|
90
|
-
`
|
|
138
|
+
`identity`, `profile`, `encounter`, `membership`, `message` —
|
|
139
|
+
`MESSAGE_TYPE`, `messageKeyOf`, `messageMac`, `messageProblem`,
|
|
140
|
+
`messageShapeOk` and the constants of Message Tasks 0.1 —,
|
|
141
|
+
`introduction`, `delivery`, `carrier-identity`, `carrier`,
|
|
142
|
+
`carrier-holder`), and two
|
|
91
143
|
namespaces of pure forms: `visibility` (anchor, star, group star,
|
|
92
144
|
continuity, acks) and `ceremony` (the encounter's, the group's and the
|
|
93
145
|
introduction's forms).
|
|
@@ -98,7 +150,7 @@ Other entry points:
|
|
|
98
150
|
|---|---|
|
|
99
151
|
| `./testing` | `InMemoryStore`, `memoryLog`, `scriptedEntropy`, `storeContract`, `emptyState`, `stateBuilder`, `freezeDeep`, `sampleState`, `openPromptModule`, the invariant checks, `forgeMapping` (deniability, Trust 6.1), `SCHEMAS` and the generated `wire` types. For tests, vectors and adapter authors; not for production holders. |
|
|
100
152
|
| `./internal` | The structural `HolderState`, `encodeState` and the codec chain, the engine's module types, the pure view functions, the modules' factories and pure reads. For the library's own modules and tests; not an app contract. |
|
|
101
|
-
| `./adapters/vti-mediator` | The VTI mediator as a carrier adapter: its submission states as `DeliveryReport`, collection and ack handling. |
|
|
153
|
+
| `./adapters/vti-mediator` | The VTI mediator as a carrier adapter: its submission states as `DeliveryReport`, collection and ack handling, the selective conclusion of a collection (`conclude(c, now, {keep})`, `concludable(result)`: a `failed(rate-limited)` item stays with the carrier). |
|
|
102
154
|
|
|
103
155
|
## The modules and the rules they implement
|
|
104
156
|
|
|
@@ -117,9 +169,10 @@ Bare four-digit numbers are RLTP-TRU rules; the other layers name theirs.
|
|
|
117
169
|
| `trust/continuity` | Trust §6a | `continuity-probe@1` and `continuity-mapping@1`, chaining a re-encounter into the existing relationship (6a.4) |
|
|
118
170
|
| `trust/profile`, `profile` | Trust §6b | `profile@1`: the one revision counter (6450), delivery on the class gates (6455), reception and the image bounds (6475) |
|
|
119
171
|
| `trust/duties` | Trust 2850, 6370, 6455, 6595, 6596 | the duties a commit leaves: class on, re-issue after a rotation, the lag rule |
|
|
120
|
-
| `membership`, `membership/holder` | Membership Tasks 0.
|
|
172
|
+
| `membership`, `membership/holder` | Membership Tasks 0.20 on Access 0.57 | founding (Access 3.4.1), the prelude (3.5: `membership-prelude-request/0.1`, `membership-prelude-reply/0.1`, the binding per relationship), invite, accept, admission within the bound of 3282 and welcome, evidence relay and `vouch@2` (Access 5.3), an in-library Access over the holder's groups |
|
|
173
|
+
| `message`, `message/holder` | Message Tasks 0.1 | `message@1`, `k_msg` and its MAC (3); sending on a ready, unblocked relationship with the sender lifetime (5); reception through the stages with the age and future bounds on the time mark, the completion record, the inbox taken over by the app, the rates and the inbox bound as `failed(rate-limited)` (4); the block of a relationship (6010–6030, 6510), its discard of messages and its treatment of invitations and prelude replies (Membership 3115, 3975), the holder's own offers refused (6410) |
|
|
121
174
|
| `introduction`, `introduction/holder` | Trust §8 on Delivery §4.4 | the Introduction Act in its three roles: request, forward, reply, the mediator's one ack at its declared delay, the vouchers; the requester's timeout at the act's expiry (8340; A20, spec follow-up 18: no ack timeout of 8690) |
|
|
122
|
-
| `receive`, `engine` | Delivery 0.
|
|
175
|
+
| `receive`, `engine` | Delivery 0.83 §5, §6.1, §6.2 | the sealed envelope and the two key classes, stages 1–9 once per envelope with the dispositions `discarded` and the transient `failed(rate-limited)`, the task register by full task URI, the completed-effect cache with stored acks, the outbox with the status trias, retry by backoff, give-up at the horizon, custody before the trias and the hand-over gate (`pendingTransport`, `mayHandOver`, `close`), ack retries apart from ack retention, the act journal |
|
|
123
176
|
| `carrier-identity`, `carrier`, `carrier-holder` | Identity §7a, Delivery §4.4, §5a, Identity §9.3 | the carrier-relationship principal, the carrier port's state machine, proofs, verdicts and recovery |
|
|
124
177
|
| `views`, `prompts` | — | the read model: contacts by entry (2120, 2140), groups, prompts, the delivery status |
|
|
125
178
|
|
|
@@ -144,23 +197,36 @@ A holder's state is pure JSON under a codec version. The Store port takes
|
|
|
144
197
|
the state as opaque JSON and gives it back; the library decodes it
|
|
145
198
|
(`decodeState`), the adapter never migrates.
|
|
146
199
|
|
|
147
|
-
- **Codec
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
200
|
+
- **Codec 3** is the format of 0.6.0 and the only one this library
|
|
201
|
+
reads. It holds the state of Message Tasks 0.1 (`messages`: the block,
|
|
202
|
+
the rates, the ready tuples, the completion record, the inbox), an
|
|
203
|
+
outbox item's sender lifetime (`expiresAt`) and `failed(task-expired)`,
|
|
204
|
+
the record of surfaced and the register of declined invitations, and
|
|
205
|
+
per stored ack (Delivery 0.83) why it counts as sent (`sentBy`:
|
|
206
|
+
`accepted`, `failed`, `horizon`, present exactly when `sent`), whether
|
|
207
|
+
the adapter holds it (`held`), and the duplicates' answers (`answers`,
|
|
208
|
+
`answerDue`). Its fixtures (`test/fixtures/state-v3*.json`,
|
|
209
|
+
deterministic runs of `test/fixtures/gen-state-v3.mjs`, reproduced in
|
|
210
|
+
`npm test`) cover a settled holder, one with work open (prompts, a
|
|
211
|
+
joining invite, duties, a rotation at step 2, a block and a declined
|
|
212
|
+
invitation), one with a tombstone, a revoked device and carrier entries,
|
|
213
|
+
and one with transport in custody (acks held, accepted, failed and
|
|
214
|
+
unsent, an answer due and one handed over, an own document held); each
|
|
215
|
+
decodes and re-encodes byte for byte.
|
|
216
|
+
- Codecs 1 and 2 (lib 0.4.0, 0.5.0) never held a rolled-out app's state:
|
|
217
|
+
they are read no more, a state of either is `codec-unknown`. A later
|
|
218
|
+
codec that must read codec 3 brings its validator, a pure migration from
|
|
219
|
+
it, and its own fixture with a migration test.
|
|
154
220
|
- A newer codec is refused as `codec-newer`, a codec without a validator
|
|
155
221
|
as `codec-unknown`; nothing is read best-effort.
|
|
156
|
-
- `schemas/holder-state-
|
|
222
|
+
- `schemas/holder-state-v3.schema.json` describes the codec as a
|
|
157
223
|
non-normative JSON Schema (published with the package). The type
|
|
158
|
-
`
|
|
224
|
+
`HolderStateV3` (`./internal`) is generated from it
|
|
159
225
|
(`scripts/build-holder-state-types.mjs`); the build holds it against the
|
|
160
226
|
library's `HolderState`, and the tests hold the schema against the
|
|
161
|
-
codec's validator on the fixtures and on mutations of them.
|
|
162
|
-
|
|
163
|
-
|
|
227
|
+
codec's validator on the fixtures and on mutations of them. Rules only
|
|
228
|
+
the codec states: a record's id equals its key, an envelope's `rkid`
|
|
229
|
+
equals its recipient's `keyAgreement`, and a set of strings is sorted.
|
|
164
230
|
|
|
165
231
|
**Writing a Store adapter.** Implement `read(): Promise<{state, version}>`
|
|
166
232
|
(a deep, independent copy; `null` state and version for an empty store) and
|
|
@@ -201,9 +267,10 @@ This package uses its own semver; the specification uses castings.
|
|
|
201
267
|
| identity | Identity 0.54 | recovery derivation (§5.3), service identities (§7) |
|
|
202
268
|
| encounter | Encounter 0.31, cards 0.25, credentials 0.26 | — |
|
|
203
269
|
| trust | Trust Layer 0.31 | — |
|
|
204
|
-
| membership | Membership Tasks 0.
|
|
270
|
+
| membership | Membership Tasks 0.20, Access 0.57 | the Access envelope (Membership 3.3: `access-operation/0.1` with `member.add` and the sealed welcome; this library sends its own `x-membership-welcome/0.1`); an admission prompt after the bound of RLTP-MT-3282; roster replication: a holder knows the members it admitted and the roster its welcome carried |
|
|
205
271
|
| introduction | Trust 0.31 §8 | how a requester learns the mediator's designator (8.3): this library's mediator sends `x-introduction-offer/0.1` |
|
|
206
|
-
| delivery | Delivery 0.
|
|
272
|
+
| delivery | Delivery 0.83 | transport adapters beyond `./adapters/vti-mediator`; the block of the Trust Layer's types (Message Tasks 6240: their treatments wait for the next casting of the Trust Layer) |
|
|
273
|
+
| message | Message Tasks 0.1 | holding a message unsent until its tuple is ready (5020): `sendMessage` answers `not-ready` and the app keeps the message; checking `replyTo` against the relationship's history (5120), which is the app's; multi-device (§9); `failed(task-expired)` for a message: reachable only with a retry horizon beyond P179D, which the engine does not admit (at most P90D), so an undelivered message ends as `failed(expired-by-adapter-policy)` |
|
|
207
274
|
| devices | Identity §5.5 | multi-device production: one writer per holder |
|
|
208
275
|
|
|
209
276
|
## The contract: the vectors
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { CarrierPrincipal, CarrierScopedIdentity } from '../carrier-identity.js';
|
|
2
|
-
import type { DeliveryReport,
|
|
2
|
+
import type { DeliveryReport, ReceiverRefusalCode, SubmissionRef } from '../ports.js';
|
|
3
|
+
import type { TransportEntry, TransportView } from '../engine.js';
|
|
4
|
+
import type { ReceiveResult } from '../results.js';
|
|
3
5
|
export type { ReceiverRefusalCode } from '../ports.js';
|
|
4
|
-
export declare const DECLARED: {
|
|
6
|
+
export declare const DECLARED: Readonly<{
|
|
5
7
|
readonly giveUpHorizonMs: number;
|
|
6
8
|
readonly statusHorizonMs: 60000;
|
|
7
9
|
readonly queueFloorCount: 64;
|
|
8
10
|
readonly queueFloorBytes: 1048576;
|
|
9
11
|
readonly maxQueueBytes: 16777216;
|
|
10
12
|
readonly duplicateWindowMs: number;
|
|
11
|
-
}
|
|
13
|
+
}>;
|
|
12
14
|
export type WireErrorKind = 'unreachable' | 'refused-retriable' | 'refused-admission' | 'oversize';
|
|
13
15
|
export declare class WireError extends Error {
|
|
14
16
|
kind: WireErrorKind;
|
|
@@ -57,6 +59,12 @@ export type SubmissionState = {
|
|
|
57
59
|
/** The ports' DeliveryReport for a document `digest` in adapter state `st`
|
|
58
60
|
* (Delivery §6.1): one-to-one, `late` and the refusal code carried over. */
|
|
59
61
|
export declare function deliveryReportOf(digest: string, st: SubmissionState): DeliveryReport;
|
|
62
|
+
/** Whether a receive outcome is terminal and its item may be concluded
|
|
63
|
+
* (Delivery 5a.8): every disposition but `failed(rate-limited)`, the one
|
|
64
|
+
* failure that is transient (RLTP-DEL-5820). An InfraError of the
|
|
65
|
+
* holder's store is transient as well (RLTP-DEL-5810): an item whose
|
|
66
|
+
* receive threw is kept, too. */
|
|
67
|
+
export declare function concludable(r: ReceiveResult): boolean;
|
|
60
68
|
export interface CollectedItem {
|
|
61
69
|
bytes: Uint8Array;
|
|
62
70
|
queueId: string;
|
|
@@ -75,6 +83,14 @@ export interface AckState {
|
|
|
75
83
|
}>;
|
|
76
84
|
pending: string[];
|
|
77
85
|
}
|
|
86
|
+
/** The holder's side of a hand-over (lib 0.6.0): the holder itself.
|
|
87
|
+
* handOver checks the entry and calls `start` inside the holder's queue;
|
|
88
|
+
* `start` re-checks the adapter's own state, starts the deposit
|
|
89
|
+
* synchronously and says whether it did. `closed` is read in `start`. */
|
|
90
|
+
export interface TransportGate {
|
|
91
|
+
handOver(entry: TransportEntry, when: number, start: () => boolean): Promise<boolean>;
|
|
92
|
+
readonly closed?: boolean;
|
|
93
|
+
}
|
|
78
94
|
export declare class MediatorCarrierAdapter {
|
|
79
95
|
#private;
|
|
80
96
|
get principal(): string;
|
|
@@ -96,10 +112,14 @@ export declare class MediatorCarrierAdapter {
|
|
|
96
112
|
* honest report exists, status() returns null — §6.1's own
|
|
97
113
|
* pre-report window, represented as absence, not as a value. */
|
|
98
114
|
submit(envelopeBytes: Uint8Array, rawNow: number): string;
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
|
|
115
|
+
/** Takes the holder's custody set (holder.pendingTransport, after a
|
|
116
|
+
* resume of this opening) and the holder as the gate: files every entry
|
|
117
|
+
* not yet filed under its digest (its envelope as JCS bytes; the give-up
|
|
118
|
+
* horizon from entry.since) and returns their SubmissionRefs; withdraws
|
|
119
|
+
* every filed submission still before the trias (no report, or
|
|
120
|
+
* awaiting-transport) whose digest the view does not name. Accepted and
|
|
121
|
+
* terminal submissions stay for their reports. */
|
|
122
|
+
reconcile(view: TransportView, gate: TransportGate, rawNow: number): SubmissionRef[];
|
|
103
123
|
/** The current state as the ports' DeliveryReport for holder.report(),
|
|
104
124
|
* or null while no honest report exists (and for an unknown id). A
|
|
105
125
|
* submission filed without a digest (submit) has no report form. */
|
|
@@ -137,9 +157,17 @@ export declare class MediatorCarrierAdapter {
|
|
|
137
157
|
to: 'delivered';
|
|
138
158
|
}>;
|
|
139
159
|
collect(rawNow: number): Collection;
|
|
160
|
+
/** Concludes a collection (profile §4, Delivery 5a.8): its items'
|
|
161
|
+
* digests become ack intent. `keep` names the items whose disposition
|
|
162
|
+
* is transient (Delivery RLTP-DEL-5810, 5820: `failed(rate-limited)`,
|
|
163
|
+
* or a transaction that could not commit, see `concludable`): they are
|
|
164
|
+
* not concluded and not acknowledged, they go back to the buffer and the
|
|
165
|
+
* next collect offers them again, and the mediator keeps its copy. */
|
|
140
166
|
conclude(collection: {
|
|
141
167
|
id: string;
|
|
142
|
-
}, rawNow: number
|
|
168
|
+
}, rawNow: number, opts?: {
|
|
169
|
+
keep?: readonly string[];
|
|
170
|
+
}): void;
|
|
143
171
|
ackState(): AckState;
|
|
144
172
|
advance(rawNow: number): void;
|
|
145
173
|
/** §5a.10 lifecycle boundary: after close, every state port is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vti-mediator.d.ts","sourceRoot":"","sources":["../../src/adapters/vti-mediator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vti-mediator.d.ts","sourceRoot":"","sources":["../../src/adapters/vti-mediator.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAItD,eAAO,MAAM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