@fabricorg/platform 1.6.0 → 1.8.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.
- package/CHANGELOG.md +79 -0
- package/README.md +216 -3
- package/dist/actions/index.cjs +6 -6
- package/dist/actions/index.d.cts +85 -3
- package/dist/actions/index.d.ts +85 -3
- package/dist/actions/index.js +1 -1
- package/dist/adapters/index.cjs +33 -9
- package/dist/adapters/index.d.cts +388 -1
- package/dist/adapters/index.d.ts +388 -1
- package/dist/adapters/index.js +1 -1
- package/dist/certification/index.cjs +6 -6
- package/dist/certification/index.js +3 -3
- package/dist/{chunk-VZ6C4LXC.cjs → chunk-45OKKLNY.cjs} +17 -9
- package/dist/chunk-45OKKLNY.cjs.map +1 -0
- package/dist/chunk-5FOCPRTR.js +511 -0
- package/dist/chunk-5FOCPRTR.js.map +1 -0
- package/dist/{chunk-USDLP4E7.cjs → chunk-5IVFPWK6.cjs} +4 -4
- package/dist/{chunk-USDLP4E7.cjs.map → chunk-5IVFPWK6.cjs.map} +1 -1
- package/dist/chunk-6HY35TKB.cjs +491 -0
- package/dist/chunk-6HY35TKB.cjs.map +1 -0
- package/dist/chunk-6UGEIDLC.cjs +26 -0
- package/dist/chunk-6UGEIDLC.cjs.map +1 -0
- package/dist/chunk-BJGZE3GE.js +20 -0
- package/dist/chunk-BJGZE3GE.js.map +1 -0
- package/dist/{chunk-X3GHYMAJ.cjs → chunk-CRZXTZ36.cjs} +2 -22
- package/dist/chunk-CRZXTZ36.cjs.map +1 -0
- package/dist/{chunk-TMMP4U2D.cjs → chunk-DBTAUI6C.cjs} +5 -2
- package/dist/chunk-DBTAUI6C.cjs.map +1 -0
- package/dist/{chunk-UYCQV65U.js → chunk-EMSAFNPX.js} +3 -3
- package/dist/{chunk-UYCQV65U.js.map → chunk-EMSAFNPX.js.map} +1 -1
- package/dist/{chunk-DCC3UIUJ.js → chunk-GFU7BGEJ.js} +3 -3
- package/dist/{chunk-DCC3UIUJ.js.map → chunk-GFU7BGEJ.js.map} +1 -1
- package/dist/{chunk-JFVEPAED.js → chunk-GU3LZWJD.js} +17 -9
- package/dist/chunk-GU3LZWJD.js.map +1 -0
- package/dist/chunk-HEYMMVDP.js +480 -0
- package/dist/chunk-HEYMMVDP.js.map +1 -0
- package/dist/chunk-IF6NJORI.cjs +526 -0
- package/dist/chunk-IF6NJORI.cjs.map +1 -0
- package/dist/{chunk-XS7EUS4T.cjs → chunk-MCWSUGB3.cjs} +4 -4
- package/dist/{chunk-XS7EUS4T.cjs.map → chunk-MCWSUGB3.cjs.map} +1 -1
- package/dist/{chunk-QHV6LOS6.js → chunk-PDN5DOLQ.js} +3 -3
- package/dist/{chunk-QHV6LOS6.js.map → chunk-PDN5DOLQ.js.map} +1 -1
- package/dist/{chunk-OZWUNGJE.js → chunk-PIDZQAEL.js} +5 -2
- package/dist/chunk-PIDZQAEL.js.map +1 -0
- package/dist/{chunk-ATWWZTRC.js → chunk-TYNIFC7J.js} +3 -18
- package/dist/chunk-TYNIFC7J.js.map +1 -0
- package/dist/{chunk-DDX5FKOM.cjs → chunk-UGWGHTNC.cjs} +5 -2
- package/dist/chunk-UGWGHTNC.cjs.map +1 -0
- package/dist/{chunk-ZF5HDNSU.js → chunk-WNZP53GI.js} +5 -2
- package/dist/chunk-WNZP53GI.js.map +1 -0
- package/dist/{chunk-2URHPZXL.cjs → chunk-WQ3BYI7T.cjs} +6 -6
- package/dist/{chunk-2URHPZXL.cjs.map → chunk-WQ3BYI7T.cjs.map} +1 -1
- package/dist/evidence/index.cjs +45 -1
- package/dist/evidence/index.d.cts +187 -1
- package/dist/evidence/index.d.ts +187 -1
- package/dist/evidence/index.js +3 -1
- package/dist/governance/index.d.cts +1 -0
- package/dist/governance/index.d.ts +1 -0
- package/dist/index.cjs +153 -88
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +11 -10
- package/dist/manifest/index.cjs +8 -8
- package/dist/manifest/index.js +2 -2
- package/dist/modules/index.cjs +9 -9
- package/dist/modules/index.js +1 -1
- package/dist/policies/index.cjs +9 -9
- package/dist/policies/index.d.cts +14 -1
- package/dist/policies/index.d.ts +14 -1
- package/dist/policies/index.js +1 -1
- package/dist/privacy/index.cjs +19 -18
- package/dist/privacy/index.js +2 -1
- package/dist/testing/index.cjs +5 -5
- package/dist/testing/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ATWWZTRC.js.map +0 -1
- package/dist/chunk-DDX5FKOM.cjs.map +0 -1
- package/dist/chunk-FAG2RTPM.js +0 -120
- package/dist/chunk-FAG2RTPM.js.map +0 -1
- package/dist/chunk-JFVEPAED.js.map +0 -1
- package/dist/chunk-OZLZHISS.js +0 -3
- package/dist/chunk-OZLZHISS.js.map +0 -1
- package/dist/chunk-OZWUNGJE.js.map +0 -1
- package/dist/chunk-PG5LYTUX.cjs +0 -4
- package/dist/chunk-PG5LYTUX.cjs.map +0 -1
- package/dist/chunk-TMMP4U2D.cjs.map +0 -1
- package/dist/chunk-VZ6C4LXC.cjs.map +0 -1
- package/dist/chunk-X3GHYMAJ.cjs.map +0 -1
- package/dist/chunk-XZQZQ5SW.cjs +0 -129
- package/dist/chunk-XZQZQ5SW.cjs.map +0 -1
- package/dist/chunk-ZF5HDNSU.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../adapters/circuit-breaker.ts","../adapters/index.ts"],"names":[],"mappings":";;;AAgDO,SAAS,8BAA8B,IAAA,EAAiD;AAC9F,EAAA,QAAQ,IAAA;AAAM,IACb,KAAK,SAAA;AACJ,MAAA,OAAO,SAAA;AAAA,IACR,KAAK,mBAAA;AACJ,MAAA,OAAO,SAAA;AAAA,IACR,KAAK,mBAAA;AAAA,IACL,KAAK,SAAA;AAAA,IACL,KAAK,WAAA;AACJ,MAAA,OAAO,SAAA;AAAA,IACR;AAEC,MAAA,OAAO,SAAA;AAAA;AAEV;AA0HA,IAAM,gBAAA,GAAmE,CAAC,YAAA,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AAO,MAAA;AACrB,EAAA,MAAM,OAAA,GAAU,QAAQ,KAAA,EAAM;AAC9B,EAAA,OAAO,OAAA,CAAQ,UAAU,MAAA,GAAY,OAAA;AACtC","file":"chunk-IF6NJORI.cjs","sourcesContent":["import type {\n\tAdapterCircuitBreakerConfig,\n\tAdapterCircuitBreakerManualOverride,\n\tAdapterImplementation,\n\tAdapterOutcomeKind,\n} from \"./index\";\n\n/**\n * State of an adapter circuit breaker.\n *\n * - `closed`: calls flow and outcomes are counted.\n * - `open`: the dependency is presumed unhealthy. In `enforce` mode calls are\n * rejected without being attempted until `cooldownMs` has elapsed.\n * - `half_open`: the cooldown elapsed. One probe call is admitted; its outcome\n * closes the breaker (success) or reopens it (failure).\n */\nexport type AdapterCircuitState = \"closed\" | \"open\" | \"half_open\";\n\n/**\n * How a single adapter outcome counts toward the breaker.\n *\n * - `success`: the dependency answered and the call succeeded.\n * - `failure`: evidence the dependency is unhealthy.\n * - `ignored`: the dependency answered but rejected the request on its merits\n * (a validation or business rejection). It is neither a success nor a\n * dependency failure and does not enter the rolling window.\n */\nexport type AdapterCircuitOutcome = \"success\" | \"failure\" | \"ignored\";\n\n/**\n * Map an {@link AdapterOutcomeKind} to how it counts toward a circuit breaker.\n *\n * | Outcome kind | Counts as |\n * |---------------------|-----------|\n * | `success` | `success` |\n * | `transient_failure` | `failure` |\n * | `timeout` | `failure` |\n * | `ambiguous` | `failure` |\n * | `permanent_failure` | `ignored` |\n *\n * `ambiguous` counts as a failure: the dependency did not give a definite\n * answer, which is a health signal even though the Host routes the invocation\n * to reconciliation. `permanent_failure` (validation or rejection) is the\n * dependency working correctly and saying no, so it does not trip the breaker.\n * `executeWithAdapterRetry` classifies a thrown error with the caller's\n * `classifyThrownError` (default `transient_failure`) and maps that kind here,\n * so an unclassified thrown error counts as a failure.\n */\nexport function classifyCircuitBreakerOutcome(kind: AdapterOutcomeKind): AdapterCircuitOutcome {\n\tswitch (kind) {\n\t\tcase \"success\":\n\t\t\treturn \"success\";\n\t\tcase \"permanent_failure\":\n\t\t\treturn \"ignored\";\n\t\tcase \"transient_failure\":\n\t\tcase \"timeout\":\n\t\tcase \"ambiguous\":\n\t\t\treturn \"failure\";\n\t\tdefault:\n\t\t\t// An unknown kind is treated as a dependency failure (fail closed).\n\t\t\treturn \"failure\";\n\t}\n}\n\n/** The answer a breaker gives before a call. */\nexport interface AdapterCircuitAdmission {\n\t/**\n\t * Whether the call may proceed. Always `true` in `monitor` mode; `false`\n\t * only in `enforce` mode while the breaker is open, forced open, or\n\t * half-open with its probe already in flight.\n\t */\n\tallowed: boolean;\n\t/** State at the time of the decision. */\n\tstate: AdapterCircuitState;\n\t/** True when this admission is the half-open probe. Pass it back to `record`. */\n\tprobe: boolean;\n\t/** Monitor mode only: true when `enforce` mode would have rejected this call. */\n\twouldReject?: boolean;\n\t/**\n\t * Milliseconds until the breaker will admit a probe, when known. Absent while\n\t * a manual `force_open` override is set or a half-open probe is in flight.\n\t */\n\tretryAfterMs?: number;\n\t/** Set when a manual override decided the admission. */\n\tmanualOverride?: AdapterCircuitBreakerManualOverride;\n\t/**\n\t * The breaker epoch the admission was granted in; opaque to callers.\n\t * {@link InMemoryAdapterCircuitBreaker} lets an outcome change state only\n\t * when this still matches its current epoch. An admission without it is\n\t * treated as current.\n\t */\n\tgeneration?: number;\n}\n\n/**\n * Contract between a circuit breaker and `executeWithAdapterRetry`.\n * Implement it to plug in a shared or distributed breaker.\n */\nexport interface AdapterCircuitBreaker {\n\t/** `adapterType:operation` this breaker guards. */\n\treadonly key: string;\n\treadonly mode: \"monitor\" | \"enforce\";\n\t/** Current state, applying any elapsed cooldown or manual override. */\n\tgetState(): AdapterCircuitState;\n\t/**\n\t * Preview whether a call would be admitted now. Side-effect free: it does\n\t * not commit an elapsed cooldown, take the half-open probe or emit\n\t * telemetry.\n\t */\n\tcheck(): AdapterCircuitAdmission;\n\t/**\n\t * Decide whether a call may start now. Call it immediately before the\n\t * external effect and pass the returned admission to {@link record}.\n\t */\n\tacquire(): AdapterCircuitAdmission;\n\t/**\n\t * Record the outcome of a call that was admitted by {@link acquire}. Pass\n\t * that admission, not a {@link check} preview, so the breaker can tell a\n\t * stale outcome from a current one.\n\t */\n\trecord(outcome: AdapterCircuitOutcome, admission?: AdapterCircuitAdmission): void;\n}\n\nexport type AdapterCircuitBreakerEventReason =\n\t| \"failure_threshold\"\n\t| \"cooldown_elapsed\"\n\t| \"probe_succeeded\"\n\t| \"probe_failed\"\n\t| \"manual_override\"\n\t| \"manual_override_cleared\";\n\ninterface AdapterCircuitBreakerEventBase {\n\tkey: string;\n\tmode: \"monitor\" | \"enforce\";\n\t/** Epoch milliseconds from the breaker's clock. */\n\tat: number;\n}\n\n/** Telemetry reported by {@link InMemoryAdapterCircuitBreaker}. */\nexport type AdapterCircuitBreakerEvent =\n\t| (AdapterCircuitBreakerEventBase & {\n\t\t\ttype: \"state_change\";\n\t\t\tfrom: AdapterCircuitState;\n\t\t\tto: AdapterCircuitState;\n\t\t\treason: AdapterCircuitBreakerEventReason;\n\t\t\tmanualOverride?: AdapterCircuitBreakerManualOverride;\n\t })\n\t| (AdapterCircuitBreakerEventBase & {\n\t\t\t/** Enforce mode refused a call; it was not attempted. */\n\t\t\ttype: \"rejected\";\n\t\t\tstate: AdapterCircuitState;\n\t\t\tretryAfterMs?: number;\n\t\t\tmanualOverride?: AdapterCircuitBreakerManualOverride;\n\t })\n\t| (AdapterCircuitBreakerEventBase & {\n\t\t\t/** Monitor mode let a call through that enforce mode would have refused. */\n\t\t\ttype: \"would_reject\";\n\t\t\tstate: AdapterCircuitState;\n\t\t\tretryAfterMs?: number;\n\t\t\tmanualOverride?: AdapterCircuitBreakerManualOverride;\n\t });\n\n/**\n * Telemetry callback. Errors it throws and promises it rejects are caught\n * and discarded so telemetry cannot change an adapter call's outcome.\n *\n * {@link InMemoryAdapterCircuitBreaker} calls it only after the operation that\n * produced the event has committed, never part-way through a decision or a\n * record. A callback may call back into the breaker; it sees committed state,\n * and events its own calls produce are delivered after it returns, in order.\n */\nexport type AdapterCircuitBreakerEventListener = (\n\tevent: AdapterCircuitBreakerEvent,\n) => void | Promise<void>;\n\nexport interface InMemoryAdapterCircuitBreakerOptions {\n\t/** Usually `adapterType:operation`. */\n\tkey: string;\n\tconfig: AdapterCircuitBreakerConfig;\n\t/** Epoch-millisecond clock. Defaults to `Date.now`. */\n\tnow?: () => number;\n\tonEvent?: AdapterCircuitBreakerEventListener;\n}\n\nconst MANUAL_OVERRIDES: readonly AdapterCircuitBreakerManualOverride[] = [\"force_open\", \"force_closed\"];\n\n/**\n * Validate a circuit-breaker config. Throws a `RangeError` naming the first\n * invalid field: `mode` must be `monitor` or `enforce`; `failureThreshold` and\n * `minimumSamples` positive integers; `windowMs` and `probeLeaseMs` positive\n * finite numbers; `cooldownMs` a non-negative finite number; `manualOverride`\n * `force_open` or `force_closed` when present.\n */\nexport function assertAdapterCircuitBreakerConfig(config: AdapterCircuitBreakerConfig): void {\n\tif (!config || typeof config !== \"object\") {\n\t\tthrow new RangeError(\"Adapter circuit breaker config must be an object.\");\n\t}\n\tif (config.mode !== \"monitor\" && config.mode !== \"enforce\") {\n\t\tthrow new RangeError(`Adapter circuit breaker mode must be \"monitor\" or \"enforce\"; got ${JSON.stringify(config.mode)}.`);\n\t}\n\tif (!Number.isInteger(config.failureThreshold) || config.failureThreshold < 1) {\n\t\tthrow new RangeError(`Adapter circuit breaker failureThreshold must be a positive integer; got ${String(config.failureThreshold)}.`);\n\t}\n\tif (typeof config.windowMs !== \"number\" || !Number.isFinite(config.windowMs) || config.windowMs <= 0) {\n\t\tthrow new RangeError(`Adapter circuit breaker windowMs must be a positive number of milliseconds; got ${String(config.windowMs)}.`);\n\t}\n\tif (typeof config.cooldownMs !== \"number\" || !Number.isFinite(config.cooldownMs) || config.cooldownMs < 0) {\n\t\tthrow new RangeError(`Adapter circuit breaker cooldownMs must be a non-negative number of milliseconds; got ${String(config.cooldownMs)}.`);\n\t}\n\tif (\n\t\tconfig.minimumSamples !== undefined &&\n\t\t(!Number.isInteger(config.minimumSamples) || config.minimumSamples < 1)\n\t) {\n\t\tthrow new RangeError(`Adapter circuit breaker minimumSamples must be a positive integer; got ${String(config.minimumSamples)}.`);\n\t}\n\tif (\n\t\tconfig.probeLeaseMs !== undefined &&\n\t\t(typeof config.probeLeaseMs !== \"number\" || !Number.isFinite(config.probeLeaseMs) || config.probeLeaseMs <= 0)\n\t) {\n\t\tthrow new RangeError(`Adapter circuit breaker probeLeaseMs must be a positive number of milliseconds; got ${String(config.probeLeaseMs)}.`);\n\t}\n\tif (config.manualOverride !== undefined && !MANUAL_OVERRIDES.includes(config.manualOverride)) {\n\t\tthrow new RangeError(`Adapter circuit breaker manualOverride must be \"force_open\" or \"force_closed\"; got ${JSON.stringify(config.manualOverride)}.`);\n\t}\n}\n\ninterface Sample {\n\tat: number;\n\tfailure: boolean;\n}\n\n/**\n * Dependency-free, in-process circuit breaker for one adapter operation.\n *\n * State lives in this instance only: it is not shared between processes,\n * hosts, or replicas, and it is lost on restart. Each replica trips on the\n * failures it observes itself.\n *\n * Tripping rule (parity with the .NET `InMemoryAdapterCircuitBreaker`): after\n * a failure is recorded while `closed`, let `N` be the outcomes recorded within\n * the last `windowMs` and `M = minimumSamples ?? failureThreshold`. The breaker\n * opens when `N >= M` and either\n * 1. the most recent `failureThreshold` outcomes in the window are all\n * failures, or\n * 2. the failure ratio in the window is at least `failureThreshold / M`.\n *\n * With `minimumSamples` omitted this reads \"`failureThreshold` consecutive\n * failures\". With `minimumSamples: 20, failureThreshold: 10` it also opens at\n * a 50% failure rate over at least 20 calls.\n *\n * After `cooldownMs` the breaker turns `half_open` and admits one probe. A\n * probe success closes it and clears the window; a probe failure reopens it\n * and restarts the cooldown. At most one probe is outstanding at a time: it\n * holds a lease of `probeLeaseMs` (default `max(cooldownMs, windowMs)`, never\n * derived from the cooldown alone, so `cooldownMs: 0` still admits one probe).\n * A probe that has not recorded when its lease expires is considered lost and\n * the next call becomes the probe.\n *\n * Epochs: the breaker keeps a generation counter that advances on every state\n * change (including one committed by an elapsed cooldown), every manual\n * override change, and every probe grant. Each admission carries the\n * generation it was granted in. `record` first commits any elapsed cooldown,\n * then compares generations. An outcome from an earlier epoch is stale: it is\n * dropped entirely. It changes no state, does not resolve or free the probe\n * slot, and is not added to the rolling window, so it cannot contribute to a\n * later trip either. Because a probe grant starts a new epoch, the outstanding\n * probe is the only `probe: true` admission of the current epoch, which is how\n * a replaced probe's late outcome is told apart. An outcome recorded without an\n * admission, or with one that has no `generation`, is treated as current: it is\n * sampled, can trip a closed breaker and resolves an outstanding probe.\n *\n * Telemetry is buffered and delivered after each operation commits. An\n * elapsed cooldown is committed, and its `cooldown_elapsed` event delivered,\n * as a step of its own before `acquire`, `record`, `getState` or\n * `setManualOverride` continues, so a callback reacting to it (for example by\n * forcing the breaker open) governs the call that observed it. Every other\n * event is delivered once the method's decision or record is final, and a\n * callback never revokes an admission that is already committed. Two cases\n * follow from that: a breaker call made from inside a callback queues its own\n * `cooldown_elapsed` behind the current delivery and decides first; and with\n * `cooldownMs: 0`, a cooldown that falls due again during the decision (because\n * a callback reopened the breaker) is committed and admitted before its event\n * is delivered.\n *\n * `monitor` mode runs the same state machine and reports the same telemetry\n * but admits every call; calls enforce mode would have refused are reported\n * as `would_reject`.\n *\n * A manual override pins the reported state (`force_open` → `open`,\n * `force_closed` → `closed`) and suspends automatic transitions while set;\n * outcomes of calls admitted under the override are still recorded. Like an\n * automatic open, `force_open` blocks only in `enforce` mode. Clearing the\n * override returns the breaker to `closed` with its window intact.\n */\nexport class InMemoryAdapterCircuitBreaker implements AdapterCircuitBreaker {\n\treadonly key: string;\n\treadonly mode: \"monitor\" | \"enforce\";\n\tprivate readonly config: AdapterCircuitBreakerConfig;\n\tprivate readonly now: () => number;\n\tprivate readonly onEvent: AdapterCircuitBreakerEventListener | undefined;\n\tprivate readonly probeLeaseMs: number;\n\tprivate samples: Sample[] = [];\n\tprivate state: AdapterCircuitState = \"closed\";\n\tprivate openedAt = 0;\n\tprivate probeIssuedAt: number | undefined;\n\t/** Advances on every state change, manual override change and probe grant. */\n\tprivate generation = 0;\n\tprivate manualOverride: AdapterCircuitBreakerManualOverride | undefined;\n\t/** Telemetry waiting for the current operation to commit. */\n\tprivate readonly outbox: AdapterCircuitBreakerEvent[] = [];\n\tprivate operationDepth = 0;\n\tprivate flushing = false;\n\n\tconstructor(options: InMemoryAdapterCircuitBreakerOptions) {\n\t\tassertAdapterCircuitBreakerConfig(options.config);\n\t\tthis.key = options.key;\n\t\tthis.config = { ...options.config };\n\t\tthis.mode = options.config.mode;\n\t\tthis.now = options.now ?? Date.now;\n\t\tthis.onEvent = options.onEvent;\n\t\tthis.manualOverride = options.config.manualOverride;\n\t\tthis.probeLeaseMs = options.config.probeLeaseMs ?? Math.max(options.config.cooldownMs, options.config.windowMs);\n\t}\n\n\tgetState(): AdapterCircuitState {\n\t\tthis.settle(this.now());\n\t\treturn this.reportedState();\n\t}\n\n\tgetManualOverride(): AdapterCircuitBreakerManualOverride | undefined {\n\t\treturn this.manualOverride;\n\t}\n\n\t/**\n\t * Set (`force_open` / `force_closed`) or clear (`undefined`) the manual\n\t * override. Clearing returns the breaker to `closed` with its window intact.\n\t */\n\tsetManualOverride(override: AdapterCircuitBreakerManualOverride | undefined): void {\n\t\tif (override !== undefined && !MANUAL_OVERRIDES.includes(override)) {\n\t\t\tthrow new RangeError(`Adapter circuit breaker manualOverride must be \"force_open\" or \"force_closed\"; got ${JSON.stringify(override)}.`);\n\t\t}\n\t\tconst now = this.now();\n\t\tthis.settle(now);\n\t\t// Compared after settle: a telemetry callback may have set this override.\n\t\tif (override === this.manualOverride) return;\n\t\tthis.operation(() => {\n\t\t\tconst from = this.reportedState();\n\t\t\tthis.manualOverride = override;\n\t\t\tthis.generation++;\n\t\t\tif (override === undefined) {\n\t\t\t\tthis.state = \"closed\";\n\t\t\t\tthis.releaseProbe();\n\t\t\t}\n\t\t\tthis.emit({\n\t\t\t\ttype: \"state_change\",\n\t\t\t\tkey: this.key,\n\t\t\t\tmode: this.mode,\n\t\t\t\tat: now,\n\t\t\t\tfrom,\n\t\t\t\tto: this.reportedState(),\n\t\t\t\treason: override === undefined ? \"manual_override_cleared\" : \"manual_override\",\n\t\t\t\t...(override ? { manualOverride: override } : {}),\n\t\t\t});\n\t\t});\n\t}\n\n\tcheck(): AdapterCircuitAdmission {\n\t\treturn this.decide(false, this.now());\n\t}\n\n\tacquire(): AdapterCircuitAdmission {\n\t\tconst now = this.now();\n\t\tthis.settle(now);\n\t\treturn this.operation(() => this.decide(true, now));\n\t}\n\n\trecord(outcome: AdapterCircuitOutcome, admission?: AdapterCircuitAdmission): void {\n\t\tconst now = this.now();\n\t\t// Commit an elapsed cooldown first, so an outcome admitted while open\n\t\t// is judged against the half_open epoch it would otherwise influence.\n\t\tthis.settle(now);\n\t\tthis.operation(() => this.applyOutcome(outcome, admission, now));\n\t}\n\n\tprivate applyOutcome(outcome: AdapterCircuitOutcome, admission: AdapterCircuitAdmission | undefined, now: number): void {\n\t\tconst generation = admission?.generation;\n\t\t// Stale: admitted in an earlier epoch. No transition, no probe release, no sample.\n\t\tif (generation !== undefined && generation !== this.generation) return;\n\t\t// In the current epoch the only probe admission is the outstanding probe.\n\t\tconst resolvesProbe =\n\t\t\tthis.state === \"half_open\" &&\n\t\t\tthis.probeIssuedAt !== undefined &&\n\t\t\t(generation === undefined || admission?.probe === true);\n\t\tif (outcome === \"ignored\") {\n\t\t\t// The dependency answered; the probe proved nothing either way.\n\t\t\tif (resolvesProbe) this.releaseProbe();\n\t\t\treturn;\n\t\t}\n\t\tthis.prune(now);\n\t\tthis.samples.push({ at: now, failure: outcome === \"failure\" });\n\t\tif (this.manualOverride) return;\n\t\tif (resolvesProbe) {\n\t\t\tthis.releaseProbe();\n\t\t\tif (outcome === \"success\") {\n\t\t\t\tthis.samples = [];\n\t\t\t\tthis.transition(\"closed\", \"probe_succeeded\", now);\n\t\t\t} else {\n\t\t\t\tthis.openedAt = now;\n\t\t\t\tthis.transition(\"open\", \"probe_failed\", now);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (this.state === \"closed\" && outcome === \"failure\" && this.shouldTrip()) {\n\t\t\tthis.openedAt = now;\n\t\t\tthis.transition(\"open\", \"failure_threshold\", now);\n\t\t}\n\t}\n\n\t/**\n\t * `take` is false for {@link check}: a pure preview that sees an elapsed\n\t * cooldown without committing it, takes no probe and emits nothing.\n\t */\n\tprivate decide(take: boolean, now: number): AdapterCircuitAdmission {\n\t\tif (this.manualOverride === \"force_closed\") {\n\t\t\treturn { allowed: true, state: \"closed\", probe: false, manualOverride: \"force_closed\", generation: this.generation };\n\t\t}\n\t\tif (this.manualOverride === \"force_open\") {\n\t\t\treturn this.refuse(take, { state: \"open\", manualOverride: \"force_open\" });\n\t\t}\n\t\t// An elapsed cooldown releases any probe, so a pending open → half_open\n\t\t// transition always has its probe free.\n\t\tconst cooldownElapsed = this.state === \"open\" && now - this.openedAt >= this.config.cooldownMs;\n\t\t// Normally a no-op: acquire() settled first. A listener run by that\n\t\t// settle can reopen the breaker (with cooldownMs 0 it is due at once);\n\t\t// that cooldown is committed here and reported after the decision.\n\t\tif (take) this.advance(now);\n\t\tconst state: AdapterCircuitState = !take && cooldownElapsed ? \"half_open\" : this.state;\n\t\tif (state === \"closed\") return { allowed: true, state: \"closed\", probe: false, generation: this.generation };\n\t\tif (state === \"open\") {\n\t\t\treturn this.refuse(take, {\n\t\t\t\tstate: \"open\",\n\t\t\t\tretryAfterMs: Math.max(0, this.openedAt + this.config.cooldownMs - now),\n\t\t\t});\n\t\t}\n\t\t// half_open: one probe at a time, until it records or its lease expires.\n\t\tconst probeFree =\n\t\t\t(!take && cooldownElapsed) ||\n\t\t\tthis.probeIssuedAt === undefined ||\n\t\t\tnow - this.probeIssuedAt >= this.probeLeaseMs;\n\t\tif (!probeFree) return this.refuse(take, { state: \"half_open\" });\n\t\tif (!take) return { allowed: true, state: \"half_open\", probe: true, generation: this.generation };\n\t\t// Granting the probe starts a new epoch, so a replaced probe's token goes stale.\n\t\tthis.probeIssuedAt = now;\n\t\tthis.generation++;\n\t\treturn { allowed: true, state: \"half_open\", probe: true, generation: this.generation };\n\t}\n\n\tprivate refuse(\n\t\ttake: boolean,\n\t\tdetail: { state: AdapterCircuitState; retryAfterMs?: number; manualOverride?: AdapterCircuitBreakerManualOverride },\n\t): AdapterCircuitAdmission {\n\t\tconst enforce = this.mode === \"enforce\";\n\t\tif (take) {\n\t\t\tthis.emit({\n\t\t\t\ttype: enforce ? \"rejected\" : \"would_reject\",\n\t\t\t\tkey: this.key,\n\t\t\t\tmode: this.mode,\n\t\t\t\tat: this.now(),\n\t\t\t\t...detail,\n\t\t\t});\n\t\t}\n\t\tconst generation = this.generation;\n\t\treturn enforce\n\t\t\t? { allowed: false, probe: false, ...detail, generation }\n\t\t\t: { allowed: true, probe: false, wouldReject: true, ...detail, generation };\n\t}\n\n\tprivate releaseProbe(): void {\n\t\tthis.probeIssuedAt = undefined;\n\t}\n\n\t/** Apply the time-based open → half_open transition. */\n\tprivate advance(now: number): void {\n\t\tif (this.state === \"open\" && now - this.openedAt >= this.config.cooldownMs) {\n\t\t\tthis.releaseProbe();\n\t\t\tthis.transition(\"half_open\", \"cooldown_elapsed\", now);\n\t\t}\n\t}\n\n\tprivate shouldTrip(): boolean {\n\t\tconst minimumSamples = this.config.minimumSamples ?? this.config.failureThreshold;\n\t\tconst total = this.samples.length;\n\t\tif (total < minimumSamples) return false;\n\t\tlet consecutive = 0;\n\t\tfor (let index = total - 1; index >= 0 && this.samples[index]!.failure; index--) consecutive++;\n\t\tif (consecutive >= this.config.failureThreshold) return true;\n\t\tconst failures = this.samples.reduce((count, sample) => count + (sample.failure ? 1 : 0), 0);\n\t\treturn failures / total >= this.config.failureThreshold / minimumSamples;\n\t}\n\n\tprivate prune(now: number): void {\n\t\tconst cutoff = now - this.config.windowMs;\n\t\tlet drop = 0;\n\t\twhile (drop < this.samples.length && this.samples[drop]!.at < cutoff) drop++;\n\t\tif (drop > 0) this.samples.splice(0, drop);\n\t}\n\n\tprivate transition(to: AdapterCircuitState, reason: AdapterCircuitBreakerEventReason, at: number): void {\n\t\tconst from = this.state;\n\t\tif (from === to) return;\n\t\tthis.state = to;\n\t\tthis.generation++;\n\t\tthis.emit({ type: \"state_change\", key: this.key, mode: this.mode, at, from, to, reason });\n\t}\n\n\tprivate reportedState(): AdapterCircuitState {\n\t\tif (this.manualOverride) return this.manualOverride === \"force_open\" ? \"open\" : \"closed\";\n\t\treturn this.state;\n\t}\n\n\t/**\n\t * Commit an elapsed cooldown as an operation of its own, delivering its\n\t * event before the caller's operation reads state.\n\t */\n\tprivate settle(now: number): void {\n\t\tif (this.manualOverride) return;\n\t\tthis.operation(() => this.advance(now));\n\t}\n\n\t/**\n\t * Run `step` to completion, then deliver the telemetry it produced. The\n\t * return value is fixed before any listener runs.\n\t */\n\tprivate operation<T>(step: () => T): T {\n\t\tthis.operationDepth++;\n\t\ttry {\n\t\t\treturn step();\n\t\t} finally {\n\t\t\tthis.operationDepth--;\n\t\t\tif (this.operationDepth === 0) this.flush();\n\t\t}\n\t}\n\n\tprivate emit(event: AdapterCircuitBreakerEvent): void {\n\t\tif (this.onEvent) this.outbox.push(event);\n\t}\n\n\t/**\n\t * Deliver buffered events in order. A listener that calls back into the\n\t * breaker queues its own events; this loop delivers them after it returns\n\t * instead of recursing.\n\t */\n\tprivate flush(): void {\n\t\tif (this.flushing) return;\n\t\tthis.flushing = true;\n\t\ttry {\n\t\t\tfor (let event = this.outbox.shift(); event; event = this.outbox.shift()) this.deliver(event);\n\t\t} finally {\n\t\t\tthis.flushing = false;\n\t\t}\n\t}\n\n\tprivate deliver(event: AdapterCircuitBreakerEvent): void {\n\t\tconst listener = this.onEvent;\n\t\tif (!listener) return;\n\t\ttry {\n\t\t\tconst result = listener(event);\n\t\t\tif (result && typeof (result as PromiseLike<void>).then === \"function\") {\n\t\t\t\t(result as PromiseLike<void>).then(undefined, () => undefined);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Telemetry must never change an adapter call's outcome.\n\t\t}\n\t}\n}\n\n/** Supplies the breaker, if any, that guards an adapter. */\nexport interface AdapterCircuitBreakerProvider {\n\tforAdapter(adapter: AdapterImplementation): AdapterCircuitBreaker | undefined;\n}\n\nexport interface AdapterCircuitBreakerRegistryOptions {\n\t/** Epoch-millisecond clock handed to every breaker. Defaults to `Date.now`. */\n\tnow?: () => number;\n\tonEvent?: AdapterCircuitBreakerEventListener;\n}\n\n/**\n * Lazily creates one {@link InMemoryAdapterCircuitBreaker} per\n * `adapterType:operation`, from that adapter's own `circuitBreaker` config.\n * Adapters without a config get no breaker. The first config seen for a key\n * wins; share a registry only between hosts that register the same adapters.\n */\nexport class AdapterCircuitBreakerRegistry implements AdapterCircuitBreakerProvider {\n\tprivate readonly breakers = new Map<string, InMemoryAdapterCircuitBreaker>();\n\n\tconstructor(private readonly options: AdapterCircuitBreakerRegistryOptions = {}) {}\n\n\tforAdapter(adapter: AdapterImplementation): InMemoryAdapterCircuitBreaker | undefined {\n\t\tif (!adapter.circuitBreaker) return undefined;\n\t\tconst key = `${adapter.adapterType}:${adapter.operation}`;\n\t\tlet breaker = this.breakers.get(key);\n\t\tif (!breaker) {\n\t\t\tbreaker = new InMemoryAdapterCircuitBreaker({\n\t\t\t\tkey,\n\t\t\t\tconfig: adapter.circuitBreaker,\n\t\t\t\t...(this.options.now ? { now: this.options.now } : {}),\n\t\t\t\t...(this.options.onEvent ? { onEvent: this.options.onEvent } : {}),\n\t\t\t});\n\t\t\tthis.breakers.set(key, breaker);\n\t\t}\n\t\treturn breaker;\n\t}\n\n\t/** The breaker already created for `adapterType:operation`, if any. */\n\tget(adapterType: string, operation: string): InMemoryAdapterCircuitBreaker | undefined {\n\t\treturn this.breakers.get(`${adapterType}:${operation}`);\n\t}\n}\n\n/**\n * Thrown by `executeWithAdapterRetry` when an `enforce`-mode breaker refuses\n * an attempt. The refused attempt never reached `execute`, so no external\n * effect happened for it.\n */\nexport class AdapterCircuitOpenError extends Error {\n\toverride readonly name = \"AdapterCircuitOpenError\";\n\treadonly code = \"ADAPTER_CIRCUIT_OPEN\" as const;\n\treadonly reason = \"circuit_open\" as const;\n\treadonly adapterKey: string;\n\treadonly state: AdapterCircuitState;\n\t/** The attempt number that was refused (1 = refused before any call). */\n\treadonly attempt: number;\n\treadonly retryAfterMs?: number;\n\treadonly manualOverride?: AdapterCircuitBreakerManualOverride;\n\t/** Error of the previous attempt, when the breaker opened mid-retry. */\n\treadonly lastError?: string;\n\n\tconstructor(input: {\n\t\tadapterKey: string;\n\t\tstate: AdapterCircuitState;\n\t\tattempt: number;\n\t\tretryAfterMs?: number;\n\t\tmanualOverride?: AdapterCircuitBreakerManualOverride;\n\t\tlastError?: string;\n\t}) {\n\t\tconst after = input.retryAfterMs !== undefined ? `; retry after ${input.retryAfterMs} ms` : \"\";\n\t\tsuper(`Adapter circuit is ${input.state === \"half_open\" ? \"half-open with its probe in flight\" : \"open\"} for ${input.adapterKey}; the call was not attempted${after}.`);\n\t\tthis.adapterKey = input.adapterKey;\n\t\tthis.state = input.state;\n\t\tthis.attempt = input.attempt;\n\t\tif (input.retryAfterMs !== undefined) this.retryAfterMs = input.retryAfterMs;\n\t\tif (input.manualOverride !== undefined) this.manualOverride = input.manualOverride;\n\t\tif (input.lastError !== undefined) this.lastError = input.lastError;\n\t}\n}\n\n/**\n * Recognise an {@link AdapterCircuitOpenError}, including one constructed by a\n * second copy of this package (for example an ESM and a CommonJS build loaded\n * side by side), where `instanceof` fails.\n */\nexport function isAdapterCircuitOpenError(error: unknown): error is AdapterCircuitOpenError {\n\tif (error instanceof AdapterCircuitOpenError) return true;\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error as { name?: unknown }).name === \"AdapterCircuitOpenError\" &&\n\t\t(error as { code?: unknown }).code === \"ADAPTER_CIRCUIT_OPEN\"\n\t);\n}\n","import {\n\tAdapterCircuitOpenError,\n\tclassifyCircuitBreakerOutcome,\n\ttype AdapterCircuitAdmission,\n\ttype AdapterCircuitBreaker,\n\ttype AdapterCircuitOutcome,\n} from \"./circuit-breaker\";\n\nexport * from \"./circuit-breaker\";\n\nexport interface AdapterExecutionContext {\n\ttenantId: string;\n\tspaceId: string;\n\tactionInvocationId: string;\n\tadapterInvocationId: string;\n\tcorrelationId: string;\n\tcausationId?: string;\n\tattempt: number;\n\tmaxAttempts: number;\n\t/** Epoch-millis deadline after which the adapter should abandon the call. */\n\tdeadlineMs?: number;\n\t/** Set by the host when the invocation has been cancelled; adapters should stop work. */\n\tcancelled?: boolean;\n\t/** Non-secret reason the invocation was cancelled. */\n\tcancellationReason?: string;\n\t/**\n\t * AbortSignal the host aborts when the deadline expires or the invocation is\n\t * cancelled. Adapters should propagate this to underlying HTTP/database\n\t * clients so in-flight work is abandoned rather than left dangling.\n\t */\n\tsignal?: AbortSignal;\n}\n\n/**\n * Additive classification of an adapter outcome so the retry layer can\n * distinguish retryable transient failures from permanent rejections,\n * timeouts, and ambiguous results that require manual reconciliation.\n *\n * When `outcome` is absent on an {@link AdapterExecutionResult}, the retry\n * layer treats a non-success result as `transient_failure` for backward\n * compatibility.\n */\nexport type AdapterOutcomeKind =\n\t| \"success\"\n\t| \"transient_failure\"\n\t| \"permanent_failure\"\n\t| \"timeout\"\n\t| \"ambiguous\";\n\n/**\n * Durable, non-secret evidence attached to a classified adapter outcome.\n * Used by the host to record reconciliation evidence when an adapter returns\n * an ambiguous result whose external effect may or may not have been applied.\n */\nexport interface AdapterOutcomeEvidence {\n\tkind: AdapterOutcomeKind;\n\treason?: string;\n\t/** Opaque, non-secret reference to external operation state for reconciliation. */\n\texternalReference?: string;\n\t/** Whether the external effect may have been applied (true for ambiguous/timeout). */\n\teffectMayHaveApplied?: boolean;\n\tobservedAt: Date | string;\n}\n\n/**\n * An adapter handed the work to an external system that will finish it later.\n *\n * Explicit rather than inferred from evidence: a successful adapter call that\n * merely records a reference is not the same as one that has left the outcome\n * in someone else's hands. The host keeps the invocation running and expects a\n * completion carrying this reference through its completion ingress.\n */\nexport interface AcceptedExternalOperation {\n\t/** Opaque, non-secret reference the external system will complete by. */\n\texternalReference: string;\n\t/** When the external system said it expects to finish, if it said. */\n\texpectedBy?: Date | string;\n}\n\nexport interface AdapterExecutionResult {\n\tsuccess: boolean;\n\tcorrelationId?: string;\n\terror?: string;\n\t/** Additive outcome classification. Omitted = infer from `success`. */\n\toutcome?: AdapterOutcomeKind;\n\t/** Durable evidence for ambiguous or timeout outcomes requiring reconciliation. */\n\toutcomeEvidence?: AdapterOutcomeEvidence;\n\t/** Present when a successful call handed the work off to finish elsewhere. */\n\tacceptedExternalOperation?: AcceptedExternalOperation;\n}\n\nexport type AdapterExecutor = (\n\tinput: Record<string, unknown>,\n\tcontext: AdapterExecutionContext,\n) => Promise<AdapterExecutionResult>;\n\nexport interface AdapterRetryPolicy {\n\t/** External calls must explicitly opt into retry by being idempotent. */\n\tidempotent: boolean;\n\t/** Total attempts including the first call. Non-idempotent policies are forced to 1. */\n\tmaxAttempts?: number;\n\t/** First backoff delay in milliseconds. */\n\tinitialDelayMs?: number;\n\t/** Exponential multiplier applied after each failed attempt. */\n\tbackoffMultiplier?: number;\n\t/** Upper bound for any single retry delay in milliseconds. */\n\tmaxDelayMs?: number;\n}\n\nexport interface ResolvedAdapterRetryPolicy {\n\tidempotent: boolean;\n\tmaxAttempts: number;\n\tinitialDelayMs: number;\n\tbackoffMultiplier: number;\n\tmaxDelayMs: number;\n}\n\n/** Manual circuit-breaker override: pin the breaker open or closed. */\nexport type AdapterCircuitBreakerManualOverride = \"force_open\" | \"force_closed\";\n\n/**\n * Per-adapter circuit-breaker configuration, read by\n * {@link AdapterCircuitBreakerRegistry} (and so by Platform Host) to create one\n * in-process {@link InMemoryAdapterCircuitBreaker} per `adapterType:operation`.\n * Validated by {@link assertAdapterCircuitBreakerConfig}.\n */\nexport interface AdapterCircuitBreakerConfig {\n\t/**\n\t * `monitor` records outcomes, runs the state machine and reports what it\n\t * would have refused, but never blocks a call. `enforce` refuses calls\n\t * while the breaker is open, without attempting them.\n\t */\n\tmode: \"monitor\" | \"enforce\";\n\t/**\n\t * A failure count. Let `M = minimumSamples ?? failureThreshold`. Once at\n\t * least `M` outcomes fall within `windowMs`, the breaker opens when the most\n\t * recent `failureThreshold` of them are all failures, or when the failure\n\t * ratio in the window reaches `failureThreshold / M`. Without\n\t * `minimumSamples` this is \"`failureThreshold` consecutive failures\".\n\t * Matches the .NET port's `InMemoryAdapterCircuitBreaker`. Positive integer.\n\t */\n\tfailureThreshold: number;\n\t/** Rolling window, in milliseconds, of outcomes the thresholds consider. */\n\twindowMs: number;\n\t/** Milliseconds an open breaker waits before admitting one half-open probe. */\n\tcooldownMs: number;\n\t/** Outcomes required in the window before the breaker can open. Defaults to `failureThreshold`. */\n\tminimumSamples?: number;\n\t/**\n\t * How long, in milliseconds, the single half-open probe holds its slot\n\t * before it is presumed lost and another call may probe. Defaults to\n\t * `max(cooldownMs, windowMs)`; it is independent of `cooldownMs`, so a zero\n\t * or short cooldown never admits concurrent probes. Positive.\n\t */\n\tprobeLeaseMs?: number;\n\t/**\n\t * Optional initial manual override. `force_open` reports `open` (and blocks\n\t * only in `enforce` mode); `force_closed` reports `closed` and never blocks.\n\t * Change it at runtime with `InMemoryAdapterCircuitBreaker.setManualOverride`.\n\t */\n\tmanualOverride?: AdapterCircuitBreakerManualOverride;\n}\n\nexport interface AdapterImplementation {\n\tadapterType: string;\n\toperation: string;\n\tvendor: string;\n\t/** Whether this adapter operation can be safely retried by default. */\n\tidempotent: boolean;\n\tretryPolicy?: AdapterRetryPolicy;\n\t/** Defaults to monitor-only; enforce mode must be explicitly configured. */\n\tcircuitBreaker?: AdapterCircuitBreakerConfig;\n\texecute: AdapterExecutor;\n}\n\nexport interface AdapterAttempt<T> {\n\tattempt: number;\n\tresult?: T;\n\terror?: string;\n\twillRetry: boolean;\n\tnextDelayMs?: number;\n}\n\nexport interface ExecuteWithRetryOptions<T> {\n\tpolicy?: AdapterRetryPolicy;\n\tdefaultIdempotent: boolean;\n\texecute: (attempt: number, maxAttempts: number) => Promise<T>;\n\tisSuccessful: (result: T) => boolean;\n\tgetError: (result: T) => string | undefined;\n\t/**\n\t * Optional outcome classifier. When provided, the retry layer retries only\n\t * `transient_failure` outcomes (and only when the policy is idempotent).\n\t * `permanent_failure`, `timeout`, and `ambiguous` outcomes are never retried.\n\t * When omitted, all non-success results are treated as transient (backward compatible).\n\t */\n\tclassifyOutcome?: (result: T) => AdapterOutcomeKind;\n\t/**\n\t * Optional classifier for errors thrown by the execute callback (not returned\n\t * as results). When provided, the retry layer retries only `transient_failure`\n\t * classifications. When omitted, thrown errors are never retried — the caller\n\t * must explicitly opt into retrying a thrown failure by classifying it.\n\t */\n\tclassifyThrownError?: (error: unknown) => AdapterOutcomeKind;\n\tsleep?: (delayMs: number) => Promise<void>;\n\tonAttempt?: (attempt: AdapterAttempt<T>) => Promise<void> | void;\n\t/**\n\t * Optional per-attempt preparation, awaited before the circuit breaker is\n\t * consulted and before `execute` (for example, persisting the attempt\n\t * number). Put every await a caller needs before the call here, so that\n\t * nothing awaits between breaker admission and the external call. If it\n\t * throws, no admission is taken and no breaker outcome is recorded; the\n\t * error is classified with `classifyThrownError` and retried or rethrown\n\t * exactly like an error thrown by `execute`.\n\t */\n\tprepareAttempt?: (attempt: number, maxAttempts: number) => Promise<void> | void;\n\t/**\n\t * Optional circuit breaker. When present, `acquire()` is called\n\t * immediately before every `execute` call, with no await in between, and every attempt's outcome is\n\t * recorded through {@link classifyCircuitBreakerOutcome}. In `enforce` mode\n\t * a refused attempt is not executed and {@link AdapterCircuitOpenError} is\n\t * thrown; if the breaker opens between attempts, retrying stops and the\n\t * same error is thrown. When omitted, behaviour is unchanged.\n\t */\n\tcircuitBreaker?: AdapterCircuitBreaker;\n}\n\nfunction adapterKey(adapterType: string, operation: string): string {\n\treturn `${adapterType}:${operation}`;\n}\n\nexport class MissingAdapterRegistrationError extends Error {\n\tconstructor(adapterType: string, operation: string) {\n\t\tsuper(`No adapter registered for adapterType \"${adapterType}\" and operation \"${operation}\"`);\n\t\tthis.name = \"MissingAdapterRegistrationError\";\n\t}\n}\n\nexport class AdapterRegistry {\n\tprivate readonly adapters = new Map<string, AdapterImplementation>();\n\n\tregister(adapter: AdapterImplementation): void {\n\t\tconst key = adapterKey(adapter.adapterType, adapter.operation);\n\t\tif (this.adapters.has(key)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter already registered for adapterType \"${adapter.adapterType}\" and operation \"${adapter.operation}\"`,\n\t\t\t);\n\t\t}\n\n\t\tthis.adapters.set(key, adapter);\n\t}\n\n\tresolve(adapterType: string, operation: string): AdapterImplementation | undefined {\n\t\treturn this.adapters.get(adapterKey(adapterType, operation));\n\t}\n\n\trequire(adapterType: string, operation: string): AdapterImplementation {\n\t\tconst adapter = this.resolve(adapterType, operation);\n\t\tif (!adapter) {\n\t\t\tthrow new MissingAdapterRegistrationError(adapterType, operation);\n\t\t}\n\n\t\treturn adapter;\n\t}\n}\n\nconst DEFAULT_RETRY_POLICY: ResolvedAdapterRetryPolicy = {\n\tidempotent: true,\n\tmaxAttempts: 3,\n\tinitialDelayMs: 100,\n\tbackoffMultiplier: 2,\n\tmaxDelayMs: 1_000,\n};\n\nconst NO_RETRY_POLICY: ResolvedAdapterRetryPolicy = {\n\tidempotent: false,\n\tmaxAttempts: 1,\n\tinitialDelayMs: 0,\n\tbackoffMultiplier: 1,\n\tmaxDelayMs: 0,\n};\n\nexport function resolveAdapterRetryPolicy(\n\tpolicy: AdapterRetryPolicy | undefined,\n\tdefaultIdempotent: boolean,\n): ResolvedAdapterRetryPolicy {\n\tconst idempotent = policy?.idempotent ?? defaultIdempotent;\n\n\tif (!idempotent) {\n\t\treturn NO_RETRY_POLICY;\n\t}\n\n\treturn {\n\t\tidempotent: true,\n\t\tmaxAttempts: Math.max(1, Math.min(policy?.maxAttempts ?? DEFAULT_RETRY_POLICY.maxAttempts, 5)),\n\t\tinitialDelayMs: Math.max(0, policy?.initialDelayMs ?? DEFAULT_RETRY_POLICY.initialDelayMs),\n\t\tbackoffMultiplier: Math.max(\n\t\t\t1,\n\t\t\tpolicy?.backoffMultiplier ?? DEFAULT_RETRY_POLICY.backoffMultiplier,\n\t\t),\n\t\tmaxDelayMs: Math.max(0, policy?.maxDelayMs ?? DEFAULT_RETRY_POLICY.maxDelayMs),\n\t};\n}\n\nexport function getRetryDelayMs(attempt: number, policy: ResolvedAdapterRetryPolicy): number {\n\tconst exponentialDelay =\n\t\tpolicy.initialDelayMs * policy.backoffMultiplier ** Math.max(0, attempt - 1);\n\n\treturn Math.min(exponentialDelay, policy.maxDelayMs);\n}\n\n/**\n * Classify an {@link AdapterExecutionResult} into an {@link AdapterOutcomeKind}.\n * When `outcome` is explicitly set, it is returned directly, after rejecting a\n * contradictory result where `success` is true but the outcome is non-success.\n * Otherwise a successful result maps to `success` and a failed result maps to\n * `transient_failure` (the historical default).\n */\nexport function classifyAdapterOutcome(result: AdapterExecutionResult): AdapterOutcomeKind {\n\tif (result.outcome) {\n\t\tassertAdapterOutcomeConsistency(result);\n\t\treturn result.outcome;\n\t}\n\treturn result.success ? \"success\" : \"transient_failure\";\n}\n\n/**\n * Determine whether an outcome kind is retryable. Only `transient_failure`\n * is retryable, and only when the adapter policy is idempotent. Permanent\n * failures, timeouts, and ambiguous outcomes are never retried.\n */\nexport function shouldRetryAdapterOutcome(\n\tkind: AdapterOutcomeKind,\n\tidempotent: boolean,\n): boolean {\n\treturn kind === \"transient_failure\" && idempotent;\n}\n\n/**\n * Reject a contradictory adapter result where `success` is true but the\n * explicit `outcome` is a non-success kind. A successful result claiming an\n * ambiguous, permanent, timeout, or transient outcome is a programming\n * error — the adapter cannot have both succeeded and require reconciliation.\n */\nexport function assertAdapterOutcomeConsistency(result: AdapterExecutionResult): void {\n\tif (result.success && result.outcome && result.outcome !== \"success\") {\n\t\tthrow new Error(\n\t\t\t`Adapter returned success=true with contradictory outcome \"${result.outcome}\"; a successful result must not declare a non-success outcome.`,\n\t\t);\n\t}\n}\n\n/**\n * Record an outcome on the breaker. A breaker that throws must not turn a\n * call that already ran (and may have had its external effect) into a failure.\n */\nfunction recordCircuitOutcome(\n\tbreaker: AdapterCircuitBreaker | undefined,\n\toutcome: AdapterCircuitOutcome,\n\tadmission: AdapterCircuitAdmission | undefined,\n): void {\n\tif (!breaker) return;\n\ttry {\n\t\tbreaker.record(outcome, admission);\n\t} catch {\n\t\t// Breaker bookkeeping is best effort once the call has happened.\n\t}\n}\n\nfunction circuitOpenError(\n\tbreaker: AdapterCircuitBreaker,\n\tadmission: AdapterCircuitAdmission,\n\tattempt: number,\n\tlastError: string | undefined,\n): AdapterCircuitOpenError {\n\treturn new AdapterCircuitOpenError({\n\t\tadapterKey: breaker.key,\n\t\tstate: admission.state,\n\t\tattempt,\n\t\t...(admission.retryAfterMs !== undefined ? { retryAfterMs: admission.retryAfterMs } : {}),\n\t\t...(admission.manualOverride !== undefined ? { manualOverride: admission.manualOverride } : {}),\n\t\t...(lastError !== undefined ? { lastError } : {}),\n\t});\n}\n\nexport async function executeWithAdapterRetry<T>(options: ExecuteWithRetryOptions<T>): Promise<T> {\n\tconst policy = resolveAdapterRetryPolicy(options.policy, options.defaultIdempotent);\n\tconst sleep =\n\t\toptions.sleep ?? ((delayMs) => new Promise((resolve) => setTimeout(resolve, delayMs)));\n\tconst breaker = options.circuitBreaker;\n\tlet lastError: string | undefined;\n\n\tfor (let attempt = 1; attempt <= policy.maxAttempts; attempt++) {\n\t\tlet admission: AdapterCircuitAdmission | undefined;\n\t\t// One outcome per attempt reaches the breaker, and only for an attempt\n\t\t// that reached `execute`; a later step of this iteration (onAttempt,\n\t\t// sleep) that throws into the catch below does not record a second one.\n\t\tlet executed = false;\n\t\tlet recorded = false;\n\t\tconst record = (outcome: AdapterCircuitOutcome) => {\n\t\t\tif (!executed || recorded) return;\n\t\t\trecorded = true;\n\t\t\trecordCircuitOutcome(breaker, outcome, admission);\n\t\t};\n\t\tlet refusal: AdapterCircuitAdmission | undefined;\n\t\t/**\n\t\t * Classify an error thrown by `prepareAttempt`, `execute` or a later\n\t\t * step of this attempt. Returns \"retry\" after sleeping, \"rethrow\", or the\n\t\t * breaker admission that refuses the retry.\n\t\t */\n\t\tasync function handleThrown(error: unknown): Promise<\"retry\" | \"rethrow\" | AdapterCircuitAdmission> {\n\t\t\tlastError = error instanceof Error ? error.message : String(error);\n\t\t\t// Preserve the pre-classification contract for direct callers. The\n\t\t\t// governed Host supplies a classifier and therefore remains fail-closed\n\t\t\t// for ambiguous, timeout, and permanent failures.\n\t\t\tconst thrownOutcome = options.classifyThrownError\n\t\t\t\t? options.classifyThrownError(error)\n\t\t\t\t: \"transient_failure\" as const;\n\t\t\trecord(classifyCircuitBreakerOutcome(thrownOutcome));\n\t\t\tlet willRetry =\n\t\t\t\tshouldRetryAdapterOutcome(thrownOutcome, policy.idempotent) && attempt < policy.maxAttempts;\n\t\t\tconst blocked = willRetry ? refusedRetry(breaker) : undefined;\n\t\t\tif (blocked) willRetry = false;\n\t\t\tconst nextDelayMs = willRetry ? getRetryDelayMs(attempt, policy) : undefined;\n\t\t\tawait options.onAttempt?.({ attempt, error: lastError, willRetry, nextDelayMs });\n\n\t\t\tif (blocked) return blocked;\n\t\t\tif (!willRetry) return \"rethrow\";\n\t\t\tawait sleep(nextDelayMs ?? 0);\n\t\t\treturn \"retry\";\n\t\t}\n\n\t\ttry {\n\t\t\tif (options.prepareAttempt) await options.prepareAttempt(attempt, policy.maxAttempts);\n\t\t} catch (error) {\n\t\t\tconst decision = await handleThrown(error);\n\t\t\tif (decision === \"rethrow\") throw error;\n\t\t\tif (decision === \"retry\") continue;\n\t\t\trefusal = decision;\n\t\t}\n\t\tif (!refusal) {\n\t\t\t// Admission sits immediately before the external call: no await between.\n\t\t\tif (breaker) {\n\t\t\t\tadmission = breaker.acquire();\n\t\t\t\tif (!admission.allowed) throw circuitOpenError(breaker, admission, attempt, lastError);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\texecuted = true;\n\t\t\t\tconst result = await options.execute(attempt, policy.maxAttempts);\n\t\t\t\tif (options.isSuccessful(result)) {\n\t\t\t\t\trecord(\"success\");\n\t\t\t\t\tawait options.onAttempt?.({ attempt, result, willRetry: false });\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tlastError = options.getError(result) ?? \"Adapter returned unsuccessful result\";\n\t\t\t\tconst outcome = options.classifyOutcome\n\t\t\t\t\t? options.classifyOutcome(result)\n\t\t\t\t\t: \"transient_failure\" as const;\n\t\t\t\trecord(classifyCircuitBreakerOutcome(outcome));\n\t\t\t\tlet willRetry =\n\t\t\t\t\tshouldRetryAdapterOutcome(outcome, policy.idempotent) && attempt < policy.maxAttempts;\n\t\t\t\trefusal = willRetry ? refusedRetry(breaker) : undefined;\n\t\t\t\tif (refusal) willRetry = false;\n\t\t\t\tconst nextDelayMs = willRetry ? getRetryDelayMs(attempt, policy) : undefined;\n\t\t\t\tawait options.onAttempt?.({ attempt, result, error: lastError, willRetry, nextDelayMs });\n\n\t\t\t\tif (!willRetry && !refusal) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (!refusal) await sleep(nextDelayMs ?? 0);\n\t\t\t} catch (error) {\n\t\t\t\tconst decision = await handleThrown(error);\n\t\t\t\tif (decision === \"rethrow\") throw error;\n\t\t\t\trefusal = decision === \"retry\" ? undefined : decision;\n\t\t\t}\n\t\t}\n\t\t// The breaker opened on this attempt's outcome: stop instead of retrying.\n\t\tif (refusal && breaker) throw circuitOpenError(breaker, refusal, attempt + 1, lastError);\n\t}\n\n\tthrow new Error(lastError ?? \"Adapter retry exhausted\");\n}\n\n/**\n * Preview whether an `enforce`-mode breaker would refuse the next attempt.\n * Returns the refusing admission, or undefined when the retry may proceed.\n */\nfunction refusedRetry(breaker: AdapterCircuitBreaker | undefined): AdapterCircuitAdmission | undefined {\n\tif (!breaker) return undefined;\n\tconst preview = breaker.check();\n\treturn preview.allowed ? undefined : preview;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWQ3BYI7T_cjs = require('./chunk-WQ3BYI7T.cjs');
|
|
4
4
|
|
|
5
5
|
// certification/index.ts
|
|
6
6
|
var STRICT_EXECUTION_CONTRACT_PROFILE_ID = "fabric.execution-contract.strict";
|
|
@@ -80,7 +80,7 @@ function executionContractProfile(options = {}) {
|
|
|
80
80
|
id,
|
|
81
81
|
validate,
|
|
82
82
|
assert(subject) {
|
|
83
|
-
const manifest = isManifest(subject) ? subject :
|
|
83
|
+
const manifest = isManifest(subject) ? subject : chunkWQ3BYI7T_cjs.exportModuleManifest(subject);
|
|
84
84
|
const findings = validate(manifest);
|
|
85
85
|
if (findings.length > 0) {
|
|
86
86
|
throw new Error(`Execution-contract profile "${id}" failed for "${manifest.namespace}":
|
|
@@ -98,5 +98,5 @@ function isManifest(subject) {
|
|
|
98
98
|
exports.STRICT_EXECUTION_CONTRACT_PROFILE = STRICT_EXECUTION_CONTRACT_PROFILE;
|
|
99
99
|
exports.STRICT_EXECUTION_CONTRACT_PROFILE_ID = STRICT_EXECUTION_CONTRACT_PROFILE_ID;
|
|
100
100
|
exports.executionContractProfile = executionContractProfile;
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
101
|
+
//# sourceMappingURL=chunk-MCWSUGB3.cjs.map
|
|
102
|
+
//# sourceMappingURL=chunk-MCWSUGB3.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../certification/index.ts"],"names":["exportModuleManifest"],"mappings":";;;;;AA+CO,IAAM,oCAAA,GAAuC;AAGpD,SAAS,mBAAA,GAAqE;AAC7E,EAAA,OAAO;AAAA,IACN,CAAC,gCAAgB,IAAI,GAAA,CAAI,CAAC,iBAAA,EAAmB,oBAAoB,CAAC,CAAC,CAAA;AAAA,IACnE,CAAC,mCAAmB,IAAI,GAAA,CAAI,CA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AA,MAAM,WAAW,UAAA,CAAW,OAAO,CAAA,GAAI,OAAA,GAAUA,uCAAqB,OAAO,CAAA;AAC7E,MAAA,MAAM,QAAA,GAAW,SAAS,QAAQ,CAAA;AAClC,MAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACxB,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,EAAE,CAAA,cAAA,EAAiB,SAAS,SAAS,CAAA;AAAA,EAAO,QAAA,CAAS,GAAA,CAAI,CAAC,OAAA,KAAY,CAAA,EAAA,EAAK,OAAA,CAAQ,OAAO,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,MAC1J;AAAA,IACD,CAAA;AAAA,IACA,OAAA,EAAS,EAAE,EAAA,EAAI,QAAA,EAAU,QAAA;AAAS,GACnC;AACD;AAGO,IAAM,oCAA8D,wBAAA;AAE3E,SAAS,WAAW,OAAA,EAA4E;AAC/F,EAAA,OAAO,OAAQ,OAAA,CAA2B,eAAA,KAAoB,YAAY,KAAA,CAAM,OAAA,CAAS,QAA2B,OAAO,CAAA;AAC5H","file":"chunk-XS7EUS4T.cjs","sourcesContent":["import type { ActionCompletionMode } from \"../actions\";\nimport { exportModuleManifest, type ModuleManifest } from \"../manifest\";\nimport type { FabricModule } from \"../modules\";\n\n// ── Execution-contract certification ────────────────────────────────────────\n//\n// The base types keep the execution contract optional, because making it\n// mandatory is a break for every existing manifest. A deployment that wants\n// the guarantee applies a profile at certification instead: every governed\n// action declares all six dimensions, and any action that hands work to an\n// external system says how long it may wait. The profile is a seam a\n// vertical applies, not content the platform assumes.\n\nexport type ExecutionContractFindingCode =\n\t| \"missing_execution_contract\"\n\t| \"invalid_execution_dimension\"\n\t| \"missing_sensitivity\"\n\t| \"missing_completion_deadline\"\n\t| \"unexpected_completion_deadline\";\n\nexport interface ExecutionContractFinding {\n\tcode: ExecutionContractFindingCode;\n\tactionId: string;\n\tmessage: string;\n}\n\nexport interface ExecutionContractProfileOptions {\n\t/** Adapter and profile id. Defaults to the strict profile's id. */\n\tid?: string;\n\t/** Require `sensitivity`, which the base contract leaves optional. Defaults to true. */\n\trequireSensitivity?: boolean;\n\t/**\n\t * Completion modes that must declare `completionDeadlineMs`. Defaults to\n\t * both modes that hand work off, since without a deadline nothing sweeps a\n\t * callback that never comes.\n\t */\n\trequireDeadlineFor?: readonly ActionCompletionMode[];\n}\n\nexport interface ExecutionContractProfile {\n\treadonly id: string;\n\tvalidate(manifest: ModuleManifest): ExecutionContractFinding[];\n\tassert(subject: FabricModule<unknown> | ModuleManifest): void;\n\t/** For certification tooling: the compiler's conformance adapter shape. */\n\treadonly adapter: { id: string; evaluate(manifest: ModuleManifest): ExecutionContractFinding[] };\n}\n\nexport const STRICT_EXECUTION_CONTRACT_PROFILE_ID = \"fabric.execution-contract.strict\";\n\n/** The permitted values of each required dimension, mirrored from the action types. */\nfunction permittedDimensions(): ReadonlyArray<[string, ReadonlySet<unknown>]> {\n\treturn [\n\t\t[\"connectivity\", new Set([\"online-required\", \"offline-capturable\"])],\n\t\t[\"authorityMoment\", new Set([\"capture\", \"execution\", \"both\"])],\n\t\t[\"idempotency\", new Set([\"required\", \"supported\", \"prohibited\"])],\n\t\t[\"completion\", new Set([\"immediate\", \"accepted\", \"long-running\"])],\n\t\t[\"consistency\", new Set([\"authoritative-now\", \"provisional-until-reconciled\"])],\n\t];\n}\nconst permittedSensitivities = (): ReadonlySet<string> => new Set([\"public\", \"internal\", \"confidential\", \"restricted\"]);\n\nexport function executionContractProfile(options: ExecutionContractProfileOptions = {}): ExecutionContractProfile {\n\tconst id = options.id ?? STRICT_EXECUTION_CONTRACT_PROFILE_ID;\n\tconst requireSensitivity = options.requireSensitivity ?? true;\n\tconst requireDeadlineFor = new Set<ActionCompletionMode>(options.requireDeadlineFor ?? [\"accepted\", \"long-running\"]);\n\tconst dimensions = permittedDimensions();\n\tconst sensitivities = permittedSensitivities();\n\tconst validate = (manifest: ModuleManifest): ExecutionContractFinding[] => {\n\t\tconst findings: ExecutionContractFinding[] = [];\n\t\tfor (const action of manifest.actions) {\n\t\t\tconst contract = action.execution;\n\t\t\tif (!contract) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"missing_execution_contract\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares no execution contract; connectivity, authorityMoment, idempotency, completion, and consistency are required.`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// The contract's presence proves nothing about its content: a manifest\n\t\t\t// reaches certification without passing through the registry, so each\n\t\t\t// dimension is checked against its permitted values here.\n\t\t\tlet complete = true;\n\t\t\tfor (const [dimension, permitted] of dimensions) {\n\t\t\t\tconst value = (contract as unknown as Record<string, unknown>)[dimension];\n\t\t\t\tif (!permitted.has(value)) {\n\t\t\t\t\tcomplete = false;\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tcode: \"invalid_execution_dimension\",\n\t\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\t\tmessage: `Action \"${action.actionId}\" ${value === undefined ? \"declares no\" : `declares an unknown`} ${dimension}${value === undefined ? \"\" : ` \"${String(value)}\"`}; permitted values are ${[...permitted].map((item) => `\"${String(item)}\"`).join(\", \")}.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (contract.sensitivity !== undefined && !sensitivities.has(contract.sensitivity)) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"invalid_execution_dimension\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares an unknown sensitivity \"${String(contract.sensitivity)}\"; permitted values are ${[...sensitivities].map((item) => `\"${item}\"`).join(\", \")}.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!complete) continue;\n\t\t\tif (contract.completion === \"immediate\" && contract.completionDeadlineMs !== undefined) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"unexpected_completion_deadline\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares immediate completion and a completionDeadlineMs; nothing external completes it.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (requireSensitivity && contract.sensitivity === undefined) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"missing_sensitivity\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares no sensitivity; say whether its durable data is public, internal, confidential, or restricted.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (requireDeadlineFor.has(contract.completion) && !(typeof contract.completionDeadlineMs === \"number\" && contract.completionDeadlineMs > 0)) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"missing_completion_deadline\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares ${contract.completion} completion and no completionDeadlineMs; a callback that never comes would never be noticed.`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn findings;\n\t};\n\treturn {\n\t\tid,\n\t\tvalidate,\n\t\tassert(subject) {\n\t\t\tconst manifest = isManifest(subject) ? subject : exportModuleManifest(subject);\n\t\t\tconst findings = validate(manifest);\n\t\t\tif (findings.length > 0) {\n\t\t\t\tthrow new Error(`Execution-contract profile \"${id}\" failed for \"${manifest.namespace}\":\\n${findings.map((finding) => `- ${finding.message}`).join(\"\\n\")}`);\n\t\t\t}\n\t\t},\n\t\tadapter: { id, evaluate: validate },\n\t};\n}\n\n/** All six dimensions on every action, and a deadline wherever work is handed off. */\nexport const STRICT_EXECUTION_CONTRACT_PROFILE: ExecutionContractProfile = executionContractProfile();\n\nfunction isManifest(subject: FabricModule<unknown> | ModuleManifest): subject is ModuleManifest {\n\treturn typeof (subject as ModuleManifest).manifestVersion === \"number\" && Array.isArray((subject as ModuleManifest).actions);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../certification/index.ts"],"names":["exportModuleManifest"],"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CAAO,QAAQ,CAAA,WAAA,EAAc,SAAS,UAAU,CAAA,4FAAA;AAAA,SACpE,CAAA;AAAA,MACF;AAAA,IACD;AACA,IAAA,OAAO,QAAA;AAAA,EACR,CAAA;AACA,EAAA,OAAO;AAAA,IACN,EAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAO,OAAA,EAAS;AACf,MAAA,MAAM,WAAW,UAAA,CAAW,OAAO,CAAA,GAAI,OAAA,GAAUA,uCAAqB,OAAO,CAAA;AAC7E,MAAA,MAAM,QAAA,GAAW,SAAS,QAAQ,CAAA;AAClC,MAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACxB,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,EAAE,CAAA,cAAA,EAAiB,SAAS,SAAS,CAAA;AAAA,EAAO,QAAA,CAAS,GAAA,CAAI,CAAC,OAAA,KAAY,CAAA,EAAA,EAAK,OAAA,CAAQ,OAAO,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,MAC1J;AAAA,IACD,CAAA;AAAA,IACA,OAAA,EAAS,EAAE,EAAA,EAAI,QAAA,EAAU,QAAA;AAAS,GACnC;AACD;AAGO,IAAM,oCAA8D,wBAAA;AAE3E,SAAS,WAAW,OAAA,EAA4E;AAC/F,EAAA,OAAO,OAAQ,OAAA,CAA2B,eAAA,KAAoB,YAAY,KAAA,CAAM,OAAA,CAAS,QAA2B,OAAO,CAAA;AAC5H","file":"chunk-MCWSUGB3.cjs","sourcesContent":["import type { ActionCompletionMode } from \"../actions\";\nimport { exportModuleManifest, type ModuleManifest } from \"../manifest\";\nimport type { FabricModule } from \"../modules\";\n\n// ── Execution-contract certification ────────────────────────────────────────\n//\n// The base types keep the execution contract optional, because making it\n// mandatory is a break for every existing manifest. A deployment that wants\n// the guarantee applies a profile at certification instead: every governed\n// action declares all six dimensions, and any action that hands work to an\n// external system says how long it may wait. The profile is a seam a\n// vertical applies, not content the platform assumes.\n\nexport type ExecutionContractFindingCode =\n\t| \"missing_execution_contract\"\n\t| \"invalid_execution_dimension\"\n\t| \"missing_sensitivity\"\n\t| \"missing_completion_deadline\"\n\t| \"unexpected_completion_deadline\";\n\nexport interface ExecutionContractFinding {\n\tcode: ExecutionContractFindingCode;\n\tactionId: string;\n\tmessage: string;\n}\n\nexport interface ExecutionContractProfileOptions {\n\t/** Adapter and profile id. Defaults to the strict profile's id. */\n\tid?: string;\n\t/** Require `sensitivity`, which the base contract leaves optional. Defaults to true. */\n\trequireSensitivity?: boolean;\n\t/**\n\t * Completion modes that must declare `completionDeadlineMs`. Defaults to\n\t * both modes that hand work off, since without a deadline nothing sweeps a\n\t * callback that never comes.\n\t */\n\trequireDeadlineFor?: readonly ActionCompletionMode[];\n}\n\nexport interface ExecutionContractProfile {\n\treadonly id: string;\n\tvalidate(manifest: ModuleManifest): ExecutionContractFinding[];\n\tassert(subject: FabricModule<unknown> | ModuleManifest): void;\n\t/** For certification tooling: the compiler's conformance adapter shape. */\n\treadonly adapter: { id: string; evaluate(manifest: ModuleManifest): ExecutionContractFinding[] };\n}\n\nexport const STRICT_EXECUTION_CONTRACT_PROFILE_ID = \"fabric.execution-contract.strict\";\n\n/** The permitted values of each required dimension, mirrored from the action types. */\nfunction permittedDimensions(): ReadonlyArray<[string, ReadonlySet<unknown>]> {\n\treturn [\n\t\t[\"connectivity\", new Set([\"online-required\", \"offline-capturable\"])],\n\t\t[\"authorityMoment\", new Set([\"capture\", \"execution\", \"both\"])],\n\t\t[\"idempotency\", new Set([\"required\", \"supported\", \"prohibited\"])],\n\t\t[\"completion\", new Set([\"immediate\", \"accepted\", \"long-running\"])],\n\t\t[\"consistency\", new Set([\"authoritative-now\", \"provisional-until-reconciled\"])],\n\t];\n}\nconst permittedSensitivities = (): ReadonlySet<string> => new Set([\"public\", \"internal\", \"confidential\", \"restricted\"]);\n\nexport function executionContractProfile(options: ExecutionContractProfileOptions = {}): ExecutionContractProfile {\n\tconst id = options.id ?? STRICT_EXECUTION_CONTRACT_PROFILE_ID;\n\tconst requireSensitivity = options.requireSensitivity ?? true;\n\tconst requireDeadlineFor = new Set<ActionCompletionMode>(options.requireDeadlineFor ?? [\"accepted\", \"long-running\"]);\n\tconst dimensions = permittedDimensions();\n\tconst sensitivities = permittedSensitivities();\n\tconst validate = (manifest: ModuleManifest): ExecutionContractFinding[] => {\n\t\tconst findings: ExecutionContractFinding[] = [];\n\t\tfor (const action of manifest.actions) {\n\t\t\tconst contract = action.execution;\n\t\t\tif (!contract) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"missing_execution_contract\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares no execution contract; connectivity, authorityMoment, idempotency, completion, and consistency are required.`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// The contract's presence proves nothing about its content: a manifest\n\t\t\t// reaches certification without passing through the registry, so each\n\t\t\t// dimension is checked against its permitted values here.\n\t\t\tlet complete = true;\n\t\t\tfor (const [dimension, permitted] of dimensions) {\n\t\t\t\tconst value = (contract as unknown as Record<string, unknown>)[dimension];\n\t\t\t\tif (!permitted.has(value)) {\n\t\t\t\t\tcomplete = false;\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tcode: \"invalid_execution_dimension\",\n\t\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\t\tmessage: `Action \"${action.actionId}\" ${value === undefined ? \"declares no\" : `declares an unknown`} ${dimension}${value === undefined ? \"\" : ` \"${String(value)}\"`}; permitted values are ${[...permitted].map((item) => `\"${String(item)}\"`).join(\", \")}.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (contract.sensitivity !== undefined && !sensitivities.has(contract.sensitivity)) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"invalid_execution_dimension\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares an unknown sensitivity \"${String(contract.sensitivity)}\"; permitted values are ${[...sensitivities].map((item) => `\"${item}\"`).join(\", \")}.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!complete) continue;\n\t\t\tif (contract.completion === \"immediate\" && contract.completionDeadlineMs !== undefined) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"unexpected_completion_deadline\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares immediate completion and a completionDeadlineMs; nothing external completes it.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (requireSensitivity && contract.sensitivity === undefined) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"missing_sensitivity\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares no sensitivity; say whether its durable data is public, internal, confidential, or restricted.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (requireDeadlineFor.has(contract.completion) && !(typeof contract.completionDeadlineMs === \"number\" && contract.completionDeadlineMs > 0)) {\n\t\t\t\tfindings.push({\n\t\t\t\t\tcode: \"missing_completion_deadline\",\n\t\t\t\t\tactionId: action.actionId,\n\t\t\t\t\tmessage: `Action \"${action.actionId}\" declares ${contract.completion} completion and no completionDeadlineMs; a callback that never comes would never be noticed.`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn findings;\n\t};\n\treturn {\n\t\tid,\n\t\tvalidate,\n\t\tassert(subject) {\n\t\t\tconst manifest = isManifest(subject) ? subject : exportModuleManifest(subject);\n\t\t\tconst findings = validate(manifest);\n\t\t\tif (findings.length > 0) {\n\t\t\t\tthrow new Error(`Execution-contract profile \"${id}\" failed for \"${manifest.namespace}\":\\n${findings.map((finding) => `- ${finding.message}`).join(\"\\n\")}`);\n\t\t\t}\n\t\t},\n\t\tadapter: { id, evaluate: validate },\n\t};\n}\n\n/** All six dimensions on every action, and a deadline wherever work is handed off. */\nexport const STRICT_EXECUTION_CONTRACT_PROFILE: ExecutionContractProfile = executionContractProfile();\n\nfunction isManifest(subject: FabricModule<unknown> | ModuleManifest): subject is ModuleManifest {\n\treturn typeof (subject as ModuleManifest).manifestVersion === \"number\" && Array.isArray((subject as ModuleManifest).actions);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEventTypeName, getObjectTypeName, getModuleDependencyNamespace } from './chunk-
|
|
1
|
+
import { getEventTypeName, getObjectTypeName, getModuleDependencyNamespace } from './chunk-WNZP53GI.js';
|
|
2
2
|
import { assertSurfaceDeclaration } from './chunk-LFE74IJX.js';
|
|
3
3
|
|
|
4
4
|
// manifest/index.ts
|
|
@@ -238,5 +238,5 @@ function exportModuleManifestBundle(modules) {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator, normalizeModuleManifest, normalizeModuleManifestBundle };
|
|
241
|
-
//# sourceMappingURL=chunk-
|
|
242
|
-
//# sourceMappingURL=chunk-
|
|
241
|
+
//# sourceMappingURL=chunk-PDN5DOLQ.js.map
|
|
242
|
+
//# sourceMappingURL=chunk-PDN5DOLQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../manifest/index.ts"],"names":[],"mappings":";;;;AA+BO,IAAM,uBAAA,GAA0B;AAkKhC,SAAS,wBACf,QAAA,EACiB;AACjB,EAAA,MAAM,UAAkB,QAAA,CAAS,eAAA;AACjC,EAAA,IAAI,OAAA,KAAY,CAAA,IAAK,OAAA,KAAY,uBAAA,EAAyB;AACzD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,qCAAA,EAAwC,MAAA,CAAO,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC1E;AACA,EAAA,MAAM,KAAA,GAAQ,OAAA,IAAW,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA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W,MAAA,CAAO,QAAA,IAAY,EAAC,EAC7B,GAAA,CAAI,YAAY,CAAA,CAChB,MAAA,CAAO,CAAC,MAAA,KAA2C,MAAA,KAAW,MAAS,CAAA;AAAA,IACzE,aAAA,EAAA,CAAgB,MAAA,CAAO,aAAA,IAAiB,EAAC,EACvC,GAAA,CAAI,kBAAkB,CAAA,CACtB,MAAA,CAAO,CAAC,OAAA,KAAmD,OAAA,KAAY,MAAS,CAAA;AAAA,IAClF,QAAQ,MAAA,CAAO,KAAA,IAAS,EAAC,EAAG,IAAI,UAAU;AAAA,GAC3C;AAEA,EAAA,IAAI,MAAA,CAAO,OAAA,KAAY,MAAA,EAAW,QAAA,CAAS,UAAU,MAAA,CAAO,OAAA;AAC5D,EAAA,IAAI,MAAA,CAAO,WAAA,KAAgB,MAAA,EAAW,QAAA,CAAS,cAAc,MAAA,CAAO,WAAA;AACpE,EAAA,IAAI,MAAA,CAAO,WAAA,KAAgB,MAAA,EAAW,QAAA,CAAS,cAAc,MAAA,CAAO,WAAA;AACpE,EAAA,IAAI,OAAO,UAAA,KAAe,MAAA,WAAoB,UAAA,GAAa,SAAA,CAAU,OAAO,UAAU,CAAA;AAEtF,EAAA,OAAO,QAAA;AACR;AAMO,SAAS,2BACf,OAAA,EACuB;AACvB,EAAA,OAAO;AAAA,IACN,eAAA,EAAiB,uBAAA;AAAA,IACjB,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,oBAAoB;AAAA,GAC1C;AACD","file":"chunk-QHV6LOS6.js","sourcesContent":["import { assertSurfaceDeclaration, type SurfaceDeclaration } from \"../discovery\";\nimport type {\n\tActionExecutionContract,\n\tActionDefinition,\n\tAdapterStepRetryPolicy,\n\tSchemaValidator,\n} from \"../actions\";\nimport {\n\tgetEventTypeName,\n\tgetModuleDependencyNamespace,\n\tgetObjectTypeName,\n\ttype FabricModule,\n\ttype CapabilityMetadata,\n\ttype DeclarativeInvariant,\n\ttype ModuleDependency,\n\ttype ModuleDependencyInput,\n\ttype ObjectRelationDefinition,\n} from \"../modules\";\nimport type { JsonValue, PortableJsonSchema } from \"../objects\";\nimport type {\n\tDataPolicyDefinition,\n\tPolicyFallbackDefinition,\n\tPolicyKind,\n} from \"../policies\";\nimport type { StateDefinition, StateMachineDefinition } from \"../state-machines\";\nimport type { ViewContract } from \"../projections\";\n\n/**\n * Version of the module manifest contract. Bump when the serialized shape\n * changes in a way consumers must detect.\n */\nexport const MODULE_MANIFEST_VERSION = 2 as const;\n\nexport interface ModuleManifestObjectType {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n\tschema?: PortableJsonSchema;\n\tsemantics?: Record<string, JsonValue>;\n\trelations?: ObjectRelationDefinition[];\n\tinvariants?: DeclarativeInvariant[];\n}\n\nexport interface ModuleManifestIdPrefix {\n\tprefix: string;\n\tname: string;\n}\n\nexport interface ModuleManifestEventType {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n\tschema?: PortableJsonSchema;\n}\n\nexport interface ModuleManifestActionStateMachine {\n\tentityType: string;\n\t/** Present only when the binding declares a static target state. */\n\ttargetState?: string;\n}\n\nexport interface ModuleManifestAdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n}\n\nexport interface ModuleManifestAction extends SurfaceDeclaration {\n\tactionId: string;\n\tversion: number;\n\tkind: \"atomic\" | \"saga\";\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\temitsEvents: string[];\n\tpolicies?: string[];\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\texecution?: ActionExecutionContract;\n\t/**\n\t * JSON Schema for the action parameters, present only when the action's\n\t * `schema` validator implements {@link JsonSchemaExportableValidator}.\n\t */\n\tparameterSchema?: unknown;\n\tparameterSchemaFormat?: \"json-schema\";\n\tresultSchema?: unknown;\n\tresultSchemaFormat?: \"json-schema\";\n\tstateMachine?: ModuleManifestActionStateMachine;\n\tadapterSteps?: ModuleManifestAdapterStep[];\n}\n\nexport interface ModuleManifestCodePolicy {\n\ttype: \"code\";\n\tpolicyId: string;\n\tversion: number;\n\tpreviewSafe?: boolean;\n}\n\nexport interface ModuleManifestDataPolicy {\n\ttype: \"data\";\n\tpolicyId: string;\n\tpolicyVersion: number;\n\tkind: PolicyKind;\n\tdataDefinition?: DataPolicyDefinition;\n\tcodeEvaluatorPolicyId?: string;\n\tfallback?: PolicyFallbackDefinition;\n}\n\nexport type ModuleManifestPolicy = ModuleManifestCodePolicy | ModuleManifestDataPolicy;\n\nexport interface ModuleManifestStateMachineTransition {\n\tfrom: string;\n\tto: string;\n\tcausedByAction: string;\n\t/** `true` when the transition declares a guard function. The guard itself is never serialized. */\n\thasGuard: boolean;\n}\n\nexport interface ModuleManifestStateMachine {\n\tentityType: string;\n\t/** States in declaration order (`Object.values` order of the definition record). */\n\tstates: StateDefinition[];\n\ttransitions: ModuleManifestStateMachineTransition[];\n}\n\nexport interface ModuleManifestView extends SurfaceDeclaration {\n\tname: string;\n\tversion: string;\n\tshape: PortableJsonSchema;\n\tparameterSchema?: PortableJsonSchema;\n\tconsumes: Array<{ eventType: string; schemaVersions: number[] }>;\n\tscope: \"tenant-space\";\n\tsnapshotVersion: number;\n\tcompatibleSnapshotVersions?: number[];\n\tusage?: ViewContract[\"usage\"];\n}\n\n/**\n * Stable, JSON-serializable description of a {@link FabricModule}'s ontology:\n * object types, subject types, id prefixes, event types, actions, policies,\n * and state machines. Intended for downstream tooling (semantics exporters,\n * docs generators, tool generators) that cannot consume live module code.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields (`handler`, `evaluate`, `guard`,\n * dynamic `targetState`, adapter `getInput`) are never serialized.\n */\nexport interface ModuleManifest {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tcapability?: CapabilityMetadata;\n\tdependencies: ModuleDependency[];\n\tobjectTypes: ModuleManifestObjectType[];\n\tsubjectTypes: string[];\n\tidPrefixes: ModuleManifestIdPrefix[];\n\teventTypes: ModuleManifestEventType[];\n\tactions: ModuleManifestAction[];\n\tpolicies: ModuleManifestPolicy[];\n\tstateMachines: ModuleManifestStateMachine[];\n\tviews: ModuleManifestView[];\n}\n\nexport interface ModuleManifestBundle {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\t/** Manifests in the input module order. */\n\tmodules: ModuleManifest[];\n}\n\n/** Manifest v1 remains accepted by v2 readers; missing v2 fields normalize to absence. */\nexport type ModuleManifestObjectTypeV1 = Omit<\n\tModuleManifestObjectType,\n\t\"schema\" | \"semantics\" | \"relations\" | \"invariants\"\n>;\nexport type ModuleManifestActionV1 = Omit<\n\tModuleManifestAction,\n\t\"resultSchema\" | \"resultSchemaFormat\"\n>;\nexport type ModuleManifestV1 = Omit<\n\tModuleManifest,\n\t\"manifestVersion\" | \"objectTypes\" | \"actions\" | \"views\"\n> & {\n\tmanifestVersion: 1;\n\tobjectTypes: ModuleManifestObjectTypeV1[];\n\tactions: ModuleManifestActionV1[];\n};\nexport type ModuleManifestBundleV1 = Omit<ModuleManifestBundle, \"manifestVersion\" | \"modules\"> & {\n\tmanifestVersion: 1;\n\tmodules: ModuleManifestV1[];\n};\n\nexport function normalizeModuleManifest(\n\tmanifest: ModuleManifest | ModuleManifestV1,\n): ModuleManifest {\n\tconst version: number = manifest.manifestVersion;\n\tif (version !== 1 && version !== MODULE_MANIFEST_VERSION) {\n\t\tthrow new Error(`Unsupported module manifest version: ${String(version)}`);\n\t}\n\tconst views = \"views\" in manifest && Array.isArray(manifest.views) ? manifest.views : [];\n\t// Preserve the normalizer's legacy tolerance for absent/non-array fields.\n\tif (Array.isArray(manifest.actions))\n\t\tfor (const [index, action] of manifest.actions.entries())\n\t\t\tassertSurfaceDeclaration(action, `Module \"${manifest.namespace}\" action[${index}] \"${action?.actionId ?? \"unknown\"}\"`);\n\tfor (const [index, view] of views.entries())\n\t\tassertSurfaceDeclaration(view, `Module \"${manifest.namespace}\" view[${index}] \"${view?.name ?? \"unknown\"}\"`);\n\treturn {\n\t\t...manifest,\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tviews,\n\t};\n}\n\nexport function normalizeModuleManifestBundle(\n\tbundle: ModuleManifestBundle | ModuleManifestBundleV1,\n): ModuleManifestBundle {\n\tconst version: number = bundle.manifestVersion;\n\tif (version !== 1 && version !== MODULE_MANIFEST_VERSION) {\n\t\tthrow new Error(`Unsupported module manifest bundle version: ${String(version)}`);\n\t}\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: bundle.modules.map((manifest) => normalizeModuleManifest(manifest)),\n\t};\n}\n\n/**\n * A {@link SchemaValidator} that can also export its parameter schema as JSON\n * Schema (for example a Zod 4 schema via `z.toJSONSchema`). Keeps the platform\n * zero-dependency while letting schema-bearing actions flow into manifests.\n */\nexport interface JsonSchemaExportableValidator extends SchemaValidator {\n\ttoJSONSchema(): Record<string, unknown>;\n}\n\nexport function isJsonSchemaExportableValidator(\n\tschema: SchemaValidator,\n): schema is JsonSchemaExportableValidator {\n\treturn (\n\t\ttypeof (schema as Partial<JsonSchemaExportableValidator>).toJSONSchema === \"function\"\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction exportDependency(dependency: ModuleDependencyInput): ModuleDependency {\n\tconst namespace = getModuleDependencyNamespace(dependency);\n\tif (typeof dependency === \"string\") {\n\t\treturn { namespace };\n\t}\n\tconst normalized: ModuleDependency = { namespace };\n\tif (dependency.version !== undefined) normalized.version = dependency.version;\n\tif (dependency.optional !== undefined) normalized.optional = dependency.optional;\n\treturn normalized;\n}\n\nfunction exportObjectType(\n\tobjectType: NonNullable<FabricModule[\"objectTypes\"]>[number],\n): ModuleManifestObjectType {\n\tif (typeof objectType === \"string\") {\n\t\treturn { type: objectType };\n\t}\n\tconst normalized: ModuleManifestObjectType = { type: getObjectTypeName(objectType) };\n\tif (objectType.displayName !== undefined) normalized.displayName = objectType.displayName;\n\tif (objectType.idPrefix !== undefined) normalized.idPrefix = objectType.idPrefix;\n\tif (objectType.schema !== undefined) normalized.schema = cloneJson(objectType.schema);\n\tif (objectType.semantics !== undefined) normalized.semantics = cloneJson(objectType.semantics);\n\tif (objectType.relations !== undefined) {\n\t\tnormalized.relations = objectType.relations.map((relation) => ({ ...relation }));\n\t}\n\tif (objectType.invariants !== undefined) {\n\t\tnormalized.invariants = objectType.invariants.map((invariant) => ({ ...invariant }));\n\t}\n\treturn normalized;\n}\n\nfunction cloneJson<T>(value: T): T {\n\tif (Array.isArray(value)) return value.map((item) => cloneJson(item)) as T;\n\tif (value !== null && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>).map(([key, child]) => [key, cloneJson(child)]),\n\t\t) as T;\n\t}\n\treturn value;\n}\n\nfunction exportEventType(\n\teventType: NonNullable<FabricModule[\"eventTypes\"]>[number],\n): ModuleManifestEventType {\n\tif (typeof eventType === \"string\") {\n\t\t// String registrations carry no explicit schema version; the events\n\t\t// registry treats the bare name as the initial version of the type.\n\t\treturn { eventType, schemaVersion: 1 };\n\t}\n\tconst normalized: ModuleManifestEventType = {\n\t\teventType: getEventTypeName(eventType),\n\t\tschemaVersion: eventType.schemaVersion,\n\t};\n\tif (eventType.description !== undefined) normalized.description = eventType.description;\n\tif (eventType.schema !== undefined) normalized.schema = cloneJson(eventType.schema);\n\treturn normalized;\n}\n\nfunction exportAction(action: ActionDefinition): ModuleManifestAction {\n\tassertSurfaceDeclaration(action, `Action \"${action?.actionId ?? \"unknown\"}\"`);\n\tconst manifest: ModuleManifestAction = {\n\t\tactionId: action.actionId,\n\t\tversion: action.version,\n\t\tkind: action.kind ?? \"atomic\",\n\t\tidempotent: action.idempotent,\n\t\tmutatesDomain: action.mutatesDomain,\n\t\temitsEvents: [...action.emitsEvents],\n\t};\n\n\tif (action.surface !== undefined) manifest.surface = action.surface;\n\tif (action.surfaceReason !== undefined) manifest.surfaceReason = action.surfaceReason;\n\tif (action.policies !== undefined) manifest.policies = [...action.policies];\n\tif (action.requiredRoles !== undefined) manifest.requiredRoles = [...action.requiredRoles];\n\tif (action.requiredPermissions !== undefined) {\n\t\tmanifest.requiredPermissions = [...action.requiredPermissions];\n\t}\n\tif (action.eventPhase !== undefined) manifest.eventPhase = action.eventPhase;\n\tif (action.execution !== undefined) manifest.execution = cloneJson(action.execution);\n\n\tif (isJsonSchemaExportableValidator(action.schema)) {\n\t\ttry {\n\t\t\tmanifest.parameterSchema = action.schema.toJSONSchema();\n\t\t\tmanifest.parameterSchemaFormat = \"json-schema\";\n\t\t} catch {\n\t\t\t// Runtime-valid schemas that cannot be represented portably remain executable;\n\t\t\t// build-time consumers see the schema as unavailable rather than crashing export.\n\t\t}\n\t}\n\tif (action.resultSchema && isJsonSchemaExportableValidator(action.resultSchema)) {\n\t\ttry {\n\t\t\tmanifest.resultSchema = action.resultSchema.toJSONSchema();\n\t\t\tmanifest.resultSchemaFormat = \"json-schema\";\n\t\t} catch {\n\t\t\t// See parameter-schema behavior above.\n\t\t}\n\t}\n\n\tif (action.stateMachine !== undefined) {\n\t\tconst binding: ModuleManifestActionStateMachine = {\n\t\t\tentityType: action.stateMachine.entityType,\n\t\t};\n\t\tif (typeof action.stateMachine.targetState === \"string\") {\n\t\t\tbinding.targetState = action.stateMachine.targetState;\n\t\t}\n\t\tmanifest.stateMachine = binding;\n\t}\n\n\tif (action.adapterSteps !== undefined) {\n\t\tmanifest.adapterSteps = action.adapterSteps.map((step) => {\n\t\t\tconst exported: ModuleManifestAdapterStep = {\n\t\t\t\tadapterType: step.adapterType,\n\t\t\t\toperation: step.operation,\n\t\t\t};\n\t\t\tif (step.retryPolicy !== undefined) exported.retryPolicy = { ...step.retryPolicy };\n\t\t\treturn exported;\n\t\t});\n\t}\n\n\treturn manifest;\n}\n\nfunction exportPolicy(policy: unknown): ModuleManifestPolicy | undefined {\n\tif (!isRecord(policy) || typeof policy.policyId !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\t// Code evaluator: identified by its `evaluate` function (never serialized).\n\tif (typeof policy.evaluate === \"function\") {\n\t\tconst exported: ModuleManifestCodePolicy = {\n\t\t\ttype: \"code\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tversion: typeof policy.version === \"number\" ? policy.version : 1,\n\t\t};\n\t\tif (typeof policy.previewSafe === \"boolean\") exported.previewSafe = policy.previewSafe;\n\t\treturn exported;\n\t}\n\n\t// Declarative runtime policy definition: pure data, serialized as-is.\n\tif (typeof policy.kind === \"string\" && typeof policy.policyVersion === \"number\") {\n\t\tconst exported: ModuleManifestDataPolicy = {\n\t\t\ttype: \"data\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tkind: policy.kind as PolicyKind,\n\t\t};\n\t\tif (isRecord(policy.dataDefinition)) {\n\t\t\texported.dataDefinition = policy.dataDefinition as unknown as DataPolicyDefinition;\n\t\t}\n\t\tif (typeof policy.codeEvaluatorPolicyId === \"string\") {\n\t\t\texported.codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId;\n\t\t}\n\t\tif (isRecord(policy.fallback)) {\n\t\t\texported.fallback = policy.fallback as unknown as PolicyFallbackDefinition;\n\t\t}\n\t\treturn exported;\n\t}\n\n\t// Unknown policy shape: omit rather than guess.\n\treturn undefined;\n}\n\nfunction exportStateMachine(machine: unknown): ModuleManifestStateMachine | undefined {\n\tif (\n\t\t!isRecord(machine) ||\n\t\ttypeof machine.entityType !== \"string\" ||\n\t\t!isRecord(machine.states) ||\n\t\t!Array.isArray(machine.transitions)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst definition = machine as unknown as StateMachineDefinition;\n\treturn {\n\t\tentityType: definition.entityType,\n\t\tstates: Object.values(definition.states),\n\t\ttransitions: definition.transitions.map((transition) => ({\n\t\t\tfrom: transition.from,\n\t\t\tto: transition.to,\n\t\t\tcausedByAction: transition.causedByAction,\n\t\t\thasGuard: typeof transition.guard === \"function\",\n\t\t})),\n\t};\n}\n\nfunction exportView(view: ViewContract): ModuleManifestView {\n\tassertSurfaceDeclaration(view, `View \"${view?.name ?? \"unknown\"}\"`);\n\tconst output: ModuleManifestView = {\n\t\tname: view.name,\n\t\tversion: view.version,\n\t\tshape: cloneJson(view.shape),\n\t\tconsumes: view.consumes.map((consumption) => ({\n\t\t\teventType: consumption.eventType,\n\t\t\tschemaVersions: [...consumption.schemaVersions],\n\t\t})),\n\t\tscope: view.scope,\n\t\tsnapshotVersion: view.snapshotVersion,\n\t};\n\tif (view.surface !== undefined) output.surface = view.surface;\n\tif (view.surfaceReason !== undefined) output.surfaceReason = view.surfaceReason;\n\tif (view.parameterSchema !== undefined) output.parameterSchema = cloneJson(view.parameterSchema);\n\tif (view.compatibleSnapshotVersions) output.compatibleSnapshotVersions = [...view.compatibleSnapshotVersions];\n\tif (view.usage) output.usage = cloneJson(view.usage);\n\treturn output;\n}\n\n/**\n * Export a stable, JSON-serializable manifest of a module's ontology.\n *\n * This is a pure function of the module object: it does not read or mutate the\n * global module/action/policy/state-machine registries, and the module does\n * not need to be registered first. Declaration order is preserved everywhere\n * (nothing is sorted), so the same module object always produces a\n * byte-identical `JSON.stringify` result.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields are elided (`handler`,\n * policy `evaluate`, transition `guard` → `hasGuard`, dynamic `targetState`,\n * adapter `getInput`).\n */\nexport function exportModuleManifest(module: FabricModule<unknown>): ModuleManifest {\n\tconst manifest: ModuleManifest = {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tnamespace: module.namespace,\n\t\tdependencies: (module.dependencies ?? []).map(exportDependency),\n\t\tobjectTypes: (module.objectTypes ?? []).map(exportObjectType),\n\t\tsubjectTypes: [...(module.subjectTypes ?? [])],\n\t\tidPrefixes: (module.idPrefixes ?? []).map((registration) => ({\n\t\t\tprefix: registration.prefix,\n\t\t\tname: registration.name,\n\t\t})),\n\t\teventTypes: (module.eventTypes ?? []).map(exportEventType),\n\t\tactions: (module.actions ?? []).map(exportAction),\n\t\tpolicies: (module.policies ?? [])\n\t\t\t.map(exportPolicy)\n\t\t\t.filter((policy): policy is ModuleManifestPolicy => policy !== undefined),\n\t\tstateMachines: (module.stateMachines ?? [])\n\t\t\t.map(exportStateMachine)\n\t\t\t.filter((machine): machine is ModuleManifestStateMachine => machine !== undefined),\n\t\tviews: (module.views ?? []).map(exportView),\n\t};\n\n\tif (module.version !== undefined) manifest.version = module.version;\n\tif (module.displayName !== undefined) manifest.displayName = module.displayName;\n\tif (module.description !== undefined) manifest.description = module.description;\n\tif (module.capability !== undefined) manifest.capability = cloneJson(module.capability);\n\n\treturn manifest;\n}\n\n/**\n * Export manifests for a set of modules, preserving the input order.\n * Like {@link exportModuleManifest}, this is pure and registry-free.\n */\nexport function exportModuleManifestBundle(\n\tmodules: FabricModule<unknown>[],\n): ModuleManifestBundle {\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: modules.map(exportModuleManifest),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../manifest/index.ts"],"names":[],"mappings":";;;;AA+BO,IAAM,uBAAA,GAA0B;AAkKhC,SAAS,wBACf,QAAA,EACiB;AACjB,EAAA,MAAM,UAAkB,QAAA,CAAS,eAAA;AACjC,EAAA,IAAI,OAAA,KAAY,CAAA,IAAK,OAAA,KAAY,uBAAA,EAAyB;AACzD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,qCAAA,EAAwC,MAAA,CAAO,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC1E;AACA,EAAA,MAAM,KAAA,GAAQ,OAAA,IAAW,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA,GAAQ,EAAC;AAEvF,EAAA,IAAI,KAAA,CAAM,OAAA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,YAAY,CAAA,CAChB,MAAA,CAAO,CAAC,MAAA,KAA2C,MAAA,KAAW,MAAS,CAAA;AAAA,IACzE,aAAA,EAAA,CAAgB,MAAA,CAAO,aAAA,IAAiB,EAAC,EACvC,GAAA,CAAI,kBAAkB,CAAA,CACtB,MAAA,CAAO,CAAC,OAAA,KAAmD,OAAA,KAAY,MAAS,CAAA;AAAA,IAClF,QAAQ,MAAA,CAAO,KAAA,IAAS,EAAC,EAAG,IAAI,UAAU;AAAA,GAC3C;AAEA,EAAA,IAAI,MAAA,CAAO,OAAA,KAAY,MAAA,EAAW,QAAA,CAAS,UAAU,MAAA,CAAO,OAAA;AAC5D,EAAA,IAAI,MAAA,CAAO,WAAA,KAAgB,MAAA,EAAW,QAAA,CAAS,cAAc,MAAA,CAAO,WAAA;AACpE,EAAA,IAAI,MAAA,CAAO,WAAA,KAAgB,MAAA,EAAW,QAAA,CAAS,cAAc,MAAA,CAAO,WAAA;AACpE,EAAA,IAAI,OAAO,UAAA,KAAe,MAAA,WAAoB,UAAA,GAAa,SAAA,CAAU,OAAO,UAAU,CAAA;AAEtF,EAAA,OAAO,QAAA;AACR;AAMO,SAAS,2BACf,OAAA,EACuB;AACvB,EAAA,OAAO;AAAA,IACN,eAAA,EAAiB,uBAAA;AAAA,IACjB,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,oBAAoB;AAAA,GAC1C;AACD","file":"chunk-PDN5DOLQ.js","sourcesContent":["import { assertSurfaceDeclaration, type SurfaceDeclaration } from \"../discovery\";\nimport type {\n\tActionExecutionContract,\n\tActionDefinition,\n\tAdapterStepRetryPolicy,\n\tSchemaValidator,\n} from \"../actions\";\nimport {\n\tgetEventTypeName,\n\tgetModuleDependencyNamespace,\n\tgetObjectTypeName,\n\ttype FabricModule,\n\ttype CapabilityMetadata,\n\ttype DeclarativeInvariant,\n\ttype ModuleDependency,\n\ttype ModuleDependencyInput,\n\ttype ObjectRelationDefinition,\n} from \"../modules\";\nimport type { JsonValue, PortableJsonSchema } from \"../objects\";\nimport type {\n\tDataPolicyDefinition,\n\tPolicyFallbackDefinition,\n\tPolicyKind,\n} from \"../policies\";\nimport type { StateDefinition, StateMachineDefinition } from \"../state-machines\";\nimport type { ViewContract } from \"../projections\";\n\n/**\n * Version of the module manifest contract. Bump when the serialized shape\n * changes in a way consumers must detect.\n */\nexport const MODULE_MANIFEST_VERSION = 2 as const;\n\nexport interface ModuleManifestObjectType {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n\tschema?: PortableJsonSchema;\n\tsemantics?: Record<string, JsonValue>;\n\trelations?: ObjectRelationDefinition[];\n\tinvariants?: DeclarativeInvariant[];\n}\n\nexport interface ModuleManifestIdPrefix {\n\tprefix: string;\n\tname: string;\n}\n\nexport interface ModuleManifestEventType {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n\tschema?: PortableJsonSchema;\n}\n\nexport interface ModuleManifestActionStateMachine {\n\tentityType: string;\n\t/** Present only when the binding declares a static target state. */\n\ttargetState?: string;\n}\n\nexport interface ModuleManifestAdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n}\n\nexport interface ModuleManifestAction extends SurfaceDeclaration {\n\tactionId: string;\n\tversion: number;\n\tkind: \"atomic\" | \"saga\";\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\temitsEvents: string[];\n\tpolicies?: string[];\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\texecution?: ActionExecutionContract;\n\t/**\n\t * JSON Schema for the action parameters, present only when the action's\n\t * `schema` validator implements {@link JsonSchemaExportableValidator}.\n\t */\n\tparameterSchema?: unknown;\n\tparameterSchemaFormat?: \"json-schema\";\n\tresultSchema?: unknown;\n\tresultSchemaFormat?: \"json-schema\";\n\tstateMachine?: ModuleManifestActionStateMachine;\n\tadapterSteps?: ModuleManifestAdapterStep[];\n}\n\nexport interface ModuleManifestCodePolicy {\n\ttype: \"code\";\n\tpolicyId: string;\n\tversion: number;\n\tpreviewSafe?: boolean;\n}\n\nexport interface ModuleManifestDataPolicy {\n\ttype: \"data\";\n\tpolicyId: string;\n\tpolicyVersion: number;\n\tkind: PolicyKind;\n\tdataDefinition?: DataPolicyDefinition;\n\tcodeEvaluatorPolicyId?: string;\n\tfallback?: PolicyFallbackDefinition;\n}\n\nexport type ModuleManifestPolicy = ModuleManifestCodePolicy | ModuleManifestDataPolicy;\n\nexport interface ModuleManifestStateMachineTransition {\n\tfrom: string;\n\tto: string;\n\tcausedByAction: string;\n\t/** `true` when the transition declares a guard function. The guard itself is never serialized. */\n\thasGuard: boolean;\n}\n\nexport interface ModuleManifestStateMachine {\n\tentityType: string;\n\t/** States in declaration order (`Object.values` order of the definition record). */\n\tstates: StateDefinition[];\n\ttransitions: ModuleManifestStateMachineTransition[];\n}\n\nexport interface ModuleManifestView extends SurfaceDeclaration {\n\tname: string;\n\tversion: string;\n\tshape: PortableJsonSchema;\n\tparameterSchema?: PortableJsonSchema;\n\tconsumes: Array<{ eventType: string; schemaVersions: number[] }>;\n\tscope: \"tenant-space\";\n\tsnapshotVersion: number;\n\tcompatibleSnapshotVersions?: number[];\n\tusage?: ViewContract[\"usage\"];\n}\n\n/**\n * Stable, JSON-serializable description of a {@link FabricModule}'s ontology:\n * object types, subject types, id prefixes, event types, actions, policies,\n * and state machines. Intended for downstream tooling (semantics exporters,\n * docs generators, tool generators) that cannot consume live module code.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields (`handler`, `evaluate`, `guard`,\n * dynamic `targetState`, adapter `getInput`) are never serialized.\n */\nexport interface ModuleManifest {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tcapability?: CapabilityMetadata;\n\tdependencies: ModuleDependency[];\n\tobjectTypes: ModuleManifestObjectType[];\n\tsubjectTypes: string[];\n\tidPrefixes: ModuleManifestIdPrefix[];\n\teventTypes: ModuleManifestEventType[];\n\tactions: ModuleManifestAction[];\n\tpolicies: ModuleManifestPolicy[];\n\tstateMachines: ModuleManifestStateMachine[];\n\tviews: ModuleManifestView[];\n}\n\nexport interface ModuleManifestBundle {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\t/** Manifests in the input module order. */\n\tmodules: ModuleManifest[];\n}\n\n/** Manifest v1 remains accepted by v2 readers; missing v2 fields normalize to absence. */\nexport type ModuleManifestObjectTypeV1 = Omit<\n\tModuleManifestObjectType,\n\t\"schema\" | \"semantics\" | \"relations\" | \"invariants\"\n>;\nexport type ModuleManifestActionV1 = Omit<\n\tModuleManifestAction,\n\t\"resultSchema\" | \"resultSchemaFormat\"\n>;\nexport type ModuleManifestV1 = Omit<\n\tModuleManifest,\n\t\"manifestVersion\" | \"objectTypes\" | \"actions\" | \"views\"\n> & {\n\tmanifestVersion: 1;\n\tobjectTypes: ModuleManifestObjectTypeV1[];\n\tactions: ModuleManifestActionV1[];\n};\nexport type ModuleManifestBundleV1 = Omit<ModuleManifestBundle, \"manifestVersion\" | \"modules\"> & {\n\tmanifestVersion: 1;\n\tmodules: ModuleManifestV1[];\n};\n\nexport function normalizeModuleManifest(\n\tmanifest: ModuleManifest | ModuleManifestV1,\n): ModuleManifest {\n\tconst version: number = manifest.manifestVersion;\n\tif (version !== 1 && version !== MODULE_MANIFEST_VERSION) {\n\t\tthrow new Error(`Unsupported module manifest version: ${String(version)}`);\n\t}\n\tconst views = \"views\" in manifest && Array.isArray(manifest.views) ? manifest.views : [];\n\t// Preserve the normalizer's legacy tolerance for absent/non-array fields.\n\tif (Array.isArray(manifest.actions))\n\t\tfor (const [index, action] of manifest.actions.entries())\n\t\t\tassertSurfaceDeclaration(action, `Module \"${manifest.namespace}\" action[${index}] \"${action?.actionId ?? \"unknown\"}\"`);\n\tfor (const [index, view] of views.entries())\n\t\tassertSurfaceDeclaration(view, `Module \"${manifest.namespace}\" view[${index}] \"${view?.name ?? \"unknown\"}\"`);\n\treturn {\n\t\t...manifest,\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tviews,\n\t};\n}\n\nexport function normalizeModuleManifestBundle(\n\tbundle: ModuleManifestBundle | ModuleManifestBundleV1,\n): ModuleManifestBundle {\n\tconst version: number = bundle.manifestVersion;\n\tif (version !== 1 && version !== MODULE_MANIFEST_VERSION) {\n\t\tthrow new Error(`Unsupported module manifest bundle version: ${String(version)}`);\n\t}\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: bundle.modules.map((manifest) => normalizeModuleManifest(manifest)),\n\t};\n}\n\n/**\n * A {@link SchemaValidator} that can also export its parameter schema as JSON\n * Schema (for example a Zod 4 schema via `z.toJSONSchema`). Keeps the platform\n * zero-dependency while letting schema-bearing actions flow into manifests.\n */\nexport interface JsonSchemaExportableValidator extends SchemaValidator {\n\ttoJSONSchema(): Record<string, unknown>;\n}\n\nexport function isJsonSchemaExportableValidator(\n\tschema: SchemaValidator,\n): schema is JsonSchemaExportableValidator {\n\treturn (\n\t\ttypeof (schema as Partial<JsonSchemaExportableValidator>).toJSONSchema === \"function\"\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction exportDependency(dependency: ModuleDependencyInput): ModuleDependency {\n\tconst namespace = getModuleDependencyNamespace(dependency);\n\tif (typeof dependency === \"string\") {\n\t\treturn { namespace };\n\t}\n\tconst normalized: ModuleDependency = { namespace };\n\tif (dependency.version !== undefined) normalized.version = dependency.version;\n\tif (dependency.optional !== undefined) normalized.optional = dependency.optional;\n\treturn normalized;\n}\n\nfunction exportObjectType(\n\tobjectType: NonNullable<FabricModule[\"objectTypes\"]>[number],\n): ModuleManifestObjectType {\n\tif (typeof objectType === \"string\") {\n\t\treturn { type: objectType };\n\t}\n\tconst normalized: ModuleManifestObjectType = { type: getObjectTypeName(objectType) };\n\tif (objectType.displayName !== undefined) normalized.displayName = objectType.displayName;\n\tif (objectType.idPrefix !== undefined) normalized.idPrefix = objectType.idPrefix;\n\tif (objectType.schema !== undefined) normalized.schema = cloneJson(objectType.schema);\n\tif (objectType.semantics !== undefined) normalized.semantics = cloneJson(objectType.semantics);\n\tif (objectType.relations !== undefined) {\n\t\tnormalized.relations = objectType.relations.map((relation) => ({ ...relation }));\n\t}\n\tif (objectType.invariants !== undefined) {\n\t\tnormalized.invariants = objectType.invariants.map((invariant) => ({ ...invariant }));\n\t}\n\treturn normalized;\n}\n\nfunction cloneJson<T>(value: T): T {\n\tif (Array.isArray(value)) return value.map((item) => cloneJson(item)) as T;\n\tif (value !== null && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>).map(([key, child]) => [key, cloneJson(child)]),\n\t\t) as T;\n\t}\n\treturn value;\n}\n\nfunction exportEventType(\n\teventType: NonNullable<FabricModule[\"eventTypes\"]>[number],\n): ModuleManifestEventType {\n\tif (typeof eventType === \"string\") {\n\t\t// String registrations carry no explicit schema version; the events\n\t\t// registry treats the bare name as the initial version of the type.\n\t\treturn { eventType, schemaVersion: 1 };\n\t}\n\tconst normalized: ModuleManifestEventType = {\n\t\teventType: getEventTypeName(eventType),\n\t\tschemaVersion: eventType.schemaVersion,\n\t};\n\tif (eventType.description !== undefined) normalized.description = eventType.description;\n\tif (eventType.schema !== undefined) normalized.schema = cloneJson(eventType.schema);\n\treturn normalized;\n}\n\nfunction exportAction(action: ActionDefinition): ModuleManifestAction {\n\tassertSurfaceDeclaration(action, `Action \"${action?.actionId ?? \"unknown\"}\"`);\n\tconst manifest: ModuleManifestAction = {\n\t\tactionId: action.actionId,\n\t\tversion: action.version,\n\t\tkind: action.kind ?? \"atomic\",\n\t\tidempotent: action.idempotent,\n\t\tmutatesDomain: action.mutatesDomain,\n\t\temitsEvents: [...action.emitsEvents],\n\t};\n\n\tif (action.surface !== undefined) manifest.surface = action.surface;\n\tif (action.surfaceReason !== undefined) manifest.surfaceReason = action.surfaceReason;\n\tif (action.policies !== undefined) manifest.policies = [...action.policies];\n\tif (action.requiredRoles !== undefined) manifest.requiredRoles = [...action.requiredRoles];\n\tif (action.requiredPermissions !== undefined) {\n\t\tmanifest.requiredPermissions = [...action.requiredPermissions];\n\t}\n\tif (action.eventPhase !== undefined) manifest.eventPhase = action.eventPhase;\n\tif (action.execution !== undefined) manifest.execution = cloneJson(action.execution);\n\n\tif (isJsonSchemaExportableValidator(action.schema)) {\n\t\ttry {\n\t\t\tmanifest.parameterSchema = action.schema.toJSONSchema();\n\t\t\tmanifest.parameterSchemaFormat = \"json-schema\";\n\t\t} catch {\n\t\t\t// Runtime-valid schemas that cannot be represented portably remain executable;\n\t\t\t// build-time consumers see the schema as unavailable rather than crashing export.\n\t\t}\n\t}\n\tif (action.resultSchema && isJsonSchemaExportableValidator(action.resultSchema)) {\n\t\ttry {\n\t\t\tmanifest.resultSchema = action.resultSchema.toJSONSchema();\n\t\t\tmanifest.resultSchemaFormat = \"json-schema\";\n\t\t} catch {\n\t\t\t// See parameter-schema behavior above.\n\t\t}\n\t}\n\n\tif (action.stateMachine !== undefined) {\n\t\tconst binding: ModuleManifestActionStateMachine = {\n\t\t\tentityType: action.stateMachine.entityType,\n\t\t};\n\t\tif (typeof action.stateMachine.targetState === \"string\") {\n\t\t\tbinding.targetState = action.stateMachine.targetState;\n\t\t}\n\t\tmanifest.stateMachine = binding;\n\t}\n\n\tif (action.adapterSteps !== undefined) {\n\t\tmanifest.adapterSteps = action.adapterSteps.map((step) => {\n\t\t\tconst exported: ModuleManifestAdapterStep = {\n\t\t\t\tadapterType: step.adapterType,\n\t\t\t\toperation: step.operation,\n\t\t\t};\n\t\t\tif (step.retryPolicy !== undefined) exported.retryPolicy = { ...step.retryPolicy };\n\t\t\treturn exported;\n\t\t});\n\t}\n\n\treturn manifest;\n}\n\nfunction exportPolicy(policy: unknown): ModuleManifestPolicy | undefined {\n\tif (!isRecord(policy) || typeof policy.policyId !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\t// Code evaluator: identified by its `evaluate` function (never serialized).\n\tif (typeof policy.evaluate === \"function\") {\n\t\tconst exported: ModuleManifestCodePolicy = {\n\t\t\ttype: \"code\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tversion: typeof policy.version === \"number\" ? policy.version : 1,\n\t\t};\n\t\tif (typeof policy.previewSafe === \"boolean\") exported.previewSafe = policy.previewSafe;\n\t\treturn exported;\n\t}\n\n\t// Declarative runtime policy definition: pure data, serialized as-is.\n\tif (typeof policy.kind === \"string\" && typeof policy.policyVersion === \"number\") {\n\t\tconst exported: ModuleManifestDataPolicy = {\n\t\t\ttype: \"data\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tkind: policy.kind as PolicyKind,\n\t\t};\n\t\tif (isRecord(policy.dataDefinition)) {\n\t\t\texported.dataDefinition = policy.dataDefinition as unknown as DataPolicyDefinition;\n\t\t}\n\t\tif (typeof policy.codeEvaluatorPolicyId === \"string\") {\n\t\t\texported.codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId;\n\t\t}\n\t\tif (isRecord(policy.fallback)) {\n\t\t\texported.fallback = policy.fallback as unknown as PolicyFallbackDefinition;\n\t\t}\n\t\treturn exported;\n\t}\n\n\t// Unknown policy shape: omit rather than guess.\n\treturn undefined;\n}\n\nfunction exportStateMachine(machine: unknown): ModuleManifestStateMachine | undefined {\n\tif (\n\t\t!isRecord(machine) ||\n\t\ttypeof machine.entityType !== \"string\" ||\n\t\t!isRecord(machine.states) ||\n\t\t!Array.isArray(machine.transitions)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst definition = machine as unknown as StateMachineDefinition;\n\treturn {\n\t\tentityType: definition.entityType,\n\t\tstates: Object.values(definition.states),\n\t\ttransitions: definition.transitions.map((transition) => ({\n\t\t\tfrom: transition.from,\n\t\t\tto: transition.to,\n\t\t\tcausedByAction: transition.causedByAction,\n\t\t\thasGuard: typeof transition.guard === \"function\",\n\t\t})),\n\t};\n}\n\nfunction exportView(view: ViewContract): ModuleManifestView {\n\tassertSurfaceDeclaration(view, `View \"${view?.name ?? \"unknown\"}\"`);\n\tconst output: ModuleManifestView = {\n\t\tname: view.name,\n\t\tversion: view.version,\n\t\tshape: cloneJson(view.shape),\n\t\tconsumes: view.consumes.map((consumption) => ({\n\t\t\teventType: consumption.eventType,\n\t\t\tschemaVersions: [...consumption.schemaVersions],\n\t\t})),\n\t\tscope: view.scope,\n\t\tsnapshotVersion: view.snapshotVersion,\n\t};\n\tif (view.surface !== undefined) output.surface = view.surface;\n\tif (view.surfaceReason !== undefined) output.surfaceReason = view.surfaceReason;\n\tif (view.parameterSchema !== undefined) output.parameterSchema = cloneJson(view.parameterSchema);\n\tif (view.compatibleSnapshotVersions) output.compatibleSnapshotVersions = [...view.compatibleSnapshotVersions];\n\tif (view.usage) output.usage = cloneJson(view.usage);\n\treturn output;\n}\n\n/**\n * Export a stable, JSON-serializable manifest of a module's ontology.\n *\n * This is a pure function of the module object: it does not read or mutate the\n * global module/action/policy/state-machine registries, and the module does\n * not need to be registered first. Declaration order is preserved everywhere\n * (nothing is sorted), so the same module object always produces a\n * byte-identical `JSON.stringify` result.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields are elided (`handler`,\n * policy `evaluate`, transition `guard` → `hasGuard`, dynamic `targetState`,\n * adapter `getInput`).\n */\nexport function exportModuleManifest(module: FabricModule<unknown>): ModuleManifest {\n\tconst manifest: ModuleManifest = {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tnamespace: module.namespace,\n\t\tdependencies: (module.dependencies ?? []).map(exportDependency),\n\t\tobjectTypes: (module.objectTypes ?? []).map(exportObjectType),\n\t\tsubjectTypes: [...(module.subjectTypes ?? [])],\n\t\tidPrefixes: (module.idPrefixes ?? []).map((registration) => ({\n\t\t\tprefix: registration.prefix,\n\t\t\tname: registration.name,\n\t\t})),\n\t\teventTypes: (module.eventTypes ?? []).map(exportEventType),\n\t\tactions: (module.actions ?? []).map(exportAction),\n\t\tpolicies: (module.policies ?? [])\n\t\t\t.map(exportPolicy)\n\t\t\t.filter((policy): policy is ModuleManifestPolicy => policy !== undefined),\n\t\tstateMachines: (module.stateMachines ?? [])\n\t\t\t.map(exportStateMachine)\n\t\t\t.filter((machine): machine is ModuleManifestStateMachine => machine !== undefined),\n\t\tviews: (module.views ?? []).map(exportView),\n\t};\n\n\tif (module.version !== undefined) manifest.version = module.version;\n\tif (module.displayName !== undefined) manifest.displayName = module.displayName;\n\tif (module.description !== undefined) manifest.description = module.description;\n\tif (module.capability !== undefined) manifest.capability = cloneJson(module.capability);\n\n\treturn manifest;\n}\n\n/**\n * Export manifests for a set of modules, preserving the input order.\n * Like {@link exportModuleManifest}, this is pure and registry-free.\n */\nexport function exportModuleManifestBundle(\n\tmodules: FabricModule<unknown>[],\n): ModuleManifestBundle {\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: modules.map(exportModuleManifest),\n\t};\n}\n"]}
|
|
@@ -28,6 +28,9 @@ function createActionRegistry(definitions = []) {
|
|
|
28
28
|
if (definition.mutatesDomain && definition.emitsEvents.length === 0) {
|
|
29
29
|
throw new Error(`Action "${definition.actionId}" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`);
|
|
30
30
|
}
|
|
31
|
+
if (definition.admitSubmission !== void 0 && typeof definition.admitSubmission !== "function") {
|
|
32
|
+
throw new Error(`Action "${definition.actionId}" declares admitSubmission that is not a function.`);
|
|
33
|
+
}
|
|
31
34
|
actions.set(definition.actionId, definition);
|
|
32
35
|
};
|
|
33
36
|
for (const definition of definitions) register(definition);
|
|
@@ -43,5 +46,5 @@ function createActionRegistry(definitions = []) {
|
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
export { ACTOR_TYPES, assertActionId, assertActorType, createActionRegistry, isActorType };
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
47
|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A,EAAG;AACpE,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,QAAA,EAAW,UAAA,CAAW,QAAQ,CAAA,8FAAA,CAAgG,CAAA;AAAA,IAC/I;AACA,IAAA,IAAI,WAAW,eAAA,KAAoB,MAAA,IAAa,OAAO,UAAA,CAAW,oBAAoB,UAAA,EAAY;AACjG,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,QAAA,EAAW,UAAA,CAAW,QAAQ,CAAA,kDAAA,CAAoD,CAAA;AAAA,IACnG;AACA,IAAA,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAW,QAAA,EAAU,UAAU,CAAA;AAAA,EAC5C,CAAA;AACA,EAAA,KAAA,MAAW,UAAA,IAAc,WAAA,EAAa,QAAA,CAAS,UAAU,CAAA;AACzD,EAAA,OAAO;AAAA,IACN,QAAA;AAAA,IACA,kBAAkB,UAAA,EAAY;AAC7B,MAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,WAAW,QAAQ,CAAA,WAAY,UAAU,CAAA;AAAA,IAC3D,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,QAAA,KAAa,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAAA,IAC3C,GAAA,EAAK,CAAC,QAAA,KAAmC,OAAA,CAAQ,IAAI,QAAoB,CAAA;AAAA,IACzE,KAAK,MAAM,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,MAAM;AAAA,GACrC;AACD","file":"chunk-PIDZQAEL.js","sourcesContent":["import type { SurfaceDeclaration } from \"../discovery\";\nexport type ActionId = `${string}.${string}`;\n\nexport interface SchemaParseIssue {\n\tpath: PropertyKey[];\n\tmessage: string;\n}\n\nexport type SchemaParseResult<T = unknown> =\n\t| { success: true; data: T }\n\t| { success: false; error: { issues: SchemaParseIssue[] } };\n\nexport interface SchemaValidator<T = unknown> {\n\tparse(input: unknown): T;\n\tsafeParse(input: unknown): SchemaParseResult<T>;\n}\n\nexport type ActorType =\n\t| \"natural_person\"\n\t| \"agent\"\n\t| \"system\"\n\t| \"service_account\"\n\t| \"external_system\"\n\t| \"integration\";\n\nexport const ACTOR_TYPES: readonly ActorType[] = [\n\t\"natural_person\",\n\t\"agent\",\n\t\"system\",\n\t\"service_account\",\n\t\"external_system\",\n\t\"integration\",\n] as const;\n\nexport function isActorType(value: string): value is ActorType {\n\treturn (ACTOR_TYPES as readonly string[]).includes(value);\n}\n\nexport function assertActorType(value: string): asserts value is ActorType {\n\tif (!isActorType(value)) {\n\t\tthrow new Error(`Invalid actorType: ${value}`);\n\t}\n}\n\nexport type ActionStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"blocked_by_policy\"\n\t| \"waiting_for_approval\"\n\t| \"reconciliation_required\"\n\t| \"validation_failed\";\n\nexport interface FabricRuntimeServices {\n\treadonly [serviceName: string]: unknown;\n}\n\nexport interface ActionContext<TDb = unknown> {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tactorId: string;\n\tactorType: ActorType;\n\tcorrelationId: string;\n\tcausationId?: string;\n\tprovenance?: { source: string; auditAttributes?: Record<string, string> };\n\tdb: TDb;\n\tservices?: FabricRuntimeServices;\n\t/**\n\t * When the host admitted this invocation's submission through the\n\t * action's `admitSubmission` check, read from the durable invocation\n\t * record. Absent when the action declares no check, or when the runtime\n\t * that built this context does not run declared admission checks (a host\n\t * older than the one that introduced them). A handler whose action\n\t * declares `admitSubmission` can refuse to run without it.\n\t */\n\tadmittedAt?: Date;\n}\n\n/**\n * Trusted facts a host gives an action's `admitSubmission` check. Scope and\n * actor come from the host's authenticated submission, never from the\n * parameters.\n */\nexport interface ActionAdmissionInput {\n\treadonly actionId: ActionId;\n\treadonly tenantId: string;\n\treadonly spaceId: string;\n\treadonly actorId: string;\n\treadonly actorType: ActorType;\n\t/**\n\t * The submitted parameters, unvalidated, as a copy made for this check.\n\t * `@fabricorg/platform-host` records its own copy of the same value, taken\n\t * before the check ran, and only if the check admits it; changing this\n\t * copy changes nothing the host records.\n\t */\n\treadonly parameters: Readonly<Record<string, unknown>>;\n\t/**\n\t * Aborted when the host's admission deadline passes. Hosts pass an\n\t * `AbortSignal`. `@fabricorg/platform-host` refuses an answer that settles\n\t * at or after the deadline, even one that settles before the abort.\n\t */\n\treadonly signal: ActionAdmissionSignal;\n}\n\n/**\n * The part of an `AbortSignal` an admission check can rely on. Declared\n * structurally so this module compiles without DOM or Node type libraries; a\n * host passes a real `AbortSignal`, which satisfies it.\n */\nexport interface ActionAdmissionSignal {\n\treadonly aborted: boolean;\n\taddEventListener(type: \"abort\", listener: () => void, options?: { once?: boolean }): void;\n\tremoveEventListener(type: \"abort\", listener: () => void): void;\n}\n\n/**\n * An admission check's answer. Only `{ admitted: true }` admits. A refusal's\n * `code` must be a fixed code chosen by the action (lower-case first letter,\n * then letters, digits, `_`, `.`, `:` or `-`, at most 128 characters), never\n * a submitted value: the host puts it in the error it throws.\n */\nexport type ActionAdmissionDecision =\n\t| { readonly admitted: true }\n\t| { readonly admitted: false; readonly code: string };\n\n/**\n * Decides whether a submission may be recorded at all. A host that supports\n * it runs the check after authorizing the submitter and before it writes\n * anything durable for the submission; a refusal, a throw, a timeout or any\n * answer other than `{ admitted: true }` refuses the submission.\n */\nexport type ActionAdmission = (input: ActionAdmissionInput) => Promise<ActionAdmissionDecision>;\n\nexport interface ActionResult {\n\tsuccess: boolean;\n\tdata?: Record<string, unknown>;\n\terror?: string;\n}\n\nexport type ActionHandler<TDb = unknown> = (\n\tctx: ActionContext<TDb>,\n\tparams: unknown,\n) => Promise<ActionResult>;\n\nexport interface AdapterStepRetryPolicy {\n\tidempotent: boolean;\n\tmaxAttempts?: number;\n\tinitialDelayMs?: number;\n\tbackoffMultiplier?: number;\n\tmaxDelayMs?: number;\n}\n\nexport interface AdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n\tgetInput: (\n\t\tparams: unknown,\n\t\thandlerResult: Record<string, unknown>,\n\t) => Record<string, unknown> | undefined;\n}\n\nexport interface ActionStateMachineBinding {\n\tentityType: string;\n\ttargetState: string | ((params: unknown) => string);\n\tgetEntityId: (params: unknown) => string | undefined;\n}\n\nexport interface ActionDefinition<TDb = unknown> extends SurfaceDeclaration {\n\tactionId: ActionId;\n\tnamespace: string;\n\tversion: number;\n\tschema: SchemaValidator;\n\t/**\n\t * Optional check a host runs on every submission before it records\n\t * anything durable for it (invocation, idempotency key, events, errors).\n\t * Use it when parameters must be validated against trusted context, for\n\t * example a secret reference the tenant's secret store must hold, before\n\t * they may be persisted. `@fabricorg/platform-host` runs it from the\n\t * release that introduced it; an older host ignores it, so a handler that\n\t * relies on it should require `ActionContext.admittedAt`.\n\t */\n\tadmitSubmission?: ActionAdmission;\n\t/** Optional validation contract for the public handler result data. */\n\tresultSchema?: SchemaValidator;\n\thandler?: ActionHandler<TDb>;\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\tpolicies?: `${string}.v${number}`[];\n\temitsEvents: string[];\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\t/** Portable execution semantics used by hosts, gateways, and generated capability contracts. */\n\texecution?: ActionExecutionContract;\n\tstateMachine?: ActionStateMachineBinding;\n\tadapterSteps?: AdapterStep[];\n\t/** Completion actions can attest only after all external adapter work succeeds. */\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\t/**\n\t * If \"saga\", the action is a multi-step orchestration. The worker dispatches\n\t * to a registered saga implementation instead of running `handler` directly.\n\t */\n\tkind?: \"atomic\" | \"saga\";\n}\n\nexport type ActionConnectivity = \"online-required\" | \"offline-capturable\";\nexport type AuthorityMoment = \"capture\" | \"execution\" | \"both\";\nexport type ActionIdempotencyStance = \"required\" | \"supported\" | \"prohibited\";\nexport type ActionCompletionMode = \"immediate\" | \"accepted\" | \"long-running\";\nexport type ActionConsistency = \"authoritative-now\" | \"provisional-until-reconciled\";\nexport type ActionDataSensitivity = \"public\" | \"internal\" | \"confidential\" | \"restricted\";\n\nexport interface ActionExecutionContract {\n\tconnectivity: ActionConnectivity;\n\tauthorityMoment: AuthorityMoment;\n\tidempotency: ActionIdempotencyStance;\n\t/**\n\t * `immediate`: the invocation settles within the host's execution.\n\t * `accepted` and `long-running`: an adapter may hand the work to an\n\t * external system and the invocation stays running until that system\n\t * completes it by reference through the host's completion ingress.\n\t * Declare `completionDeadlineMs` on a `long-running` action so a callback\n\t * that never comes is noticed rather than waited on forever.\n\t */\n\tcompletion: ActionCompletionMode;\n\t/**\n\t * How long an accepted handoff may wait for its completion before the host\n\t * moves the invocation to reconciliation. Without it, nothing sweeps the\n\t * handoff. Refused on `immediate`, since nothing external completes it.\n\t */\n\tcompletionDeadlineMs?: number;\n\tconsistency: ActionConsistency;\n\tsensitivity?: ActionDataSensitivity;\n}\n\nexport interface SagaContext {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tparameters: unknown;\n\tsleep?: (delayMs: number) => Promise<void>;\n\tquery?: <T = unknown>(model: string, operation: string, args: unknown) => Promise<T>;\n\t/**\n\t * Wait for a named external signal carrying a payload of `T`, with a timeout.\n\t *\n\t * Resolves with the payload of the first signal received, or `null` if the timeout\n\t * fires first. Subsequent distinct signals with the same name received before\n\t * another `awaitSignal` call are buffered in FIFO order so none is lost.\n\t *\n\t * A signal may carry a stable signal ID that the sender keeps the same on each redelivery\n\t * (for example a webhook delivery ID or an approval decision ID). A runtime drops\n\t * a signal whose ID it has already received for this saga, so a sender retrying\n\t * after a timeout does not wake the saga twice. Signals without an ID are not\n\t * deduplicated. `@fabricorg/platform-temporal` provides `createSagaSignalInbox()`\n\t * for Temporal runtimes.\n\t *\n\t * Intended for agent-driven and webhook-driven coordination: replace polling loops\n\t * with push-based wakeups while preserving the saga's deterministic replay\n\t * semantics (the runtime is responsible for capturing signals into workflow history).\n\t *\n\t * Optional. Runtimes that cannot implement push-based signaling (e.g. an in-memory\n\t * test harness) may omit this; sagas should treat absence as a fallback condition\n\t * and use `sleep` + `query` polling instead.\n\t *\n\t * Signal *senders* are runtime-specific (e.g. a Temporal `WorkflowClient.signal()`\n\t * call from an action handler). Apps that need to send signals from action\n\t * handlers should expose a coordination service via `ActionContext.services`\n\t * — the platform does not prescribe the sender API.\n\t *\n\t * @example\n\t * const payload = await ctx.awaitSignal?.<{ result: Record<string, unknown> }>(\n\t * \"userInputProcessed\",\n\t * 5 * 60 * 1000,\n\t * );\n\t * if (payload) { /* handle pushed result *\\/ }\n\t * else { /* timeout — fall back to deterministic path *\\/ }\n\t */\n\tawaitSignal?: <T = unknown>(signalName: string, timeoutMs: number) => Promise<T | null>;\n}\n\nexport interface SagaChildActionInput {\n\tsuffix: string;\n\tactionId: string;\n\tparameters: Record<string, unknown>;\n}\n\nexport type SagaRunChild = (input: SagaChildActionInput) => Promise<Record<string, unknown>>;\n\nexport interface SagaCompletionEvent {\n\teventType: string;\n\tsubjectType: string;\n\tsubjectId: string;\n\tpayload: unknown;\n\teventSchemaVersion?: number;\n}\n\nexport interface SagaCompletion {\n\tresultData: Record<string, unknown>;\n\tevent?: SagaCompletionEvent;\n}\n\nexport type SagaImplementation = (\n\tctx: SagaContext,\n\trunChild: SagaRunChild,\n) => Promise<SagaCompletion>;\n\nexport function assertActionId(actionId: string): asserts actionId is ActionId {\n\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(actionId)) {\n\t\tthrow new Error(`Invalid action ID: ${actionId}`);\n\t}\n}\n\nexport interface ActionRegistry<TDb = unknown> {\n\tregister(definition: ActionDefinition<TDb>): void;\n\tregisterIfMissing(definition: ActionDefinition<TDb>): void;\n\tresolve(actionId: ActionId): ActionDefinition<TDb> | undefined;\n\thas(actionId: string): actionId is ActionId;\n\tids(): ActionId[];\n}\n\nexport function createActionRegistry<TDb = unknown>(definitions: readonly ActionDefinition<TDb>[] = []): ActionRegistry<TDb> {\n\tconst actions = new Map<ActionId, ActionDefinition<TDb>>();\n\tconst register = (definition: ActionDefinition<TDb>): void => {\n\t\tassertActionId(definition.actionId);\n\t\tif (actions.has(definition.actionId)) throw new Error(`Action \"${definition.actionId}\" is already registered`);\n\t\tif (definition.mutatesDomain && definition.emitsEvents.length === 0) {\n\t\t\tthrow new Error(`Action \"${definition.actionId}\" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`);\n\t\t}\n\t\tif (definition.admitSubmission !== undefined && typeof definition.admitSubmission !== \"function\") {\n\t\t\tthrow new Error(`Action \"${definition.actionId}\" declares admitSubmission that is not a function.`);\n\t\t}\n\t\tactions.set(definition.actionId, definition);\n\t};\n\tfor (const definition of definitions) register(definition);\n\treturn {\n\t\tregister,\n\t\tregisterIfMissing(definition) {\n\t\t\tif (!actions.has(definition.actionId)) register(definition);\n\t\t},\n\t\tresolve: (actionId) => actions.get(actionId),\n\t\thas: (actionId): actionId is ActionId => actions.has(actionId as ActionId),\n\t\tids: () => Array.from(actions.keys()),\n\t};\n}\n"]}
|
|
@@ -248,21 +248,6 @@ var AnonymizationEngine = class {
|
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return new AnonymizationEngine(policy).anonymizeJsonValue(value, context, dataClass);
|
|
255
|
-
}
|
|
256
|
-
function anonymizeAssetEventPayload(event, context, policy) {
|
|
257
|
-
return new AnonymizationEngine(policy).anonymizeAssetEventPayload(event, context);
|
|
258
|
-
}
|
|
259
|
-
function anonymizeEvidencePacket(packet, context, policy) {
|
|
260
|
-
return new AnonymizationEngine(policy).anonymizeEvidencePacket(packet, context);
|
|
261
|
-
}
|
|
262
|
-
function buildAnonymizationLifecycleEvidence(input, policy) {
|
|
263
|
-
return new AnonymizationEngine(policy).buildAnonymizationLifecycleEvidence(input);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export { ANONYMIZATION_POLICY_VERSION, AnonymizationEngine, FieldRedactor, PLATFORM_PRIVACY_POLICY_VERSION, anonymizeAssetEventPayload, anonymizeEvidencePacket, anonymizeJsonValue, buildAnonymizationLifecycleEvidence, stableChecksum };
|
|
267
|
-
//# sourceMappingURL=chunk-ATWWZTRC.js.map
|
|
268
|
-
//# sourceMappingURL=chunk-ATWWZTRC.js.map
|
|
251
|
+
export { ANONYMIZATION_POLICY_VERSION, AnonymizationEngine, FieldRedactor, stableChecksum };
|
|
252
|
+
//# sourceMappingURL=chunk-TYNIFC7J.js.map
|
|
253
|
+
//# sourceMappingURL=chunk-TYNIFC7J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../privacy/engine.ts"],"names":[],"mappings":";;;AAWO,IAAM,4BAAA,GAA+B;AAgE5C,SAAS,aAAa,GAAA,EAAqB;AAC1C,EAAA,OAAO,GAAA,CAAI,OAAA,CAAQ,eAAA,EAAiB,EAAE,EAAE,WAAA,EAAY;AACrD;AAEO,SAAS,eAAe,KAAA,EAAwB;AACtD,EAAA,OAAO,UAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,IAAA,CAAK,UAAU,KAAK,CAAC,CAAA,CAAE,MAAA,CAAO,KAAK,CAAA;AACvE;AAEA,SAAS,iBAAA,CACR,KAAA,EACA,OAAA,EACA,SAAA,EACS;AACT,EAAA,MAAM,KAAA,GAAQ,GAAG,OAAA,CAAQ,QAAQ,IAAI,OAAA,CAAQ,OAAA,IAAW,QAAQ,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAC7E,EAAA,OAAO,CAAA,IAAA,EAAO,WAAW,QAAQ,CAAA,CAC/B,OAAO,CAAA,EAAG,OAAA,CAAQ,aAAA,IAAiB,4BAA4B,CAAA,CAAA,EAAI,KAAK,IAAI,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA,CAC3F,MAAA,CAAO,KAAK,CAAA,CACZ,KAAA,CAAM,CAAA,EAAG,EAAE,CAAC,CAAA,CAAA;AACf;AAEA,SAAS,UAAU,KAAA,EAA+B;AACjD,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW;AAC1C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AS,cAAA,CAAe,GAAA;AAAA,YAC3C,CAAC,EAAE,SAAA,EAAW,MAAA,EAAQ,gBAAe,MAAO;AAAA,cAC3C,SAAA;AAAA,cACA,MAAA;AAAA,cACA;AAAA,aACD;AAAA;AACD,SACD,CAAE,CAAA;AAAA,QACF,GAAG,eAAA,CAAgB,GAAA,CAAI,CAAC,IAAA,MAAU;AAAA,UACjC,WAAA,EAAa,iBAAA;AAAA,UACb,QAAA,EAAU,KAAK,MAAA,CAAO,EAAA;AAAA,UACtB,aAAA,EAAe,IAAA,CAAK,QAAA,CAAS,cAAA,CAAe,GAAA;AAAA,YAC3C,CAAC,EAAE,SAAA,EAAW,MAAA,EAAQ,gBAAe,MAAO;AAAA,cAC3C,SAAA;AAAA,cACA,MAAA;AAAA,cACA;AAAA,aACD;AAAA;AACD,SACD,CAAE;AAAA,OACH;AAAA,MACA,oBAAoB,CAAC,GAAI,KAAK,OAAA,CAAQ,kBAAA,IAAsB,EAAG;AAAA,KAChE;AAAA,EACD;AACD","file":"chunk-TYNIFC7J.js","sourcesContent":["import { createHash } from \"node:crypto\";\n\nimport type {\n\tAnonymizationContext,\n\tAnonymizationFieldMetadata,\n\tAnonymizationMetadata,\n\tAnonymizationResult,\n\tPlatformDataClass,\n\tRedactionMethod,\n} from \"./index\";\n\nexport const ANONYMIZATION_POLICY_VERSION = \"adr-026-platform-anonymization-v1\";\n\ntype JsonObject = Record<string, unknown>;\n\nexport interface AnonymizationFieldPolicy {\n\tmethod: RedactionMethod;\n\tmatch: \"key\" | \"path\";\n\tvalue: string;\n}\n\nexport interface AnonymizationPolicy {\n\tfields: readonly AnonymizationFieldPolicy[];\n\tpreservedSemantics?: readonly string[];\n}\n\nexport interface AssetEventLike {\n\tid: string;\n\ttenantId: string;\n\tspaceId: string;\n\teventType: string;\n\tsubjectType: string;\n\tsubjectId: string;\n\tactionInvocationId: string;\n\tpayload: unknown;\n\tsequence: number;\n\toccurredAt: Date;\n\trecordedAt: Date;\n\tcorrelationId: string;\n\tcausationId?: string | null;\n}\n\nexport interface EvidencePacketLike {\n\tid: string;\n\tpacket: unknown;\n\tredactionMetadata: unknown;\n\tchecksum: string;\n}\n\nexport interface AnonymizationLifecycleEvidence {\n\teventType: \"AnonymizationApplied\";\n\tpolicyVersion: string;\n\tjobId: string;\n\treason: string;\n\tappliedAt: string;\n\ttenantId: string;\n\tspaceId: string | null;\n\tcounts: {\n\t\tassetEvents: number;\n\t\treadModels: number;\n\t\tevidencePackets: number;\n\t\tredactedFields: number;\n\t};\n\trecords: Array<{\n\t\trecordClass: PlatformDataClass;\n\t\trecordId: string;\n\t\tsubjectType?: string;\n\t\tsubjectId?: string;\n\t\tfieldManifest: Array<\n\t\t\tPick<AnonymizationFieldMetadata, \"fieldPath\" | \"method\" | \"beforeChecksum\">\n\t\t>;\n\t}>;\n\tpreservedSemantics: string[];\n}\n\nfunction normalizeKey(key: string): string {\n\treturn key.replace(/[^a-zA-Z0-9]/g, \"\").toLowerCase();\n}\n\nexport function stableChecksum(value: unknown): string {\n\treturn createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\");\n}\n\nfunction stableScopedToken(\n\tvalue: unknown,\n\tcontext: AnonymizationContext,\n\tfieldPath: string,\n): string {\n\tconst scope = `${context.tenantId}:${context.spaceId ?? \"global\"}:${fieldPath}`;\n\treturn `tok_${createHash(\"sha256\")\n\t\t.update(`${context.policyVersion ?? ANONYMIZATION_POLICY_VERSION}:${scope}:${String(value)}`)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 24)}`;\n}\n\nfunction maskValue(value: unknown): string | null {\n\tif (value === null || value === undefined) {\n\t\treturn null;\n\t}\n\n\tconst stringValue = String(value);\n\tif (stringValue.length <= 4) {\n\t\treturn \"****\";\n\t}\n\n\treturn `${\"*\".repeat(Math.max(stringValue.length - 4, 4))}${stringValue.slice(-4)}`;\n}\n\nfunction generalizeValue(value: unknown): unknown {\n\tif (typeof value === \"number\") {\n\t\treturn Math.round(value / 1000) * 1000;\n\t}\n\n\tif (typeof value === \"string\" && /^\\d{5}(?:-\\d{4})?$/.test(value)) {\n\t\treturn `${value.slice(0, 3)}**`;\n\t}\n\n\treturn null;\n}\n\nfunction applyMethod(\n\tvalue: unknown,\n\tmethod: RedactionMethod,\n\tcontext: AnonymizationContext,\n\tpath: string,\n): unknown {\n\tswitch (method) {\n\t\tcase \"drop\":\n\t\t\treturn undefined;\n\t\tcase \"nullify\":\n\t\t\treturn null;\n\t\tcase \"mask\":\n\t\t\treturn maskValue(value);\n\t\tcase \"hash\":\n\t\t\treturn `sha256_${stableChecksum(value)}`;\n\t\tcase \"tokenize\":\n\t\t\treturn stableScopedToken(value, context, path);\n\t\tcase \"generalize\":\n\t\t\treturn generalizeValue(value);\n\t}\n}\n\nfunction policyForPath(policies: readonly AnonymizationFieldPolicy[], path: string, key?: string): AnonymizationFieldPolicy | undefined {\n\tconst normalizedPath = normalizeKey(path);\n\tconst normalizedKey = key ? normalizeKey(key) : undefined;\n\n\treturn policies.find((policy) => {\n\t\tconst normalizedValue = normalizeKey(policy.value);\n\t\tif (policy.match === \"key\") {\n\t\t\treturn normalizedValue === normalizedKey;\n\t\t}\n\n\t\treturn normalizedValue === normalizedPath;\n\t});\n}\n\nfunction isPlainObject(value: unknown): value is JsonObject {\n\treturn (\n\t\tBoolean(value) && typeof value === \"object\" && !Array.isArray(value) && !(value instanceof Date)\n\t);\n}\n\nfunction anonymizeRecursive(\n\tvalue: unknown,\n\tcontext: AnonymizationContext,\n\tdataClass: PlatformDataClass,\n\tpath: string,\n\tredactedFields: AnonymizationFieldMetadata[],\n\tpolicies: readonly AnonymizationFieldPolicy[],\n\tkey?: string,\n): unknown {\n\tconst fieldPolicy = policyForPath(policies, path, key);\n\tif (fieldPolicy && value !== null && value !== undefined) {\n\t\tredactedFields.push({\n\t\t\tfieldPath: path,\n\t\t\tmethod: fieldPolicy.method,\n\t\t\tpolicyVersion: context.policyVersion ?? ANONYMIZATION_POLICY_VERSION,\n\t\t\tjobId: context.jobId,\n\t\t\tredactedAt: (context.redactedAt ?? new Date()).toISOString(),\n\t\t\treason: context.reason,\n\t\t\tdataClass,\n\t\t\tbeforeChecksum: stableChecksum(value),\n\t\t});\n\n\t\treturn applyMethod(value, fieldPolicy.method, context, path);\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn value.map((item, index) =>\n\t\t\tanonymizeRecursive(item, context, dataClass, `${path}[${index}]`, redactedFields, policies),\n\t\t);\n\t}\n\n\tif (!isPlainObject(value)) {\n\t\treturn value;\n\t}\n\n\tconst result: JsonObject = {};\n\tfor (const [childKey, childValue] of Object.entries(value)) {\n\t\tif (childKey === \"_privacy\") {\n\t\t\tresult[childKey] = childValue;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst anonymized = anonymizeRecursive(\n\t\t\tchildValue,\n\t\t\tcontext,\n\t\t\tdataClass,\n\t\t\t`${path}.${childKey}`,\n\t\t\tredactedFields,\n\t\t\tpolicies,\n\t\t\tchildKey,\n\t\t);\n\n\t\tif (anonymized !== undefined) {\n\t\t\tresult[childKey] = anonymized;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction buildMetadata(\n\tcontext: AnonymizationContext,\n\tdataClass: PlatformDataClass,\n\tredactedFields: AnonymizationFieldMetadata[],\n\tpreservedSemantics: readonly string[],\n): AnonymizationMetadata {\n\treturn {\n\t\tredactionState: \"anonymized\",\n\t\tpolicyVersion: context.policyVersion ?? ANONYMIZATION_POLICY_VERSION,\n\t\tjobId: context.jobId,\n\t\tredactedAt: (context.redactedAt ?? new Date()).toISOString(),\n\t\treason: context.reason,\n\t\tdataClass,\n\t\tredactedFields,\n\t\tpreservedSemantics: [...preservedSemantics],\n\t};\n}\n\nexport class FieldRedactor {\n\tredactField(value: unknown, method: RedactionMethod, context: AnonymizationContext, path: string): unknown {\n\t\treturn applyMethod(value, method, context, path);\n\t}\n\n\tmask(value: unknown): string | null {\n\t\treturn maskValue(value);\n\t}\n\n\thash(value: unknown): string {\n\t\treturn `sha256_${stableChecksum(value)}`;\n\t}\n\n\ttokenize(value: unknown, context: AnonymizationContext, path: string): string {\n\t\treturn stableScopedToken(value, context, path);\n\t}\n\n\tgeneralize(value: unknown): unknown {\n\t\treturn generalizeValue(value);\n\t}\n}\n\nexport class AnonymizationEngine {\n\treadonly #policy: AnonymizationPolicy;\n\n\tconstructor(policy: AnonymizationPolicy) {\n\t\tthis.#policy = {\n\t\t\tfields: policy.fields.map((field) => ({ ...field })),\n\t\t\tpreservedSemantics: [...(policy.preservedSemantics ?? [])],\n\t\t};\n\t}\n\n\tanonymizeJsonValue<TValue>(\n\t\tvalue: TValue,\n\t\tcontext: AnonymizationContext,\n\t\tdataClass: PlatformDataClass,\n\t): AnonymizationResult<TValue> {\n\t\treturn this.anonymizeJsonValueAtPath(value, context, dataClass, \"$\");\n\t}\n\n\tanonymizeJsonValueAtPath<TValue>(\n\t\tvalue: TValue,\n\t\tcontext: AnonymizationContext,\n\t\tdataClass: PlatformDataClass,\n\t\tbasePath: string,\n\t): AnonymizationResult<TValue> {\n\t\tconst redactedFields: AnonymizationFieldMetadata[] = [];\n\t\tconst anonymizedValue = anonymizeRecursive(\n\t\t\tvalue,\n\t\t\tcontext,\n\t\t\tdataClass,\n\t\t\tbasePath,\n\t\t\tredactedFields,\n\t\t\tthis.#policy.fields,\n\t\t) as TValue;\n\n\t\treturn {\n\t\t\tvalue: anonymizedValue,\n\t\t\tmetadata: buildMetadata(context, dataClass, redactedFields, this.#policy.preservedSemantics ?? []),\n\t\t};\n\t}\n\n\tanonymizeAssetEventPayload(\n\t\tevent: AssetEventLike,\n\t\tcontext: AnonymizationContext,\n\t): AnonymizationResult<unknown> {\n\t\tconst result = this.anonymizeJsonValue(event.payload, context, \"asset_event\");\n\t\tconst payload = isPlainObject(result.value)\n\t\t\t? { ...result.value, _privacy: result.metadata }\n\t\t\t: { value: result.value, _privacy: result.metadata };\n\n\t\treturn { value: payload, metadata: result.metadata };\n\t}\n\n\tanonymizeEvidencePacket(\n\t\tpacket: EvidencePacketLike,\n\t\tcontext: AnonymizationContext,\n\t): AnonymizationResult<Pick<EvidencePacketLike, \"packet\" | \"redactionMetadata\" | \"checksum\">> {\n\t\tconst result = this.anonymizeJsonValue(packet.packet, context, \"evidence_packet\");\n\t\tconst redactionMetadata = {\n\t\t\t...(isPlainObject(packet.redactionMetadata) ? packet.redactionMetadata : {}),\n\t\t\tlifecycleAnonymization: result.metadata,\n\t\t};\n\t\tconst anonymizedPacket = isPlainObject(result.value)\n\t\t\t? { ...result.value, _privacy: result.metadata }\n\t\t\t: { value: result.value, _privacy: result.metadata };\n\n\t\treturn {\n\t\t\tvalue: {\n\t\t\t\tpacket: anonymizedPacket,\n\t\t\t\tredactionMetadata,\n\t\t\t\tchecksum: stableChecksum({ packet: anonymizedPacket, redactionMetadata }),\n\t\t\t},\n\t\t\tmetadata: result.metadata,\n\t\t};\n\t}\n\n\tbuildAnonymizationLifecycleEvidence(input: {\n\t\tcontext: AnonymizationContext;\n\t\tassetEvents?: Array<{ event: AssetEventLike; metadata: AnonymizationMetadata }>;\n\t\treadModels?: Array<{\n\t\t\tmodelKind: string;\n\t\t\trecord: JsonObject & { id: string };\n\t\t\tmetadata: AnonymizationMetadata;\n\t\t}>;\n\t\tevidencePackets?: Array<{ packet: EvidencePacketLike; metadata: AnonymizationMetadata }>;\n\t}): AnonymizationLifecycleEvidence {\n\t\tconst assetEvents = input.assetEvents ?? [];\n\t\tconst readModels = input.readModels ?? [];\n\t\tconst evidencePackets = input.evidencePackets ?? [];\n\t\tconst redactedFields = [\n\t\t\t...assetEvents.flatMap((item) => item.metadata.redactedFields),\n\t\t\t...readModels.flatMap((item) => item.metadata.redactedFields),\n\t\t\t...evidencePackets.flatMap((item) => item.metadata.redactedFields),\n\t\t];\n\n\t\treturn {\n\t\t\teventType: \"AnonymizationApplied\",\n\t\t\tpolicyVersion: input.context.policyVersion ?? ANONYMIZATION_POLICY_VERSION,\n\t\t\tjobId: input.context.jobId,\n\t\t\treason: input.context.reason,\n\t\t\tappliedAt: (input.context.redactedAt ?? new Date()).toISOString(),\n\t\t\ttenantId: input.context.tenantId,\n\t\t\tspaceId: input.context.spaceId ?? null,\n\t\t\tcounts: {\n\t\t\t\tassetEvents: assetEvents.length,\n\t\t\t\treadModels: readModels.length,\n\t\t\t\tevidencePackets: evidencePackets.length,\n\t\t\t\tredactedFields: redactedFields.length,\n\t\t\t},\n\t\t\trecords: [\n\t\t\t\t...assetEvents.map((item) => ({\n\t\t\t\t\trecordClass: \"asset_event\" as PlatformDataClass,\n\t\t\t\t\trecordId: item.event.id,\n\t\t\t\t\tsubjectType: item.event.subjectType,\n\t\t\t\t\tsubjectId: item.event.subjectId,\n\t\t\t\t\tfieldManifest: item.metadata.redactedFields.map(\n\t\t\t\t\t\t({ fieldPath, method, beforeChecksum }) => ({\n\t\t\t\t\t\t\tfieldPath,\n\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\tbeforeChecksum,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t})),\n\t\t\t\t...readModels.map((item) => ({\n\t\t\t\t\trecordClass: \"read_model\" as PlatformDataClass,\n\t\t\t\t\trecordId: item.record.id,\n\t\t\t\t\tsubjectType: item.modelKind,\n\t\t\t\t\tsubjectId: item.record.id,\n\t\t\t\t\tfieldManifest: item.metadata.redactedFields.map(\n\t\t\t\t\t\t({ fieldPath, method, beforeChecksum }) => ({\n\t\t\t\t\t\t\tfieldPath,\n\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\tbeforeChecksum,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t})),\n\t\t\t\t...evidencePackets.map((item) => ({\n\t\t\t\t\trecordClass: \"evidence_packet\" as PlatformDataClass,\n\t\t\t\t\trecordId: item.packet.id,\n\t\t\t\t\tfieldManifest: item.metadata.redactedFields.map(\n\t\t\t\t\t\t({ fieldPath, method, beforeChecksum }) => ({\n\t\t\t\t\t\t\tfieldPath,\n\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\tbeforeChecksum,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t})),\n\t\t\t],\n\t\t\tpreservedSemantics: [...(this.#policy.preservedSemantics ?? [])],\n\t\t};\n\t}\n}\n"]}
|
|
@@ -30,6 +30,9 @@ function createActionRegistry(definitions = []) {
|
|
|
30
30
|
if (definition.mutatesDomain && definition.emitsEvents.length === 0) {
|
|
31
31
|
throw new Error(`Action "${definition.actionId}" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`);
|
|
32
32
|
}
|
|
33
|
+
if (definition.admitSubmission !== void 0 && typeof definition.admitSubmission !== "function") {
|
|
34
|
+
throw new Error(`Action "${definition.actionId}" declares admitSubmission that is not a function.`);
|
|
35
|
+
}
|
|
33
36
|
actions.set(definition.actionId, definition);
|
|
34
37
|
};
|
|
35
38
|
for (const definition of definitions) register(definition);
|
|
@@ -49,5 +52,5 @@ exports.assertActionId = assertActionId;
|
|
|
49
52
|
exports.assertActorType = assertActorType;
|
|
50
53
|
exports.createActionRegistry = createActionRegistry;
|
|
51
54
|
exports.isActorType = isActorType;
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-UGWGHTNC.cjs.map
|
|
56
|
+
//# sourceMappingURL=chunk-UGWGHTNC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../actions/index.ts"],"names":[],"mappings":";;;AAyBO,IAAM,WAAA,GAAoC;AAAA,EAChD,gBAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACD;AAEO,SAAS,YAAY,KAAA,EAAmC;AAC9D,EAAA,OAAQ,WAAA,CAAkC,SAAS,KAAK,CAAA;AACzD;AAEO,SAAS,gBAAgB,KAAA,EAA2C;AAC1E,EAAA,IAAI,CAAC,WAAA,CAAY,KAAK,CAAA,EAAG;AAC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AAAA,IACN,QAAA;AAAA,IACA,kBAAkB,UAAA,EAAY;AAC7B,MAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,WAAW,QAAQ,CAAA,WAAY,UAAU,CAAA;AAAA,IAC3D,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,QAAA,KAAa,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAAA,IAC3C,GAAA,EAAK,CAAC,QAAA,KAAmC,OAAA,CAAQ,IAAI,QAAoB,CAAA;AAAA,IACzE,KAAK,MAAM,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,MAAM;AAAA,GACrC;AACD","file":"chunk-UGWGHTNC.cjs","sourcesContent":["import type { SurfaceDeclaration } from \"../discovery\";\nexport type ActionId = `${string}.${string}`;\n\nexport interface SchemaParseIssue {\n\tpath: PropertyKey[];\n\tmessage: string;\n}\n\nexport type SchemaParseResult<T = unknown> =\n\t| { success: true; data: T }\n\t| { success: false; error: { issues: SchemaParseIssue[] } };\n\nexport interface SchemaValidator<T = unknown> {\n\tparse(input: unknown): T;\n\tsafeParse(input: unknown): SchemaParseResult<T>;\n}\n\nexport type ActorType =\n\t| \"natural_person\"\n\t| \"agent\"\n\t| \"system\"\n\t| \"service_account\"\n\t| \"external_system\"\n\t| \"integration\";\n\nexport const ACTOR_TYPES: readonly ActorType[] = [\n\t\"natural_person\",\n\t\"agent\",\n\t\"system\",\n\t\"service_account\",\n\t\"external_system\",\n\t\"integration\",\n] as const;\n\nexport function isActorType(value: string): value is ActorType {\n\treturn (ACTOR_TYPES as readonly string[]).includes(value);\n}\n\nexport function assertActorType(value: string): asserts value is ActorType {\n\tif (!isActorType(value)) {\n\t\tthrow new Error(`Invalid actorType: ${value}`);\n\t}\n}\n\nexport type ActionStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"blocked_by_policy\"\n\t| \"waiting_for_approval\"\n\t| \"reconciliation_required\"\n\t| \"validation_failed\";\n\nexport interface FabricRuntimeServices {\n\treadonly [serviceName: string]: unknown;\n}\n\nexport interface ActionContext<TDb = unknown> {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tactorId: string;\n\tactorType: ActorType;\n\tcorrelationId: string;\n\tcausationId?: string;\n\tprovenance?: { source: string; auditAttributes?: Record<string, string> };\n\tdb: TDb;\n\tservices?: FabricRuntimeServices;\n\t/**\n\t * When the host admitted this invocation's submission through the\n\t * action's `admitSubmission` check, read from the durable invocation\n\t * record. Absent when the action declares no check, or when the runtime\n\t * that built this context does not run declared admission checks (a host\n\t * older than the one that introduced them). A handler whose action\n\t * declares `admitSubmission` can refuse to run without it.\n\t */\n\tadmittedAt?: Date;\n}\n\n/**\n * Trusted facts a host gives an action's `admitSubmission` check. Scope and\n * actor come from the host's authenticated submission, never from the\n * parameters.\n */\nexport interface ActionAdmissionInput {\n\treadonly actionId: ActionId;\n\treadonly tenantId: string;\n\treadonly spaceId: string;\n\treadonly actorId: string;\n\treadonly actorType: ActorType;\n\t/**\n\t * The submitted parameters, unvalidated, as a copy made for this check.\n\t * `@fabricorg/platform-host` records its own copy of the same value, taken\n\t * before the check ran, and only if the check admits it; changing this\n\t * copy changes nothing the host records.\n\t */\n\treadonly parameters: Readonly<Record<string, unknown>>;\n\t/**\n\t * Aborted when the host's admission deadline passes. Hosts pass an\n\t * `AbortSignal`. `@fabricorg/platform-host` refuses an answer that settles\n\t * at or after the deadline, even one that settles before the abort.\n\t */\n\treadonly signal: ActionAdmissionSignal;\n}\n\n/**\n * The part of an `AbortSignal` an admission check can rely on. Declared\n * structurally so this module compiles without DOM or Node type libraries; a\n * host passes a real `AbortSignal`, which satisfies it.\n */\nexport interface ActionAdmissionSignal {\n\treadonly aborted: boolean;\n\taddEventListener(type: \"abort\", listener: () => void, options?: { once?: boolean }): void;\n\tremoveEventListener(type: \"abort\", listener: () => void): void;\n}\n\n/**\n * An admission check's answer. Only `{ admitted: true }` admits. A refusal's\n * `code` must be a fixed code chosen by the action (lower-case first letter,\n * then letters, digits, `_`, `.`, `:` or `-`, at most 128 characters), never\n * a submitted value: the host puts it in the error it throws.\n */\nexport type ActionAdmissionDecision =\n\t| { readonly admitted: true }\n\t| { readonly admitted: false; readonly code: string };\n\n/**\n * Decides whether a submission may be recorded at all. A host that supports\n * it runs the check after authorizing the submitter and before it writes\n * anything durable for the submission; a refusal, a throw, a timeout or any\n * answer other than `{ admitted: true }` refuses the submission.\n */\nexport type ActionAdmission = (input: ActionAdmissionInput) => Promise<ActionAdmissionDecision>;\n\nexport interface ActionResult {\n\tsuccess: boolean;\n\tdata?: Record<string, unknown>;\n\terror?: string;\n}\n\nexport type ActionHandler<TDb = unknown> = (\n\tctx: ActionContext<TDb>,\n\tparams: unknown,\n) => Promise<ActionResult>;\n\nexport interface AdapterStepRetryPolicy {\n\tidempotent: boolean;\n\tmaxAttempts?: number;\n\tinitialDelayMs?: number;\n\tbackoffMultiplier?: number;\n\tmaxDelayMs?: number;\n}\n\nexport interface AdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n\tgetInput: (\n\t\tparams: unknown,\n\t\thandlerResult: Record<string, unknown>,\n\t) => Record<string, unknown> | undefined;\n}\n\nexport interface ActionStateMachineBinding {\n\tentityType: string;\n\ttargetState: string | ((params: unknown) => string);\n\tgetEntityId: (params: unknown) => string | undefined;\n}\n\nexport interface ActionDefinition<TDb = unknown> extends SurfaceDeclaration {\n\tactionId: ActionId;\n\tnamespace: string;\n\tversion: number;\n\tschema: SchemaValidator;\n\t/**\n\t * Optional check a host runs on every submission before it records\n\t * anything durable for it (invocation, idempotency key, events, errors).\n\t * Use it when parameters must be validated against trusted context, for\n\t * example a secret reference the tenant's secret store must hold, before\n\t * they may be persisted. `@fabricorg/platform-host` runs it from the\n\t * release that introduced it; an older host ignores it, so a handler that\n\t * relies on it should require `ActionContext.admittedAt`.\n\t */\n\tadmitSubmission?: ActionAdmission;\n\t/** Optional validation contract for the public handler result data. */\n\tresultSchema?: SchemaValidator;\n\thandler?: ActionHandler<TDb>;\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\tpolicies?: `${string}.v${number}`[];\n\temitsEvents: string[];\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\t/** Portable execution semantics used by hosts, gateways, and generated capability contracts. */\n\texecution?: ActionExecutionContract;\n\tstateMachine?: ActionStateMachineBinding;\n\tadapterSteps?: AdapterStep[];\n\t/** Completion actions can attest only after all external adapter work succeeds. */\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\t/**\n\t * If \"saga\", the action is a multi-step orchestration. The worker dispatches\n\t * to a registered saga implementation instead of running `handler` directly.\n\t */\n\tkind?: \"atomic\" | \"saga\";\n}\n\nexport type ActionConnectivity = \"online-required\" | \"offline-capturable\";\nexport type AuthorityMoment = \"capture\" | \"execution\" | \"both\";\nexport type ActionIdempotencyStance = \"required\" | \"supported\" | \"prohibited\";\nexport type ActionCompletionMode = \"immediate\" | \"accepted\" | \"long-running\";\nexport type ActionConsistency = \"authoritative-now\" | \"provisional-until-reconciled\";\nexport type ActionDataSensitivity = \"public\" | \"internal\" | \"confidential\" | \"restricted\";\n\nexport interface ActionExecutionContract {\n\tconnectivity: ActionConnectivity;\n\tauthorityMoment: AuthorityMoment;\n\tidempotency: ActionIdempotencyStance;\n\t/**\n\t * `immediate`: the invocation settles within the host's execution.\n\t * `accepted` and `long-running`: an adapter may hand the work to an\n\t * external system and the invocation stays running until that system\n\t * completes it by reference through the host's completion ingress.\n\t * Declare `completionDeadlineMs` on a `long-running` action so a callback\n\t * that never comes is noticed rather than waited on forever.\n\t */\n\tcompletion: ActionCompletionMode;\n\t/**\n\t * How long an accepted handoff may wait for its completion before the host\n\t * moves the invocation to reconciliation. Without it, nothing sweeps the\n\t * handoff. Refused on `immediate`, since nothing external completes it.\n\t */\n\tcompletionDeadlineMs?: number;\n\tconsistency: ActionConsistency;\n\tsensitivity?: ActionDataSensitivity;\n}\n\nexport interface SagaContext {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tparameters: unknown;\n\tsleep?: (delayMs: number) => Promise<void>;\n\tquery?: <T = unknown>(model: string, operation: string, args: unknown) => Promise<T>;\n\t/**\n\t * Wait for a named external signal carrying a payload of `T`, with a timeout.\n\t *\n\t * Resolves with the payload of the first signal received, or `null` if the timeout\n\t * fires first. Subsequent distinct signals with the same name received before\n\t * another `awaitSignal` call are buffered in FIFO order so none is lost.\n\t *\n\t * A signal may carry a stable signal ID that the sender keeps the same on each redelivery\n\t * (for example a webhook delivery ID or an approval decision ID). A runtime drops\n\t * a signal whose ID it has already received for this saga, so a sender retrying\n\t * after a timeout does not wake the saga twice. Signals without an ID are not\n\t * deduplicated. `@fabricorg/platform-temporal` provides `createSagaSignalInbox()`\n\t * for Temporal runtimes.\n\t *\n\t * Intended for agent-driven and webhook-driven coordination: replace polling loops\n\t * with push-based wakeups while preserving the saga's deterministic replay\n\t * semantics (the runtime is responsible for capturing signals into workflow history).\n\t *\n\t * Optional. Runtimes that cannot implement push-based signaling (e.g. an in-memory\n\t * test harness) may omit this; sagas should treat absence as a fallback condition\n\t * and use `sleep` + `query` polling instead.\n\t *\n\t * Signal *senders* are runtime-specific (e.g. a Temporal `WorkflowClient.signal()`\n\t * call from an action handler). Apps that need to send signals from action\n\t * handlers should expose a coordination service via `ActionContext.services`\n\t * — the platform does not prescribe the sender API.\n\t *\n\t * @example\n\t * const payload = await ctx.awaitSignal?.<{ result: Record<string, unknown> }>(\n\t * \"userInputProcessed\",\n\t * 5 * 60 * 1000,\n\t * );\n\t * if (payload) { /* handle pushed result *\\/ }\n\t * else { /* timeout — fall back to deterministic path *\\/ }\n\t */\n\tawaitSignal?: <T = unknown>(signalName: string, timeoutMs: number) => Promise<T | null>;\n}\n\nexport interface SagaChildActionInput {\n\tsuffix: string;\n\tactionId: string;\n\tparameters: Record<string, unknown>;\n}\n\nexport type SagaRunChild = (input: SagaChildActionInput) => Promise<Record<string, unknown>>;\n\nexport interface SagaCompletionEvent {\n\teventType: string;\n\tsubjectType: string;\n\tsubjectId: string;\n\tpayload: unknown;\n\teventSchemaVersion?: number;\n}\n\nexport interface SagaCompletion {\n\tresultData: Record<string, unknown>;\n\tevent?: SagaCompletionEvent;\n}\n\nexport type SagaImplementation = (\n\tctx: SagaContext,\n\trunChild: SagaRunChild,\n) => Promise<SagaCompletion>;\n\nexport function assertActionId(actionId: string): asserts actionId is ActionId {\n\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(actionId)) {\n\t\tthrow new Error(`Invalid action ID: ${actionId}`);\n\t}\n}\n\nexport interface ActionRegistry<TDb = unknown> {\n\tregister(definition: ActionDefinition<TDb>): void;\n\tregisterIfMissing(definition: ActionDefinition<TDb>): void;\n\tresolve(actionId: ActionId): ActionDefinition<TDb> | undefined;\n\thas(actionId: string): actionId is ActionId;\n\tids(): ActionId[];\n}\n\nexport function createActionRegistry<TDb = unknown>(definitions: readonly ActionDefinition<TDb>[] = []): ActionRegistry<TDb> {\n\tconst actions = new Map<ActionId, ActionDefinition<TDb>>();\n\tconst register = (definition: ActionDefinition<TDb>): void => {\n\t\tassertActionId(definition.actionId);\n\t\tif (actions.has(definition.actionId)) throw new Error(`Action \"${definition.actionId}\" is already registered`);\n\t\tif (definition.mutatesDomain && definition.emitsEvents.length === 0) {\n\t\t\tthrow new Error(`Action \"${definition.actionId}\" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`);\n\t\t}\n\t\tif (definition.admitSubmission !== undefined && typeof definition.admitSubmission !== \"function\") {\n\t\t\tthrow new Error(`Action \"${definition.actionId}\" declares admitSubmission that is not a function.`);\n\t\t}\n\t\tactions.set(definition.actionId, definition);\n\t};\n\tfor (const definition of definitions) register(definition);\n\treturn {\n\t\tregister,\n\t\tregisterIfMissing(definition) {\n\t\t\tif (!actions.has(definition.actionId)) register(definition);\n\t\t},\n\t\tresolve: (actionId) => actions.get(actionId),\n\t\thas: (actionId): actionId is ActionId => actions.has(actionId as ActionId),\n\t\tids: () => Array.from(actions.keys()),\n\t};\n}\n"]}
|