@agenticprimitives/fabric 0.0.0-alpha.10 → 0.0.0-alpha.12
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 +30 -49
- package/dist/adoption.d.ts +79 -0
- package/dist/adoption.d.ts.map +1 -0
- package/dist/adoption.js +95 -0
- package/dist/adoption.js.map +1 -0
- package/dist/cloudflare/authority-verdict-cache.d.ts +28 -1
- package/dist/cloudflare/authority-verdict-cache.d.ts.map +1 -1
- package/dist/cloudflare/authority-verdict-cache.js +32 -1
- package/dist/cloudflare/authority-verdict-cache.js.map +1 -1
- package/dist/cloudflare/index.d.ts +3 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +3 -1
- package/dist/cloudflare/index.js.map +1 -1
- package/dist/cloudflare/principal-gateway-do.d.ts +18 -0
- package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -1
- package/dist/cloudflare/principal-gateway-do.js +9 -2
- package/dist/cloudflare/principal-gateway-do.js.map +1 -1
- package/dist/cloudflare/sql-vault.d.ts.map +1 -1
- package/dist/cloudflare/sql-vault.js +56 -0
- package/dist/cloudflare/sql-vault.js.map +1 -1
- package/dist/cloudflare/vault-exchange-store.d.ts +47 -0
- package/dist/cloudflare/vault-exchange-store.d.ts.map +1 -0
- package/dist/cloudflare/vault-exchange-store.js +118 -0
- package/dist/cloudflare/vault-exchange-store.js.map +1 -0
- package/dist/cloudflare/vault-interaction-store.d.ts +44 -0
- package/dist/cloudflare/vault-interaction-store.d.ts.map +1 -0
- package/dist/cloudflare/vault-interaction-store.js +245 -0
- package/dist/cloudflare/vault-interaction-store.js.map +1 -0
- package/dist/email/index.d.ts +75 -0
- package/dist/email/index.d.ts.map +1 -0
- package/dist/email/index.js +77 -0
- package/dist/email/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/interactions/grant-scopes.d.ts +21 -0
- package/dist/interactions/grant-scopes.d.ts.map +1 -0
- package/dist/interactions/grant-scopes.js +39 -0
- package/dist/interactions/grant-scopes.js.map +1 -0
- package/dist/interactions/index.d.ts +1 -0
- package/dist/interactions/index.d.ts.map +1 -1
- package/dist/interactions/index.js +3 -0
- package/dist/interactions/index.js.map +1 -1
- package/dist/interactions/open-case.d.ts +60 -0
- package/dist/interactions/open-case.d.ts.map +1 -0
- package/dist/interactions/open-case.js +83 -0
- package/dist/interactions/open-case.js.map +1 -0
- package/dist/messaging/consult-routing.d.ts +21 -14
- package/dist/messaging/consult-routing.d.ts.map +1 -1
- package/dist/messaging/consult-routing.js +34 -25
- package/dist/messaging/consult-routing.js.map +1 -1
- package/dist/messaging/consult.d.ts +4 -0
- package/dist/messaging/consult.d.ts.map +1 -1
- package/dist/messaging/consult.js +3 -1
- package/dist/messaging/consult.js.map +1 -1
- package/dist/messaging/conversation.d.ts +69 -1
- package/dist/messaging/conversation.d.ts.map +1 -1
- package/dist/messaging/conversation.js +131 -0
- package/dist/messaging/conversation.js.map +1 -1
- package/dist/messaging/index.d.ts +2 -1
- package/dist/messaging/index.d.ts.map +1 -1
- package/dist/messaging/index.js +6 -1
- package/dist/messaging/index.js.map +1 -1
- package/dist/messaging/outbound-message.d.ts +42 -0
- package/dist/messaging/outbound-message.d.ts.map +1 -0
- package/dist/messaging/outbound-message.js +64 -0
- package/dist/messaging/outbound-message.js.map +1 -0
- package/dist/record-catalog.d.ts.map +1 -1
- package/dist/record-catalog.js +5 -0
- package/dist/record-catalog.js.map +1 -1
- package/package.json +13 -9
package/CLAUDE.md
CHANGED
|
@@ -6,42 +6,11 @@ exec/case FSM. Decentralized (per-principal gateway + vault), tiered (T0/T1/T2),
|
|
|
6
6
|
re-verified against the principal SA. Transport-agnostic core; the Cloudflare `PrincipalGatewayDO`
|
|
7
7
|
adapter ships from `./cloudflare`.
|
|
8
8
|
|
|
9
|
-
## Status
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
single-writer `createDurableObjectExchangeStore` (fail-closed `applyExchangeEvent`); T0
|
|
15
|
-
`deliver`/`applyEvent`/`inbox`; T1 `AuthorityVerdictCache` + `RequestIdLedger` (§3a: cached verdict
|
|
16
|
-
A + single-use requestId); **co-resident MCP** (`invokeFast` runs the tool IN-PROCESS over the DO
|
|
17
|
-
vault after the A→B→requestId gate; heavy verify + KEK wrapper INJECTED via `GatewayDeps`); **T2
|
|
18
|
-
orchestration loop** (co-resident tools AS the `orchestration` ToolInvoker; only the LLM planner
|
|
19
|
-
injected); **signed `DeliveryReceiptV1`** (DO-local secp256k1). The ONLY subtree importing
|
|
20
|
-
`@cloudflare/workers-types`.
|
|
21
|
-
- **W4 DONE:** `GatewaySurfaceCommitmentV1` (gatewayRoot preimage) + peer `DeliveryEnvelopeV1` +
|
|
22
|
-
`receiveDelivery` + `OutboxStore` store-and-forward.
|
|
23
|
-
- **W6 DONE (spec 340 — the Agentic Interaction spine):** `apix:` is the canonical vocabulary
|
|
24
|
-
(`apfab:` RETIRED). `InteractionRecordV1` is the root aggregate; `ContextSnapshotV1` replaces
|
|
25
|
-
floating `contextRefs`; six state machines, never collapsed (delivery · inbox · interaction ·
|
|
26
|
-
decision · commitment · execution); versioned `InteractionProfile`s replace the `MessageKind`/
|
|
27
|
-
`CaseState` enums; `createDurableObjectInteractionStore` is their durable home on the gateway DO,
|
|
28
|
-
reachable as `do.interactions`. **The store exposes transitions, never state assignment** — the
|
|
29
|
-
creditor discharges, not the debtor, and persistence must not become a bypass.
|
|
30
|
-
- **W10a DONE (spec 340):** the case flow EMITS. `caseTransitionEmissions` + `applyCaseEmissions` put
|
|
31
|
-
`approve`/`deny`/`expire` into the decision machine and `issue-credential`/`revoke` into the
|
|
32
|
-
commitment machine, applied THROUGH those machines (never state assignment), wired into the
|
|
33
|
-
interaction store the Home drives. `deliver-credential` deliberately emits nothing — completing the
|
|
34
|
-
work discharges no obligation (ADR-0058 §15).
|
|
35
|
-
- **W10b DONE (spec 340):** `CaseState` is EXECUTION-ONLY (11 → 8). `approved`/`denied`/`expired`/
|
|
36
|
-
`revoked` removed, `closed` added. The transition VERBS are unchanged — which is why stored logs
|
|
37
|
-
replay untouched and no migration exists. `issue-credential`'s ordering is now a cross-machine
|
|
38
|
-
precondition (`requires-granted-decision`), projected onto `ExchangeRecordV1.decision` for the
|
|
39
|
-
reducer path, because that path had been getting the guarantee free from the FSM edge.
|
|
40
|
-
- **Next:** `MessageEnvelopeV1.kind` — the LAST enum, and the hard one: it is inside the signed wire
|
|
41
|
-
hash, so removal is an `ap.message.v2` cutover with re-signing, not a cleanup (spec 340 §R.1/§R.3); an interaction-aware ingress that
|
|
42
|
-
opens/joins an Interaction rather than only writing an Exchange; on-chain `atl:gatewayRoot` record
|
|
43
|
-
(contracts, separate); `A2aTaskDO`/`SessionStoreDO` absorption + `alarm()` drain; `fetch`/`alarm`
|
|
44
|
-
e2e via vitest-pool-workers.
|
|
9
|
+
## Status
|
|
10
|
+
**W1–W10b DONE.** Wave-by-wave history + what each shipped:
|
|
11
|
+
[`docs/architecture.md` §7a](docs/architecture.md). Next: `MessageEnvelopeV1.kind` — the last enum, and a
|
|
12
|
+
re-signing cutover rather than a cleanup (it is inside the signed wire hash, spec 340 §R.1/§R.3);
|
|
13
|
+
interaction-aware ingress; on-chain `atl:gatewayRoot`; `A2aTaskDO`/`SessionStoreDO` absorption.
|
|
45
14
|
|
|
46
15
|
## What this package owns
|
|
47
16
|
- `ExchangeRecordV1` — the ONE canonical object (spine id `xch_`); two-level FSM: `ExecState`
|
|
@@ -53,6 +22,16 @@ adapter ships from `./cloudflare`.
|
|
|
53
22
|
case reducer + typed payloads + runs (from `interactions`), delivery/admission/discovery.
|
|
54
23
|
|
|
55
24
|
## Hard rules
|
|
25
|
+
- **DO-local is the serving plane; the vault is the RECORD** ([ADR-0055](../../docs/architecture/decisions/0055-vaults-are-the-canonical-system-of-record-for-content.md)
|
|
26
|
+
+ amendment). `state.storage.sql` holds ordering, cursors, receipts, request-id ledgers, projections,
|
|
27
|
+
caches. Test for any new table: *if this DO were wiped, is the loss a rebuild or a bereavement?* A
|
|
28
|
+
projection must be rebuildable AND the rebuild tested (vault-first write · `rebuild()` in code · a test
|
|
29
|
+
that wipes and rebuilds) — `createVaultExchangeStore` / `createVaultInteractionStore` satisfy all three;
|
|
30
|
+
residency (**each party holds their own copy**) is [spec 316 §0b](../../specs/316-agentic-interaction-fabric.md).
|
|
31
|
+
`PrincipalGatewayDO` builds a DO-SQL vault INTERNALLY, so an adopting app MUST inject.
|
|
32
|
+
- **Two serving planes; the transition is a LADDER** ([ADR-0060](../../docs/architecture/decisions/0060-incremental-gateway-adoption.md)).
|
|
33
|
+
`InteractionsDO` serves; this is the target. Ops climb `off → shadow → serving` one at a time. A clean
|
|
34
|
+
shadow proves the planes AGREE, never that either is right.
|
|
56
35
|
- **Authority is never satisfied by the exchange.** A request carries an `authorityRef`; approving a
|
|
57
36
|
case advances the lifecycle, it NEVER unlocks a resource (spec 316 §2, ADR-0041).
|
|
58
37
|
- **`ExecState` is `fulfillment`'s `TaskState`, unmodified** — `fulfillment` stays a pure leaf.
|
|
@@ -60,6 +39,11 @@ adapter ships from `./cloudflare`.
|
|
|
60
39
|
- **Transport-agnostic core.** No Cloudflare/MCP/A2A-SDK imports in `src/` — `./cloudflare` is the
|
|
61
40
|
only adapter and the only `@cloudflare/workers-types` consumer.
|
|
62
41
|
|
|
42
|
+
- **The adoption ladder's mechanics are here** (`src/adoption.ts`, promoted in spec 399 §4): `AdoptionLedger`
|
|
43
|
+
types, `adoptionStage(ledger, op, env)` (the deployment's `GATEWAY_SHADOW` gates a shadow; `""` is unset),
|
|
44
|
+
`compareServed` / `classifyDivergence` (a race is not a divergence), `shouldShadow` sampling, the bounded
|
|
45
|
+
in-memory `recordDivergence`. The ledger VALUES — which op is on which rung, and why — stay with the product.
|
|
46
|
+
|
|
63
47
|
## Boundary
|
|
64
48
|
`types`, `fulfillment`, `vault`, `audit`, `delegation`, `chain-state`, `tool-policy`, `agent-naming`
|
|
65
49
|
(injected resolver) ← `fabric`; `fabric/cloudflare → orchestration` (adapter-only); `fabric →
|
|
@@ -71,17 +55,14 @@ pnpm --filter @agenticprimitives/fabric typecheck
|
|
|
71
55
|
pnpm --filter @agenticprimitives/fabric test
|
|
72
56
|
```
|
|
73
57
|
|
|
74
|
-
## Capabilities
|
|
75
|
-
- **Messaging + Interactions** ([
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
[`apps/demo-sso-next/docs/home-inbox/guide.md`](../../apps/demo-sso-next/docs/home-inbox/guide.md).
|
|
81
|
-
- Index: [`docs/architecture/cross-cutting-capabilities.md`](../../docs/architecture/cross-cutting-capabilities.md).
|
|
58
|
+
## Capabilities
|
|
59
|
+
- **Messaging + Interactions** ([spec 309](../../specs/309-messaging-and-interactions.md)) — fabric IS the
|
|
60
|
+
substrate both were absorbed into · [guide](../../apps/demo-sso-next/docs/messaging-interactions/guide.md).
|
|
61
|
+
- **Home control plane + inbox** ([spec 310](../../specs/310-agentic-trust-home-control-plane-and-inbox.md))
|
|
62
|
+
· [guide](../../apps/demo-sso-next/docs/home-inbox/guide.md).
|
|
63
|
+
- Index: [cross-cutting-capabilities.md](../../docs/architecture/cross-cutting-capabilities.md).
|
|
82
64
|
|
|
83
|
-
## Spec +
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`../../apps/demo-sso-next/docs/home-inbox/guide.md`.
|
|
65
|
+
## Spec + guides
|
|
66
|
+
[spec 316](../../specs/316-agentic-interaction-fabric.md) (architect-of-record) ·
|
|
67
|
+
[target](../../docs/architecture/agentic-interaction-fabric-target.md) · ADR-0047 ·
|
|
68
|
+
[fabric architecture](docs/architecture.md) (live wiring + build history).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** Which of the five candidate causes an op's move actually exercises. Naming it per op is the point of
|
|
2
|
+
* moving one at a time: if an op diverges, its concerns say where to look, and where not to. */
|
|
3
|
+
export type AdoptionConcern = 'auth' | 'projection' | 'ordering' | 'data-shape' | 'assistant';
|
|
4
|
+
export type AdoptionStage = 'off' | 'shadow' | 'serving';
|
|
5
|
+
export interface AdoptionEntry {
|
|
6
|
+
stage: AdoptionStage;
|
|
7
|
+
/** What moving this op puts at risk — read this first when its shadow diverges. */
|
|
8
|
+
concerns: readonly AdoptionConcern[];
|
|
9
|
+
/** Why this op is at this rung. Prose, because "it's next" and "it's blocked" look identical in a stage
|
|
10
|
+
* field, and the difference is the whole state of the migration. */
|
|
11
|
+
note: string;
|
|
12
|
+
/**
|
|
13
|
+
* Fields that legitimately differ between the two planes because each computes them at its own instant.
|
|
14
|
+
* Declared PER OP and BEFORE evidence arrives — classifying noise after seeing a report is how a real
|
|
15
|
+
* divergence gets explained away as expected. An EMPTY list is a claim, not an omission: it asserts this
|
|
16
|
+
* op has no per-read computation, so any difference is either a race or a defect. Say why in `note`.
|
|
17
|
+
*/
|
|
18
|
+
volatileFields: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
/** The ledger: one place that says which plane serves what, so adoption is data rather than conditionals
|
|
21
|
+
* spread across a serving object. An op absent from it is `off`: adoption is opt-in, because the failure
|
|
22
|
+
* mode of opt-out is an op that moved because nobody remembered to stop it. */
|
|
23
|
+
export type AdoptionLedger = Readonly<Record<string, AdoptionEntry>>;
|
|
24
|
+
/**
|
|
25
|
+
* The stage an op runs at IN THIS DEPLOYMENT. The ledger says how far an op has climbed in the code; the
|
|
26
|
+
* deployment's `GATEWAY_SHADOW` says whether it is running the comparison at all. Both are required, and the
|
|
27
|
+
* env one defaults to OFF — constructing the gateway creates its tables, and an ungated shadow on a hot op
|
|
28
|
+
* would make that storage decision for every principal at once. Empty string is unset, not enabled
|
|
29
|
+
* (`wrangler`'s `VAR = ""` binds an empty string that `??` sails straight past).
|
|
30
|
+
*/
|
|
31
|
+
export declare function adoptionStage(ledger: AdoptionLedger, op: string, env?: {
|
|
32
|
+
GATEWAY_SHADOW?: string;
|
|
33
|
+
}): AdoptionStage;
|
|
34
|
+
export interface Divergence {
|
|
35
|
+
op: string;
|
|
36
|
+
at: string;
|
|
37
|
+
/** `equal` is recorded too. A shadow that only reports differences cannot distinguish "the planes agree"
|
|
38
|
+
* from "the shadow never ran", and those justify opposite decisions about promoting. */
|
|
39
|
+
kind: 'equal' | 'value' | 'raced' | 'gateway-error' | 'shadow-skipped';
|
|
40
|
+
detail?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Compare the two planes' answers. Canonical JSON with sorted keys: key ORDER is not a difference worth
|
|
44
|
+
* blocking a promotion on. Everything else counts, including `undefined` vs absent — a field that vanished
|
|
45
|
+
* is exactly the data-shape drift being watched for.
|
|
46
|
+
*/
|
|
47
|
+
export declare function compareServed(op: string, served: unknown, shadow: unknown, at: string): Divergence;
|
|
48
|
+
/**
|
|
49
|
+
* Was an apparent divergence just the document moving between the two reads? After the shadow read, take
|
|
50
|
+
* the serving read AGAIN: `servedAgain` matches the shadow ⇒ the document moved — RACED, benign, evidence of
|
|
51
|
+
* nothing; `servedAgain` still matches the original and differs from the shadow ⇒ the planes really
|
|
52
|
+
* disagree. DELIBERATELY CONSERVATIVE: anything not provably a race stays `value`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function classifyDivergence(input: {
|
|
55
|
+
op: string;
|
|
56
|
+
served: unknown;
|
|
57
|
+
shadow: unknown;
|
|
58
|
+
servedAgain: unknown;
|
|
59
|
+
at: string;
|
|
60
|
+
}): Divergence;
|
|
61
|
+
/**
|
|
62
|
+
* Should this call run its shadow? Shadowing doubles the delegated reads on the path being shadowed, so it
|
|
63
|
+
* is SAMPLED: at most one shadow per principal per `intervalMs`. Time-based rather than 1-in-N because it
|
|
64
|
+
* bounds the ADDED LOAD directly; a ratio bounds a proportion of a rate that varies with how many clients a
|
|
65
|
+
* principal has open. The first call always samples — a low-traffic principal must still contribute.
|
|
66
|
+
*/
|
|
67
|
+
export declare function shouldShadow(input: {
|
|
68
|
+
lastShadowAt: number | undefined;
|
|
69
|
+
now: number;
|
|
70
|
+
intervalMs: number;
|
|
71
|
+
}): boolean;
|
|
72
|
+
/** One shadow per principal per minute: enough to catch a systematic difference within a session, far below
|
|
73
|
+
* a per-principal read limiter's budget even with several clients open. */
|
|
74
|
+
export declare const SHADOW_INTERVAL_MS = 60000;
|
|
75
|
+
/** How many divergences to keep — in MEMORY, not durable storage: diagnostics with a shelf life of one
|
|
76
|
+
* investigation. Losing them on isolate recycle is the correct trade. */
|
|
77
|
+
export declare const DIVERGENCE_BUFFER = 20;
|
|
78
|
+
export declare function recordDivergence(buf: Divergence[], d: Divergence): Divergence[];
|
|
79
|
+
//# sourceMappingURL=adoption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adoption.d.ts","sourceRoot":"","sources":["../src/adoption.ts"],"names":[],"mappings":"AAiBA;iGACiG;AACjG,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,CAAC;AAE9F,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,aAAa,CAAC;IACrB,mFAAmF;IACnF,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IACrC;yEACqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;gFAEgF;AAChF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAIlH;AAID,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX;6FACyF;IACzF,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,GAAG,gBAAgB,CAAC;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAKlG;AAoBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAQxI;AAID;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAGlH;AAED;4EAC4E;AAC5E,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC;0EAC0E;AAC1E,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAG/E"}
|
package/dist/adoption.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// INCREMENTAL SERVING-PLANE ADOPTION — the LADDER (ADR-0060; ADR-0055 amendment). Promoted from the runtime
|
|
2
|
+
// app in spec 399 W0 (§4): the ledger TYPES, the rung rule and the divergence/sampling mechanics are the
|
|
3
|
+
// contract every product adopting `PrincipalGatewayDO` needs; the ledger VALUES (which op sits on which rung,
|
|
4
|
+
// and why) stay with the product that owns those ops.
|
|
5
|
+
//
|
|
6
|
+
// THE LADDER. Every op climbs the same three rungs, and never skips one:
|
|
7
|
+
// `off` — the incumbent plane serves. The gateway is not consulted.
|
|
8
|
+
// `shadow` — the incumbent serves AND ITS ANSWER IS THE RESPONSE. The gateway runs alongside and the
|
|
9
|
+
// two are compared. Divergence is recorded; it never reaches the caller and never fails the
|
|
10
|
+
// request. This is the rung that converts "we think it matches" into evidence.
|
|
11
|
+
// `serving` — the gateway serves. Promotion is earned by a shadow run with no unexplained divergence,
|
|
12
|
+
// not by the code being finished.
|
|
13
|
+
//
|
|
14
|
+
// WHAT A RUNG DOES NOT DO. Shadowing proves the two planes AGREE; it does not prove either is right. An op
|
|
15
|
+
// whose incumbent implementation is wrong will shadow perfectly clean while the gateway faithfully
|
|
16
|
+
// reproduces the bug. Promotion is evidence of equivalence, not of correctness.
|
|
17
|
+
/**
|
|
18
|
+
* The stage an op runs at IN THIS DEPLOYMENT. The ledger says how far an op has climbed in the code; the
|
|
19
|
+
* deployment's `GATEWAY_SHADOW` says whether it is running the comparison at all. Both are required, and the
|
|
20
|
+
* env one defaults to OFF — constructing the gateway creates its tables, and an ungated shadow on a hot op
|
|
21
|
+
* would make that storage decision for every principal at once. Empty string is unset, not enabled
|
|
22
|
+
* (`wrangler`'s `VAR = ""` binds an empty string that `??` sails straight past).
|
|
23
|
+
*/
|
|
24
|
+
export function adoptionStage(ledger, op, env) {
|
|
25
|
+
const stage = ledger[op]?.stage ?? 'off';
|
|
26
|
+
if (stage === 'shadow' && (env?.GATEWAY_SHADOW ?? '').trim().toLowerCase() !== 'on')
|
|
27
|
+
return 'off';
|
|
28
|
+
return stage;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Compare the two planes' answers. Canonical JSON with sorted keys: key ORDER is not a difference worth
|
|
32
|
+
* blocking a promotion on. Everything else counts, including `undefined` vs absent — a field that vanished
|
|
33
|
+
* is exactly the data-shape drift being watched for.
|
|
34
|
+
*/
|
|
35
|
+
export function compareServed(op, served, shadow, at) {
|
|
36
|
+
const a = canonical(served);
|
|
37
|
+
const b = canonical(shadow);
|
|
38
|
+
if (a === b)
|
|
39
|
+
return { op, at, kind: 'equal' };
|
|
40
|
+
return { op, at, kind: 'value', detail: firstDifference(a, b) };
|
|
41
|
+
}
|
|
42
|
+
function canonical(v) {
|
|
43
|
+
return JSON.stringify(v, (_k, val) => val && typeof val === 'object' && !Array.isArray(val)
|
|
44
|
+
? Object.fromEntries(Object.entries(val).sort(([x], [y]) => x.localeCompare(y)))
|
|
45
|
+
: val) ?? 'undefined';
|
|
46
|
+
}
|
|
47
|
+
/** A bounded excerpt around the first difference. Bounded because a divergence report that embeds two whole
|
|
48
|
+
* documents is a copy of the person's records in a diagnostic buffer — the thing the vault doctrine exists
|
|
49
|
+
* to prevent, arrived at through the back door. */
|
|
50
|
+
function firstDifference(a, b) {
|
|
51
|
+
let i = 0;
|
|
52
|
+
while (i < a.length && i < b.length && a[i] === b[i])
|
|
53
|
+
i++;
|
|
54
|
+
const w = 40;
|
|
55
|
+
return `@${i}: served=${JSON.stringify(a.slice(Math.max(0, i - 8), i + w))} shadow=${JSON.stringify(b.slice(Math.max(0, i - 8), i + w))}`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Was an apparent divergence just the document moving between the two reads? After the shadow read, take
|
|
59
|
+
* the serving read AGAIN: `servedAgain` matches the shadow ⇒ the document moved — RACED, benign, evidence of
|
|
60
|
+
* nothing; `servedAgain` still matches the original and differs from the shadow ⇒ the planes really
|
|
61
|
+
* disagree. DELIBERATELY CONSERVATIVE: anything not provably a race stays `value`.
|
|
62
|
+
*/
|
|
63
|
+
export function classifyDivergence(input) {
|
|
64
|
+
const first = compareServed(input.op, input.served, input.shadow, input.at);
|
|
65
|
+
if (first.kind === 'equal')
|
|
66
|
+
return first;
|
|
67
|
+
const settled = compareServed(input.op, input.servedAgain, input.shadow, input.at);
|
|
68
|
+
if (settled.kind === 'equal') {
|
|
69
|
+
return { op: input.op, at: input.at, kind: 'raced', detail: 'document changed between the serving read and the shadow read' };
|
|
70
|
+
}
|
|
71
|
+
return first;
|
|
72
|
+
}
|
|
73
|
+
// ── Sampling ──────────────────────────────────────────────────────────────────────────────────────────
|
|
74
|
+
/**
|
|
75
|
+
* Should this call run its shadow? Shadowing doubles the delegated reads on the path being shadowed, so it
|
|
76
|
+
* is SAMPLED: at most one shadow per principal per `intervalMs`. Time-based rather than 1-in-N because it
|
|
77
|
+
* bounds the ADDED LOAD directly; a ratio bounds a proportion of a rate that varies with how many clients a
|
|
78
|
+
* principal has open. The first call always samples — a low-traffic principal must still contribute.
|
|
79
|
+
*/
|
|
80
|
+
export function shouldShadow(input) {
|
|
81
|
+
if (input.lastShadowAt === undefined)
|
|
82
|
+
return true;
|
|
83
|
+
return input.now - input.lastShadowAt >= input.intervalMs;
|
|
84
|
+
}
|
|
85
|
+
/** One shadow per principal per minute: enough to catch a systematic difference within a session, far below
|
|
86
|
+
* a per-principal read limiter's budget even with several clients open. */
|
|
87
|
+
export const SHADOW_INTERVAL_MS = 60_000;
|
|
88
|
+
/** How many divergences to keep — in MEMORY, not durable storage: diagnostics with a shelf life of one
|
|
89
|
+
* investigation. Losing them on isolate recycle is the correct trade. */
|
|
90
|
+
export const DIVERGENCE_BUFFER = 20;
|
|
91
|
+
export function recordDivergence(buf, d) {
|
|
92
|
+
buf.push(d);
|
|
93
|
+
return buf.length > DIVERGENCE_BUFFER ? buf.slice(-DIVERGENCE_BUFFER) : buf;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=adoption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adoption.js","sourceRoot":"","sources":["../src/adoption.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,yGAAyG;AACzG,8GAA8G;AAC9G,sDAAsD;AACtD,EAAE;AACF,yEAAyE;AACzE,0EAA0E;A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KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,+DAA+D,EAAE,CAAC;IAChI,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,yGAAyG;AAEzG;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAA4E;IACvG,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAClD,OAAO,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,UAAU,CAAC;AAC5D,CAAC;AAED;4EAC4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC;0EAC0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,UAAU,gBAAgB,CAAC,GAAiB,EAAE,CAAa;IAC/D,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9E,CAAC"}
|
|
@@ -23,5 +23,32 @@ export interface AuthorityVerdictCache {
|
|
|
23
23
|
/** Deployment-epoch change (spec 311): drop every verdict NOT on `currentEpoch`. */
|
|
24
24
|
sweepEpoch(currentEpoch: string): Promise<void>;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* How long a cached verdict may be reused before the cold path must run again.
|
|
28
|
+
*
|
|
29
|
+
* 60s mirrors `InteractionsDO`'s existing positive-verdict cache (NEW-H4/FAB-A2A-1), which was sized as
|
|
30
|
+
* an RPC-429 mitigation for high-frequency non-sensitive reads. Matching it keeps ONE number in the
|
|
31
|
+
* deployment rather than two that drift.
|
|
32
|
+
*/
|
|
33
|
+
export declare const VERDICT_TTL_MS = 60000;
|
|
34
|
+
export interface VerdictCacheOptions {
|
|
35
|
+
/** Bounded reuse window. `0` disables caching entirely (every get misses ⇒ cold path every call). */
|
|
36
|
+
ttlMs?: number;
|
|
37
|
+
now?: () => number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* BOUNDED REUSE IS PART OF THE VERDICT, NOT AN OPTIMISATION KNOB.
|
|
41
|
+
*
|
|
42
|
+
* Verdict (A) asserts "this delegation was valid AND UNREVOKED at `verifiedAt`". Serving it later without
|
|
43
|
+
* regard to age silently upgrades that into "is valid and unrevoked", which is a claim the cold path never
|
|
44
|
+
* made. Before this, `verified_at` was written and never read: a verdict cached once stayed warm forever,
|
|
45
|
+
* and a revoked delegation kept passing (A) until something called `invalidateDelegation` — a revocation
|
|
46
|
+
* NOTICE that has to be delivered by a second mechanism and may simply never arrive. Revocation that only
|
|
47
|
+
* works when someone remembers to push it is not revocation.
|
|
48
|
+
*
|
|
49
|
+
* Expiry is a MISS, not an error: `invokeFast` refuses on a miss and the caller re-runs `verifyAndCache`,
|
|
50
|
+
* which re-checks the signature and `isRevoked` on-chain. So the ceiling on serving a revoked delegation
|
|
51
|
+
* is `ttlMs`, and the mechanism is the same one throughout (ADR-0013) — the cold path, run again.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createDurableObjectAuthorityVerdictCache(sql: SqlStorage, opts?: VerdictCacheOptions): AuthorityVerdictCache;
|
|
27
54
|
//# sourceMappingURL=authority-verdict-cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authority-verdict-cache.d.ts","sourceRoot":"","sources":["../../src/cloudflare/authority-verdict-cache.ts"],"names":[],"mappings":"AA6BA;4GAC4G;AAC5G,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAYhH,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,GAAG,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C;mGAC+F;IAC/F,GAAG,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAChE,uFAAuF;IACvF,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,oFAAoF;IACpF,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAKD,wBAAgB,wCAAwC,
|
|
1
|
+
{"version":3,"file":"authority-verdict-cache.d.ts","sourceRoot":"","sources":["../../src/cloudflare/authority-verdict-cache.ts"],"names":[],"mappings":"AA6BA;4GAC4G;AAC5G,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAYhH,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,GAAG,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C;mGAC+F;IAC/F,GAAG,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAChE,uFAAuF;IACvF,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,oFAAoF;IACpF,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,MAAM,WAAW,mBAAmB;IAClC,qGAAqG;IACrG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wCAAwC,CACtD,GAAG,EAAE,UAAU,EACf,IAAI,CAAC,EAAE,mBAAmB,GACzB,qBAAqB,CAsDvB"}
|
|
@@ -26,10 +26,34 @@ const CREATE_TABLE = `CREATE TABLE IF NOT EXISTS authority_verdicts (
|
|
|
26
26
|
const CREATE_IDX_DELEG = `CREATE INDEX IF NOT EXISTS idx_authority_verdicts_deleg ON authority_verdicts (delegation_hash)`;
|
|
27
27
|
const CREATE_IDX_EPOCH = `CREATE INDEX IF NOT EXISTS idx_authority_verdicts_epoch ON authority_verdicts (epoch)`;
|
|
28
28
|
const keyOf = (k) => `${k.sessionKey.toLowerCase()}|${k.delegationHash.toLowerCase()}|${k.epoch}|${k.manager.toLowerCase()}`;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* How long a cached verdict may be reused before the cold path must run again.
|
|
31
|
+
*
|
|
32
|
+
* 60s mirrors `InteractionsDO`'s existing positive-verdict cache (NEW-H4/FAB-A2A-1), which was sized as
|
|
33
|
+
* an RPC-429 mitigation for high-frequency non-sensitive reads. Matching it keeps ONE number in the
|
|
34
|
+
* deployment rather than two that drift.
|
|
35
|
+
*/
|
|
36
|
+
export const VERDICT_TTL_MS = 60_000;
|
|
37
|
+
/**
|
|
38
|
+
* BOUNDED REUSE IS PART OF THE VERDICT, NOT AN OPTIMISATION KNOB.
|
|
39
|
+
*
|
|
40
|
+
* Verdict (A) asserts "this delegation was valid AND UNREVOKED at `verifiedAt`". Serving it later without
|
|
41
|
+
* regard to age silently upgrades that into "is valid and unrevoked", which is a claim the cold path never
|
|
42
|
+
* made. Before this, `verified_at` was written and never read: a verdict cached once stayed warm forever,
|
|
43
|
+
* and a revoked delegation kept passing (A) until something called `invalidateDelegation` — a revocation
|
|
44
|
+
* NOTICE that has to be delivered by a second mechanism and may simply never arrive. Revocation that only
|
|
45
|
+
* works when someone remembers to push it is not revocation.
|
|
46
|
+
*
|
|
47
|
+
* Expiry is a MISS, not an error: `invokeFast` refuses on a miss and the caller re-runs `verifyAndCache`,
|
|
48
|
+
* which re-checks the signature and `isRevoked` on-chain. So the ceiling on serving a revoked delegation
|
|
49
|
+
* is `ttlMs`, and the mechanism is the same one throughout (ADR-0013) — the cold path, run again.
|
|
50
|
+
*/
|
|
51
|
+
export function createDurableObjectAuthorityVerdictCache(sql, opts) {
|
|
30
52
|
sql.exec(CREATE_TABLE);
|
|
31
53
|
sql.exec(CREATE_IDX_DELEG);
|
|
32
54
|
sql.exec(CREATE_IDX_EPOCH);
|
|
55
|
+
const ttlMs = opts?.ttlMs ?? VERDICT_TTL_MS;
|
|
56
|
+
const now = opts?.now ?? (() => Date.now());
|
|
33
57
|
return {
|
|
34
58
|
async put(v) {
|
|
35
59
|
sql.exec(`INSERT INTO authority_verdicts (cache_key, principal, session_key, delegation_hash, epoch, manager, verified_at)
|
|
@@ -46,6 +70,13 @@ export function createDurableObjectAuthorityVerdictCache(sql) {
|
|
|
46
70
|
const r = rows[0];
|
|
47
71
|
if (!r)
|
|
48
72
|
return null;
|
|
73
|
+
// Age it out. An unparseable `verified_at` counts as EXPIRED: a row whose age cannot be established
|
|
74
|
+
// is one whose freshness cannot be established, and the safe reading of "I don't know" is a miss.
|
|
75
|
+
const verifiedAtMs = Date.parse(r.verified_at);
|
|
76
|
+
if (!Number.isFinite(verifiedAtMs) || now() - verifiedAtMs >= ttlMs) {
|
|
77
|
+
sql.exec('DELETE FROM authority_verdicts WHERE cache_key = ?', keyOf(key));
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
49
80
|
return {
|
|
50
81
|
principal: r.principal,
|
|
51
82
|
sessionKey: r.session_key,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authority-verdict-cache.js","sourceRoot":"","sources":["../../src/cloudflare/authority-verdict-cache.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,uEAAuE;AACvE,EAAE;AACF,0FAA0F;AAC1F,2GAA2G;AAC3G,oGAAoG;AACpG,iGAAiG;AACjG,4GAA4G;AAC5G,qDAAqD;AACrD,wGAAwG;AACxG,yGAAyG;AACzG,wGAAwG;AACxG,4GAA4G;AAC5G,oGAAoG;AACpG,EAAE;AACF,0GAA0G;AAE1G,MAAM,YAAY,GAAG;;;;;;;;EAQnB,CAAC;AACH,MAAM,gBAAgB,GAAG,iGAAiG,CAAC;AAC3H,MAAM,gBAAgB,GAAG,uFAAuF,CAAC;AAwCjH,MAAM,KAAK,GAAG,CAAC,CAAsB,EAAU,EAAE,CAC/C,GAAG,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;AAE1G,MAAM,UAAU,wCAAwC,
|
|
1
|
+
{"version":3,"file":"authority-verdict-cache.js","sourceRoot":"","sources":["../../src/cloudflare/authority-verdict-cache.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,uEAAuE;AACvE,EAAE;AACF,0FAA0F;AAC1F,2GAA2G;AAC3G,oGAAoG;AACp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InteractionStore, type InteractionStore, type Snapsh
|
|
|
4
4
|
export { createDurableObjectOutboxStore, type OutboxStore, type OutboxEntry } from './outbox-store.js';
|
|
5
5
|
export { createDurableObjectProvenanceStore, type ProvenanceStore } from './provenance-store.js';
|
|
6
6
|
export { createDurableObjectChannelStore, projectionAuthorizes, type ChannelStore, type ChannelV1, type ConversationRoleProjection, type ConversationRoleAction, } from './channel-store.js';
|
|
7
|
-
export { createDurableObjectAuthorityVerdictCache, type AuthorityVerdictCache, type AuthorityVerdict, type AuthorityVerdictKey, } from './authority-verdict-cache.js';
|
|
7
|
+
export { createDurableObjectAuthorityVerdictCache, VERDICT_TTL_MS, type VerdictCacheOptions, type AuthorityVerdictCache, type AuthorityVerdict, type AuthorityVerdictKey, } from './authority-verdict-cache.js';
|
|
8
8
|
export { createDurableObjectRequestIdLedger, type RequestIdLedger, type RequestIdReservation } from './request-id-ledger.js';
|
|
9
9
|
export { createDurableObjectReceiptSigner, verifyDeliveryReceipt, type DeliveryReceiptSigner, type DeliveryReceiptInput, type SignedDeliveryReceiptV1, } from './receipt-signer.js';
|
|
10
10
|
export { PrincipalGatewayDO, type PrincipalGatewayEnv, type GatewayDeps } from './principal-gateway-do.js';
|
|
11
11
|
export { buildVaultTools, createToolRegistry, type GatewayTool, type GatewayToolContext, type GatewayToolRegistry, } from './gateway-tools.js';
|
|
12
12
|
export { runGatewayOrchestration, gatewayToolSpecs, bindGatewayToolInvoker } from './orchestration-runtime.js';
|
|
13
|
+
export { createVaultExchangeStore, exchangeResource, EXCHANGE_INDEX_RESOURCE, type VaultExchangeStore, type ExchangeIndexV1, } from './vault-exchange-store.js';
|
|
14
|
+
export { createVaultInteractionStore, interactionResource, decisionResource, commitmentResource, snapshotResource, inboxEntryResource, INTERACTION_INDEX_RESOURCE, type VaultInteractionStore, type InteractionIndexV1, } from './vault-interaction-store.js';
|
|
13
15
|
export declare const FABRIC_CLOUDFLARE_ADAPTER_STATUS: "w2-coresident-mcp";
|
|
14
16
|
//# s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CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC/G,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,eAAO,MAAM,gCAAgC,EAAG,mBAA4B,CAAC"}
|
package/dist/cloudflare/index.js
CHANGED
|
@@ -14,11 +14,13 @@ export { createDurableObjectInteractionStore, } from './interaction-store.js';
|
|
|
14
14
|
export { createDurableObjectOutboxStore } from './outbox-store.js';
|
|
15
15
|
export { createDurableObjectProvenanceStore } from './provenance-store.js';
|
|
16
16
|
export { createDurableObjectChannelStore, projectionAuthorizes, } from './channel-store.js';
|
|
17
|
-
export { createDurableObjectAuthorityVerdictCache, } from './authority-verdict-cache.js';
|
|
17
|
+
export { createDurableObjectAuthorityVerdictCache, VERDICT_TTL_MS, } from './authority-verdict-cache.js';
|
|
18
18
|
export { createDurableObjectRequestIdLedger } from './request-id-ledger.js';
|
|
19
19
|
export { createDurableObjectReceiptSigner, verifyDeliveryReceipt, } from './receipt-signer.js';
|
|
20
20
|
export { PrincipalGatewayDO } from './principal-gateway-do.js';
|
|
21
21
|
export { buildVaultTools, createToolRegistry, } from './gateway-tools.js';
|
|
22
22
|
export { runGatewayOrchestration, gatewayToolSpecs, bindGatewayToolInvoker } from './orchestration-runtime.js';
|
|
23
|
+
export { createVaultExchangeStore, exchangeResource, EXCHANGE_INDEX_RESOURCE, } from './vault-exchange-store.js';
|
|
24
|
+
export { createVaultInteractionStore, interactionResource, decisionResource, commitmentResource, snapshotResource, inboxEntryResource, INTERACTION_INDEX_RESOURCE, } from './vault-interaction-store.js';
|
|
23
25
|
export const FABRIC_CLOUDFLARE_ADAPTER_STATUS = 'w2-coresident-mcp';
|
|
24
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,EAAE;AACF,wGAAwG;AACxG,wGAAwG;AACxG,yGAAyG;AACzG,yGAAyG;AACzG,4CAA4C;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAsB,MAAM,qBAAqB,CAAC;AAC3F,mGAAmG;AACnG,oGAAoG;AACpG,oEAAoE;AACpE,OAAO,EACL,mCAAmC,GAGpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,8BAA8B,EAAsC,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,kCAAkC,EAAwB,MAAM,uBAAuB,CAAC;AACjG,OAAO,EACL,+BAA+B,EAAE,oBAAoB,GAEtD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wCAAwC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,EAAE;AACF,wGAAwG;AACxG,wGAAwG;AACxG,yGAAyG;AACzG,yGAAyG;AACzG,4CAA4C;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAsB,MAAM,qBAAqB,CAAC;AAC3F,mGAAmG;AACnG,oGAAoG;AACpG,oEAAoE;AACpE,OAAO,EACL,mCAAmC,GAGpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,8BAA8B,EAAsC,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,kCAAkC,EAAwB,MAAM,uBAAuB,CAAC;AACjG,OAAO,EACL,+BAA+B,EAAE,oBAAoB,GAEtD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wCAAwC,EACxC,cAAc,GAKf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kCAAkC,EAAmD,MAAM,wBAAwB,CAAC;AAC7H,OAAO,EACL,gCAAgC,EAChC,qBAAqB,GAItB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAA8C,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EACL,eAAe,EACf,kBAAkB,GAInB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC/G,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,GAGxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,GAG3B,MAAM,8BAA8B,CAAC;AAEtC,MAAM,CAAC,MAAM,gCAAgC,GAAG,mBAA4B,CAAC"}
|
|
@@ -4,6 +4,7 @@ import type { AuthorityTier } from '@agenticprimitives/tool-policy';
|
|
|
4
4
|
import type { ExchangeRecordV1, ExchangeEventV1, ExchangeId } from '../exchange-record.js';
|
|
5
5
|
import { type DeliveryEnvelopeV1 } from '../delivery-envelope.js';
|
|
6
6
|
import { type OutboxEntry } from './outbox-store.js';
|
|
7
|
+
import { type ExchangeStore } from './exchange-store.js';
|
|
7
8
|
import { type InteractionStore } from './interaction-store.js';
|
|
8
9
|
import type { CommitmentRecordV1 } from '../interaction-machines.js';
|
|
9
10
|
import type { InteractionRecordV1, InteractionId, ProfileVersion, ParticipationV1 } from '../interaction-record.js';
|
|
@@ -40,6 +41,23 @@ export interface GatewayDeps {
|
|
|
40
41
|
/** The injected planner for the T2 orchestration loop (§15) — the LLM adapter in prod, the rule-based
|
|
41
42
|
* planner in tests. Absent ⇒ `orchestrate()` throws (T2 unavailable), but T0/T1 still work. */
|
|
42
43
|
planner?: Planner;
|
|
44
|
+
/**
|
|
45
|
+
* THE THREE STORAGE SEAMS (ADR-0055 amendment). Omit them and this DO constructs its own DO-SQL
|
|
46
|
+
* stores, which is right for tests and for a self-hosted single-tenant gateway. A deployment whose
|
|
47
|
+
* records already live in an owner's vault MUST inject instead — because otherwise adopting this DO
|
|
48
|
+
* moves person data out of the vault as a SIDE EFFECT of a runtime change, decided by a constructor
|
|
49
|
+
* rather than by anyone.
|
|
50
|
+
*
|
|
51
|
+
* `vault` is the one that carries durable private records, so it is the one that matters most.
|
|
52
|
+
* `exchangeStore` / `interactionStore` may stay DO-local ONLY as ordering + index over exchanges
|
|
53
|
+
* whose records live in the vault — and only if they are genuinely rebuildable from it: the durable
|
|
54
|
+
* fact written to the vault first, an explicit rebuild in code, and a test that wipes the DO and
|
|
55
|
+
* rebuilds. An untested rebuild path is indistinguishable from an absent one, which is how a
|
|
56
|
+
* projection silently becomes the only copy.
|
|
57
|
+
*/
|
|
58
|
+
vault?(wrapper: DekWrapper): Vault;
|
|
59
|
+
exchangeStore?: ExchangeStore;
|
|
60
|
+
interactionStore?: InteractionStore;
|
|
43
61
|
/** Token-gated channel join (spec 318 C3): verify a `member`'s `credential` satisfies a channel's
|
|
44
62
|
* `joinGate` requirement. Injected (the `entitlements`/`verifiable-credentials` resolver in prod, a fake in
|
|
45
63
|
* tests) — the fabric core stays credential-mechanism-free. Absent ⇒ a gated channel cannot be joined. */
|
|
@@ -1 +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,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C,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IA8BhD;;;;qDAIiD;IAC3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -35,8 +35,9 @@ export class PrincipalGatewayDO {
|
|
|
35
35
|
this.sql = state.storage.sql;
|
|
36
36
|
// Co-resident, DO-local: exchange stream + vault + T1 verdict cache + request-id ledger all share the
|
|
37
37
|
// one SQLite trust domain (L2, §4.0). The receipt signer holds a DO-local software key in DO KV storage.
|
|
38
|
-
|
|
39
|
-
this.
|
|
38
|
+
// Injected when the deployment's records live elsewhere (ADR-0055); DO-local otherwise.
|
|
39
|
+
this.exchanges = deps?.exchangeStore ?? createDurableObjectExchangeStore(this.sql);
|
|
40
|
+
this.interactionStore = deps?.interactionStore ?? createDurableObjectInteractionStore(this.sql);
|
|
40
41
|
this.verdicts = createDurableObjectAuthorityVerdictCache(this.sql);
|
|
41
42
|
this.requestIds = createDurableObjectRequestIdLedger(this.sql);
|
|
42
43
|
this.receipts = createDurableObjectReceiptSigner(state.storage);
|
|
@@ -290,6 +291,12 @@ export class PrincipalGatewayDO {
|
|
|
290
291
|
* accessor stays key-material-free. Same `state.storage.sql` as the exchange stream — one trust domain.
|
|
291
292
|
*/
|
|
292
293
|
vault(wrapper) {
|
|
294
|
+
// INJECTED WINS. A deployment whose records live in the owner's vault passes `deps.vault`; the
|
|
295
|
+
// DO-SQL construction below is the fallback for tests and single-tenant self-hosting. Inheriting
|
|
296
|
+
// the fallback in production is exactly the drift ADR-0055's amendment refuses: a custody change
|
|
297
|
+
// arriving as a side effect of a runtime change.
|
|
298
|
+
if (this.deps?.vault)
|
|
299
|
+
return this.deps.vault(wrapper);
|
|
293
300
|
return createDurableObjectSqlVault(this.sql, wrapper);
|
|
294
301
|
}
|
|
295
302
|
/**
|