@entifix/transactions 0.9.0 → 0.10.0

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 (56) hide show
  1. package/dist/contracts/command.d.ts +2 -2
  2. package/dist/contracts/command.d.ts.map +1 -1
  3. package/dist/contracts/command.js.map +1 -1
  4. package/dist/contracts/inbox.d.ts +2 -2
  5. package/dist/contracts/inbox.d.ts.map +1 -1
  6. package/dist/contracts/inbox.js.map +1 -1
  7. package/dist/contracts/outbox.d.ts +6 -6
  8. package/dist/contracts/outbox.d.ts.map +1 -1
  9. package/dist/contracts/outbox.js.map +1 -1
  10. package/dist/contracts/record.d.ts +4 -4
  11. package/dist/contracts/record.d.ts.map +1 -1
  12. package/dist/contracts/record.js.map +1 -1
  13. package/dist/contracts/unit-of-work.d.ts +5 -5
  14. package/dist/contracts/unit-of-work.d.ts.map +1 -1
  15. package/dist/contracts/unit-of-work.js +1 -1
  16. package/dist/contracts/unit-of-work.js.map +1 -1
  17. package/dist/engine/in-memory-retry-budget.d.ts +33 -0
  18. package/dist/engine/in-memory-retry-budget.d.ts.map +1 -0
  19. package/dist/engine/in-memory-retry-budget.js +84 -0
  20. package/dist/engine/in-memory-retry-budget.js.map +1 -0
  21. package/dist/engine/index.d.ts +1 -0
  22. package/dist/engine/index.d.ts.map +1 -1
  23. package/dist/engine/index.js +1 -0
  24. package/dist/engine/index.js.map +1 -1
  25. package/dist/engine/run-saga.d.ts +3 -3
  26. package/dist/engine/run-saga.d.ts.map +1 -1
  27. package/dist/engine/run-saga.js.map +1 -1
  28. package/dist/engine/run-transaction.d.ts +1 -1
  29. package/dist/engine/run-transaction.d.ts.map +1 -1
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +2 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/ports/event-bus.d.ts +3 -3
  35. package/dist/ports/event-bus.d.ts.map +1 -1
  36. package/dist/ports/event-bus.js.map +1 -1
  37. package/dist/ports/lock-service.d.ts +4 -4
  38. package/dist/ports/lock-service.d.ts.map +1 -1
  39. package/dist/ports/lock-service.js.map +1 -1
  40. package/dist/ports/retry-budget.d.ts +51 -0
  41. package/dist/ports/retry-budget.d.ts.map +1 -0
  42. package/dist/ports/retry-budget.js +23 -0
  43. package/dist/ports/retry-budget.js.map +1 -0
  44. package/dist/ports/saga-store.d.ts +9 -9
  45. package/dist/ports/saga-store.d.ts.map +1 -1
  46. package/dist/ports/saga-store.js.map +1 -1
  47. package/dist/ports/sequence-service.d.ts +2 -2
  48. package/dist/ports/sequence-service.d.ts.map +1 -1
  49. package/dist/ports/sequence-service.js.map +1 -1
  50. package/dist/reactions/on.d.ts +53 -0
  51. package/dist/reactions/on.d.ts.map +1 -0
  52. package/dist/reactions/on.js +55 -0
  53. package/dist/reactions/on.js.map +1 -0
  54. package/dist/use-case/facade.uc.d.ts +2 -2
  55. package/dist/use-case/facade.uc.d.ts.map +1 -1
  56. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- import { EntifixBuildError, type EntifixEnvelope, type SerializedEntity } from '@entifix/core';
1
+ import { EntifixBuildError, type EntifixEnvelope, type InvalidEnvelope, type SerializedEntity } from '@entifix/core';
2
2
  import { Effect } from 'effect';
3
3
  /**
4
4
  * A write intent in CQRS terms. A client no longer mutates directly — it issues
@@ -54,5 +54,5 @@ export declare const isTransactionId: (value: unknown) => value is string;
54
54
  * idempotency key, and a caller who omits it silently loses retry safety while
55
55
  * appearing to succeed.
56
56
  */
57
- export declare function readCommandEnvelope<TPayload = SerializedEntity>(body: unknown): Effect.Effect<TransactionCommand<TPayload>, EntifixBuildError>;
57
+ export declare function readCommandEnvelope<TPayload = SerializedEntity>(body: unknown): Effect.Effect<TransactionCommand<TPayload>, EntifixBuildError | InvalidEnvelope>;
58
58
  //# sourceMappingURL=command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/contracts/command.ts"],"names":[],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AEhC;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ,GAAG,gBAAgB;IAC7D;;;;;;;;OAQG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,IAAI,EAAE,QAAQ,CAAC;IACf,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,OAAO,EAAE,QAAQ,CAAC;IAClB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,eAAe,CAAC,QAAQ,GAAG,gBAAgB,IAAI,eAAe,CACxE,kBAAkB,CAAC,QAAQ,CAAC,CAC7B,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,QAAQ,GAAG,gBAAgB,EAC7D,OAAO,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACpC,eAAe,CAAC,QAAQ,CAAC,CAE3B;AAaD,kDAAkD;AAClD,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACX,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,GAAG,gBAAgB,EAC7D,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,CACd,kBAAkB,CAAC,QAAQ,CAAC,EAC5B,iBAAiB,GAAG,eAAe,CACpC,CA6BA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contracts/command.ts"],"sourcesContent":["import {\n EntifixBuildError,\n type EntifixEnvelope,\n makeEnvelope,\n readEnvelope,\n type SerializedEntity,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\n/**\n * A write intent in CQRS terms. A client no longer mutates directly — it issues\n * a command, the service runs the transaction facade over it, and answers with a\n * transaction id. `payload` is a serialized entity (the same wire shape the\n * entity envelopes carry), so a command round-trips through the existing\n * (de)serializer.\n */\nexport interface TransactionCommand<TPayload = SerializedEntity> {\n /**\n * Correlates every event and record for this run, and **the client mints it**.\n *\n * It is also the stored entity's id and the idempotency key: re-sending a\n * command with the same id returns the first one's answer instead of writing\n * twice. That makes it untrusted input which becomes a primary key, so\n * {@link readCommandEnvelope} constrains it to a UUID rather than accepting\n * any string.\n */\n transactionId: string;\n /** What to do — only `create` in phase 1. */\n type: 'create';\n /** The target entity's `key` (e.g. `product`), the routing/lock subject. */\n entity: string;\n /** The serialized entity to act on. */\n payload: TPayload;\n /**\n * Whose organization this command acts in — **stamped by the route from the\n * verified token, never read from the wire**.\n *\n * {@link readCommandEnvelope} drops whatever a caller sent under this name, so\n * a client cannot name another tenant by writing one into the body. It is the\n * same rule the id already follows (`entity.id = params.id`), and the same\n * rule `requireOrganization` states: the organization comes from the token and\n * nowhere else.\n *\n * Optional because the parser produces a command without it and the route\n * fills it in a moment later. A command that reaches the engine still carrying\n * `undefined` emits events that no tenant-scoped stream connection receives —\n * which is the intended direction to fail.\n */\n organizationId?: string;\n}\n\nexport type CommandEnvelope<TPayload = SerializedEntity> = EntifixEnvelope<\n TransactionCommand<TPayload>\n>;\n\n/** Frames a command as a transport-free `command` envelope. */\nexport function makeCommandEnvelope<TPayload = SerializedEntity>(\n command: TransactionCommand<TPayload>,\n): CommandEnvelope<TPayload> {\n return makeEnvelope('command', command.entity, command);\n}\n\n/**\n * A canonical RFC 9562 UUID — any version, standard variant.\n *\n * The transaction id arrives from the client and becomes a primary key, so the\n * key space it may address has to be fixed rather than \"whatever string was\n * sent\". Accepting every version keeps v4 (random) and v7 (time-ordered) both\n * usable without the wire format becoming a second decision.\n */\nconst UUID =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\n/** Whether a value is a usable transaction id. */\nexport const isTransactionId = (value: unknown): value is string =>\n typeof value === 'string' && UUID.test(value);\n\n/**\n * Parses a `command` envelope, failing on a wrong shape/type.\n *\n * A command carrying no valid transaction id is rejected outright — there is no\n * server-side fallback that mints one. That is deliberate: the id is the\n * idempotency key, and a caller who omits it silently loses retry safety while\n * appearing to succeed.\n */\nexport function readCommandEnvelope<TPayload = SerializedEntity>(\n body: unknown,\n): Effect.Effect<TransactionCommand<TPayload>, EntifixBuildError> {\n return Effect.gen(function* () {\n const envelope = yield* readEnvelope<TransactionCommand<TPayload>>(\n body,\n 'command',\n 'command',\n );\n const command = envelope.data;\n if (\n command == null ||\n !isTransactionId(command.transactionId) ||\n typeof command.entity !== 'string'\n ) {\n return yield* Effect.fail(\n new EntifixBuildError(\n 'command envelope carried no valid command',\n undefined,\n {\n body,\n },\n ),\n );\n }\n // `organizationId` is deliberately **not** carried over from the parsed\n // body. Spreading the caller's object here would let a request name another\n // tenant, which is precisely the scoping the stream depends on.\n const { organizationId: _ignored, ...trusted } = command;\n return trusted as TransactionCommand<TPayload>;\n });\n}\n"],"names":["EntifixBuildError","makeEnvelope","readEnvelope","Effect","makeCommandEnvelope","command","entity","UUID","isTransactionId","value","test","readCommandEnvelope","body","gen","envelope","data","transactionId","fail","undefined","organizationId","_ignored","trusted"],"mappings":";AAAA,SACEA,iBAAiB,EAEjBC,YAAY,EACZC,YAAY,QAEP,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAgDhC,6DAA6D,GAC7D,OAAO,SAASC,oBACdC,OAAqC;IAErC,OAAOJ,aAAa,WAAWI,QAAQC,MAAM,EAAED;AACjD;AAEA;;;;;;;CAOC,GACD,MAAME,OACJ;AAEF,gDAAgD,GAChD,OAAO,MAAMC,kBAAkB,CAACC,QAC9B,OAAOA,UAAU,YAAYF,KAAKG,IAAI,CAACD,OAAO;AAEhD;;;;;;;CAOC,GACD,OAAO,SAASE,oBACdC,IAAa;IAEb,OAAOT,OAAOU,GAAG,CAAC;QAChB,MAAMC,WAAW,OAAOZ,aACtBU,MACA,WACA;QAEF,MAAMP,UAAUS,SAASC,IAAI;QAC7B,IACEV,WAAW,QACX,CAACG,gBAAgBH,QAAQW,aAAa,KACtC,OAAOX,QAAQC,MAAM,KAAK,UAC1B;YACA,OAAO,OAAOH,OAAOc,IAAI,CACvB,IAAIjB,kBACF,6CACAkB,WACA;gBACEN;YACF;QAGN;QACA,wEAAwE;QACxE,4EAA4E;QAC5E,gEAAgE;QAChE,MAAM,EAAEO,gBAAgBC,QAAQ,EAAc,GAAGf,SAAZgB,2CAAYhB;;;QACjD,OAAOgB;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/contracts/command.ts"],"sourcesContent":["import {\n EntifixBuildError,\n type EntifixEnvelope,\n type InvalidEnvelope,\n makeEnvelope,\n readEnvelope,\n type SerializedEntity,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\n/**\n * A write intent in CQRS terms. A client no longer mutates directly — it issues\n * a command, the service runs the transaction facade over it, and answers with a\n * transaction id. `payload` is a serialized entity (the same wire shape the\n * entity envelopes carry), so a command round-trips through the existing\n * (de)serializer.\n */\nexport interface TransactionCommand<TPayload = SerializedEntity> {\n /**\n * Correlates every event and record for this run, and **the client mints it**.\n *\n * It is also the stored entity's id and the idempotency key: re-sending a\n * command with the same id returns the first one's answer instead of writing\n * twice. That makes it untrusted input which becomes a primary key, so\n * {@link readCommandEnvelope} constrains it to a UUID rather than accepting\n * any string.\n */\n transactionId: string;\n /** What to do — only `create` in phase 1. */\n type: 'create';\n /** The target entity's `key` (e.g. `product`), the routing/lock subject. */\n entity: string;\n /** The serialized entity to act on. */\n payload: TPayload;\n /**\n * Whose organization this command acts in — **stamped by the route from the\n * verified token, never read from the wire**.\n *\n * {@link readCommandEnvelope} drops whatever a caller sent under this name, so\n * a client cannot name another tenant by writing one into the body. It is the\n * same rule the id already follows (`entity.id = params.id`), and the same\n * rule `requireOrganization` states: the organization comes from the token and\n * nowhere else.\n *\n * Optional because the parser produces a command without it and the route\n * fills it in a moment later. A command that reaches the engine still carrying\n * `undefined` emits events that no tenant-scoped stream connection receives —\n * which is the intended direction to fail.\n */\n organizationId?: string;\n}\n\nexport type CommandEnvelope<TPayload = SerializedEntity> = EntifixEnvelope<\n TransactionCommand<TPayload>\n>;\n\n/** Frames a command as a transport-free `command` envelope. */\nexport function makeCommandEnvelope<TPayload = SerializedEntity>(\n command: TransactionCommand<TPayload>,\n): CommandEnvelope<TPayload> {\n return makeEnvelope('command', command.entity, command);\n}\n\n/**\n * A canonical RFC 9562 UUID — any version, standard variant.\n *\n * The transaction id arrives from the client and becomes a primary key, so the\n * key space it may address has to be fixed rather than \"whatever string was\n * sent\". Accepting every version keeps v4 (random) and v7 (time-ordered) both\n * usable without the wire format becoming a second decision.\n */\nconst UUID =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\n/** Whether a value is a usable transaction id. */\nexport const isTransactionId = (value: unknown): value is string =>\n typeof value === 'string' && UUID.test(value);\n\n/**\n * Parses a `command` envelope, failing on a wrong shape/type.\n *\n * A command carrying no valid transaction id is rejected outright — there is no\n * server-side fallback that mints one. That is deliberate: the id is the\n * idempotency key, and a caller who omits it silently loses retry safety while\n * appearing to succeed.\n */\nexport function readCommandEnvelope<TPayload = SerializedEntity>(\n body: unknown,\n): Effect.Effect<\n TransactionCommand<TPayload>,\n EntifixBuildError | InvalidEnvelope\n> {\n return Effect.gen(function* () {\n const envelope = yield* readEnvelope<TransactionCommand<TPayload>>(\n body,\n 'command',\n 'command',\n );\n const command = envelope.data;\n if (\n command == null ||\n !isTransactionId(command.transactionId) ||\n typeof command.entity !== 'string'\n ) {\n return yield* Effect.fail(\n new EntifixBuildError(\n 'command envelope carried no valid command',\n undefined,\n {\n body,\n },\n ),\n );\n }\n // `organizationId` is deliberately **not** carried over from the parsed\n // body. Spreading the caller's object here would let a request name another\n // tenant, which is precisely the scoping the stream depends on.\n const { organizationId: _ignored, ...trusted } = command;\n return trusted as TransactionCommand<TPayload>;\n });\n}\n"],"names":["EntifixBuildError","makeEnvelope","readEnvelope","Effect","makeCommandEnvelope","command","entity","UUID","isTransactionId","value","test","readCommandEnvelope","body","gen","envelope","data","transactionId","fail","undefined","organizationId","_ignored","trusted"],"mappings":";AAAA,SACEA,iBAAiB,EAGjBC,YAAY,EACZC,YAAY,QAEP,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAgDhC,6DAA6D,GAC7D,OAAO,SAASC,oBACdC,OAAqC;IAErC,OAAOJ,aAAa,WAAWI,QAAQC,MAAM,EAAED;AACjD;AAEA;;;;;;;CAOC,GACD,MAAME,OACJ;AAEF,gDAAgD,GAChD,OAAO,MAAMC,kBAAkB,CAACC,QAC9B,OAAOA,UAAU,YAAYF,KAAKG,IAAI,CAACD,OAAO;AAEhD;;;;;;;CAOC,GACD,OAAO,SAASE,oBACdC,IAAa;IAKb,OAAOT,OAAOU,GAAG,CAAC;QAChB,MAAMC,WAAW,OAAOZ,aACtBU,MACA,WACA;QAEF,MAAMP,UAAUS,SAASC,IAAI;QAC7B,IACEV,WAAW,QACX,CAACG,gBAAgBH,QAAQW,aAAa,KACtC,OAAOX,QAAQC,MAAM,KAAK,UAC1B;YACA,OAAO,OAAOH,OAAOc,IAAI,CACvB,IAAIjB,kBACF,6CACAkB,WACA;gBACEN;YACF;QAGN;QACA,wEAAwE;QACxE,4EAA4E;QAC5E,gEAAgE;QAChE,MAAM,EAAEO,gBAAgBC,QAAQ,EAAc,GAAGf,SAAZgB,2CAAYhB;;;QACjD,OAAOgB;IACT;AACF"}
@@ -1,4 +1,4 @@
1
- import type { EntifixConnError } from '@entifix/core';
1
+ import type { StoreFailure } from '@entifix/core';
2
2
  import { Context, type Effect } from 'effect';
3
3
  /**
4
4
  * A consumer's claim on one delivered message.
@@ -70,7 +70,7 @@ export interface TransactionInbox {
70
70
  * Answering `duplicate` means some earlier delivery already ran the side
71
71
  * effect to completion, because the claim and the effect commit together.
72
72
  */
73
- claim(eventId: string): Effect.Effect<InboxClaimResult, EntifixConnError>;
73
+ claim(eventId: string): Effect.Effect<InboxClaimResult, StoreFailure>;
74
74
  }
75
75
  declare const TransactionInboxTag_base: Context.ServiceClass<TransactionInboxTag, "TransactionInboxTag", TransactionInbox>;
76
76
  export declare class TransactionInboxTag extends TransactionInboxTag_base {
@@ -1 +1 @@
1
- {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../../src/contracts/inbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;CAC3E;;AAED,qBAAa,mBAAoB,SAAQ,wBAGf;CAAG"}
1
+ {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../../src/contracts/inbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;CACvE;;AAED,qBAAa,mBAAoB,SAAQ,wBAGf;CAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contracts/inbox.ts"],"sourcesContent":["import type { EntifixConnError } from '@entifix/core';\nimport { Context, type Effect } from 'effect';\n\n/**\n * A consumer's claim on one delivered message.\n *\n * The mirror of an {@link OutboxEntry}: the outbox makes a publisher's event\n * survive a broker outage, the inbox makes a consumer's side effect survive a\n * redelivery. Each end owns one unique index, and the value in it is the same\n * `event.id`.\n */\nexport interface InboxClaim {\n /**\n * Which consumer claimed it — the subscription's durable work-queue name\n * (`<slice>.<pattern>`).\n *\n * **Half of the key, and the half that is easy to leave out.** Two consumers\n * legitimately process the same event: the saga tracker's fold and the SSE\n * hub both bind `transaction.*` today. Keyed on `eventId` alone, whichever\n * claimed first would starve the other of every message — a consumer that\n * silently stops working while the broker, the queue and the handler all\n * report success.\n */\n consumer: string;\n /**\n * The message's own id, which for a transaction step is\n * `<transactionId>:<step>`.\n *\n * Never `correlationId`: one transaction emits up to three messages, so\n * keying on the correlation id would make `completed` look like a\n * redelivery of `accepted`.\n */\n eventId: string;\n /** ISO-8601, for retention — nothing reads it to make a decision. */\n claimedAt: string;\n}\n\n/**\n * Whether {@link TransactionInbox.claim} actually wrote.\n *\n * `duplicate` is not a failure — it is how a **redelivery** is recognised, the\n * same way `OutboxEnqueueResult`'s `duplicate` recognises a replayed command.\n * Delivery is at-least-once by construction (a crash between `publish` and\n * `markSent` re-sends), so a consumer seeing this should skip its side effect\n * and ack, not error.\n */\nexport type InboxClaimResult = 'claimed' | 'duplicate';\n\n/**\n * The consumer-side half of exactly-once processing over an at-least-once bus.\n *\n * A claim is only worth anything if it is written **in the same storage\n * transaction as the side effect it guards**. Claim-then-act leaves a crash\n * window in which the claim is taken and the effect never ran, so the\n * redelivery is skipped and the work is lost — strictly worse than doing it\n * twice.\n *\n * There is deliberately **no `claimWithin(session)` here**, for the reason\n * {@link TransactionOutbox} states about `enqueueWithin`: a driver session may\n * not enter a framework-free contract. A claim that must commit with its side\n * effect is a {@link UnitOfWork}'s `event` claim (ADR 0009); this port is what\n * a consumer that can claim standalone uses instead.\n *\n * It follows that **the inbox lives with the side effect, not in one central\n * place**: the claim and the write must be in the same database to be one fact.\n * The outbox is per-tenant because the entity is; the saga tracker's inbox is in\n * the `saga` database because that is where its fold writes.\n */\nexport interface TransactionInbox {\n /**\n * Claim an event for this consumer. Idempotent per `(consumer, eventId)`.\n *\n * Answering `duplicate` means some earlier delivery already ran the side\n * effect to completion, because the claim and the effect commit together.\n */\n claim(eventId: string): Effect.Effect<InboxClaimResult, EntifixConnError>;\n}\n\nexport class TransactionInboxTag extends Context.Service<\n TransactionInboxTag,\n TransactionInbox\n>()('TransactionInboxTag') {}\n"],"names":["Context","TransactionInboxTag","Service"],"mappings":"AACA,SAASA,OAAO,QAAqB,SAAS;AA6E9C,OAAO,MAAMC,4BAA4BD,QAAQE,OAAO,GAGpD;AAAwB"}
1
+ {"version":3,"sources":["../../src/contracts/inbox.ts"],"sourcesContent":["import type { StoreFailure } from '@entifix/core';\nimport { Context, type Effect } from 'effect';\n\n/**\n * A consumer's claim on one delivered message.\n *\n * The mirror of an {@link OutboxEntry}: the outbox makes a publisher's event\n * survive a broker outage, the inbox makes a consumer's side effect survive a\n * redelivery. Each end owns one unique index, and the value in it is the same\n * `event.id`.\n */\nexport interface InboxClaim {\n /**\n * Which consumer claimed it — the subscription's durable work-queue name\n * (`<slice>.<pattern>`).\n *\n * **Half of the key, and the half that is easy to leave out.** Two consumers\n * legitimately process the same event: the saga tracker's fold and the SSE\n * hub both bind `transaction.*` today. Keyed on `eventId` alone, whichever\n * claimed first would starve the other of every message — a consumer that\n * silently stops working while the broker, the queue and the handler all\n * report success.\n */\n consumer: string;\n /**\n * The message's own id, which for a transaction step is\n * `<transactionId>:<step>`.\n *\n * Never `correlationId`: one transaction emits up to three messages, so\n * keying on the correlation id would make `completed` look like a\n * redelivery of `accepted`.\n */\n eventId: string;\n /** ISO-8601, for retention — nothing reads it to make a decision. */\n claimedAt: string;\n}\n\n/**\n * Whether {@link TransactionInbox.claim} actually wrote.\n *\n * `duplicate` is not a failure — it is how a **redelivery** is recognised, the\n * same way `OutboxEnqueueResult`'s `duplicate` recognises a replayed command.\n * Delivery is at-least-once by construction (a crash between `publish` and\n * `markSent` re-sends), so a consumer seeing this should skip its side effect\n * and ack, not error.\n */\nexport type InboxClaimResult = 'claimed' | 'duplicate';\n\n/**\n * The consumer-side half of exactly-once processing over an at-least-once bus.\n *\n * A claim is only worth anything if it is written **in the same storage\n * transaction as the side effect it guards**. Claim-then-act leaves a crash\n * window in which the claim is taken and the effect never ran, so the\n * redelivery is skipped and the work is lost — strictly worse than doing it\n * twice.\n *\n * There is deliberately **no `claimWithin(session)` here**, for the reason\n * {@link TransactionOutbox} states about `enqueueWithin`: a driver session may\n * not enter a framework-free contract. A claim that must commit with its side\n * effect is a {@link UnitOfWork}'s `event` claim (ADR 0009); this port is what\n * a consumer that can claim standalone uses instead.\n *\n * It follows that **the inbox lives with the side effect, not in one central\n * place**: the claim and the write must be in the same database to be one fact.\n * The outbox is per-tenant because the entity is; the saga tracker's inbox is in\n * the `saga` database because that is where its fold writes.\n */\nexport interface TransactionInbox {\n /**\n * Claim an event for this consumer. Idempotent per `(consumer, eventId)`.\n *\n * Answering `duplicate` means some earlier delivery already ran the side\n * effect to completion, because the claim and the effect commit together.\n */\n claim(eventId: string): Effect.Effect<InboxClaimResult, StoreFailure>;\n}\n\nexport class TransactionInboxTag extends Context.Service<\n TransactionInboxTag,\n TransactionInbox\n>()('TransactionInboxTag') {}\n"],"names":["Context","TransactionInboxTag","Service"],"mappings":"AACA,SAASA,OAAO,QAAqB,SAAS;AA6E9C,OAAO,MAAMC,4BAA4BD,QAAQE,OAAO,GAGpD;AAAwB"}
@@ -1,4 +1,4 @@
1
- import type { DomainEvent, EntifixConnError } from '@entifix/core';
1
+ import type { DomainEvent, StoreFailure } from '@entifix/core';
2
2
  import { Context, type Effect } from 'effect';
3
3
  /**
4
4
  * A transaction event recorded durably *before* it reaches the broker.
@@ -96,20 +96,20 @@ export interface OutboxStats {
96
96
  */
97
97
  export interface TransactionOutbox {
98
98
  /** Record an event durably. Idempotent per `event.id`. */
99
- enqueue(event: DomainEvent): Effect.Effect<OutboxEnqueueResult, EntifixConnError>;
99
+ enqueue(event: DomainEvent): Effect.Effect<OutboxEnqueueResult, StoreFailure>;
100
100
  /**
101
101
  * Unsent, un-quarantined entries, oldest first — the relay's input.
102
102
  *
103
103
  * Excluding the quarantined ones here rather than in the relay is deliberate:
104
104
  * a skip the caller has to remember is a skip the next caller forgets.
105
105
  */
106
- pending(limit: number): Effect.Effect<readonly OutboxEntry[], EntifixConnError>;
106
+ pending(limit: number): Effect.Effect<readonly OutboxEntry[], StoreFailure>;
107
107
  /**
108
108
  * Mark an entry published. A crash between the publish and this call re-sends
109
109
  * the event on the next drain, which is why delivery is at-least-once and why
110
110
  * a consumer that must not fold twice dedupes on `event.id`.
111
111
  */
112
- markSent(entry: OutboxEntry): Effect.Effect<void, EntifixConnError>;
112
+ markSent(entry: OutboxEntry): Effect.Effect<void, StoreFailure>;
113
113
  /**
114
114
  * Record a failed publish: increments `attempts` and stores `error`.
115
115
  *
@@ -118,7 +118,7 @@ export interface TransactionOutbox {
118
118
  * knowing it. Once set, {@link pending} must stop returning the entry — that
119
119
  * is the whole mechanism by which the queue's head moves.
120
120
  */
121
- recordFailure(entry: OutboxEntry, error: string, quarantine: boolean): Effect.Effect<void, EntifixConnError>;
121
+ recordFailure(entry: OutboxEntry, error: string, quarantine: boolean): Effect.Effect<void, StoreFailure>;
122
122
  /**
123
123
  * Depth and age, for the relay to sample once per sweep.
124
124
  *
@@ -127,7 +127,7 @@ export interface TransactionOutbox {
127
127
  * full" and not "how far behind are we" — which are the same number right up
128
128
  * to the moment the second one starts to matter.
129
129
  */
130
- stats(): Effect.Effect<OutboxStats, EntifixConnError>;
130
+ stats(): Effect.Effect<OutboxStats, StoreFailure>;
131
131
  }
132
132
  declare const TransactionOutboxTag_base: Context.ServiceClass<TransactionOutboxTag, "TransactionOutboxTag", TransactionOutbox>;
133
133
  export declare class TransactionOutboxTag extends TransactionOutboxTag_base {
@@ -1 +1 @@
1
- {"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../src/contracts/outbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,WAAW,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,iBAAiB;IACh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GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,WAAW,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;IAC9E;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,WAAW,EAAE,EAAE,YAAY,CAAC,CAAC;IAC5E;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAChE;;;;;;;OAOG;IACH,aAAa,CACX,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,OAAO,GAClB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACrC;;;;;;;OAOG;IACH,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;CACnD;;AAED,qBAAa,oBAAqB,SAAQ,yBAGf;CAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contracts/outbox.ts"],"sourcesContent":["import type { DomainEvent, EntifixConnError } from '@entifix/core';\nimport { Context, type Effect } from 'effect';\n\n/**\n * A transaction event recorded durably *before* it reaches the broker.\n *\n * The point of the outbox is that a state change and the event announcing it\n * become one fact. `execute` used to write Mongo and then call `bus.publish`\n * separately: with the broker down between the two, the write happened and the\n * event never did, so the saga record sat `PENDING` until the sweep mislabelled\n * a successful transaction `STALE`. An entry written in the same transaction as\n * the state change cannot be lost that way, and a relay carries it to the bus\n * afterwards.\n */\nexport interface OutboxEntry {\n /**\n * The message's own id, denormalized out of `event` so the unique index sits\n * on a plain top-level field rather than a nested path.\n *\n * This **is** the idempotency claim: for a transaction step it is\n * `<transactionId>:<step>`, so a replayed command collides here and is\n * recognised as a retry before any lock is taken or work forked.\n */\n eventId: string;\n event: DomainEvent;\n sent: boolean;\n /**\n * Publish attempts already spent on this entry.\n *\n * The relay drains in order and stops at the first failure, which is what\n * keeps `accepted` ahead of a terminal event — and is also why an entry that\n * can *never* publish used to block everything behind it forever. Counting\n * the attempts is what turns \"retrying\" into a state with an end.\n */\n attempts: number;\n /**\n * Why the last attempt failed. Absent until one has, so its presence alone\n * says this entry has been tried.\n */\n lastError?: string;\n /**\n * Set once the attempts are spent. A quarantined entry is **skipped** rather\n * than retried, so the head of the line moves; nothing deletes it, because a\n * stuck transaction nobody is told about is the same as a lost one.\n */\n quarantined: boolean;\n /** ISO-8601, and the drain order: entries publish oldest-first. */\n createdAt: string;\n}\n\n/**\n * Whether {@link TransactionOutbox.enqueue} actually wrote.\n *\n * `duplicate` is not a failure — it is how a *retry* is recognised. The\n * transaction id is the client's idempotency key, so a repeated\n * command must return the first one's answer rather than execute twice. The\n * adapter owns the detection because the mechanism is storage-specific (a Mongo\n * `E11000` against the unique index on `eventId`), and translating it here keeps\n * driver error codes out of route handlers.\n */\nexport type OutboxEnqueueResult = 'enqueued' | 'duplicate';\n\n/**\n * An aggregate view of one outbox, for {@link TransactionOutbox.stats}.\n *\n * Counts and one timestamp — **no ids and no payloads**. That is what makes it\n * safe where a listing is not: an outbox holds event payloads, and once\n * `catalog.published` carries a whole offering an unfiltered read of one is a\n * tenant-data surface.\n */\nexport interface OutboxStats {\n /** Unsent, un-quarantined entries — the same set {@link pending} drains. */\n pending: number;\n /**\n * `createdAt` of the oldest such entry, absent when there are none.\n *\n * The age derived from this is the metric that makes a stuck relay visible.\n * An entry that can never publish no longer blocks the ones behind it —\n * quarantine gave the relay a ceiling — but a quarantine is reported only as a log line,\n * so *how far behind* the head has fallen is otherwise unanswerable.\n */\n oldestPendingAt?: string;\n /** Entries past the ceiling, which {@link pending} skips and nothing deletes. */\n quarantined: number;\n}\n\n/**\n * The durable hand-off between a transactional write and the event bus.\n *\n * Deliberately **not** a publisher: it never touches the broker. `enqueue` is\n * the only write, and the relay composes `pending`/`markSent` with an\n * {@link EventBus} — which is what keeps the engine framework-free and lets the\n * relay be tested without either a database or a broker.\n *\n * There is no `enqueueWithin(session)` here on purpose: a driver session in\n * this port would drag a datastore into a framework-free contract. A write that\n * must be atomic with its event runs in a {@link UnitOfWork} instead, whose\n * handle is opaque and whose `emit` records the event inside the same\n * transaction (ADR 0009). `enqueue` is for an event with no write to join.\n */\nexport interface TransactionOutbox {\n /** Record an event durably. Idempotent per `event.id`. */\n enqueue(\n event: DomainEvent,\n ): Effect.Effect<OutboxEnqueueResult, EntifixConnError>;\n /**\n * Unsent, un-quarantined entries, oldest first — the relay's input.\n *\n * Excluding the quarantined ones here rather than in the relay is deliberate:\n * a skip the caller has to remember is a skip the next caller forgets.\n */\n pending(\n limit: number,\n ): Effect.Effect<readonly OutboxEntry[], EntifixConnError>;\n /**\n * Mark an entry published. A crash between the publish and this call re-sends\n * the event on the next drain, which is why delivery is at-least-once and why\n * a consumer that must not fold twice dedupes on `event.id`.\n */\n markSent(entry: OutboxEntry): Effect.Effect<void, EntifixConnError>;\n /**\n * Record a failed publish: increments `attempts` and stores `error`.\n *\n * `quarantine` is the caller's decision rather than the adapter's, because\n * the ceiling is configuration the relay reads and the store has no business\n * knowing it. Once set, {@link pending} must stop returning the entry — that\n * is the whole mechanism by which the queue's head moves.\n */\n recordFailure(\n entry: OutboxEntry,\n error: string,\n quarantine: boolean,\n ): Effect.Effect<void, EntifixConnError>;\n /**\n * Depth and age, for the relay to sample once per sweep.\n *\n * An aggregate rather than a read, deliberately: `pending(limit)` truncates at\n * the relay's batch size, so counting what it returns answers \"is the batch\n * full\" and not \"how far behind are we\" — which are the same number right up\n * to the moment the second one starts to matter.\n */\n stats(): Effect.Effect<OutboxStats, EntifixConnError>;\n}\n\nexport class TransactionOutboxTag extends Context.Service<\n TransactionOutboxTag,\n TransactionOutbox\n>()('TransactionOutboxTag') {}\n"],"names":["Context","TransactionOutboxTag","Service"],"mappings":"AACA,SAASA,OAAO,QAAqB,SAAS;AA+I9C,OAAO,MAAMC,6BAA6BD,QAAQE,OAAO,GAGrD;AAAyB"}
1
+ {"version":3,"sources":["../../src/contracts/outbox.ts"],"sourcesContent":["import type { DomainEvent, StoreFailure } from '@entifix/core';\nimport { Context, type Effect } from 'effect';\n\n/**\n * A transaction event recorded durably *before* it reaches the broker.\n *\n * The point of the outbox is that a state change and the event announcing it\n * become one fact. `execute` used to write Mongo and then call `bus.publish`\n * separately: with the broker down between the two, the write happened and the\n * event never did, so the saga record sat `PENDING` until the sweep mislabelled\n * a successful transaction `STALE`. An entry written in the same transaction as\n * the state change cannot be lost that way, and a relay carries it to the bus\n * afterwards.\n */\nexport interface OutboxEntry {\n /**\n * The message's own id, denormalized out of `event` so the unique index sits\n * on a plain top-level field rather than a nested path.\n *\n * This **is** the idempotency claim: for a transaction step it is\n * `<transactionId>:<step>`, so a replayed command collides here and is\n * recognised as a retry before any lock is taken or work forked.\n */\n eventId: string;\n event: DomainEvent;\n sent: boolean;\n /**\n * Publish attempts already spent on this entry.\n *\n * The relay drains in order and stops at the first failure, which is what\n * keeps `accepted` ahead of a terminal event — and is also why an entry that\n * can *never* publish used to block everything behind it forever. Counting\n * the attempts is what turns \"retrying\" into a state with an end.\n */\n attempts: number;\n /**\n * Why the last attempt failed. Absent until one has, so its presence alone\n * says this entry has been tried.\n */\n lastError?: string;\n /**\n * Set once the attempts are spent. A quarantined entry is **skipped** rather\n * than retried, so the head of the line moves; nothing deletes it, because a\n * stuck transaction nobody is told about is the same as a lost one.\n */\n quarantined: boolean;\n /** ISO-8601, and the drain order: entries publish oldest-first. */\n createdAt: string;\n}\n\n/**\n * Whether {@link TransactionOutbox.enqueue} actually wrote.\n *\n * `duplicate` is not a failure — it is how a *retry* is recognised. The\n * transaction id is the client's idempotency key, so a repeated\n * command must return the first one's answer rather than execute twice. The\n * adapter owns the detection because the mechanism is storage-specific (a Mongo\n * `E11000` against the unique index on `eventId`), and translating it here keeps\n * driver error codes out of route handlers.\n */\nexport type OutboxEnqueueResult = 'enqueued' | 'duplicate';\n\n/**\n * An aggregate view of one outbox, for {@link TransactionOutbox.stats}.\n *\n * Counts and one timestamp — **no ids and no payloads**. That is what makes it\n * safe where a listing is not: an outbox holds event payloads, and once\n * `catalog.published` carries a whole offering an unfiltered read of one is a\n * tenant-data surface.\n */\nexport interface OutboxStats {\n /** Unsent, un-quarantined entries — the same set {@link pending} drains. */\n pending: number;\n /**\n * `createdAt` of the oldest such entry, absent when there are none.\n *\n * The age derived from this is the metric that makes a stuck relay visible.\n * An entry that can never publish no longer blocks the ones behind it —\n * quarantine gave the relay a ceiling — but a quarantine is reported only as a log line,\n * so *how far behind* the head has fallen is otherwise unanswerable.\n */\n oldestPendingAt?: string;\n /** Entries past the ceiling, which {@link pending} skips and nothing deletes. */\n quarantined: number;\n}\n\n/**\n * The durable hand-off between a transactional write and the event bus.\n *\n * Deliberately **not** a publisher: it never touches the broker. `enqueue` is\n * the only write, and the relay composes `pending`/`markSent` with an\n * {@link EventBus} — which is what keeps the engine framework-free and lets the\n * relay be tested without either a database or a broker.\n *\n * There is no `enqueueWithin(session)` here on purpose: a driver session in\n * this port would drag a datastore into a framework-free contract. A write that\n * must be atomic with its event runs in a {@link UnitOfWork} instead, whose\n * handle is opaque and whose `emit` records the event inside the same\n * transaction (ADR 0009). `enqueue` is for an event with no write to join.\n */\nexport interface TransactionOutbox {\n /** Record an event durably. Idempotent per `event.id`. */\n enqueue(event: DomainEvent): Effect.Effect<OutboxEnqueueResult, StoreFailure>;\n /**\n * Unsent, un-quarantined entries, oldest first — the relay's input.\n *\n * Excluding the quarantined ones here rather than in the relay is deliberate:\n * a skip the caller has to remember is a skip the next caller forgets.\n */\n pending(limit: number): Effect.Effect<readonly OutboxEntry[], StoreFailure>;\n /**\n * Mark an entry published. A crash between the publish and this call re-sends\n * the event on the next drain, which is why delivery is at-least-once and why\n * a consumer that must not fold twice dedupes on `event.id`.\n */\n markSent(entry: OutboxEntry): Effect.Effect<void, StoreFailure>;\n /**\n * Record a failed publish: increments `attempts` and stores `error`.\n *\n * `quarantine` is the caller's decision rather than the adapter's, because\n * the ceiling is configuration the relay reads and the store has no business\n * knowing it. Once set, {@link pending} must stop returning the entry — that\n * is the whole mechanism by which the queue's head moves.\n */\n recordFailure(\n entry: OutboxEntry,\n error: string,\n quarantine: boolean,\n ): Effect.Effect<void, StoreFailure>;\n /**\n * Depth and age, for the relay to sample once per sweep.\n *\n * An aggregate rather than a read, deliberately: `pending(limit)` truncates at\n * the relay's batch size, so counting what it returns answers \"is the batch\n * full\" and not \"how far behind are we\" — which are the same number right up\n * to the moment the second one starts to matter.\n */\n stats(): Effect.Effect<OutboxStats, StoreFailure>;\n}\n\nexport class TransactionOutboxTag extends Context.Service<\n TransactionOutboxTag,\n TransactionOutbox\n>()('TransactionOutboxTag') {}\n"],"names":["Context","TransactionOutboxTag","Service"],"mappings":"AACA,SAASA,OAAO,QAAqB,SAAS;AA2I9C,OAAO,MAAMC,6BAA6BD,QAAQE,OAAO,GAGrD;AAAyB"}
@@ -1,4 +1,4 @@
1
- import { type EntifixConnError, type EntifixError, type EntityId } from '@entifix/core';
1
+ import { type EntifixConnError, type EntityId, type InvalidEnvelope, type TransitionalFailure } from '@entifix/core';
2
2
  import { Context, Effect } from 'effect';
3
3
  import type { TransactionEvent, TransactionState } from './event.js';
4
4
  /**
@@ -75,7 +75,7 @@ export interface TransactionAccepted {
75
75
  * Read for its **shape**, not its contents: it asserts the service really
76
76
  * accepted a transaction rather than answering something else with a `2xx`.
77
77
  */
78
- export declare function readTransactionAcceptedEnvelope(body: unknown): Effect.Effect<TransactionAccepted, EntifixError>;
78
+ export declare function readTransactionAcceptedEnvelope(body: unknown): Effect.Effect<TransactionAccepted, InvalidEnvelope>;
79
79
  /**
80
80
  * Parses the tracker's by-id response, which frames a {@link TransactionRecord}.
81
81
  *
@@ -85,7 +85,7 @@ export declare function readTransactionAcceptedEnvelope(body: unknown): Effect.E
85
85
  * event has no `step`, no `at`, and a `state` the caller is about to branch on.
86
86
  * That is the reason the four transaction-shaped discriminants are four.
87
87
  */
88
- export declare function readTransactionRecordEnvelope(body: unknown): Effect.Effect<TransactionRecord, EntifixError>;
88
+ export declare function readTransactionRecordEnvelope(body: unknown): Effect.Effect<TransactionRecord, InvalidEnvelope>;
89
89
  /**
90
90
  * Reads one transaction's record, for a browser reconciling a write it started.
91
91
  *
@@ -98,7 +98,7 @@ export declare function readTransactionRecordEnvelope(body: unknown): Effect.Eff
98
98
  * `STALE` are terminal.
99
99
  */
100
100
  export interface TransactionStatusReader {
101
- read(transactionId: string): Effect.Effect<TransactionRecord | undefined, EntifixError>;
101
+ read(transactionId: string): Effect.Effect<TransactionRecord | undefined, TransitionalFailure>;
102
102
  }
103
103
  declare const TransactionStatusReaderTag_base: Context.ServiceClass<TransactionStatusReaderTag, "TransactionStatusReaderTag", TransactionStatusReader>;
104
104
  export declare class TransactionStatusReaderTag extends TransactionStatusReaderTag_base {
@@ -1 +1 @@
1
- {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/contracts/record.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,QAAQ,EAEd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,M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gBAAgB,CAAC,CAAC;IAMlE,8EAA8E;IAC9E,SAAS,CACP,WAAW,EAAE,MAAM,GAClB,MAAM,CAAC,MAAM,CAAC,SAAS,iBAAiB,EAAE,EAAE,gBAAgB,CAAC,CAAC;IACjE,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACxE;;;;;;;;;;;;;OAaG;IACH,YAAY,IAAI,MAAM,CAAC,MAAM,CAC3B,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,EAChC,gBAAgB,CACjB,CAAC;CACH;;AAED,qBAAa,mBAAoB,SAAQ,wBAGf;CAAG;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC,CASrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC,CASnD;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,CACF,aAAa,EAAE,MAAM,GACpB,MAAM,CAAC,MAAM,CAAC,iBAAiB,GAAG,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACtE;;AAED,qBAAa,0BAA2B,SAAQ,+BAGf;CAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contracts/record.ts"],"sourcesContent":["import {\n type EntifixConnError,\n type EntifixError,\n type EntityId,\n readEnvelope,\n} from '@entifix/core';\nimport { Context, Effect } from 'effect';\n\nimport type { TransactionEvent, TransactionState } from './event.js';\n\n/**\n * The the saga tracker's persisted view of a transaction, folded from the\n * events it observes. It is the source of truth a client polls.\n */\nexport interface TransactionRecord {\n transactionId: string;\n entity: string;\n state: TransactionState;\n code?: string;\n entityId?: EntityId;\n error?: string;\n createdAt: string;\n updatedAt: string;\n /**\n * Whose organization this transaction happened in, folded from the event.\n *\n * The `saga` store is control-plane and single-partition — it holds every\n * organization's records by design — so isolation on the read routes has to be\n * this filter. A record written before the member existed carries none and is\n * therefore readable by nobody, which is the direction to fail.\n */\n organizationId?: string;\n}\n\n/**\n * Port the manager tracks transactions through. Implemented over Mongo in the\n * service; framework-free here so the engine/manager stay environment-agnostic.\n */\nexport interface TransactionStore {\n /** Folds an event into the record, creating it on first sight. */\n upsertFromEvent(\n event: TransactionEvent,\n ): Effect.Effect<TransactionRecord, EntifixConnError>;\n get(\n transactionId: string,\n ): Effect.Effect<TransactionRecord | undefined, EntifixConnError>;\n // There is deliberately no `list`. The `saga` store is control-plane and\n // single-partition, so an unfiltered index is every organization's\n // transactions — which is why there is no `GET /api/transaction` list.\n // Anything that needs a set of records asks for one narrow enough to scope,\n // the way `findStale` does.\n /** Non-terminal records not updated within `olderThanMs` — recovery input. */\n findStale(\n olderThanMs: number,\n ): Effect.Effect<readonly TransactionRecord[], EntifixConnError>;\n markStale(transactionId: string): Effect.Effect<void, EntifixConnError>;\n /**\n * How many records sit in each state — the recovery sweep samples it.\n *\n * ⚠️ **This is a count, and is not the `list` above.** It returns no record,\n * no id and no organization, so it does not reopen the list surface removed\n * `GET /api/transaction` for: an unfiltered *listing* of this store is every\n * organization's transactions, while a total of how many are `STALE` is a\n * fleet health number that names nobody. The distinction is the whole reason\n * one is here and the other is refused.\n *\n * It exists so `STALE` is something a dashboard shows rather than something a\n * poll discovers — which is what the recovery sweep, whose only action is to\n * apply that label, otherwise leaves entirely unobservable.\n */\n countByState(): Effect.Effect<\n Record<TransactionState, number>,\n EntifixConnError\n >;\n}\n\nexport class TransactionStoreTag extends Context.Service<\n TransactionStoreTag,\n TransactionStore\n>()('TransactionStoreTag') {}\n\n/**\n * What a service answers a `202` with: the id to poll, and the state it starts\n * in.\n *\n * ⚠️ **Not a {@link TransactionRecord}, which is why it has its own\n * discriminant.** Nothing has been folded yet — there is no `createdAt`, no\n * entity id, and no code, because the write has not run. Framing it as a record\n * meant the browser's accept-shape assertion was checking a name that the\n * by-id route and the bus payload also answered to, so it asserted nothing it\n * claimed to.\n */\nexport interface TransactionAccepted {\n transactionId: string;\n state: TransactionState;\n}\n\n/**\n * Parses a `202` accept body, for a browser about to start polling.\n *\n * Read for its **shape**, not its contents: it asserts the service really\n * accepted a transaction rather than answering something else with a `2xx`.\n */\nexport function readTransactionAcceptedEnvelope(\n body: unknown,\n): Effect.Effect<TransactionAccepted, EntifixError> {\n return Effect.map(\n readEnvelope<TransactionAccepted>(\n body,\n 'transactionAccepted',\n 'transactionAccepted',\n ),\n envelope => envelope.data,\n );\n}\n\n/**\n * Parses the tracker's by-id response, which frames a {@link TransactionRecord}.\n *\n * ⚠️ **`readEnvelope` validates the discriminant and then *casts* the payload**\n * — it checks no members. So a discriminant shared by two shapes hands back\n * whichever one the caller asked for, typed and wrong: a record read as an\n * event has no `step`, no `at`, and a `state` the caller is about to branch on.\n * That is the reason the four transaction-shaped discriminants are four.\n */\nexport function readTransactionRecordEnvelope(\n body: unknown,\n): Effect.Effect<TransactionRecord, EntifixError> {\n return Effect.map(\n readEnvelope<TransactionRecord>(\n body,\n 'transactionRecord',\n 'transactionRecord',\n ),\n envelope => envelope.data,\n );\n}\n\n/**\n * Reads one transaction's record, for a browser reconciling a write it started.\n *\n * ⚠️ **`undefined` means _not tracked yet_, not _failed_.** `accepted` reaches\n * the tracker over the bus, so with the broker down the entity write commits —\n * the outbox is in the same Mongo transaction — while no event is ever\n * published and this answers `404`. That is a write in perfect health, and a\n * caller that rolls back on it un-renders a record that is about to appear, at\n * exactly the moment nobody can tell a UI bug from an outage. Only `FAILED` and\n * `STALE` are terminal.\n */\nexport interface TransactionStatusReader {\n read(\n transactionId: string,\n ): Effect.Effect<TransactionRecord | undefined, EntifixError>;\n}\n\nexport class TransactionStatusReaderTag extends Context.Service<\n TransactionStatusReaderTag,\n TransactionStatusReader\n>()('TransactionStatusReaderTag') {}\n"],"names":["readEnvelope","Context","Effect","TransactionStoreTag","Service","readTransactionAcceptedEnvelope","body","map","envelope","data","readTransactionRecordEnvelope","TransactionStatusReaderTag"],"mappings":"AAAA,SAIEA,YAAY,QACP,gBAAgB;AACvB,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AAsEzC,OAAO,MAAMC,4BAA4BF,QAAQG,OAAO,GAGpD;AAAwB;AAkB5B;;;;;CAKC,GACD,OAAO,SAASC,gCACdC,IAAa;IAEb,OAAOJ,OAAOK,GAAG,CACfP,aACEM,MACA,uBACA,wBAEFE,CAAAA,WAAYA,SAASC,IAAI;AAE7B;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASC,8BACdJ,IAAa;IAEb,OAAOJ,OAAOK,GAAG,CACfP,aACEM,MACA,qBACA,sBAEFE,CAAAA,WAAYA,SAASC,IAAI;AAE7B;AAmBA,OAAO,MAAME,mCAAmCV,QAAQG,OAAO,GAG3D;AAA+B"}
1
+ {"version":3,"sources":["../../src/contracts/record.ts"],"sourcesContent":["import {\n type EntifixConnError,\n type EntityId,\n type InvalidEnvelope,\n readEnvelope,\n type TransitionalFailure,\n} from '@entifix/core';\nimport { Context, Effect } from 'effect';\n\nimport type { TransactionEvent, TransactionState } from './event.js';\n\n/**\n * The the saga tracker's persisted view of a transaction, folded from the\n * events it observes. It is the source of truth a client polls.\n */\nexport interface TransactionRecord {\n transactionId: string;\n entity: string;\n state: TransactionState;\n code?: string;\n entityId?: EntityId;\n error?: string;\n createdAt: string;\n updatedAt: string;\n /**\n * Whose organization this transaction happened in, folded from the event.\n *\n * The `saga` store is control-plane and single-partition — it holds every\n * organization's records by design — so isolation on the read routes has to be\n * this filter. A record written before the member existed carries none and is\n * therefore readable by nobody, which is the direction to fail.\n */\n organizationId?: string;\n}\n\n/**\n * Port the manager tracks transactions through. Implemented over Mongo in the\n * service; framework-free here so the engine/manager stay environment-agnostic.\n */\nexport interface TransactionStore {\n /** Folds an event into the record, creating it on first sight. */\n upsertFromEvent(\n event: TransactionEvent,\n ): Effect.Effect<TransactionRecord, EntifixConnError>;\n get(\n transactionId: string,\n ): Effect.Effect<TransactionRecord | undefined, EntifixConnError>;\n // There is deliberately no `list`. The `saga` store is control-plane and\n // single-partition, so an unfiltered index is every organization's\n // transactions — which is why there is no `GET /api/transaction` list.\n // Anything that needs a set of records asks for one narrow enough to scope,\n // the way `findStale` does.\n /** Non-terminal records not updated within `olderThanMs` — recovery input. */\n findStale(\n olderThanMs: number,\n ): Effect.Effect<readonly TransactionRecord[], EntifixConnError>;\n markStale(transactionId: string): Effect.Effect<void, EntifixConnError>;\n /**\n * How many records sit in each state — the recovery sweep samples it.\n *\n * ⚠️ **This is a count, and is not the `list` above.** It returns no record,\n * no id and no organization, so it does not reopen the list surface removed\n * `GET /api/transaction` for: an unfiltered *listing* of this store is every\n * organization's transactions, while a total of how many are `STALE` is a\n * fleet health number that names nobody. The distinction is the whole reason\n * one is here and the other is refused.\n *\n * It exists so `STALE` is something a dashboard shows rather than something a\n * poll discovers — which is what the recovery sweep, whose only action is to\n * apply that label, otherwise leaves entirely unobservable.\n */\n countByState(): Effect.Effect<\n Record<TransactionState, number>,\n EntifixConnError\n >;\n}\n\nexport class TransactionStoreTag extends Context.Service<\n TransactionStoreTag,\n TransactionStore\n>()('TransactionStoreTag') {}\n\n/**\n * What a service answers a `202` with: the id to poll, and the state it starts\n * in.\n *\n * ⚠️ **Not a {@link TransactionRecord}, which is why it has its own\n * discriminant.** Nothing has been folded yet — there is no `createdAt`, no\n * entity id, and no code, because the write has not run. Framing it as a record\n * meant the browser's accept-shape assertion was checking a name that the\n * by-id route and the bus payload also answered to, so it asserted nothing it\n * claimed to.\n */\nexport interface TransactionAccepted {\n transactionId: string;\n state: TransactionState;\n}\n\n/**\n * Parses a `202` accept body, for a browser about to start polling.\n *\n * Read for its **shape**, not its contents: it asserts the service really\n * accepted a transaction rather than answering something else with a `2xx`.\n */\nexport function readTransactionAcceptedEnvelope(\n body: unknown,\n): Effect.Effect<TransactionAccepted, InvalidEnvelope> {\n return Effect.map(\n readEnvelope<TransactionAccepted>(\n body,\n 'transactionAccepted',\n 'transactionAccepted',\n ),\n envelope => envelope.data,\n );\n}\n\n/**\n * Parses the tracker's by-id response, which frames a {@link TransactionRecord}.\n *\n * ⚠️ **`readEnvelope` validates the discriminant and then *casts* the payload**\n * — it checks no members. So a discriminant shared by two shapes hands back\n * whichever one the caller asked for, typed and wrong: a record read as an\n * event has no `step`, no `at`, and a `state` the caller is about to branch on.\n * That is the reason the four transaction-shaped discriminants are four.\n */\nexport function readTransactionRecordEnvelope(\n body: unknown,\n): Effect.Effect<TransactionRecord, InvalidEnvelope> {\n return Effect.map(\n readEnvelope<TransactionRecord>(\n body,\n 'transactionRecord',\n 'transactionRecord',\n ),\n envelope => envelope.data,\n );\n}\n\n/**\n * Reads one transaction's record, for a browser reconciling a write it started.\n *\n * ⚠️ **`undefined` means _not tracked yet_, not _failed_.** `accepted` reaches\n * the tracker over the bus, so with the broker down the entity write commits —\n * the outbox is in the same Mongo transaction — while no event is ever\n * published and this answers `404`. That is a write in perfect health, and a\n * caller that rolls back on it un-renders a record that is about to appear, at\n * exactly the moment nobody can tell a UI bug from an outage. Only `FAILED` and\n * `STALE` are terminal.\n */\nexport interface TransactionStatusReader {\n read(\n transactionId: string,\n ): Effect.Effect<TransactionRecord | undefined, TransitionalFailure>;\n}\n\nexport class TransactionStatusReaderTag extends Context.Service<\n TransactionStatusReaderTag,\n TransactionStatusReader\n>()('TransactionStatusReaderTag') {}\n"],"names":["readEnvelope","Context","Effect","TransactionStoreTag","Service","readTransactionAcceptedEnvelope","body","map","envelope","data","readTransactionRecordEnvelope","TransactionStatusReaderTag"],"mappings":"AAAA,SAIEA,YAAY,QAEP,gBAAgB;AACvB,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AAsEzC,OAAO,MAAMC,4BAA4BF,QAAQG,OAAO,GAGpD;AAAwB;AAkB5B;;;;;CAKC,GACD,OAAO,SAASC,gCACdC,IAAa;IAEb,OAAOJ,OAAOK,GAAG,CACfP,aACEM,MACA,uBACA,wBAEFE,CAAAA,WAAYA,SAASC,IAAI;AAE7B;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASC,8BACdJ,IAAa;IAEb,OAAOJ,OAAOK,GAAG,CACfP,aACEM,MACA,qBACA,sBAEFE,CAAAA,WAAYA,SAASC,IAAI;AAE7B;AAmBA,OAAO,MAAME,mCAAmCV,QAAQG,OAAO,GAG3D;AAA+B"}
@@ -1,4 +1,4 @@
1
- import type { DomainEvent, EntifixConnError } from '@entifix/core';
1
+ import type { DomainEvent, StoreFault } from '@entifix/core';
2
2
  import type { Effect, Option } from 'effect';
3
3
  /**
4
4
  * What a unit of work deduplicates on, if anything. At most one per unit.
@@ -42,7 +42,7 @@ export interface Unit<H> {
42
42
  }
43
43
  /**
44
44
  * How a unit ended. A failure of the store itself is not one of these — it is
45
- * the `EntifixConnError` in the error channel of {@link UnitOfWork.run}.
45
+ * the `StoreFault` in the error channel of {@link UnitOfWork.run}.
46
46
  *
47
47
  * - `committed` — every write, every event and the claim are durable.
48
48
  * - `duplicate` — the claim was already taken, so the body's work had already
@@ -94,19 +94,19 @@ export interface UnitRunOptions<A, R = never> {
94
94
  * store. Do those before the unit and pass the results in.
95
95
  *
96
96
  * The body's typed failure is the abort: `run` rolls back and answers
97
- * `aborted` with it. An `EntifixConnError` is the exception — the store failing
97
+ * `aborted` with it. A `StoreFault` is the exception — the store failing
98
98
  * is not a business decision, so it rolls back and surfaces in `run`'s own
99
99
  * error channel instead.
100
100
  *
101
101
  * Reads through the handle see the unit's own uncommitted writes.
102
102
  */
103
103
  export interface UnitOfWork<H> {
104
- run<A, E, R>(body: (unit: Unit<H>) => Effect.Effect<A, E, R>, options?: UnitRunOptions<A, R>): Effect.Effect<UnitOutcome<A, Exclude<E, EntifixConnError>>, EntifixConnError, R>;
104
+ run<A, E, R>(body: (unit: Unit<H>) => Effect.Effect<A, E, R>, options?: UnitRunOptions<A, R>): Effect.Effect<UnitOutcome<A, Exclude<E, StoreFault>>, StoreFault, R>;
105
105
  /**
106
106
  * What the run that took this `command` claim asked to be remembered, or
107
107
  * `none` if no run has taken it — for a caller that has to answer a duplicate
108
108
  * outside a unit.
109
109
  */
110
- replay(commandId: string): Effect.Effect<Option.Option<unknown>, EntifixConnError>;
110
+ replay(commandId: string): Effect.Effect<Option.Option<unknown>, StoreFault>;
111
111
  }
112
112
  //# sourceMappingURL=unit-of-work.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unit-of-work.d.ts","sourceRoot":"","sources":["../../src/contracts/unit-of-work.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,GACjB;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,Q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C,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IACxC;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACT,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC/C,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7B,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IACxE;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;CAC9E"}
@@ -10,7 +10,7 @@
10
10
  * store. Do those before the unit and pass the results in.
11
11
  *
12
12
  * The body's typed failure is the abort: `run` rolls back and answers
13
- * `aborted` with it. An `EntifixConnError` is the exception — the store failing
13
+ * `aborted` with it. A `StoreFault` is the exception — the store failing
14
14
  * is not a business decision, so it rolls back and surfaces in `run`'s own
15
15
  * error channel instead.
16
16
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contracts/unit-of-work.ts"],"sourcesContent":["import type { DomainEvent, EntifixConnError } from '@entifix/core';\nimport type { Effect, Option } from 'effect';\n\n/**\n * What a unit of work deduplicates on, if anything. At most one per unit.\n *\n * Two kinds, because there are two directions a duplicate arrives from:\n *\n * - `event` — a consumer folding a bus message. Keyed on `(consumer, eventId)`,\n * the inbox's compound key: two consumers legitimately process one event,\n * and a key on `eventId` alone would let whichever claimed first starve the\n * other.\n * - `command` — a participant answering a dispatched command. Keyed on the\n * command id alone, and it **remembers an answer**: a redelivered command must\n * be told what the first delivery decided, not that it was a duplicate.\n */\nexport type UnitClaim =\n | {\n readonly kind: 'event';\n readonly consumer: string;\n readonly eventId: string;\n }\n | { readonly kind: 'command'; readonly commandId: string };\n\n/**\n * The view a unit's body gets of the transaction it runs in.\n *\n * `handle` is the store's own — a driver session and the database it is bound\n * to, for Mongo. It is opaque to this package on purpose: the contract states\n * what commits together, and only the adapter that implements it (and the\n * persistence code written against that adapter) ever looks inside.\n */\nexport interface Unit<H> {\n readonly handle: H;\n /**\n * Record an event to publish **if and only if** the unit commits.\n *\n * Recorded, not published. The adapter writes it to the outbox inside the\n * same transaction, so the state change and its announcement are one fact,\n * and the relay carries it to the bus afterwards.\n */\n emit(event: DomainEvent): void;\n}\n\n/**\n * How a unit ended. A failure of the store itself is not one of these — it is\n * the `EntifixConnError` in the error channel of {@link UnitOfWork.run}.\n *\n * - `committed` — every write, every event and the claim are durable.\n * - `duplicate` — the claim was already taken, so the body's work had already\n * committed once. Nothing was written. `replay` is what the first run asked\n * to be remembered (`command` claims only).\n * - `aborted` — the body failed with a business reason. Nothing was written.\n * This is how a refusal leaves a unit: as a typed value, never as a thrown\n * sentinel caught three frames up.\n */\nexport type UnitOutcome<A, E> =\n | { readonly _tag: 'committed'; readonly value: A }\n | { readonly _tag: 'duplicate'; readonly replay: Option.Option<unknown> }\n | { readonly _tag: 'aborted'; readonly reason: E };\n\nexport interface UnitRunOptions<A, R = never> {\n readonly claim?: UnitClaim;\n /**\n * What a later duplicate of this `command` claim is answered with, derived\n * from the committed value. Stored with the claim, in the same transaction.\n *\n * It must be JSON: it is written to the store and read back by a different\n * process, possibly after a restart.\n */\n readonly replay?: (value: A) => unknown;\n /**\n * Runs once the unit has committed, and never otherwise — the place to drain\n * the outbox inline so the event leaves now rather than at the next sweep.\n *\n * Its failure does not undo the commit, and is not reported as the unit's: a\n * drain that fails here is retried by the sweep, which is exactly the\n * fallback the outbox exists to provide.\n */\n readonly afterCommit?: Effect.Effect<void, unknown, R>;\n}\n\n/**\n * One storage transaction that the outbox, the inbox and a command claim all\n * join: domain writes, zero or more events, and at most one claim, which commit\n * or vanish together.\n *\n * The body may run **more than once**. A store that retries a transient\n * conflict re-runs it from the start, so the body must be a pure function of\n * its inputs and the handle — no clock read that has to match a value already\n * returned, no call to another service, no counter drawn from outside the\n * store. Do those before the unit and pass the results in.\n *\n * The body's typed failure is the abort: `run` rolls back and answers\n * `aborted` with it. An `EntifixConnError` is the exception — the store failing\n * is not a business decision, so it rolls back and surfaces in `run`'s own\n * error channel instead.\n *\n * Reads through the handle see the unit's own uncommitted writes.\n */\nexport interface UnitOfWork<H> {\n run<A, E, R>(\n body: (unit: Unit<H>) => Effect.Effect<A, E, R>,\n options?: UnitRunOptions<A, R>,\n ): Effect.Effect<\n UnitOutcome<A, Exclude<E, EntifixConnError>>,\n EntifixConnError,\n R\n >;\n /**\n * What the run that took this `command` claim asked to be remembered, or\n * `none` if no run has taken it — for a caller that has to answer a duplicate\n * outside a unit.\n */\n replay(\n commandId: string,\n ): Effect.Effect<Option.Option<unknown>, EntifixConnError>;\n}\n"],"names":[],"mappings":"AAkFA;;;;;;;;;;;;;;;;;CAiBC,GACD,WAiBC"}
1
+ {"version":3,"sources":["../../src/contracts/unit-of-work.ts"],"sourcesContent":["import type { DomainEvent, StoreFault } from '@entifix/core';\nimport type { Effect, Option } from 'effect';\n\n/**\n * What a unit of work deduplicates on, if anything. At most one per unit.\n *\n * Two kinds, because there are two directions a duplicate arrives from:\n *\n * - `event` — a consumer folding a bus message. Keyed on `(consumer, eventId)`,\n * the inbox's compound key: two consumers legitimately process one event,\n * and a key on `eventId` alone would let whichever claimed first starve the\n * other.\n * - `command` — a participant answering a dispatched command. Keyed on the\n * command id alone, and it **remembers an answer**: a redelivered command must\n * be told what the first delivery decided, not that it was a duplicate.\n */\nexport type UnitClaim =\n | {\n readonly kind: 'event';\n readonly consumer: string;\n readonly eventId: string;\n }\n | { readonly kind: 'command'; readonly commandId: string };\n\n/**\n * The view a unit's body gets of the transaction it runs in.\n *\n * `handle` is the store's own — a driver session and the database it is bound\n * to, for Mongo. It is opaque to this package on purpose: the contract states\n * what commits together, and only the adapter that implements it (and the\n * persistence code written against that adapter) ever looks inside.\n */\nexport interface Unit<H> {\n readonly handle: H;\n /**\n * Record an event to publish **if and only if** the unit commits.\n *\n * Recorded, not published. The adapter writes it to the outbox inside the\n * same transaction, so the state change and its announcement are one fact,\n * and the relay carries it to the bus afterwards.\n */\n emit(event: DomainEvent): void;\n}\n\n/**\n * How a unit ended. A failure of the store itself is not one of these — it is\n * the `StoreFault` in the error channel of {@link UnitOfWork.run}.\n *\n * - `committed` — every write, every event and the claim are durable.\n * - `duplicate` — the claim was already taken, so the body's work had already\n * committed once. Nothing was written. `replay` is what the first run asked\n * to be remembered (`command` claims only).\n * - `aborted` — the body failed with a business reason. Nothing was written.\n * This is how a refusal leaves a unit: as a typed value, never as a thrown\n * sentinel caught three frames up.\n */\nexport type UnitOutcome<A, E> =\n | { readonly _tag: 'committed'; readonly value: A }\n | { readonly _tag: 'duplicate'; readonly replay: Option.Option<unknown> }\n | { readonly _tag: 'aborted'; readonly reason: E };\n\nexport interface UnitRunOptions<A, R = never> {\n readonly claim?: UnitClaim;\n /**\n * What a later duplicate of this `command` claim is answered with, derived\n * from the committed value. Stored with the claim, in the same transaction.\n *\n * It must be JSON: it is written to the store and read back by a different\n * process, possibly after a restart.\n */\n readonly replay?: (value: A) => unknown;\n /**\n * Runs once the unit has committed, and never otherwise — the place to drain\n * the outbox inline so the event leaves now rather than at the next sweep.\n *\n * Its failure does not undo the commit, and is not reported as the unit's: a\n * drain that fails here is retried by the sweep, which is exactly the\n * fallback the outbox exists to provide.\n */\n readonly afterCommit?: Effect.Effect<void, unknown, R>;\n}\n\n/**\n * One storage transaction that the outbox, the inbox and a command claim all\n * join: domain writes, zero or more events, and at most one claim, which commit\n * or vanish together.\n *\n * The body may run **more than once**. A store that retries a transient\n * conflict re-runs it from the start, so the body must be a pure function of\n * its inputs and the handle — no clock read that has to match a value already\n * returned, no call to another service, no counter drawn from outside the\n * store. Do those before the unit and pass the results in.\n *\n * The body's typed failure is the abort: `run` rolls back and answers\n * `aborted` with it. A `StoreFault` is the exception — the store failing\n * is not a business decision, so it rolls back and surfaces in `run`'s own\n * error channel instead.\n *\n * Reads through the handle see the unit's own uncommitted writes.\n */\nexport interface UnitOfWork<H> {\n run<A, E, R>(\n body: (unit: Unit<H>) => Effect.Effect<A, E, R>,\n options?: UnitRunOptions<A, R>,\n ): Effect.Effect<UnitOutcome<A, Exclude<E, StoreFault>>, StoreFault, R>;\n /**\n * What the run that took this `command` claim asked to be remembered, or\n * `none` if no run has taken it — for a caller that has to answer a duplicate\n * outside a unit.\n */\n replay(commandId: string): Effect.Effect<Option.Option<unknown>, StoreFault>;\n}\n"],"names":[],"mappings":"AAkFA;;;;;;;;;;;;;;;;;CAiBC,GACD,WAWC"}
@@ -0,0 +1,33 @@
1
+ import { Layer } from 'effect';
2
+ import { type RetryBudget, RetryBudgetTag, type RetryDials } from '../ports/retry-budget.js';
3
+ /** Requests the window must hold before throttling reads anything into it. */
4
+ export declare const MIN_THROTTLING_SAMPLE = 10;
5
+ export interface InMemoryRetryBudgetOptions {
6
+ readonly dials?: Partial<RetryDials>;
7
+ /** The clock, in epoch milliseconds. Injected so a spec can move time. */
8
+ readonly now?: () => number;
9
+ /** A uniform draw in [0, 1). Injected so a spec can pin throttling. */
10
+ readonly random?: () => number;
11
+ }
12
+ /**
13
+ * A token-bucket retry budget held in this process
14
+ * ([ADR 0014](../../../../../docs/adr/0014-retry-once-at-the-layer-above-under-a-budget.md)).
15
+ *
16
+ * Each first attempt adds `budgetRatio` of a token, so retries can add at most
17
+ * that fraction to the dependency's load; the floor refills
18
+ * `budgetFloorPerSecond` tokens a second regardless, so a quiet dependency can
19
+ * still retry. Tokens are capped at what the floor plus ten seconds of ratio
20
+ * would earn, so a long calm does not bank a stampede.
21
+ *
22
+ * Adaptive throttling is the SRE book's client-side rule: past `K` requests
23
+ * per accept over the window, a first attempt is rejected locally with
24
+ * probability `(requests − K·accepts) / (requests + 1)` — once the window holds
25
+ * {@link MIN_THROTTLING_SAMPLE} requests, so a cold start is not throttled.
26
+ *
27
+ * One process, one budget: replicas do not share it, which is the point — a
28
+ * replica's retries are its own load on the dependency.
29
+ */
30
+ export declare const makeInMemoryRetryBudget: (options?: InMemoryRetryBudgetOptions) => RetryBudget;
31
+ /** The in-memory budget as a layer, for a host's composition root. */
32
+ export declare const InMemoryRetryBudgetLayer: (options?: InMemoryRetryBudgetOptions) => Layer.Layer<RetryBudgetTag, never, never>;
33
+ //# sourceMappingURL=in-memory-retry-budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory-retry-budget.d.ts","sourceRoot":"","sources":["../../src/engine/in-memory-retry-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAEL,KAAK,WAAW,EAChB,cAAc,EACd,KAAK,UAAU,EAEhB,MAAM,0BAA0B,CAAC;AAYlC,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAKxC,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAS,0BAA+B,KACvC,WAkEF,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,wBAAwB,GACnC,UAAS,0BAA+B,8CAC6B,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { Effect, Layer } from 'effect';
3
+ import { DEFAULT_RETRY_DIALS, RetryBudgetTag } from '../ports/retry-budget.js';
4
+ /** Requests the window must hold before throttling reads anything into it. */ export const MIN_THROTTLING_SAMPLE = 10;
5
+ const keyOf = (key)=>{
6
+ var _key_organizationId;
7
+ return `${key.dependency}\u0000${(_key_organizationId = key.organizationId) != null ? _key_organizationId : ''}`;
8
+ };
9
+ /**
10
+ * A token-bucket retry budget held in this process
11
+ * ([ADR 0014](../../../../../docs/adr/0014-retry-once-at-the-layer-above-under-a-budget.md)).
12
+ *
13
+ * Each first attempt adds `budgetRatio` of a token, so retries can add at most
14
+ * that fraction to the dependency's load; the floor refills
15
+ * `budgetFloorPerSecond` tokens a second regardless, so a quiet dependency can
16
+ * still retry. Tokens are capped at what the floor plus ten seconds of ratio
17
+ * would earn, so a long calm does not bank a stampede.
18
+ *
19
+ * Adaptive throttling is the SRE book's client-side rule: past `K` requests
20
+ * per accept over the window, a first attempt is rejected locally with
21
+ * probability `(requests − K·accepts) / (requests + 1)` — once the window holds
22
+ * {@link MIN_THROTTLING_SAMPLE} requests, so a cold start is not throttled.
23
+ *
24
+ * One process, one budget: replicas do not share it, which is the point — a
25
+ * replica's retries are its own load on the dependency.
26
+ */ export const makeInMemoryRetryBudget = (options = {})=>{
27
+ var _options_now, _options_random;
28
+ const dials = _extends({}, DEFAULT_RETRY_DIALS, options.dials);
29
+ const now = (_options_now = options.now) != null ? _options_now : Date.now;
30
+ const random = (_options_random = options.random) != null ? _options_random : Math.random;
31
+ const buckets = new Map();
32
+ const cap = Math.max(1, dials.budgetFloorPerSecond * 10);
33
+ const bucketFor = (key)=>{
34
+ const id = keyOf(key);
35
+ let bucket = buckets.get(id);
36
+ if (bucket === undefined) {
37
+ // One second's floor up front, so a dependency's very first failure can
38
+ // be retried.
39
+ bucket = {
40
+ tokens: dials.budgetFloorPerSecond,
41
+ refilledAt: now(),
42
+ requests: [],
43
+ accepts: []
44
+ };
45
+ buckets.set(id, bucket);
46
+ }
47
+ const at = now();
48
+ const elapsedSeconds = (at - bucket.refilledAt) / 1000;
49
+ bucket.tokens = Math.min(cap, bucket.tokens + elapsedSeconds * dials.budgetFloorPerSecond);
50
+ bucket.refilledAt = at;
51
+ const horizon = at - dials.adaptiveThrottlingWindowMs;
52
+ bucket.requests = bucket.requests.filter((t)=>t > horizon);
53
+ bucket.accepts = bucket.accepts.filter((t)=>t > horizon);
54
+ return bucket;
55
+ };
56
+ return {
57
+ dials,
58
+ admitAttempt: (key)=>Effect.sync(()=>{
59
+ const bucket = bucketFor(key);
60
+ bucket.requests.push(now());
61
+ bucket.tokens = Math.min(cap, bucket.tokens + dials.budgetRatio);
62
+ if (dials.adaptiveThrottlingK <= 0) return true;
63
+ const requests = bucket.requests.length;
64
+ // Too few requests to say anything: a cold dependency, or one just
65
+ // coming back, would otherwise throttle half its first calls before a
66
+ // single answer had a chance to arrive.
67
+ if (requests < MIN_THROTTLING_SAMPLE) return true;
68
+ const rejection = Math.max(0, (requests - dials.adaptiveThrottlingK * bucket.accepts.length) / (requests + 1));
69
+ return random() >= rejection;
70
+ }),
71
+ admitRetry: (key)=>Effect.sync(()=>{
72
+ const bucket = bucketFor(key);
73
+ if (bucket.tokens < 1) return false;
74
+ bucket.tokens -= 1;
75
+ return true;
76
+ }),
77
+ recordAccepted: (key)=>Effect.sync(()=>{
78
+ bucketFor(key).accepts.push(now());
79
+ })
80
+ };
81
+ };
82
+ /** The in-memory budget as a layer, for a host's composition root. */ export const InMemoryRetryBudgetLayer = (options = {})=>Layer.sync(RetryBudgetTag, ()=>makeInMemoryRetryBudget(options));
83
+
84
+ //# sourceMappingURL=in-memory-retry-budget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/engine/in-memory-retry-budget.ts"],"sourcesContent":["import { Effect, Layer } from 'effect';\n\nimport {\n DEFAULT_RETRY_DIALS,\n type RetryBudget,\n RetryBudgetTag,\n type RetryDials,\n type RetryKey,\n} from '../ports/retry-budget.js';\n\ninterface Bucket {\n /** Retry tokens available. */\n tokens: number;\n /** When the floor last refilled, epoch ms. */\n refilledAt: number;\n /** Adaptive throttling's window: request and accept timestamps. */\n requests: number[];\n accepts: number[];\n}\n\n/** Requests the window must hold before throttling reads anything into it. */\nexport const MIN_THROTTLING_SAMPLE = 10;\n\nconst keyOf = (key: RetryKey) =>\n `${key.dependency}\\u0000${key.organizationId ?? ''}`;\n\nexport interface InMemoryRetryBudgetOptions {\n readonly dials?: Partial<RetryDials>;\n /** The clock, in epoch milliseconds. Injected so a spec can move time. */\n readonly now?: () => number;\n /** A uniform draw in [0, 1). Injected so a spec can pin throttling. */\n readonly random?: () => number;\n}\n\n/**\n * A token-bucket retry budget held in this process\n * ([ADR 0014](../../../../../docs/adr/0014-retry-once-at-the-layer-above-under-a-budget.md)).\n *\n * Each first attempt adds `budgetRatio` of a token, so retries can add at most\n * that fraction to the dependency's load; the floor refills\n * `budgetFloorPerSecond` tokens a second regardless, so a quiet dependency can\n * still retry. Tokens are capped at what the floor plus ten seconds of ratio\n * would earn, so a long calm does not bank a stampede.\n *\n * Adaptive throttling is the SRE book's client-side rule: past `K` requests\n * per accept over the window, a first attempt is rejected locally with\n * probability `(requests − K·accepts) / (requests + 1)` — once the window holds\n * {@link MIN_THROTTLING_SAMPLE} requests, so a cold start is not throttled.\n *\n * One process, one budget: replicas do not share it, which is the point — a\n * replica's retries are its own load on the dependency.\n */\nexport const makeInMemoryRetryBudget = (\n options: InMemoryRetryBudgetOptions = {},\n): RetryBudget => {\n const dials: RetryDials = { ...DEFAULT_RETRY_DIALS, ...options.dials };\n const now = options.now ?? Date.now;\n const random = options.random ?? Math.random;\n const buckets = new Map<string, Bucket>();\n const cap = Math.max(1, dials.budgetFloorPerSecond * 10);\n\n const bucketFor = (key: RetryKey): Bucket => {\n const id = keyOf(key);\n let bucket = buckets.get(id);\n if (bucket === undefined) {\n // One second's floor up front, so a dependency's very first failure can\n // be retried.\n bucket = {\n tokens: dials.budgetFloorPerSecond,\n refilledAt: now(),\n requests: [],\n accepts: [],\n };\n buckets.set(id, bucket);\n }\n const at = now();\n const elapsedSeconds = (at - bucket.refilledAt) / 1000;\n bucket.tokens = Math.min(\n cap,\n bucket.tokens + elapsedSeconds * dials.budgetFloorPerSecond,\n );\n bucket.refilledAt = at;\n const horizon = at - dials.adaptiveThrottlingWindowMs;\n bucket.requests = bucket.requests.filter(t => t > horizon);\n bucket.accepts = bucket.accepts.filter(t => t > horizon);\n return bucket;\n };\n\n return {\n dials,\n admitAttempt: key =>\n Effect.sync(() => {\n const bucket = bucketFor(key);\n bucket.requests.push(now());\n bucket.tokens = Math.min(cap, bucket.tokens + dials.budgetRatio);\n if (dials.adaptiveThrottlingK <= 0) return true;\n const requests = bucket.requests.length;\n // Too few requests to say anything: a cold dependency, or one just\n // coming back, would otherwise throttle half its first calls before a\n // single answer had a chance to arrive.\n if (requests < MIN_THROTTLING_SAMPLE) return true;\n const rejection = Math.max(\n 0,\n (requests - dials.adaptiveThrottlingK * bucket.accepts.length) /\n (requests + 1),\n );\n return random() >= rejection;\n }),\n admitRetry: key =>\n Effect.sync(() => {\n const bucket = bucketFor(key);\n if (bucket.tokens < 1) return false;\n bucket.tokens -= 1;\n return true;\n }),\n recordAccepted: key =>\n Effect.sync(() => {\n bucketFor(key).accepts.push(now());\n }),\n };\n};\n\n/** The in-memory budget as a layer, for a host's composition root. */\nexport const InMemoryRetryBudgetLayer = (\n options: InMemoryRetryBudgetOptions = {},\n) => Layer.sync(RetryBudgetTag, () => makeInMemoryRetryBudget(options));\n"],"names":["Effect","Layer","DEFAULT_RETRY_DIALS","RetryBudgetTag","MIN_THROTTLING_SAMPLE","keyOf","key","dependency","organizationId","makeInMemoryRetryBudget","options","dials","now","Date","random","Math","buckets","Map","cap","max","budgetFloorPerSecond","bucketFor","id","bucket","get","undefined","tokens","refilledAt","requests","accepts","set","at","elapsedSeconds","min","horizon","adaptiveThrottlingWindowMs","filter","t","admitAttempt","sync","push","budgetRatio","adaptiveThrottlingK","length","rejection","admitRetry","recordAccepted","InMemoryRetryBudgetLayer"],"mappings":";AAAA,SAASA,MAAM,EAAEC,KAAK,QAAQ,SAAS;AAEvC,SACEC,mBAAmB,EAEnBC,cAAc,QAGT,2BAA2B;AAYlC,4EAA4E,GAC5E,OAAO,MAAMC,wBAAwB,GAAG;AAExC,MAAMC,QAAQ,CAACC;QACaA;WAA1B,GAAGA,IAAIC,UAAU,CAAC,MAAM,GAAED,sBAAAA,IAAIE,cAAc,YAAlBF,sBAAsB,IAAI;;AAUtD;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,MAAMG,0BAA0B,CACrCC,UAAsC,CAAC,CAAC;QAG5BA,cACGA;IAFf,MAAMC,QAAoB,aAAKT,qBAAwBQ,QAAQC,KAAK;IACpE,MAAMC,OAAMF,eAAAA,QAAQE,GAAG,YAAXF,eAAeG,KAAKD,GAAG;IACnC,MAAME,UAASJ,kBAAAA,QAAQI,MAAM,YAAdJ,kBAAkBK,KAAKD,MAAM;IAC5C,MAAME,UAAU,IAAIC;IACpB,MAAMC,MAAMH,KAAKI,GAAG,CAAC,GAAGR,MAAMS,oBAAoB,GAAG;IAErD,MAAMC,YAAY,CAACf;QACjB,MAAMgB,KAAKjB,MAAMC;QACjB,IAAIiB,SAASP,QAAQQ,GAAG,CAACF;QACzB,IAAIC,WAAWE,WAAW;YACxB,wEAAwE;YACxE,cAAc;YACdF,SAAS;gBACPG,QAAQf,MAAMS,oBAAoB;gBAClCO,YAAYf;gBACZgB,UAAU,EAAE;gBACZC,SAAS,EAAE;YACb;YACAb,QAAQc,GAAG,CAACR,IAAIC;QAClB;QACA,MAAMQ,KAAKnB;QACX,MAAMoB,iBAAiB,AAACD,CAAAA,KAAKR,OAAOI,UAAU,AAAD,IAAK;QAClDJ,OAAOG,MAAM,GAAGX,KAAKkB,GAAG,CACtBf,KACAK,OAAOG,MAAM,GAAGM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C,UAAsC,CAAC,CAAC,GACrCT,MAAMsC,IAAI,CAACpC,gBAAgB,IAAMM,wBAAwBC,UAAU"}
@@ -9,6 +9,7 @@
9
9
  * specifier (ADR 0006).
10
10
  */
11
11
  export * from '../stream/transaction-stream-hub.js';
12
+ export * from './in-memory-retry-budget.js';
12
13
  export * from './local-saga-dispatcher.js';
13
14
  export * from './resolve-template.js';
14
15
  export * from './resume-sweep.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
@@ -8,6 +8,7 @@
8
8
  * participant — must be able to ban the engine by name, and a ban matches a
9
9
  * specifier (ADR 0006).
10
10
  */ export * from '../stream/transaction-stream-hub.js';
11
+ export * from './in-memory-retry-budget.js';
11
12
  export * from './local-saga-dispatcher.js';
12
13
  export * from './resolve-template.js';
13
14
  export * from './resume-sweep.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/engine/index.ts"],"sourcesContent":["/**\n * The mechanism behind `@entifix/transactions`' ports: the saga runner and its\n * resume sweep, the single-step transaction engine, the in-process dispatcher\n * and the stream hub.\n *\n * A subpath rather than part of `.` although it installs nothing `.` does not,\n * because a consumer that writes against the contracts — a cell, a route, a\n * participant — must be able to ban the engine by name, and a ban matches a\n * specifier (ADR 0006).\n */\nexport * from '../stream/transaction-stream-hub.js';\nexport * from './local-saga-dispatcher.js';\nexport * from './resolve-template.js';\nexport * from './resume-sweep.js';\nexport * from './run-saga.js';\nexport * from './run-transaction.js';\n"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GACD,cAAc,sCAAsC;AACpD,cAAc,6BAA6B;AAC3C,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB"}
1
+ {"version":3,"sources":["../../src/engine/index.ts"],"sourcesContent":["/**\n * The mechanism behind `@entifix/transactions`' ports: the saga runner and its\n * resume sweep, the single-step transaction engine, the in-process dispatcher\n * and the stream hub.\n *\n * A subpath rather than part of `.` although it installs nothing `.` does not,\n * because a consumer that writes against the contracts — a cell, a route, a\n * participant — must be able to ban the engine by name, and a ban matches a\n * specifier (ADR 0006).\n */\nexport * from '../stream/transaction-stream-hub.js';\nexport * from './in-memory-retry-budget.js';\nexport * from './local-saga-dispatcher.js';\nexport * from './resolve-template.js';\nexport * from './resume-sweep.js';\nexport * from './run-saga.js';\nexport * from './run-transaction.js';\n"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GACD,cAAc,sCAAsC;AACpD,cAAc,8BAA8B;AAC5C,cAAc,6BAA6B;AAC3C,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB"}
@@ -1,4 +1,4 @@
1
- import type { EntifixConnError } from '@entifix/core';
1
+ import type { EntifixConnError, StoreFailure } from '@entifix/core';
2
2
  import { Effect } from 'effect';
3
3
  import { type SagaDefinition, type SagaInputs, type SagaStepInput, type SagaStepOutcome } from '../contracts/saga-definition.js';
4
4
  import { SagaDispatcherTag } from '../ports/saga-dispatcher.js';
@@ -23,7 +23,7 @@ export interface SagaResult {
23
23
  * is durability *behind* that answer: if this process dies mid-walk, the record
24
24
  * it has been writing all along is enough for another one to finish the flow.
25
25
  */
26
- export declare const runSaga: (options: RunSagaOptions) => Effect.Effect<SagaResult, EntifixConnError, SagaDispatcherTag | SagaStoreTag>;
26
+ export declare const runSaga: (options: RunSagaOptions) => Effect.Effect<SagaResult, StoreFailure | EntifixConnError, SagaDispatcherTag | SagaStoreTag>;
27
27
  export interface ResumeSagaOptions {
28
28
  readonly instance: SagaInstance;
29
29
  readonly definition: SagaDefinition;
@@ -50,5 +50,5 @@ export interface ResumeSagaOptions {
50
50
  * - the instance is `COMPENSATING` — it died mid-unwind, so **continue the
51
51
  * unwind**, skipping steps already marked `compensated`.
52
52
  */
53
- export declare const resumeSaga: (options: ResumeSagaOptions) => Effect.Effect<SagaResult, EntifixConnError, SagaDispatcherTag | SagaStoreTag>;
53
+ export declare const resumeSaga: (options: ResumeSagaOptions) => Effect.Effect<SagaResult, StoreFailure | EntifixConnError, SagaDispatcherTag | SagaStoreTag>;
54
54
  //# sourceMappingURL=run-saga.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-saga.d.ts","sourceRoot":"","sources":["../../src/engine/run-saga.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,UAAU,EAEf,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,YAAY,EAEjB,YAAY,EACb,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AAa1C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAA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