@agenticprimitives/fabric 0.0.0-alpha.1
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/CLAUDE.md +67 -0
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/case-machine.d.ts +76 -0
- package/dist/case-machine.d.ts.map +1 -0
- package/dist/case-machine.js +83 -0
- package/dist/case-machine.js.map +1 -0
- package/dist/client/index.d.ts +114 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +76 -0
- package/dist/client/index.js.map +1 -0
- package/dist/cloudflare/authority-verdict-cache.d.ts +27 -0
- package/dist/cloudflare/authority-verdict-cache.d.ts.map +1 -0
- package/dist/cloudflare/authority-verdict-cache.js +66 -0
- package/dist/cloudflare/authority-verdict-cache.js.map +1 -0
- package/dist/cloudflare/channel-store.d.ts +61 -0
- package/dist/cloudflare/channel-store.d.ts.map +1 -0
- package/dist/cloudflare/channel-store.js +124 -0
- package/dist/cloudflare/channel-store.js.map +1 -0
- package/dist/cloudflare/exchange-store.d.ts +16 -0
- package/dist/cloudflare/exchange-store.d.ts.map +1 -0
- package/dist/cloudflare/exchange-store.js +45 -0
- package/dist/cloudflare/exchange-store.js.map +1 -0
- package/dist/cloudflare/gateway-tools.d.ts +28 -0
- package/dist/cloudflare/gateway-tools.d.ts.map +1 -0
- package/dist/cloudflare/gateway-tools.js +45 -0
- package/dist/cloudflare/gateway-tools.js.map +1 -0
- package/dist/cloudflare/index.d.ts +13 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +20 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/cloudflare/orchestration-runtime.d.ts +28 -0
- package/dist/cloudflare/orchestration-runtime.d.ts.map +1 -0
- package/dist/cloudflare/orchestration-runtime.js +35 -0
- package/dist/cloudflare/orchestration-runtime.js.map +1 -0
- package/dist/cloudflare/outbox-store.d.ts +24 -0
- package/dist/cloudflare/outbox-store.d.ts.map +1 -0
- package/dist/cloudflare/outbox-store.js +42 -0
- package/dist/cloudflare/outbox-store.js.map +1 -0
- package/dist/cloudflare/principal-gateway-do.d.ts +234 -0
- package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -0
- package/dist/cloudflare/principal-gateway-do.js +369 -0
- package/dist/cloudflare/principal-gateway-do.js.map +1 -0
- package/dist/cloudflare/provenance-store.d.ts +9 -0
- package/dist/cloudflare/provenance-store.d.ts.map +1 -0
- package/dist/cloudflare/provenance-store.js +36 -0
- package/dist/cloudflare/provenance-store.js.map +1 -0
- package/dist/cloudflare/receipt-signer.d.ts +26 -0
- package/dist/cloudflare/receipt-signer.d.ts.map +1 -0
- package/dist/cloudflare/receipt-signer.js +69 -0
- package/dist/cloudflare/receipt-signer.js.map +1 -0
- package/dist/cloudflare/request-id-ledger.d.ts +13 -0
- package/dist/cloudflare/request-id-ledger.d.ts.map +1 -0
- package/dist/cloudflare/request-id-ledger.js +38 -0
- package/dist/cloudflare/request-id-ledger.js.map +1 -0
- package/dist/cloudflare/sql-vault.d.ts +10 -0
- package/dist/cloudflare/sql-vault.d.ts.map +1 -0
- package/dist/cloudflare/sql-vault.js +98 -0
- package/dist/cloudflare/sql-vault.js.map +1 -0
- package/dist/communicative-act.d.ts +47 -0
- package/dist/communicative-act.d.ts.map +1 -0
- package/dist/communicative-act.js +36 -0
- package/dist/communicative-act.js.map +1 -0
- package/dist/delivery-envelope.d.ts +38 -0
- package/dist/delivery-envelope.d.ts.map +1 -0
- package/dist/delivery-envelope.js +43 -0
- package/dist/delivery-envelope.js.map +1 -0
- package/dist/exchange-record.d.ts +131 -0
- package/dist/exchange-record.d.ts.map +1 -0
- package/dist/exchange-record.js +25 -0
- package/dist/exchange-record.js.map +1 -0
- package/dist/exchange-reducer.d.ts +25 -0
- package/dist/exchange-reducer.d.ts.map +1 -0
- package/dist/exchange-reducer.js +108 -0
- package/dist/exchange-reducer.js.map +1 -0
- package/dist/exchange-state.d.ts +56 -0
- package/dist/exchange-state.d.ts.map +1 -0
- package/dist/exchange-state.js +81 -0
- package/dist/exchange-state.js.map +1 -0
- package/dist/gateway-surface.d.ts +24 -0
- package/dist/gateway-surface.d.ts.map +1 -0
- package/dist/gateway-surface.js +33 -0
- package/dist/gateway-surface.js.map +1 -0
- package/dist/inbox-doc.d.ts +32 -0
- package/dist/inbox-doc.d.ts.map +1 -0
- package/dist/inbox-doc.js +57 -0
- package/dist/inbox-doc.js.map +1 -0
- package/dist/inbox-projection.d.ts +15 -0
- package/dist/inbox-projection.d.ts.map +1 -0
- package/dist/inbox-projection.js +28 -0
- package/dist/inbox-projection.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/interactions/audited.d.ts +12 -0
- package/dist/interactions/audited.d.ts.map +1 -0
- package/dist/interactions/audited.js +67 -0
- package/dist/interactions/audited.js.map +1 -0
- package/dist/interactions/builders.d.ts +24 -0
- package/dist/interactions/builders.d.ts.map +1 -0
- package/dist/interactions/builders.js +48 -0
- package/dist/interactions/builders.js.map +1 -0
- package/dist/interactions/cards.d.ts +32 -0
- package/dist/interactions/cards.d.ts.map +1 -0
- package/dist/interactions/cards.js +20 -0
- package/dist/interactions/cards.js.map +1 -0
- package/dist/interactions/index.d.ts +15 -0
- package/dist/interactions/index.d.ts.map +1 -0
- package/dist/interactions/index.js +23 -0
- package/dist/interactions/index.js.map +1 -0
- package/dist/interactions/machine.d.ts +19 -0
- package/dist/interactions/machine.d.ts.map +1 -0
- package/dist/interactions/machine.js +31 -0
- package/dist/interactions/machine.js.map +1 -0
- package/dist/interactions/mandates.d.ts +64 -0
- package/dist/interactions/mandates.d.ts.map +1 -0
- package/dist/interactions/mandates.js +62 -0
- package/dist/interactions/mandates.js.map +1 -0
- package/dist/interactions/relationship.d.ts +29 -0
- package/dist/interactions/relationship.d.ts.map +1 -0
- package/dist/interactions/relationship.js +31 -0
- package/dist/interactions/relationship.js.map +1 -0
- package/dist/interactions/risk.d.ts +39 -0
- package/dist/interactions/risk.d.ts.map +1 -0
- package/dist/interactions/risk.js +49 -0
- package/dist/interactions/risk.js.map +1 -0
- package/dist/interactions/runs.d.ts +26 -0
- package/dist/interactions/runs.d.ts.map +1 -0
- package/dist/interactions/runs.js +80 -0
- package/dist/interactions/runs.js.map +1 -0
- package/dist/interactions/store.d.ts +20 -0
- package/dist/interactions/store.d.ts.map +1 -0
- package/dist/interactions/store.js +68 -0
- package/dist/interactions/store.js.map +1 -0
- package/dist/interactions/tickets.d.ts +68 -0
- package/dist/interactions/tickets.d.ts.map +1 -0
- package/dist/interactions/tickets.js +49 -0
- package/dist/interactions/tickets.js.map +1 -0
- package/dist/interactions/types.d.ts +160 -0
- package/dist/interactions/types.d.ts.map +1 -0
- package/dist/interactions/types.js +7 -0
- package/dist/interactions/types.js.map +1 -0
- package/dist/messaging/board.d.ts +54 -0
- package/dist/messaging/board.d.ts.map +1 -0
- package/dist/messaging/board.js +90 -0
- package/dist/messaging/board.js.map +1 -0
- package/dist/messaging/conversation.d.ts +35 -0
- package/dist/messaging/conversation.d.ts.map +1 -0
- package/dist/messaging/conversation.js +72 -0
- package/dist/messaging/conversation.js.map +1 -0
- package/dist/messaging/delivery.d.ts +19 -0
- package/dist/messaging/delivery.d.ts.map +1 -0
- package/dist/messaging/delivery.js +56 -0
- package/dist/messaging/delivery.js.map +1 -0
- package/dist/messaging/directory.d.ts +32 -0
- package/dist/messaging/directory.d.ts.map +1 -0
- package/dist/messaging/directory.js +35 -0
- package/dist/messaging/directory.js.map +1 -0
- package/dist/messaging/envelope.d.ts +14 -0
- package/dist/messaging/envelope.d.ts.map +1 -0
- package/dist/messaging/envelope.js +71 -0
- package/dist/messaging/envelope.js.map +1 -0
- package/dist/messaging/hash.d.ts +19 -0
- package/dist/messaging/hash.d.ts.map +1 -0
- package/dist/messaging/hash.js +36 -0
- package/dist/messaging/hash.js.map +1 -0
- package/dist/messaging/index.d.ts +16 -0
- package/dist/messaging/index.d.ts.map +1 -0
- package/dist/messaging/index.js +29 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/messaging/projector.d.ts +58 -0
- package/dist/messaging/projector.d.ts.map +1 -0
- package/dist/messaging/projector.js +103 -0
- package/dist/messaging/projector.js.map +1 -0
- package/dist/messaging/receipts.d.ts +5 -0
- package/dist/messaging/receipts.d.ts.map +1 -0
- package/dist/messaging/receipts.js +19 -0
- package/dist/messaging/receipts.js.map +1 -0
- package/dist/messaging/rules.d.ts +84 -0
- package/dist/messaging/rules.d.ts.map +1 -0
- package/dist/messaging/rules.js +109 -0
- package/dist/messaging/rules.js.map +1 -0
- package/dist/messaging/store.d.ts +24 -0
- package/dist/messaging/store.d.ts.map +1 -0
- package/dist/messaging/store.js +120 -0
- package/dist/messaging/store.js.map +1 -0
- package/dist/messaging/types.d.ts +166 -0
- package/dist/messaging/types.d.ts.map +1 -0
- package/dist/messaging/types.js +7 -0
- package/dist/messaging/types.js.map +1 -0
- package/dist/messaging/vault-store.d.ts +37 -0
- package/dist/messaging/vault-store.d.ts.map +1 -0
- package/dist/messaging/vault-store.js +62 -0
- package/dist/messaging/vault-store.js.map +1 -0
- package/dist/record-catalog.d.ts +22 -0
- package/dist/record-catalog.d.ts.map +1 -0
- package/dist/record-catalog.js +35 -0
- package/dist/record-catalog.js.map +1 -0
- package/package.json +82 -0
- package/spec.md +15 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import type { Vault, DekWrapper } from '@agenticprimitives/vault';
|
|
2
|
+
import type { CanonicalAgentId } from '@agenticprimitives/types';
|
|
3
|
+
import type { AuthorityTier } from '@agenticprimitives/tool-policy';
|
|
4
|
+
import type { ExchangeRecordV1, ExchangeEventV1, ExchangeId } from '../exchange-record.js';
|
|
5
|
+
import { type DeliveryEnvelopeV1 } from '../delivery-envelope.js';
|
|
6
|
+
import { type OutboxEntry } from './outbox-store.js';
|
|
7
|
+
import { type AuthorityVerdictCache, type AuthorityVerdict, type AuthorityVerdictKey } from './authority-verdict-cache.js';
|
|
8
|
+
import { type DeliveryReceiptInput, type SignedDeliveryReceiptV1 } from './receipt-signer.js';
|
|
9
|
+
import type { GatewayToolRegistry } from './gateway-tools.js';
|
|
10
|
+
import type { Intent, Planner, RunResult } from '@agenticprimitives/orchestration';
|
|
11
|
+
import { type ProvenanceRecordV1 } from '@agenticprimitives/provenance';
|
|
12
|
+
import { type ChannelV1, type ConversationRoleProjection } from './channel-store.js';
|
|
13
|
+
/** Bindings the gateway DO needs. Kept minimal; W2 follow-steps add the receipt-signing key + chain-state RPC. */
|
|
14
|
+
export interface PrincipalGatewayEnv {
|
|
15
|
+
/** The chain id the gateway verifies authority against (for the T1 verdict + delivery). */
|
|
16
|
+
CHAIN_ID?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Injected co-resident-MCP dependencies. INJECTED (not built in the fabric core) because they need
|
|
20
|
+
* deployment config — kept out of the transport-agnostic package (spec 316 §8). The real DO is an app
|
|
21
|
+
* subclass: `class Gateway extends PrincipalGatewayDO { constructor(s, e) { super(s, e, buildDeps(e)); } }`;
|
|
22
|
+
* tests pass fakes. Absent ⇒ the storage/guard methods still work, but the co-resident-MCP methods throw.
|
|
23
|
+
*/
|
|
24
|
+
export interface GatewayDeps {
|
|
25
|
+
/** Cold-path: FULL token verification → the args-independent verdict (A), or `null` if invalid. The app
|
|
26
|
+
* wires `delegation.verifyDelegationToken` with its chainId / DelegationManager / RPC here. */
|
|
27
|
+
verifyToken(token: string): Promise<AuthorityVerdict | null>;
|
|
28
|
+
/** Resolve the per-owner DEK wrapper (the owner's KEK — KMS, cold-path). */
|
|
29
|
+
wrapperFor(owner: string): Promise<DekWrapper>;
|
|
30
|
+
/** The co-resident MCP tools this gateway serves (built-in vault tools + app tools). */
|
|
31
|
+
tools: GatewayToolRegistry;
|
|
32
|
+
/** The injected planner for the T2 orchestration loop (§15) — the LLM adapter in prod, the rule-based
|
|
33
|
+
* planner in tests. Absent ⇒ `orchestrate()` throws (T2 unavailable), but T0/T1 still work. */
|
|
34
|
+
planner?: Planner;
|
|
35
|
+
/** Token-gated channel join (spec 318 C3): verify a `member`'s `credential` satisfies a channel's
|
|
36
|
+
* `joinGate` requirement. Injected (the `entitlements`/`verifiable-credentials` resolver in prod, a fake in
|
|
37
|
+
* tests) — the fabric core stays credential-mechanism-free. Absent ⇒ a gated channel cannot be joined. */
|
|
38
|
+
verifyEntitlement?: (requirement: string, credential: unknown, member: string) => Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
export declare class PrincipalGatewayDO {
|
|
41
|
+
private readonly state;
|
|
42
|
+
private readonly env;
|
|
43
|
+
private readonly deps?;
|
|
44
|
+
private readonly sql;
|
|
45
|
+
private readonly exchanges;
|
|
46
|
+
private readonly verdicts;
|
|
47
|
+
private readonly requestIds;
|
|
48
|
+
private readonly receipts;
|
|
49
|
+
private readonly outbox;
|
|
50
|
+
private readonly provenance;
|
|
51
|
+
private readonly channels;
|
|
52
|
+
constructor(state: DurableObjectState, env: PrincipalGatewayEnv, deps?: GatewayDeps | undefined);
|
|
53
|
+
/** Create/rename a channel owned by this org gateway. */
|
|
54
|
+
createChannel(channel: ChannelV1): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Add a member with a role (spec 318 C2 — the role IS the projection of an org-SA delegation caveat).
|
|
57
|
+
* TOKEN-GATED (C3): if the channel carries a `joinGate`, the join is admitted ONLY if `opts.credential`
|
|
58
|
+
* satisfies it via the injected `verifyEntitlement` (fail-closed — no credential / no verifier / invalid ⇒
|
|
59
|
+
* rejected). An ungated channel joins openly.
|
|
60
|
+
*/
|
|
61
|
+
joinChannel(channelId: string, member: string, opts?: {
|
|
62
|
+
credential?: unknown;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
ok: true;
|
|
65
|
+
} | {
|
|
66
|
+
ok: false;
|
|
67
|
+
reason: string;
|
|
68
|
+
}>;
|
|
69
|
+
/** Remove a member — **kick = the org revokes** its role delegation (C2). */
|
|
70
|
+
leaveChannel(channelId: string, member: string): Promise<void>;
|
|
71
|
+
channelMembers(channelId: string): Promise<string[]>;
|
|
72
|
+
/** An agent's cached conversation-role projection, or `null` if none is projected (spec 324 §8). */
|
|
73
|
+
channelRoleProjection(channelId: string, agent: string): Promise<ConversationRoleProjection | null>;
|
|
74
|
+
/** AUTHORITATIVE projection (spec 324 §8): the org that OWNS this gateway caches a conversation-role it just
|
|
75
|
+
* materialized (RoleAssignment + delegation). Ungated — the principal is authoritative over its own
|
|
76
|
+
* conversations (this is the bootstrap + primary path). The `by`-gated variant is for delegated managers. */
|
|
77
|
+
projectConversationRole(channelId: string, projection: ConversationRoleProjection): Promise<void>;
|
|
78
|
+
/** MANAGE-gated (spec 324 §8): project a member's conversation role. `by` must hold a cached projection
|
|
79
|
+
* authorizing `manage`. This CACHES an org-issued RoleAssignment + its materializing delegation — it does
|
|
80
|
+
* not itself grant authority (ADR-0048 #4); the org issues the delegation, then the projection mirrors it. */
|
|
81
|
+
putConversationRoleProjection(channelId: string, projection: ConversationRoleProjection, by: string, at?: string): Promise<{
|
|
82
|
+
ok: true;
|
|
83
|
+
} | {
|
|
84
|
+
ok: false;
|
|
85
|
+
reason: string;
|
|
86
|
+
}>;
|
|
87
|
+
/** MANAGE-gated: clear a member's conversation-role projection (the org revoked the underlying delegation). */
|
|
88
|
+
clearConversationRoleProjection(channelId: string, member: string, by: string, at?: string): Promise<{
|
|
89
|
+
ok: true;
|
|
90
|
+
} | {
|
|
91
|
+
ok: false;
|
|
92
|
+
reason: string;
|
|
93
|
+
}>;
|
|
94
|
+
/** MODERATE-gated (spec 324 §8): remove a post from the channel board. `by` must hold a cached projection
|
|
95
|
+
* authorizing `moderate`. The exchange itself is NOT deleted (immutable stream + provenance); only its
|
|
96
|
+
* channel index entry is removed. */
|
|
97
|
+
removeChannelPost(channelId: string, exchangeId: string, by: string, at?: string): Promise<{
|
|
98
|
+
ok: true;
|
|
99
|
+
} | {
|
|
100
|
+
ok: false;
|
|
101
|
+
reason: string;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Post to a channel — MEMBER-GATED, fail-closed: only a current member (`record.parties.from`) may post.
|
|
105
|
+
* The post is persisted on the org's exchange stream via `deliver()` (so it accretes a provenance trace like
|
|
106
|
+
* any exchange) and indexed into the channel. Fan-out to members is the org re-delivering (§4 / Blocker 6).
|
|
107
|
+
*/
|
|
108
|
+
postToChannel(channelId: string, record: ExchangeRecordV1): Promise<{
|
|
109
|
+
ok: true;
|
|
110
|
+
} | {
|
|
111
|
+
ok: false;
|
|
112
|
+
reason: string;
|
|
113
|
+
}>;
|
|
114
|
+
/** Admit a Service-SA bot to a channel (the org's scoped channel-participation delegation). */
|
|
115
|
+
addChannelBot(channelId: string, botSA: string): Promise<void>;
|
|
116
|
+
/** Remove a bot — revoke its channel participation. */
|
|
117
|
+
removeChannelBot(channelId: string, botSA: string): Promise<void>;
|
|
118
|
+
channelBots(channelId: string): Promise<string[]>;
|
|
119
|
+
/** The channel's shared board — its posts (full exchange records), newest first. */
|
|
120
|
+
channelFeed(channelId: string): Promise<ExchangeRecordV1[]>;
|
|
121
|
+
/** Adapt a persisted `ExchangeRecordV1` to the provenance projector's STRUCTURAL input (the projector is a
|
|
122
|
+
* leaf — `fabric → provenance` §8 — so fabric does the mapping). `resourceOwner ≠ principal` ⇒ `onBehalfOf`
|
|
123
|
+
* (private detail); authority refs go by `kind:hash`; the body VaultRef is the output ref (never plaintext). */
|
|
124
|
+
private exchangeToProvenanceInput;
|
|
125
|
+
/** The exchange's PRIVATE provenance A-box (PROV-O activity + P-Plan, §6/§15), or `null`. */
|
|
126
|
+
getProvenance(exchangeId: ExchangeId | string): Promise<ProvenanceRecordV1 | null>;
|
|
127
|
+
/** The DO-local delivery-receipt attestation pubkey — publish it so senders can verify receipts. */
|
|
128
|
+
receiptPubkey(): Promise<string>;
|
|
129
|
+
/** Sign a `DeliveryReceiptV1` with the DO-local key — the delivery-proof-under-authority-at-T the sender
|
|
130
|
+
* gets, decoupled from body storage (spec 316 §3a receipt / Blocker 4). Verify with `verifyDeliveryReceipt`. */
|
|
131
|
+
signDeliveryReceipt(input: DeliveryReceiptInput): Promise<SignedDeliveryReceiptV1>;
|
|
132
|
+
/**
|
|
133
|
+
* RECIPIENT-side peer delivery (spec 316 §4 / W4). Transport-admits an inbound `DeliveryEnvelopeV1` (routing
|
|
134
|
+
* + addressing + structural), then persists the exchange, records the `delivered` fact, and returns a
|
|
135
|
+
* DO-signed `DeliveryReceiptV1`. Sender AUTHORITY (envelope signature) is re-verified separately by the gateway
|
|
136
|
+
* (ADR-0041) — admission here is transport-level only. `recipient` is this gateway's principal.
|
|
137
|
+
*/
|
|
138
|
+
receiveDelivery(delivery: DeliveryEnvelopeV1, opts: {
|
|
139
|
+
recipient: CanonicalAgentId;
|
|
140
|
+
tier: AuthorityTier;
|
|
141
|
+
at: string;
|
|
142
|
+
}): Promise<{
|
|
143
|
+
ok: true;
|
|
144
|
+
receipt: SignedDeliveryReceiptV1;
|
|
145
|
+
} | {
|
|
146
|
+
ok: false;
|
|
147
|
+
reason: string;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* T2 orchestrated lane (spec 316 §15) — a `request`/agent-task INTENT is fulfilled by the Ring-0
|
|
151
|
+
* orchestration loop running IN this gateway, with the co-resident MCP tools as the loop's ToolInvoker
|
|
152
|
+
* (in-process over the DO-local vault, under the verified `principal`). Only the LLM `planner` is injected;
|
|
153
|
+
* the loop, the tools, and the vault are the gateway's own. Returns the orchestration `RunResult`. (Absorbing
|
|
154
|
+
* `A2aTaskDO` + driving this from `alarm()` via a durable task queue is the remaining async-scheduling wrap.)
|
|
155
|
+
*/
|
|
156
|
+
orchestrate(input: {
|
|
157
|
+
intent: Intent;
|
|
158
|
+
principal: string;
|
|
159
|
+
maxSteps?: number;
|
|
160
|
+
exchangeId?: string;
|
|
161
|
+
at?: string;
|
|
162
|
+
}): Promise<RunResult>;
|
|
163
|
+
/** SENDER-side store-and-forward (spec 316 §4): queue a peer delivery that could not be handed to the
|
|
164
|
+
* recipient gateway now; `alarm()` retries with backoff until delivered (offline-first, §11a). */
|
|
165
|
+
enqueueOutbound(delivery: DeliveryEnvelopeV1, opts: {
|
|
166
|
+
nextAttemptAt: string;
|
|
167
|
+
at: string;
|
|
168
|
+
}): Promise<void>;
|
|
169
|
+
/** The due outbound deliveries to retry (the `alarm()` drain set). */
|
|
170
|
+
outboxDue(now: string): Promise<OutboxEntry[]>;
|
|
171
|
+
/** Mark an outbound delivery delivered (remove from the queue) after a successful peer hand-off. */
|
|
172
|
+
outboxDelivered(nonce: string): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* The co-resident vault for `wrapper`'s owner. The per-owner DEK `wrapper` (the owner's KEK) is resolved
|
|
175
|
+
* COLD-PATH by the caller (KMS, never on the warm lane — spec 316 §3/Blocker 4) and handed in, so this hot
|
|
176
|
+
* accessor stays key-material-free. Same `state.storage.sql` as the exchange stream — one trust domain.
|
|
177
|
+
*/
|
|
178
|
+
vault(wrapper: DekWrapper): Vault;
|
|
179
|
+
/**
|
|
180
|
+
* T0 communication lane — persist a delivered exchange (sender-proof-only; no case, no RPC — §3). The
|
|
181
|
+
* record is built upstream (envelope validated + `bodyHash`-verified at ingress); the DO is the durable
|
|
182
|
+
* single writer. Idempotent by `exchangeId` (put overwrites the same id; a genuine redelivery is caught by
|
|
183
|
+
* the message event's `idempotencyKey` at the reducer). Receipt signing (`DeliveryReceiptV1`, DO-local
|
|
184
|
+
* software key) is a W2 follow-step.
|
|
185
|
+
*/
|
|
186
|
+
deliver(record: ExchangeRecordV1): Promise<void>;
|
|
187
|
+
/** Append one event to an existing exchange (case transitions / transport moves), reduced fail-closed. */
|
|
188
|
+
applyEvent(exchangeId: ExchangeId | string, event: ExchangeEventV1): Promise<import("../exchange-reducer.js").ExchangeApplyResult | null>;
|
|
189
|
+
private requireDeps;
|
|
190
|
+
/** The verdict cache (revoke / epoch-sweep hooks + read for tests). */
|
|
191
|
+
get authority(): AuthorityVerdictCache;
|
|
192
|
+
/**
|
|
193
|
+
* COLD path (§3a): run the FULL injected `verifyToken` (establishes DEL-001 binding + ERC-1271 validity +
|
|
194
|
+
* `delegator===principal`) and, on success, cache the args-independent verdict (A) so the warm T1 lane can
|
|
195
|
+
* reuse it. Returns the verdict (or `null` if invalid). This is the ONLY place (A) is produced.
|
|
196
|
+
*/
|
|
197
|
+
verifyAndCache(token: string): Promise<AuthorityVerdict | null>;
|
|
198
|
+
/**
|
|
199
|
+
* T1 execution-fast lane (§3a) — the co-resident MCP call. Authorization = **(A) PLUS (B) PLUS a single-use
|
|
200
|
+
* requestId**, never (A) alone:
|
|
201
|
+
* (A) the CACHED args-independent verdict — a miss falls to the cold path (`verifyAndCache`);
|
|
202
|
+
* (B) the per-call caveat pass against the concrete tool+args — injected `runCaveatPass`, run on EVERY
|
|
203
|
+
* invoke, NEVER cached;
|
|
204
|
+
* then a single-use `requestId` (argsHash-bound by the caller) guards replay.
|
|
205
|
+
* Only AFTER all three does the co-resident tool run IN-PROCESS over the DO-local vault (resolved under the
|
|
206
|
+
* verified `principal`'s KEK) — no cross-service hop. A failed invoke releases the requestId (retryable).
|
|
207
|
+
*/
|
|
208
|
+
invokeFast(input: {
|
|
209
|
+
key: AuthorityVerdictKey;
|
|
210
|
+
requestId: string;
|
|
211
|
+
now: string;
|
|
212
|
+
tool: string;
|
|
213
|
+
args: Record<string, unknown>;
|
|
214
|
+
runCaveatPass: (verdict: AuthorityVerdict, tool: string, args: Record<string, unknown>) => Promise<boolean>;
|
|
215
|
+
}): Promise<{
|
|
216
|
+
ok: true;
|
|
217
|
+
principal: string;
|
|
218
|
+
result: unknown;
|
|
219
|
+
} | {
|
|
220
|
+
ok: false;
|
|
221
|
+
reason: string;
|
|
222
|
+
}>;
|
|
223
|
+
/** The principal's exchanges, newest first — the inbox-projection source (full `projectInboxItem` fold is
|
|
224
|
+
* the W2 incremental-projection step; the durable stream it reads is here). */
|
|
225
|
+
inbox(): Promise<ExchangeRecordV1[]>;
|
|
226
|
+
fetch(request: Request): Promise<Response>;
|
|
227
|
+
/** Due-work processing (async). Drives two loops: (1) **outbox drain** — re-attempt `outboxDue(now)` peer
|
|
228
|
+
* deliveries via the injected transport, `outboxDelivered` on success / `outbox.reschedule` with backoff on
|
|
229
|
+
* failure; (2) T2 orchestration (the §15 loop + `A2aTaskDO` absorption). Both need injected effects (the
|
|
230
|
+
* peer transport / the orchestration binding) — wired in the W2/W4 follow-steps; the durable queues they
|
|
231
|
+
* read (`outbox`, exchange stream) are here. */
|
|
232
|
+
alarm(): Promise<void>;
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=principal-gateway-do.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-gateway-do.d.ts","sourceRoot":"","sources":["../../src/cloudflare/principal-gateway-do.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAoD,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvG,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAA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MAAM,EAAE,KAAK,EAAE,eAAe;IAIxE,OAAO,CAAC,WAAW;IAKnB,uEAAuE;IACvE,IAAI,SAAS,IAAI,qBAAqB,CAErC;IAED;;;;OAIG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAMrE;;;;;;;;;OASG;IACG,UAAU,CAAC,KAAK,EAAE;QACtB,GAAG,EAAE,mBAAmB,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,aAAa,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;KAC7G,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAoB7F;oFACgF;IAC1E,KAAK,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAIpC,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IA4BhD;;;;qDAIiD;IAC3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { admitDeliveryEnvelope, deliveryToExchangeRecord, } from '../delivery-envelope.js';
|
|
2
|
+
import { createDurableObjectSqlVault } from './sql-vault.js';
|
|
3
|
+
import { createDurableObjectOutboxStore } from './outbox-store.js';
|
|
4
|
+
import { createDurableObjectExchangeStore } from './exchange-store.js';
|
|
5
|
+
import { createDurableObjectAuthorityVerdictCache, } from './authority-verdict-cache.js';
|
|
6
|
+
import { createDurableObjectRequestIdLedger } from './request-id-ledger.js';
|
|
7
|
+
import { createDurableObjectReceiptSigner, } from './receipt-signer.js';
|
|
8
|
+
import { runGatewayOrchestration } from './orchestration-runtime.js';
|
|
9
|
+
import { projectExchangeProvenance, projectRunProvenance, } from '@agenticprimitives/provenance';
|
|
10
|
+
import { createDurableObjectProvenanceStore } from './provenance-store.js';
|
|
11
|
+
import { createDurableObjectChannelStore, projectionAuthorizes } from './channel-store.js';
|
|
12
|
+
function json(body, status = 200) {
|
|
13
|
+
return new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } });
|
|
14
|
+
}
|
|
15
|
+
export class PrincipalGatewayDO {
|
|
16
|
+
state;
|
|
17
|
+
env;
|
|
18
|
+
deps;
|
|
19
|
+
sql;
|
|
20
|
+
exchanges;
|
|
21
|
+
verdicts;
|
|
22
|
+
requestIds;
|
|
23
|
+
receipts;
|
|
24
|
+
outbox;
|
|
25
|
+
provenance;
|
|
26
|
+
channels;
|
|
27
|
+
constructor(state, env, deps) {
|
|
28
|
+
this.state = state;
|
|
29
|
+
this.env = env;
|
|
30
|
+
this.deps = deps;
|
|
31
|
+
this.sql = state.storage.sql;
|
|
32
|
+
// Co-resident, DO-local: exchange stream + vault + T1 verdict cache + request-id ledger all share the
|
|
33
|
+
// one SQLite trust domain (L2, §4.0). The receipt signer holds a DO-local software key in DO KV storage.
|
|
34
|
+
this.exchanges = createDurableObjectExchangeStore(this.sql);
|
|
35
|
+
this.verdicts = createDurableObjectAuthorityVerdictCache(this.sql);
|
|
36
|
+
this.requestIds = createDurableObjectRequestIdLedger(this.sql);
|
|
37
|
+
this.receipts = createDurableObjectReceiptSigner(state.storage);
|
|
38
|
+
this.outbox = createDurableObjectOutboxStore(this.sql);
|
|
39
|
+
this.provenance = createDurableObjectProvenanceStore(this.sql);
|
|
40
|
+
this.channels = createDurableObjectChannelStore(this.sql);
|
|
41
|
+
}
|
|
42
|
+
// ─── Channels (spec 318 C1) — this gateway DO acts as an ORG SA's shared board ──────────────────────
|
|
43
|
+
// A channel is a shared context on this org's exchange stream; membership is the org's policy (projected
|
|
44
|
+
// from the app directory listing, spec 313); posting is member-gated fail-closed. Roles = delegations
|
|
45
|
+
// (C2) and token-gated join (C3) layer on top; the org agent acting in-channel is `orchestrate()` (§15).
|
|
46
|
+
/** Create/rename a channel owned by this org gateway. */
|
|
47
|
+
async createChannel(channel) {
|
|
48
|
+
return this.channels.createChannel(channel);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Add a member with a role (spec 318 C2 — the role IS the projection of an org-SA delegation caveat).
|
|
52
|
+
* TOKEN-GATED (C3): if the channel carries a `joinGate`, the join is admitted ONLY if `opts.credential`
|
|
53
|
+
* satisfies it via the injected `verifyEntitlement` (fail-closed — no credential / no verifier / invalid ⇒
|
|
54
|
+
* rejected). An ungated channel joins openly.
|
|
55
|
+
*/
|
|
56
|
+
async joinChannel(channelId, member, opts = {}) {
|
|
57
|
+
const channel = await this.channels.getChannel(channelId);
|
|
58
|
+
if (channel?.joinGate) {
|
|
59
|
+
const verify = this.deps?.verifyEntitlement;
|
|
60
|
+
if (!verify)
|
|
61
|
+
return { ok: false, reason: 'gate_unverifiable' };
|
|
62
|
+
if (opts.credential === undefined)
|
|
63
|
+
return { ok: false, reason: 'credential_required' };
|
|
64
|
+
if (!(await verify(channel.joinGate, opts.credential, member)))
|
|
65
|
+
return { ok: false, reason: 'entitlement_denied' };
|
|
66
|
+
}
|
|
67
|
+
// Joining establishes plain MEMBERSHIP only (spec 324 §8 — no mandatory role). In-conversation authority
|
|
68
|
+
// (moderate/manage) is a SEPARATE ConversationRoleProjection the org projects after issuing a RoleAssignment.
|
|
69
|
+
await this.channels.join(channelId, member);
|
|
70
|
+
return { ok: true };
|
|
71
|
+
}
|
|
72
|
+
/** Remove a member — **kick = the org revokes** its role delegation (C2). */
|
|
73
|
+
async leaveChannel(channelId, member) {
|
|
74
|
+
return this.channels.leave(channelId, member);
|
|
75
|
+
}
|
|
76
|
+
async channelMembers(channelId) {
|
|
77
|
+
return this.channels.members(channelId);
|
|
78
|
+
}
|
|
79
|
+
/** An agent's cached conversation-role projection, or `null` if none is projected (spec 324 §8). */
|
|
80
|
+
async channelRoleProjection(channelId, agent) {
|
|
81
|
+
return this.channels.roleProjection(channelId, agent);
|
|
82
|
+
}
|
|
83
|
+
/** AUTHORITATIVE projection (spec 324 §8): the org that OWNS this gateway caches a conversation-role it just
|
|
84
|
+
* materialized (RoleAssignment + delegation). Ungated — the principal is authoritative over its own
|
|
85
|
+
* conversations (this is the bootstrap + primary path). The `by`-gated variant is for delegated managers. */
|
|
86
|
+
async projectConversationRole(channelId, projection) {
|
|
87
|
+
await this.channels.putRoleProjection({ ...projection, conversationId: channelId });
|
|
88
|
+
}
|
|
89
|
+
/** MANAGE-gated (spec 324 §8): project a member's conversation role. `by` must hold a cached projection
|
|
90
|
+
* authorizing `manage`. This CACHES an org-issued RoleAssignment + its materializing delegation — it does
|
|
91
|
+
* not itself grant authority (ADR-0048 #4); the org issues the delegation, then the projection mirrors it. */
|
|
92
|
+
async putConversationRoleProjection(channelId, projection, by, at) {
|
|
93
|
+
if (!projectionAuthorizes(await this.channels.roleProjection(channelId, by), 'manage', at))
|
|
94
|
+
return { ok: false, reason: 'not_authorized' };
|
|
95
|
+
await this.channels.putRoleProjection({ ...projection, conversationId: channelId });
|
|
96
|
+
return { ok: true };
|
|
97
|
+
}
|
|
98
|
+
/** MANAGE-gated: clear a member's conversation-role projection (the org revoked the underlying delegation). */
|
|
99
|
+
async clearConversationRoleProjection(channelId, member, by, at) {
|
|
100
|
+
if (!projectionAuthorizes(await this.channels.roleProjection(channelId, by), 'manage', at))
|
|
101
|
+
return { ok: false, reason: 'not_authorized' };
|
|
102
|
+
await this.channels.clearRoleProjection(channelId, member);
|
|
103
|
+
return { ok: true };
|
|
104
|
+
}
|
|
105
|
+
/** MODERATE-gated (spec 324 §8): remove a post from the channel board. `by` must hold a cached projection
|
|
106
|
+
* authorizing `moderate`. The exchange itself is NOT deleted (immutable stream + provenance); only its
|
|
107
|
+
* channel index entry is removed. */
|
|
108
|
+
async removeChannelPost(channelId, exchangeId, by, at) {
|
|
109
|
+
if (!projectionAuthorizes(await this.channels.roleProjection(channelId, by), 'moderate', at))
|
|
110
|
+
return { ok: false, reason: 'not_authorized' };
|
|
111
|
+
await this.channels.removePost(channelId, exchangeId);
|
|
112
|
+
return { ok: true };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Post to a channel — MEMBER-GATED, fail-closed: only a current member (`record.parties.from`) may post.
|
|
116
|
+
* The post is persisted on the org's exchange stream via `deliver()` (so it accretes a provenance trace like
|
|
117
|
+
* any exchange) and indexed into the channel. Fan-out to members is the org re-delivering (§4 / Blocker 6).
|
|
118
|
+
*/
|
|
119
|
+
async postToChannel(channelId, record) {
|
|
120
|
+
const from = record.parties.from;
|
|
121
|
+
// A poster is either a channel MEMBER (person/org, C1/C2) or an admitted channel BOT (Service SA, C4).
|
|
122
|
+
if (!(await this.channels.isMember(channelId, from)) && !(await this.channels.isBot(channelId, from))) {
|
|
123
|
+
return { ok: false, reason: 'not_a_member' };
|
|
124
|
+
}
|
|
125
|
+
await this.deliver(record);
|
|
126
|
+
await this.channels.addPost(channelId, String(record.exchangeId), record.updatedAt);
|
|
127
|
+
return { ok: true };
|
|
128
|
+
}
|
|
129
|
+
// ─── C4: channel bots ARE Service Smart Agents (spec 318 §8) ─────────────────────────────────────────
|
|
130
|
+
// A bot is a DISTINCT Service SA admitted to the channel via a scoped org delegation (tracked here);
|
|
131
|
+
// it may post like a member (`postToChannel`). Invocation is INTENT-NATIVE: an @-mention routes to the
|
|
132
|
+
// bot's OWN gateway `orchestrate()` (§15), which posts the reply back via `postToChannel` under the bot's
|
|
133
|
+
// authority — not a webhook. The bot holds ONLY its scoped delegation; removeChannelBot = revoke.
|
|
134
|
+
/** Admit a Service-SA bot to a channel (the org's scoped channel-participation delegation). */
|
|
135
|
+
async addChannelBot(channelId, botSA) {
|
|
136
|
+
return this.channels.addBot(channelId, botSA);
|
|
137
|
+
}
|
|
138
|
+
/** Remove a bot — revoke its channel participation. */
|
|
139
|
+
async removeChannelBot(channelId, botSA) {
|
|
140
|
+
return this.channels.removeBot(channelId, botSA);
|
|
141
|
+
}
|
|
142
|
+
async channelBots(channelId) {
|
|
143
|
+
return this.channels.bots(channelId);
|
|
144
|
+
}
|
|
145
|
+
/** The channel's shared board — its posts (full exchange records), newest first. */
|
|
146
|
+
async channelFeed(channelId) {
|
|
147
|
+
const ids = await this.channels.postIds(channelId);
|
|
148
|
+
const out = [];
|
|
149
|
+
for (const id of ids) {
|
|
150
|
+
const rec = await this.exchanges.get(id);
|
|
151
|
+
if (rec)
|
|
152
|
+
out.push(rec);
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
/** Adapt a persisted `ExchangeRecordV1` to the provenance projector's STRUCTURAL input (the projector is a
|
|
157
|
+
* leaf — `fabric → provenance` §8 — so fabric does the mapping). `resourceOwner ≠ principal` ⇒ `onBehalfOf`
|
|
158
|
+
* (private detail); authority refs go by `kind:hash`; the body VaultRef is the output ref (never plaintext). */
|
|
159
|
+
exchangeToProvenanceInput(record) {
|
|
160
|
+
const onBehalfOf = record.resourceOwner && record.resourceOwner.toLowerCase() !== record.principal.toLowerCase()
|
|
161
|
+
? record.resourceOwner
|
|
162
|
+
: undefined;
|
|
163
|
+
return {
|
|
164
|
+
exchangeId: String(record.exchangeId),
|
|
165
|
+
tier: record.tier,
|
|
166
|
+
principal: record.principal,
|
|
167
|
+
from: record.parties.from,
|
|
168
|
+
at: record.updatedAt,
|
|
169
|
+
authorityRefs: (record.authorityRefs ?? []).map((r) => `${r.kind}:${r.hash}`),
|
|
170
|
+
onBehalfOf,
|
|
171
|
+
outputRef: record.envelopes[0]?.body?.resource,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** The exchange's PRIVATE provenance A-box (PROV-O activity + P-Plan, §6/§15), or `null`. */
|
|
175
|
+
async getProvenance(exchangeId) {
|
|
176
|
+
return this.provenance.get(String(exchangeId));
|
|
177
|
+
}
|
|
178
|
+
/** The DO-local delivery-receipt attestation pubkey — publish it so senders can verify receipts. */
|
|
179
|
+
async receiptPubkey() {
|
|
180
|
+
return this.receipts.pubkey();
|
|
181
|
+
}
|
|
182
|
+
/** Sign a `DeliveryReceiptV1` with the DO-local key — the delivery-proof-under-authority-at-T the sender
|
|
183
|
+
* gets, decoupled from body storage (spec 316 §3a receipt / Blocker 4). Verify with `verifyDeliveryReceipt`. */
|
|
184
|
+
async signDeliveryReceipt(input) {
|
|
185
|
+
return this.receipts.sign(input);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* RECIPIENT-side peer delivery (spec 316 §4 / W4). Transport-admits an inbound `DeliveryEnvelopeV1` (routing
|
|
189
|
+
* + addressing + structural), then persists the exchange, records the `delivered` fact, and returns a
|
|
190
|
+
* DO-signed `DeliveryReceiptV1`. Sender AUTHORITY (envelope signature) is re-verified separately by the gateway
|
|
191
|
+
* (ADR-0041) — admission here is transport-level only. `recipient` is this gateway's principal.
|
|
192
|
+
*/
|
|
193
|
+
async receiveDelivery(delivery, opts) {
|
|
194
|
+
const admission = admitDeliveryEnvelope(delivery, { recipient: opts.recipient });
|
|
195
|
+
if (!admission.ok)
|
|
196
|
+
return admission;
|
|
197
|
+
const rec = deliveryToExchangeRecord(delivery, { tier: opts.tier, at: opts.at });
|
|
198
|
+
await this.deliver(rec);
|
|
199
|
+
await this.applyEvent(rec.exchangeId, {
|
|
200
|
+
kind: 'message', seq: 0, at: opts.at, eventType: 'delivered', actor: delivery.envelope.from, messageId: delivery.envelope.id,
|
|
201
|
+
});
|
|
202
|
+
const receipt = await this.signDeliveryReceipt({
|
|
203
|
+
exchangeId: String(delivery.exchangeId), messageId: delivery.envelope.id, recipient: delivery.toGateway, at: opts.at,
|
|
204
|
+
});
|
|
205
|
+
return { ok: true, receipt };
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* T2 orchestrated lane (spec 316 §15) — a `request`/agent-task INTENT is fulfilled by the Ring-0
|
|
209
|
+
* orchestration loop running IN this gateway, with the co-resident MCP tools as the loop's ToolInvoker
|
|
210
|
+
* (in-process over the DO-local vault, under the verified `principal`). Only the LLM `planner` is injected;
|
|
211
|
+
* the loop, the tools, and the vault are the gateway's own. Returns the orchestration `RunResult`. (Absorbing
|
|
212
|
+
* `A2aTaskDO` + driving this from `alarm()` via a durable task queue is the remaining async-scheduling wrap.)
|
|
213
|
+
*/
|
|
214
|
+
async orchestrate(input) {
|
|
215
|
+
const deps = this.requireDeps();
|
|
216
|
+
if (!deps.planner)
|
|
217
|
+
throw new Error('PrincipalGatewayDO: no planner configured for T2 orchestration');
|
|
218
|
+
const vault = this.vault(await deps.wrapperFor(input.principal));
|
|
219
|
+
const result = await runGatewayOrchestration(input.intent, {
|
|
220
|
+
planner: deps.planner,
|
|
221
|
+
registry: deps.tools,
|
|
222
|
+
vault,
|
|
223
|
+
principal: input.principal,
|
|
224
|
+
maxSteps: input.maxSteps,
|
|
225
|
+
});
|
|
226
|
+
// W5 — bridge the executed plan into the exchange's provenance A-box as a P-Plan (the SAME trace as the
|
|
227
|
+
// OrchestratedTask activity, §15). Merged by `exchangeId` when the caller ties the run to an exchange.
|
|
228
|
+
if (input.exchangeId && input.at) {
|
|
229
|
+
const { plan } = projectRunProvenance({ exchangeId: input.exchangeId, goal: input.intent.goal, steps: result.plan.steps.map((s) => ({ toolId: s.toolId })) });
|
|
230
|
+
await this.provenance.put(input.exchangeId, { version: 'ap.provenance.v1', agents: [], activities: [], entities: [], plans: [plan] }, input.at);
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
/** SENDER-side store-and-forward (spec 316 §4): queue a peer delivery that could not be handed to the
|
|
235
|
+
* recipient gateway now; `alarm()` retries with backoff until delivered (offline-first, §11a). */
|
|
236
|
+
async enqueueOutbound(delivery, opts) {
|
|
237
|
+
return this.outbox.enqueue(delivery, opts);
|
|
238
|
+
}
|
|
239
|
+
/** The due outbound deliveries to retry (the `alarm()` drain set). */
|
|
240
|
+
async outboxDue(now) {
|
|
241
|
+
return this.outbox.due(now);
|
|
242
|
+
}
|
|
243
|
+
/** Mark an outbound delivery delivered (remove from the queue) after a successful peer hand-off. */
|
|
244
|
+
async outboxDelivered(nonce) {
|
|
245
|
+
return this.outbox.markDelivered(nonce);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The co-resident vault for `wrapper`'s owner. The per-owner DEK `wrapper` (the owner's KEK) is resolved
|
|
249
|
+
* COLD-PATH by the caller (KMS, never on the warm lane — spec 316 §3/Blocker 4) and handed in, so this hot
|
|
250
|
+
* accessor stays key-material-free. Same `state.storage.sql` as the exchange stream — one trust domain.
|
|
251
|
+
*/
|
|
252
|
+
vault(wrapper) {
|
|
253
|
+
return createDurableObjectSqlVault(this.sql, wrapper);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* T0 communication lane — persist a delivered exchange (sender-proof-only; no case, no RPC — §3). The
|
|
257
|
+
* record is built upstream (envelope validated + `bodyHash`-verified at ingress); the DO is the durable
|
|
258
|
+
* single writer. Idempotent by `exchangeId` (put overwrites the same id; a genuine redelivery is caught by
|
|
259
|
+
* the message event's `idempotencyKey` at the reducer). Receipt signing (`DeliveryReceiptV1`, DO-local
|
|
260
|
+
* software key) is a W2 follow-step.
|
|
261
|
+
*/
|
|
262
|
+
async deliver(record) {
|
|
263
|
+
await this.exchanges.put(record);
|
|
264
|
+
// W5 — project the exchange into the PRIVATE provenance A-box (one trace, §15). Off the sender's hot path
|
|
265
|
+
// conceptually, but co-located here (demo-scale); a public row is derived SEPARATELY via the S1 firewall.
|
|
266
|
+
await this.provenance.put(String(record.exchangeId), projectExchangeProvenance(this.exchangeToProvenanceInput(record)), record.updatedAt);
|
|
267
|
+
}
|
|
268
|
+
/** Append one event to an existing exchange (case transitions / transport moves), reduced fail-closed. */
|
|
269
|
+
async applyEvent(exchangeId, event) {
|
|
270
|
+
return this.exchanges.append(exchangeId, event);
|
|
271
|
+
}
|
|
272
|
+
requireDeps() {
|
|
273
|
+
if (!this.deps)
|
|
274
|
+
throw new Error('PrincipalGatewayDO: co-resident MCP deps not configured (verifyToken/wrapperFor/tools)');
|
|
275
|
+
return this.deps;
|
|
276
|
+
}
|
|
277
|
+
/** The verdict cache (revoke / epoch-sweep hooks + read for tests). */
|
|
278
|
+
get authority() {
|
|
279
|
+
return this.verdicts;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* COLD path (§3a): run the FULL injected `verifyToken` (establishes DEL-001 binding + ERC-1271 validity +
|
|
283
|
+
* `delegator===principal`) and, on success, cache the args-independent verdict (A) so the warm T1 lane can
|
|
284
|
+
* reuse it. Returns the verdict (or `null` if invalid). This is the ONLY place (A) is produced.
|
|
285
|
+
*/
|
|
286
|
+
async verifyAndCache(token) {
|
|
287
|
+
const verdict = await this.requireDeps().verifyToken(token);
|
|
288
|
+
if (verdict)
|
|
289
|
+
await this.verdicts.put(verdict);
|
|
290
|
+
return verdict;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* T1 execution-fast lane (§3a) — the co-resident MCP call. Authorization = **(A) PLUS (B) PLUS a single-use
|
|
294
|
+
* requestId**, never (A) alone:
|
|
295
|
+
* (A) the CACHED args-independent verdict — a miss falls to the cold path (`verifyAndCache`);
|
|
296
|
+
* (B) the per-call caveat pass against the concrete tool+args — injected `runCaveatPass`, run on EVERY
|
|
297
|
+
* invoke, NEVER cached;
|
|
298
|
+
* then a single-use `requestId` (argsHash-bound by the caller) guards replay.
|
|
299
|
+
* Only AFTER all three does the co-resident tool run IN-PROCESS over the DO-local vault (resolved under the
|
|
300
|
+
* verified `principal`'s KEK) — no cross-service hop. A failed invoke releases the requestId (retryable).
|
|
301
|
+
*/
|
|
302
|
+
async invokeFast(input) {
|
|
303
|
+
const deps = this.requireDeps();
|
|
304
|
+
const verdict = await this.verdicts.get(input.key); // (A)
|
|
305
|
+
if (!verdict)
|
|
306
|
+
return { ok: false, reason: 'verdict_miss_cold_path_required' };
|
|
307
|
+
if (!(await input.runCaveatPass(verdict, input.tool, input.args)))
|
|
308
|
+
return { ok: false, reason: 'caveat_denied' }; // (B), never cached
|
|
309
|
+
const tool = deps.tools.get(input.tool);
|
|
310
|
+
if (!tool)
|
|
311
|
+
return { ok: false, reason: 'unknown_tool' }; // check before reserving — an unknown tool burns no id
|
|
312
|
+
const reservation = await this.requestIds.reserve(input.requestId, input.now);
|
|
313
|
+
if (!reservation)
|
|
314
|
+
return { ok: false, reason: 'replay' };
|
|
315
|
+
try {
|
|
316
|
+
const wrapper = await deps.wrapperFor(verdict.principal);
|
|
317
|
+
const result = await tool.run({ principal: verdict.principal, vault: this.vault(wrapper), args: input.args });
|
|
318
|
+
await reservation.commit();
|
|
319
|
+
return { ok: true, principal: verdict.principal, result };
|
|
320
|
+
}
|
|
321
|
+
catch (e) {
|
|
322
|
+
await reservation.release(); // a failed invoke frees the id for a legitimate retry (spec 290 §3)
|
|
323
|
+
throw e;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/** The principal's exchanges, newest first — the inbox-projection source (full `projectInboxItem` fold is
|
|
327
|
+
* the W2 incremental-projection step; the durable stream it reads is here). */
|
|
328
|
+
async inbox() {
|
|
329
|
+
return this.exchanges.list();
|
|
330
|
+
}
|
|
331
|
+
async fetch(request) {
|
|
332
|
+
const url = new URL(request.url);
|
|
333
|
+
try {
|
|
334
|
+
if (request.method === 'POST' && url.pathname === '/deliver') {
|
|
335
|
+
await this.deliver((await request.json()));
|
|
336
|
+
return json({ ok: true });
|
|
337
|
+
}
|
|
338
|
+
if (request.method === 'POST' && url.pathname === '/event') {
|
|
339
|
+
const body = (await request.json());
|
|
340
|
+
const result = await this.applyEvent(body.exchangeId, body.event);
|
|
341
|
+
if (result === null)
|
|
342
|
+
return json({ ok: false, error: 'unknown_exchange' }, 404);
|
|
343
|
+
return result.ok ? json({ ok: true }) : json({ ok: false, error: result.reason }, 409);
|
|
344
|
+
}
|
|
345
|
+
if (request.method === 'GET' && url.pathname === '/inbox') {
|
|
346
|
+
return json({ ok: true, exchanges: await this.inbox() });
|
|
347
|
+
}
|
|
348
|
+
// TODO (W2 follow-steps, spec 316 §3/§4/§15):
|
|
349
|
+
// • T1 `invokeFast` — co-resident MCP `withDelegation` in-DO + `AuthorityVerdictCache` (full
|
|
350
|
+
// `verifyDelegationToken` §3a) + `RequestIdLedger`; sensitive stays T2.
|
|
351
|
+
// • T2 orchestrated — the `@agenticprimitives/orchestration` loop in this DO (intent alignment §15),
|
|
352
|
+
// driven by `alarm()`; absorb `A2aTaskDO`.
|
|
353
|
+
// • gatewayRoot delivery + signed `DeliveryReceiptV1` (DO-local software key).
|
|
354
|
+
return json({ ok: false, error: 'not_found' }, 404);
|
|
355
|
+
}
|
|
356
|
+
catch (e) {
|
|
357
|
+
return json({ ok: false, error: e instanceof Error ? e.message : String(e) }, 500);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/** Due-work processing (async). Drives two loops: (1) **outbox drain** — re-attempt `outboxDue(now)` peer
|
|
361
|
+
* deliveries via the injected transport, `outboxDelivered` on success / `outbox.reschedule` with backoff on
|
|
362
|
+
* failure; (2) T2 orchestration (the §15 loop + `A2aTaskDO` absorption). Both need injected effects (the
|
|
363
|
+
* peer transport / the orchestration binding) — wired in the W2/W4 follow-steps; the durable queues they
|
|
364
|
+
* read (`outbox`, exchange stream) are here. */
|
|
365
|
+
async alarm() {
|
|
366
|
+
// no-op until the peer transport + T2 orchestration bindings are injected
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=principal-gateway-do.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-gateway-do.js","sourceRoot":"","sources":["../../src/cloudflare/principal-gateway-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