@agenticprimitives/fabric 0.0.0-alpha.1 → 0.0.0-alpha.11

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 (167) hide show
  1. package/CLAUDE.md +26 -30
  2. package/README.md +16 -16
  3. package/dist/case-emissions.d.ts +95 -0
  4. package/dist/case-emissions.d.ts.map +1 -0
  5. package/dist/case-emissions.js +208 -0
  6. package/dist/case-emissions.js.map +1 -0
  7. package/dist/case-machine.d.ts +28 -2
  8. package/dist/case-machine.d.ts.map +1 -1
  9. package/dist/case-machine.js +34 -7
  10. package/dist/case-machine.js.map +1 -1
  11. package/dist/cloudflare/authority-verdict-cache.d.ts +28 -1
  12. package/dist/cloudflare/authority-verdict-cache.d.ts.map +1 -1
  13. package/dist/cloudflare/authority-verdict-cache.js +32 -1
  14. package/dist/cloudflare/authority-verdict-cache.js.map +1 -1
  15. package/dist/cloudflare/index.d.ts +4 -1
  16. package/dist/cloudflare/index.d.ts.map +1 -1
  17. package/dist/cloudflare/index.js +7 -1
  18. package/dist/cloudflare/index.js.map +1 -1
  19. package/dist/cloudflare/interaction-store.d.ts +55 -0
  20. package/dist/cloudflare/interaction-store.d.ts.map +1 -0
  21. package/dist/cloudflare/interaction-store.js +230 -0
  22. package/dist/cloudflare/interaction-store.js.map +1 -0
  23. package/dist/cloudflare/principal-gateway-do.d.ts +136 -2
  24. package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -1
  25. package/dist/cloudflare/principal-gateway-do.js +190 -8
  26. package/dist/cloudflare/principal-gateway-do.js.map +1 -1
  27. package/dist/cloudflare/vault-exchange-store.d.ts +47 -0
  28. package/dist/cloudflare/vault-exchange-store.d.ts.map +1 -0
  29. package/dist/cloudflare/vault-exchange-store.js +118 -0
  30. package/dist/cloudflare/vault-exchange-store.js.map +1 -0
  31. package/dist/cloudflare/vault-interaction-store.d.ts +44 -0
  32. package/dist/cloudflare/vault-interaction-store.d.ts.map +1 -0
  33. package/dist/cloudflare/vault-interaction-store.js +245 -0
  34. package/dist/cloudflare/vault-interaction-store.js.map +1 -0
  35. package/dist/communicative-act.d.ts +24 -1
  36. package/dist/communicative-act.d.ts.map +1 -1
  37. package/dist/communicative-act.js +28 -0
  38. package/dist/communicative-act.js.map +1 -1
  39. package/dist/delivery-envelope.d.ts.map +1 -1
  40. package/dist/delivery-envelope.js +0 -1
  41. package/dist/delivery-envelope.js.map +1 -1
  42. package/dist/enum-retirement.d.ts +43 -0
  43. package/dist/enum-retirement.d.ts.map +1 -0
  44. package/dist/enum-retirement.js +93 -0
  45. package/dist/enum-retirement.js.map +1 -0
  46. package/dist/exchange-record.d.ts +35 -4
  47. package/dist/exchange-record.d.ts.map +1 -1
  48. package/dist/exchange-record.js.map +1 -1
  49. package/dist/exchange-reducer.d.ts +32 -4
  50. package/dist/exchange-reducer.d.ts.map +1 -1
  51. package/dist/exchange-reducer.js +75 -1
  52. package/dist/exchange-reducer.js.map +1 -1
  53. package/dist/exchange-state.d.ts +30 -8
  54. package/dist/exchange-state.d.ts.map +1 -1
  55. package/dist/exchange-state.js +12 -10
  56. package/dist/exchange-state.js.map +1 -1
  57. package/dist/inbox-doc.d.ts +2 -2
  58. package/dist/inbox-doc.d.ts.map +1 -1
  59. package/dist/inbox-doc.js.map +1 -1
  60. package/dist/inbox-projection.d.ts +2 -2
  61. package/dist/inbox-projection.d.ts.map +1 -1
  62. package/dist/inbox-projection.js.map +1 -1
  63. package/dist/inbox-revision.d.ts +42 -0
  64. package/dist/inbox-revision.d.ts.map +1 -0
  65. package/dist/inbox-revision.js +57 -0
  66. package/dist/inbox-revision.js.map +1 -0
  67. package/dist/index.d.ts +24 -3
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +37 -2
  70. package/dist/index.js.map +1 -1
  71. package/dist/interaction-machines.d.ts +136 -0
  72. package/dist/interaction-machines.d.ts.map +1 -0
  73. package/dist/interaction-machines.js +174 -0
  74. package/dist/interaction-machines.js.map +1 -0
  75. package/dist/interaction-profile.d.ts +126 -0
  76. package/dist/interaction-profile.d.ts.map +1 -0
  77. package/dist/interaction-profile.js +192 -0
  78. package/dist/interaction-profile.js.map +1 -0
  79. package/dist/interaction-record.d.ts +168 -0
  80. package/dist/interaction-record.d.ts.map +1 -0
  81. package/dist/interaction-record.js +108 -0
  82. package/dist/interaction-record.js.map +1 -0
  83. package/dist/interactions/machine.d.ts +2 -2
  84. package/dist/interactions/machine.d.ts.map +1 -1
  85. package/dist/interactions/machine.js +2 -2
  86. package/dist/interactions/machine.js.map +1 -1
  87. package/dist/interactions/open-case.d.ts +60 -0
  88. package/dist/interactions/open-case.d.ts.map +1 -0
  89. package/dist/interactions/open-case.js +83 -0
  90. package/dist/interactions/open-case.js.map +1 -0
  91. package/dist/interactions/store.d.ts +9 -0
  92. package/dist/interactions/store.d.ts.map +1 -1
  93. package/dist/interactions/store.js +57 -2
  94. package/dist/interactions/store.js.map +1 -1
  95. package/dist/messaging/board.d.ts +86 -6
  96. package/dist/messaging/board.d.ts.map +1 -1
  97. package/dist/messaging/board.js +100 -9
  98. package/dist/messaging/board.js.map +1 -1
  99. package/dist/messaging/consult-routing.d.ts +289 -0
  100. package/dist/messaging/consult-routing.d.ts.map +1 -0
  101. package/dist/messaging/consult-routing.js +455 -0
  102. package/dist/messaging/consult-routing.js.map +1 -0
  103. package/dist/messaging/consult.d.ts +158 -0
  104. package/dist/messaging/consult.d.ts.map +1 -0
  105. package/dist/messaging/consult.js +141 -0
  106. package/dist/messaging/consult.js.map +1 -0
  107. package/dist/messaging/conversation-interaction.d.ts +66 -0
  108. package/dist/messaging/conversation-interaction.d.ts.map +1 -0
  109. package/dist/messaging/conversation-interaction.js +139 -0
  110. package/dist/messaging/conversation-interaction.js.map +1 -0
  111. package/dist/messaging/delivery.d.ts +2 -2
  112. package/dist/messaging/delivery.d.ts.map +1 -1
  113. package/dist/messaging/delivery.js +8 -1
  114. package/dist/messaging/delivery.js.map +1 -1
  115. package/dist/messaging/directory.d.ts +16 -0
  116. package/dist/messaging/directory.d.ts.map +1 -1
  117. package/dist/messaging/directory.js.map +1 -1
  118. package/dist/messaging/envelope.d.ts +7 -3
  119. package/dist/messaging/envelope.d.ts.map +1 -1
  120. package/dist/messaging/envelope.js +18 -1
  121. package/dist/messaging/envelope.js.map +1 -1
  122. package/dist/messaging/hash.d.ts +8 -2
  123. package/dist/messaging/hash.d.ts.map +1 -1
  124. package/dist/messaging/hash.js +6 -0
  125. package/dist/messaging/hash.js.map +1 -1
  126. package/dist/messaging/inbox-assistant.d.ts +80 -0
  127. package/dist/messaging/inbox-assistant.d.ts.map +1 -0
  128. package/dist/messaging/inbox-assistant.js +125 -0
  129. package/dist/messaging/inbox-assistant.js.map +1 -0
  130. package/dist/messaging/index.d.ts +10 -3
  131. package/dist/messaging/index.d.ts.map +1 -1
  132. package/dist/messaging/index.js +20 -2
  133. package/dist/messaging/index.js.map +1 -1
  134. package/dist/messaging/outbound-message.d.ts +42 -0
  135. package/dist/messaging/outbound-message.d.ts.map +1 -0
  136. package/dist/messaging/outbound-message.js +64 -0
  137. package/dist/messaging/outbound-message.js.map +1 -0
  138. package/dist/messaging/projector.d.ts +3 -3
  139. package/dist/messaging/projector.d.ts.map +1 -1
  140. package/dist/messaging/projector.js.map +1 -1
  141. package/dist/messaging/receipts.d.ts +3 -3
  142. package/dist/messaging/receipts.d.ts.map +1 -1
  143. package/dist/messaging/receipts.js.map +1 -1
  144. package/dist/messaging/rules.d.ts +10 -3
  145. package/dist/messaging/rules.d.ts.map +1 -1
  146. package/dist/messaging/rules.js +8 -1
  147. package/dist/messaging/rules.js.map +1 -1
  148. package/dist/messaging/store.d.ts +4 -4
  149. package/dist/messaging/store.d.ts.map +1 -1
  150. package/dist/messaging/store.js +5 -3
  151. package/dist/messaging/store.js.map +1 -1
  152. package/dist/messaging/types.d.ts +52 -0
  153. package/dist/messaging/types.d.ts.map +1 -1
  154. package/dist/messaging/types.js +18 -1
  155. package/dist/messaging/types.js.map +1 -1
  156. package/dist/messaging/vault-store.d.ts +35 -2
  157. package/dist/messaging/vault-store.d.ts.map +1 -1
  158. package/dist/messaging/vault-store.js +53 -5
  159. package/dist/messaging/vault-store.js.map +1 -1
  160. package/dist/protocol-binding.d.ts +71 -0
  161. package/dist/protocol-binding.d.ts.map +1 -0
  162. package/dist/protocol-binding.js +0 -0
  163. package/dist/protocol-binding.js.map +1 -0
  164. package/dist/record-catalog.d.ts.map +1 -1
  165. package/dist/record-catalog.js +24 -0
  166. package/dist/record-catalog.js.map +1 -1
  167. package/package.json +7 -7
@@ -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"}
package/dist/index.d.ts CHANGED
@@ -1,13 +1,34 @@
1
1
  export { canTaskTransition, canExchangeTransition, expectedExecForCase, isExecCaseConsistent, EXEC_CASE_COUPLING, TRANSPORT_SET_EXEC, EXEC_STATES, CASE_STATES, } from './exchange-state.js';
2
2
  export type { ExecState, CaseState } from './exchange-state.js';
3
+ export { isEnvelopeV2 } from './messaging/types.js';
4
+ export type { AnyMessageEnvelope, MessageEnvelopeV1, MessageEnvelopeV2 } from './messaging/types.js';
3
5
  export { hashExchangeEnvelope, hashIntentEnvelope, actorOf } from './exchange-record.js';
4
6
  export type { ExchangeId, ExchangeEnvelopeV1, IntentEnvelopeV1, ExchangeRecordV1, ExchangeEventV1, ArtifactRef, } from './exchange-record.js';
5
- export { performativeForKind } from './communicative-act.js';
7
+ export { performativeForKind, performativeOf, isOriginalMessage } from './communicative-act.js';
6
8
  export type { Performative, CommunicativeActV1, SemanticContentRef, EvidenceRef, } from './communicative-act.js';
7
- export { applyCaseTransition, isTerminalCaseState, TERMINAL_CASE_STATES, } from './case-machine.js';
8
- export type { FabricCaseV1, CaseFsmFields, CaseTransition, CaseTransitionEventV1, CaseResult, CaseRejection, } from './case-machine.js';
9
+ export { applyCaseTransition, isTerminalCaseState, TERMINAL_CASE_STATES, requiresGrantedDecision, TRANSITIONS_REQUIRING_GRANTED_DECISION, } from './case-machine.js';
10
+ export type { FabricCaseV1, CaseFsmFields, CaseTransition, CaseTransitionEventV1, CaseResult, CaseRejection, CaseTransitionContext, } from './case-machine.js';
11
+ export { caseTransitionEmissions, applyCaseEmissions, seedDecision, seedCommitment, decisionIdForCase, commitmentIdForCase, EMITTING_CASE_TRANSITIONS, } from './case-emissions.js';
12
+ export type { CaseEmissionsV1, CaseEmissionApplyResult, EmissionOutcome, DecisionSeedV1, CommitmentSeedV1, } from './case-emissions.js';
9
13
  export { applyExchangeEvent, caseViewFromRecord } from './exchange-reducer.js';
14
+ export { openCase, derivedCaseId, type OpenCaseInput, type OpenCaseResult } from './interactions/open-case.js';
10
15
  export type { ExchangeApplyResult } from './exchange-reducer.js';
16
+ export { EXCHANGE_REDUCER_VERSION, eventSetDigest, replayExchange } from './exchange-reducer.js';
17
+ export type { MaterializationProvenanceV1, ExchangeReplayResult } from './exchange-reducer.js';
18
+ export { PROTOCOL, looksCanonical, bindProtocol, bindingKey, buildBindingIndex, resolveInteractionByBinding, topicInteractionId, channelIdFromTopicInteraction, } from './protocol-binding.js';
19
+ export type { ProtocolBindingV1, BindingRejection, BindingIndex, BindingResolution } from './protocol-binding.js';
20
+ export { PROFILE_FOR_MESSAGE_KIND, MACHINE_FOR_CASE_STATE, machinesSpannedByCaseState } from './enum-retirement.js';
21
+ export type { OwningMachine } from './enum-retirement.js';
22
+ export { checkExchangeAgainstProfile, profileFor, PROFILE_LIBRARY, DIRECT_PROFILE, NEGOTIATION_PROFILE, CONSULTATION_PROFILE, ENGAGEMENT_PROFILE, TOPIC_PROFILE, ENGAGEMENT_RESPONSE_KIND_AXES, } from './interaction-profile.js';
23
+ export type { InteractionProfileV1, ProfileViolation, ExchangeUnderProfile, } from './interaction-profile.js';
24
+ export { applyInboxTransition, applyInteractionTransition, applyDecisionTransition, applyCommitmentTransition, mayDischargeOnExecution, TERMINAL_INTERACTION_STATES, TERMINAL_DECISION_STATES, TERMINAL_COMMITMENT_STATES, } from './interaction-machines.js';
25
+ export type { MachineRejection, MachineResult, InboxState, InboxTransition, InboxEntryV1, InteractionState, InteractionTransition, InteractionLifecycleV1, DecisionState, DecisionTransition, DecisionRecordV1, CommitmentState, CommitmentTransition, CommitmentRecordV1, } from './interaction-machines.js';
26
+ export { isProfileVersion, isFloatingVersion, checkReproducible, assertReproducible, hashContextSnapshot, buildContextSnapshot, verifyContextSnapshot, participantsAt, detectProfileDowngrades, } from './interaction-record.js';
27
+ export type { InteractionId, InteractionRecordV1, ProfileVersion, ParticipationV1, ContextDigest, ContextReferenceV1, ContextSnapshotV1, ContextReproducibilityFailure, ProfileDowngrade, } from './interaction-record.js';
28
+ export { inboxRevision, inboxUnchanged, readInboxWithCursor } from './inbox-revision.js';
29
+ export type { InboxRevision, InboxReadResult } from './inbox-revision.js';
30
+ export { conversationInteractionId, conversationIdFromInteraction, participationModeOfConversation, profileVersionOfConversation, participationsOfConversation, conversationPins, interactionViewOfConversation, participationModeOfChannel, interactionViewOfChannel, } from './messaging/conversation-interaction.js';
31
+ export type { ConversationExchangePins, ConversationInteractionView } from './messaging/conversation-interaction.js';
11
32
  export { projectInboxItem, applyMessageEvent, applyInboxRules, createInMemoryInboxProjector, } from './inbox-projection.js';
12
33
  export type { InboxProjectionEvent, InboxItemV1, InboxRuleV1, InboxProjector, CreateInboxProjectorOpts, FolderKind, } from './inbox-projection.js';
13
34
  export { buildGatewaySurfaceCommitment, hashGatewaySurfaceCommitment, verifyGatewaySurfaceCommitment, } from './gateway-surface.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACzF,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,6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CAAyC,CAAC;AACjD,YAAY,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAGrH,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIpF,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,WAAW,GACjB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -7,14 +7,49 @@
7
7
  // Wave 1 (this slice): the two-level exec/case state machine spine. Envelope + inbox reducers + case
8
8
  // payloads are absorbed from messaging/interactions in the subsequent Wave-1 steps.
9
9
  export { canTaskTransition, canExchangeTransition, expectedExecForCase, isExecCaseConsistent, EXEC_CASE_COUPLING, TRANSPORT_SET_EXEC, EXEC_STATES, CASE_STATES, } from './exchange-state.js';
10
+ // spec 340 — the ap.message.v2 wire version and its dual-read seam. V1 is untouched and still
11
+ // verifies; V2 drops `kind` and carries `performative` natively. Readers take `AnyMessageEnvelope`.
12
+ export { isEnvelopeV2 } from './messaging/types.js';
10
13
  // The canonical exchange object (spec 316 §b) — absorbs the messaging envelope + composes the two-level FSM.
11
14
  export { hashExchangeEnvelope, hashIntentEnvelope, actorOf } from './exchange-record.js';
12
15
  // Fabric semantic acts (spec 324 §9) — the speech-act layer over the transport envelope. Never authority.
13
- export { performativeForKind } from './communicative-act.js';
16
+ export { performativeForKind, performativeOf, isOriginalMessage } from './communicative-act.js';
14
17
  // The absorbed case (business-substate) machine — interactions FSM re-anchored on the 11-state CaseState.
15
- export { applyCaseTransition, isTerminalCaseState, TERMINAL_CASE_STATES, } from './case-machine.js';
18
+ export { applyCaseTransition, isTerminalCaseState, TERMINAL_CASE_STATES, requiresGrantedDecision, TRANSITIONS_REQUIRING_GRANTED_DECISION, } from './case-machine.js';
19
+ // spec 340 W10 — what a case transition emits into the decision and commitment machines. The
20
+ // prerequisite §R.3 names for shrinking `CaseState` to execution: those states must land in their own
21
+ // machines before the enum can lose them.
22
+ export { caseTransitionEmissions, applyCaseEmissions, seedDecision, seedCommitment, decisionIdForCase, commitmentIdForCase, EMITTING_CASE_TRANSITIONS, } from './case-emissions.js';
16
23
  // The unified exchange-event reducer (spec 316 §b/§2) — one append-only stream, one reducer over the record.
17
24
  export { applyExchangeEvent, caseViewFromRecord } from './exchange-reducer.js';
25
+ export { openCase, derivedCaseId } from './interactions/open-case.js';
26
+ // Materialization provenance (spec 340 INV-340-8) — rebuilt state travels WITH which events and which
27
+ // rules produced it, so a dropped event and a never-received one stop looking identical.
28
+ export { EXCHANGE_REDUCER_VERSION, eventSetDigest, replayExchange } from './exchange-reducer.js';
29
+ // Protocol bindings (spec 340 §11 / W5) — foreign keys into other protocols' namespaces, NEVER our
30
+ // canonical ids. Resolution returns a typed ambiguity rather than a first match: cross-wiring two
31
+ // interactions merges two participant sets, two commitment ledgers and two audit trails.
32
+ export { PROTOCOL, looksCanonical, bindProtocol, bindingKey, buildBindingIndex, resolveInteractionByBinding, topicInteractionId, channelIdFromTopicInteraction, } from './protocol-binding.js';
33
+ // TRANSITIONAL (spec 340 W5) — the MessageKind/CaseState retirement path. This module exists to be
34
+ // deleted; both enums are still live, and the total compiler-checked mapping is what makes the later
35
+ // removal mechanical instead of a judgement call per call site.
36
+ export { PROFILE_FOR_MESSAGE_KIND, MACHINE_FOR_CASE_STATE, machinesSpannedByCaseState } from './enum-retirement.js';
37
+ // The profile mechanism (spec 340 W4) — what replaces the frozen MessageKind/CaseState enums. A new
38
+ // interaction type is DATA, not a schema change. A profile permits nothing.
39
+ export { checkExchangeAgainstProfile, profileFor, PROFILE_LIBRARY, DIRECT_PROFILE, NEGOTIATION_PROFILE, CONSULTATION_PROFILE, ENGAGEMENT_PROFILE, TOPIC_PROFILE, ENGAGEMENT_RESPONSE_KIND_AXES, } from './interaction-profile.js';
40
+ // The four state machines spec 340 §5 named and the fabric did not have (W3). Six, never collapsed:
41
+ // delivery · inbox · interaction · decision · commitment · execution. None of them is authority.
42
+ export { applyInboxTransition, applyInteractionTransition, applyDecisionTransition, applyCommitmentTransition, mayDischargeOnExecution, TERMINAL_INTERACTION_STATES, TERMINAL_DECISION_STATES, TERMINAL_COMMITMENT_STATES, } from './interaction-machines.js';
43
+ // The durable governed situation (spec 340 W2; ADR-0058). The aggregate an Exchange occurs IN — an
44
+ // Exchange without one is a message, which is a legitimate state and why the pins are optional.
45
+ export { isProfileVersion, isFloatingVersion, checkReproducible, assertReproducible, hashContextSnapshot, buildContextSnapshot, verifyContextSnapshot, participantsAt, detectProfileDowngrades, } from './interaction-record.js';
46
+ // spec 341 §3.2 / Wave 2a — the inbox READ CURSOR. Makes an unchanged poll cheap BEFORE the read moves
47
+ // onto signed A2A round-trips, so the migration is not a latency regression. A digest, not a counter:
48
+ // derived rather than stored, so it cannot drift from the document it describes.
49
+ export { inboxRevision, inboxUnchanged, readInboxWithCursor } from './inbox-revision.js';
50
+ // The vault-backed conversation as an Interaction (spec 340 W12) — the projection `demo-a2a`'s live
51
+ // board path uses. W11 wired the DO-SQL channel store, which no app runs; this reaches the one that does.
52
+ export { conversationInteractionId, conversationIdFromInteraction, participationModeOfConversation, profileVersionOfConversation, participationsOfConversation, conversationPins, interactionViewOfConversation, participationModeOfChannel, interactionViewOfChannel, } from './messaging/conversation-interaction.js';
18
53
  // Inbox projection (spec 316 §b) — the vault-resident inbox row projected from the message-event slice.
19
54
  export { projectInboxItem, applyMessageEvent, applyInboxRules, createInMemoryInboxProjector, } from './inbox-projection.js';
20
55
  // Gateway surface commitment (spec 316 §4.1 / W4 — decentralized discovery; the atl:gatewayRoot preimage).
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,sGAAsG;AACtG,oGAAoG;AACpG,8EAA8E;AAC9E,EAAE;AACF,qGAAqG;AACrG,oFAAoF;AAEpF,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAG7B,6GAA6G;AAC7G,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAUzF,0GAA0G;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQ7D,0GAA0G;AAC1G,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAU3B,6GAA6G;AAC7G,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG/E,wGAAwG;AACxG,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAU/B,2GAA2G;AAC3G,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAG9B,sFAAsF;AACtF,OAAO,EACL,qBAAqB,EACrB,qBA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AAC1G,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,+BAA+B,EAC/B,4BAA4B,EAC5B,4BAA4B,EAC5B,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,yCAAyC,CAAC;AAGjD,wGAAwG;AACxG,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAU/B,2GAA2G;AAC3G,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAG9B,sFAAsF;AACtF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAGhC,mGAAmG;AACnG,yFAAyF;AACzF,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,gBAAgB,CAAC;AAExB,iGAAiG;AACjG,uFAAuF;AACvF,OAAO,EAAE,cAAc,EAAE,eAAe,EAA2B,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,136 @@
1
+ import type { CanonicalAgentId } from '@agenticprimitives/types';
2
+ import type { InteractionId, ParticipationV1 } from './interaction-record.js';
3
+ /** Shared rejection vocabulary. Every machine is fail-closed: an unknown or ill-timed move is a TYPED
4
+ * rejection, never a silent no-op, because a silent no-op is indistinguishable from success. */
5
+ export type MachineRejection = 'invalid-transition' | 'unauthorized-actor' | 'terminal-state' | 'wrong-subject';
6
+ export type MachineResult<T> = {
7
+ ok: true;
8
+ next: T;
9
+ } | {
10
+ ok: false;
11
+ reason: MachineRejection;
12
+ };
13
+ /**
14
+ * What one participant's client has done with an exchange. Deliberately separate from delivery: two
15
+ * recipients of the same exchange have different inbox states, and neither is a fact about the
16
+ * exchange itself.
17
+ *
18
+ * `read` is the state ADR-0058 §16 is most careful about. It means a client marked something read. It
19
+ * is not comprehension, not acknowledgement, not consent, and not acceptance.
20
+ */
21
+ export type InboxState = 'unread' | 'read' | 'archived' | 'deleted';
22
+ export type InboxTransition = 'mark-read' | 'mark-unread' | 'archive' | 'restore' | 'delete';
23
+ export interface InboxEntryV1 {
24
+ /** WHOSE inbox. The state belongs to this viewer alone. */
25
+ viewer: CanonicalAgentId;
26
+ exchangeId: string;
27
+ state: InboxState;
28
+ updatedAt: string;
29
+ }
30
+ /**
31
+ * Only the viewer moves their own inbox state.
32
+ *
33
+ * `deleted` is a tombstone, not an erasure: `restore` can bring it back, and the exchange itself is
34
+ * untouched. One participant deleting their copy must never remove the record other participants and
35
+ * the audit trail depend on.
36
+ */
37
+ export declare function applyInboxTransition(entry: InboxEntryV1, event: {
38
+ transition: InboxTransition;
39
+ actor: CanonicalAgentId;
40
+ at: string;
41
+ }): MachineResult<InboxEntryV1>;
42
+ export type InteractionState = 'forming' | 'active' | 'suspended' | 'concluded' | 'abandoned';
43
+ export type InteractionTransition = 'open' | 'suspend' | 'resume' | 'conclude' | 'abandon';
44
+ export declare const TERMINAL_INTERACTION_STATES: readonly InteractionState[];
45
+ export interface InteractionLifecycleV1 {
46
+ interactionId: InteractionId;
47
+ state: InteractionState;
48
+ /** The SA custodying the interaction. Ending it is a custodial act, not a participant's. */
49
+ principal: CanonicalAgentId;
50
+ participations: readonly ParticipationV1[];
51
+ updatedAt: string;
52
+ }
53
+ /**
54
+ * Ending an interaction is CUSTODIAL — the principal, not any participant. A counterparty who could
55
+ * conclude a negotiation could end it the moment it stopped favouring them.
56
+ *
57
+ * Concluding does NOT touch commitments. That separation is the entire reason this machine and the
58
+ * commitment machine are distinct: otherwise closing a conversation quietly voids what was promised
59
+ * in it, and the party who benefits from that is exactly the party who closes it.
60
+ */
61
+ export declare function applyInteractionTransition(lifecycle: InteractionLifecycleV1, event: {
62
+ transition: InteractionTransition;
63
+ actor: CanonicalAgentId;
64
+ at: string;
65
+ }): MachineResult<InteractionLifecycleV1>;
66
+ /**
67
+ * A determination's own lifecycle, separate from the work it may authorize.
68
+ *
69
+ * `granted` means a decision was recorded. It does not mean anything ran, and it does not by itself
70
+ * permit anything — the authority re-check happens at the moment of acting regardless of what this
71
+ * says (ADR-0041). A `DecisionReceipt` attests that a decision was made, never that it was executed.
72
+ */
73
+ export type DecisionState = 'pending' | 'granted' | 'refused' | 'withdrawn' | 'expired' | 'superseded';
74
+ export type DecisionTransition = 'grant' | 'refuse' | 'withdraw' | 'expire' | 'supersede';
75
+ export declare const TERMINAL_DECISION_STATES: readonly DecisionState[];
76
+ export interface DecisionRecordV1 {
77
+ decisionId: string;
78
+ state: DecisionState;
79
+ /** Whose determination this is. */
80
+ decider: CanonicalAgentId;
81
+ /** What it is about — an exchange, an act, a request. */
82
+ subject: string;
83
+ decidedAt?: string;
84
+ expiresAt?: string;
85
+ updatedAt: string;
86
+ }
87
+ /** Only the decider moves their own decision. `expire` is the exception: time is not an actor, so any
88
+ * party may record that the deadline passed, and only once it actually has. */
89
+ export declare function applyDecisionTransition(decision: DecisionRecordV1, event: {
90
+ transition: DecisionTransition;
91
+ actor: CanonicalAgentId;
92
+ at: string;
93
+ subject?: string;
94
+ }): MachineResult<DecisionRecordV1>;
95
+ /**
96
+ * A normative obligation with a debtor, a creditor and its own lifecycle.
97
+ *
98
+ * The two states doing the real work are `fulfilment-claimed` and `discharged`, and they are separate
99
+ * because the debtor saying "done" and the obligation ENDING are different facts with different
100
+ * signers. Collapsing them lets the party who owes the obligation declare it satisfied — which is the
101
+ * failure ADR-0058 §15 names when it says workflow completion discharges nothing on its own.
102
+ */
103
+ export type CommitmentState = 'proposed' | 'active' | 'fulfilment-claimed' | 'discharged' | 'breached' | 'void';
104
+ export type CommitmentTransition = 'activate' | 'claim-fulfilment' | 'dispute-claim' | 'discharge' | 'assert-breach' | 'void';
105
+ export declare const TERMINAL_COMMITMENT_STATES: readonly CommitmentState[];
106
+ export interface CommitmentRecordV1 {
107
+ commitmentId: string;
108
+ state: CommitmentState;
109
+ /** Who owes. */
110
+ debtor: CanonicalAgentId;
111
+ /** Who is owed. */
112
+ creditor: CanonicalAgentId;
113
+ /** The Offer this obligation came from — an Offer is not a Commitment (ADR-0058 §15). */
114
+ fromOffer?: string;
115
+ updatedAt: string;
116
+ }
117
+ export declare function applyCommitmentTransition(commitment: CommitmentRecordV1, event: {
118
+ transition: CommitmentTransition;
119
+ actor: CanonicalAgentId;
120
+ at: string;
121
+ }): MachineResult<CommitmentRecordV1>;
122
+ /**
123
+ * Whether finishing the work discharges the obligation.
124
+ *
125
+ * The answer is NO unless the profile says otherwise, and this function exists so that answer has a
126
+ * name a caller can find instead of an assumption a caller can make. A profile MAY declare
127
+ * auto-discharge for obligations whose fulfilment is objectively observable (a payment settling); it
128
+ * MUST NOT for anything requiring the creditor's judgement, which is most things.
129
+ *
130
+ * There is no code path from an execution event to a commitment transition. That is deliberate: the
131
+ * link has to be written by a profile that chose it, so the choice appears in a diff.
132
+ */
133
+ export declare function mayDischargeOnExecution(profile: {
134
+ autoDischargeOnExecution?: boolean;
135
+ }): boolean;
136
+ //# sourceMappingURL=interaction-machines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-machines.d.ts","sourceRoot":"","sources":["../src/interaction-machines.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE9E;iGACiG;AACjG,MAAM,MAAM,gBAAgB,GACxB,oBAAoB,GACpB,oBAAoB,GACpB,gBAAgB,GAChB,eAAe,CAAC;AAEpB,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAI/F;;;;;;;GAOG;AACH,MAAM,MAAM,UA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AgB,CAAC;IACzB,mBAAmB;IACnB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAoBD,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE;IAAE,UAAU,EAAE,oBAAoB,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/E,aAAa,CAAC,kBAAkB,CAAC,CAYnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAE,wBAAwB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAEhG"}
@@ -0,0 +1,174 @@
1
+ // The four state machines spec 340 §5 names and the fabric did not have.
2
+ //
3
+ // Six machines, never collapsed: `delivery · inbox · interaction · decision · commitment · execution`.
4
+ // Two exist — `ExecState` (delivery/transport) and `CaseState` (execution substate). These are the
5
+ // other four.
6
+ //
7
+ // WHY SIX AND NOT ONE. A single `status` field forces every question through one answer, and the
8
+ // answers genuinely differ. The chain that must never be short-circuited:
9
+ //
10
+ // delivered ≠ admitted ≠ authenticated ≠ canonical-agent-bound ≠ authorized ≠ executed ≠ completed
11
+ //
12
+ // Each collapse below is a real, specific misreading — not a theoretical one:
13
+ //
14
+ // inbox into delivery → "they read it" becomes "they agreed". Read state is PER-VIEWER and
15
+ // proves only that a client marked something read (ADR-0058 §16).
16
+ // decision into execution → a granted decision reads as work done. Deciding is not doing.
17
+ // commitment into execution → finishing the work discharges the obligation. It does not, unless the
18
+ // profile's discharge conditions are met (ADR-0058 §15) — which is why
19
+ // `claim-fulfilment` and `discharge` are two states with two signers.
20
+ // interaction into case → concluding a conversation silently voids what was promised in it.
21
+ //
22
+ // NONE OF THESE MACHINES IS AUTHORITY. They record what a situation IS, never what a party MAY do.
23
+ // A transition being legal here says nothing about whether the actor was permitted to make it —
24
+ // that is `delegation` + `entitlements` + `tool-policy`, re-evaluated at the moment of acting
25
+ // (ADR-0041, ADR-0043). The role checks below are integrity checks on the record's own shape
26
+ // ("the creditor releases their own claim"), not permission grants.
27
+ const INBOX_TRANSITIONS = {
28
+ 'mark-read': { from: ['unread', 'archived'], to: 'read' },
29
+ // Reversible on purpose: marking unread is a UI affordance, and a machine that forbade it would push
30
+ // clients into tracking read state somewhere this machine could not see.
31
+ 'mark-unread': { from: ['read', 'archived'], to: 'unread' },
32
+ archive: { from: ['unread', 'read'], to: 'archived' },
33
+ restore: { from: ['archived', 'deleted'], to: 'read' },
34
+ delete: { from: ['unread', 'read', 'archived'], to: 'deleted' },
35
+ };
36
+ /**
37
+ * Only the viewer moves their own inbox state.
38
+ *
39
+ * `deleted` is a tombstone, not an erasure: `restore` can bring it back, and the exchange itself is
40
+ * untouched. One participant deleting their copy must never remove the record other participants and
41
+ * the audit trail depend on.
42
+ */
43
+ export function applyInboxTransition(entry, event) {
44
+ if (event.actor !== entry.viewer)
45
+ return { ok: false, reason: 'unauthorized-actor' };
46
+ const spec = INBOX_TRANSITIONS[event.transition];
47
+ if (!spec)
48
+ return { ok: false, reason: 'invalid-transition' };
49
+ if (!spec.from.includes(entry.state))
50
+ return { ok: false, reason: 'invalid-transition' };
51
+ return { ok: true, next: { ...entry, state: spec.to, updatedAt: event.at } };
52
+ }
53
+ export const TERMINAL_INTERACTION_STATES = ['concluded', 'abandoned'];
54
+ const INTERACTION_TRANSITIONS = {
55
+ open: { from: ['forming'], to: 'active', custodialOnly: false },
56
+ suspend: { from: ['active'], to: 'suspended', custodialOnly: true },
57
+ resume: { from: ['suspended'], to: 'active', custodialOnly: true },
58
+ conclude: { from: ['active', 'suspended'], to: 'concluded', custodialOnly: true },
59
+ abandon: { from: ['forming', 'active', 'suspended'], to: 'abandoned', custodialOnly: true },
60
+ };
61
+ /**
62
+ * Ending an interaction is CUSTODIAL — the principal, not any participant. A counterparty who could
63
+ * conclude a negotiation could end it the moment it stopped favouring them.
64
+ *
65
+ * Concluding does NOT touch commitments. That separation is the entire reason this machine and the
66
+ * commitment machine are distinct: otherwise closing a conversation quietly voids what was promised
67
+ * in it, and the party who benefits from that is exactly the party who closes it.
68
+ */
69
+ export function applyInteractionTransition(lifecycle, event) {
70
+ const spec = INTERACTION_TRANSITIONS[event.transition];
71
+ if (!spec)
72
+ return { ok: false, reason: 'invalid-transition' };
73
+ if (TERMINAL_INTERACTION_STATES.includes(lifecycle.state))
74
+ return { ok: false, reason: 'terminal-state' };
75
+ if (!spec.from.includes(lifecycle.state))
76
+ return { ok: false, reason: 'invalid-transition' };
77
+ if (spec.custodialOnly) {
78
+ if (event.actor !== lifecycle.principal)
79
+ return { ok: false, reason: 'unauthorized-actor' };
80
+ }
81
+ else {
82
+ const isParticipant = lifecycle.participations.some((p) => p.agent === event.actor && p.leftAt === undefined);
83
+ if (!isParticipant && event.actor !== lifecycle.principal)
84
+ return { ok: false, reason: 'unauthorized-actor' };
85
+ }
86
+ return { ok: true, next: { ...lifecycle, state: spec.to, updatedAt: event.at } };
87
+ }
88
+ export const TERMINAL_DECISION_STATES = [
89
+ 'refused', 'withdrawn', 'expired', 'superseded',
90
+ ];
91
+ const DECISION_TRANSITIONS = {
92
+ grant: { from: ['pending'], to: 'granted' },
93
+ refuse: { from: ['pending'], to: 'refused' },
94
+ // A GRANT may be withdrawn; a refusal may not be "un-refused" into nothing — reversing a refusal is
95
+ // a NEW decision, so the trail shows both rather than one mutable verdict.
96
+ withdraw: { from: ['pending', 'granted'], to: 'withdrawn' },
97
+ expire: { from: ['pending', 'granted'], to: 'expired' },
98
+ supersede: { from: ['pending', 'granted'], to: 'superseded' },
99
+ };
100
+ /** Only the decider moves their own decision. `expire` is the exception: time is not an actor, so any
101
+ * party may record that the deadline passed, and only once it actually has. */
102
+ export function applyDecisionTransition(decision, event) {
103
+ if (event.subject !== undefined && event.subject !== decision.subject) {
104
+ return { ok: false, reason: 'wrong-subject' };
105
+ }
106
+ const spec = DECISION_TRANSITIONS[event.transition];
107
+ if (!spec)
108
+ return { ok: false, reason: 'invalid-transition' };
109
+ if (!spec.from.includes(decision.state)) {
110
+ return { ok: false, reason: TERMINAL_DECISION_STATES.includes(decision.state) ? 'terminal-state' : 'invalid-transition' };
111
+ }
112
+ if (event.transition === 'expire') {
113
+ if (decision.expiresAt === undefined || Date.parse(event.at) < Date.parse(decision.expiresAt)) {
114
+ return { ok: false, reason: 'invalid-transition' };
115
+ }
116
+ }
117
+ else if (event.actor !== decision.decider) {
118
+ return { ok: false, reason: 'unauthorized-actor' };
119
+ }
120
+ return {
121
+ ok: true,
122
+ next: {
123
+ ...decision,
124
+ state: spec.to,
125
+ decidedAt: spec.to === 'granted' || spec.to === 'refused' ? event.at : decision.decidedAt,
126
+ updatedAt: event.at,
127
+ },
128
+ };
129
+ }
130
+ export const TERMINAL_COMMITMENT_STATES = ['discharged', 'breached', 'void'];
131
+ const COMMITMENT_TRANSITIONS = {
132
+ // Activation follows a VALID, authorized Accept. This machine records that it happened; it does not
133
+ // judge the acceptance — acceptance by an unauthorized party creates nothing, and the check for that
134
+ // lives in the authority layer, which is why no amount of calling `activate` here can substitute.
135
+ activate: { from: ['proposed'], to: 'active', signers: ['creditor'] },
136
+ 'claim-fulfilment': { from: ['active'], to: 'fulfilment-claimed', signers: ['debtor'] },
137
+ 'dispute-claim': { from: ['fulfilment-claimed'], to: 'active', signers: ['creditor'] },
138
+ discharge: { from: ['active', 'fulfilment-claimed'], to: 'discharged', signers: ['creditor'] },
139
+ 'assert-breach': { from: ['active', 'fulfilment-claimed'], to: 'breached', signers: ['creditor'] },
140
+ // Only the creditor voids: giving up your own claim is yours to do; cancelling what you owe is not.
141
+ void: { from: ['proposed', 'active'], to: 'void', signers: ['creditor'] },
142
+ };
143
+ export function applyCommitmentTransition(commitment, event) {
144
+ const spec = COMMITMENT_TRANSITIONS[event.transition];
145
+ if (!spec)
146
+ return { ok: false, reason: 'invalid-transition' };
147
+ if (TERMINAL_COMMITMENT_STATES.includes(commitment.state))
148
+ return { ok: false, reason: 'terminal-state' };
149
+ if (!spec.from.includes(commitment.state))
150
+ return { ok: false, reason: 'invalid-transition' };
151
+ const parties = new Set();
152
+ if (event.actor === commitment.debtor)
153
+ parties.add('debtor');
154
+ if (event.actor === commitment.creditor)
155
+ parties.add('creditor');
156
+ if (!spec.signers.some((p) => parties.has(p)))
157
+ return { ok: false, reason: 'unauthorized-actor' };
158
+ return { ok: true, next: { ...commitment, state: spec.to, updatedAt: event.at } };
159
+ }
160
+ /**
161
+ * Whether finishing the work discharges the obligation.
162
+ *
163
+ * The answer is NO unless the profile says otherwise, and this function exists so that answer has a
164
+ * name a caller can find instead of an assumption a caller can make. A profile MAY declare
165
+ * auto-discharge for obligations whose fulfilment is objectively observable (a payment settling); it
166
+ * MUST NOT for anything requiring the creditor's judgement, which is most things.
167
+ *
168
+ * There is no code path from an execution event to a commitment transition. That is deliberate: the
169
+ * link has to be written by a profile that chose it, so the choice appears in a diff.
170
+ */
171
+ export function mayDischargeOnExecution(profile) {
172
+ return profile.autoDischargeOnExecution === true;
173
+ }
174
+ //# sourceMappingURL=interaction-machines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-machines.js","sourceRoot":"","sources":["../src/interaction-machines.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,uGAAuG;AACvG,mGAAmG;AACnG,cAAc;AACd,EAAE;AACF,iGAAiG;AACjG,0EAA0E;AAC1E,EAAE;AACF,qGAAqG;AACrG,EAAE;AACF,8EAA8E;AAC9E,EAAE;AACF,mGAAmG;AACnG,gGAAgG;AAChG,8FAA8F;AAC9F,sGAAsG;AACtG,qGAAqG;AACrG,oGAAoG;AACpG,kGAAkG;AAClG,EAAE;AACF,mGAAmG;AACnG,gGAAgG;AAChG,8FAA8F;AAC9F,6FAA6F;AAC7F,oEAAoE;AAqCpE,MAAM,iBAAiB,GAA6E;IAClG,WAAW,EAAE,EAAE,IAAI,EAAE,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