@agenticprimitives/fabric 0.0.0-alpha.4 → 0.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CLAUDE.md +12 -2
  2. package/dist/cloudflare/index.d.ts +1 -0
  3. package/dist/cloudflare/index.d.ts.map +1 -1
  4. package/dist/cloudflare/index.js +4 -0
  5. package/dist/cloudflare/index.js.map +1 -1
  6. package/dist/cloudflare/interaction-store.d.ts +55 -0
  7. package/dist/cloudflare/interaction-store.d.ts.map +1 -0
  8. package/dist/cloudflare/interaction-store.js +230 -0
  9. package/dist/cloudflare/interaction-store.js.map +1 -0
  10. package/dist/cloudflare/principal-gateway-do.d.ts +118 -2
  11. package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -1
  12. package/dist/cloudflare/principal-gateway-do.js +182 -7
  13. package/dist/cloudflare/principal-gateway-do.js.map +1 -1
  14. package/dist/communicative-act.d.ts +24 -1
  15. package/dist/communicative-act.d.ts.map +1 -1
  16. package/dist/communicative-act.js +28 -0
  17. package/dist/communicative-act.js.map +1 -1
  18. package/dist/delivery-envelope.d.ts.map +1 -1
  19. package/dist/delivery-envelope.js +0 -1
  20. package/dist/delivery-envelope.js.map +1 -1
  21. package/dist/enum-retirement.d.ts +34 -0
  22. package/dist/enum-retirement.d.ts.map +1 -0
  23. package/dist/enum-retirement.js +87 -0
  24. package/dist/enum-retirement.js.map +1 -0
  25. package/dist/exchange-record.d.ts +19 -3
  26. package/dist/exchange-record.d.ts.map +1 -1
  27. package/dist/exchange-record.js.map +1 -1
  28. package/dist/exchange-reducer.d.ts +33 -0
  29. package/dist/exchange-reducer.d.ts.map +1 -1
  30. package/dist/exchange-reducer.js +48 -0
  31. package/dist/exchange-reducer.js.map +1 -1
  32. package/dist/index.d.ts +14 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +23 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/interaction-machines.d.ts +136 -0
  37. package/dist/interaction-machines.d.ts.map +1 -0
  38. package/dist/interaction-machines.js +174 -0
  39. package/dist/interaction-machines.js.map +1 -0
  40. package/dist/interaction-profile.d.ts +126 -0
  41. package/dist/interaction-profile.d.ts.map +1 -0
  42. package/dist/interaction-profile.js +192 -0
  43. package/dist/interaction-profile.js.map +1 -0
  44. package/dist/interaction-record.d.ts +168 -0
  45. package/dist/interaction-record.d.ts.map +1 -0
  46. package/dist/interaction-record.js +108 -0
  47. package/dist/interaction-record.js.map +1 -0
  48. package/dist/messaging/conversation-interaction.d.ts +66 -0
  49. package/dist/messaging/conversation-interaction.d.ts.map +1 -0
  50. package/dist/messaging/conversation-interaction.js +139 -0
  51. package/dist/messaging/conversation-interaction.js.map +1 -0
  52. package/dist/messaging/inbox-assistant.d.ts +6 -3
  53. package/dist/messaging/inbox-assistant.d.ts.map +1 -1
  54. package/dist/messaging/inbox-assistant.js +23 -2
  55. package/dist/messaging/inbox-assistant.js.map +1 -1
  56. package/dist/messaging/index.d.ts +4 -1
  57. package/dist/messaging/index.d.ts.map +1 -1
  58. package/dist/messaging/index.js +4 -0
  59. package/dist/messaging/index.js.map +1 -1
  60. package/dist/messaging/rules.d.ts +9 -2
  61. package/dist/messaging/rules.d.ts.map +1 -1
  62. package/dist/messaging/rules.js +8 -1
  63. package/dist/messaging/rules.js.map +1 -1
  64. package/dist/messaging/store.d.ts.map +1 -1
  65. package/dist/messaging/store.js +5 -3
  66. package/dist/messaging/store.js.map +1 -1
  67. package/dist/messaging/types.d.ts +30 -0
  68. package/dist/messaging/types.d.ts.map +1 -1
  69. package/dist/messaging/types.js +3 -0
  70. package/dist/messaging/types.js.map +1 -1
  71. package/dist/protocol-binding.d.ts +71 -0
  72. package/dist/protocol-binding.d.ts.map +1 -0
  73. package/dist/protocol-binding.js +0 -0
  74. package/dist/protocol-binding.js.map +1 -0
  75. package/dist/record-catalog.d.ts.map +1 -1
  76. package/dist/record-catalog.js +7 -0
  77. package/dist/record-catalog.js.map +1 -1
  78. package/package.json +7 -7
package/CLAUDE.md CHANGED
@@ -20,8 +20,18 @@ adapter ships from `./cloudflare`.
20
20
  `@cloudflare/workers-types`.
21
21
  - **W4 DONE:** `GatewaySurfaceCommitmentV1` (gatewayRoot preimage) + peer `DeliveryEnvelopeV1` +
22
22
  `receiveDelivery` + `OutboxStore` store-and-forward.
23
- - **Next:** on-chain `atl:gatewayRoot` record (contracts, separate); `A2aTaskDO`/`SessionStoreDO`
24
- absorption + `alarm()` drain; `fetch`/`alarm` e2e via vitest-pool-workers.
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
+ - **Next:** the `MessageKind`/`CaseState` REMOVAL (spec 340 §R — the mapping is total and
31
+ compiler-checked; the rewrite spans 26 files and is its own wave); an interaction-aware ingress that
32
+ opens/joins an Interaction rather than only writing an Exchange; on-chain `atl:gatewayRoot` record
33
+ (contracts, separate); `A2aTaskDO`/`SessionStoreDO` absorption + `alarm()` drain; `fetch`/`alarm`
34
+ e2e via vitest-pool-workers.
25
35
 
26
36
  ## What this package owns
27
37
  - `ExchangeRecordV1` — the ONE canonical object (spine id `xch_`); two-level FSM: `ExecState`
@@ -1,5 +1,6 @@
1
1
  export { createDurableObjectSqlVault } from './sql-vault.js';
2
2
  export { createDurableObjectExchangeStore, type ExchangeStore } from './exchange-store.js';
3
+ export { createDurableObjectInteractionStore, type InteractionStore, type SnapshotPutResult, } from './interaction-store.js';
3
4
  export { createDurableObjectOutboxStore, type OutboxStore, type OutboxEntry } from './outbox-store.js';
4
5
  export { createDurableObjectProvenanceStore, type ProvenanceStore } from './provenance-store.js';
5
6
  export { createDurableObjectChannelStore, projectionAuthorizes, type ChannelStore, type ChannelV1, type ConversationRoleProjection, type ConversationRoleAction, } from './channel-store.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,8BAA8B,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,kCAAkC,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EACL,+BAA+B,EAAE,oBAAoB,EACrD,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,0BAA0B,EAAE,KAAK,sBAAsB,GAChG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wCAAwC,EACxC,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kCAAkC,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC7H,OAAO,EACL,gCAAgC,EAChC,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,C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kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAE/G,eAAO,MAAM,gCAAgC,EAAG,mBAA4B,CAAC"}
@@ -7,6 +7,10 @@
7
7
  // absorption follow in subsequent W2 steps.
8
8
  export { createDurableObjectSqlVault } from './sql-vault.js';
9
9
  export { createDurableObjectExchangeStore } from './exchange-store.js';
10
+ // The interaction spine's durable home (spec 340 W6) — interactions, context snapshots, decisions,
11
+ // commitments and per-viewer inbox state. Five tables, because the six machines answer to different
12
+ // parties at different times and one row would make them one write.
13
+ export { createDurableObjectInteractionStore, } from './interaction-store.js';
10
14
  export { createDurableObjectOutboxStore } from './outbox-store.js';
11
15
  export { createDurableObjectProvenanceStore } from './provenance-store.js';
12
16
  export { createDurableObjectChannelStore, projectionAuthorizes, } from './channel-store.js';
@@ -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,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,GAIzC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kCAAkC,EAAmD,MAAM,wBAAwB,CAAC;AAC7H,OAAO,EACL,gCAAgC,EAChC,qBAAqB,GAItB,MAAM,qBAAqB,CAA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AA4B,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { InteractionRecordV1, InteractionId, ContextSnapshotV1 } from '../interaction-record.js';
2
+ import { type InteractionLifecycleV1, type InteractionTransition, type DecisionRecordV1, type DecisionTransition, type CommitmentRecordV1, type CommitmentTransition, type InboxEntryV1, type InboxTransition, type MachineResult } from '../interaction-machines.js';
3
+ import { type ProtocolBindingV1, type BindingResolution } from '../protocol-binding.js';
4
+ import type { CanonicalAgentId } from '@agenticprimitives/types';
5
+ export type SnapshotPutResult = {
6
+ ok: true;
7
+ stored: 'new' | 'identical';
8
+ } | {
9
+ ok: false;
10
+ reason: 'digest-mismatch';
11
+ };
12
+ export interface InteractionStore {
13
+ putInteraction(record: InteractionRecordV1): Promise<void>;
14
+ getInteraction(id: InteractionId | string): Promise<InteractionRecordV1 | null>;
15
+ listInteractions(): Promise<InteractionRecordV1[]>;
16
+ /** Drive the interaction lifecycle THROUGH its machine. `null` when the interaction is unknown. */
17
+ transitionInteraction(id: InteractionId | string, event: {
18
+ transition: InteractionTransition;
19
+ actor: CanonicalAgentId;
20
+ at: string;
21
+ }): Promise<MachineResult<InteractionLifecycleV1> | null>;
22
+ /** Index a foreign correlator. Duplicates across interactions are KEPT — that is the ambiguity. */
23
+ bindProtocolTo(id: InteractionId, binding: ProtocolBindingV1): Promise<void>;
24
+ resolveByBinding(protocol: string, field: string, value: string): Promise<BindingResolution>;
25
+ /** Content-addressed. Verifies the digest against the bytes before storing — which IS the
26
+ * immutability guarantee: forged content cannot reach a digest it does not hash to. */
27
+ putContextSnapshot(snapshot: ContextSnapshotV1): Promise<SnapshotPutResult>;
28
+ getContextSnapshot(digest: string): Promise<ContextSnapshotV1 | null>;
29
+ putDecision(record: DecisionRecordV1): Promise<void>;
30
+ getDecision(id: string): Promise<DecisionRecordV1 | null>;
31
+ transitionDecision(id: string, event: {
32
+ transition: DecisionTransition;
33
+ actor: CanonicalAgentId;
34
+ at: string;
35
+ subject?: string;
36
+ }): Promise<MachineResult<DecisionRecordV1> | null>;
37
+ putCommitment(record: CommitmentRecordV1): Promise<void>;
38
+ getCommitment(id: string): Promise<CommitmentRecordV1 | null>;
39
+ /** Open obligations — the query "what is still owed" that a single `case` field could not answer. */
40
+ listOpenCommitments(): Promise<CommitmentRecordV1[]>;
41
+ transitionCommitment(id: string, event: {
42
+ transition: CommitmentTransition;
43
+ actor: CanonicalAgentId;
44
+ at: string;
45
+ }): Promise<MachineResult<CommitmentRecordV1> | null>;
46
+ putInboxEntry(entry: InboxEntryV1): Promise<void>;
47
+ getInboxEntry(viewer: CanonicalAgentId, exchangeId: string): Promise<InboxEntryV1 | null>;
48
+ transitionInbox(viewer: CanonicalAgentId, exchangeId: string, event: {
49
+ transition: InboxTransition;
50
+ actor: CanonicalAgentId;
51
+ at: string;
52
+ }): Promise<MachineResult<InboxEntryV1> | null>;
53
+ }
54
+ export declare function createDurableObjectInteractionStore(sql: SqlStorage): InteractionStore;
55
+ //# sourceMappingURL=interaction-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-store.d.ts","sourceRoot":"","sources":["../../src/cloudflare/interaction-store.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAEtG,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AA8CjE,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM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,0 +1,230 @@
1
+ /// <reference types="@cloudflare/workers-types" />
2
+ // DO-local InteractionStore (spec 340 W6) — durable homes for the records W2–W5 defined and nothing
3
+ // wrote. The `PrincipalGatewayDO` is the single writer for its principal, so no cross-writer races.
4
+ //
5
+ // Five tables, and the reason they are five rather than one wide row is the reason there are six state
6
+ // machines: an interaction's lifecycle, a decision, a commitment and a viewer's inbox state are
7
+ // answered by different parties at different times, and one row would make them one write.
8
+ //
9
+ // TWO INVARIANTS THIS LAYER OWNS, both about immutability rather than authority:
10
+ //
11
+ // 1. A ContextSnapshot is CONTENT-ADDRESSED, and the digest check IS the immutability guarantee.
12
+ // `putContextSnapshot` verifies the digest against the bytes before storing, so a party cannot
13
+ // rewrite what an evaluator saw while every Exchange still pins the same hash — the forged
14
+ // snapshot is refused at the door, not detected later.
15
+ //
16
+ // There is deliberately no separate `immutable-conflict` outcome. It was written first and was
17
+ // BOTH dead and wrong: dead, because content that differs necessarily fails the digest check
18
+ // already; and wrong, because it compared `JSON.stringify` output, so the same snapshot re-put
19
+ // with a different key insertion order would have been rejected as a conflicting overwrite. A
20
+ // verified digest with a row already at it means the content is the same — that is what
21
+ // content-addressing means — so the re-put is a no-op.
22
+ // 2. Every transition goes through its machine. The store never sets a state directly, so "the
23
+ // creditor discharges, not the debtor" cannot be bypassed by writing the row.
24
+ //
25
+ // It confers nothing. Persisting a commitment does not make it owed; persisting a decision does not
26
+ // authorize anything. Authority is `delegation` + `entitlements` + `tool-policy` at the moment of
27
+ // acting (ADR-0041, ADR-0043).
28
+ import { verifyContextSnapshot } from '../interaction-record.js';
29
+ import { applyInteractionTransition, applyDecisionTransition, applyCommitmentTransition, applyInboxTransition, } from '../interaction-machines.js';
30
+ import { bindingKey, resolveInteractionByBinding, } from '../protocol-binding.js';
31
+ const CREATE_TABLES = [
32
+ `CREATE TABLE IF NOT EXISTS interaction_records (
33
+ interaction_id TEXT PRIMARY KEY,
34
+ record_json TEXT NOT NULL,
35
+ state TEXT NOT NULL,
36
+ rev INTEGER NOT NULL,
37
+ updated_at TEXT NOT NULL
38
+ )`,
39
+ // Keyed by the binding, not by the interaction: the lookup direction is foreign → ours, and a
40
+ // duplicate key across two interactions is the AMBIGUITY the resolver must be able to see. A UNIQUE
41
+ // constraint here would silently drop the second one and manufacture a confident wrong answer.
42
+ `CREATE TABLE IF NOT EXISTS interaction_bindings (
43
+ binding_key TEXT NOT NULL,
44
+ interaction_id TEXT NOT NULL,
45
+ binding_json TEXT NOT NULL,
46
+ PRIMARY KEY (binding_key, interaction_id)
47
+ )`,
48
+ `CREATE TABLE IF NOT EXISTS context_snapshots (
49
+ digest TEXT PRIMARY KEY,
50
+ snapshot_json TEXT NOT NULL
51
+ )`,
52
+ `CREATE TABLE IF NOT EXISTS decision_records (
53
+ decision_id TEXT PRIMARY KEY,
54
+ record_json TEXT NOT NULL,
55
+ updated_at TEXT NOT NULL
56
+ )`,
57
+ `CREATE TABLE IF NOT EXISTS commitment_records (
58
+ commitment_id TEXT PRIMARY KEY,
59
+ record_json TEXT NOT NULL,
60
+ state TEXT NOT NULL,
61
+ updated_at TEXT NOT NULL
62
+ )`,
63
+ `CREATE TABLE IF NOT EXISTS inbox_entries (
64
+ viewer TEXT NOT NULL,
65
+ exchange_id TEXT NOT NULL,
66
+ record_json TEXT NOT NULL,
67
+ PRIMARY KEY (viewer, exchange_id)
68
+ )`,
69
+ ];
70
+ /** States an obligation is still live in. `discharged`/`breached`/`void` are ended, differently. */
71
+ const OPEN_COMMITMENT_STATES = ['proposed', 'active', 'fulfilment-claimed'];
72
+ export function createDurableObjectInteractionStore(sql) {
73
+ for (const ddl of CREATE_TABLES)
74
+ sql.exec(ddl);
75
+ const one = (query, ...binds) => {
76
+ const rows = sql.exec(query, ...binds).toArray();
77
+ return rows[0] ? JSON.parse(rows[0].record_json) : null;
78
+ };
79
+ const saveInteraction = (record) => {
80
+ sql.exec(`INSERT INTO interaction_records (interaction_id, record_json, state, rev, updated_at)
81
+ VALUES (?, ?, ?, ?, ?)
82
+ ON CONFLICT(interaction_id) DO UPDATE SET
83
+ record_json = excluded.record_json, state = excluded.state,
84
+ rev = excluded.rev, updated_at = excluded.updated_at`, record.interactionId, JSON.stringify(record), lifecycleStateOf(record), record.rev, record.updatedAt);
85
+ };
86
+ const saveCommitment = (record) => {
87
+ sql.exec(`INSERT INTO commitment_records (commitment_id, record_json, state, updated_at)
88
+ VALUES (?, ?, ?, ?)
89
+ ON CONFLICT(commitment_id) DO UPDATE SET
90
+ record_json = excluded.record_json, state = excluded.state, updated_at = excluded.updated_at`, record.commitmentId, JSON.stringify(record), record.state, record.updatedAt);
91
+ };
92
+ const store = {
93
+ async putInteraction(record) {
94
+ saveInteraction(record);
95
+ for (const b of record.protocolBindings ?? []) {
96
+ sql.exec(`INSERT INTO interaction_bindings (binding_key, interaction_id, binding_json) VALUES (?, ?, ?)
97
+ ON CONFLICT(binding_key, interaction_id) DO UPDATE SET binding_json = excluded.binding_json`, bindingKey(b.protocol, b.field, b.value), record.interactionId, JSON.stringify(b));
98
+ }
99
+ },
100
+ async getInteraction(id) {
101
+ return one('SELECT record_json FROM interaction_records WHERE interaction_id = ?', String(id));
102
+ },
103
+ async listInteractions() {
104
+ return sql
105
+ .exec('SELECT record_json FROM interaction_records ORDER BY updated_at DESC')
106
+ .toArray()
107
+ .map((r) => JSON.parse(r.record_json));
108
+ },
109
+ async transitionInteraction(id, event) {
110
+ const record = await this.getInteraction(id);
111
+ if (!record)
112
+ return null;
113
+ const result = applyInteractionTransition(lifecycleOf(record), event);
114
+ // Fail-closed: a rejection leaves the row exactly as it was. The store never sets state itself,
115
+ // so "concluding is custodial" cannot be bypassed by writing the row directly.
116
+ if (result.ok) {
117
+ saveInteraction({
118
+ ...record,
119
+ lifecycleState: result.next.state,
120
+ updatedAt: event.at,
121
+ rev: record.rev + 1,
122
+ });
123
+ }
124
+ return result;
125
+ },
126
+ async bindProtocolTo(id, binding) {
127
+ sql.exec(`INSERT INTO interaction_bindings (binding_key, interaction_id, binding_json) VALUES (?, ?, ?)
128
+ ON CONFLICT(binding_key, interaction_id) DO UPDATE SET binding_json = excluded.binding_json`, bindingKey(binding.protocol, binding.field, binding.value), id, JSON.stringify(binding));
129
+ },
130
+ async resolveByBinding(protocol, field, value) {
131
+ const key = bindingKey(protocol, field, value);
132
+ const ids = sql
133
+ .exec('SELECT interaction_id FROM interaction_bindings WHERE binding_key = ?', key)
134
+ .toArray()
135
+ .map((r) => r.interaction_id);
136
+ // Reuses the in-memory resolver over a one-key index so SQL and non-SQL callers cannot disagree
137
+ // about what "ambiguous" means — one definition, two backing stores.
138
+ return resolveInteractionByBinding(new Map([[key, ids]]), protocol, field, value);
139
+ },
140
+ async putContextSnapshot(snapshot) {
141
+ // A snapshot whose digest does not match its bytes is not evidence, and storing it would let a
142
+ // later `verifyContextSnapshot` fail on a record that arrived corrupt rather than was tampered.
143
+ if (!(await verifyContextSnapshot(snapshot)))
144
+ return { ok: false, reason: 'digest-mismatch' };
145
+ const existing = sql
146
+ .exec('SELECT snapshot_json FROM context_snapshots WHERE digest = ?', snapshot.digest)
147
+ .toArray()[0];
148
+ // The digest verified and a row is already here, so the content is the same — two parties
149
+ // observing one context legitimately store it twice. A no-op, and the stored bytes win.
150
+ if (existing)
151
+ return { ok: true, stored: 'identical' };
152
+ sql.exec('INSERT INTO context_snapshots (digest, snapshot_json) VALUES (?, ?)', snapshot.digest, JSON.stringify(snapshot));
153
+ return { ok: true, stored: 'new' };
154
+ },
155
+ async getContextSnapshot(digest) {
156
+ const rows = sql
157
+ .exec('SELECT snapshot_json FROM context_snapshots WHERE digest = ?', digest)
158
+ .toArray();
159
+ return rows[0] ? JSON.parse(rows[0].snapshot_json) : null;
160
+ },
161
+ async putDecision(record) {
162
+ sql.exec(`INSERT INTO decision_records (decision_id, record_json, updated_at) VALUES (?, ?, ?)
163
+ ON CONFLICT(decision_id) DO UPDATE SET record_json = excluded.record_json, updated_at = excluded.updated_at`, record.decisionId, JSON.stringify(record), record.updatedAt);
164
+ },
165
+ async getDecision(id) {
166
+ return one('SELECT record_json FROM decision_records WHERE decision_id = ?', id);
167
+ },
168
+ async transitionDecision(id, event) {
169
+ const record = await this.getDecision(id);
170
+ if (!record)
171
+ return null;
172
+ const result = applyDecisionTransition(record, event);
173
+ if (result.ok)
174
+ await this.putDecision(result.next);
175
+ return result;
176
+ },
177
+ async putCommitment(record) {
178
+ saveCommitment(record);
179
+ },
180
+ async getCommitment(id) {
181
+ return one('SELECT record_json FROM commitment_records WHERE commitment_id = ?', id);
182
+ },
183
+ async listOpenCommitments() {
184
+ return sql
185
+ .exec(`SELECT record_json FROM commitment_records WHERE state IN (?, ?, ?) ORDER BY updated_at DESC`, ...OPEN_COMMITMENT_STATES)
186
+ .toArray()
187
+ .map((r) => JSON.parse(r.record_json));
188
+ },
189
+ async transitionCommitment(id, event) {
190
+ const record = await this.getCommitment(id);
191
+ if (!record)
192
+ return null;
193
+ const result = applyCommitmentTransition(record, event);
194
+ if (result.ok)
195
+ saveCommitment(result.next);
196
+ return result;
197
+ },
198
+ async putInboxEntry(entry) {
199
+ sql.exec(`INSERT INTO inbox_entries (viewer, exchange_id, record_json) VALUES (?, ?, ?)
200
+ ON CONFLICT(viewer, exchange_id) DO UPDATE SET record_json = excluded.record_json`, entry.viewer, entry.exchangeId, JSON.stringify(entry));
201
+ },
202
+ async getInboxEntry(viewer, exchangeId) {
203
+ return one('SELECT record_json FROM inbox_entries WHERE viewer = ? AND exchange_id = ?', viewer, exchangeId);
204
+ },
205
+ async transitionInbox(viewer, exchangeId, event) {
206
+ const entry = await this.getInboxEntry(viewer, exchangeId);
207
+ if (!entry)
208
+ return null;
209
+ const result = applyInboxTransition(entry, event);
210
+ if (result.ok)
211
+ await this.putInboxEntry(result.next);
212
+ return result;
213
+ },
214
+ };
215
+ return store;
216
+ }
217
+ /** The lifecycle facet of a stored interaction, for the machine to operate on. */
218
+ function lifecycleOf(record) {
219
+ return {
220
+ interactionId: record.interactionId,
221
+ state: lifecycleStateOf(record),
222
+ principal: record.principal,
223
+ participations: record.participations,
224
+ updatedAt: record.updatedAt,
225
+ };
226
+ }
227
+ function lifecycleStateOf(record) {
228
+ return record.lifecycleState;
229
+ }
230
+ //# sourceMappingURL=interaction-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-store.js","sourceRoot":"","sources":["../../src/cloudflare/interaction-store.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,oGAAoG;AACpG,oGAAoG;AACpG,EAAE;AACF,uGAAuG;AACvG,gGAAgG;AAChG,2FAA2F;AAC3F,EAAE;AACF,iFAAiF;AACjF,EAAE;AACF,mGAAmG;AACnG,oGAAoG;AACpG,gGAAgG;AAChG,4DAA4D;AAC5D,EAAE;AACF,oGAAoG;AACpG,kGAAkG;AAClG,oGAAoG;AACpG,mGAAmG;AACnG,6FAA6F;AAC7F,4DAA4D;AAC5D,iGAAiG;AACjG,mFAAmF;AACnF,EAAE;AACF,oGAAoG;AACpG,kGAAkG;AAClG,+BAA+B;AAG/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,GAUrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,UAAU,EACV,2BAA2B,GAG5B,MAAM,wBAAwB,CAAC;AAGhC,MAAM,aAAa,GAAG;IACpB;;;;;;KAMG;IACH,8FAA8F;IAC9F,oGAAoG;IACpG,+FAA+F;IAC/F;;;;;KAKG;IACH;;;KAGG;IACH;;;;KAIG;IACH;;;;;KAKG;IACH;;;;;KAKG;CACJ,CAAC;AAsDF,oGAAoG;AACpG,MAAM,sBAAsB,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,oBAAoB,CAAU,CAAC;AAErF,MAAM,UAAU,mCAAmC,CAAC,GAAe;IACjE,KAAK,MAAM,GAAG,IAAI,aAAa;QAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE/C,MAA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,CAAC,aAAa;QACnC,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAA2B;IACnD,OAAO,MAAM,CAAC,cAAc,CAAC;AAC/B,CAAC"}
@@ -4,6 +4,10 @@ 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 InteractionStore } from './interaction-store.js';
8
+ import type { CommitmentRecordV1 } from '../interaction-machines.js';
9
+ import type { InteractionRecordV1, InteractionId, ProfileVersion, ParticipationV1 } from '../interaction-record.js';
10
+ import type { ProtocolBindingV1 } from '../protocol-binding.js';
7
11
  import { type AuthorityVerdictCache, type AuthorityVerdict, type AuthorityVerdictKey } from './authority-verdict-cache.js';
8
12
  import { type DeliveryReceiptInput, type SignedDeliveryReceiptV1 } from './receipt-signer.js';
9
13
  import type { GatewayToolRegistry } from './gateway-tools.js';
@@ -14,6 +18,10 @@ import { type ChannelV1, type ConversationRoleProjection } from './channel-store
14
18
  export interface PrincipalGatewayEnv {
15
19
  /** The chain id the gateway verifies authority against (for the T1 verdict + delivery). */
16
20
  CHAIN_ID?: string;
21
+ /** The CAIP-10 of the principal THIS gateway belongs to. Optional so every existing deployment keeps
22
+ * working, but required by `openInteraction`: an interaction is custodied by the gateway holding it,
23
+ * and a gateway that cannot name itself cannot be a custodian. Fails closed rather than defaulting. */
24
+ PRINCIPAL_SA?: string;
17
25
  }
18
26
  /**
19
27
  * Injected co-resident-MCP dependencies. INJECTED (not built in the fabric core) because they need
@@ -37,12 +45,40 @@ export interface GatewayDeps {
37
45
  * tests) — the fabric core stays credential-mechanism-free. Absent ⇒ a gated channel cannot be joined. */
38
46
  verifyEntitlement?: (requirement: string, credential: unknown, member: string) => Promise<boolean>;
39
47
  }
48
+ /** What ingress observed about an exchange's place in a governed situation (spec 340 W7). */
49
+ export type DeliveryNote =
50
+ /** No `interactionId`: this is a message, not part of a governed situation. The common case. */
51
+ {
52
+ kind: 'unpinned-exchange';
53
+ }
54
+ /** Pinned an older profile version than the interaction now runs. Legal — and the signal that
55
+ * survives a downgrade, which is why it is reported rather than refused. */
56
+ | {
57
+ kind: 'profile-downgrade';
58
+ pinned: string;
59
+ inForce: string;
60
+ }
61
+ /** The pinned ContextSnapshot is not on this gateway — normal for an inbound delivery, where it
62
+ * lives on the sender's. Recorded so nobody reads the exchange as replayable here. */
63
+ | {
64
+ kind: 'context-unavailable';
65
+ digest: string;
66
+ };
67
+ export type DeliveryOutcome = {
68
+ ok: true;
69
+ interactionId?: InteractionId;
70
+ notes: readonly DeliveryNote[];
71
+ } | {
72
+ ok: false;
73
+ reason: 'unknown-interaction' | 'not-a-participant';
74
+ };
40
75
  export declare class PrincipalGatewayDO {
41
76
  private readonly state;
42
77
  private readonly env;
43
78
  private readonly deps?;
44
79
  private readonly sql;
45
80
  private readonly exchanges;
81
+ private readonly interactionStore;
46
82
  private readonly verdicts;
47
83
  private readonly requestIds;
48
84
  private readonly receipts;
@@ -50,7 +86,18 @@ export declare class PrincipalGatewayDO {
50
86
  private readonly provenance;
51
87
  private readonly channels;
52
88
  constructor(state: DurableObjectState, env: PrincipalGatewayEnv, deps?: GatewayDeps | undefined);
53
- /** Create/rename a channel owned by this org gateway. */
89
+ /**
90
+ * Create/rename a channel owned by this org gateway, and open the Interaction it IS (spec 340 W11).
91
+ *
92
+ * A topic was already a governed situation in everything but name: the org owns the board, members
93
+ * join and leave, `facilitator`/`contributor` are its roles, and it opens and closes. Opening the
94
+ * Interaction alongside it names that rather than adding a parallel object — the id is DERIVED
95
+ * (`ixn_topic_<channelId>`), so the two cannot drift and no join table exists to go stale.
96
+ *
97
+ * `participationMode: 'derived'`. Membership belongs to the channel (and, for an open topic, to the
98
+ * organization behind it), so the Interaction stores NO member list. Copying one per topic is what
99
+ * `apmsg:openParticipation` forbids, and a stale copy is how a removed member keeps posting.
100
+ */
54
101
  createChannel(channel: ChannelV1): Promise<void>;
55
102
  /**
56
103
  * Add a member with a role (spec 318 C2 — the role IS the projection of an org-SA delegation caveat).
@@ -183,9 +230,78 @@ export declare class PrincipalGatewayDO {
183
230
  * the message event's `idempotencyKey` at the reducer). Receipt signing (`DeliveryReceiptV1`, DO-local
184
231
  * software key) is a W2 follow-step.
185
232
  */
186
- deliver(record: ExchangeRecordV1): Promise<void>;
233
+ deliver(record: ExchangeRecordV1): Promise<DeliveryOutcome>;
234
+ /**
235
+ * The interaction-aware half of ingress (spec 340 W7).
236
+ *
237
+ * THREE OUTCOMES, and which is which is the whole design:
238
+ *
239
+ * 1. NO `interactionId` → delivered, with an `unpinned-exchange` note. An Exchange without an
240
+ * Interaction is a MESSAGE (ADR-0058 §12) — a legitimate state, and the overwhelmingly common
241
+ * one. Auto-creating an interaction per message would make "a thread is a projection, not a
242
+ * container" false by turning every message into a container.
243
+ *
244
+ * 2. UNKNOWN `interactionId` → REFUSED. Interactions are opened by their custodian
245
+ * (`openInteraction`), never conjured by a sender. If ingress created one from a sender-supplied
246
+ * id, any peer could seed arbitrary interactions with arbitrary participations on someone else's
247
+ * gateway, then post into them — inventing a governed situation the owner never entered.
248
+ *
249
+ * 3. KNOWN `interactionId` → the sender must be a current participant. An exchange claiming to occur
250
+ * in an interaction whose membership does not include its sender is a record that misrepresents
251
+ * the situation. This is an integrity check on the record's shape, NOT authority: being a
252
+ * participant is not permission to do anything (ADR-0048 §4).
253
+ *
254
+ * Two conditions are NOTED rather than refused, because refusing them would lose true records:
255
+ * · a profile-version mismatch — a mid-flight profile bump is legal, and the per-exchange pin is
256
+ * the signal that survives, so this reports (spec 340 §6);
257
+ * · a pinned context digest we do not hold — normal for an INBOUND delivery, where the snapshot
258
+ * lives on the sender's gateway. Dropping the message would be fail-closed in the wrong place;
259
+ * the digest stays pinned and resolvable later. What we must not do is pretend it is replayable.
260
+ */
261
+ private admitIntoInteraction;
262
+ /**
263
+ * Membership for a `derived` interaction.
264
+ *
265
+ * Topic interactions carry `ixn_topic_<channelId>`, so the channel is recoverable from the id and the
266
+ * answer comes from the channel store — the same member-or-bot test `postToChannel` already applies.
267
+ * That is the point of doing this: the gate stops being a second check that could drift from the
268
+ * first, and becomes the same check asked once.
269
+ *
270
+ * Fail-closed by construction: an id that names no known derivation source resolves to `false`, so a
271
+ * `derived` interaction with no resolver admits nobody rather than everybody.
272
+ */
273
+ private resolveDerivedParticipation;
274
+ /**
275
+ * Open a governed situation on this gateway. The custodian is always THIS principal — an interaction
276
+ * is custodied by the gateway that holds it, and accepting a caller-supplied principal would let a
277
+ * peer name someone else as custodian of a situation on our storage.
278
+ */
279
+ openInteraction(input: {
280
+ interactionId: InteractionId;
281
+ profileVersion: ProfileVersion;
282
+ /** Omit for a `derived` interaction — see `InteractionRecordV1.participationMode`. */
283
+ participations?: readonly ParticipationV1[];
284
+ participationMode?: 'asserted' | 'derived';
285
+ at: string;
286
+ protocolBindings?: readonly ProtocolBindingV1[];
287
+ }): Promise<InteractionRecordV1>;
187
288
  /** Append one event to an existing exchange (case transitions / transport moves), reduced fail-closed. */
188
289
  applyEvent(exchangeId: ExchangeId | string, event: ExchangeEventV1): Promise<import("../exchange-reducer.js").ExchangeApplyResult | null>;
290
+ /** Interactions, context snapshots, decisions, commitments, per-viewer inbox state. */
291
+ get interactions(): InteractionStore;
292
+ /**
293
+ * Everything still owed on this gateway — the query the single `case` field could not answer.
294
+ *
295
+ * A case could be `denied` while an obligation stayed outstanding with nowhere to record it, because
296
+ * one field was serving three machines (spec 340 §R). Concluding an interaction deliberately does NOT
297
+ * appear here as a discharge: closing a conversation ends the conversation, never the promise made
298
+ * inside it.
299
+ */
300
+ openCommitments(): Promise<CommitmentRecordV1[]>;
301
+ /** The gateway's own SA. Throws rather than defaulting: a wrong custodian on a governed situation is
302
+ * worse than a refused write, and empty-string config is treated as unset (a wrangler `VAR = ""`
303
+ * binds an empty string, which `??` would happily accept). */
304
+ private requirePrincipal;
189
305
  private requireDeps;
190
306
  /** The verdict cache (revoke / epoch-sweep hooks + read for tests). */
191
307
  get authority(): AuthorityVerdictCache;
@@ -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,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,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAA4E,KAAK,SAAS,EAAE,KAAK,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAE/J,kHAAkH;AAClH,MAAM,WAAW,mBAAmB;I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