@dharma-ai-labs/agent-fabric-relay-client 0.2.38 → 0.2.40

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/README.md CHANGED
@@ -95,6 +95,201 @@ ordinary authentication/audit record. Report that effect separately from source,
95
95
  plan and credential mutations. Unavailable or inconsistent protected identity
96
96
  fails closed instead of enrolling or generating a replacement key.
97
97
 
98
+ ## How long one signed relay request holds device signing control
99
+
100
+ Every signed request is signed, written to the local outbox, sent and
101
+ acknowledged while the device signing control for its origin, organization,
102
+ device and OS user is held. While one caller holds it, no other caller that
103
+ takes signing control signs or sends a request. Each hold that the client or
104
+ the admission line takes makes at most one network send. When a request sends
105
+ another kept request before its own (its client's own earlier call, or another
106
+ entry's request to make room in a full file), that hold ends after that send,
107
+ and the request is signed and sent in a fresh hold, after every caller that
108
+ waited meanwhile. The relay workspace loops' admission line hands its hold back
109
+ in the same way, and so does a caller that holds signing control itself around
110
+ one signed call (the CLI's workspace policy sync) when it takes it with
111
+ `withSigningControlPerSend`: that caller's work then runs again in a fresh hold
112
+ before its own request is signed. A hold that a caller takes itself without
113
+ `withSigningControlPerSend` keeps its work in that hold, and the client adds no
114
+ send of its own to it: it sends no other entry's request there to make room,
115
+ and a full file refuses the caller's request
116
+ (`relay_protocol_state_outbox_full`), as before; after it sends its own earlier
117
+ kept call there, the caller's request fails with `relay_retry_after_recovery`,
118
+ unsent, and a retry signs and sends it in a hold of its own. A session open
119
+ (`openSession`) in a hold its caller took itself, with or without
120
+ `withSigningControlPerSend`, adds no send of its own either: it sends no other
121
+ entry's request there; after it sends its own earlier kept call there, a
122
+ `withSigningControlPerSend` hold is handed back and the session opens in a
123
+ fresh hold, and in any other hold the session open fails with
124
+ `relay_retry_after_recovery`; and a taken-over action acknowledgement that it
125
+ signs again is sent after that hold ends, in a hold of its own. Until then,
126
+ another call on that client is neither signed nor sent and fails with
127
+ `relay_retry_after_recovery`, so it never takes the acknowledgement's place in
128
+ the client's outbox entry; a retry after that hold signs and sends it. Such a hold makes
129
+ one send for each signed call its caller makes in it, so a caller that holds
130
+ signing control across several calls holds it across several sends. The CLI
131
+ takes no such hold around a protocol-state request: the named session
132
+ activation boundary takes only the workspace skill activation lock, and each
133
+ signed call in a named session's turn takes a hold of its own. Every write of the local
134
+ protocol state (the outbox, the session and recovered task completions)
135
+ happens under the device signing control and starts from the latest file, so
136
+ clients on one device never overwrite each other's kept requests or
137
+ completions when every process on the device runs this version. A process of
138
+ an earlier version still writes the whole file from its own copy and does not
139
+ read the per-client outbox entries described below. The relay upgrade stops
140
+ the relay before it switches versions, but a command of the earlier version
141
+ that is still running can overwrite the file until it exits.
142
+
143
+ Only the owner of a session — the process that opened it, or a restarted
144
+ process with the same owner key for its own kept request only — signs in it,
145
+ from the sequence it holds in memory: no client reads another's session or
146
+ sequence from the file, and a restarted process with the same owner key opens a
147
+ session of its own for every other request. Every
148
+ other client sends a kept request only exactly as signed: every signed header
149
+ (message id, session, sequence, idempotency key, time, nonce and signature) and
150
+ the body byte for byte. The server refuses a signature older than 5 minutes, so
151
+ another client never sends a kept request signed more than 4 minutes ago: it
152
+ stays in its entry, unsent and with its outcome unknown, for its owner. Only the
153
+ client with that entry's owner key (its process, or a restarted process with
154
+ the same owner key) sends its own kept request again with a new time and
155
+ signature, and only with the same message id, session, sequence, body and
156
+ idempotency key. An earlier version reads only one
157
+ kept request, at the top level of the file, and gives one signed more than 4
158
+ minutes ago a new time and signature. Every write of this version copies
159
+ there, exactly as signed, the oldest kept request that is already due (see
160
+ below) and that another client may send unchanged. Any other entry is due only
161
+ after it stood unchanged for 10 minutes, so in practice the copy is a request a
162
+ command signed within the last 4 minutes before it exited. A live client's
163
+ fresh request, a request signed more than 4 minutes ago, a session open, poll or
164
+ read, and an action acknowledgement are never copied. Each later write
165
+ of this version drops the copy once it is 4 minutes old. This version never
166
+ sends that copy on its own. After a rollback to an earlier version, the first
167
+ session open of that version sends the copied request again, with the same
168
+ message id, byte for byte when it runs within 4 minutes of that signature, and
169
+ then writes a file without the per-client entries. When no write of this
170
+ version came between and the rollback is later, that version signs the
171
+ request again in the exited command's session, where no process of this
172
+ version signs any more. A rollback
173
+ loses at most the rest: every other kept request, whose outcome then stays
174
+ unknown, and the completion receipts that wait in an entry (see below).
175
+
176
+ Each client keeps its own outbox entry in the protocol-state file: its
177
+ session, its next sequence and at most one kept request. A relay workspace
178
+ loop uses one entry per workspace, and every other client gets an entry of its
179
+ own. A client signs and replays the kept request in its own entry, in its own
180
+ session, so another client's kept request never delays, fails or answers its
181
+ calls. Another client sends that request only in the cases below: once its
182
+ owner process has exited, or once its entry has stood unchanged for 10
183
+ minutes, even while its owner still runs, and in both cases only while its
184
+ signature is recent enough to send byte for byte as signed (see above). A workspace loop that restarts finds its entry and sends its
185
+ kept request again, with the same message id, when it opens its session.
186
+
187
+ When the owner process has exited, as with an ad hoc command that stopped
188
+ during an outage, another client sends the kept request of that entry: the
189
+ next session open on the device, or a client opened with an owner key, such
190
+ as a workspace loop, after one of its own requests. A one-shot command sends
191
+ such a request only when it opens its session, so it exits once its last call
192
+ returns. That client sends it in a signing-control
193
+ section of its own, which starts only once the request has returned its
194
+ answer, sends one kept request at most, and does not start while any client of
195
+ the process holds a task lease. A kept request that stood unchanged for 10
196
+ minutes is due too, even when its process id still answers (it may have been
197
+ reused or belong to another account) or when it belongs to a workspace loop
198
+ that never ran again; but it was signed at least that long ago, so another
199
+ client leaves it in the entry for its owner, as below. The outcome never answers the client that sent
200
+ it and is never raised to its caller. An accepted or refused request leaves
201
+ the file. When its owner can still read the entry (a workspace loop, or a
202
+ process that still runs), the answer stays in the owner's entry for 10
203
+ minutes, and the next write after that removes it. An owner that still runs
204
+ takes that outcome from the file instead of sending the request again: when
205
+ its caller retries the same call, it returns that answer or raises that
206
+ refusal without signing the call again. Only an answer whose body is a JSON
207
+ object is kept. When no answer is there (any other answer, or one removed
208
+ after its 10 minutes), the owner sends the request it signed again, with the
209
+ same message id and idempotency key; it never signs that call again. Only an
210
+ action acknowledgement older than 8 minutes is signed again, with a new message
211
+ id and the same idempotency key, and only by its owner process in its own open
212
+ session, at its next sequence. A process that took it over with its owner key
213
+ signs it again only in the session it opens, once the server accepted that
214
+ session open. Until then it signs no other call, and the acknowledgement stays
215
+ in the owner's entry, so when that session open fails or the process stops,
216
+ the next process with the owner key takes it over again, and when the server
217
+ refuses it, the process's next session open signs it again. Another client
218
+ never sends such an acknowledgement, nor a kept request signed more than 4
219
+ minutes ago, nor a kept
220
+ session open, poll or read: it leaves them in the entry while their owner can
221
+ come back (a workspace loop that restarts, or a process that still runs), and
222
+ removes them unsent once that owner is gone (a command that exited, or an
223
+ entry moved from an earlier version's file). The
224
+ client records each such send in
225
+ the file before it starts, so a request without a definite answer, including
226
+ one whose sender stopped during the send, stays in the file and is due again
227
+ after at least 10 minutes. By then it was signed too long ago for another
228
+ client to send: it stays for its owner, or is removed unsent once that owner is
229
+ gone. A session open sends at most one such request in
230
+ its signing-control section, and none when it replays its own kept request
231
+ there, so another process that waits for signing control waits for at most
232
+ one such send; while more are due, each next request of a client opened with
233
+ an owner key sends one more. A kept session open, poll or read matters only to
234
+ its owner, so the task or content a poll or read returns is never written to
235
+ the file. A kept request in a file written by an earlier version is moved to
236
+ such an entry when the file is first read, unless it has the message id of a
237
+ kept request in an entry (it is then that entry's copy). Such an entry has
238
+ no owner process: it is due only once it has stood unchanged for 10 minutes,
239
+ counted from when it was last signed or stamped, so a command of the earlier
240
+ version that still runs sends its own request first. By then its signature is
241
+ too old to send as signed and no process of this version opened its session,
242
+ so this version removes it unsent, and its outcome stays unknown.
243
+ Another client's entry stays in the file only while it holds a kept request,
244
+ waiting completion receipts, or an answer another client got for it in the
245
+ last 10 minutes; every other entry is removed on the next write, so clients
246
+ that come and go never fill the file. When the kept request of an owner that
247
+ still runs leaves its entry (an earlier version rewrote the file or wrote back
248
+ an older copy, or the file was removed), the owner keeps the request and its
249
+ session: it writes the request back to its own entry before it sends it again,
250
+ exactly as signed, and signs its next call at the next sequence it holds in
251
+ memory.
252
+
253
+ The file holds at most 1,000 recovered task completions. A new completion is
254
+ refused while that list is full, but a kept completion is still sent again,
255
+ since the server may already have accepted it. A completion the server accepted
256
+ is never dropped: when the list has no room for it, its receipt waits in its
257
+ client's entry, which stays like an entry with a kept request, and the next
258
+ write by any client that finds room moves it to the list. Acknowledging a
259
+ completion removes its receipt from the list and from any entry it waits in.
260
+
261
+ The file holds at most 256 kept requests. A client without a kept request
262
+ still opens its session in a full file; that session open is not kept in the
263
+ file. Before a request that would add a
264
+ kept request to a full file, the client sends a due request of another entry to
265
+ make room, in a hold of its own; when none is due yet, or the file is still
266
+ full after that send, the request is refused with
267
+ `relay_protocol_state_outbox_full`. A new kept request that an earlier version
268
+ adds to a full file stays at the top level of the file, in place of the copy
269
+ described above, until a client of this version sends it or removes it unsent.
270
+
271
+ A signed request that is kept in the outbox may be sent again: see the two
272
+ cases below.
273
+
274
+ - **Connect phase: at most 30 s** (`RELAY_CONNECT_TIMEOUT_MS`). A relay
275
+ connection that does not open in time fails with the code
276
+ `relay_connect_timeout`. This attempt sent nothing. The signed request stays
277
+ in the outbox and is sent on the next attempt, exactly as after any other
278
+ failure that keeps it. An earlier attempt may already have sent it.
279
+ - **After the request is sent: up to 90 s from the start**
280
+ (`RELAY_ACKNOWLEDGEMENT_TIMEOUT_MS`). The gateway normally answers within
281
+ about 35 s. If no answer arrives, the call fails with `relay_response_timeout`
282
+ and the outcome is unknown, so the exact signed request is kept and may be
283
+ sent again later. This window is not shortened: a shorter wait would resend
284
+ requests that already succeeded.
285
+
286
+ Another process that needs signing control on the same device waits up to 10 s
287
+ and then fails with `connection_anchor_busy`. That error is raised before the
288
+ lock is held and before anything is signed, so retrying the call is safe. The
289
+ repository relay loop retries its session open on this error and restarts the
290
+ loop after a failure at a later stage; ad hoc callers should retry the call.
291
+ Callers in the same process wait in line for up to 120 s instead.
292
+
98
293
  - [Bidirectional protocol](https://github.com/dharma-ai-labs/dharma-agent-fabric/blob/main/docs/05-bidirectional-protocol.md)
99
294
  - [Security boundary](https://github.com/dharma-ai-labs/dharma-agent-fabric/blob/main/docs/10-security-privacy-and-threat-model.md)
100
295
  - [Source](https://github.com/dharma-ai-labs/dharma-agent-fabric/tree/main/packages/relay-client)
@@ -5,6 +5,24 @@ export interface DeviceSigningControlLease {
5
5
  readonly leaseDigest: string;
6
6
  assertHeld(): Promise<void>;
7
7
  }
8
+ /** Runs work so that a root signing-control wait inside it leaves the line when signal aborts. */
9
+ export declare function withDeviceSigningLineSignal<T>(signal: AbortSignal, work: () => Promise<T>): Promise<T>;
10
+ /** Runs work outside any signing-control hold of its caller, so a signing-control call started in it, even one
11
+ * that runs after the caller's hold has settled, takes control as a root. A relay loop's line signal still applies. */
12
+ export declare function outsideDeviceSigningControl<T>(work: () => T): T;
13
+ /** Runs one signed request under device signing control so that each hold covers at most one network send. When the
14
+ * request first sends another kept request, it hands the hold back (handBackDeviceSigningControl) and runs again in a
15
+ * fresh hold, behind every root that waited meanwhile. Inside a caller's own hold it runs there, as
16
+ * withDeviceSigningControl does, so a caller that holds control across several calls keeps it across their sends. */
17
+ export declare function withSigningControlPerSend<T>(input: Parameters<typeof withDeviceSigningControl>[0], work: () => Promise<T>): Promise<T>;
18
+ /** Whether the current async context is inside a live hold that its caller took itself without perSend (with
19
+ * withDeviceSigningControl, directly or nested). Work in such a hold always runs in that one hold. */
20
+ export declare function insideCallerSigningControlHold(): boolean;
21
+ /** Whether the current async context is inside a live hold of signing control of any kind, perSend or not. */
22
+ export declare function insideDeviceSigningControlHold(): boolean;
23
+ /** Ends the current hold when it is a root of withSigningControlPerSend, whose work then runs again in a fresh hold.
24
+ * In any other hold, or outside one, it returns and the caller goes on. */
25
+ export declare function handBackDeviceSigningControl(): void;
8
26
  /** Serialization, not device, source, consent or task authority. Native turns,
9
27
  * ordinary signed transport and device maintenance use the same OS-user/device
10
28
  * namespace. Nested SDK calls reuse only their still-live async owner; a copied
@@ -1 +1 @@
1
- {"version":3,"file":"deviceSigningControl.d.ts","sourceRoot":"","sources":["../src/deviceSigningControl.ts"],"names":[],"mappings":"AAOA,OAAO,EAAoB,KAAK,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AAEnF,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,oBAAoB,EAAC,MAAM,CAAC;IACrC,QAAQ,CAAC,qBAAqB,EAAC,MAAM,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAC,MAAM,CAAC;IAC5B,UAAU,IAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAMD;;;gFAGgF;AAChF,wBAAsB,wBAAwB,CAAC,CAAC,EAAE,KAAK,EAAC;IAAC,MAAM,EAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAA,cAAc,EAAC,MAAM,CAAC;QAAA,QAAQ,EAAC,MAAM,CAAA;KAAC,CAAC;IACnH,SAAS,CAAC,EAAC,kBAAkB,CAAC;IAAA,SAAS,CAAC,EAAC,MAAM,CAAA;CAAC,EAAC,IAAI,EAAC,CAAC,KAAK,EAAC,yBAAyB,KAAG,OAAO,CAAC,CAAC,CAAC,GAAE,OAAO,CAAC,CAAC,CAAC,CAgChH"}
1
+ {"version":3,"file":"deviceSigningControl.d.ts","sourceRoot":"","sources":["../src/deviceSigningControl.ts"],"names":[],"mappings":"AAOA,OAAO,EAAoB,KAAK,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AAEnF,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,oBAAoB,EAAC,MAAM,CAAC;IACrC,QAAQ,CAAC,qBAAqB,EAAC,MAAM,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAC,MAAM,CAAC;IAC5B,UAAU,IAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAeD,kGAAkG;AAClG,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,MAAM,EAAC,WAAW,EAAC,IAAI,EAAC,MAAI,OAAO,CAAC,CAAC,CAAC,GAAE,OAAO,CAAC,CAAC,CAAC,CAEhG;AAED;uHACuH;AACvH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAC,MAAI,CAAC,GAAE,CAAC,CAE3D;AAMD;;;qHAGqH;AACrH,wBAAsB,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,EACrG,IAAI,EAAC,MAAI,OAAO,CAAC,CAAC,CAAC,GAAE,OAAO,CAAC,CAAC,CAAC,CAMhC;AAED;sGACsG;AACtG,wBAAgB,8BAA8B,IAAG,OAAO,CAGvD;AAED,8GAA8G;AAC9G,wBAAgB,8BAA8B,IAAG,OAAO,CAEvD;AAED;2EAC2E;AAC3E,wBAAgB,4BAA4B,IAAG,IAAI,CAGlD;AAsCD;;;gFAGgF;AAChF,wBAAsB,wBAAwB,CAAC,CAAC,EAAE,KAAK,EAAC;IAAC,MAAM,EAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAA,cAAc,EAAC,MAAM,CAAC;QAAA,QAAQ,EAAC,MAAM,CAAA;KAAC,CAAC;IACnH,SAAS,CAAC,EAAC,kBAAkB,CAAC;IAAA,SAAS,CAAC,EAAC,MAAM,CAAA;CAAC,EAAC,IAAI,EAAC,CAAC,KAAK,EAAC,yBAAyB,KAAG,OAAO,CAAC,CAAC,CAAC,GAAE,OAAO,CAAC,CAAC,CAAC,CAuChH"}
@@ -7,6 +7,122 @@ import { canonicalize } from '@dharma-ai-labs/agent-fabric-contracts';
7
7
  import { acquireEnrollmentAnchorLock } from './enrollmentAnchorLock.js';
8
8
  import { HostOperationFence } from './hostOperationScope.js';
9
9
  const owners = new AsyncLocalStorage();
10
+ // #511: one relay process runs several workspace loops on one device. Their roots wait in one line per
11
+ // namespace in this process, in arrival order, so a sibling's long hold is a wait in line rather than a
12
+ // connection_anchor_busy after the lock wait. Only the root at the front of the line contends for the lock
13
+ // file, which still excludes every other process and still recovers a lock whose owner died.
14
+ const DEVICE_SIGNING_LINE_WAIT_MS = 120_000;
15
+ const DEVICE_SIGNING_LOCK_WAIT_MS = 10_000;
16
+ const lines = new Map();
17
+ // A relay workspace loop has no host scope, so its stop signal reaches the line through this store. It only
18
+ // lets a root leave the line: a root with nobody ahead of it, and the lock file itself, behave as before.
19
+ const lineSignals = new AsyncLocalStorage();
20
+ /** Runs work so that a root signing-control wait inside it leaves the line when signal aborts. */
21
+ export function withDeviceSigningLineSignal(signal, work) {
22
+ return lineSignals.run(signal, work);
23
+ }
24
+ /** Runs work outside any signing-control hold of its caller, so a signing-control call started in it, even one
25
+ * that runs after the caller's hold has settled, takes control as a root. A relay loop's line signal still applies. */
26
+ export function outsideDeviceSigningControl(work) {
27
+ return owners.exit(work);
28
+ }
29
+ /** Roots taken by withSigningControlPerSend: their work may end the hold after one network send. */
30
+ const perSendRoots = new WeakSet();
31
+ class SigningControlHandBack extends Error {
32
+ constructor() { super('device_signing_control_hand_back'); }
33
+ }
34
+ /** Runs one signed request under device signing control so that each hold covers at most one network send. When the
35
+ * request first sends another kept request, it hands the hold back (handBackDeviceSigningControl) and runs again in a
36
+ * fresh hold, behind every root that waited meanwhile. Inside a caller's own hold it runs there, as
37
+ * withDeviceSigningControl does, so a caller that holds control across several calls keeps it across their sends. */
38
+ export async function withSigningControlPerSend(input, work) {
39
+ if (owners.getStore())
40
+ return withDeviceSigningControl(input, work);
41
+ for (;;) {
42
+ try {
43
+ return await withDeviceSigningControl(input, async () => { perSendRoots.add(owners.getStore()); return work(); });
44
+ }
45
+ catch (error) {
46
+ if (!(error instanceof SigningControlHandBack))
47
+ throw error;
48
+ }
49
+ }
50
+ }
51
+ /** Whether the current async context is inside a live hold that its caller took itself without perSend (with
52
+ * withDeviceSigningControl, directly or nested). Work in such a hold always runs in that one hold. */
53
+ export function insideCallerSigningControlHold() {
54
+ const owner = owners.getStore();
55
+ return !!owner?.active && !perSendRoots.has(owner);
56
+ }
57
+ /** Whether the current async context is inside a live hold of signing control of any kind, perSend or not. */
58
+ export function insideDeviceSigningControlHold() {
59
+ return !!owners.getStore()?.active;
60
+ }
61
+ /** Ends the current hold when it is a root of withSigningControlPerSend, whose work then runs again in a fresh hold.
62
+ * In any other hold, or outside one, it returns and the caller goes on. */
63
+ export function handBackDeviceSigningControl() {
64
+ const owner = owners.getStore();
65
+ if (owner?.active && perSendRoots.has(owner))
66
+ throw new SigningControlHandBack();
67
+ }
68
+ /** Resolves with this root's leave() once every root ahead of it has left. A root that gives up, at the
69
+ * deadline, when its host scope is withdrawn or when its relay loop stops, leaves at once, so the roots
70
+ * behind it keep their order. */
71
+ async function waitInLine(namespace, deadline, fence) {
72
+ const line = lines.get(namespace) ?? { tail: Promise.resolve(), waiting: 0 };
73
+ lines.set(namespace, line);
74
+ const stop = line.waiting > 0 ? lineSignals.getStore() : undefined;
75
+ const ahead = line.tail;
76
+ let open, left = false;
77
+ const leaving = new Promise(accept => { open = accept; });
78
+ line.tail = ahead.then(() => leaving);
79
+ line.waiting++;
80
+ const leave = () => {
81
+ if (left)
82
+ return;
83
+ left = true;
84
+ open();
85
+ if (--line.waiting === 0 && lines.get(namespace) === line)
86
+ lines.delete(namespace);
87
+ };
88
+ let timer, onAbort, onStop;
89
+ try {
90
+ const outcome = await new Promise(accept => {
91
+ void ahead.then(() => accept('turn'));
92
+ timer = setTimeout(() => accept('deadline'), Math.max(0, deadline - Date.now()));
93
+ if (fence) {
94
+ onAbort = () => accept('withdrawn');
95
+ fence.signal.addEventListener('abort', onAbort, { once: true });
96
+ if (fence.signal.aborted)
97
+ accept('withdrawn');
98
+ }
99
+ if (stop) {
100
+ onStop = () => accept('stopped');
101
+ stop.addEventListener('abort', onStop, { once: true });
102
+ if (stop.aborted)
103
+ accept('stopped');
104
+ }
105
+ });
106
+ if (outcome === 'turn')
107
+ return leave;
108
+ if (outcome === 'withdrawn')
109
+ await fence.assert();
110
+ if (outcome === 'stopped')
111
+ stop.throwIfAborted();
112
+ throw Error('connection_anchor_busy');
113
+ }
114
+ catch (error) {
115
+ leave();
116
+ throw error;
117
+ }
118
+ finally {
119
+ clearTimeout(timer);
120
+ if (onAbort)
121
+ fence.signal.removeEventListener('abort', onAbort);
122
+ if (onStop)
123
+ stop.removeEventListener('abort', onStop);
124
+ }
125
+ }
10
126
  const hash = (v) => 'sha256:' + createHash('sha256').update(canonicalize(v)).digest('hex');
11
127
  const denied = () => { throw Error('device_signing_control_unavailable'); };
12
128
  /** Serialization, not device, source, consent or task authority. Native turns,
@@ -19,9 +135,12 @@ export async function withDeviceSigningControl(input, work) {
19
135
  if ((url.protocol !== 'https:' && !(loopback && url.protocol === 'http:')) || url.origin !== input.config.hqUrl
20
136
  || [org, device].some(value => typeof value !== 'string' || value.length < 1 || value.length > 256 || /[\x00-\x1f\x7f]/.test(value)))
21
137
  return denied();
22
- const timeout = input.timeoutMs ?? 10000;
23
- if (!Number.isSafeInteger(timeout) || timeout < 1 || timeout > 10000)
138
+ // An explicit timeoutMs bounds the whole wait, in line and for the lock. Without one, a root waits in
139
+ // line for up to DEVICE_SIGNING_LINE_WAIT_MS and then for up to 10 s for the lock file.
140
+ const timeout = input.timeoutMs ?? DEVICE_SIGNING_LOCK_WAIT_MS;
141
+ if (!Number.isSafeInteger(timeout) || timeout < 1 || timeout > DEVICE_SIGNING_LOCK_WAIT_MS)
24
142
  return denied();
143
+ const started = Date.now();
25
144
  const user = userInfo(), userHash = hash({ home: user.homedir, user: user.username }).slice(7);
26
145
  const namespace = hash({ origin: url.origin, organizationId: org, deviceId: device, user: userHash });
27
146
  const fence = input.hostScope ? new HostOperationFence(input.hostScope) : undefined;
@@ -38,7 +157,16 @@ export async function withDeviceSigningControl(input, work) {
38
157
  }
39
158
  const root = process.platform === 'win32' ? resolve(user.homedir, 'AppData', 'Local', 'Temp') : '/tmp';
40
159
  const path = resolve(root, 'dharma-signing-controls-' + userHash.slice(0, 32), namespace.slice(7) + '.lock');
41
- const release = await acquireEnrollmentAnchorLock(path, fence, timeout);
160
+ const explicit = input.timeoutMs !== undefined;
161
+ const leaveLine = await waitInLine(namespace, started + (explicit ? timeout : DEVICE_SIGNING_LINE_WAIT_MS), fence);
162
+ let release;
163
+ try {
164
+ release = await acquireEnrollmentAnchorLock(path, fence, explicit ? Math.max(1, started + timeout - Date.now()) : timeout);
165
+ }
166
+ catch (error) {
167
+ leaveLine();
168
+ throw error;
169
+ }
42
170
  const controllerInstanceId = randomUUID(), owner = { namespace, active: true, lease: undefined };
43
171
  const processIdentityDigest = hash({ schema: 'dharma.signing-controller-process/v1', hostUser: userHash,
44
172
  pid: process.pid, processTimeOrigin: performance.timeOrigin, controllerInstanceId });
@@ -62,7 +190,12 @@ export async function withDeviceSigningControl(input, work) {
62
190
  }
63
191
  finally {
64
192
  owner.active = false;
65
- await release();
193
+ try {
194
+ await release();
195
+ }
196
+ finally {
197
+ leaveLine();
198
+ }
66
199
  }
67
200
  }
68
201
  //# sourceMappingURL=deviceSigningControl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deviceSigningControl.js","sourceRoot":"","sources":["../src/deviceSigningControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAC,2BAA2B,EAAC,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAC,kBAAkB,EAAyB,MAAM,yBAAyB,CAAC;AASnF,MAAM,MAAM,GAAC,IAAI,iBAAiB,EAAS,CAAC;AAC5C,MAAM,IAAI,GAAC,CAAC,CAAS,EAAC,EAAE,CAAA,SAAS,GAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC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 @@
1
1
  import assert from 'node:assert/strict';
2
+ import { spawn } from 'node:child_process';
2
3
  import { createHash, randomUUID } from 'node:crypto';
3
4
  import { mkdir, readdir, rm, writeFile } from 'node:fs/promises';
4
5
  import { userInfo } from 'node:os';
@@ -69,4 +70,148 @@ test('a NUL lock left by a hard reset at the real signing path no longer blocks
69
70
  assert.equal(await run(scope, async (lease) => { await lease.assertHeld(); return 'signed'; }), 'signed');
70
71
  assert.equal((await readdir(dirname(path))).some(name => name.startsWith(namespace.slice(7))), false);
71
72
  });
73
+ // #511: one relay process serves several workspace loops. Their waits for the device signing control
74
+ // queue inside the process, so a sibling's long hold is a wait in line and not a connection_anchor_busy.
75
+ const settle = (value) => value.then(result => result, (error) => error.message);
76
+ const gate = () => { let open; const promise = new Promise(accept => { open = accept; }); return { promise, open }; };
77
+ const delay = (ms) => new Promise(accept => setTimeout(accept, ms));
78
+ test('an in-process waiter queues behind a hold longer than the 10 s lock wait and is admitted after it', async () => {
79
+ const run = api(), scope = input(), held = gate(), released = gate();
80
+ let holding = false;
81
+ const order = [];
82
+ const holder = run(scope, async () => { holding = true; held.open(); await released.promise; holding = false; order.push('holder'); });
83
+ await held.promise;
84
+ const waiter = settle(run(scope, async (lease) => { assert.equal(holding, false); await lease.assertHeld(); order.push('waiter'); return 'admitted'; }));
85
+ await delay(10_500);
86
+ released.open();
87
+ await holder;
88
+ assert.equal(await waiter, 'admitted');
89
+ assert.deepEqual(order, ['holder', 'waiter']);
90
+ });
91
+ test('in-process waiters enter signing control one at a time, in the order they arrived', async () => {
92
+ const run = api(), scope = input(), held = gate(), released = gate();
93
+ let inside = 0;
94
+ const order = [];
95
+ const holder = run(scope, async () => { held.open(); await released.promise; });
96
+ await held.promise;
97
+ const waiters = [];
98
+ for (const name of ['first', 'second', 'third']) {
99
+ waiters.push(settle(run(scope, async () => { assert.equal(++inside, 1); order.push(name); await delay(30); inside--; return name; })));
100
+ await delay(40);
101
+ }
102
+ released.open();
103
+ await holder;
104
+ assert.deepEqual(await Promise.all(waiters), ['first', 'second', 'third']);
105
+ assert.deepEqual(order, ['first', 'second', 'third']);
106
+ });
107
+ test('control: a waiter with an explicit timeout still gives up, and the waiter behind it keeps its place', async () => {
108
+ const run = api(), scope = input(), held = gate(), released = gate();
109
+ const holder = run(scope, async () => { held.open(); await released.promise; });
110
+ await held.promise;
111
+ const impatient = settle(run({ ...scope, timeoutMs: 50 }, async () => assert.fail('admitted while held')));
112
+ const patient = settle(run(scope, async () => 'admitted'));
113
+ assert.equal(await impatient, 'connection_anchor_busy');
114
+ released.open();
115
+ await holder;
116
+ assert.equal(await patient, 'admitted');
117
+ });
118
+ test('control: a waiter whose host scope is withdrawn leaves the line at once without holding up the rest', async () => {
119
+ const run = api(), scope = input(), held = gate(), released = gate(), controller = new AbortController();
120
+ const holder = run(scope, async () => { held.open(); await released.promise; });
121
+ await held.promise;
122
+ const withdrawn = settle(run({ ...scope, hostScope: { signal: controller.signal, current: async () => !controller.signal.aborted } }, async () => assert.fail('withdrawn waiter admitted')));
123
+ const behind = settle(run(scope, async () => 'admitted'));
124
+ await delay(20);
125
+ const started = Date.now();
126
+ controller.abort();
127
+ assert.equal(await withdrawn, 'relay_host_scope_unavailable');
128
+ assert.ok(Date.now() - started < 2_000);
129
+ released.open();
130
+ await holder;
131
+ assert.equal(await behind, 'admitted');
132
+ });
133
+ // The child holds the same control from another process, through the real signing-control lock file.
134
+ function childHolder(scope) {
135
+ const module = new URL('./index.js', import.meta.url).href;
136
+ const child = spawn(process.execPath, ['--input-type=module', '-e', `import {withDeviceSigningControl} from ${JSON.stringify(module)};
137
+ await withDeviceSigningControl({config:JSON.parse(process.argv[1])},async()=>{process.stdout.write('held;');
138
+ await new Promise(accept=>process.stdin.once('data',accept));});process.stdout.write('released;');`, JSON.stringify(scope.config)], { stdio: ['pipe', 'pipe', 'inherit'] });
139
+ let output = '';
140
+ const waiters = [];
141
+ child.stdout.on('data', chunk => { output += chunk; for (const wake of waiters.splice(0))
142
+ wake(); });
143
+ const saw = async (text) => { while (!output.includes(text))
144
+ await new Promise(wake => waiters.push(wake)); };
145
+ const exited = new Promise(accept => child.once('exit', code => accept(code)));
146
+ return { child, saw, exited };
147
+ }
148
+ test('control: a holder in another process still excludes this one, and only for the lock wait', async () => {
149
+ const run = api(), scope = input(), other = childHolder(scope);
150
+ try {
151
+ await other.saw('held');
152
+ assert.equal(await settle(run({ ...scope, timeoutMs: 300 }, async () => assert.fail('admitted while another process holds'))), 'connection_anchor_busy');
153
+ const waiting = settle(run(scope, async () => 'admitted'));
154
+ await delay(200);
155
+ other.child.stdin.end('go');
156
+ await other.saw('released');
157
+ assert.equal(await waiting, 'admitted');
158
+ assert.equal(await other.exited, 0);
159
+ }
160
+ finally {
161
+ other.child.kill();
162
+ }
163
+ });
164
+ test('control: a lock left by a killed holder process is still recovered', async () => {
165
+ const run = api(), scope = input(), other = childHolder(scope);
166
+ try {
167
+ await other.saw('held');
168
+ }
169
+ finally {
170
+ other.child.kill('SIGKILL');
171
+ }
172
+ await other.exited;
173
+ assert.equal(await run(scope, async (lease) => { await lease.assertHeld(); return 'signed'; }), 'signed');
174
+ });
175
+ // Review round 1 on #511: a relay loop that is told to stop leaves the line at once. Relay loops have no host
176
+ // scope, so their stop signal reaches the line through withDeviceSigningLineSignal.
177
+ function lineSignal() {
178
+ const fn = relay.withDeviceSigningLineSignal;
179
+ assert.equal(typeof fn, 'function', 'withDeviceSigningLineSignal is exported');
180
+ return fn;
181
+ }
182
+ test('a queued waiter whose relay loop stops leaves the line at once, never runs its work, and keeps the rest in order', async () => {
183
+ const run = api(), inLoop = lineSignal(), scope = input(), held = gate(), released = gate(), loop = new AbortController();
184
+ let ran = 0;
185
+ const holder = run(scope, async () => { held.open(); await released.promise; });
186
+ await held.promise;
187
+ const stopped = inLoop(loop.signal, () => run(scope, async () => { ran++; })).then(() => 'admitted', (error) => error.name);
188
+ const behind = settle(run(scope, async () => 'admitted'));
189
+ await delay(20);
190
+ const started = Date.now();
191
+ loop.abort();
192
+ assert.equal(await stopped, 'AbortError');
193
+ assert.ok(Date.now() - started < 2_000);
194
+ released.open();
195
+ await holder;
196
+ assert.equal(await behind, 'admitted');
197
+ assert.equal(ran, 0);
198
+ });
199
+ test('a waiter whose relay loop has already stopped does not join a busy line', async () => {
200
+ const run = api(), inLoop = lineSignal(), scope = input(), held = gate(), released = gate(), loop = new AbortController();
201
+ let ran = 0;
202
+ const holder = run(scope, async () => { held.open(); await released.promise; });
203
+ await held.promise;
204
+ loop.abort();
205
+ const started = Date.now();
206
+ assert.equal(await inLoop(loop.signal, () => run(scope, async () => { ran++; })).then(() => 'admitted', (error) => error.name), 'AbortError');
207
+ assert.ok(Date.now() - started < 2_000);
208
+ released.open();
209
+ await holder;
210
+ assert.equal(ran, 0);
211
+ });
212
+ test('control: a stopping loop with nobody ahead of it still signs, as before the line existed', async () => {
213
+ const run = api(), inLoop = lineSignal(), scope = input(), loop = new AbortController();
214
+ loop.abort();
215
+ assert.equal(await inLoop(loop.signal, () => run(scope, async (lease) => { await lease.assertHeld(); return 'signed'; })), 'signed');
216
+ });
72
217
  //# sourceMappingURL=deviceSigningControl.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deviceSigningControl.test.js","sourceRoot":"","sources":["../src/deviceSigningControl.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,UAAU,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAClD,OAAO,EAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,YAAY,EAAC,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAI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