@agenticprimitives/fabric 0.0.0-alpha.39 → 0.0.0-alpha.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.
Files changed (48) hide show
  1. package/CLAUDE.md +14 -22
  2. package/dist/cloudflare/exchange-store.d.ts +20 -1
  3. package/dist/cloudflare/exchange-store.d.ts.map +1 -1
  4. package/dist/cloudflare/exchange-store.js +26 -4
  5. package/dist/cloudflare/exchange-store.js.map +1 -1
  6. package/dist/cloudflare/index.d.ts +4 -4
  7. package/dist/cloudflare/index.d.ts.map +1 -1
  8. package/dist/cloudflare/index.js +2 -2
  9. package/dist/cloudflare/index.js.map +1 -1
  10. package/dist/cloudflare/interaction-store.d.ts +26 -0
  11. package/dist/cloudflare/interaction-store.d.ts.map +1 -1
  12. package/dist/cloudflare/interaction-store.js +52 -1
  13. package/dist/cloudflare/interaction-store.js.map +1 -1
  14. package/dist/cloudflare/orchestration-runtime.d.ts +19 -5
  15. package/dist/cloudflare/orchestration-runtime.d.ts.map +1 -1
  16. package/dist/cloudflare/orchestration-runtime.js +11 -6
  17. package/dist/cloudflare/orchestration-runtime.js.map +1 -1
  18. package/dist/cloudflare/principal-gateway-do.d.ts +227 -31
  19. package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -1
  20. package/dist/cloudflare/principal-gateway-do.js +398 -58
  21. package/dist/cloudflare/principal-gateway-do.js.map +1 -1
  22. package/dist/cloudflare/receipt-signer.d.ts.map +1 -1
  23. package/dist/cloudflare/receipt-signer.js +6 -3
  24. package/dist/cloudflare/receipt-signer.js.map +1 -1
  25. package/dist/cloudflare/vault-exchange-store.d.ts.map +1 -1
  26. package/dist/cloudflare/vault-exchange-store.js +17 -0
  27. package/dist/cloudflare/vault-exchange-store.js.map +1 -1
  28. package/dist/cloudflare/vault-interaction-store.d.ts +1 -1
  29. package/dist/cloudflare/vault-interaction-store.d.ts.map +1 -1
  30. package/dist/cloudflare/vault-interaction-store.js +14 -0
  31. package/dist/cloudflare/vault-interaction-store.js.map +1 -1
  32. package/dist/email/index.d.ts +4 -0
  33. package/dist/email/index.d.ts.map +1 -1
  34. package/dist/email/index.js +19 -5
  35. package/dist/email/index.js.map +1 -1
  36. package/dist/messaging/board.d.ts +1 -1
  37. package/dist/messaging/consult-routing.d.ts +92 -19
  38. package/dist/messaging/consult-routing.d.ts.map +1 -1
  39. package/dist/messaging/consult-routing.js +136 -35
  40. package/dist/messaging/consult-routing.js.map +1 -1
  41. package/dist/messaging/index.d.ts +1 -1
  42. package/dist/messaging/index.d.ts.map +1 -1
  43. package/dist/messaging/index.js +1 -1
  44. package/dist/messaging/index.js.map +1 -1
  45. package/dist/messaging/vault-store.d.ts.map +1 -1
  46. package/dist/messaging/vault-store.js +8 -0
  47. package/dist/messaging/vault-store.js.map +1 -1
  48. package/package.json +9 -9
@@ -2,6 +2,7 @@ import type { Vault, DekWrapper } from '@agenticprimitives/vault';
2
2
  import type { CanonicalAgentId } from '@agenticprimitives/types';
3
3
  import type { AuthorityTier } from '@agenticprimitives/tool-policy';
4
4
  import type { ExchangeRecordV1, ExchangeEventV1, ExchangeId } from '../exchange-record.js';
5
+ import { type InteractionState } from '../interaction-machines.js';
5
6
  import { type DeliveryEnvelopeV1 } from '../delivery-envelope.js';
6
7
  import { type OutboxEntry } from './outbox-store.js';
7
8
  import { type ExchangeStore } from './exchange-store.js';
@@ -10,7 +11,7 @@ import type { CommitmentRecordV1 } from '../interaction-machines.js';
10
11
  import type { InteractionRecordV1, InteractionId, ProfileVersion, ParticipationV1 } from '../interaction-record.js';
11
12
  import type { ProtocolBindingV1 } from '../protocol-binding.js';
12
13
  import { type AuthorityVerdictCache, type AuthorityVerdict, type AuthorityVerdictKey } from './authority-verdict-cache.js';
13
- import { type DeliveryReceiptInput, type SignedDeliveryReceiptV1 } from './receipt-signer.js';
14
+ import { type SignedDeliveryReceiptV1 } from './receipt-signer.js';
14
15
  import type { GatewayToolRegistry } from './gateway-tools.js';
15
16
  import type { Intent, Planner, RunResult } from '@agenticprimitives/orchestration';
16
17
  import { type ProvenanceRecordV1 } from '@agenticprimitives/provenance';
@@ -31,6 +32,17 @@ export interface PrincipalGatewayEnv {
31
32
  * tests pass fakes. Absent ⇒ the storage/guard methods still work, but the co-resident-MCP methods throw.
32
33
  */
33
34
  export interface GatewayDeps {
35
+ /**
36
+ * WHO IS CALLING (spec 445 §3.4, audit DATA-3). The embedding Worker has admitted the request
37
+ * (application authentication → canonical resolution → Admission, ADR-0057); this port hands that
38
+ * verdict to the gateway. It is the ONLY source of `principal`, `tier` and `actor` on every ingress —
39
+ * `fetch` and the RPC-style methods alike — and it is REQUIRED for them: with no authenticator
40
+ * configured every ingress is refused. `null` ⇒ not admitted.
41
+ *
42
+ * A Durable Object is reachable only through its Worker, and this class does not rely on that: a
43
+ * fronting Worker that forwards without its own gate, or any code holding the binding, gets nothing.
44
+ */
45
+ authenticate?: GatewayAuthenticator;
34
46
  /** Cold-path: FULL token verification → the args-independent verdict (A), or `null` if invalid. The app
35
47
  * wires `delegation.verifyDelegationToken` with its chainId / DelegationManager / RPC here. */
36
48
  verifyToken(token: string): Promise<AuthorityVerdict | null>;
@@ -63,6 +75,55 @@ export interface GatewayDeps {
63
75
  * tests) — the fabric core stays credential-mechanism-free. Absent ⇒ a gated channel cannot be joined. */
64
76
  verifyEntitlement?: (requirement: string, credential: unknown, member: string) => Promise<boolean>;
65
77
  }
78
+ /** What the embedding Worker's admission established about one request. */
79
+ export interface GatewayCallerIdentity {
80
+ /** The principal the request is FOR — this gateway's own (refused otherwise when `PRINCIPAL_SA` is set). */
81
+ principal: CanonicalAgentId;
82
+ /** The lane, server-classified at admission (`ExchangeRecordV1.tier` is never client-asserted). */
83
+ tier: AuthorityTier;
84
+ /** The agent PRESENTING the request: the sender of a delivery, the poster, the party moving a case. */
85
+ actor: CanonicalAgentId;
86
+ }
87
+ /** The authenticator port: an admitted request's identity, or `null`. Supplied by the embedding Worker. */
88
+ export type GatewayAuthenticator = (request: Request) => Promise<GatewayCallerIdentity | null>;
89
+ declare const authenticatedCallerBrand: unique symbol;
90
+ /**
91
+ * A caller identity MINTED by `PrincipalGatewayDO.admitCaller` from the authenticator's result. The
92
+ * RPC-style methods take this, never loose `principal`/`tier`/`actor` fields: an object literal of the
93
+ * same shape was not minted and is refused. In-process only — it does not survive serialization, so a
94
+ * caller on the far side of a stub goes through `fetch`, which authenticates each request itself.
95
+ */
96
+ export type AuthenticatedCaller = Readonly<GatewayCallerIdentity> & {
97
+ readonly [authenticatedCallerBrand]: true;
98
+ };
99
+ export type GatewayAuthReason = 'authenticator_not_configured' | 'unauthenticated'
100
+ /** The authenticated principal is not this gateway's. */
101
+ | 'principal_mismatch';
102
+ /** An ingress was refused before anything was read or written (spec 445 §3.4, DATA-3). */
103
+ export declare class GatewayAuthError extends Error {
104
+ readonly reason: GatewayAuthReason;
105
+ constructor(reason: GatewayAuthReason);
106
+ }
107
+ /** `openInteraction` was asked to open an interaction that already exists as something else — a
108
+ * different shape, or one that has ended (spec 445 §3.4, DATB-2). Nothing was written. */
109
+ export declare class InteractionExistsError extends Error {
110
+ readonly interactionId: string;
111
+ readonly state: InteractionState;
112
+ readonly reason: "interaction-exists";
113
+ constructor(interactionId: string, state: InteractionState);
114
+ }
115
+ export type GatewayOrchestrationResult = {
116
+ ok: true;
117
+ principal: string;
118
+ result: RunResult;
119
+ } | {
120
+ ok: false;
121
+ reason: 'verdict_miss_cold_path_required'
122
+ /** The verdict's principal is not this gateway's (or not the one the caller named). */
123
+ | 'principal_mismatch'
124
+ /** `requestId` given without `now`, or the reverse. */
125
+ | 'request_id_incomplete' | 'replay';
126
+ };
66
127
  /** What ingress observed about an exchange's place in a governed situation (spec 340 W7). */
67
128
  export type DeliveryNote =
68
129
  /** No `interactionId`: this is a message, not part of a governed situation. The common case. */
@@ -88,7 +149,22 @@ export type DeliveryOutcome = {
88
149
  notes: readonly DeliveryNote[];
89
150
  } | {
90
151
  ok: false;
91
- reason: 'unknown-interaction' | 'not-a-participant';
152
+ reason:
153
+ /** No minted caller was presented (spec 445 §3.4, DATA-3). */
154
+ 'unauthenticated'
155
+ /** The record names a `principal` other than the authenticated one. */
156
+ | 'principal-mismatch'
157
+ /** The record's `parties.from` (or an event's `actor`) is not the authenticated actor. */
158
+ | 'actor-mismatch' | 'unknown-interaction'
159
+ /** The interaction is suspended, concluded, abandoned or still forming (DATB-2). `state` says which. */
160
+ | 'interaction-not-active' | 'not-a-participant'
161
+ /** An unpinned exchange whose envelope sender is not its `from`, or which does not name this
162
+ * gateway's principal as a party (spec 445 §3.4). */
163
+ | 'not-a-party'
164
+ /** Something is already held under this exchange id and the offer is not the same one
165
+ * (spec 445 §3.4). Nothing was written. */
166
+ | 'exchange-exists';
167
+ state?: InteractionState;
92
168
  };
93
169
  export declare class PrincipalGatewayDO {
94
170
  private readonly state;
@@ -103,7 +179,9 @@ export declare class PrincipalGatewayDO {
103
179
  private readonly outbox;
104
180
  private readonly provenance;
105
181
  private readonly channels;
106
- constructor(state: DurableObjectState, env: PrincipalGatewayEnv, deps?: GatewayDeps | undefined);
182
+ /** The callers `admitCaller` minted. Membership IS the proof of minting — nothing else is. */
183
+ private readonly minted;
184
+ constructor(state: DurableObjectState, env: PrincipalGatewayEnv, deps?: Partial<GatewayDeps> | undefined);
107
185
  /**
108
186
  * Create/rename a channel owned by this org gateway, and open the Interaction it IS (spec 340 W11).
109
187
  *
@@ -123,7 +201,7 @@ export declare class PrincipalGatewayDO {
123
201
  * satisfies it via the injected `verifyEntitlement` (fail-closed — no credential / no verifier / invalid ⇒
124
202
  * rejected). An ungated channel joins openly.
125
203
  */
126
- joinChannel(channelId: string, member: string, opts?: {
204
+ joinChannel(channelId: string, member: string, caller: AuthenticatedCaller, opts?: {
127
205
  credential?: unknown;
128
206
  }): Promise<{
129
207
  ok: true;
@@ -132,7 +210,12 @@ export declare class PrincipalGatewayDO {
132
210
  reason: string;
133
211
  }>;
134
212
  /** Remove a member — **kick = the org revokes** its role delegation (C2). */
135
- leaveChannel(channelId: string, member: string): Promise<void>;
213
+ leaveChannel(channelId: string, member: string, caller: AuthenticatedCaller): Promise<{
214
+ ok: true;
215
+ } | {
216
+ ok: false;
217
+ reason: string;
218
+ }>;
136
219
  channelMembers(channelId: string): Promise<string[]>;
137
220
  /** An agent's cached conversation-role projection, or `null` if none is projected (spec 324 §8). */
138
221
  channelRoleProjection(channelId: string, agent: string): Promise<ConversationRoleProjection | null>;
@@ -140,37 +223,41 @@ export declare class PrincipalGatewayDO {
140
223
  * materialized (RoleAssignment + delegation). Ungated — the principal is authoritative over its own
141
224
  * conversations (this is the bootstrap + primary path). The `by`-gated variant is for delegated managers. */
142
225
  projectConversationRole(channelId: string, projection: ConversationRoleProjection): Promise<void>;
143
- /** MANAGE-gated (spec 324 §8): project a member's conversation role. `by` must hold a cached projection
226
+ /** MANAGE-gated (spec 324 §8): project a member's conversation role. The AUTHENTICATED actor (never a
227
+ * caller-named `by`, DATA-3) must hold a cached projection
144
228
  * authorizing `manage`. This CACHES an org-issued RoleAssignment + its materializing delegation — it does
145
229
  * not itself grant authority (ADR-0048 #4); the org issues the delegation, then the projection mirrors it. */
146
- putConversationRoleProjection(channelId: string, projection: ConversationRoleProjection, by: string, at?: string): Promise<{
230
+ putConversationRoleProjection(channelId: string, projection: ConversationRoleProjection, caller: AuthenticatedCaller, at?: string): Promise<{
147
231
  ok: true;
148
232
  } | {
149
233
  ok: false;
150
234
  reason: string;
151
235
  }>;
152
236
  /** MANAGE-gated: clear a member's conversation-role projection (the org revoked the underlying delegation). */
153
- clearConversationRoleProjection(channelId: string, member: string, by: string, at?: string): Promise<{
237
+ clearConversationRoleProjection(channelId: string, member: string, caller: AuthenticatedCaller, at?: string): Promise<{
154
238
  ok: true;
155
239
  } | {
156
240
  ok: false;
157
241
  reason: string;
158
242
  }>;
159
- /** MODERATE-gated (spec 324 §8): remove a post from the channel board. `by` must hold a cached projection
243
+ /** MODERATE-gated (spec 324 §8): remove a post from the channel board. The AUTHENTICATED actor must hold a cached projection
160
244
  * authorizing `moderate`. The exchange itself is NOT deleted (immutable stream + provenance); only its
161
245
  * channel index entry is removed. */
162
- removeChannelPost(channelId: string, exchangeId: string, by: string, at?: string): Promise<{
246
+ removeChannelPost(channelId: string, exchangeId: string, caller: AuthenticatedCaller, at?: string): Promise<{
163
247
  ok: true;
164
248
  } | {
165
249
  ok: false;
166
250
  reason: string;
167
251
  }>;
168
252
  /**
169
- * Post to a channel — MEMBER-GATED, fail-closed: only a current member (`record.parties.from`) may post.
253
+ * Post to a channel — MEMBER-GATED, fail-closed: only a current member may post, and the poster is the
254
+ * AUTHENTICATED actor: `record.parties.from` must be `caller.actor` (DATA-3), so membership is asked
255
+ * about who is actually posting, never about a name in the record. A topic whose interaction is not
256
+ * `active` takes no posts (`interaction-not-active`, DATB-2).
170
257
  * The post is persisted on the org's exchange stream via `deliver()` (so it accretes a provenance trace like
171
258
  * any exchange) and indexed into the channel. Fan-out to members is the org re-delivering (§4 / Blocker 6).
172
259
  */
173
- postToChannel(channelId: string, record: ExchangeRecordV1): Promise<{
260
+ postToChannel(channelId: string, record: ExchangeRecordV1, caller: AuthenticatedCaller): Promise<{
174
261
  ok: true;
175
262
  } | {
176
263
  ok: false;
@@ -191,18 +278,34 @@ export declare class PrincipalGatewayDO {
191
278
  getProvenance(exchangeId: ExchangeId | string): Promise<ProvenanceRecordV1 | null>;
192
279
  /** The DO-local delivery-receipt attestation pubkey — publish it so senders can verify receipts. */
193
280
  receiptPubkey(): Promise<string>;
194
- /** Sign a `DeliveryReceiptV1` with the DO-local key — the delivery-proof-under-authority-at-T the sender
195
- * gets, decoupled from body storage (spec 316 §3a receipt / Blocker 4). Verify with `verifyDeliveryReceipt`. */
196
- signDeliveryReceipt(input: DeliveryReceiptInput): Promise<SignedDeliveryReceiptV1>;
281
+ /** Sign a `DeliveryReceiptV1` with the DO-local key. PRIVATE: a receipt attests to a delivery this
282
+ * gateway RECORDED, so the only callers are the two delivery paths, after the `delivered` fact is in
283
+ * the stream. A public signer would be a receipt oracle for any fields a caller cared to name. Verify
284
+ * with `verifyDeliveryReceipt`. */
285
+ private signDeliveryReceipt;
197
286
  /**
198
287
  * RECIPIENT-side peer delivery (spec 316 §4 / W4). Transport-admits an inbound `DeliveryEnvelopeV1` (routing
199
288
  * + addressing + structural), then persists the exchange, records the `delivered` fact, and returns a
200
289
  * DO-signed `DeliveryReceiptV1`. Sender AUTHORITY (envelope signature) is re-verified separately by the gateway
201
- * (ADR-0041) — admission here is transport-level only. `recipient` is this gateway's principal.
290
+ * (ADR-0041) — admission here is transport-level only.
291
+ *
292
+ * `recipient` and `tier` are the AUTHENTICATED caller's `principal` and `tier`, and the envelope's `from`
293
+ * must be its `actor` (spec 445 §3.4, DATA-3): who a delivery is for, which lane it rides and who
294
+ * sent it are admission's findings, never fields of the call.
295
+ *
296
+ * A DELIVERY NEVER OVERWRITES (spec 445 §3.4, audit H-10 / DATA-1). The exchange id comes from the
297
+ * peer and is known to every counterparty, so it identifies nothing about who is sending. If a record
298
+ * is already held under it, exactly two things can be true:
299
+ *
300
+ * · the offered envelope IS the stored one (`isSameSignedEnvelope` — full canonical bytes, signature
301
+ * included) → an idempotent redelivery. Nothing is rewritten and no second `delivered` event is
302
+ * appended; the receipt returned is for the ORIGINAL delivery. Receipts are not stored, so it is
303
+ * re-signed over the original `delivered` event's time — same exchange, message, recipient and
304
+ * `at`, hence the same attested fact, never a fresh claim that it arrived again now.
305
+ * · anything else → refused `exchange-exists`, and NO receipt is signed: a receipt for a delivery
306
+ * we did not store would attest to something false.
202
307
  */
203
- receiveDelivery(delivery: DeliveryEnvelopeV1, opts: {
204
- recipient: CanonicalAgentId;
205
- tier: AuthorityTier;
308
+ receiveDelivery(delivery: DeliveryEnvelopeV1, caller: AuthenticatedCaller, opts: {
206
309
  at: string;
207
310
  }): Promise<{
208
311
  ok: true;
@@ -211,20 +314,48 @@ export declare class PrincipalGatewayDO {
211
314
  ok: false;
212
315
  reason: string;
213
316
  }>;
317
+ /**
318
+ * The receipt for a redelivery of an envelope this gateway already holds (spec 445 §3.4).
319
+ *
320
+ * The time attested is the ORIGINAL `delivered` event's. One case needs a write: a first attempt that
321
+ * stored the record and stopped before recording `delivered`. The redelivery then completes that
322
+ * delivery — one event, through the reducer — rather than signing for a fact the stream does not hold.
323
+ */
324
+ private redeliveryReceipt;
214
325
  /**
215
326
  * T2 orchestrated lane (spec 316 §15) — a `request`/agent-task INTENT is fulfilled by the Ring-0
216
327
  * orchestration loop running IN this gateway, with the co-resident MCP tools as the loop's ToolInvoker
217
- * (in-process over the DO-local vault, under the verified `principal`). Only the LLM `planner` is injected;
218
- * the loop, the tools, and the vault are the gateway's own. Returns the orchestration `RunResult`. (Absorbing
219
- * `A2aTaskDO` + driving this from `alarm()` via a durable task queue is the remaining async-scheduling wrap.)
328
+ * (in-process over the DO-local vault). Only the LLM `planner` is injected; the loop, the tools, and the
329
+ * vault are the gateway's own. (Absorbing `A2aTaskDO` + driving this from `alarm()` via a durable task
330
+ * queue is the remaining async-scheduling wrap.)
331
+ *
332
+ * THE SAME §3a GATE AS `invokeFast`, PER STEP (spec 445 §3.4, audit DATA-4). A T2 intent is by design
333
+ * a peer's request and its text reaches the planner, so nothing here trusts the plan:
334
+ *
335
+ * (A) the cached args-independent verdict for `key` — a miss runs NOTHING (cold path first). The
336
+ * principal the tools run as, and whose KEK is resolved, is the VERDICT's. It must be this
337
+ * gateway's principal when the deployment names one, and the one the caller says it expects
338
+ * (`principal`) when it says: a verdict for A never reaches B's records.
339
+ * (B) `runCaveatPass(verdict, tool, args)` for EVERY planned step against the concrete tool and
340
+ * arguments — never cached; a denied step throws inside the loop and its tool does not run.
341
+ * (C) a single-use `requestId` (+ `now`) for the run. A WRITE tool does not run without one — it is
342
+ * not even offered to the planner — and a replayed id is refused before anything runs, so a
343
+ * retried intent is not applied twice. The id is released only when no step ran (a legitimate
344
+ * retry); once any tool ran it stays consumed, whatever the outcome.
220
345
  */
221
346
  orchestrate(input: {
222
347
  intent: Intent;
223
- principal: string;
348
+ key: AuthorityVerdictKey;
349
+ runCaveatPass: (verdict: AuthorityVerdict, tool: string, args: Record<string, unknown>) => Promise<boolean>;
350
+ /** Required for any write; with it, `now` is required too. */
351
+ requestId?: string;
352
+ now?: string;
353
+ /** Optional cross-check: refuse unless the verdict is for this principal. Never the source of it. */
354
+ principal?: string;
224
355
  maxSteps?: number;
225
356
  exchangeId?: string;
226
357
  at?: string;
227
- }): Promise<RunResult>;
358
+ }): Promise<GatewayOrchestrationResult>;
228
359
  /** SENDER-side store-and-forward (spec 316 §4): queue a peer delivery that could not be handed to the
229
360
  * recipient gateway now; `alarm()` retries with backoff until delivered (offline-first, §11a). */
230
361
  enqueueOutbound(delivery: DeliveryEnvelopeV1, opts: {
@@ -244,11 +375,24 @@ export declare class PrincipalGatewayDO {
244
375
  /**
245
376
  * T0 communication lane — persist a delivered exchange (sender-proof-only; no case, no RPC — §3). The
246
377
  * record is built upstream (envelope validated + `bodyHash`-verified at ingress); the DO is the durable
247
- * single writer. Idempotent by `exchangeId` (put overwrites the same id; a genuine redelivery is caught by
248
- * the message event's `idempotencyKey` at the reducer). Receipt signing (`DeliveryReceiptV1`, DO-local
249
- * software key) is a W2 follow-step.
378
+ * single writer.
379
+ *
380
+ * AUTHENTICATED (spec 445 §3.4, audit DATA-3): `caller` is minted by `admitCaller`; the record's
381
+ * `principal` must be the caller's, its `parties.from` the caller's `actor`, and its `tier` is the
382
+ * caller's whatever the record says.
383
+ *
384
+ * INSERT-ONLY (spec 445 §3.4, audit H-10 / DATA-1). Every way into this method carries an exchange id
385
+ * somebody else chose — a peer's delivery, a member's channel post, a `/deliver` body — so it never
386
+ * overwrites: the store's `insert` either writes a new record or returns the one already held. An
387
+ * offer that is canonically identical to the held record is a retry and succeeds without writing;
388
+ * anything else under a held id is refused `exchange-exists`. (An exchange that has since accrued
389
+ * events no longer equals its seed, so a late retry of the seed is refused — `receiveDelivery`
390
+ * decides redelivery by the signed envelope instead, which is the identity that survives.) Changing a
391
+ * held exchange is the reducer's job (`applyEvent`), never a second delivery's.
250
392
  */
251
- deliver(record: ExchangeRecordV1): Promise<DeliveryOutcome>;
393
+ deliver(record: ExchangeRecordV1, caller: AuthenticatedCaller): Promise<DeliveryOutcome>;
394
+ /** The store half of `deliver`, after the caller has been established. */
395
+ private ingest;
252
396
  /**
253
397
  * The interaction-aware half of ingress (spec 340 W7).
254
398
  *
@@ -259,12 +403,17 @@ export declare class PrincipalGatewayDO {
259
403
  * one. Auto-creating an interaction per message would make "a thread is a projection, not a
260
404
  * container" false by turning every message into a container.
261
405
  *
406
+ * Not unconditionally, though (spec 445 §3.4): with no interaction there is no membership to ask,
407
+ * so the record must at least be true about its own parties — `admitUnpinned`. Like outcome 3
408
+ * this is the record's shape, never authority.
409
+ *
262
410
  * 2. UNKNOWN `interactionId` → REFUSED. Interactions are opened by their custodian
263
411
  * (`openInteraction`), never conjured by a sender. If ingress created one from a sender-supplied
264
412
  * id, any peer could seed arbitrary interactions with arbitrary participations on someone else's
265
413
  * gateway, then post into them — inventing a governed situation the owner never entered.
266
414
  *
267
- * 3. KNOWN `interactionId` → the sender must be a current participant. An exchange claiming to occur
415
+ * 3. KNOWN `interactionId` → the interaction must be `active` (DATB-2), and the sender must be a
416
+ * current participant. An exchange claiming to occur
268
417
  * in an interaction whose membership does not include its sender is a record that misrepresents
269
418
  * the situation. This is an integrity check on the record's shape, NOT authority: being a
270
419
  * participant is not permission to do anything (ADR-0048 §4).
@@ -277,6 +426,19 @@ export declare class PrincipalGatewayDO {
277
426
  * the digest stays pinned and resolvable later. What we must not do is pretend it is replayable.
278
427
  */
279
428
  private admitIntoInteraction;
429
+ /**
430
+ * An exchange with no interaction is admitted only if its sender is a party of the record it
431
+ * delivers (spec 445 §3.4, audit H-10 / DATA-1). Two checks, both fail-closed:
432
+ *
433
+ * · the delivered envelope's `from` IS the record's `parties.from` — a record cannot attribute
434
+ * somebody's envelope to somebody else;
435
+ * · this gateway's principal is a party (`from`, or in `to`/`cc`) — a gateway stores its own
436
+ * principal's exchanges, as sender or as recipient, and nobody else's.
437
+ *
438
+ * The principal is `PRINCIPAL_SA` when the deployment names it, else the record's own `principal`
439
+ * (a gateway that cannot name itself can only check the record against itself).
440
+ */
441
+ private admitUnpinned;
280
442
  /**
281
443
  * Membership for a `derived` interaction.
282
444
  *
@@ -293,6 +455,14 @@ export declare class PrincipalGatewayDO {
293
455
  * Open a governed situation on this gateway. The custodian is always THIS principal — an interaction
294
456
  * is custodied by the gateway that holds it, and accepting a caller-supplied principal would let a
295
457
  * peer name someone else as custodian of a situation on our storage.
458
+ *
459
+ * CREATE-ONLY (spec 445 §3.4, audit DATB-2). Opening never overwrites: an interaction already held
460
+ * under this id is returned as it stands when it is LIVE and was opened with the same profile,
461
+ * participation mode, participations and bindings (a retry); anything else — a different shape, or
462
+ * an interaction that has ended — throws `InteractionExistsError` and writes nothing. In particular
463
+ * there is no reopening a concluded interaction: the machine has no transition out of a terminal
464
+ * state, and `open` is not a way round it. (`suspended → active` is `resume`, via
465
+ * `interactions.transitionInteraction`, custodial and counted in `rev`.)
296
466
  */
297
467
  openInteraction(input: {
298
468
  interactionId: InteractionId;
@@ -303,8 +473,26 @@ export declare class PrincipalGatewayDO {
303
473
  at: string;
304
474
  protocolBindings?: readonly ProtocolBindingV1[];
305
475
  }): Promise<InteractionRecordV1>;
306
- /** Append one event to an existing exchange (case transitions / transport moves), reduced fail-closed. */
307
- applyEvent(exchangeId: ExchangeId | string, event: ExchangeEventV1): Promise<import("../exchange-reducer.js").ExchangeApplyResult | null>;
476
+ /**
477
+ * Append one event to an existing exchange (case transitions / transport moves), reduced fail-closed.
478
+ *
479
+ * The case machine authorizes a transition by comparing `event.actor` with the record's parties, so
480
+ * the actor must not be the caller's to choose (DATA-3): `event.actor` must be the AUTHENTICATED
481
+ * actor, on a minted caller for this gateway's principal. `null` ⇒ no such exchange. (`event.at` is
482
+ * still the caller's — audit DATB-11, open: the embedder stamps it.)
483
+ */
484
+ applyEvent(exchangeId: ExchangeId | string, event: ExchangeEventV1, caller: AuthenticatedCaller): Promise<import("../exchange-reducer.js").ExchangeApplyResult | null>;
485
+ /**
486
+ * Mint the caller for one admitted request (spec 445 §3.4, audit DATA-3) — the ONLY way to obtain an
487
+ * `AuthenticatedCaller`. Runs the injected authenticator; throws `GatewayAuthError` when none is
488
+ * configured (fail closed), when the request is not admitted, or when it was admitted for a
489
+ * principal other than this gateway's (`PRINCIPAL_SA`). A gateway that does not name itself takes the
490
+ * authenticator's principal — the embedder that built the port is the one that addressed this DO.
491
+ */
492
+ admitCaller(request: Request): Promise<AuthenticatedCaller>;
493
+ private isMinted;
494
+ /** `member` is the authenticated actor, or the actor is this gateway's own principal acting on it. */
495
+ private selfOrPrincipal;
308
496
  /** Interactions, context snapshots, decisions, commitments, per-viewer inbox state. */
309
497
  get interactions(): InteractionStore;
310
498
  /**
@@ -357,6 +545,13 @@ export declare class PrincipalGatewayDO {
357
545
  /** The principal's exchanges, newest first — the inbox-projection source (full `projectInboxItem` fold is
358
546
  * the W2 incremental-projection step; the durable stream it reads is here). */
359
547
  inbox(): Promise<ExchangeRecordV1[]>;
548
+ /**
549
+ * The HTTP surface. EVERY route authenticates first (spec 445 §3.4, audit DATA-3): `admitCaller`
550
+ * runs the injected authenticator before the path is even looked at, so with no authenticator the
551
+ * answer is 503 for everything, and an unadmitted request is 401 whatever it asked for. `principal`,
552
+ * `tier` and `actor` then come from that result alone — a body naming another principal or another
553
+ * actor is 403, and a body's `tier` is ignored.
554
+ */
360
555
  fetch(request: Request): Promise<Response>;
361
556
  /** Due-work processing (async). Drives two loops: (1) **outbox drain** — re-attempt `outboxDue(now)` peer
362
557
  * deliveries via the injected transport, `outboxDelivered` on success / `outbox.reschedule` with backoff on
@@ -365,4 +560,5 @@ export declare class PrincipalGatewayDO {
365
560
  * read (`outbox`, exchange stream) are here. */
366
561
  alarm(): Promise<void>;
367
562
  }
563
+ export {};
368
564
  //# sourceMappingURL=principal-gateway-do.d.ts.map
@@ -1 +1 @@
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