@agenticprimitives/fabric 0.0.0-alpha.1 → 0.0.0-alpha.10
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 +22 -2
- package/README.md +16 -16
- package/dist/case-emissions.d.ts +95 -0
- package/dist/case-emissions.d.ts.map +1 -0
- package/dist/case-emissions.js +208 -0
- package/dist/case-emissions.js.map +1 -0
- package/dist/case-machine.d.ts +28 -2
- package/dist/case-machine.d.ts.map +1 -1
- package/dist/case-machine.js +34 -7
- package/dist/case-machine.js.map +1 -1
- package/dist/cloudflare/index.d.ts +1 -0
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +4 -0
- package/dist/cloudflare/index.js.map +1 -1
- package/dist/cloudflare/interaction-store.d.ts +55 -0
- package/dist/cloudflare/interaction-store.d.ts.map +1 -0
- package/dist/cloudflare/interaction-store.js +230 -0
- package/dist/cloudflare/interaction-store.js.map +1 -0
- package/dist/cloudflare/principal-gateway-do.d.ts +118 -2
- package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -1
- package/dist/cloudflare/principal-gateway-do.js +182 -7
- package/dist/cloudflare/principal-gateway-do.js.map +1 -1
- package/dist/communicative-act.d.ts +24 -1
- package/dist/communicative-act.d.ts.map +1 -1
- package/dist/communicative-act.js +28 -0
- package/dist/communicative-act.js.map +1 -1
- package/dist/delivery-envelope.d.ts.map +1 -1
- package/dist/delivery-envelope.js +0 -1
- package/dist/delivery-envelope.js.map +1 -1
- package/dist/enum-retirement.d.ts +43 -0
- package/dist/enum-retirement.d.ts.map +1 -0
- package/dist/enum-retirement.js +93 -0
- package/dist/enum-retirement.js.map +1 -0
- package/dist/exchange-record.d.ts +35 -4
- package/dist/exchange-record.d.ts.map +1 -1
- package/dist/exchange-record.js.map +1 -1
- package/dist/exchange-reducer.d.ts +32 -4
- package/dist/exchange-reducer.d.ts.map +1 -1
- package/dist/exchange-reducer.js +75 -1
- package/dist/exchange-reducer.js.map +1 -1
- package/dist/exchange-state.d.ts +30 -8
- package/dist/exchange-state.d.ts.map +1 -1
- package/dist/exchange-state.js +12 -10
- package/dist/exchange-state.js.map +1 -1
- package/dist/inbox-doc.d.ts +2 -2
- package/dist/inbox-doc.d.ts.map +1 -1
- package/dist/inbox-doc.js.map +1 -1
- package/dist/inbox-projection.d.ts +2 -2
- package/dist/inbox-projection.d.ts.map +1 -1
- package/dist/inbox-projection.js.map +1 -1
- package/dist/inbox-revision.d.ts +42 -0
- package/dist/inbox-revision.d.ts.map +1 -0
- package/dist/inbox-revision.js +57 -0
- package/dist/inbox-revision.js.map +1 -0
- package/dist/index.d.ts +23 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/interaction-machines.d.ts +136 -0
- package/dist/interaction-machines.d.ts.map +1 -0
- package/dist/interaction-machines.js +174 -0
- package/dist/interaction-machines.js.map +1 -0
- package/dist/interaction-profile.d.ts +126 -0
- package/dist/interaction-profile.d.ts.map +1 -0
- package/dist/interaction-profile.js +192 -0
- package/dist/interaction-profile.js.map +1 -0
- package/dist/interaction-record.d.ts +168 -0
- package/dist/interaction-record.d.ts.map +1 -0
- package/dist/interaction-record.js +108 -0
- package/dist/interaction-record.js.map +1 -0
- package/dist/interactions/machine.d.ts +2 -2
- package/dist/interactions/machine.d.ts.map +1 -1
- package/dist/interactions/machine.js +2 -2
- package/dist/interactions/machine.js.map +1 -1
- package/dist/interactions/store.d.ts +9 -0
- package/dist/interactions/store.d.ts.map +1 -1
- package/dist/interactions/store.js +57 -2
- package/dist/interactions/store.js.map +1 -1
- package/dist/messaging/board.d.ts +86 -6
- package/dist/messaging/board.d.ts.map +1 -1
- package/dist/messaging/board.js +100 -9
- package/dist/messaging/board.js.map +1 -1
- package/dist/messaging/consult-routing.d.ts +289 -0
- package/dist/messaging/consult-routing.d.ts.map +1 -0
- package/dist/messaging/consult-routing.js +455 -0
- package/dist/messaging/consult-routing.js.map +1 -0
- package/dist/messaging/consult.d.ts +158 -0
- package/dist/messaging/consult.d.ts.map +1 -0
- package/dist/messaging/consult.js +141 -0
- package/dist/messaging/consult.js.map +1 -0
- package/dist/messaging/conversation-interaction.d.ts +66 -0
- package/dist/messaging/conversation-interaction.d.ts.map +1 -0
- package/dist/messaging/conversation-interaction.js +139 -0
- package/dist/messaging/conversation-interaction.js.map +1 -0
- package/dist/messaging/delivery.d.ts +2 -2
- package/dist/messaging/delivery.d.ts.map +1 -1
- package/dist/messaging/delivery.js +8 -1
- package/dist/messaging/delivery.js.map +1 -1
- package/dist/messaging/directory.d.ts +16 -0
- package/dist/messaging/directory.d.ts.map +1 -1
- package/dist/messaging/directory.js.map +1 -1
- package/dist/messaging/envelope.d.ts +7 -3
- package/dist/messaging/envelope.d.ts.map +1 -1
- package/dist/messaging/envelope.js +18 -1
- package/dist/messaging/envelope.js.map +1 -1
- package/dist/messaging/hash.d.ts +8 -2
- package/dist/messaging/hash.d.ts.map +1 -1
- package/dist/messaging/hash.js +6 -0
- package/dist/messaging/hash.js.map +1 -1
- package/dist/messaging/inbox-assistant.d.ts +80 -0
- package/dist/messaging/inbox-assistant.d.ts.map +1 -0
- package/dist/messaging/inbox-assistant.js +125 -0
- package/dist/messaging/inbox-assistant.js.map +1 -0
- package/dist/messaging/index.d.ts +9 -3
- package/dist/messaging/index.d.ts.map +1 -1
- package/dist/messaging/index.js +17 -2
- package/dist/messaging/index.js.map +1 -1
- package/dist/messaging/projector.d.ts +3 -3
- package/dist/messaging/projector.d.ts.map +1 -1
- package/dist/messaging/projector.js.map +1 -1
- package/dist/messaging/receipts.d.ts +3 -3
- package/dist/messaging/receipts.d.ts.map +1 -1
- package/dist/messaging/receipts.js.map +1 -1
- package/dist/messaging/rules.d.ts +10 -3
- package/dist/messaging/rules.d.ts.map +1 -1
- package/dist/messaging/rules.js +8 -1
- package/dist/messaging/rules.js.map +1 -1
- package/dist/messaging/store.d.ts +4 -4
- package/dist/messaging/store.d.ts.map +1 -1
- package/dist/messaging/store.js +5 -3
- package/dist/messaging/store.js.map +1 -1
- package/dist/messaging/types.d.ts +52 -0
- package/dist/messaging/types.d.ts.map +1 -1
- package/dist/messaging/types.js +18 -1
- package/dist/messaging/types.js.map +1 -1
- package/dist/messaging/vault-store.d.ts +35 -2
- package/dist/messaging/vault-store.d.ts.map +1 -1
- package/dist/messaging/vault-store.js +53 -5
- package/dist/messaging/vault-store.js.map +1 -1
- package/dist/protocol-binding.d.ts +71 -0
- package/dist/protocol-binding.d.ts.map +1 -0
- package/dist/protocol-binding.js +0 -0
- package/dist/protocol-binding.js.map +1 -0
- package/dist/record-catalog.d.ts.map +1 -1
- package/dist/record-catalog.js +19 -0
- package/dist/record-catalog.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { MessageEnvelopeV1,
|
|
1
|
+
import type { MessageEnvelopeV1, MessageEventType, MessageId, Hex32, ContextRefV1 } from './messaging/index.js';
|
|
2
2
|
import { hashMessageEnvelope } from './messaging/index.js';
|
|
3
3
|
import type { AuthorityRef } from './interactions/index.js';
|
|
4
4
|
import type { AuthorityTier } from '@agenticprimitives/tool-policy';
|
|
5
5
|
import type { CanonicalAgentId } from '@agenticprimitives/types';
|
|
6
6
|
import type { VaultRef } from '@agenticprimitives/vault';
|
|
7
7
|
import type { ExecState, CaseState } from './exchange-state.js';
|
|
8
|
+
import type { DecisionState } from './interaction-machines.js';
|
|
8
9
|
import type { CaseTransition } from './case-machine.js';
|
|
10
|
+
import type { InteractionId, ProfileVersion, ContextDigest } from './interaction-record.js';
|
|
9
11
|
/** The exchange spine id — replaces today's `taskId` / `int_`+`run_` / `conv_`+`msg_` id families. */
|
|
10
12
|
export type ExchangeId = `xch_${string}`;
|
|
11
13
|
/**
|
|
@@ -82,12 +84,16 @@ export type ExchangeEventV1 = (ExchangeEventBase & {
|
|
|
82
84
|
* The ONE canonical exchange record (spec §b). Two-level FSM: `exec` (transport, always present) + `case`
|
|
83
85
|
* (business substate, execution-tier only). Authority is referenced, never satisfied here — approving a case
|
|
84
86
|
* advances `case`, it never unlocks a resource (ADR-0041).
|
|
87
|
+
*
|
|
88
|
+
* `kind: MessageKind` was REMOVED in spec 340 W8. It was a frozen taxonomy on the aggregate, it was a second
|
|
89
|
+
* copy of `envelope.kind`, and it had ZERO readers — the authority tier is server-classified from the skill
|
|
90
|
+
* selector, never from `kind`, and that comment was the only thing the field was doing. `profileVersion` is
|
|
91
|
+
* what carries interaction type now. `MessageEnvelopeV1.kind` is a DIFFERENT field and stays: it is inside
|
|
92
|
+
* the signed wire hash and has live readers (spec 340 §R.1).
|
|
85
93
|
*/
|
|
86
94
|
export interface ExchangeRecordV1 {
|
|
87
95
|
version: 'ap.exchange.v1';
|
|
88
96
|
exchangeId: ExchangeId;
|
|
89
|
-
/** Projection hint only — the authority TIER is server-classified from the skill selector, never `kind`. */
|
|
90
|
-
kind: MessageKind;
|
|
91
97
|
/** Server-classified ONCE at ingress (never client-asserted). */
|
|
92
98
|
tier: AuthorityTier;
|
|
93
99
|
/** The delegator / gateway owner SA — on whose behalf the exchange runs. Also the case RESPONDER by
|
|
@@ -108,8 +114,22 @@ export interface ExchangeRecordV1 {
|
|
|
108
114
|
resourceOwner?: CanonicalAgentId;
|
|
109
115
|
/** Transport envelope state (always present). */
|
|
110
116
|
exec: ExecState;
|
|
111
|
-
/**
|
|
117
|
+
/** Execution substate — execution-tier only; `undefined` for a T0 communication exchange. */
|
|
112
118
|
case?: CaseState;
|
|
119
|
+
/**
|
|
120
|
+
* spec 340 W10b-3 — the DECISION substate, projected onto this record.
|
|
121
|
+
*
|
|
122
|
+
* Until W10b-3 the ordering "you cannot issue before approving" was an FSM edge
|
|
123
|
+
* (`issue-credential` ran only `from: ['approved']`). With the determination out of `CaseState`,
|
|
124
|
+
* this reducer would otherwise have no way to know one was made, and issuance could skip it — a
|
|
125
|
+
* guarantee silently lost to a type change. So the reducer projects the decision state the same way
|
|
126
|
+
* it projects `exec` from `case`.
|
|
127
|
+
*
|
|
128
|
+
* A PROJECTION, not the record of record: the full `DecisionRecordV1` (with its decider and
|
|
129
|
+
* timestamps) lives in the interaction store's decision machine. This carries only what the
|
|
130
|
+
* precondition needs. It is never authority — a `granted` here permits nothing (ADR-0041).
|
|
131
|
+
*/
|
|
132
|
+
decision?: DecisionState;
|
|
113
133
|
/** The signed wire objects (deliveries, responses, decisions). */
|
|
114
134
|
envelopes: ExchangeEnvelopeV1[];
|
|
115
135
|
/** The single append-only event stream (single-writer in the DO). */
|
|
@@ -120,6 +140,17 @@ export interface ExchangeRecordV1 {
|
|
|
120
140
|
artifacts?: ArtifactRef[];
|
|
121
141
|
/** Entities this exchange is ABOUT (spec 312) — carried through from the envelope. */
|
|
122
142
|
contextRefs?: ContextRefV1[];
|
|
143
|
+
/** The governed situation this exchange occurs in. An Exchange without one is a message — a
|
|
144
|
+
* legitimate state, not an error, and the reason this is optional rather than required. */
|
|
145
|
+
interactionId?: InteractionId;
|
|
146
|
+
/** The EXACT profile version this exchange was made under, recorded HERE rather than read off the
|
|
147
|
+
* live interaction. Reading it off the interaction is what makes a downgrade invisible: an
|
|
148
|
+
* adversary edits one field and a Negotiation is reinterpreted as a Conversation, taking its
|
|
149
|
+
* acceptance semantics with it (spec 340 §6). */
|
|
150
|
+
profileVersion?: ProfileVersion;
|
|
151
|
+
/** Digest of the `ContextSnapshotV1` this exchange was evaluated against — by hash, never a pointer
|
|
152
|
+
* at live state. Supersedes `contextRefs` for authority-bearing context (spec 340 §7). */
|
|
153
|
+
contextDigest?: ContextDigest;
|
|
123
154
|
/** Monotonic revision for the inbox-projection cursor. */
|
|
124
155
|
rev: number;
|
|
125
156
|
updatedAt: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-record.d.ts","sourceRoot":"","sources":["../src/exchange-record.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"exchange-record.d.ts","s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6G;AAC7G,8GAA8G;AAC9G,+EAA+E;AAC/E,EAAE;AACF,4GAA4G;AAC5G,oGAAoG;AAGpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"exchange-record.js","sourceRoot":"","sources":["../src/exchange-record.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,6GAA6G;AAC7G,0GAA0G;AAC1G,EAAE;AACF,oGAAoG;AACpG,2GAA2G;AAC3G,6GAA6G;AAC7G,8GAA8G;AAC9G,+EAA+E;AAC/E,EAAE;AACF,4GAA4G;AAC5G,oGAAoG;AAGpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAmC3D;;kDAEkD;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AACxD,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AA+GtD;uGACuG;AACvG,MAAM,UAAU,OAAO,CAAC,MAAqD;IAC3E,OAAO,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC;AAC1C,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CaseFsmFields } from './case-machine.js';
|
|
2
2
|
import type { ExchangeRecordV1, ExchangeEventV1 } from './exchange-record.js';
|
|
3
|
+
import type { Hex32 } from './messaging/index.js';
|
|
3
4
|
export type ExchangeApplyResult = {
|
|
4
5
|
ok: true;
|
|
5
6
|
record: ExchangeRecordV1;
|
|
@@ -16,10 +17,37 @@ export type ExchangeApplyResult = {
|
|
|
16
17
|
* `null` for a case-less (T0) exchange.
|
|
17
18
|
*/
|
|
18
19
|
export declare function caseViewFromRecord(record: ExchangeRecordV1): CaseFsmFields | null;
|
|
20
|
+
export declare function applyExchangeEvent(record: ExchangeRecordV1, event: ExchangeEventV1): ExchangeApplyResult;
|
|
21
|
+
/** Bumped ONLY when a fold changes an output for inputs it already accepted. Adding a rejection reason
|
|
22
|
+
* is not a bump; changing what an accepted event does to the record is. */
|
|
23
|
+
export declare const EXCHANGE_REDUCER_VERSION: "ap.exchange-reducer.v1";
|
|
24
|
+
export interface MaterializationProvenanceV1 {
|
|
25
|
+
reducerVersion: typeof EXCHANGE_REDUCER_VERSION;
|
|
26
|
+
/** sha256 over the canonical event array — order-sensitive, because the fold is. */
|
|
27
|
+
eventSetDigest: Hex32;
|
|
28
|
+
eventCount: number;
|
|
29
|
+
}
|
|
30
|
+
/** Digest of the exact event sequence a materialization consumed. Order-sensitive on purpose: the same
|
|
31
|
+
* events in a different order are a different history, and folding them yields a different record. */
|
|
32
|
+
export declare function eventSetDigest(events: readonly ExchangeEventV1[]): Promise<Hex32>;
|
|
33
|
+
export type ExchangeReplayResult = {
|
|
34
|
+
ok: true;
|
|
35
|
+
record: ExchangeRecordV1;
|
|
36
|
+
provenance: MaterializationProvenanceV1;
|
|
37
|
+
} | {
|
|
38
|
+
ok: false;
|
|
39
|
+
reason: string;
|
|
40
|
+
atSeq: number;
|
|
41
|
+
};
|
|
19
42
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
43
|
+
* Rebuild an exchange from its event stream, and return the state WITH the evidence of how it was
|
|
44
|
+
* built.
|
|
45
|
+
*
|
|
46
|
+
* `seed` is the record as it existed before any event — the identity fields only. Its `events` are
|
|
47
|
+
* ignored and replaced by the fold, so replaying an already-materialized record cannot double-apply.
|
|
48
|
+
*
|
|
49
|
+
* Failure carries `atSeq` rather than just a reason: on a stream of two hundred events, "illegal
|
|
50
|
+
* transition" without the position is not a diagnosis.
|
|
23
51
|
*/
|
|
24
|
-
export declare function
|
|
52
|
+
export declare function replayExchange(seed: ExchangeRecordV1, events: readonly ExchangeEventV1[]): Promise<ExchangeReplayResult>;
|
|
25
53
|
//# sourceMappingURL=exchange-reducer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-reducer.d.ts","sourceRoot":"","sources":["../src/exchange-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K,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,SAAS,eAAe,EAAE,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAgB/B"}
|
package/dist/exchange-reducer.js
CHANGED
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Fail-closed: an illegal case transition, an inconsistent transport move, or a seq gap is a typed rejection,
|
|
15
15
|
// never a silent state change. Idempotent: a replayed event (same `idempotencyKey`) is a no-op.
|
|
16
|
+
import { canonicalizeJson } from '@agenticprimitives/types';
|
|
16
17
|
import { canTaskTransition, expectedExecForCase, isExecCaseConsistent } from './exchange-state.js';
|
|
17
18
|
import { applyCaseTransition } from './case-machine.js';
|
|
19
|
+
import { sha256Hex32 } from './messaging/index.js';
|
|
18
20
|
/**
|
|
19
21
|
* Derive the transient case FSM view from a lean `ExchangeRecordV1` (option (a) — the record stays the lean
|
|
20
22
|
* spine; the case view is constructed only when applying a transition). Role convention: `requester` = the
|
|
@@ -42,6 +44,28 @@ export function caseViewFromRecord(record) {
|
|
|
42
44
|
* next slot (`record.events.length`). Returns the next record (`changed: true`), a no-op for an idempotent
|
|
43
45
|
* replay (`changed: false`), or a typed rejection.
|
|
44
46
|
*/
|
|
47
|
+
/**
|
|
48
|
+
* spec 340 W10b-3 — the decision substate this record projects, given the transition just applied.
|
|
49
|
+
*
|
|
50
|
+
* Mirrors `caseTransitionEmissions`' decision half deliberately narrowly: the reducer holds no
|
|
51
|
+
* `DecisionRecordV1` (no decider, no timestamps), only the state the `issue-credential` precondition
|
|
52
|
+
* needs. The authoritative record lives in the interaction store's decision machine.
|
|
53
|
+
*
|
|
54
|
+
* `undefined` in, `undefined` out for every non-deciding transition — this never invents a
|
|
55
|
+
* determination, and a transition that decides nothing leaves the projection exactly as it was.
|
|
56
|
+
*/
|
|
57
|
+
function nextDecisionState(current, transition) {
|
|
58
|
+
switch (transition) {
|
|
59
|
+
case 'approve':
|
|
60
|
+
return 'granted';
|
|
61
|
+
case 'deny':
|
|
62
|
+
return 'refused';
|
|
63
|
+
case 'expire':
|
|
64
|
+
return 'expired';
|
|
65
|
+
default:
|
|
66
|
+
return current;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
45
69
|
export function applyExchangeEvent(record, event) {
|
|
46
70
|
// Idempotent replay — a matching key already in the stream is a no-op (no second row).
|
|
47
71
|
if (event.idempotencyKey && record.events.some((e) => e.idempotencyKey === event.idempotencyKey)) {
|
|
@@ -77,7 +101,10 @@ export function applyExchangeEvent(record, event) {
|
|
|
77
101
|
messageId: event.messageId,
|
|
78
102
|
evidenceRef: event.evidenceRef,
|
|
79
103
|
authorityRef: event.authorityRef,
|
|
80
|
-
}
|
|
104
|
+
},
|
|
105
|
+
// W10b-3: supply the decision this record has projected so far, so `issue-credential` still
|
|
106
|
+
// cannot precede a grant now that the ordering is no longer an FSM edge.
|
|
107
|
+
{ decisionState: record.decision ?? null });
|
|
81
108
|
if (!res.ok)
|
|
82
109
|
return { ok: false, reason: `case:${res.reason}` };
|
|
83
110
|
const nextCase = res.case.state;
|
|
@@ -88,6 +115,7 @@ export function applyExchangeEvent(record, event) {
|
|
|
88
115
|
...appended,
|
|
89
116
|
case: nextCase,
|
|
90
117
|
exec: expectedExecForCase(nextCase), // projection — the case FSM is the authority
|
|
118
|
+
decision: nextDecisionState(record.decision, event.transition),
|
|
91
119
|
authorityRefs: res.case.authorityRefs,
|
|
92
120
|
},
|
|
93
121
|
};
|
|
@@ -105,4 +133,50 @@ export function applyExchangeEvent(record, event) {
|
|
|
105
133
|
}
|
|
106
134
|
}
|
|
107
135
|
}
|
|
136
|
+
// ─── Materialization provenance (spec 340 INV-340-8) ─────────────────────────
|
|
137
|
+
//
|
|
138
|
+
// "Materialized state rebuilds deterministically from signed events" is a claim, and a claim nobody can
|
|
139
|
+
// check is a hope. Two things make it checkable, and both must travel WITH the rebuilt state:
|
|
140
|
+
//
|
|
141
|
+
// eventSetDigest — WHICH events produced this. Without it, a state that silently dropped an event
|
|
142
|
+
// and a state that legitimately never received one are indistinguishable.
|
|
143
|
+
// reducerVersion — WHICH rules produced this. Two nodes on different reducer versions can fold the
|
|
144
|
+
// same events into different states and both be internally consistent; the
|
|
145
|
+
// disagreement then looks like data corruption instead of a version skew.
|
|
146
|
+
/** Bumped ONLY when a fold changes an output for inputs it already accepted. Adding a rejection reason
|
|
147
|
+
* is not a bump; changing what an accepted event does to the record is. */
|
|
148
|
+
export const EXCHANGE_REDUCER_VERSION = 'ap.exchange-reducer.v1';
|
|
149
|
+
/** Digest of the exact event sequence a materialization consumed. Order-sensitive on purpose: the same
|
|
150
|
+
* events in a different order are a different history, and folding them yields a different record. */
|
|
151
|
+
export async function eventSetDigest(events) {
|
|
152
|
+
return sha256Hex32(canonicalizeJson(events));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Rebuild an exchange from its event stream, and return the state WITH the evidence of how it was
|
|
156
|
+
* built.
|
|
157
|
+
*
|
|
158
|
+
* `seed` is the record as it existed before any event — the identity fields only. Its `events` are
|
|
159
|
+
* ignored and replaced by the fold, so replaying an already-materialized record cannot double-apply.
|
|
160
|
+
*
|
|
161
|
+
* Failure carries `atSeq` rather than just a reason: on a stream of two hundred events, "illegal
|
|
162
|
+
* transition" without the position is not a diagnosis.
|
|
163
|
+
*/
|
|
164
|
+
export async function replayExchange(seed, events) {
|
|
165
|
+
let record = { ...seed, events: [] };
|
|
166
|
+
for (const event of events) {
|
|
167
|
+
const res = applyExchangeEvent(record, event);
|
|
168
|
+
if (!res.ok)
|
|
169
|
+
return { ok: false, reason: res.reason, atSeq: event.seq };
|
|
170
|
+
record = res.record;
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
ok: true,
|
|
174
|
+
record,
|
|
175
|
+
provenance: {
|
|
176
|
+
reducerVersion: EXCHANGE_REDUCER_VERSION,
|
|
177
|
+
eventSetDigest: await eventSetDigest(events),
|
|
178
|
+
eventCount: events.length,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
108
182
|
//# sourceMappingURL=exchange-reducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-reducer.js","sourceRoot":"","sources":["../src/exchange-reducer.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,0GAA0G;AAC1G,6FAA6F;AAC7F,EAAE;AACF,2GAA2G;AAC3G,2GAA2G;AAC3G,6GAA6G;AAC7G,oEAAoE;AACpE,2GAA2G;AAC3G,wDAAwD;AACxD,6GAA6G;AAC7G,+GAA+G;AAC/G,EAAE;AACF,8GAA8G;AAC9G,gGAAgG;AAEhG,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"exchange-reducer.js","sourceRoot":"","sources":["../src/exchange-reducer.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,0GAA0G;AAC1G,6FAA6F;AAC7F,EAAE;AACF,2GAA2G;AAC3G,2GAA2G;AAC3G,6GAA6G;AAC7G,oEAAoE;AACpE,2GAA2G;AAC3G,wDAAwD;AACxD,6GAA6G;AAC7G,+GAA+G;AAC/G,EAAE;AACF,8GAA8G;AAC9G,gGAAgG;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAA2C,MAAM,mBAAmB,CAAC;AAIjG,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAwB;IACzD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO;QAC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;IACH,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,EAAE;AACF,wGAAwG;AACxG,8FAA8F;AAC9F,EAAE;AACF,qGAAqG;AACrG,8FAA8F;AAC9F,sGAAsG;AACtG,+FAA+F;AAC/F,8FAA8F;AAE9F;4EAC4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG,wBAAiC,CAAC;AAS1E;uGACuG;AACvG,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAkC;IACrE,OAAO,WAAW,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/C,CAAC;AAMD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAsB,EACtB,MAAkC;IAElC,IAAI,MAAM,GAAqB,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACvD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;QACxE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM;QACN,UAAU,EAAE;YACV,cAAc,EAAE,wBAAwB;YACxC,cAAc,EAAE,MAAM,cAAc,CAAC,MAAM,CAAC;YAC5C,UAAU,EAAE,MAAM,CAAC,MAAM;SAC1B;KACF,CAAC;AACJ,CAAC"}
|
package/dist/exchange-state.d.ts
CHANGED
|
@@ -4,20 +4,42 @@ export type ExecState = TaskState;
|
|
|
4
4
|
export { canTaskTransition };
|
|
5
5
|
/** All 8 transport `ExecState`s (mirrors `fulfillment` `TaskState`), for coverage assertions. */
|
|
6
6
|
export declare const EXEC_STATES: readonly ExecState[];
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The EXECUTION substate (spec 340 W10b-3), 8 states. Two earlier removals and one late one:
|
|
9
|
+
*
|
|
10
|
+
* - `delivered`/`seen` went in Blocker 6 — inbox read-receipt facts, not lifecycle transitions.
|
|
11
|
+
* - `approved`/`denied`/`expired`/`revoked` went in W10b-3. They were never execution. `approved`,
|
|
12
|
+
* `denied` and `expired` are DECISIONS and `revoked` is what happens to a COMMITMENT, so they now
|
|
13
|
+
* live in the machines that own them (spec 340 §R.2). One field was answering three questions with
|
|
14
|
+
* three different signers, which is why a case could be `denied` while a commitment stayed
|
|
15
|
+
* outstanding with nowhere to record it.
|
|
16
|
+
*
|
|
17
|
+
* `closed` replaces the terminal those four used to provide: the work was taken up and ended without
|
|
18
|
+
* issuance. It carries no verdict — the verdict is in the decision record. Deliberately not folded
|
|
19
|
+
* into `failed`: a denial is not a fault, and collapsing them would reclassify every refusal as an
|
|
20
|
+
* error (and would silently drop the `rejected` exec value, which nothing else produces).
|
|
21
|
+
*
|
|
22
|
+
* The TRANSITION VERBS did not change. `approve`/`deny`/`expire`/`revoke` are still transitions — they
|
|
23
|
+
* now emit into the decision and commitment machines and land the case on an execution state. That is
|
|
24
|
+
* what lets a stored v1 event log keep replaying with no migration (W10b-1).
|
|
25
|
+
*/
|
|
26
|
+
export type CaseState = 'draft' | 'submitted' | 'triaged' | 'needs-info' | 'issued' | 'completed' | 'closed' | 'failed';
|
|
10
27
|
export declare const CASE_STATES: readonly CaseState[];
|
|
11
28
|
/**
|
|
12
|
-
* EXEC_CASE_COUPLING (spec 316 §2) — the canonical `ExecState` each `CaseState` maps to. Exhaustive over
|
|
13
|
-
*
|
|
29
|
+
* EXEC_CASE_COUPLING (spec 316 §2) — the canonical `ExecState` each `CaseState` maps to. Exhaustive over
|
|
30
|
+
* all 8 `CaseState`. Rationale per row:
|
|
14
31
|
* - `draft`/`submitted` → `submitted` : case created, pre-triage/local — accepted, not yet worked.
|
|
15
|
-
* - `triaged
|
|
32
|
+
* - `triaged` → `working` : responder actively working the request.
|
|
16
33
|
* - `needs-info` → `input-required` : the ONLY case → `input-required` (blocked awaiting requester;
|
|
17
34
|
* A2A `input-required` = blocked on the SENDER, so `triaged` must NOT map here).
|
|
18
35
|
* - `issued`/`completed` → `completed`.
|
|
19
|
-
* - `
|
|
20
|
-
*
|
|
36
|
+
* - `closed` → `rejected` : taken up and ended without issuance — distinct from a failed
|
|
37
|
+
* task, which is the distinction `denied` used to carry. Keeping this row is
|
|
38
|
+
* what keeps `rejected` reachable at all; folding `closed` into `failed`
|
|
39
|
+
* would leave an `ExecState` no case produces.
|
|
40
|
+
* - `failed` → `failed` (canonical; `canceled` is the transport-set alternative).
|
|
41
|
+
*
|
|
42
|
+
* Still 6 case-derived exec values + the 2 transport-set ones = all 8 `ExecState`, unchanged by W10b-3.
|
|
21
43
|
*/
|
|
22
44
|
export declare const EXEC_CASE_COUPLING: Record<CaseState, ExecState>;
|
|
23
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-state.d.ts","sourceRoot":"","sources":["../src/exchange-state.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEnF,yGAAyG;AACzG,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,iGAAiG;AACjG,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAElC,CAAC;AAEX;
|
|
1
|
+
{"version":3,"file":"exchange-state.d.ts","sourceRoot":"","sources":["../src/exchange-state.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEnF,yGAAyG;AACzG,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,iGAAiG;AACjG,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAElC,CAAC;AAEX;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,SAAS,GACjB,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,GAChD,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjD,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAElC,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,CAS3D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,SAAS,EAA2C,CAAC;AAE/F,kHAAkH;AAClH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAG/E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAG/F;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,EAC3C,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,GACxC,OAAO,CAGT"}
|
package/dist/exchange-state.js
CHANGED
|
@@ -13,30 +13,32 @@ export const EXEC_STATES = [
|
|
|
13
13
|
'submitted', 'working', 'completed', 'failed', 'canceled', 'input-required', 'rejected', 'auth-required',
|
|
14
14
|
];
|
|
15
15
|
export const CASE_STATES = [
|
|
16
|
-
'draft', 'submitted', 'triaged', 'needs-info', '
|
|
16
|
+
'draft', 'submitted', 'triaged', 'needs-info', 'issued', 'completed', 'closed', 'failed',
|
|
17
17
|
];
|
|
18
18
|
/**
|
|
19
|
-
* EXEC_CASE_COUPLING (spec 316 §2) — the canonical `ExecState` each `CaseState` maps to. Exhaustive over
|
|
20
|
-
*
|
|
19
|
+
* EXEC_CASE_COUPLING (spec 316 §2) — the canonical `ExecState` each `CaseState` maps to. Exhaustive over
|
|
20
|
+
* all 8 `CaseState`. Rationale per row:
|
|
21
21
|
* - `draft`/`submitted` → `submitted` : case created, pre-triage/local — accepted, not yet worked.
|
|
22
|
-
* - `triaged
|
|
22
|
+
* - `triaged` → `working` : responder actively working the request.
|
|
23
23
|
* - `needs-info` → `input-required` : the ONLY case → `input-required` (blocked awaiting requester;
|
|
24
24
|
* A2A `input-required` = blocked on the SENDER, so `triaged` must NOT map here).
|
|
25
25
|
* - `issued`/`completed` → `completed`.
|
|
26
|
-
* - `
|
|
27
|
-
*
|
|
26
|
+
* - `closed` → `rejected` : taken up and ended without issuance — distinct from a failed
|
|
27
|
+
* task, which is the distinction `denied` used to carry. Keeping this row is
|
|
28
|
+
* what keeps `rejected` reachable at all; folding `closed` into `failed`
|
|
29
|
+
* would leave an `ExecState` no case produces.
|
|
30
|
+
* - `failed` → `failed` (canonical; `canceled` is the transport-set alternative).
|
|
31
|
+
*
|
|
32
|
+
* Still 6 case-derived exec values + the 2 transport-set ones = all 8 `ExecState`, unchanged by W10b-3.
|
|
28
33
|
*/
|
|
29
34
|
export const EXEC_CASE_COUPLING = {
|
|
30
35
|
draft: 'submitted',
|
|
31
36
|
submitted: 'submitted',
|
|
32
37
|
triaged: 'working',
|
|
33
38
|
'needs-info': 'input-required',
|
|
34
|
-
approved: 'working',
|
|
35
39
|
issued: 'completed',
|
|
36
40
|
completed: 'completed',
|
|
37
|
-
|
|
38
|
-
expired: 'failed',
|
|
39
|
-
revoked: 'failed',
|
|
41
|
+
closed: 'rejected',
|
|
40
42
|
failed: 'failed',
|
|
41
43
|
};
|
|
42
44
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-state.js","sourceRoot":"","sources":["../src/exchange-state.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,2GAA2G;AAC3G,4GAA4G;AAC5G,4GAA4G;AAC5G,gHAAgH;AAChH,EAAE;AACF,2GAA2G;AAC3G,4GAA4G;AAE5G,OAAO,EAAE,iBAAiB,EAAkB,MAAM,gCAAgC,CAAC;AAInF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,iGAAiG;AACjG,MAAM,CAAC,MAAM,WAAW,GAAyB;IAC/C,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe;CAChG,CAAC;
|
|
1
|
+
{"version":3,"file":"exchange-state.js","sourceRoot":"","sources":["../src/exchange-state.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,2GAA2G;AAC3G,4GAA4G;AAC5G,4GAA4G;AAC5G,gHAAgH;AAChH,EAAE;AACF,2GAA2G;AAC3G,4GAA4G;AAE5G,OAAO,EAAE,iBAAiB,EAAkB,MAAM,gCAAgC,CAAC;AAInF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,iGAAiG;AACjG,MAAM,CAAC,MAAM,WAAW,GAAyB;IAC/C,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe;CAChG,CAAC;AAyBX,MAAM,CAAC,MAAM,WAAW,GAAyB;IAC/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ;CAChF,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiC;IAC9D,KAAK,EAAE,WAAW;IAClB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,gBAAgB;IAC9B,MAAM,EAAE,WAAW;IACnB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAyB,CAAC,eAAe,EAAE,UAAU,CAAU,CAAC;AAE/F,kHAAkH;AAClH,MAAM,UAAU,mBAAmB,CAAC,SAAgC;IAClE,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IAChD,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAe,EAAE,SAAgC;IACpF,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,KAAK,SAAS,CAAC;IACtE,OAAO,mBAAmB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAA2C,EAC3C,EAAyC;IAEzC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACzD,OAAO,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/inbox-doc.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type ContextRefV1, type ConversationDescriptorV1, type InboxProjector, type
|
|
1
|
+
import { type ContextRefV1, type ConversationDescriptorV1, type InboxProjector, type AnyMessageEnvelope, type MessageEventV1 } from './messaging/index.js';
|
|
2
2
|
import { type ActionCardV1, type InteractionCaseV1, type InteractionMandateV1, type InteractionStore, type InteractionTransitionEventV1 } from './interactions/index.js';
|
|
3
3
|
export interface InboxDataV1 {
|
|
4
4
|
version: 1;
|
|
5
|
-
envelopes:
|
|
5
|
+
envelopes: AnyMessageEnvelope[];
|
|
6
6
|
events: MessageEventV1[];
|
|
7
7
|
/** Cases as they entered (draft) — current state is replayed from caseEvents. */
|
|
8
8
|
draftCases: InteractionCaseV1[];
|
package/dist/inbox-doc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox-doc.d.ts","sourceRoot":"","sources":["../src/inbox-doc.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"inbox-doc.d.ts","sourceRoot":"","sources":["../src/inbox-doc.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EAClC,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,iFAAiF;IACjF,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,UAAU,EAAE,4BAA4B,EAAE,CAAC;IAC3C,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAChD,2EAA2E;IAC3E,aAAa,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAE5C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,yGAAyG;AACzG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAGvD;AAED,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,YAAY,EAAE,gBAAgB,CAAA;CAAE,CAYpI;AAED;;wEAEwE;AACxE,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,wBAAwB,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,SAAS,GAAG,OAAO,CAOhH;AAED;kGACkG;AAClG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAQ/F"}
|
package/dist/inbox-doc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox-doc.js","sourceRoot":"","sources":["../src/inbox-doc.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,oGAAoG;AACpG,iGAAiG;AACjG,sGAAsG;AACtG,0DAA0D;AAC1D,OAAO,EACL,4BAA4B,
|
|
1
|
+
{"version":3,"file":"inbox-doc.js","sourceRoot":"","sources":["../src/inbox-doc.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,oGAAoG;AACpG,iGAAiG;AACjG,sGAAsG;AACtG,0DAA0D;AAC1D,OAAO,EACL,4BAA4B,GAO7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,8BAA8B,GAM/B,MAAM,yBAAyB,CAAC;AAkBjC,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAC9F,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI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AK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACjE,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAChC,UAAU,CAAC,WAAW,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC;IACvE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;kGACkG;AAClG,MAAM,UAAU,kBAAkB,CAAC,GAAgB,EAAE,UAAoC;IACvF,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,GAAG,CAAC,aAAa,GAAG,CAAC,GAAG,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IACD,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyMessageEnvelope, InboxItemV1 } from './messaging/index.js';
|
|
2
2
|
import type { ExchangeEventV1 } from './exchange-record.js';
|
|
3
3
|
/** A `kind:'message'` fabric event — the inbox-relevant slice of the stream. */
|
|
4
4
|
export type InboxProjectionEvent = Extract<ExchangeEventV1, {
|
|
@@ -9,7 +9,7 @@ export type InboxProjectionEvent = Extract<ExchangeEventV1, {
|
|
|
9
9
|
* seeds the row from the envelope. Adapts the fabric event to messaging's `MessageEventV1` and delegates to
|
|
10
10
|
* the absorbed `applyMessageEvent` reducer, so folder/unread semantics stay identical across the absorption.
|
|
11
11
|
*/
|
|
12
|
-
export declare function projectInboxItem(prev: InboxItemV1 | undefined, envelope:
|
|
12
|
+
export declare function projectInboxItem(prev: InboxItemV1 | undefined, envelope: AnyMessageEnvelope, event: InboxProjectionEvent): InboxItemV1;
|
|
13
13
|
export { applyMessageEvent, applyInboxRules, createInMemoryInboxProjector } from './messaging/index.js';
|
|
14
14
|
export type { InboxItemV1, InboxRuleV1, InboxProjector, CreateInboxProjectorOpts, FolderKind, } from './messaging/index.js';
|
|
15
15
|
//# sourceMappingURL=inbox-projection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox-projection.d.ts","sourceRoot":"","sources":["../src/inbox-projection.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"inbox-projection.d.ts","sourceRoot":"","sources":["../src/inbox-projection.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAC5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,oBAAoB,GAC1B,WAAW,CAUb;AAGD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACxG,YAAY,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,UAAU,GACX,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox-projection.js","sourceRoot":"","sources":["../src/inbox-projection.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,uGAAuG;AACvG,8GAA8G;AAC9G,4GAA4G;AAC5G,0GAA0G;AAC1G,EAAE;AACF,4GAA4G;AAC5G,yEAAyE;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAOzD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"inbox-projection.js","sourceRoot":"","sources":["../src/inbox-projection.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,uGAAuG;AACvG,8GAA8G;AAC9G,4GAA4G;AAC5G,0GAA0G;AAC1G,EAAE;AACF,4GAA4G;AAC5G,yEAAyE;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAOzD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAA6B,EAC7B,QAA4B,EAC5B,KAA2B;IAE3B,MAAM,YAAY,GAAmB;QACnC,OAAO,EAAE,qBAAqB;QAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC;IACF,OAAO,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AACzD,CAAC;AAED,qGAAqG;AACrG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Hex32 } from './messaging/index.js';
|
|
2
|
+
import type { InboxDataV1 } from './inbox-doc.js';
|
|
3
|
+
/** An opaque cursor. Callers compare it for equality and MUST NOT parse or order it — see the header
|
|
4
|
+
* on why "newer?" is deliberately unanswerable. */
|
|
5
|
+
export type InboxRevision = Hex32;
|
|
6
|
+
/**
|
|
7
|
+
* The revision of an inbox document.
|
|
8
|
+
*
|
|
9
|
+
* Canonical JSON (sorted keys, `undefined` dropped) means two structurally identical documents produce
|
|
10
|
+
* the same digest regardless of key order — so a re-serialization round trip, or a different property
|
|
11
|
+
* insertion order between two writers, does not read as a change. That matters: a cursor that reported
|
|
12
|
+
* spurious changes would send the client back for a full replay it did not need, which is the cost this
|
|
13
|
+
* exists to remove.
|
|
14
|
+
*/
|
|
15
|
+
export declare function inboxRevision(doc: InboxDataV1): Promise<InboxRevision>;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the caller's cursor still matches the document — the whole read-side contract.
|
|
18
|
+
*
|
|
19
|
+
* An absent cursor is NOT a match: a first-time caller has seen nothing, so it must receive the
|
|
20
|
+
* document. Treating "no cursor" as "unchanged" would return an empty answer to a client with an empty
|
|
21
|
+
* cache, and the two look identical from the client's side (ADR-0013 — empty is an answer, and here it
|
|
22
|
+
* would be the wrong one).
|
|
23
|
+
*/
|
|
24
|
+
export declare function inboxUnchanged(doc: InboxDataV1, callerRevision: string | null | undefined): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* The read result: either the document with its revision, or a bare "unchanged".
|
|
27
|
+
*
|
|
28
|
+
* A discriminated union rather than an optional `doc`, so a caller cannot read `result.doc` on an
|
|
29
|
+
* unchanged response and silently observe `undefined` as "empty inbox" — which is the shape of bug
|
|
30
|
+
* this cursor would otherwise introduce into every consumer.
|
|
31
|
+
*/
|
|
32
|
+
export type InboxReadResult = {
|
|
33
|
+
unchanged: true;
|
|
34
|
+
revision: InboxRevision;
|
|
35
|
+
} | {
|
|
36
|
+
unchanged: false;
|
|
37
|
+
revision: InboxRevision;
|
|
38
|
+
doc: InboxDataV1;
|
|
39
|
+
};
|
|
40
|
+
/** Build the read result for a caller presenting `callerRevision` (or none). */
|
|
41
|
+
export declare function readInboxWithCursor(doc: InboxDataV1, callerRevision: string | null | undefined): Promise<InboxReadResult>;
|
|
42
|
+
//# sourceMappingURL=inbox-revision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-revision.d.ts","sourceRoot":"","sources":["../src/inbox-revision.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;oDACoD;AACpD,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAElC;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAE5E;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,WAAW,EAChB,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACxC,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,GAC5C;IAAE,SAAS,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAC;IAAC,GAAG,EAAE,WAAW,CAAA;CAAE,CAAC;AAEpE,gFAAgF;AAChF,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,WAAW,EAChB,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACxC,OAAO,CAAC,eAAe,CAAC,CAI1B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// The inbox READ CURSOR (spec 341 §3.2 / Wave 2a).
|
|
2
|
+
//
|
|
3
|
+
// WHAT PROBLEM THIS SOLVES, precisely. Spec 341 moves the Home's inbox read off a shared-secret bridge
|
|
4
|
+
// and onto A2A. A poll that today is a cheap local-ish call becomes a signed round-trip, so a read that
|
|
5
|
+
// returns "nothing changed" has to become cheap or the migration is a latency regression wearing
|
|
6
|
+
// compliance's clothes (ADR-0059).
|
|
7
|
+
//
|
|
8
|
+
// WHY A DIGEST AND NOT A COUNTER. A monotonic counter needs somewhere to live and someone to increment
|
|
9
|
+
// it — new storage, and a second source of truth that can drift from the document it describes. A
|
|
10
|
+
// digest is derived: it changes if and only if the content changes, it needs no storage, and it cannot
|
|
11
|
+
// disagree with the thing it summarises. What a digest gives up is ORDER — it answers "different?" and
|
|
12
|
+
// never "newer?" — and that is exactly the ETag contract, which is all a poll requires.
|
|
13
|
+
//
|
|
14
|
+
// WHAT IT DOES NOT SAVE, stated so nobody expects more. The holder still reads and decrypts the
|
|
15
|
+
// document to compute the digest; the vault round-trip is unavoidable. What it saves is everything
|
|
16
|
+
// AFTER that: the JSON transfer, and — the expensive half — the client's `hydrateInboxStores` replay,
|
|
17
|
+
// which is O(events) on every single load. An unchanged answer lets a caller skip a full event-log
|
|
18
|
+
// replay it was otherwise doing several times a minute.
|
|
19
|
+
//
|
|
20
|
+
// NOT AUTHORITY, and not freshness. A matching revision says the bytes are the same; it says nothing
|
|
21
|
+
// about whether the caller may read them, and nothing about how recently anyone looked. Authorization
|
|
22
|
+
// is re-decided per call regardless (ADR-0041).
|
|
23
|
+
import { canonicalizeJson } from '@agenticprimitives/types';
|
|
24
|
+
import { sha256Hex32 } from './messaging/index.js';
|
|
25
|
+
/**
|
|
26
|
+
* The revision of an inbox document.
|
|
27
|
+
*
|
|
28
|
+
* Canonical JSON (sorted keys, `undefined` dropped) means two structurally identical documents produce
|
|
29
|
+
* the same digest regardless of key order — so a re-serialization round trip, or a different property
|
|
30
|
+
* insertion order between two writers, does not read as a change. That matters: a cursor that reported
|
|
31
|
+
* spurious changes would send the client back for a full replay it did not need, which is the cost this
|
|
32
|
+
* exists to remove.
|
|
33
|
+
*/
|
|
34
|
+
export async function inboxRevision(doc) {
|
|
35
|
+
return sha256Hex32(canonicalizeJson(doc));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether the caller's cursor still matches the document — the whole read-side contract.
|
|
39
|
+
*
|
|
40
|
+
* An absent cursor is NOT a match: a first-time caller has seen nothing, so it must receive the
|
|
41
|
+
* document. Treating "no cursor" as "unchanged" would return an empty answer to a client with an empty
|
|
42
|
+
* cache, and the two look identical from the client's side (ADR-0013 — empty is an answer, and here it
|
|
43
|
+
* would be the wrong one).
|
|
44
|
+
*/
|
|
45
|
+
export async function inboxUnchanged(doc, callerRevision) {
|
|
46
|
+
if (!callerRevision)
|
|
47
|
+
return false;
|
|
48
|
+
return (await inboxRevision(doc)) === callerRevision;
|
|
49
|
+
}
|
|
50
|
+
/** Build the read result for a caller presenting `callerRevision` (or none). */
|
|
51
|
+
export async function readInboxWithCursor(doc, callerRevision) {
|
|
52
|
+
const revision = await inboxRevision(doc);
|
|
53
|
+
if (callerRevision && callerRevision === revision)
|
|
54
|
+
return { unchanged: true, revision };
|
|
55
|
+
return { unchanged: false, revision, doc };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=inbox-revision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-revision.js","sourceRoot":"","sources":["../src/inbox-revision.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,uGAAuG;AACvG,wGAAwG;AACxG,iGAAiG;AACjG,mCAAmC;AACnC,EAAE;AACF,uGAAuG;AACvG,kGAAkG;AAClG,uGAAuG;AACvG,uGAAuG;AACvG,wFAAwF;AACxF,EAAE;AACF,gGAAgG;AAChG,mGAAmG;AACnG,sGAAsG;AACtG,mGAAmG;AACnG,wDAAwD;AACxD,EAAE;AACF,qGAAqG;AACrG,sGAAsG;AACtG,gDAAgD;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQnD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAgB;IAClD,OAAO,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAgB,EAChB,cAAyC;IAEzC,IAAI,CAAC,cAAc;QAAE,OAAO,KAAK,CAAC;IAClC,OAAO,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,cAAc,CAAC;AACvD,CAAC;AAaD,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,GAAgB,EAChB,cAAyC;IAEzC,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,IAAI,cAAc,IAAI,cAAc,KAAK,QAAQ;QAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACxF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AAC7C,CAAC"}
|