@serfab/cadre-client 2.0.0 → 2.1.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/ADOPTING.md CHANGED
@@ -164,14 +164,21 @@ const invitation = await node.createOpenInvitation(sAppId, validForMs);
164
164
  await node.publishFormationInvite(invitation.token, sAppId, { expiresAtMs, strandId, totalUses: 1 });
165
165
  const token = node.encodeInvitation(await client.invitations.withBootstrap(invitation));
166
166
  // the link the app shares carries `token`
167
+
168
+ const ready = invitationReadinessStore(client, token); // bind it beside the QR code
167
169
  ```
168
170
 
169
171
  - **`withBootstrap`** replaces cadre-core's address list with the person's cadrons that reach from
170
172
  anywhere (preferred first, at most their `maxAddrs`). It never fails: on any problem it returns
171
173
  the invitation as it came.
172
- - **Readiness:** `invitationReadinessStore(client, strandId, { newStrand })`, with `newStrand: true`
173
- when this invitation founded the strand just now. Show "ready to hand out" only on `ready`; on
174
- `no-cadron`, say only this device can answer.
174
+ - **Readiness:** `invitationReadinessStore(client, token)` takes the encoded invitation and reports
175
+ whether another machine of the party can answer a join through it now, from cadre-core's probe of
176
+ the machines the invitation names. Show "ready to hand out" only on `ready`. On `waiting`, show
177
+ `missing` as the steps still outstanding ("being told about the conversation"), not a bare
178
+ spinner; it is the union over every machine the invitation names, so phrase it without naming one
179
+ machine, and an empty `missing` there means no machine answered at all. On `no-cadron` say only
180
+ this device can answer, and on `spent` that the invitation is expired or used up and the remedy is
181
+ a new one.
175
182
  - **The readable invitation:** `client.invitations.describe(token, link)`, behind a "What's in this
176
183
  invitation" control. Show `cadrons`: each machine as the cadre screen shows it (its label, its
177
184
  `presence` dot, "your machine" or, when `yours` is false, "not one of your machines"), with its
@@ -209,7 +216,8 @@ catalog; `retryable` says whether trying again can help.
209
216
  - [ ] The client created once, with `ownerKeyStore` and `preferences`.
210
217
  - [ ] The cadre screen: status dots, add with approval, remove after `planRemoval`, owner key backup, relays.
211
218
  - [ ] Incoming node-code links handed to a `nodeCodeInbox`; the screen takes them when it can prompt.
212
- - [ ] Invitations minted through `withBootstrap`; readiness shown with the right `newStrand`.
219
+ - [ ] Invitations minted through `withBootstrap`; readiness shown from the encoded token, with what
220
+ the machines are missing while it is `waiting`.
213
221
  - [ ] Error kinds in the app's string catalog.
214
222
  - [ ] No node code or invitation link in logs.
215
223
 
package/README.md CHANGED
@@ -84,7 +84,7 @@ await client.invitations.setPreferences({ preferred: [homePeerId], names: { [hom
84
84
  const inv = await node.createOpenInvitation(sAppId, validForMs);
85
85
  const token = node.encodeInvitation(await client.invitations.withBootstrap(inv));
86
86
 
87
- const ready = invitationReadinessStore(client, strandId, { newStrand: true }); // 'waiting' → 'ready'
87
+ const ready = invitationReadinessStore(client, token); // { state, missing }: 'waiting' → 'ready'
88
88
  const words = await client.invitations.describe(token, link); // per machine: presence, yours; per address: kind, host, port, included
89
89
  const edited = await client.invitations.rebootstrap(token, chosenAddrs); // the same invitation, the person's own list
90
90
  const plan = await client.invitations.bootstrapPlan(); // the list and its warnings, before minting
@@ -93,6 +93,7 @@ const plan = await client.invitations.bootstrapPlan(); // t
93
93
  `CadronPreferences`: `preferred` (peer ids, in order), `names`, `maxAddrs` (1–8, default 2),
94
94
  `thisDevice` (`'fallback'` default, `'always'`, `'never'`), `allowPrivate` (default false).
95
95
 
96
+
96
97
  ### Binding a store
97
98
 
98
99
  A store follows the Svelte store contract plus `get()`, and is reference-counted (it reads,
package/dist/model.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  * These are interfaces. `@serfab/cadre-client/sereus` implements them over a running
11
11
  * cadre-core node; an app's mock implements them over sample data.
12
12
  */
13
+ import type { FormationReadinessGap } from '@serfab/cadre-core';
13
14
  import type { CadreResult } from './result.js';
14
15
  import type { BootstrapPlan, CadronPreferences } from './bootstrap.js';
15
16
  import type { InvitationText } from './invitation-text.js';
@@ -192,14 +193,35 @@ export interface RelaysModel {
192
193
  set(addrs: string[]): Promise<CadreResult<void>>;
193
194
  }
194
195
  /**
195
- * Whether a new invitation can be handed out with this device about to go quiet:
196
- * - `ready`: another cadron holds the invitation's strand (one of its commits is held
197
- * elsewhere), so it can answer a join without this device;
198
- * - `waiting`: not yet (a new strand's copy reaches a cadron a second or two after the
199
- * invitation is made);
200
- * - `no-cadron`: no other cadron serves the party's strands; only this device answers.
196
+ * What a machine of the party is missing before it could answer a join through an invitation,
197
+ * as cadre-core's probe names it (`docs/strands/formation.md` → "Whether a named machine can
198
+ * answer yet"). Re-exported so a screen can label the gaps without importing cadre-core.
201
199
  */
202
- export type InvitationReadiness = 'ready' | 'waiting' | 'no-cadron';
200
+ export type { FormationReadinessGap };
201
+ /**
202
+ * Whether a new invitation can be handed out with this device about to go quiet. cadre-core
203
+ * asks each machine the invitation names whether it could answer a redemption of it right now
204
+ * (`CadreNode.readInvitationReadiness`); this is that report as one answer about the invitation.
205
+ */
206
+ export interface InvitationReadiness {
207
+ /**
208
+ * - `ready`: another of the party's machines can answer a join through this invitation now,
209
+ * so this device may go quiet;
210
+ * - `waiting`: none of them can yet, and `missing` says what they lack;
211
+ * - `no-cadron`: the invitation names no machine but this one, so only this device can ever
212
+ * answer it. Waiting changes nothing: stay open until the guest joins, or add a machine
213
+ * that stays on and make a new invitation;
214
+ * - `spent`: the invitation is expired or used up, so no machine will answer it; the remedy
215
+ * is a new invitation.
216
+ */
217
+ state: 'ready' | 'waiting' | 'no-cadron' | 'spent';
218
+ /**
219
+ * What the other machines are missing, each gap once, in the order they reported it. Empty
220
+ * unless `state` is `waiting` — and empty there too when no machine answered the probe at
221
+ * all (unreachable, or too busy to decide), which a later probe may change.
222
+ */
223
+ missing: readonly FormationReadinessGap[];
224
+ }
203
225
  /**
204
226
  * What goes into an invitation, and whether it is ready to hand out. The app mints the
205
227
  * invitation (cadre-core's `createOpenInvitation`), passes it through `withBootstrap` before
@@ -219,13 +241,16 @@ export interface InvitationsModel {
219
241
  bootstrap: string[];
220
242
  }>(invitation: T): Promise<T>;
221
243
  /**
222
- * `newStrand`: the invitation founded this strand just now. Its copy reaches a cadron only once
223
- * a commit of it is held there (the signal waited for). An established strand counts as ready
224
- * when another cadron serves it.
244
+ * Whether another machine can answer a join through this invitation now. The encoded
245
+ * invitation, not a strand id: half the question is whether that invitation's own record has
246
+ * reached the machine that would answer.
247
+ *
248
+ * Synchronous, over a cache per token: the first read for a token starts cadre-core's probe
249
+ * and answers `waiting`, and `changes.invitations` fires when an answer differs from the one
250
+ * before. While an answer stays `waiting` the probe repeats on cadre-core's own ladder, and
251
+ * only while something is watching, so a subscribed store sees `waiting` turn `ready`.
225
252
  */
226
- readiness(strandId: string, opts?: {
227
- newStrand?: boolean;
228
- }): InvitationReadiness;
253
+ readiness(token: string): InvitationReadiness;
229
254
  /**
230
255
  * An invitation in words, from its encoded form. `link`: the text actually shared (the URL the
231
256
  * QR code carries), for its length; the token's length otherwise. Its addresses grouped by
package/dist/model.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAqRA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE/C,MAAM,UAAU,cAAc,CAAC,OAAuD,EAAE,MAAc,IAAI,CAAC,GAAG,EAAE;IAC/G,IAAI,OAAO,CAAC,SAAS;QAAE,OAAO,WAAW,CAAC;IAC1C,IAAI,OAAO,CAAC,UAAU,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAClD,OAAO,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,gBAAgB,CAAC,YAAoB;IACpD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,MAAc;IACzC,OAAO,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7D,CAAC"}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAiTA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE/C,MAAM,UAAU,cAAc,CAAC,OAAuD,EAAE,MAAc,IAAI,CAAC,GAAG,EAAE;IAC/G,IAAI,OAAO,CAAC,SAAS;QAAE,OAAO,WAAW,CAAC;IAC1C,IAAI,OAAO,CAAC,UAAU,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAClD,OAAO,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,gBAAgB,CAAC,YAAoB;IACpD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,MAAc;IACzC,OAAO,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7D,CAAC"}
@@ -27,7 +27,7 @@ export interface CadreClient extends CadreView, ReachabilityView, InvitationsVie
27
27
  /** What an invitation names, whether it is ready to hand out, and what it says in words. */
28
28
  invitations: InvitationsModel;
29
29
  changes: {
30
- /** Cadron preferences changed, or a cadron came to hold a strand (readiness). */
30
+ /** Cadron preferences changed, or an invitation's readiness did (a probe answered differently). */
31
31
  invitations(onChange: () => void): () => void;
32
32
  /**
33
33
  * A cadron left the cadre: removed through this client, or found gone when the machine list is
@@ -9,14 +9,14 @@
9
9
  * which is all there is in the minute before the cadron's first record arrives. cadre-core's
10
10
  * own invitation leaves such a cadron out altogether.
11
11
  *
12
- * READINESS. A new strand's copy is on a cadron once a commit of the strand is held elsewhere
13
- * (`strand:commit-held`, or a commit reported `heldElsewhere`). The cadron may still be starting
14
- * then, but it holds the strand's data and finishes starting on its own. Its `StrandPeer` row is
15
- * not enough: it is written before the cadron's copy is live, and a join answered by a cadron
16
- * whose copy is not live is refused `host-strand-unavailable`.
17
- * WORKAROUND(sereus: a readiness signal for an invitation): read from commit durability.
12
+ * READINESS comes from cadre-core's probe of the machines an invitation names
13
+ * (`CadreNode.readInvitationReadiness`), which asks each of them whether it could answer a
14
+ * redemption of that invitation right now. Nothing here infers it from replication: this module
15
+ * keeps the probe's answer per token, asks again on cadre-core's ladder while the answer is
16
+ * still `waiting`, and reports which of the five things the machines said they are missing.
18
17
  */
19
18
  import { multiaddr } from '@multiformats/multiaddr';
19
+ import { nextFormationReadyPoll } from '@serfab/cadre-core';
20
20
  import { CADRON_PREFERENCES_FORMAT, normalizePreferences, planBootstrap } from '../bootstrap.js';
21
21
  import { describeInvitation, destinationPeerId } from '../invitation-text.js';
22
22
  import { cadreAttempt, CadreFailure, describeThrown, withTimeout } from '../result.js';
@@ -30,6 +30,40 @@ function withPeer(addr, peerId) {
30
30
  return addr;
31
31
  }
32
32
  }
33
+ /** The answer before a probe has landed, and when there is no node to probe with. */
34
+ const NOT_YET = { state: 'waiting', missing: [] };
35
+ /** Each gap the OTHER machines reported, once, in the order they reported it. */
36
+ function missingAcross(machines) {
37
+ const gaps = new Set();
38
+ for (const machine of machines) {
39
+ if (!machine.self)
40
+ for (const gap of machine.gaps)
41
+ gaps.add(gap);
42
+ }
43
+ return [...gaps];
44
+ }
45
+ /**
46
+ * cadre-core's per-machine report as one answer about the invitation.
47
+ *
48
+ * `spent` is read first: a machine holding the invitation's record and reading it dead settles
49
+ * the question, and a gap another machine reports cannot change that. `no-cadron` is the
50
+ * invitation naming no machine but this one, which is settled too — the machines probed are the
51
+ * ones its bootstrap list names, and that list cannot grow after minting.
52
+ */
53
+ function readinessOf(report) {
54
+ if (report.machines.some(m => m.outcome === 'spent'))
55
+ return { state: 'spent', missing: [] };
56
+ if (report.answerable)
57
+ return { state: 'ready', missing: [] };
58
+ if (!report.machines.some(m => !m.self))
59
+ return { state: 'no-cadron', missing: [] };
60
+ return { state: 'waiting', missing: missingAcross(report.machines) };
61
+ }
62
+ /** Two answers a screen would render identically, so the change signal can stay quiet. */
63
+ function sameReadiness(a, b) {
64
+ return a !== null && a.state === b.state && a.missing.length === b.missing.length
65
+ && a.missing.every((gap, i) => gap === b.missing[i]);
66
+ }
33
67
  export function createInvitations({ host, machines, controlReadMs, log }) {
34
68
  const listeners = new Set();
35
69
  const changed = () => { for (const l of [...listeners])
@@ -58,32 +92,125 @@ export function createInvitations({ host, machines, controlReadMs, log }) {
58
92
  // Writes one after another: each merges into the result of the one before, so two changes made
59
93
  // in quick succession (two stars) both stay.
60
94
  let writing = Promise.resolve();
61
- // Strands with a commit held elsewhere this session.
62
- const held = new Set();
63
- const markHeld = (strandId) => {
64
- if (held.has(strandId))
95
+ // Readiness per encoded invitation: what cadre-core's probe last answered, read in the
96
+ // background and cached. Per token, because half of what it answers is whether that
97
+ // invitation's own record has reached the machine that would answer a join through it.
98
+ // NOTE: one ladder per token, and nothing coalesces two tokens of the same party — each costs
99
+ // one small control request per machine the invitation names, at most four a minute once the
100
+ // ladder tops out. Fine for an invitation screen, which shows one. If an app ever shows a list
101
+ // of pending invitations, share one ladder across them.
102
+ // NOTE: an entry is never evicted, so a session holds one small object per token it has read.
103
+ // A token is only ever re-minted by `rebootstrap`, so that is one per address the person
104
+ // toggled. If an app ever reads readiness for tokens it mints in a loop, evict by last read.
105
+ const probes = new Map();
106
+ /** `waiting` is the only answer a further probe can change. */
107
+ const settled = (probe) => probe.answer !== null && probe.answer.state !== 'waiting';
108
+ /**
109
+ * cadre-core's probe for an encoded invitation, as a promise even for a token that will not decode.
110
+ *
111
+ * NOTE: no `withTimeout` here, unlike the control reads below. cadre-core bounds each dial it
112
+ * makes, and a probe that outran a bound of ours would still be in flight behind it; the one
113
+ * unbounded leg is its read of this machine's own control database. A probe that never settles
114
+ * leaves the token reading `waiting` with its ladder stopped. Bound it here if that is ever seen.
115
+ */
116
+ async function askReadiness(node, token) {
117
+ return await node.readInvitationReadiness(node.decodeInvitation(token));
118
+ }
119
+ /** The cached probe for `token`, carrying its ladder on before the answer is read. */
120
+ function probeFor(node, token) {
121
+ const probe = probes.get(token) ?? { answer: null, asks: 0, asking: false, timer: null, at: 0 };
122
+ probes.set(token, probe);
123
+ ladder(node, token, probe);
124
+ return probe;
125
+ }
126
+ /**
127
+ * Ask again while the answer is still `waiting`, each ask no sooner than cadre-core's own
128
+ * ladder allows (`nextFormationReadyPoll`: two seconds doubling to fifteen) — the one cadence
129
+ * there is, so the client adds none of its own. An ask the ladder allows now is made at once,
130
+ * which is what answers the first read for a token. A later one is scheduled only while
131
+ * something is watching, because an answer nothing listens for has nowhere to go; the next
132
+ * read, or the next listener, picks the ladder up where it stopped.
133
+ */
134
+ function ladder(node, token, probe) {
135
+ if (probe.asking || probe.timer !== null || settled(probe))
136
+ return;
137
+ const waitMs = Math.max(0, probe.at + nextFormationReadyPoll(probe.asks) - Date.now());
138
+ if (waitMs === 0) {
139
+ ask(node, token, probe);
65
140
  return;
66
- held.add(strandId);
67
- changed();
68
- };
69
- host.node.on('strand:commit-durability', d => { if (d.heldElsewhere)
70
- markHeld(d.strandId); });
71
- host.node.on('strand:commit-held', d => markHeld(d.strandId));
72
- // Established strands: how many other cadrons serve each (their `StrandPeer` rows), read in
73
- // the background and cached; null while unknown.
74
- const serving = new Map();
75
- function servingOthers(node, strandId) {
76
- if (!serving.has(strandId)) {
77
- serving.set(strandId, null);
78
- const self = node.peerId?.toString();
79
- void withTimeout(node.getControlDatabase()?.queryStrandPeers(strandId) ?? Promise.resolve([]), controlReadMs, 'queryStrandPeers')
80
- .then(rows => { serving.set(strandId, rows.filter(r => r.peerId !== self && r.role === null).length); changed(); })
81
- .catch(() => { serving.delete(strandId); });
82
141
  }
83
- return serving.get(strandId) ?? null;
142
+ if (listeners.size === 0)
143
+ return;
144
+ probe.timer = setTimeout(() => {
145
+ probe.timer = null;
146
+ if (probes.get(token) === probe && listeners.size > 0)
147
+ ladder(node, token, probe);
148
+ }, waitMs);
84
149
  }
85
- // A cadron coming or going changes who serves: forget the cached counts.
86
- host.node.on('control:connected', () => { serving.clear(); changed(); });
150
+ /** Cancel a scheduled re-ask, so no timer outlives what wanted its answer. */
151
+ function unschedule(probe) {
152
+ if (probe.timer === null)
153
+ return;
154
+ clearTimeout(probe.timer);
155
+ probe.timer = null;
156
+ }
157
+ function ask(node, token, probe) {
158
+ probe.asking = true;
159
+ void askReadiness(node, token).then(report => keep(node, token, probe, readinessOf(report)), err => {
160
+ // A failed read forgets its entry: the next read asks again, and a failure is never
161
+ // reported as an answer. Never log the token itself.
162
+ // NOTE: forgetting also drops the ladder's backoff, so a probe that keeps throwing is
163
+ // re-asked — and warns — once per read rather than on a climbing gap. Reads are driven
164
+ // by the change signal, so that is bounded in practice. If a persistent failure ever
165
+ // shows up as a run of warnings, keep the entry and carry `asks` on instead of deleting.
166
+ if (probes.get(token) === probe)
167
+ probes.delete(token);
168
+ log.warn('[cadre-client] an invitation\'s readiness could not be read:', describeThrown(err));
169
+ });
170
+ }
171
+ /**
172
+ * Keep what a probe answered, and tell the app only when it differs from the answer before:
173
+ * the ladder asks every couple of seconds while a machine is still catching up, and a screen
174
+ * has nothing to re-render for an unchanged answer.
175
+ */
176
+ function keep(node, token, probe, answer) {
177
+ if (probes.get(token) !== probe)
178
+ return; // forgotten while the probe was in flight
179
+ const differs = !sameReadiness(probe.answer, answer);
180
+ probe.asking = false;
181
+ probe.asks += 1;
182
+ probe.at = Date.now();
183
+ if (differs) {
184
+ probe.answer = answer;
185
+ changed();
186
+ }
187
+ ladder(node, token, probe);
188
+ }
189
+ /** Something is watching again: carry on every ladder that stopped for want of a listener. */
190
+ function resumeLadders() {
191
+ const node = host.node.node;
192
+ if (!node)
193
+ return;
194
+ for (const [token, probe] of probes)
195
+ ladder(node, token, probe);
196
+ }
197
+ /** Put every token still waiting back at the foot of the ladder, so the next read asks at once. */
198
+ function restartLadders() {
199
+ for (const probe of probes.values()) {
200
+ if (settled(probe))
201
+ continue;
202
+ unschedule(probe);
203
+ probe.asks = 0;
204
+ probe.at = 0;
205
+ }
206
+ }
207
+ // A cadron coming or going may make a machine an invitation names reachable for the probe: ask
208
+ // again at once for the tokens still waiting. A settled answer is KEPT, where the serving counts
209
+ // this replaced were cleared wholesale: `ready` would otherwise read `waiting` again until the
210
+ // re-probe landed, so a screen already telling the person they may close the app would take it
211
+ // back for a second or two. Nor can a connection change the other two — `spent` is permanent,
212
+ // and `no-cadron` is the invitation's own bootstrap list, which does not grow after minting.
213
+ host.node.on('control:connected', () => { restartLadders(); changed(); });
87
214
  async function candidates(node) {
88
215
  const machines = await withTimeout(node.listMachines(), controlReadMs, 'listMachines').catch(() => []);
89
216
  const claimed = node.getBootstrapPeerStore()?.all() ?? new Map();
@@ -152,18 +279,15 @@ export function createInvitations({ host, machines, controlReadMs, log }) {
152
279
  return invitation;
153
280
  }
154
281
  },
155
- readiness(strandId, opts = {}) {
156
- if (held.has(strandId))
157
- return 'ready';
282
+ readiness(token) {
158
283
  const node = host.node.node;
284
+ // NOTE: with no node the question is dropped rather than remembered, so a store built
285
+ // while the node is stopped reads `waiting` until something else fires the change signal.
286
+ // Harmless as apps use it — a token exists only because a running node minted it. If an
287
+ // app ever reads readiness for a token it kept across a restart, queue the token here.
159
288
  if (!node)
160
- return 'waiting';
161
- const others = servingOthers(node, strandId);
162
- if (opts.newStrand)
163
- return others === 0 ? 'no-cadron' : 'waiting';
164
- if (others === null)
165
- return 'waiting';
166
- return others > 0 ? 'ready' : 'no-cadron';
289
+ return NOT_YET;
290
+ return probeFor(node, token).answer ?? NOT_YET;
167
291
  },
168
292
  describe: (token, link) => cadreAttempt(async () => {
169
293
  const node = requireNode();
@@ -190,7 +314,20 @@ export function createInvitations({ host, machines, controlReadMs, log }) {
190
314
  };
191
315
  return {
192
316
  invitations,
193
- onChange(listener) { listeners.add(listener); return () => listeners.delete(listener); },
317
+ onChange(listener) {
318
+ listeners.add(listener);
319
+ if (listeners.size === 1)
320
+ resumeLadders();
321
+ return () => {
322
+ listeners.delete(listener);
323
+ // Nothing is watching: stop the ladders here rather than leave timers to fire into an
324
+ // empty listener set — under Node one would hold the process open for up to fifteen
325
+ // seconds. The next read, or the next listener, picks each one up where it stopped.
326
+ if (listeners.size === 0)
327
+ for (const probe of probes.values())
328
+ unschedule(probe);
329
+ };
330
+ },
194
331
  };
195
332
  }
196
333
  //# sourceMappingURL=invitations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"invitations.js","sourceRoot":"","sources":["../../src/sereus/invitations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,aAAa,EAAgD,MAAM,iBAAiB,CAAC;AAC/I,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGvF,wHAAwH;AACxH,SAAS,QAAQ,CAAC,IAAY,EAAE,MAAc;IAC7C,IAAI,CAAC;QACJ,MAAM,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,EAAE,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WA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MAAM,IAAI,YAAY,CAAC,iBAAiB,EAAE,iDAAiD,CAAC,CAAC;YACzI,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACnG,CAAC,CAAC;KACF,CAAC;IAEF,OAAO;QACN,WAAW;QACX,QAAQ,CAAC,QAAQ;YAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC;gBAAE,aAAa,EAAE,CAAC;YAC1C,OAAO,GAAG,EAAE;gBACX,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC3B,sFAAsF;gBACtF,oFAAoF;gBACpF,oFAAoF;gBACpF,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC;oBAAE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE;wBAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAClF,CAAC,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC"}
package/dist/stores.d.ts CHANGED
@@ -29,9 +29,10 @@ export declare function cadreStore(view: CadreView, opts?: StoreOptions): Loader
29
29
  */
30
30
  export declare function reachabilityStore(view: ReachabilityView, opts?: StoreOptions): Loader<Reachability>;
31
31
  /**
32
- * Whether a new invitation to `strandId` is ready to hand out (`InvitationReadiness`), live: it
33
- * turns `ready` when a cadron comes to hold the strand.
32
+ * Whether the invitation `token` is ready to hand out (`InvitationReadiness`), live: it turns
33
+ * `ready` once one of the machines the invitation names can answer a join through it, and until
34
+ * then says what those machines are missing. The answer comes from cadre-core's probe of those
35
+ * machines, which the model asks in the background and asks again on its own ladder while the
36
+ * answer is still `waiting`; this store re-reads each time one lands.
34
37
  */
35
- export declare function invitationReadinessStore(view: InvitationsView, strandId: string, opts?: {
36
- newStrand?: boolean;
37
- }): Readable<InvitationReadiness>;
38
+ export declare function invitationReadinessStore(view: InvitationsView, token: string): Readable<InvitationReadiness>;
package/dist/stores.js CHANGED
@@ -32,11 +32,14 @@ export function reachabilityStore(view, opts = {}) {
32
32
  });
33
33
  }
34
34
  /**
35
- * Whether a new invitation to `strandId` is ready to hand out (`InvitationReadiness`), live: it
36
- * turns `ready` when a cadron comes to hold the strand.
35
+ * Whether the invitation `token` is ready to hand out (`InvitationReadiness`), live: it turns
36
+ * `ready` once one of the machines the invitation names can answer a join through it, and until
37
+ * then says what those machines are missing. The answer comes from cadre-core's probe of those
38
+ * machines, which the model asks in the background and asks again on its own ladder while the
39
+ * answer is still `waiting`; this store re-reads each time one lands.
37
40
  */
38
- export function invitationReadinessStore(view, strandId, opts = {}) {
39
- const read = () => view.invitations.readiness(strandId, opts);
41
+ export function invitationReadinessStore(view, token) {
42
+ const read = () => view.invitations.readiness(token);
40
43
  return writable(read(), set => {
41
44
  set(read());
42
45
  return view.changes.invitations(() => set(read()));
@@ -1 +1 @@
1
- {"version":3,"file":"stores.js","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;AAQlD;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAe,EAAE,OAAqB,EAAE;IAClE,OAAO,MAAM,CAAC;QACb,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QAC/B,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;QACjD,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,MAAM;KAC7B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,i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AAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;QACjD,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,MAAM;KAC7B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAsB,EAAE,OAAqB,EAAE;IAChF,OAAO,MAAM,CAAC;QACb,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;QACxD,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC;QACxD,UAAU,EAAE,GAAG;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,MAAM;KAC7B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAqB,EAAE,KAAa;IAC5E,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrD,OAAO,QAAQ,CAAsB,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE;QAClD,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -2,23 +2,23 @@
2
2
  * Example (React Native): beside an invitation the app has just minted. Copy and adapt; it is not
3
3
  * built or published.
4
4
  *
5
- * - Whether it is ready to hand out: a cadron holds the strand, so it can answer a join while
6
- * this phone sleeps (`invitationReadinessStore`).
5
+ * - Whether it is ready to hand out: one of the machines the invitation names can answer a join
6
+ * through it while this phone sleeps (`invitationReadinessStore`), and what the machines are
7
+ * still missing while it cannot.
7
8
  * - "What's in this invitation": the machines it names, as the cadre screen shows them, each
8
9
  * address a checkbox. The other addresses it could name are unchecked; checking or unchecking
9
10
  * one re-encodes this invitation (`invitations.rebootstrap`) and hands the app the new token.
10
11
  * - The QR code, which a tap opens full screen (dark on white, the largest the screen allows).
11
12
  *
12
13
  * Props: `token` is what `node.encodeInvitation(...)` returned (after `invitations.withBootstrap`),
13
- * `link` the text actually shared (the URL the QR code carries), `strandId` the invitation's strand,
14
- * `newStrand` true when the invitation founded it just now. `onRebootstrap`: the person changed its
15
- * addresses; the app rebuilds its link and QR code from the new token, and keeps it with the
14
+ * `link` the text actually shared (the URL the QR code carries). `onRebootstrap`: the person changed
15
+ * its addresses; the app rebuilds its link and QR code from the new token, and keeps it with the
16
16
  * invitation. A link already handed out still works, with the addresses it had.
17
17
  */
18
18
  import React, { useEffect, useMemo, useState } from 'react';
19
19
  import { Modal, Pressable, StyleSheet, Text, useWindowDimensions, View } from 'react-native';
20
20
  import QRCode from 'react-native-qrcode-svg';
21
- import { invitationReadinessStore, type CadronPresence, type InvitationText } from '@serfab/cadre-client';
21
+ import { invitationReadinessStore, type CadronPresence, type FormationReadinessGap, type InvitationReadiness, type InvitationText } from '@serfab/cadre-client';
22
22
  import type { CadreClient } from '@serfab/cadre-client/sereus';
23
23
  import { useStore } from './useStore';
24
24
 
@@ -26,16 +26,27 @@ interface Props {
26
26
  client: CadreClient;
27
27
  token: string;
28
28
  link: string;
29
- strandId: string;
30
- newStrand: boolean;
31
29
  onRebootstrap(token: string): void;
32
30
  }
33
31
 
34
- const READINESS = {
32
+ const READINESS: Record<InvitationReadiness['state'], string> = {
35
33
  ready: 'Ready to hand out: your machine can answer even while this phone sleeps.',
36
- waiting: 'Getting ready to hand out… your machine is taking a copy of the conversation.',
34
+ waiting: 'Not ready to hand out yet: no other machine of yours can let them in on its own.',
37
35
  'no-cadron': 'Only this phone can answer it: keep the app open until they join, or add a machine that stays on.',
38
- } as const;
36
+ spent: 'This invitation can no longer be used: it has expired, or it has been used up. Make a new one.',
37
+ };
38
+
39
+ // Each thing a machine can still be missing, as the step the person is waiting for. Showing these
40
+ // is the point of the record: "its own copy of the conversation" is progress, where a bare spinner
41
+ // is not. Phrased without a subject, because `missing` is the union over every machine the
42
+ // invitation names, not one machine's list.
43
+ const MISSING: Record<FormationReadinessGap, string> = {
44
+ 'invitation-record': 'being told about this invitation',
45
+ 'strand-record': 'being told about the conversation',
46
+ 'membership-key': 'a key for the conversation, to sign your guest in',
47
+ 'strand-runtime': 'running the conversation',
48
+ 'strand-database': 'its own copy of the conversation',
49
+ };
39
50
 
40
51
  const KIND = {
41
52
  public: 'public address', name: 'public name', relay: 'relayed', webrtc: 'relayed, then direct if possible',
@@ -55,18 +66,35 @@ function fromNow(iso: string): string {
55
66
  return hours >= 48 ? `in ${Math.round(hours / 24)} days` : hours >= 1 ? `in ${hours} hours` : 'within the hour';
56
67
  }
57
68
 
58
- export function InvitationPanel({ client, token, link, strandId, newStrand, onRebootstrap }: Props) {
59
- const store = useMemo(() => invitationReadinessStore(client, strandId, { newStrand }), [client, strandId, newStrand]);
69
+ export function InvitationPanel({ client, token, link, onRebootstrap }: Props) {
70
+ const store = useMemo(() => invitationReadinessStore(client, token), [client, token]);
60
71
  const readiness = useStore(store);
61
72
  return (
62
73
  <View style={styles.panel}>
63
74
  <InvitationQr value={link} />
64
- <Text style={readiness === 'ready' ? styles.ready : styles.muted}>{READINESS[readiness]}</Text>
75
+ <Readiness readiness={readiness} />
65
76
  <InvitationDetails client={client} token={token} link={link} onRebootstrap={onRebootstrap} />
66
77
  </View>
67
78
  );
68
79
  }
69
80
 
81
+ /** Why it is not ready, when the machines said: a person waiting wants the reason, not a spinner. */
82
+ function waitingDetail(missing: InvitationReadiness['missing']): string {
83
+ return missing.length === 0
84
+ ? 'None of the machines it names has answered: one may be offline, or still starting.'
85
+ : `Still needed on the machines it names: ${missing.map(gap => MISSING[gap]).join('; ')}.`;
86
+ }
87
+
88
+ function Readiness({ readiness }: { readiness: InvitationReadiness }) {
89
+ const tone = readiness.state === 'ready' ? styles.ready : readiness.state === 'spent' ? styles.spent : styles.muted;
90
+ return (
91
+ <View>
92
+ <Text style={tone}>{READINESS[readiness.state]}</Text>
93
+ {readiness.state === 'waiting' && <Text style={styles.muted}>{waitingDetail(readiness.missing)}</Text>}
94
+ </View>
95
+ );
96
+ }
97
+
70
98
  function InvitationDetails({ client, token, link, onRebootstrap }: Pick<Props, 'client' | 'token' | 'link' | 'onRebootstrap'>) {
71
99
  const [open, setOpen] = useState(false);
72
100
  const [text, setText] = useState<InvitationText | null>(null);
@@ -157,6 +185,7 @@ const styles = StyleSheet.create({
157
185
  dot: { width: 8, height: 8, borderRadius: 4 },
158
186
  title: { fontWeight: '600' },
159
187
  ready: { color: '#2c8a3f' },
188
+ spent: { color: '#b3261e' },
160
189
  muted: { color: '#777777' },
161
190
  link: { color: '#0066cc' },
162
191
  });