@knpkv/control-center 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/client/.vite/manifest.json +127 -125
  2. package/dist/client/assets/{ActiveWorkPage-Bvji6Tys.js → ActiveWorkPage-C6QwDV1Y.js} +2 -2
  3. package/dist/client/assets/{ActiveWorkPage-Bvji6Tys.js.map → ActiveWorkPage-C6QwDV1Y.js.map} +1 -1
  4. package/dist/client/assets/{AgentPage-Bom41la2.js → AgentPage-OqwP6uRi.js} +2 -2
  5. package/dist/client/assets/{AgentPage-Bom41la2.js.map → AgentPage-OqwP6uRi.js.map} +1 -1
  6. package/dist/client/assets/{AtlassianOAuthCallbackPage-dr-B9-DD.js → AtlassianOAuthCallbackPage-Bm7UhU-h.js} +2 -2
  7. package/dist/client/assets/{AtlassianOAuthCallbackPage-dr-B9-DD.js.map → AtlassianOAuthCallbackPage-Bm7UhU-h.js.map} +1 -1
  8. package/dist/client/assets/{AuthorizedSharePage-C-P-PNfm.js → AuthorizedSharePage-DblP3USU.js} +2 -2
  9. package/dist/client/assets/{AuthorizedSharePage-C-P-PNfm.js.map → AuthorizedSharePage-DblP3USU.js.map} +1 -1
  10. package/dist/client/assets/{BrowserCrypto-BPiuCuW-.js → BrowserCrypto-BGGRC6iW.js} +2 -2
  11. package/dist/client/assets/{BrowserCrypto-BPiuCuW-.js.map → BrowserCrypto-BGGRC6iW.js.map} +1 -1
  12. package/dist/client/assets/{BrowserSessionHydrator-C8F_LGhg.js → BrowserSessionHydrator-39UDbHf0.js} +2 -2
  13. package/dist/client/assets/{BrowserSessionHydrator-C8F_LGhg.js.map → BrowserSessionHydrator-39UDbHf0.js.map} +1 -1
  14. package/dist/client/assets/{CommandSearch-D6iFcdvj.js → CommandSearch-D4Fnjsl-.js} +2 -2
  15. package/dist/client/assets/{CommandSearch-D6iFcdvj.js.map → CommandSearch-D4Fnjsl-.js.map} +1 -1
  16. package/dist/client/assets/{ItemsPage-x39U11an.js → ItemsPage-BZQiTh9b.js} +2 -2
  17. package/dist/client/assets/{ItemsPage-x39U11an.js.map → ItemsPage-BZQiTh9b.js.map} +1 -1
  18. package/dist/client/assets/{PairPage-D5vlz4OG.js → PairPage-Dvfse5ky.js} +2 -2
  19. package/dist/client/assets/{PairPage-D5vlz4OG.js.map → PairPage-Dvfse5ky.js.map} +1 -1
  20. package/dist/client/assets/{PortfolioOverview-DSUabOmm.js → PortfolioOverview-DeJcfXcw.js} +2 -2
  21. package/dist/client/assets/{PortfolioOverview-DSUabOmm.js.map → PortfolioOverview-DeJcfXcw.js.map} +1 -1
  22. package/dist/client/assets/{ReleaseRoute-DyDm5s85.js → ReleaseRoute-D9q8_sCk.js} +2 -2
  23. package/dist/client/assets/{ReleaseRoute-DyDm5s85.js.map → ReleaseRoute-D9q8_sCk.js.map} +1 -1
  24. package/dist/client/assets/ReleaseWorkset-Bs_FXlbC.js +2 -0
  25. package/dist/client/assets/ReleaseWorkset-Bs_FXlbC.js.map +1 -0
  26. package/dist/client/assets/{ServicesPage-CoMVH2Si.js → ServicesPage-Co6GJHgc.js} +2 -2
  27. package/dist/client/assets/{ServicesPage-CoMVH2Si.js.map → ServicesPage-Co6GJHgc.js.map} +1 -1
  28. package/dist/client/assets/{TimelinePage-D8Fj_351.js → TimelinePage-CM2og72M.js} +2 -2
  29. package/dist/client/assets/{TimelinePage-D8Fj_351.js.map → TimelinePage-CM2og72M.js.map} +1 -1
  30. package/dist/client/assets/{WorkspaceEntityLink-BRifdJHn.js → WorkspaceEntityLink-CTw_He-8.js} +2 -2
  31. package/dist/client/assets/{WorkspaceEntityLink-BRifdJHn.js.map → WorkspaceEntityLink-CTw_He-8.js.map} +1 -1
  32. package/dist/client/assets/{WorkspaceEntityRoute-BwpujSqk.css → WorkspaceEntityRoute-Bdmv6ki4.css} +1 -1
  33. package/dist/client/assets/WorkspaceEntityRoute-BnsmaeS2.js +30 -0
  34. package/dist/client/assets/WorkspaceEntityRoute-BnsmaeS2.js.map +1 -0
  35. package/dist/client/assets/{WorkspaceReleaseLayout-DDLdY0rU.js → WorkspaceReleaseLayout-Ba6keUju.js} +2 -2
  36. package/dist/client/assets/{WorkspaceReleaseLayout-DDLdY0rU.js.map → WorkspaceReleaseLayout-Ba6keUju.js.map} +1 -1
  37. package/dist/client/assets/{authenticatedMutationClient-D5yD0rch.js → authenticatedMutationClient-CJklf3iD.js} +2 -2
  38. package/dist/client/assets/{authenticatedMutationClient-D5yD0rch.js.map → authenticatedMutationClient-CJklf3iD.js.map} +1 -1
  39. package/dist/client/assets/{authorizedShareTransport-Dyj53kJf.js → authorizedShareTransport-Xg20SHJ5.js} +2 -2
  40. package/dist/client/assets/{authorizedShareTransport-Dyj53kJf.js.map → authorizedShareTransport-Xg20SHJ5.js.map} +1 -1
  41. package/dist/client/assets/{client-OmvShYdC.js → client-P7FaPwzJ.js} +2 -2
  42. package/dist/client/assets/{client-OmvShYdC.js.map → client-P7FaPwzJ.js.map} +1 -1
  43. package/dist/client/assets/{connectionTestTransport-c25QXx7A.js → connectionTestTransport-C9iPOkKM.js} +2 -2
  44. package/dist/client/assets/{connectionTestTransport-c25QXx7A.js.map → connectionTestTransport-C9iPOkKM.js.map} +1 -1
  45. package/dist/client/assets/{index-DLoOV6Hp.js → index-DpW_ckau.js} +3 -3
  46. package/dist/client/assets/{index-DLoOV6Hp.js.map → index-DpW_ckau.js.map} +1 -1
  47. package/dist/client/assets/{patterns-DEbg7R-A-Cw0A2uKS.js → patterns-DEbg7R-A-BhsMyh9D.js} +2 -2
  48. package/dist/client/assets/{patterns-DEbg7R-A-Cw0A2uKS.js.map → patterns-DEbg7R-A-BhsMyh9D.js.map} +1 -1
  49. package/dist/client/assets/{presentPortfolio-CkRqd_zz.js → presentPortfolio-D-v615bg.js} +2 -2
  50. package/dist/client/assets/{presentPortfolio-CkRqd_zz.js.map → presentPortfolio-D-v615bg.js.map} +1 -1
  51. package/dist/client/assets/presentWorkspaceItems-IAp5SnpB.js +2 -0
  52. package/dist/client/assets/presentWorkspaceItems-IAp5SnpB.js.map +1 -0
  53. package/dist/client/assets/{releaseRoutes-DSWkTh-E.js → releaseRoutes-CfaNElmG.js} +2 -2
  54. package/dist/client/assets/{releaseRoutes-DSWkTh-E.js.map → releaseRoutes-CfaNElmG.js.map} +1 -1
  55. package/dist/client/assets/{serviceOnboarding-B9pvdyWf.js → serviceOnboarding-BZ2U_Ugw.js} +2 -2
  56. package/dist/client/assets/{serviceOnboarding-B9pvdyWf.js.map → serviceOnboarding-BZ2U_Ugw.js.map} +1 -1
  57. package/dist/client/assets/{useWorkspaceItems-D0FuHGto.js → useWorkspaceItems-DQTYaq1R.js} +2 -2
  58. package/dist/client/assets/{useWorkspaceItems-D0FuHGto.js.map → useWorkspaceItems-DQTYaq1R.js.map} +1 -1
  59. package/dist/client/assets/workspaceEntityRoutes-Biw67kRR.js +2 -0
  60. package/dist/client/assets/workspaceEntityRoutes-Biw67kRR.js.map +1 -0
  61. package/dist/client/build-graph.json +32 -2
  62. package/dist/client/index.html +1 -1
  63. package/dist/server/api/deliveryGraph.d.ts +126 -0
  64. package/dist/server/api/deliveryGraph.d.ts.map +1 -1
  65. package/dist/server/api/index.js +2 -2
  66. package/dist/server/api/shares.d.ts +14 -0
  67. package/dist/server/api/shares.d.ts.map +1 -1
  68. package/dist/server/assets/{BindConfig-BjK10BEb.js → BindConfig-Dk3vjYZc.js} +7 -7
  69. package/dist/server/assets/{BindConfig-BjK10BEb.js.map → BindConfig-Dk3vjYZc.js.map} +1 -1
  70. package/dist/server/assets/{controlCenterApi-tZPvRPRH.js → controlCenterApi-Dsug4Rzi.js} +2 -2
  71. package/dist/server/assets/{controlCenterApi-tZPvRPRH.js.map → controlCenterApi-Dsug4Rzi.js.map} +1 -1
  72. package/dist/server/assets/{domainEvent-x7yeq-gU.js → domainEvent-CZLKMqgn.js} +13 -2
  73. package/dist/server/assets/{domainEvent-x7yeq-gU.js.map → domainEvent-CZLKMqgn.js.map} +1 -1
  74. package/dist/server/assets/{firstPartyServices-Y41P8uke.js → firstPartyServices-BWdrzdfD.js} +2 -2
  75. package/dist/server/assets/{firstPartyServices-Y41P8uke.js.map → firstPartyServices-BWdrzdfD.js.map} +1 -1
  76. package/dist/server/assets/{manualPluginSynchronization-C0aHB4UM.js → manualPluginSynchronization-CDnX9qXi.js} +64 -23
  77. package/dist/server/assets/manualPluginSynchronization-CDnX9qXi.js.map +1 -0
  78. package/dist/server/assets/{portfolioInvalidation-Ds9Xm4_P.js → portfolioInvalidation-iTUo5N4r.js} +26 -6
  79. package/dist/server/assets/portfolioInvalidation-iTUo5N4r.js.map +1 -0
  80. package/dist/server/assets/{readiness-CzU3vjYQ.js → readiness-CZBkcjLP.js} +2 -2
  81. package/dist/server/assets/{readiness-CzU3vjYQ.js.map → readiness-CZBkcjLP.js.map} +1 -1
  82. package/dist/server/build-graph.json +1 -0
  83. package/dist/server/domain/deliveryGraph.d.ts +14 -0
  84. package/dist/server/domain/deliveryGraph.d.ts.map +1 -1
  85. package/dist/server/domain/index.js +3 -3
  86. package/dist/server/index.js +4 -4
  87. package/dist/server/server/application/normalizedPluginPageMaterialization.d.ts +1 -1
  88. package/dist/server/server/application/normalizedPluginPageMaterialization.d.ts.map +1 -1
  89. package/dist/server/server/cli.js +4 -4
  90. package/dist/server/server/index.js +3 -3
  91. package/dist/server/server/persistence/Persistence.d.ts +35 -0
  92. package/dist/server/server/persistence/Persistence.d.ts.map +1 -1
  93. package/dist/server/server/persistence/repositories/delivery-graph/contract.d.ts +56 -0
  94. package/dist/server/server/persistence/repositories/delivery-graph/contract.d.ts.map +1 -1
  95. package/dist/server/server/persistence/repositories/delivery-graph/decode.d.ts +7 -0
  96. package/dist/server/server/persistence/repositories/delivery-graph/decode.d.ts.map +1 -1
  97. package/dist/server/server/persistence/repositories/delivery-graph/read.d.ts +35 -0
  98. package/dist/server/server/persistence/repositories/delivery-graph/read.d.ts.map +1 -1
  99. package/dist/server/server/persistence/repositories/delivery-graph/rows.d.ts +7 -0
  100. package/dist/server/server/persistence/repositories/delivery-graph/rows.d.ts.map +1 -1
  101. package/dist/server/server/persistence/repositories/delivery-graph/write.d.ts +14 -0
  102. package/dist/server/server/persistence/repositories/delivery-graph/write.d.ts.map +1 -1
  103. package/dist/server/server/persistence/repositories/deliveryGraphRepository.d.ts +35 -0
  104. package/dist/server/server/persistence/repositories/deliveryGraphRepository.d.ts.map +1 -1
  105. package/package.json +6 -6
  106. package/dist/client/assets/ReleaseWorkset-BhGacsgb.js +0 -2
  107. package/dist/client/assets/ReleaseWorkset-BhGacsgb.js.map +0 -1
  108. package/dist/client/assets/WorkspaceEntityRoute-DPci8Q8I.js +0 -30
  109. package/dist/client/assets/WorkspaceEntityRoute-DPci8Q8I.js.map +0 -1
  110. package/dist/client/assets/presentWorkspaceItems-BU__8LcC.js +0 -2
  111. package/dist/client/assets/presentWorkspaceItems-BU__8LcC.js.map +0 -1
  112. package/dist/client/assets/workspaceEntityRoutes-CRcfSq7c.js +0 -2
  113. package/dist/client/assets/workspaceEntityRoutes-CRcfSq7c.js.map +0 -1
  114. package/dist/server/assets/manualPluginSynchronization-C0aHB4UM.js.map +0 -1
  115. package/dist/server/assets/portfolioInvalidation-Ds9Xm4_P.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Ar as GovernedActionAuthorizationId, Bt as HumanActor, Cn as ReadinessReleaseRevision, Cr as EntityId, Dr as EvidenceId, En as ReadinessRuleVersion, Er as EvidenceClaimId, Fn as compareReadinessText, Fr as PersonId, Gn as deriveReleaseReadinessVerdict, Gr as ShareId, Hn as deriveReleaseReadinessNextEvaluationAt, Hr as ReleaseId, Ir as PluginConnectionId, Kn as readinessDefinitionsShapeIsV1, Kr as WorkspaceId, Mr as GovernedActionTransitionId, Pr as JobId, Rr as ReadinessAssessmentId, Rt as AgentActor, Sr as DomainEventId, Un as deriveReleaseReadinessSourceSummaries, Vn as deriveReleaseReadinessFindings, Wn as deriveReleaseReadinessStages, Wr as SessionId, Wt as Role, _r as SourceUrl, ar as MaximumPluginPayloadBytes, bt as SemanticVersion, cr as hasMaximumPluginJsonBytes, dn as ReadinessFactDefinition, gr as SourceRevision, hn as ReadinessFactObservation, hr as Revision, in as ReadinessArtifactRevision, jr as GovernedActionId, kr as GovernedActionAttemptId, mr as ProviderId, on as ReadinessCandidateDigest, or as MaximumPluginSyncPageBytes, rr as sortedReadinessUnique, sr as PluginPayloadJson, t as DomainEventCorrelationId, tr as readinessPolicyShapeIsV1, vr as VendorImmutableId, wn as ReadinessRuleId, wr as EnvironmentId, yr as UtcTimestamp, yt as PluginId } from "./domainEvent-x7yeq-gU.js";
1
+ import { Ar as GovernedActionAuthorizationId, Bt as HumanActor, Cn as ReadinessReleaseRevision, Cr as EntityId, Dr as EvidenceId, En as ReadinessRuleVersion, Er as EvidenceClaimId, Fn as compareReadinessText, Fr as PersonId, Gn as deriveReleaseReadinessVerdict, Gr as ShareId, Hn as deriveReleaseReadinessNextEvaluationAt, Hr as ReleaseId, Ir as PluginConnectionId, Kn as readinessDefinitionsShapeIsV1, Kr as WorkspaceId, Mr as GovernedActionTransitionId, Pr as JobId, Rr as ReadinessAssessmentId, Rt as AgentActor, Sr as DomainEventId, Un as deriveReleaseReadinessSourceSummaries, Vn as deriveReleaseReadinessFindings, Wn as deriveReleaseReadinessStages, Wr as SessionId, Wt as Role, _r as SourceUrl, ar as MaximumPluginPayloadBytes, bt as SemanticVersion, cr as hasMaximumPluginJsonBytes, dn as ReadinessFactDefinition, gr as SourceRevision, hn as ReadinessFactObservation, hr as Revision, in as ReadinessArtifactRevision, jr as GovernedActionId, kr as GovernedActionAttemptId, mr as ProviderId, on as ReadinessCandidateDigest, or as MaximumPluginSyncPageBytes, rr as sortedReadinessUnique, sr as PluginPayloadJson, t as DomainEventCorrelationId, tr as readinessPolicyShapeIsV1, vr as VendorImmutableId, wn as ReadinessRuleId, wr as EnvironmentId, yr as UtcTimestamp, yt as PluginId } from "./domainEvent-CZLKMqgn.js";
2
2
  import * as Schema from "effect/Schema";
3
3
  import * as DateTime from "effect/DateTime";
4
4
  import * as Effect from "effect/Effect";
@@ -1009,4 +1009,4 @@ var rollUpReleaseReadiness = (input) => {
1009
1009
  //#endregion
1010
1010
  export { GovernedActionProposalOrigin as $, GovernedActionAuthorizationBindingInput as A, PluginSyncPageV1 as At, GovernedActionEnvelopeMaterialV1 as B, GovernedActionTransitionMaterialV1 as C, PluginCheckpointV1 as Ct, reduceGovernedActionState as D, PluginEventId as Dt, isGovernedActionTerminalState as E, PluginEntityType as Et, GovernedActionAttemptDigest as F, AuthorizedShareTarget as Ft, GovernedActionIdempotencyKey as G, GovernedActionEvidenceReference as H, GovernedActionAttemptV1 as I, GovernedActionPolicyBinding as J, GovernedActionPluginConnectionAuthorityDigest as K, GovernedActionAuthorizationDigest as L, governedActionAuthorizationMatchesTransition as M, ReadPluginEntityRequestV1 as Mt, governedActionAuthorizationMismatches as N, ReadPluginEntityResultV1 as Nt, GovernedActionAuthorityBindingInput as O, PluginPageCursorV1 as Ot, governedActionPermissionGrants as P, AuthorizedShareGrant as Pt, GovernedActionPolicyId as Q, GovernedActionAuthorizationV1 as R, GovernedActionTransitionDigest as S, NormalizedPluginEventV1 as St, GovernedActionUnknownOutcome as T, PluginEntityReferenceV1 as Tt, GovernedActionEvidenceSet as U, GovernedActionEnvelopeV1 as V, GovernedActionEvidenceSetDigest as W, GovernedActionPolicyEvaluationDigest as X, GovernedActionPolicyDigest as Y, GovernedActionPolicyEvaluationV1 as Z, GovernedActionDenialReason as _, ReadyPluginActionPreflightV1 as _t, ReleaseReadinessCandidateMaterial as a, PluginActionCancellationResultV1 as at, GovernedActionTransitionCause as b, DiffInventoryPageRequestV1 as bt, normalizeReadinessRuleMaterial as c, PluginActionPreflightV1 as ct, PluginDiscoveryV1 as d, PluginActionReconciliationRequestV1 as dt, GovernedActionTargetSnapshotV1 as et, GovernedActionLifecycleHeadV1 as f, PluginActionReconciliationResultV1 as ft, GovernedActionCommandId as g, ProposePluginActionRequestV1 as gt, GovernedActionCommandDigest as h, PluginTerminalProviderReceiptV1 as ht, ReadinessRuleMaterial as i, PluginActionCancellationRequestV1 as it, governedActionAuthorityMismatches as j, PluginSyncRequestV1 as jt, GovernedActionAuthorityMismatch as k, PluginRelativePathV1 as kt, normalizeReleaseReadinessCandidateMaterial as l, PluginActionProposalV1 as lt, advanceGovernedActionLifecycle as m, PluginProviderReceiptV1 as mt, summarizeEnvironmentReadiness as n, BlockedPluginActionPreflightV1 as nt, ReleaseReadinessChildMaterial as o, PluginActionDispatchResultV1 as ot, GovernedActionProviderLineage as p, PluginProviderOperationId as pt, GovernedActionPluginConnectionRevision as q, EnvironmentReadinessCandidateMaterial as r, PluginAcceptedProviderReceiptV1 as rt, normalizeEnvironmentReadinessCandidateMaterial as s, PluginActionPayloadDigest as st, rollUpReleaseReadiness as t, AuthorizedPluginActionV1 as tt, PluginDiscoveryEndpointV1 as u, PluginActionReconciliationKey as ut, GovernedActionOutcomeSource as v, DiffContentRangeRequestV1 as vt, GovernedActionTransitionV1 as w, PluginDiffInventoryEntryV1 as wt, GovernedActionTransitionCommand as x, DiffInventoryPageV1 as xt, GovernedActionState as y, DiffContentRangeV1 as yt, GovernedActionEnvelopeDigest as z };
1011
1011
 
1012
- //# sourceMappingURL=readiness-CzU3vjYQ.js.map
1012
+ //# sourceMappingURL=readiness-CZBkcjLP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readiness-CzU3vjYQ.js","names":[],"sources":["../../../src/domain/authorizedShare.ts","../../../src/domain/plugins/events.ts","../../../src/domain/plugins/actions.ts","../../../src/domain/governedAction/model.ts","../../../src/domain/governedAction/bindings.ts","../../../src/domain/governedAction/stateMachine.ts","../../../src/domain/governedAction/lifecycle.ts","../../../src/domain/plugins/discovery.ts","../../../src/domain/readiness/material.ts","../../../src/domain/readiness/rollup.ts"],"sourcesContent":["import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport { EntityId, PersonId, SessionId, ShareId, WorkspaceId } from \"./identifiers.js\"\nimport { UtcTimestamp } from \"./utcTimestamp.js\"\n\n/** Exact normalized entity scope granted to one authenticated person. */\nexport const AuthorizedShareTarget = Schema.TaggedStruct(\"entity\", {\n entityId: EntityId\n})\n\n/** Decoded exact authorized-share target. */\nexport type AuthorizedShareTarget = typeof AuthorizedShareTarget.Type\n\n/** Durable authenticated grant with immutable creation and optional revocation evidence. */\nexport const AuthorizedShareGrant = Schema.Struct({\n workspaceId: WorkspaceId,\n shareId: ShareId,\n target: AuthorizedShareTarget,\n granteePersonId: PersonId,\n createdByPersonId: PersonId,\n createdBySessionId: SessionId,\n createdAt: UtcTimestamp,\n expiresAt: UtcTimestamp,\n revokedAt: Schema.NullOr(UtcTimestamp)\n}).check(\n Schema.makeFilter(\n ({ createdAt, expiresAt }) => DateTime.Order(createdAt, expiresAt) < 0,\n { expected: \"authorized share expiry after creation\" }\n ),\n Schema.makeFilter(\n ({ createdAt, revokedAt }) => revokedAt === null || DateTime.Order(createdAt, revokedAt) <= 0,\n { expected: \"authorized share revocation at or after creation\" }\n )\n)\n\n/** Decoded durable authorized-share grant. */\nexport type AuthorizedShareGrant = typeof AuthorizedShareGrant.Type\n","import * as Encoding from \"effect/Encoding\"\nimport * as Result from \"effect/Result\"\nimport * as Schema from \"effect/Schema\"\n\nimport { Revision, SourceUrl, VendorImmutableId } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport {\n hasMaximumPluginJsonBytes,\n MaximumPluginPayloadBytes,\n MaximumPluginSyncPageBytes,\n PluginPayloadJson\n} from \"./bounds.js\"\n\nconst boundedOpaque = (name: string, maximum: number) =>\n Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(maximum)).pipe(Schema.brand(name))\n\n/** Stable adapter event identity used to make checkpoint replay idempotent. */\nexport const PluginEventId = boundedOpaque(\"PluginEventId\", 512)\n\n/** Decoded adapter event identity. */\nexport type PluginEventId = typeof PluginEventId.Type\n\n/** Opaque bounded checkpoint owned by one plugin sync stream. */\nexport const PluginCheckpointV1 = boundedOpaque(\"PluginCheckpointV1\", 2_048)\n\n/** Decoded plugin checkpoint. */\nexport type PluginCheckpointV1 = typeof PluginCheckpointV1.Type\n\n/** Opaque page cursor for optional paginated reads. */\nexport const PluginPageCursorV1 = boundedOpaque(\"PluginPageCursorV1\", 2_048)\n\n/** Decoded plugin page cursor. */\nexport type PluginPageCursorV1 = typeof PluginPageCursorV1.Type\n\n/** Stable entity category emitted without vendor-specific response shapes. */\nexport const PluginEntityType = boundedOpaque(\"PluginEntityType\", 100)\n\n/** Decoded normalized entity type. */\nexport type PluginEntityType = typeof PluginEntityType.Type\n\nconst SafeSummary = Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(500))\nconst MaximumDiffContentBytes = 1_048_576\nconst MaximumDiffContentBase64Characters = 4 * Math.ceil(MaximumDiffContentBytes / 3)\nconst hasSafeRelativePathShape = Schema.makeFilter(\n (value: string) => {\n if (value.startsWith(\"/\") || value.includes(\"\\\\\") || /^[a-zA-Z]:/u.test(value)) return false\n return (\n value.split(\"/\").every((segment) => segment !== \"\" && segment !== \".\" && segment !== \"..\") &&\n Array.from(value).every((character) => {\n const codePoint = character.codePointAt(0)\n return (\n codePoint !== undefined &&\n !((codePoint >= 0 && codePoint <= 0x1f) || (codePoint >= 0x7f && codePoint <= 0x9f))\n )\n })\n )\n },\n { expected: \"a normalized provider-relative path without traversal or control characters\" }\n)\nconst hasMaximumDecodedDiffBytes = Schema.makeFilter(\n (value: string) => {\n const decoded = Encoding.decodeBase64(value)\n return Result.isSuccess(decoded) && decoded.success.byteLength <= MaximumDiffContentBytes\n },\n { expected: `base64 data decoding to at most ${MaximumDiffContentBytes} bytes` }\n)\n\n/** Normalized provider-relative path safe to carry across diff and storage boundaries. */\nexport const PluginRelativePathV1 = Schema.String.check(\n Schema.isNonEmpty(),\n Schema.isMaxLength(4_096),\n hasSafeRelativePathShape\n).pipe(Schema.brand(\"PluginRelativePathV1\"))\n\n/** Decoded normalized provider-relative path. */\nexport type PluginRelativePathV1 = typeof PluginRelativePathV1.Type\n\nconst PluginDiffContentBase64V1 = Schema.String.check(\n Schema.isMaxLength(MaximumDiffContentBase64Characters),\n Schema.isBase64(),\n hasMaximumDecodedDiffBytes\n)\nconst commonEventFields = {\n eventId: PluginEventId,\n observedAt: UtcTimestamp,\n revision: Revision\n}\nconst entityReferenceFields = {\n entityType: PluginEntityType,\n vendorImmutableId: VendorImmutableId\n}\n\n/** Adapter-owned reference to a provider entity; host scope is deliberately absent. */\nexport const PluginEntityReferenceV1 = Schema.Struct(entityReferenceFields)\n\n/** Decoded provider entity reference. */\nexport type PluginEntityReferenceV1 = typeof PluginEntityReferenceV1.Type\n\nconst UpsertEntity = Schema.TaggedStruct(\"UpsertEntity\", {\n ...commonEventFields,\n ...entityReferenceFields,\n sourceUrl: Schema.NullOr(SourceUrl),\n title: SafeSummary,\n attributes: Schema.Record(Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)), Schema.Json).check(\n hasMaximumPluginJsonBytes(MaximumPluginPayloadBytes)\n )\n})\n\nconst TombstoneEntity = Schema.TaggedStruct(\"TombstoneEntity\", {\n ...commonEventFields,\n ...entityReferenceFields,\n reason: SafeSummary\n})\n\nconst AppendEvidence = Schema.TaggedStruct(\"AppendEvidence\", {\n ...commonEventFields,\n evidenceId: boundedOpaque(\"PluginEvidenceId\", 512),\n subject: PluginEntityReferenceV1,\n evidenceType: boundedOpaque(\"PluginEvidenceType\", 100),\n summary: SafeSummary,\n capturedAt: UtcTimestamp,\n data: PluginPayloadJson\n})\n\nconst UpsertPerson = Schema.TaggedStruct(\"UpsertPerson\", {\n ...commonEventFields,\n vendorPersonId: boundedOpaque(\"PluginVendorPersonId\", 512),\n displayName: Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(200)),\n avatarUrl: Schema.NullOr(SourceUrl),\n active: Schema.Boolean\n})\n\nconst ProposeRelationship = Schema.TaggedStruct(\"ProposeRelationship\", {\n ...commonEventFields,\n relationshipId: boundedOpaque(\"PluginRelationshipId\", 512),\n from: PluginEntityReferenceV1,\n to: PluginEntityReferenceV1,\n relationshipType: boundedOpaque(\"PluginRelationshipType\", 100),\n confidence: Schema.Number.check(Schema.isBetween({ minimum: 0, maximum: 1 })),\n evidenceIds: Schema.Array(boundedOpaque(\"PluginRelationshipEvidenceId\", 512)).check(\n Schema.makeFilter((evidenceIds) => evidenceIds.length <= 100, {\n expected: \"at most 100 relationship evidence identities\"\n }),\n Schema.isUnique()\n )\n})\n\n/** Vendor-neutral event emitted by a plugin and scoped by the host on ingestion. */\nexport const NormalizedPluginEventV1 = Schema.Union([\n UpsertEntity,\n TombstoneEntity,\n AppendEvidence,\n UpsertPerson,\n ProposeRelationship\n]).pipe(Schema.toTaggedUnion(\"_tag\"))\n\n/** Decoded normalized plugin event. */\nexport type NormalizedPluginEventV1 = typeof NormalizedPluginEventV1.Type\n\n/** A fully decoded page whose events and checkpoint must commit atomically. */\nexport const PluginSyncPageV1 = Schema.Struct({\n events: Schema.Array(NormalizedPluginEventV1).check(\n Schema.makeFilter((events) => events.length <= 500, {\n expected: \"at most 500 normalized plugin events\"\n }),\n Schema.makeFilter((events) => new Set(events.map(({ eventId }) => eventId)).size === events.length, {\n expected: \"unique normalized plugin event identities within a page\"\n })\n ),\n checkpointAfterPage: PluginCheckpointV1,\n hasMore: Schema.Boolean\n})\n .check(hasMaximumPluginJsonBytes(MaximumPluginSyncPageBytes))\n .annotate({ identifier: \"PluginSyncPageV1\" })\n\n/** Decoded plugin sync page. */\nexport type PluginSyncPageV1 = typeof PluginSyncPageV1.Type\n\n/** Request to resume a logical plugin stream from an accepted checkpoint. */\nexport const PluginSyncRequestV1 = Schema.Struct({\n streamKey: boundedOpaque(\"PluginSyncStreamKey\", 100),\n checkpoint: Schema.NullOr(PluginCheckpointV1)\n}).annotate({ identifier: \"PluginSyncRequestV1\" })\n\n/** Decoded plugin sync request. */\nexport type PluginSyncRequestV1 = typeof PluginSyncRequestV1.Type\n\n/** Request for one normalized entity by its immutable provider reference. */\nexport const ReadPluginEntityRequestV1 = PluginEntityReferenceV1\n\n/** Decoded normalized entity read request. */\nexport type ReadPluginEntityRequestV1 = typeof ReadPluginEntityRequestV1.Type\n\nconst FoundPluginEntity = Schema.TaggedStruct(\"found\", {\n event: UpsertEntity\n})\nconst MissingPluginEntity = Schema.TaggedStruct(\"missing\", {\n reference: PluginEntityReferenceV1,\n observedAt: UtcTimestamp\n})\n\n/** Authoritative result of a normalized plugin entity read. */\nexport const ReadPluginEntityResultV1 = Schema.Union([FoundPluginEntity, MissingPluginEntity]).pipe(\n Schema.toTaggedUnion(\"_tag\")\n)\n\n/** Decoded normalized entity read result. */\nexport type ReadPluginEntityResultV1 = typeof ReadPluginEntityResultV1.Type\n\n/** One bounded file-like entry in a complete diff inventory. */\nexport const PluginDiffInventoryEntryV1 = Schema.Struct({\n path: PluginRelativePathV1,\n previousPath: Schema.NullOr(PluginRelativePathV1),\n status: Schema.Literals([\"added\", \"modified\", \"deleted\", \"renamed\", \"copied\"]),\n binary: Schema.Boolean,\n generated: Schema.Boolean,\n oversized: Schema.Boolean\n})\n\n/** Request for one page of a complete diff inventory. */\nexport const DiffInventoryPageRequestV1 = Schema.Struct({\n entity: PluginEntityReferenceV1,\n cursor: Schema.NullOr(PluginPageCursorV1)\n})\n\n/** A bounded diff inventory page. */\nexport const DiffInventoryPageV1 = Schema.Struct({\n entries: Schema.Array(PluginDiffInventoryEntryV1).check(\n Schema.makeFilter((entries) => entries.length <= 500, {\n expected: \"at most 500 diff inventory entries\"\n })\n ),\n nextCursor: Schema.NullOr(PluginPageCursorV1)\n})\n\n/** Request for a bounded byte range of before/after diff content. */\nexport const DiffContentRangeRequestV1 = Schema.Struct({\n entity: PluginEntityReferenceV1,\n path: PluginRelativePathV1,\n side: Schema.Literals([\"before\", \"after\"]),\n offset: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n length: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1_048_576 }))\n})\n\n/** Bounded content range with explicit availability metadata. */\nexport const DiffContentRangeV1 = Schema.Struct({\n bytesBase64: Schema.NullOr(PluginDiffContentBase64V1),\n totalBytes: Schema.NullOr(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n unavailableReason: Schema.NullOr(\n Schema.Literals([\"binary\", \"generated\", \"oversized\", \"missing\", \"provider-unavailable\"])\n )\n}).check(\n Schema.makeFilter(\n ({ bytesBase64, totalBytes, unavailableReason }) =>\n unavailableReason === null ? bytesBase64 !== null && totalBytes !== null : bytesBase64 === null,\n { expected: \"available content bytes or an explicit unavailable reason\" }\n )\n)\n\nexport type DiffInventoryPageRequestV1 = typeof DiffInventoryPageRequestV1.Type\nexport type DiffInventoryPageV1 = typeof DiffInventoryPageV1.Type\nexport type DiffContentRangeRequestV1 = typeof DiffContentRangeRequestV1.Type\nexport type DiffContentRangeV1 = typeof DiffContentRangeV1.Type\n","import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport { Revision } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport { PluginPayloadJson } from \"./bounds.js\"\nimport { PluginEntityReferenceV1 } from \"./events.js\"\n\nconst boundedOpaque = (name: string, maximum: number) =>\n Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(maximum)).pipe(Schema.brand(name))\n\nconst PositiveInteger = Schema.Int.check(Schema.isGreaterThan(0))\nconst SafeSummary = Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(1_000))\n\n/** Lowercase SHA-256 digest of a canonical governed-action payload. */\nexport const PluginActionPayloadDigest = Schema.String.check(\n Schema.isPattern(/^[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n).pipe(Schema.brand(\"PluginActionPayloadDigest\"))\n\n/** Decoded canonical payload digest. */\nexport type PluginActionPayloadDigest = typeof PluginActionPayloadDigest.Type\n\n/** Opaque provider locator used to reconcile a mutation without replaying it. */\nexport const PluginActionReconciliationKey = boundedOpaque(\"PluginActionReconciliationKey\", 512)\n\n/** Decoded provider reconciliation locator. */\nexport type PluginActionReconciliationKey = typeof PluginActionReconciliationKey.Type\n\n/** Opaque provider identity of one accepted or completed mutation. */\nexport const PluginProviderOperationId = boundedOpaque(\"PluginProviderOperationId\", 512)\n\n/** Decoded provider mutation identity. */\nexport type PluginProviderOperationId = typeof PluginProviderOperationId.Type\n\n/** Request for a provider-neutral action proposal; it cannot authorize execution. */\nexport const ProposePluginActionRequestV1 = Schema.Struct({\n actionKind: boundedOpaque(\"PluginActionKind\", 100),\n target: PluginEntityReferenceV1,\n expectedRevision: Revision,\n payload: PluginPayloadJson,\n evidenceIds: Schema.Array(boundedOpaque(\"PluginActionEvidenceId\", 512)).check(\n Schema.isUnique(),\n Schema.makeFilter((evidenceIds) => evidenceIds.length <= 100, {\n expected: \"at most 100 action evidence identities\"\n })\n )\n})\n\n/** Proposal returned to the host for later policy and human authorization. */\nexport const PluginActionProposalV1 = Schema.Struct({\n proposalKey: boundedOpaque(\"PluginActionProposalKey\", 512),\n capabilityVersion: PositiveInteger,\n request: ProposePluginActionRequestV1,\n payloadDigest: PluginActionPayloadDigest,\n summary: SafeSummary,\n impact: Schema.Struct({\n level: Schema.Literals([\"low\", \"medium\", \"high\", \"critical\"]),\n summary: SafeSummary\n }),\n proposedAt: UtcTimestamp\n})\n\n/** Host-authorized request accepted only by the sealed internal executor. */\nexport const AuthorizedPluginActionV1 = Schema.Struct({\n proposal: PluginActionProposalV1,\n idempotencyKey: boundedOpaque(\"PluginActionIdempotencyKey\", 512),\n payloadDigest: PluginActionPayloadDigest,\n authorizationId: boundedOpaque(\"PluginActionAuthorizationId\", 512),\n authorizedAt: UtcTimestamp,\n expiresAt: UtcTimestamp\n}).check(\n Schema.makeFilter(({ authorizedAt, expiresAt }) => DateTime.Order(authorizedAt, expiresAt) < 0, {\n expected: \"plugin action authorization to expire after it is issued\"\n }),\n Schema.makeFilter(({ payloadDigest, proposal }) => payloadDigest === proposal.payloadDigest, {\n expected: \"authorized payload digest to match its canonical proposal digest\"\n })\n)\n\nconst providerReceiptFields = {\n providerOperationId: PluginProviderOperationId,\n safeSummary: SafeSummary,\n observedAt: UtcTimestamp\n}\n\n/** Accepted provider work that remains unresolved and can be reconciled safely. */\nexport const PluginAcceptedProviderReceiptV1 = Schema.Struct({\n ...providerReceiptFields,\n status: Schema.Literal(\"accepted\"),\n reconciliationKey: PluginActionReconciliationKey\n})\n\n/** Terminal provider receipt safe to persist and display without raw response data. */\nexport const PluginTerminalProviderReceiptV1 = Schema.Struct({\n ...providerReceiptFields,\n status: Schema.Literals([\"succeeded\", \"failed\", \"cancelled\"])\n})\n\n/** Provider receipt that never represents accepted asynchronous work as terminal. */\nexport const PluginProviderReceiptV1 = Schema.Union([\n PluginAcceptedProviderReceiptV1,\n PluginTerminalProviderReceiptV1\n])\n\n/** Provider preflight that confirms the exact revision is ready for dispatch. */\nexport const ReadyPluginActionPreflightV1 = Schema.TaggedStruct(\"ready\", {\n checkedRevision: Revision,\n checkedAt: UtcTimestamp\n})\n\n/** Provider preflight that blocks dispatch with bounded safe reasons. */\nexport const BlockedPluginActionPreflightV1 = Schema.TaggedStruct(\"blocked\", {\n reasons: Schema.Array(SafeSummary).check(\n Schema.isNonEmpty(),\n Schema.makeFilter((reasons) => reasons.length <= 50, {\n expected: \"at most 50 preflight reasons\"\n })\n ),\n checkedAt: UtcTimestamp\n})\n\n/** Result of the final provider preflight before dispatch. */\nexport const PluginActionPreflightV1 = Schema.Union([\n ReadyPluginActionPreflightV1,\n BlockedPluginActionPreflightV1\n]).pipe(\n Schema.toTaggedUnion(\"_tag\")\n)\n\nconst ConfirmedDispatch = Schema.TaggedStruct(\"confirmed\", {\n receipt: PluginProviderReceiptV1\n})\nconst UnknownDispatch = Schema.TaggedStruct(\"unknown\", {\n reconciliationKey: PluginActionReconciliationKey,\n safeSummary: SafeSummary,\n observedAt: UtcTimestamp\n})\n\n/** Truthful immediate outcome of one authorized provider dispatch. */\nexport const PluginActionDispatchResultV1 = Schema.Union([ConfirmedDispatch, UnknownDispatch]).pipe(\n Schema.toTaggedUnion(\"_tag\")\n)\n\n/** Request to cancel an action after its durable lifecycle permits cancellation. */\nexport const PluginActionCancellationRequestV1 = Schema.Struct({\n idempotencyKey: boundedOpaque(\"PluginCancellationIdempotencyKey\", 512),\n providerOperationId: Schema.NullOr(PluginProviderOperationId),\n reconciliationKey: Schema.NullOr(PluginActionReconciliationKey)\n}).check(\n Schema.makeFilter(\n ({ providerOperationId, reconciliationKey }) => (providerOperationId === null) !== (reconciliationKey === null),\n { expected: \"exactly one provider operation or reconciliation key\" }\n )\n)\n\n/** Truthful cancellation response; provider completion may win the race. */\nexport const PluginActionCancellationResultV1 = Schema.Union([\n Schema.TaggedStruct(\"cancelled\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"cancelled\", { expected: \"a cancelled provider receipt\" })\n ),\n Schema.TaggedStruct(\"completed\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"succeeded\" || receipt.status === \"failed\", {\n expected: \"a terminal succeeded or failed provider receipt\"\n })\n ),\n Schema.TaggedStruct(\"unknown\", {\n reconciliationKey: PluginActionReconciliationKey,\n observedAt: UtcTimestamp\n })\n]).pipe(Schema.toTaggedUnion(\"_tag\"))\n\n/** Request to reconcile without replay; null locates the mutation by its durable idempotency key. */\nexport const PluginActionReconciliationRequestV1 = Schema.Struct({\n reconciliationKey: Schema.NullOr(PluginActionReconciliationKey),\n idempotencyKey: boundedOpaque(\"PluginReconciliationIdempotencyKey\", 512),\n payloadDigest: PluginActionPayloadDigest\n})\n\n/** Reconciled provider state. Cancelled means the mutation provably did not occur. */\nexport const PluginActionReconciliationResultV1 = Schema.Union([\n Schema.TaggedStruct(\"pending\", { checkedAt: UtcTimestamp }),\n Schema.TaggedStruct(\"succeeded\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"succeeded\", { expected: \"a succeeded provider receipt\" })\n ),\n Schema.TaggedStruct(\"failed\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"failed\", { expected: \"a failed provider receipt\" })\n ),\n Schema.TaggedStruct(\"cancelled\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"cancelled\", { expected: \"a cancelled provider receipt\" })\n )\n]).pipe(Schema.toTaggedUnion(\"_tag\"))\n\nexport type ProposePluginActionRequestV1 = typeof ProposePluginActionRequestV1.Type\nexport type PluginActionProposalV1 = typeof PluginActionProposalV1.Type\nexport type AuthorizedPluginActionV1 = typeof AuthorizedPluginActionV1.Type\nexport type PluginAcceptedProviderReceiptV1 = typeof PluginAcceptedProviderReceiptV1.Type\nexport type PluginTerminalProviderReceiptV1 = typeof PluginTerminalProviderReceiptV1.Type\nexport type PluginProviderReceiptV1 = typeof PluginProviderReceiptV1.Type\nexport type ReadyPluginActionPreflightV1 = typeof ReadyPluginActionPreflightV1.Type\nexport type BlockedPluginActionPreflightV1 = typeof BlockedPluginActionPreflightV1.Type\nexport type PluginActionPreflightV1 = typeof PluginActionPreflightV1.Type\nexport type PluginActionDispatchResultV1 = typeof PluginActionDispatchResultV1.Type\nexport type PluginActionCancellationRequestV1 = typeof PluginActionCancellationRequestV1.Type\nexport type PluginActionCancellationResultV1 = typeof PluginActionCancellationResultV1.Type\nexport type PluginActionReconciliationRequestV1 = typeof PluginActionReconciliationRequestV1.Type\nexport type PluginActionReconciliationResultV1 = typeof PluginActionReconciliationResultV1.Type\n","import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport { AgentActor, HumanActor, Role } from \"../actors.js\"\nimport { DomainEventCorrelationId } from \"../domainEvent.js\"\nimport {\n DomainEventId,\n EntityId,\n EvidenceClaimId,\n EvidenceId,\n GovernedActionAttemptId,\n GovernedActionAuthorizationId,\n GovernedActionId,\n JobId,\n PluginConnectionId,\n SessionId,\n WorkspaceId\n} from \"../identifiers.js\"\nimport { PluginActionPayloadDigest, PluginActionProposalV1, ReadyPluginActionPreflightV1 } from \"../plugins/actions.js\"\nimport { PluginId, SemanticVersion } from \"../plugins/descriptor.js\"\nimport { PluginEntityType } from \"../plugins/events.js\"\nimport { ProviderId, Revision, SourceRevision } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\n\nconst PositiveInteger = Schema.Int.check(Schema.isGreaterThan(0))\nconst boundedIdentifier = (name: string, maximumLength: number) =>\n Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(maximumLength),\n Schema.isPattern(/^[A-Za-z0-9._:/-]+$/u, { expected: \"a bounded action identifier\" })\n ).pipe(Schema.brand(name))\nconst sha256Digest = (name: string) =>\n Schema.String.check(\n Schema.isPattern(/^sha256:[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n ).pipe(Schema.brand(name))\nconst compareText = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0\nconst isCanonicalText = (values: ReadonlyArray<string>): boolean =>\n values.every((value, index) => index === 0 || compareText(values[index - 1] ?? \"\", value) < 0)\n\n/** Digest of every immutable field in a governed action envelope. */\nexport const GovernedActionEnvelopeDigest = sha256Digest(\"GovernedActionEnvelopeDigest\")\n\n/** Decoded governed-action envelope digest. */\nexport type GovernedActionEnvelopeDigest = typeof GovernedActionEnvelopeDigest.Type\n\n/** Digest of the canonical evidence-reference set bound to an action. */\nexport const GovernedActionEvidenceSetDigest = sha256Digest(\"GovernedActionEvidenceSetDigest\")\n\n/** Decoded governed-action evidence-set digest. */\nexport type GovernedActionEvidenceSetDigest = typeof GovernedActionEvidenceSetDigest.Type\n\n/** Digest of a fresh policy evaluation persisted with one exact dispatch attempt. */\nexport const GovernedActionPolicyEvaluationDigest = sha256Digest(\"GovernedActionPolicyEvaluationDigest\")\n\n/** Decoded fresh-policy evaluation digest. */\nexport type GovernedActionPolicyEvaluationDigest = typeof GovernedActionPolicyEvaluationDigest.Type\n\n/** Digest of every immutable field in one human action authorization. */\nexport const GovernedActionAuthorizationDigest = sha256Digest(\"GovernedActionAuthorizationDigest\")\n\n/** Decoded governed-action authorization digest. */\nexport type GovernedActionAuthorizationDigest = typeof GovernedActionAuthorizationDigest.Type\n\n/** Digest of every immutable field in one durable dispatch attempt. */\nexport const GovernedActionAttemptDigest = sha256Digest(\"GovernedActionAttemptDigest\")\n\n/** Decoded governed-action attempt digest. */\nexport type GovernedActionAttemptDigest = typeof GovernedActionAttemptDigest.Type\n\n/** Digest of the exact versioned policy snapshot used for authorization. */\nexport const GovernedActionPolicyDigest = sha256Digest(\"GovernedActionPolicyDigest\")\n\n/** Decoded governed-action policy digest. */\nexport type GovernedActionPolicyDigest = typeof GovernedActionPolicyDigest.Type\n\n/** Stable identity of one governed-action policy family. */\nexport const GovernedActionPolicyId = boundedIdentifier(\"GovernedActionPolicyId\", 200)\n\n/** Decoded governed-action policy identity. */\nexport type GovernedActionPolicyId = typeof GovernedActionPolicyId.Type\n\n/** Workspace-connection scoped key that deduplicates one governed provider mutation. */\nexport const GovernedActionIdempotencyKey = Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(512)\n).pipe(Schema.brand(\"GovernedActionIdempotencyKey\"))\n\n/** Decoded governed-action idempotency key. */\nexport type GovernedActionIdempotencyKey = typeof GovernedActionIdempotencyKey.Type\n\n/** Optimistic revision of the exact configured plugin connection authorized for dispatch. */\nexport const GovernedActionPluginConnectionRevision = PositiveInteger.pipe(\n Schema.brand(\"GovernedActionPluginConnectionRevision\")\n)\n\n/** Decoded configured-connection revision bound to a governed action. */\nexport type GovernedActionPluginConnectionRevision = typeof GovernedActionPluginConnectionRevision.Type\n\n/** Non-secret digest that changes with configuration, credentials, or resolved provider account. */\nexport const GovernedActionPluginConnectionAuthorityDigest = sha256Digest(\n \"GovernedActionPluginConnectionAuthorityDigest\"\n)\n\n/** Decoded configured-connection authority generation. */\nexport type GovernedActionPluginConnectionAuthorityDigest = typeof GovernedActionPluginConnectionAuthorityDigest.Type\n\n/** Versioned policy and permission snapshot bound into an action proposal. */\nexport const GovernedActionPolicyBinding = Schema.Struct({\n policyId: GovernedActionPolicyId,\n policyVersion: PositiveInteger,\n policyDigest: GovernedActionPolicyDigest,\n requiredPermission: Role\n})\n\n/** Decoded governed-action policy binding. */\nexport type GovernedActionPolicyBinding = typeof GovernedActionPolicyBinding.Type\n\n/** Fresh policy result recomputed immediately before a provider mutation may dispatch. */\nexport const GovernedActionPolicyEvaluationV1 = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n policy: GovernedActionPolicyBinding,\n payloadDigest: PluginActionPayloadDigest,\n evidenceSetDigest: GovernedActionEvidenceSetDigest,\n expectedRevision: Revision,\n decision: Schema.Literals([\"allowed\", \"denied\"]),\n evaluatedAt: UtcTimestamp\n})\n\n/** Decoded fresh policy evaluation for one exact governed action. */\nexport type GovernedActionPolicyEvaluationV1 = typeof GovernedActionPolicyEvaluationV1.Type\n\n/** Current normalized target and exact provider provenance checked before dispatch. */\nexport const GovernedActionTargetSnapshotV1 = Schema.Struct({\n workspaceId: WorkspaceId,\n entityId: EntityId,\n entityType: PluginEntityType,\n sourceRevision: SourceRevision\n})\n\n/** Decoded current target snapshot used by governed-action authority. */\nexport type GovernedActionTargetSnapshotV1 = typeof GovernedActionTargetSnapshotV1.Type\n\n/** Exact immutable evidence state considered by policy at proposal time. */\nexport const GovernedActionEvidenceReference = Schema.Struct({\n workspaceId: WorkspaceId,\n evidenceId: EvidenceId,\n evidenceClaimIds: Schema.Array(EvidenceClaimId).check(\n Schema.isUnique(),\n Schema.makeFilter(isCanonicalText, { expected: \"evidence claim identities in canonical order\" }),\n Schema.makeFilter((evidenceClaimIds) => evidenceClaimIds.length <= 100, {\n expected: \"at most 100 evidence claims per evidence item\"\n })\n ),\n observedAt: UtcTimestamp,\n validUntil: Schema.NullOr(UtcTimestamp),\n currentUntil: Schema.NullOr(UtcTimestamp),\n evaluatedAt: UtcTimestamp,\n source: Schema.Literals([\"current\", \"stale\", \"missing\", \"unavailable\"]),\n validity: Schema.Literals([\"valid\", \"expired\"])\n}).check(\n Schema.makeFilter(\n ({ evaluatedAt, observedAt }) => DateTime.Order(observedAt, evaluatedAt) <= 0,\n { expected: \"evidence evaluation not to precede observation\" }\n ),\n Schema.makeFilter(\n ({ observedAt, validUntil }) => validUntil === null || DateTime.Order(observedAt, validUntil) < 0,\n { expected: \"evidence validity to end after observation\" }\n ),\n Schema.makeFilter(\n ({ currentUntil, observedAt }) => currentUntil === null || DateTime.Order(observedAt, currentUntil) < 0,\n { expected: \"evidence freshness to end after observation\" }\n ),\n Schema.makeFilter(\n ({ currentUntil, evaluatedAt, source }) => {\n if (source === \"current\") return currentUntil === null || DateTime.Order(evaluatedAt, currentUntil) < 0\n if (source === \"stale\") return currentUntil !== null && DateTime.Order(evaluatedAt, currentUntil) >= 0\n return currentUntil === null\n },\n { expected: \"evidence source state to match its evaluation and freshness window\" }\n ),\n Schema.makeFilter(\n ({ evaluatedAt, validUntil, validity }) => {\n const expectedValidity = validUntil === null || DateTime.Order(evaluatedAt, validUntil) < 0\n ? \"valid\"\n : \"expired\"\n return validity === expectedValidity\n },\n { expected: \"evidence validity to match its evaluation and validity window\" }\n )\n)\n\n/** Decoded immutable evidence reference. */\nexport type GovernedActionEvidenceReference = typeof GovernedActionEvidenceReference.Type\n\n/** Human or agent provenance for a proposal; neither form grants execution authority. */\nexport const GovernedActionProposalOrigin = Schema.TaggedUnion({\n human: {\n actor: HumanActor,\n sessionId: SessionId\n },\n agent: {\n actor: AgentActor,\n jobId: JobId,\n initiatingSessionId: Schema.NullOr(SessionId)\n }\n})\n\n/** Decoded governed-action proposal provenance. */\nexport type GovernedActionProposalOrigin = typeof GovernedActionProposalOrigin.Type\n\nconst canonicalEvidenceReferences = Schema.makeFilter(\n (evidence: ReadonlyArray<GovernedActionEvidenceReference>) =>\n isCanonicalText(evidence.map(({ evidenceId }) => evidenceId)),\n { expected: \"unique evidence references in canonical evidence-id order\" }\n)\n\n/** Bounded canonical set of immutable evidence references used by action authority. */\nexport const GovernedActionEvidenceSet = Schema.Array(GovernedActionEvidenceReference).check(\n Schema.makeFilter((evidence) => evidence.length <= 100, { expected: \"at most 100 evidence references\" }),\n canonicalEvidenceReferences\n)\n\n/** Decoded governed-action evidence set. */\nexport type GovernedActionEvidenceSet = typeof GovernedActionEvidenceSet.Type\n\nconst governedActionEnvelopeMaterialFields = {\n schemaVersion: Schema.Literal(1),\n actionId: GovernedActionId,\n idempotencyKey: GovernedActionIdempotencyKey,\n workspaceId: WorkspaceId,\n pluginConnectionId: PluginConnectionId,\n pluginConnectionRevision: GovernedActionPluginConnectionRevision,\n pluginConnectionAuthorityDigest: GovernedActionPluginConnectionAuthorityDigest,\n pluginId: PluginId,\n pluginContractVersion: SemanticVersion,\n pluginAdapterVersion: SemanticVersion,\n providerId: ProviderId,\n capability: Schema.Struct({\n capabilityId: Schema.Literal(\"action.execute\"),\n version: PositiveInteger\n }),\n targetEntityId: EntityId,\n proposal: PluginActionProposalV1,\n evidence: GovernedActionEvidenceSet,\n evidenceSetDigest: GovernedActionEvidenceSetDigest,\n policy: GovernedActionPolicyBinding,\n origin: GovernedActionProposalOrigin,\n proposalExpiresAt: UtcTimestamp,\n causationId: Schema.NullOr(DomainEventId),\n correlationId: Schema.NullOr(DomainEventCorrelationId)\n}\n\n/** Complete digest-free material used to derive an immutable action envelope identity. */\nexport const GovernedActionEnvelopeMaterialV1 = Schema.Struct(governedActionEnvelopeMaterialFields).check(\n Schema.makeFilter(\n ({ capability, proposal }) => capability.version === proposal.capabilityVersion,\n { expected: \"envelope capability version to match the proposal capability version\" }\n ),\n Schema.makeFilter(\n ({ proposal, proposalExpiresAt }) => DateTime.Order(proposal.proposedAt, proposalExpiresAt) < 0,\n { expected: \"action proposal to expire after it is created\" }\n ),\n Schema.makeFilter(\n ({ evidence, workspaceId }) => evidence.every((reference) => reference.workspaceId === workspaceId),\n { expected: \"every governed-action evidence reference to belong to the action workspace\" }\n )\n)\n\n/** Decoded digest-free V1 governed-action envelope material. */\nexport type GovernedActionEnvelopeMaterialV1 = typeof GovernedActionEnvelopeMaterialV1.Type\n\n/** Immutable, versioned host authority for one proposed provider mutation. */\nexport const GovernedActionEnvelopeV1 = Schema.Struct({\n ...governedActionEnvelopeMaterialFields,\n envelopeDigest: GovernedActionEnvelopeDigest\n}).check(\n Schema.makeFilter(\n ({ capability, proposal }) => capability.version === proposal.capabilityVersion,\n { expected: \"envelope capability version to match the proposal capability version\" }\n ),\n Schema.makeFilter(\n ({ proposal, proposalExpiresAt }) => DateTime.Order(proposal.proposedAt, proposalExpiresAt) < 0,\n { expected: \"action proposal to expire after it is created\" }\n ),\n Schema.makeFilter(\n ({ evidence, workspaceId }) => evidence.every((reference) => reference.workspaceId === workspaceId),\n { expected: \"every governed-action evidence reference to belong to the action workspace\" }\n )\n)\n\n/** Decoded immutable V1 governed-action envelope. */\nexport type GovernedActionEnvelopeV1 = typeof GovernedActionEnvelopeV1.Type\n\n/** Human authorization bound to the complete immutable action and policy inputs. */\nexport const GovernedActionAuthorizationV1 = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n authorizationId: GovernedActionAuthorizationId,\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n pluginConnectionId: PluginConnectionId,\n pluginConnectionRevision: GovernedActionPluginConnectionRevision,\n pluginConnectionAuthorityDigest: GovernedActionPluginConnectionAuthorityDigest,\n actionEnvelopeDigest: GovernedActionEnvelopeDigest,\n idempotencyKey: GovernedActionIdempotencyKey,\n payloadDigest: PluginActionPayloadDigest,\n evidenceSetDigest: GovernedActionEvidenceSetDigest,\n policyDigest: GovernedActionPolicyDigest,\n expectedRevision: Revision,\n capabilityVersion: PositiveInteger,\n actor: HumanActor,\n sessionId: SessionId,\n sessionPermission: Role,\n sessionExpiresAt: UtcTimestamp,\n requiredPermission: Role,\n authorizedAt: UtcTimestamp,\n expiresAt: UtcTimestamp\n}).check(\n Schema.makeFilter(\n ({ authorizedAt, expiresAt }) => DateTime.Order(authorizedAt, expiresAt) < 0,\n { expected: \"governed-action authorization to expire after it is issued\" }\n ),\n Schema.makeFilter(\n ({ expiresAt, sessionExpiresAt }) => DateTime.Order(expiresAt, sessionExpiresAt) <= 0,\n { expected: \"governed-action authorization not to outlive its authenticated session\" }\n )\n)\n\n/** Decoded immutable human authorization. */\nexport type GovernedActionAuthorizationV1 = typeof GovernedActionAuthorizationV1.Type\n\n/** Durable dispatch intent created only after an exact ready preflight. */\nexport const GovernedActionAttemptV1 = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n attemptId: GovernedActionAttemptId,\n authorizationId: GovernedActionAuthorizationId,\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n pluginConnectionId: PluginConnectionId,\n idempotencyKey: GovernedActionIdempotencyKey,\n attemptNumber: Schema.Literal(1),\n actionEnvelopeDigest: GovernedActionEnvelopeDigest,\n expectedRevision: Revision,\n policyEvaluationDigest: GovernedActionPolicyEvaluationDigest,\n preflight: ReadyPluginActionPreflightV1,\n startedAt: UtcTimestamp\n}).check(\n Schema.makeFilter(\n ({ expectedRevision, preflight }) => expectedRevision === preflight.checkedRevision,\n { expected: \"dispatch intent revision to match the ready preflight revision\" }\n ),\n Schema.makeFilter(\n ({ preflight, startedAt }) => DateTime.Order(preflight.checkedAt, startedAt) <= 0,\n { expected: \"dispatch intent not to precede its ready preflight\" }\n )\n)\n\n/** Decoded immutable dispatch intent. */\nexport type GovernedActionAttemptV1 = typeof GovernedActionAttemptV1.Type\n","import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport type { Role } from \"../actors.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport { GovernedActionAttemptV1, GovernedActionAuthorizationV1, GovernedActionEnvelopeV1 } from \"./model.js\"\nimport type { GovernedActionTransitionV1 } from \"./stateMachine.js\"\n\n/** Closed reasons why durable authorization or dispatch intent does not match its action. */\nexport const GovernedActionAuthorityMismatch = Schema.Literals([\n \"authorization-action-mismatch\",\n \"authorization-workspace-mismatch\",\n \"authorization-connection-mismatch\",\n \"authorization-connection-revision-mismatch\",\n \"authorization-connection-authority-mismatch\",\n \"authorization-envelope-mismatch\",\n \"authorization-idempotency-mismatch\",\n \"authorization-payload-mismatch\",\n \"authorization-evidence-mismatch\",\n \"authorization-policy-mismatch\",\n \"authorization-revision-mismatch\",\n \"authorization-capability-mismatch\",\n \"authorization-permission-mismatch\",\n \"authorization-outside-proposal-window\",\n \"authorization-expired\",\n \"authorization-session-expired\",\n \"evidence-not-current\",\n \"evidence-set-changed\",\n \"evidence-workspace-mismatch\",\n \"session-id-mismatch\",\n \"session-actor-mismatch\",\n \"session-workspace-mismatch\",\n \"session-permission-mismatch\",\n \"session-revoked\",\n \"authorization-session-chronology\",\n \"current-plugin-connection-mismatch\",\n \"current-plugin-workspace-mismatch\",\n \"current-plugin-provider-mismatch\",\n \"current-plugin-revision-mismatch\",\n \"current-plugin-authority-mismatch\",\n \"current-plugin-unavailable\",\n \"current-plugin-mismatch\",\n \"current-capability-unavailable\",\n \"current-capability-version-mismatch\",\n \"current-policy-denied\",\n \"current-policy-mismatch\",\n \"current-target-workspace-mismatch\",\n \"current-target-entity-mismatch\",\n \"current-target-type-mismatch\",\n \"current-target-source-mismatch\",\n \"current-target-revision-mismatch\",\n \"attempt-action-mismatch\",\n \"attempt-authorization-mismatch\",\n \"attempt-workspace-mismatch\",\n \"attempt-connection-mismatch\",\n \"attempt-envelope-mismatch\",\n \"attempt-idempotency-mismatch\",\n \"attempt-policy-evaluation-mismatch\",\n \"attempt-revision-mismatch\",\n \"attempt-outside-authorization-window\"\n])\n\n/** Decoded governed-action authority mismatch. */\nexport type GovernedActionAuthorityMismatch = typeof GovernedActionAuthorityMismatch.Type\n\n/** Complete aggregate authority checked immediately before durable dispatch intent. */\nexport const GovernedActionAuthorityBindingInput = Schema.Struct({\n envelope: GovernedActionEnvelopeV1,\n authorization: GovernedActionAuthorizationV1,\n attempt: GovernedActionAttemptV1,\n evaluatedAt: UtcTimestamp\n})\n\n/** Decoded aggregate authority inputs checked immediately before dispatch. */\nexport type GovernedActionAuthorityBindingInput = typeof GovernedActionAuthorityBindingInput.Type\n\n/** Immutable authorization inputs that can be verified before a dispatch attempt exists. */\nexport const GovernedActionAuthorizationBindingInput = Schema.Struct({\n envelope: GovernedActionEnvelopeV1,\n authorization: GovernedActionAuthorizationV1\n})\n\n/** Decoded authorization-only binding inputs. */\nexport type GovernedActionAuthorizationBindingInput = typeof GovernedActionAuthorizationBindingInput.Type\n\n/** Explicit V1 permission implication: workspace owner or an exact scoped role. */\nexport const governedActionPermissionGrants = (sessionPermission: Role, requiredPermission: Role): boolean =>\n sessionPermission === \"workspace-owner\" || sessionPermission === requiredPermission\n\n/** Return every fail-closed mismatch between an envelope and its human grant. */\nexport const governedActionAuthorizationMismatches = ({\n authorization,\n envelope\n}: GovernedActionAuthorizationBindingInput): ReadonlyArray<GovernedActionAuthorityMismatch> => {\n const mismatches: Array<GovernedActionAuthorityMismatch> = []\n const addMismatch = (condition: boolean, mismatch: GovernedActionAuthorityMismatch): void => {\n if (condition) mismatches.push(mismatch)\n }\n\n addMismatch(authorization.actionId !== envelope.actionId, \"authorization-action-mismatch\")\n addMismatch(authorization.workspaceId !== envelope.workspaceId, \"authorization-workspace-mismatch\")\n addMismatch(\n authorization.pluginConnectionId !== envelope.pluginConnectionId,\n \"authorization-connection-mismatch\"\n )\n addMismatch(\n authorization.pluginConnectionRevision !== envelope.pluginConnectionRevision,\n \"authorization-connection-revision-mismatch\"\n )\n addMismatch(\n authorization.pluginConnectionAuthorityDigest !== envelope.pluginConnectionAuthorityDigest,\n \"authorization-connection-authority-mismatch\"\n )\n addMismatch(\n authorization.actionEnvelopeDigest !== envelope.envelopeDigest,\n \"authorization-envelope-mismatch\"\n )\n addMismatch(authorization.idempotencyKey !== envelope.idempotencyKey, \"authorization-idempotency-mismatch\")\n addMismatch(\n authorization.payloadDigest !== envelope.proposal.payloadDigest,\n \"authorization-payload-mismatch\"\n )\n addMismatch(\n authorization.evidenceSetDigest !== envelope.evidenceSetDigest,\n \"authorization-evidence-mismatch\"\n )\n addMismatch(authorization.policyDigest !== envelope.policy.policyDigest, \"authorization-policy-mismatch\")\n addMismatch(\n authorization.expectedRevision !== envelope.proposal.request.expectedRevision,\n \"authorization-revision-mismatch\"\n )\n addMismatch(\n authorization.capabilityVersion !== envelope.capability.version,\n \"authorization-capability-mismatch\"\n )\n addMismatch(\n authorization.requiredPermission !== envelope.policy.requiredPermission,\n \"authorization-permission-mismatch\"\n )\n addMismatch(\n !governedActionPermissionGrants(authorization.sessionPermission, authorization.requiredPermission),\n \"authorization-permission-mismatch\"\n )\n addMismatch(\n DateTime.Order(authorization.authorizedAt, envelope.proposal.proposedAt) < 0 ||\n DateTime.Order(authorization.authorizedAt, envelope.proposalExpiresAt) >= 0 ||\n DateTime.Order(authorization.expiresAt, envelope.proposalExpiresAt) > 0,\n \"authorization-outside-proposal-window\"\n )\n\n return mismatches\n}\n\n/** Whether a human grant is attributable to its exact immutable authorize transition. */\nexport const governedActionAuthorizationMatchesTransition = (\n authorization: GovernedActionAuthorizationV1,\n transition: GovernedActionTransitionV1\n): boolean =>\n transition.command._tag === \"authorize\" &&\n transition.command.authorizationId === authorization.authorizationId &&\n transition.actionId === authorization.actionId &&\n transition.workspaceId === authorization.workspaceId &&\n transition.actionEnvelopeDigest === authorization.actionEnvelopeDigest &&\n DateTime.Order(transition.occurredAt, authorization.authorizedAt) === 0 &&\n transition.cause._tag === \"human\" &&\n transition.cause.actor.personId === authorization.actor.personId &&\n transition.cause.sessionId === authorization.sessionId\n\n/** Return every fail-closed mismatch between an envelope, human grant, and dispatch intent. */\nexport const governedActionAuthorityMismatches = ({\n attempt,\n authorization,\n envelope,\n evaluatedAt\n}: GovernedActionAuthorityBindingInput): ReadonlyArray<GovernedActionAuthorityMismatch> => {\n const mismatches: Array<GovernedActionAuthorityMismatch> = [\n ...governedActionAuthorizationMismatches({ authorization, envelope })\n ]\n const addMismatch = (condition: boolean, mismatch: GovernedActionAuthorityMismatch): void => {\n if (condition) mismatches.push(mismatch)\n }\n\n addMismatch(\n DateTime.Order(evaluatedAt, authorization.expiresAt) >= 0 ||\n DateTime.Order(evaluatedAt, envelope.proposalExpiresAt) >= 0,\n \"authorization-expired\"\n )\n addMismatch(\n DateTime.Order(evaluatedAt, authorization.sessionExpiresAt) >= 0,\n \"authorization-session-expired\"\n )\n addMismatch(\n envelope.evidence.some(({ currentUntil, source, validUntil }) =>\n source !== \"current\" ||\n (currentUntil !== null && DateTime.Order(evaluatedAt, currentUntil) >= 0) ||\n (validUntil !== null && DateTime.Order(evaluatedAt, validUntil) >= 0)\n ),\n \"evidence-not-current\"\n )\n\n addMismatch(attempt.actionId !== envelope.actionId, \"attempt-action-mismatch\")\n addMismatch(attempt.authorizationId !== authorization.authorizationId, \"attempt-authorization-mismatch\")\n addMismatch(attempt.workspaceId !== envelope.workspaceId, \"attempt-workspace-mismatch\")\n addMismatch(attempt.pluginConnectionId !== envelope.pluginConnectionId, \"attempt-connection-mismatch\")\n addMismatch(attempt.actionEnvelopeDigest !== envelope.envelopeDigest, \"attempt-envelope-mismatch\")\n addMismatch(attempt.idempotencyKey !== envelope.idempotencyKey, \"attempt-idempotency-mismatch\")\n addMismatch(attempt.expectedRevision !== envelope.proposal.request.expectedRevision, \"attempt-revision-mismatch\")\n addMismatch(\n DateTime.Order(attempt.preflight.checkedAt, authorization.authorizedAt) < 0 ||\n DateTime.Order(attempt.startedAt, authorization.authorizedAt) < 0 ||\n DateTime.Order(attempt.startedAt, authorization.expiresAt) >= 0 ||\n DateTime.Order(attempt.startedAt, envelope.proposalExpiresAt) >= 0 ||\n DateTime.Order(attempt.startedAt, evaluatedAt) > 0,\n \"attempt-outside-authorization-window\"\n )\n\n return mismatches\n}\n","import * as Schema from \"effect/Schema\"\n\nimport { AgentActor, HumanActor } from \"../actors.js\"\nimport { DomainEventCorrelationId } from \"../domainEvent.js\"\nimport {\n DomainEventId,\n GovernedActionAttemptId,\n GovernedActionAuthorizationId,\n GovernedActionId,\n GovernedActionTransitionId,\n JobId,\n SessionId,\n WorkspaceId\n} from \"../identifiers.js\"\nimport {\n PluginAcceptedProviderReceiptV1,\n PluginActionReconciliationKey,\n PluginProviderOperationId,\n PluginTerminalProviderReceiptV1\n} from \"../plugins/actions.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport { GovernedActionEnvelopeDigest } from \"./model.js\"\n\nconst PositiveInteger = Schema.Int.check(Schema.isGreaterThan(0))\nconst SafeReason = Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(1_000))\nconst boundedIdentifier = (name: string, maximumLength: number) =>\n Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(maximumLength),\n Schema.isPattern(/^[A-Za-z0-9._:/-]+$/u, { expected: \"a bounded action identifier\" })\n ).pipe(Schema.brand(name))\n\n/** Complete persisted lifecycle states for a governed action. */\nexport const GovernedActionState = Schema.Literals([\n \"proposed\",\n \"authorized\",\n \"denied\",\n \"expired\",\n \"cancelled\",\n \"started\",\n \"cancel-requested\",\n \"cancel-requested-unknown\",\n \"succeeded\",\n \"failed\",\n \"unknown\"\n])\n\n/** Decoded governed-action lifecycle state. */\nexport type GovernedActionState = typeof GovernedActionState.Type\n\n/** Stable identity supplied by a caller to deduplicate one lifecycle command. */\nexport const GovernedActionCommandId = boundedIdentifier(\"GovernedActionCommandId\", 512)\n\n/** Decoded governed-action command identity. */\nexport type GovernedActionCommandId = typeof GovernedActionCommandId.Type\n\n/** Digest of one canonical transition command used to reject changed command retries. */\nexport const GovernedActionCommandDigest = Schema.String.check(\n Schema.isPattern(/^sha256:[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n).pipe(Schema.brand(\"GovernedActionCommandDigest\"))\n\n/** Decoded governed-action command digest. */\nexport type GovernedActionCommandDigest = typeof GovernedActionCommandDigest.Type\n\n/** Digest of every immutable field in one governed-action transition. */\nexport const GovernedActionTransitionDigest = Schema.String.check(\n Schema.isPattern(/^sha256:[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n).pipe(Schema.brand(\"GovernedActionTransitionDigest\"))\n\n/** Decoded governed-action transition digest. */\nexport type GovernedActionTransitionDigest = typeof GovernedActionTransitionDigest.Type\n\n/** Closed reason why authorization or preflight failed without calling a provider. */\nexport const GovernedActionDenialReason = Schema.Literals([\n \"revision-changed\",\n \"evidence-stale\",\n \"evidence-invalid\",\n \"policy-denied\",\n \"session-invalid\",\n \"capability-changed\",\n \"plugin-unavailable\",\n \"preflight-blocked\"\n])\n\n/** Decoded governed-action denial reason. */\nexport type GovernedActionDenialReason = typeof GovernedActionDenialReason.Type\n\n/** Unknown provider outcome that is either safely reconcilable or explicitly manual. */\nexport const GovernedActionUnknownOutcome = Schema.TaggedUnion({\n reconcilable: {\n reconciliationKey: PluginActionReconciliationKey,\n observedAt: UtcTimestamp,\n safeSummary: SafeReason\n },\n manual: {\n observedAt: UtcTimestamp,\n safeSummary: SafeReason,\n reason: Schema.Literals([\n \"dispatch-deadline-exceeded\",\n \"interrupted-after-intent\",\n \"provider-defect-after-intent\",\n \"malformed-provider-result\",\n \"receipt-persistence-failed\",\n \"missing-reconciliation-locator\"\n ])\n }\n})\n\n/** Decoded truthful unknown-outcome detail. */\nexport type GovernedActionUnknownOutcome = typeof GovernedActionUnknownOutcome.Type\n\nconst SucceededReceipt = PluginTerminalProviderReceiptV1.check(\n Schema.makeFilter(({ status }) => status === \"succeeded\", { expected: \"a succeeded provider receipt\" })\n)\nconst FailedReceipt = PluginTerminalProviderReceiptV1.check(\n Schema.makeFilter(({ status }) => status === \"failed\", { expected: \"a failed provider receipt\" })\n)\nconst CancelledReceipt = PluginTerminalProviderReceiptV1.check(\n Schema.makeFilter(({ status }) => status === \"cancelled\", { expected: \"a cancelled provider receipt\" })\n)\n\n/** Whether a terminal receipt came from dispatch or reconciliation by provider/idempotency identity. */\nexport const GovernedActionOutcomeSource = Schema.TaggedUnion({\n direct: {},\n providerOperation: { providerOperationId: PluginProviderOperationId },\n reconciliation: { reconciliationKey: Schema.NullOr(PluginActionReconciliationKey) }\n})\n\n/** Decoded terminal provider-outcome source. */\nexport type GovernedActionOutcomeSource = typeof GovernedActionOutcomeSource.Type\n\n/** Closed commands that may append one governed-action lifecycle transition. */\nexport const GovernedActionTransitionCommand = Schema.TaggedUnion({\n propose: {},\n authorize: { authorizationId: GovernedActionAuthorizationId },\n deny: {\n reason: GovernedActionDenialReason,\n safeSummary: SafeReason\n },\n expire: {\n reason: Schema.Literals([\"proposal-expired\", \"authorization-expired\"])\n },\n cancel: { safeSummary: SafeReason },\n start: { attemptId: GovernedActionAttemptId },\n requestCancellation: { safeSummary: SafeReason },\n recordAccepted: { receipt: PluginAcceptedProviderReceiptV1 },\n recordSucceeded: { receipt: SucceededReceipt, source: GovernedActionOutcomeSource },\n recordFailed: { receipt: FailedReceipt, source: GovernedActionOutcomeSource },\n recordUnknown: { outcome: GovernedActionUnknownOutcome },\n recordCancelled: { receipt: CancelledReceipt, source: GovernedActionOutcomeSource },\n reconciliationPending: {\n checkedAt: UtcTimestamp,\n reconciliationKey: Schema.NullOr(PluginActionReconciliationKey)\n }\n})\n\n/** Decoded governed-action lifecycle command. */\nexport type GovernedActionTransitionCommand = typeof GovernedActionTransitionCommand.Type\n\n/** Attributable human, agent, or internal component responsible for a transition. */\nexport const GovernedActionTransitionCause = Schema.TaggedUnion({\n human: {\n actor: HumanActor,\n sessionId: SessionId\n },\n agent: {\n actor: AgentActor,\n jobId: JobId\n },\n system: {\n component: boundedIdentifier(\"GovernedActionSystemComponent\", 200)\n }\n})\n\n/** Decoded governed-action transition attribution. */\nexport type GovernedActionTransitionCause = typeof GovernedActionTransitionCause.Type\n\nconst canRecordTerminalOutcome = (\n currentState: GovernedActionState | null,\n source: GovernedActionOutcomeSource\n): boolean =>\n currentState === \"started\" ||\n currentState === \"cancel-requested\" ||\n ((currentState === \"unknown\" || currentState === \"cancel-requested-unknown\") &&\n source._tag === \"reconciliation\")\n\n/**\n * Resolve a lifecycle command without side effects.\n * A null result means the command is not legal from the supplied state.\n */\nexport const reduceGovernedActionState = (\n currentState: GovernedActionState | null,\n command: GovernedActionTransitionCommand\n): GovernedActionState | null => {\n switch (command._tag) {\n case \"propose\":\n return currentState === null ? \"proposed\" : null\n case \"authorize\":\n return currentState === \"proposed\" ? \"authorized\" : null\n case \"deny\":\n return currentState === \"proposed\" || currentState === \"authorized\" ? \"denied\" : null\n case \"expire\":\n return currentState === \"proposed\" || currentState === \"authorized\" ? \"expired\" : null\n case \"cancel\":\n return currentState === \"proposed\" || currentState === \"authorized\" ? \"cancelled\" : null\n case \"start\":\n return currentState === \"authorized\" ? \"started\" : null\n case \"requestCancellation\":\n return currentState === \"started\"\n ? \"cancel-requested\"\n : currentState === \"unknown\"\n ? \"cancel-requested-unknown\"\n : null\n case \"recordAccepted\":\n return currentState === \"started\" || currentState === \"cancel-requested\" ? currentState : null\n case \"recordUnknown\":\n return currentState === \"started\"\n ? \"unknown\"\n : currentState === \"cancel-requested\"\n ? \"cancel-requested-unknown\"\n : null\n case \"recordSucceeded\":\n return canRecordTerminalOutcome(currentState, command.source) ? \"succeeded\" : null\n case \"recordFailed\":\n return canRecordTerminalOutcome(currentState, command.source) ? \"failed\" : null\n case \"recordCancelled\":\n return canRecordTerminalOutcome(currentState, command.source) ? \"cancelled\" : null\n case \"reconciliationPending\":\n return currentState === \"started\" ||\n currentState === \"cancel-requested\" ||\n currentState === \"unknown\" ||\n currentState === \"cancel-requested-unknown\"\n ? currentState\n : null\n }\n}\n\n/** Whether a governed action has reached a state that cannot execute more provider work. */\nexport const isGovernedActionTerminalState = (state: GovernedActionState): boolean =>\n state === \"denied\" ||\n state === \"expired\" ||\n state === \"cancelled\" ||\n state === \"succeeded\" ||\n state === \"failed\"\n\nconst commandCauseIsAllowed = (\n command: GovernedActionTransitionCommand,\n cause: GovernedActionTransitionCause\n): boolean => {\n switch (cause._tag) {\n case \"agent\":\n return command._tag === \"propose\"\n case \"human\":\n return command._tag === \"propose\" ||\n command._tag === \"authorize\" ||\n command._tag === \"deny\" ||\n command._tag === \"cancel\" ||\n command._tag === \"requestCancellation\"\n case \"system\":\n return command._tag === \"deny\" ||\n command._tag === \"expire\" ||\n command._tag === \"cancel\" ||\n command._tag === \"start\" ||\n command._tag === \"requestCancellation\" ||\n command._tag === \"recordAccepted\" ||\n command._tag === \"recordSucceeded\" ||\n command._tag === \"recordFailed\" ||\n command._tag === \"recordUnknown\" ||\n command._tag === \"recordCancelled\" ||\n command._tag === \"reconciliationPending\"\n }\n}\n\nconst governedActionTransitionMaterialFields = {\n schemaVersion: Schema.Literal(1),\n transitionId: GovernedActionTransitionId,\n previousTransitionId: Schema.NullOr(GovernedActionTransitionId),\n commandId: GovernedActionCommandId,\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n sequence: PositiveInteger,\n fromState: Schema.NullOr(GovernedActionState),\n toState: GovernedActionState,\n actionEnvelopeDigest: GovernedActionEnvelopeDigest,\n command: GovernedActionTransitionCommand,\n cause: GovernedActionTransitionCause,\n occurredAt: UtcTimestamp,\n causationId: Schema.NullOr(DomainEventId),\n correlationId: Schema.NullOr(DomainEventCorrelationId)\n}\n\n/** Digest-free transition fields used only by the trusted transition constructor. */\nexport const GovernedActionTransitionMaterialV1 = Schema.Struct(\n governedActionTransitionMaterialFields\n).check(\n Schema.makeFilter(\n ({ command, fromState, toState }) => reduceGovernedActionState(fromState, command) === toState,\n { expected: \"a legal governed-action state transition\" }\n ),\n Schema.makeFilter(\n ({ cause, command }) => commandCauseIsAllowed(command, cause),\n { expected: \"transition cause to have authority for the command\" }\n ),\n Schema.makeFilter(\n ({ fromState, previousTransitionId, sequence }) =>\n sequence === 1\n ? fromState === null && previousTransitionId === null\n : fromState !== null && previousTransitionId !== null,\n { expected: \"the first transition to be the only transition without a predecessor\" }\n )\n)\n\n/** Decoded digest-free governed-action transition material. */\nexport type GovernedActionTransitionMaterialV1 = typeof GovernedActionTransitionMaterialV1.Type\n\n/** Immutable append-only audit record for one legal lifecycle command. */\nexport const GovernedActionTransitionV1 = Schema.Struct({\n ...governedActionTransitionMaterialFields,\n commandDigest: GovernedActionCommandDigest\n}).check(\n Schema.makeFilter(\n ({ command, fromState, toState }) => reduceGovernedActionState(fromState, command) === toState,\n { expected: \"a legal governed-action state transition\" }\n ),\n Schema.makeFilter(\n ({ cause, command }) => commandCauseIsAllowed(command, cause),\n { expected: \"transition cause to have authority for the command\" }\n ),\n Schema.makeFilter(\n ({ fromState, previousTransitionId, sequence }) =>\n sequence === 1\n ? fromState === null && previousTransitionId === null\n : fromState !== null && previousTransitionId !== null,\n { expected: \"the first transition to be the only transition without a predecessor\" }\n )\n)\n\n/** Decoded immutable governed-action transition. */\nexport type GovernedActionTransitionV1 = typeof GovernedActionTransitionV1.Type\n","import * as Schema from \"effect/Schema\"\n\nimport {\n PluginAcceptedProviderReceiptV1,\n PluginActionReconciliationKey,\n PluginProviderOperationId,\n PluginTerminalProviderReceiptV1\n} from \"../plugins/actions.js\"\nimport {\n GovernedActionState,\n type GovernedActionState as GovernedActionStateType,\n type GovernedActionTransitionCommand,\n reduceGovernedActionState\n} from \"./stateMachine.js\"\n\n/** Provider identity retained by the durable action head across async and ambiguous work. */\nexport const GovernedActionProviderLineage = Schema.TaggedUnion({\n none: {},\n accepted: { receipt: PluginAcceptedProviderReceiptV1 },\n reconcilable: {\n providerOperationId: Schema.NullOr(PluginProviderOperationId),\n reconciliationKey: PluginActionReconciliationKey\n },\n manual: {\n providerOperationId: Schema.NullOr(PluginProviderOperationId)\n },\n terminal: { receipt: PluginTerminalProviderReceiptV1 }\n})\n\n/** Decoded provider lineage retained by a governed-action lifecycle head. */\nexport type GovernedActionProviderLineage = typeof GovernedActionProviderLineage.Type\n\nconst stateMatchesLineage = (\n state: GovernedActionStateType,\n lineage: GovernedActionProviderLineage\n): boolean => {\n switch (state) {\n case \"proposed\":\n case \"authorized\":\n case \"denied\":\n case \"expired\":\n return lineage._tag === \"none\"\n case \"cancelled\":\n return lineage._tag === \"none\" || (lineage._tag === \"terminal\" && lineage.receipt.status === \"cancelled\")\n case \"started\":\n case \"cancel-requested\":\n return lineage._tag === \"none\" || lineage._tag === \"accepted\"\n case \"unknown\":\n case \"cancel-requested-unknown\":\n return lineage._tag === \"reconcilable\" || lineage._tag === \"manual\"\n case \"succeeded\":\n return lineage._tag === \"terminal\" && lineage.receipt.status === \"succeeded\"\n case \"failed\":\n return lineage._tag === \"terminal\" && lineage.receipt.status === \"failed\"\n }\n}\n\n/** Durable lifecycle state plus the exact provider identity needed for safe recovery. */\nexport const GovernedActionLifecycleHeadV1 = Schema.Struct({\n state: GovernedActionState,\n lineage: GovernedActionProviderLineage\n}).check(\n Schema.makeFilter(\n ({ lineage, state }) => stateMatchesLineage(state, lineage),\n { expected: \"governed-action state and provider lineage to agree\" }\n )\n)\n\n/** Decoded governed-action lifecycle head. */\nexport type GovernedActionLifecycleHeadV1 = typeof GovernedActionLifecycleHeadV1.Type\n\nconst providerOperationIdFromLineage = (\n lineage: GovernedActionProviderLineage\n): PluginProviderOperationId | null => {\n switch (lineage._tag) {\n case \"accepted\":\n return lineage.receipt.providerOperationId\n case \"reconcilable\":\n case \"manual\":\n return lineage.providerOperationId\n case \"none\":\n case \"terminal\":\n return null\n }\n}\n\nconst reconciliationKeyFromLineage = (\n lineage: GovernedActionProviderLineage\n): PluginActionReconciliationKey | null => {\n switch (lineage._tag) {\n case \"accepted\":\n return lineage.receipt.reconciliationKey\n case \"reconcilable\":\n return lineage.reconciliationKey\n case \"none\":\n case \"manual\":\n case \"terminal\":\n return null\n }\n}\n\nconst unknownLineage = (\n current: GovernedActionProviderLineage,\n command: Extract<GovernedActionTransitionCommand, { readonly _tag: \"recordUnknown\" }>\n): GovernedActionProviderLineage => {\n const providerOperationId = providerOperationIdFromLineage(current)\n if (command.outcome._tag === \"reconcilable\") {\n return {\n _tag: \"reconcilable\",\n providerOperationId,\n reconciliationKey: command.outcome.reconciliationKey\n }\n }\n const retainedReconciliationKey = reconciliationKeyFromLineage(current)\n return retainedReconciliationKey === null\n ? { _tag: \"manual\", providerOperationId }\n : { _tag: \"reconcilable\", providerOperationId, reconciliationKey: retainedReconciliationKey }\n}\n\nconst acceptedReceiptMatches = (\n lineage: GovernedActionProviderLineage,\n command: Extract<GovernedActionTransitionCommand, { readonly _tag: \"recordAccepted\" }>\n): boolean =>\n lineage._tag === \"none\" ||\n (lineage._tag === \"accepted\" &&\n lineage.receipt.providerOperationId === command.receipt.providerOperationId &&\n lineage.receipt.reconciliationKey === command.receipt.reconciliationKey)\n\n/** Null is the action envelope's immutable idempotency identity, never a missing provider key. */\nconst reconciliationLocatorMatches = (\n lineage: GovernedActionProviderLineage,\n reconciliationKey: PluginActionReconciliationKey | null\n): boolean =>\n reconciliationKey === null\n ? lineage._tag === \"none\" || lineage._tag === \"manual\"\n : reconciliationKeyFromLineage(lineage) === reconciliationKey\n\nconst terminalSourceMatches = (\n lineage: GovernedActionProviderLineage,\n command: Extract<\n GovernedActionTransitionCommand,\n { readonly _tag: \"recordSucceeded\" | \"recordFailed\" | \"recordCancelled\" }\n >\n): boolean => {\n const providerOperationId = providerOperationIdFromLineage(lineage)\n switch (command.source._tag) {\n case \"direct\":\n return lineage._tag === \"none\"\n case \"providerOperation\":\n return providerOperationId !== null &&\n command.source.providerOperationId === providerOperationId &&\n command.receipt.providerOperationId === providerOperationId\n case \"reconciliation\":\n return reconciliationLocatorMatches(lineage, command.source.reconciliationKey) &&\n (providerOperationId === null || command.receipt.providerOperationId === providerOperationId)\n }\n}\n\nconst reconciliationPendingMatches = (\n lineage: GovernedActionProviderLineage,\n command: Extract<GovernedActionTransitionCommand, { readonly _tag: \"reconciliationPending\" }>\n): boolean => reconciliationLocatorMatches(lineage, command.reconciliationKey)\n\n/**\n * Advance a durable lifecycle head while retaining and matching opaque provider identity.\n * A null result rejects illegal edges, fabricated locators, and unrelated receipts.\n */\nexport const advanceGovernedActionLifecycle = (\n current: GovernedActionLifecycleHeadV1 | null,\n command: GovernedActionTransitionCommand\n): GovernedActionLifecycleHeadV1 | null => {\n const nextState = reduceGovernedActionState(current?.state ?? null, command)\n if (nextState === null) return null\n const currentLineage: GovernedActionProviderLineage = current?.lineage ?? { _tag: \"none\" }\n\n switch (command._tag) {\n case \"recordAccepted\":\n return acceptedReceiptMatches(currentLineage, command)\n ? { state: nextState, lineage: { _tag: \"accepted\", receipt: command.receipt } }\n : null\n case \"recordUnknown\":\n return { state: nextState, lineage: unknownLineage(currentLineage, command) }\n case \"recordSucceeded\":\n case \"recordFailed\":\n case \"recordCancelled\":\n return terminalSourceMatches(currentLineage, command)\n ? { state: nextState, lineage: { _tag: \"terminal\", receipt: command.receipt } }\n : null\n case \"reconciliationPending\":\n return reconciliationPendingMatches(currentLineage, command)\n ? { state: nextState, lineage: currentLineage }\n : null\n case \"propose\":\n case \"authorize\":\n case \"deny\":\n case \"expire\":\n case \"cancel\":\n case \"start\":\n case \"requestCancellation\":\n return { state: nextState, lineage: currentLineage }\n }\n}\n","import * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport * as SchemaGetter from \"effect/SchemaGetter\"\n\nimport { SourceUrl } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\n\nconst SafeProviderIdentifier = Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(512)\n)\nconst SafeProviderLabel = Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(200)\n)\nconst SafeDiscoveryEndpointUrl = SourceUrl.pipe(\n Schema.check(\n Schema.makeFilter(\n ({ hash, search }) => hash.length === 0 && search.length === 0,\n { expected: \"a provider endpoint URL without query parameters or fragments\" }\n )\n )\n)\n\nconst ProviderContainer = Schema.Struct({\n providerImmutableId: SafeProviderIdentifier,\n displayName: SafeProviderLabel\n})\nconst NullableProviderContainer = Schema.NullOr(ProviderContainer)\n\n/** Secret-free provider endpoint advertised during connection discovery. */\nexport const PluginDiscoveryEndpointV1 = Schema.Struct({\n kind: Schema.Literals([\"api\", \"web\", \"graphql\", \"webhook\"]),\n url: SafeDiscoveryEndpointUrl,\n label: Schema.NullOr(SafeProviderLabel)\n})\n\n/** Decoded safe provider endpoint metadata. */\nexport type PluginDiscoveryEndpointV1 = typeof PluginDiscoveryEndpointV1.Type\n\n/**\n * Safe connection metadata discovered from the provider.\n * Credentials, raw headers, and provider response bodies are deliberately absent.\n */\nexport const PluginDiscoveryV1 = Schema.Struct({\n account: NullableProviderContainer,\n workspace: NullableProviderContainer,\n resource: Schema.optional(NullableProviderContainer).pipe(\n Schema.decodeTo(Schema.toType(NullableProviderContainer), {\n decode: SchemaGetter.withDefault(Effect.succeed<typeof NullableProviderContainer.Type>(null)),\n encode: SchemaGetter.required()\n })\n ),\n endpoints: Schema.Array(PluginDiscoveryEndpointV1).check(\n Schema.makeFilter(\n (endpoints) => endpoints.length <= 20,\n { expected: \"at most 20 safe provider endpoints\" }\n )\n ),\n discoveredAt: UtcTimestamp\n}).annotate({ identifier: \"PluginDiscoveryV1\" })\n\n/** Decoded secret-free connection discovery metadata. */\nexport type PluginDiscoveryV1 = typeof PluginDiscoveryV1.Type\n","import * as Schema from \"effect/Schema\"\n\nimport { EnvironmentId, ReadinessAssessmentId, ReleaseId, WorkspaceId } from \"../identifiers.js\"\nimport {\n MAX_READINESS_EVIDENCE_REFERENCES,\n ReadinessArtifactRevision,\n ReadinessCandidateDigest,\n ReadinessFactDefinition,\n type ReadinessFactDefinition as ReadinessFactDefinitionType,\n ReadinessFactObservation,\n type ReadinessFactObservation as ReadinessFactObservationType,\n ReadinessReleaseRevision,\n ReadinessRuleId,\n ReadinessRuleVersion\n} from \"./model.js\"\nimport { compareReadinessText, readinessDefinitionsShapeIsV1, readinessPolicyShapeIsV1 } from \"./policy.js\"\n\nconst unique = <Value>(values: ReadonlyArray<Value>): boolean => new Set(values).size === values.length\n\nconst CandidateMaterialBase = {\n workspaceId: WorkspaceId,\n releaseRevision: ReadinessReleaseRevision,\n artifactRevision: ReadinessArtifactRevision\n}\n\nconst readinessFactsAreValid = (input: {\n readonly definitions: ReadonlyArray<ReadinessFactDefinitionType>\n readonly observations: ReadonlyArray<ReadinessFactObservationType>\n}): boolean => {\n const definitionsById = new Map(input.definitions.map((definition) => [definition.factId, definition]))\n return unique(input.definitions.map(({ factId }) => factId)) &&\n unique(input.observations.map(({ factId }) => factId)) &&\n input.observations.every((observation) =>\n definitionsById.get(observation.factId)?.kind === observation.state._tag\n ) &&\n readinessPolicyShapeIsV1(input.definitions, input.observations) &&\n input.observations.reduce((total, observation) => total + observation.evidence.length, 0) <=\n MAX_READINESS_EVIDENCE_REFERENCES\n}\n\n/** Digest-free, complete material for one target-environment candidate. */\nexport const EnvironmentReadinessCandidateMaterial = Schema.Struct({\n ...CandidateMaterialBase,\n scope: Schema.TaggedStruct(\"environment\", {\n releaseId: ReleaseId,\n environmentId: EnvironmentId\n }),\n complete: Schema.Boolean,\n definitions: Schema.Array(ReadinessFactDefinition).check(Schema.isMaxLength(512)),\n observations: Schema.Array(ReadinessFactObservation).check(Schema.isMaxLength(512))\n}).check(\n Schema.makeFilter(readinessFactsAreValid, {\n expected: \"complete, unique, evidence-bounded V1 readiness candidate material\"\n })\n)\n\n/** Decoded environment candidate material before deterministic normalization. */\nexport type EnvironmentReadinessCandidateMaterial = typeof EnvironmentReadinessCandidateMaterial.Type\n\n/** Exact child assessment bound into a release-scope candidate. */\nexport const ReleaseReadinessChildMaterial = Schema.Struct({\n assessmentId: ReadinessAssessmentId,\n environmentId: EnvironmentId,\n candidateDigest: ReadinessCandidateDigest\n})\n\n/** Decoded release child material. */\nexport type ReleaseReadinessChildMaterial = typeof ReleaseReadinessChildMaterial.Type\n\n/** Digest-free material for one release candidate and its exact environment assessments. */\nexport const ReleaseReadinessCandidateMaterial = Schema.Struct({\n ...CandidateMaterialBase,\n scope: Schema.TaggedStruct(\"release\", { releaseId: ReleaseId }),\n environments: Schema.NonEmptyArray(ReleaseReadinessChildMaterial).check(Schema.isMaxLength(512))\n}).check(\n Schema.makeFilter(({ environments }) => unique(environments.map(({ environmentId }) => environmentId)), {\n expected: \"release candidate environment identities to be unique\"\n }),\n Schema.makeFilter(({ environments }) => unique(environments.map(({ assessmentId }) => assessmentId)), {\n expected: \"release candidate assessment identities to be unique\"\n })\n)\n\n/** Decoded release candidate material before deterministic normalization. */\nexport type ReleaseReadinessCandidateMaterial = typeof ReleaseReadinessCandidateMaterial.Type\n\n/** Digest-free immutable readiness-rule snapshot. */\nexport const ReadinessRuleMaterial = Schema.Struct({\n ruleId: ReadinessRuleId,\n version: ReadinessRuleVersion,\n definitions: Schema.Array(ReadinessFactDefinition).check(Schema.isNonEmpty(), Schema.isMaxLength(512))\n}).check(\n Schema.makeFilter(({ definitions }) => unique(definitions.map(({ factId }) => factId)), {\n expected: \"readiness rule fact identities to be unique\"\n }),\n Schema.makeFilter(({ definitions }) => readinessDefinitionsShapeIsV1(definitions), {\n expected: \"readiness rule material to contain the complete V1 policy shape\"\n })\n)\n\n/** Decoded rule material before deterministic normalization. */\nexport type ReadinessRuleMaterial = typeof ReadinessRuleMaterial.Type\n\nconst normalizeDefinitions = (\n definitions: ReadonlyArray<ReadinessFactDefinitionType>\n): Array<ReadinessFactDefinitionType> =>\n [...definitions].sort((left, right) => compareReadinessText(left.factId, right.factId))\n\nconst normalizeObservations = (\n observations: ReadonlyArray<ReadinessFactObservationType>\n): Array<ReadinessFactObservationType> =>\n observations\n .map((observation) => ({\n ...observation,\n evidence: [...observation.evidence].sort((left, right) => compareReadinessText(left.evidenceId, right.evidenceId))\n }))\n .sort((left, right) => compareReadinessText(left.factId, right.factId))\n\n/** Return the only JSON ordering accepted for environment-candidate hashing. */\nexport const normalizeEnvironmentReadinessCandidateMaterial = (\n material: EnvironmentReadinessCandidateMaterial\n): EnvironmentReadinessCandidateMaterial => ({\n ...material,\n definitions: normalizeDefinitions(material.definitions),\n observations: normalizeObservations(material.observations)\n})\n\n/** Return the only JSON ordering accepted for release-candidate hashing. */\nexport const normalizeReleaseReadinessCandidateMaterial = (\n material: ReleaseReadinessCandidateMaterial\n): ReleaseReadinessCandidateMaterial => {\n const [first, ...remaining] = material.environments\n const environments: [ReleaseReadinessChildMaterial, ...Array<ReleaseReadinessChildMaterial>] = [\n first,\n ...remaining\n ]\n environments.sort((left, right) => compareReadinessText(left.environmentId, right.environmentId))\n return { ...material, environments }\n}\n\n/** Return the only JSON ordering accepted for rule hashing. */\nexport const normalizeReadinessRuleMaterial = (\n material: ReadinessRuleMaterial\n): ReadinessRuleMaterial => ({\n ...material,\n definitions: normalizeDefinitions(material.definitions)\n})\n","import type {\n EnvironmentReadinessAssessment,\n ReleaseReadinessAssessment,\n ReleaseReadinessRollupInput\n} from \"./model.js\"\nimport {\n compareReadinessText,\n deriveReleaseReadinessFindings,\n deriveReleaseReadinessNextEvaluationAt,\n deriveReleaseReadinessSourceSummaries,\n deriveReleaseReadinessStages,\n deriveReleaseReadinessVerdict,\n sortedReadinessUnique\n} from \"./policy.js\"\n\n/** Exact compact projection retained when an environment is rolled into a release. */\nexport const summarizeEnvironmentReadiness = (\n assessment: EnvironmentReadinessAssessment\n): ReleaseReadinessAssessment[\"environments\"][number] => ({\n assessmentId: assessment.assessmentId,\n environmentId: assessment.candidate.scope.environmentId,\n candidateDigest: assessment.candidate.digest,\n inputComplete: assessment.inputComplete,\n facts: assessment.facts,\n nextEvaluationAt: assessment.nextEvaluationAt,\n verdict: assessment.verdict,\n stages: assessment.stages,\n blockers: assessment.blockers,\n warnings: assessment.warnings,\n gaps: assessment.gaps,\n sourceFreshness: assessment.sourceFreshness,\n evidenceIds: assessment.evidenceIds\n})\n\n/** Pure deterministic roll-up of current target-environment assessments. */\nexport const rollUpReleaseReadiness = (\n input: ReleaseReadinessRollupInput\n): ReleaseReadinessAssessment => {\n const environments = input.environments\n .slice()\n .sort((left, right) => {\n return compareReadinessText(\n left.candidate.scope.environmentId,\n right.candidate.scope.environmentId\n )\n })\n const first = environments.reduce((earliest, assessment) =>\n compareReadinessText(\n assessment.candidate.scope.environmentId,\n earliest.candidate.scope.environmentId\n ) < 0\n ? assessment\n : earliest, input.environments[0])\n const environmentSummaries: ReleaseReadinessAssessment[\"environments\"] = [\n summarizeEnvironmentReadiness(first),\n ...environments.filter((assessment) => assessment !== first).map(summarizeEnvironmentReadiness)\n ]\n const findings = deriveReleaseReadinessFindings(environmentSummaries)\n\n return {\n _tag: \"release\",\n assessmentId: input.assessmentId,\n previousAssessmentId: input.previousAssessmentId,\n candidate: input.candidate,\n rule: first.rule,\n derivationVersion: first.derivationVersion,\n evaluatedAt: input.evaluatedAt,\n nextEvaluationAt: deriveReleaseReadinessNextEvaluationAt(environmentSummaries),\n verdict: deriveReleaseReadinessVerdict(environmentSummaries),\n stages: deriveReleaseReadinessStages(environmentSummaries),\n environments: environmentSummaries,\n blockers: findings.blockers,\n warnings: findings.warnings,\n gaps: findings.gaps,\n sourceFreshness: deriveReleaseReadinessSourceSummaries(environmentSummaries),\n evidenceIds: sortedReadinessUnique(environments.flatMap(({ evidenceIds }) => evidenceIds))\n }\n}\n"],"mappings":";;;;;;;;;AAOA,IAAa,wBAAwB,OAAO,aAAa,UAAU,EACjE,UAAU,SACZ,CAAC;;AAMD,IAAa,uBAAuB,OAAO,OAAO;CAChD,aAAa;CACb,SAAS;CACT,QAAQ;CACR,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,WAAW;CACX,WAAW;CACX,WAAW,OAAO,OAAO,YAAY;AACvC,CAAC,CAAC,CAAC,MACD,OAAO,YACJ,EAAE,WAAW,gB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,6BAA6B,oBAAoB;EACzD,cAAc;EACd,UAAU,SAAS;EACnB,UAAU,SAAS;EACnB,MAAM,SAAS;EACf,iBAAiB,sCAAsC,oBAAoB;EAC3E,aAAa,sBAAsB,aAAa,SAAS,EAAE,kBAAkB,WAAW,CAAC;CAC3F;AACF"}
1
+ {"version":3,"file":"readiness-CZBkcjLP.js","names":[],"sources":["../../../src/domain/authorizedShare.ts","../../../src/domain/plugins/events.ts","../../../src/domain/plugins/actions.ts","../../../src/domain/governedAction/model.ts","../../../src/domain/governedAction/bindings.ts","../../../src/domain/governedAction/stateMachine.ts","../../../src/domain/governedAction/lifecycle.ts","../../../src/domain/plugins/discovery.ts","../../../src/domain/readiness/material.ts","../../../src/domain/readiness/rollup.ts"],"sourcesContent":["import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport { EntityId, PersonId, SessionId, ShareId, WorkspaceId } from \"./identifiers.js\"\nimport { UtcTimestamp } from \"./utcTimestamp.js\"\n\n/** Exact normalized entity scope granted to one authenticated person. */\nexport const AuthorizedShareTarget = Schema.TaggedStruct(\"entity\", {\n entityId: EntityId\n})\n\n/** Decoded exact authorized-share target. */\nexport type AuthorizedShareTarget = typeof AuthorizedShareTarget.Type\n\n/** Durable authenticated grant with immutable creation and optional revocation evidence. */\nexport const AuthorizedShareGrant = Schema.Struct({\n workspaceId: WorkspaceId,\n shareId: ShareId,\n target: AuthorizedShareTarget,\n granteePersonId: PersonId,\n createdByPersonId: PersonId,\n createdBySessionId: SessionId,\n createdAt: UtcTimestamp,\n expiresAt: UtcTimestamp,\n revokedAt: Schema.NullOr(UtcTimestamp)\n}).check(\n Schema.makeFilter(\n ({ createdAt, expiresAt }) => DateTime.Order(createdAt, expiresAt) < 0,\n { expected: \"authorized share expiry after creation\" }\n ),\n Schema.makeFilter(\n ({ createdAt, revokedAt }) => revokedAt === null || DateTime.Order(createdAt, revokedAt) <= 0,\n { expected: \"authorized share revocation at or after creation\" }\n )\n)\n\n/** Decoded durable authorized-share grant. */\nexport type AuthorizedShareGrant = typeof AuthorizedShareGrant.Type\n","import * as Encoding from \"effect/Encoding\"\nimport * as Result from \"effect/Result\"\nimport * as Schema from \"effect/Schema\"\n\nimport { Revision, SourceUrl, VendorImmutableId } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport {\n hasMaximumPluginJsonBytes,\n MaximumPluginPayloadBytes,\n MaximumPluginSyncPageBytes,\n PluginPayloadJson\n} from \"./bounds.js\"\n\nconst boundedOpaque = (name: string, maximum: number) =>\n Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(maximum)).pipe(Schema.brand(name))\n\n/** Stable adapter event identity used to make checkpoint replay idempotent. */\nexport const PluginEventId = boundedOpaque(\"PluginEventId\", 512)\n\n/** Decoded adapter event identity. */\nexport type PluginEventId = typeof PluginEventId.Type\n\n/** Opaque bounded checkpoint owned by one plugin sync stream. */\nexport const PluginCheckpointV1 = boundedOpaque(\"PluginCheckpointV1\", 2_048)\n\n/** Decoded plugin checkpoint. */\nexport type PluginCheckpointV1 = typeof PluginCheckpointV1.Type\n\n/** Opaque page cursor for optional paginated reads. */\nexport const PluginPageCursorV1 = boundedOpaque(\"PluginPageCursorV1\", 2_048)\n\n/** Decoded plugin page cursor. */\nexport type PluginPageCursorV1 = typeof PluginPageCursorV1.Type\n\n/** Stable entity category emitted without vendor-specific response shapes. */\nexport const PluginEntityType = boundedOpaque(\"PluginEntityType\", 100)\n\n/** Decoded normalized entity type. */\nexport type PluginEntityType = typeof PluginEntityType.Type\n\nconst SafeSummary = Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(500))\nconst MaximumDiffContentBytes = 1_048_576\nconst MaximumDiffContentBase64Characters = 4 * Math.ceil(MaximumDiffContentBytes / 3)\nconst hasSafeRelativePathShape = Schema.makeFilter(\n (value: string) => {\n if (value.startsWith(\"/\") || value.includes(\"\\\\\") || /^[a-zA-Z]:/u.test(value)) return false\n return (\n value.split(\"/\").every((segment) => segment !== \"\" && segment !== \".\" && segment !== \"..\") &&\n Array.from(value).every((character) => {\n const codePoint = character.codePointAt(0)\n return (\n codePoint !== undefined &&\n !((codePoint >= 0 && codePoint <= 0x1f) || (codePoint >= 0x7f && codePoint <= 0x9f))\n )\n })\n )\n },\n { expected: \"a normalized provider-relative path without traversal or control characters\" }\n)\nconst hasMaximumDecodedDiffBytes = Schema.makeFilter(\n (value: string) => {\n const decoded = Encoding.decodeBase64(value)\n return Result.isSuccess(decoded) && decoded.success.byteLength <= MaximumDiffContentBytes\n },\n { expected: `base64 data decoding to at most ${MaximumDiffContentBytes} bytes` }\n)\n\n/** Normalized provider-relative path safe to carry across diff and storage boundaries. */\nexport const PluginRelativePathV1 = Schema.String.check(\n Schema.isNonEmpty(),\n Schema.isMaxLength(4_096),\n hasSafeRelativePathShape\n).pipe(Schema.brand(\"PluginRelativePathV1\"))\n\n/** Decoded normalized provider-relative path. */\nexport type PluginRelativePathV1 = typeof PluginRelativePathV1.Type\n\nconst PluginDiffContentBase64V1 = Schema.String.check(\n Schema.isMaxLength(MaximumDiffContentBase64Characters),\n Schema.isBase64(),\n hasMaximumDecodedDiffBytes\n)\nconst commonEventFields = {\n eventId: PluginEventId,\n observedAt: UtcTimestamp,\n revision: Revision\n}\nconst entityReferenceFields = {\n entityType: PluginEntityType,\n vendorImmutableId: VendorImmutableId\n}\n\n/** Adapter-owned reference to a provider entity; host scope is deliberately absent. */\nexport const PluginEntityReferenceV1 = Schema.Struct(entityReferenceFields)\n\n/** Decoded provider entity reference. */\nexport type PluginEntityReferenceV1 = typeof PluginEntityReferenceV1.Type\n\nconst UpsertEntity = Schema.TaggedStruct(\"UpsertEntity\", {\n ...commonEventFields,\n ...entityReferenceFields,\n sourceUrl: Schema.NullOr(SourceUrl),\n title: SafeSummary,\n attributes: Schema.Record(Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)), Schema.Json).check(\n hasMaximumPluginJsonBytes(MaximumPluginPayloadBytes)\n )\n})\n\nconst TombstoneEntity = Schema.TaggedStruct(\"TombstoneEntity\", {\n ...commonEventFields,\n ...entityReferenceFields,\n reason: SafeSummary\n})\n\nconst AppendEvidence = Schema.TaggedStruct(\"AppendEvidence\", {\n ...commonEventFields,\n evidenceId: boundedOpaque(\"PluginEvidenceId\", 512),\n subject: PluginEntityReferenceV1,\n evidenceType: boundedOpaque(\"PluginEvidenceType\", 100),\n summary: SafeSummary,\n capturedAt: UtcTimestamp,\n data: PluginPayloadJson\n})\n\nconst UpsertPerson = Schema.TaggedStruct(\"UpsertPerson\", {\n ...commonEventFields,\n vendorPersonId: boundedOpaque(\"PluginVendorPersonId\", 512),\n displayName: Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(200)),\n avatarUrl: Schema.NullOr(SourceUrl),\n active: Schema.Boolean\n})\n\nconst ProposeRelationship = Schema.TaggedStruct(\"ProposeRelationship\", {\n ...commonEventFields,\n relationshipId: boundedOpaque(\"PluginRelationshipId\", 512),\n from: PluginEntityReferenceV1,\n to: PluginEntityReferenceV1,\n relationshipType: boundedOpaque(\"PluginRelationshipType\", 100),\n confidence: Schema.Number.check(Schema.isBetween({ minimum: 0, maximum: 1 })),\n evidenceIds: Schema.Array(boundedOpaque(\"PluginRelationshipEvidenceId\", 512)).check(\n Schema.makeFilter((evidenceIds) => evidenceIds.length <= 100, {\n expected: \"at most 100 relationship evidence identities\"\n }),\n Schema.isUnique()\n )\n})\n\n/** Vendor-neutral event emitted by a plugin and scoped by the host on ingestion. */\nexport const NormalizedPluginEventV1 = Schema.Union([\n UpsertEntity,\n TombstoneEntity,\n AppendEvidence,\n UpsertPerson,\n ProposeRelationship\n]).pipe(Schema.toTaggedUnion(\"_tag\"))\n\n/** Decoded normalized plugin event. */\nexport type NormalizedPluginEventV1 = typeof NormalizedPluginEventV1.Type\n\n/** A fully decoded page whose events and checkpoint must commit atomically. */\nexport const PluginSyncPageV1 = Schema.Struct({\n events: Schema.Array(NormalizedPluginEventV1).check(\n Schema.makeFilter((events) => events.length <= 500, {\n expected: \"at most 500 normalized plugin events\"\n }),\n Schema.makeFilter((events) => new Set(events.map(({ eventId }) => eventId)).size === events.length, {\n expected: \"unique normalized plugin event identities within a page\"\n })\n ),\n checkpointAfterPage: PluginCheckpointV1,\n hasMore: Schema.Boolean\n})\n .check(hasMaximumPluginJsonBytes(MaximumPluginSyncPageBytes))\n .annotate({ identifier: \"PluginSyncPageV1\" })\n\n/** Decoded plugin sync page. */\nexport type PluginSyncPageV1 = typeof PluginSyncPageV1.Type\n\n/** Request to resume a logical plugin stream from an accepted checkpoint. */\nexport const PluginSyncRequestV1 = Schema.Struct({\n streamKey: boundedOpaque(\"PluginSyncStreamKey\", 100),\n checkpoint: Schema.NullOr(PluginCheckpointV1)\n}).annotate({ identifier: \"PluginSyncRequestV1\" })\n\n/** Decoded plugin sync request. */\nexport type PluginSyncRequestV1 = typeof PluginSyncRequestV1.Type\n\n/** Request for one normalized entity by its immutable provider reference. */\nexport const ReadPluginEntityRequestV1 = PluginEntityReferenceV1\n\n/** Decoded normalized entity read request. */\nexport type ReadPluginEntityRequestV1 = typeof ReadPluginEntityRequestV1.Type\n\nconst FoundPluginEntity = Schema.TaggedStruct(\"found\", {\n event: UpsertEntity\n})\nconst MissingPluginEntity = Schema.TaggedStruct(\"missing\", {\n reference: PluginEntityReferenceV1,\n observedAt: UtcTimestamp\n})\n\n/** Authoritative result of a normalized plugin entity read. */\nexport const ReadPluginEntityResultV1 = Schema.Union([FoundPluginEntity, MissingPluginEntity]).pipe(\n Schema.toTaggedUnion(\"_tag\")\n)\n\n/** Decoded normalized entity read result. */\nexport type ReadPluginEntityResultV1 = typeof ReadPluginEntityResultV1.Type\n\n/** One bounded file-like entry in a complete diff inventory. */\nexport const PluginDiffInventoryEntryV1 = Schema.Struct({\n path: PluginRelativePathV1,\n previousPath: Schema.NullOr(PluginRelativePathV1),\n status: Schema.Literals([\"added\", \"modified\", \"deleted\", \"renamed\", \"copied\"]),\n binary: Schema.Boolean,\n generated: Schema.Boolean,\n oversized: Schema.Boolean\n})\n\n/** Request for one page of a complete diff inventory. */\nexport const DiffInventoryPageRequestV1 = Schema.Struct({\n entity: PluginEntityReferenceV1,\n cursor: Schema.NullOr(PluginPageCursorV1)\n})\n\n/** A bounded diff inventory page. */\nexport const DiffInventoryPageV1 = Schema.Struct({\n entries: Schema.Array(PluginDiffInventoryEntryV1).check(\n Schema.makeFilter((entries) => entries.length <= 500, {\n expected: \"at most 500 diff inventory entries\"\n })\n ),\n nextCursor: Schema.NullOr(PluginPageCursorV1)\n})\n\n/** Request for a bounded byte range of before/after diff content. */\nexport const DiffContentRangeRequestV1 = Schema.Struct({\n entity: PluginEntityReferenceV1,\n path: PluginRelativePathV1,\n side: Schema.Literals([\"before\", \"after\"]),\n offset: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n length: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1_048_576 }))\n})\n\n/** Bounded content range with explicit availability metadata. */\nexport const DiffContentRangeV1 = Schema.Struct({\n bytesBase64: Schema.NullOr(PluginDiffContentBase64V1),\n totalBytes: Schema.NullOr(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n unavailableReason: Schema.NullOr(\n Schema.Literals([\"binary\", \"generated\", \"oversized\", \"missing\", \"provider-unavailable\"])\n )\n}).check(\n Schema.makeFilter(\n ({ bytesBase64, totalBytes, unavailableReason }) =>\n unavailableReason === null ? bytesBase64 !== null && totalBytes !== null : bytesBase64 === null,\n { expected: \"available content bytes or an explicit unavailable reason\" }\n )\n)\n\nexport type DiffInventoryPageRequestV1 = typeof DiffInventoryPageRequestV1.Type\nexport type DiffInventoryPageV1 = typeof DiffInventoryPageV1.Type\nexport type DiffContentRangeRequestV1 = typeof DiffContentRangeRequestV1.Type\nexport type DiffContentRangeV1 = typeof DiffContentRangeV1.Type\n","import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport { Revision } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport { PluginPayloadJson } from \"./bounds.js\"\nimport { PluginEntityReferenceV1 } from \"./events.js\"\n\nconst boundedOpaque = (name: string, maximum: number) =>\n Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(maximum)).pipe(Schema.brand(name))\n\nconst PositiveInteger = Schema.Int.check(Schema.isGreaterThan(0))\nconst SafeSummary = Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(1_000))\n\n/** Lowercase SHA-256 digest of a canonical governed-action payload. */\nexport const PluginActionPayloadDigest = Schema.String.check(\n Schema.isPattern(/^[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n).pipe(Schema.brand(\"PluginActionPayloadDigest\"))\n\n/** Decoded canonical payload digest. */\nexport type PluginActionPayloadDigest = typeof PluginActionPayloadDigest.Type\n\n/** Opaque provider locator used to reconcile a mutation without replaying it. */\nexport const PluginActionReconciliationKey = boundedOpaque(\"PluginActionReconciliationKey\", 512)\n\n/** Decoded provider reconciliation locator. */\nexport type PluginActionReconciliationKey = typeof PluginActionReconciliationKey.Type\n\n/** Opaque provider identity of one accepted or completed mutation. */\nexport const PluginProviderOperationId = boundedOpaque(\"PluginProviderOperationId\", 512)\n\n/** Decoded provider mutation identity. */\nexport type PluginProviderOperationId = typeof PluginProviderOperationId.Type\n\n/** Request for a provider-neutral action proposal; it cannot authorize execution. */\nexport const ProposePluginActionRequestV1 = Schema.Struct({\n actionKind: boundedOpaque(\"PluginActionKind\", 100),\n target: PluginEntityReferenceV1,\n expectedRevision: Revision,\n payload: PluginPayloadJson,\n evidenceIds: Schema.Array(boundedOpaque(\"PluginActionEvidenceId\", 512)).check(\n Schema.isUnique(),\n Schema.makeFilter((evidenceIds) => evidenceIds.length <= 100, {\n expected: \"at most 100 action evidence identities\"\n })\n )\n})\n\n/** Proposal returned to the host for later policy and human authorization. */\nexport const PluginActionProposalV1 = Schema.Struct({\n proposalKey: boundedOpaque(\"PluginActionProposalKey\", 512),\n capabilityVersion: PositiveInteger,\n request: ProposePluginActionRequestV1,\n payloadDigest: PluginActionPayloadDigest,\n summary: SafeSummary,\n impact: Schema.Struct({\n level: Schema.Literals([\"low\", \"medium\", \"high\", \"critical\"]),\n summary: SafeSummary\n }),\n proposedAt: UtcTimestamp\n})\n\n/** Host-authorized request accepted only by the sealed internal executor. */\nexport const AuthorizedPluginActionV1 = Schema.Struct({\n proposal: PluginActionProposalV1,\n idempotencyKey: boundedOpaque(\"PluginActionIdempotencyKey\", 512),\n payloadDigest: PluginActionPayloadDigest,\n authorizationId: boundedOpaque(\"PluginActionAuthorizationId\", 512),\n authorizedAt: UtcTimestamp,\n expiresAt: UtcTimestamp\n}).check(\n Schema.makeFilter(({ authorizedAt, expiresAt }) => DateTime.Order(authorizedAt, expiresAt) < 0, {\n expected: \"plugin action authorization to expire after it is issued\"\n }),\n Schema.makeFilter(({ payloadDigest, proposal }) => payloadDigest === proposal.payloadDigest, {\n expected: \"authorized payload digest to match its canonical proposal digest\"\n })\n)\n\nconst providerReceiptFields = {\n providerOperationId: PluginProviderOperationId,\n safeSummary: SafeSummary,\n observedAt: UtcTimestamp\n}\n\n/** Accepted provider work that remains unresolved and can be reconciled safely. */\nexport const PluginAcceptedProviderReceiptV1 = Schema.Struct({\n ...providerReceiptFields,\n status: Schema.Literal(\"accepted\"),\n reconciliationKey: PluginActionReconciliationKey\n})\n\n/** Terminal provider receipt safe to persist and display without raw response data. */\nexport const PluginTerminalProviderReceiptV1 = Schema.Struct({\n ...providerReceiptFields,\n status: Schema.Literals([\"succeeded\", \"failed\", \"cancelled\"])\n})\n\n/** Provider receipt that never represents accepted asynchronous work as terminal. */\nexport const PluginProviderReceiptV1 = Schema.Union([\n PluginAcceptedProviderReceiptV1,\n PluginTerminalProviderReceiptV1\n])\n\n/** Provider preflight that confirms the exact revision is ready for dispatch. */\nexport const ReadyPluginActionPreflightV1 = Schema.TaggedStruct(\"ready\", {\n checkedRevision: Revision,\n checkedAt: UtcTimestamp\n})\n\n/** Provider preflight that blocks dispatch with bounded safe reasons. */\nexport const BlockedPluginActionPreflightV1 = Schema.TaggedStruct(\"blocked\", {\n reasons: Schema.Array(SafeSummary).check(\n Schema.isNonEmpty(),\n Schema.makeFilter((reasons) => reasons.length <= 50, {\n expected: \"at most 50 preflight reasons\"\n })\n ),\n checkedAt: UtcTimestamp\n})\n\n/** Result of the final provider preflight before dispatch. */\nexport const PluginActionPreflightV1 = Schema.Union([\n ReadyPluginActionPreflightV1,\n BlockedPluginActionPreflightV1\n]).pipe(\n Schema.toTaggedUnion(\"_tag\")\n)\n\nconst ConfirmedDispatch = Schema.TaggedStruct(\"confirmed\", {\n receipt: PluginProviderReceiptV1\n})\nconst UnknownDispatch = Schema.TaggedStruct(\"unknown\", {\n reconciliationKey: PluginActionReconciliationKey,\n safeSummary: SafeSummary,\n observedAt: UtcTimestamp\n})\n\n/** Truthful immediate outcome of one authorized provider dispatch. */\nexport const PluginActionDispatchResultV1 = Schema.Union([ConfirmedDispatch, UnknownDispatch]).pipe(\n Schema.toTaggedUnion(\"_tag\")\n)\n\n/** Request to cancel an action after its durable lifecycle permits cancellation. */\nexport const PluginActionCancellationRequestV1 = Schema.Struct({\n idempotencyKey: boundedOpaque(\"PluginCancellationIdempotencyKey\", 512),\n providerOperationId: Schema.NullOr(PluginProviderOperationId),\n reconciliationKey: Schema.NullOr(PluginActionReconciliationKey)\n}).check(\n Schema.makeFilter(\n ({ providerOperationId, reconciliationKey }) => (providerOperationId === null) !== (reconciliationKey === null),\n { expected: \"exactly one provider operation or reconciliation key\" }\n )\n)\n\n/** Truthful cancellation response; provider completion may win the race. */\nexport const PluginActionCancellationResultV1 = Schema.Union([\n Schema.TaggedStruct(\"cancelled\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"cancelled\", { expected: \"a cancelled provider receipt\" })\n ),\n Schema.TaggedStruct(\"completed\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"succeeded\" || receipt.status === \"failed\", {\n expected: \"a terminal succeeded or failed provider receipt\"\n })\n ),\n Schema.TaggedStruct(\"unknown\", {\n reconciliationKey: PluginActionReconciliationKey,\n observedAt: UtcTimestamp\n })\n]).pipe(Schema.toTaggedUnion(\"_tag\"))\n\n/** Request to reconcile without replay; null locates the mutation by its durable idempotency key. */\nexport const PluginActionReconciliationRequestV1 = Schema.Struct({\n reconciliationKey: Schema.NullOr(PluginActionReconciliationKey),\n idempotencyKey: boundedOpaque(\"PluginReconciliationIdempotencyKey\", 512),\n payloadDigest: PluginActionPayloadDigest\n})\n\n/** Reconciled provider state. Cancelled means the mutation provably did not occur. */\nexport const PluginActionReconciliationResultV1 = Schema.Union([\n Schema.TaggedStruct(\"pending\", { checkedAt: UtcTimestamp }),\n Schema.TaggedStruct(\"succeeded\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"succeeded\", { expected: \"a succeeded provider receipt\" })\n ),\n Schema.TaggedStruct(\"failed\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"failed\", { expected: \"a failed provider receipt\" })\n ),\n Schema.TaggedStruct(\"cancelled\", { receipt: PluginProviderReceiptV1 }).check(\n Schema.makeFilter(({ receipt }) => receipt.status === \"cancelled\", { expected: \"a cancelled provider receipt\" })\n )\n]).pipe(Schema.toTaggedUnion(\"_tag\"))\n\nexport type ProposePluginActionRequestV1 = typeof ProposePluginActionRequestV1.Type\nexport type PluginActionProposalV1 = typeof PluginActionProposalV1.Type\nexport type AuthorizedPluginActionV1 = typeof AuthorizedPluginActionV1.Type\nexport type PluginAcceptedProviderReceiptV1 = typeof PluginAcceptedProviderReceiptV1.Type\nexport type PluginTerminalProviderReceiptV1 = typeof PluginTerminalProviderReceiptV1.Type\nexport type PluginProviderReceiptV1 = typeof PluginProviderReceiptV1.Type\nexport type ReadyPluginActionPreflightV1 = typeof ReadyPluginActionPreflightV1.Type\nexport type BlockedPluginActionPreflightV1 = typeof BlockedPluginActionPreflightV1.Type\nexport type PluginActionPreflightV1 = typeof PluginActionPreflightV1.Type\nexport type PluginActionDispatchResultV1 = typeof PluginActionDispatchResultV1.Type\nexport type PluginActionCancellationRequestV1 = typeof PluginActionCancellationRequestV1.Type\nexport type PluginActionCancellationResultV1 = typeof PluginActionCancellationResultV1.Type\nexport type PluginActionReconciliationRequestV1 = typeof PluginActionReconciliationRequestV1.Type\nexport type PluginActionReconciliationResultV1 = typeof PluginActionReconciliationResultV1.Type\n","import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport { AgentActor, HumanActor, Role } from \"../actors.js\"\nimport { DomainEventCorrelationId } from \"../domainEvent.js\"\nimport {\n DomainEventId,\n EntityId,\n EvidenceClaimId,\n EvidenceId,\n GovernedActionAttemptId,\n GovernedActionAuthorizationId,\n GovernedActionId,\n JobId,\n PluginConnectionId,\n SessionId,\n WorkspaceId\n} from \"../identifiers.js\"\nimport { PluginActionPayloadDigest, PluginActionProposalV1, ReadyPluginActionPreflightV1 } from \"../plugins/actions.js\"\nimport { PluginId, SemanticVersion } from \"../plugins/descriptor.js\"\nimport { PluginEntityType } from \"../plugins/events.js\"\nimport { ProviderId, Revision, SourceRevision } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\n\nconst PositiveInteger = Schema.Int.check(Schema.isGreaterThan(0))\nconst boundedIdentifier = (name: string, maximumLength: number) =>\n Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(maximumLength),\n Schema.isPattern(/^[A-Za-z0-9._:/-]+$/u, { expected: \"a bounded action identifier\" })\n ).pipe(Schema.brand(name))\nconst sha256Digest = (name: string) =>\n Schema.String.check(\n Schema.isPattern(/^sha256:[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n ).pipe(Schema.brand(name))\nconst compareText = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0\nconst isCanonicalText = (values: ReadonlyArray<string>): boolean =>\n values.every((value, index) => index === 0 || compareText(values[index - 1] ?? \"\", value) < 0)\n\n/** Digest of every immutable field in a governed action envelope. */\nexport const GovernedActionEnvelopeDigest = sha256Digest(\"GovernedActionEnvelopeDigest\")\n\n/** Decoded governed-action envelope digest. */\nexport type GovernedActionEnvelopeDigest = typeof GovernedActionEnvelopeDigest.Type\n\n/** Digest of the canonical evidence-reference set bound to an action. */\nexport const GovernedActionEvidenceSetDigest = sha256Digest(\"GovernedActionEvidenceSetDigest\")\n\n/** Decoded governed-action evidence-set digest. */\nexport type GovernedActionEvidenceSetDigest = typeof GovernedActionEvidenceSetDigest.Type\n\n/** Digest of a fresh policy evaluation persisted with one exact dispatch attempt. */\nexport const GovernedActionPolicyEvaluationDigest = sha256Digest(\"GovernedActionPolicyEvaluationDigest\")\n\n/** Decoded fresh-policy evaluation digest. */\nexport type GovernedActionPolicyEvaluationDigest = typeof GovernedActionPolicyEvaluationDigest.Type\n\n/** Digest of every immutable field in one human action authorization. */\nexport const GovernedActionAuthorizationDigest = sha256Digest(\"GovernedActionAuthorizationDigest\")\n\n/** Decoded governed-action authorization digest. */\nexport type GovernedActionAuthorizationDigest = typeof GovernedActionAuthorizationDigest.Type\n\n/** Digest of every immutable field in one durable dispatch attempt. */\nexport const GovernedActionAttemptDigest = sha256Digest(\"GovernedActionAttemptDigest\")\n\n/** Decoded governed-action attempt digest. */\nexport type GovernedActionAttemptDigest = typeof GovernedActionAttemptDigest.Type\n\n/** Digest of the exact versioned policy snapshot used for authorization. */\nexport const GovernedActionPolicyDigest = sha256Digest(\"GovernedActionPolicyDigest\")\n\n/** Decoded governed-action policy digest. */\nexport type GovernedActionPolicyDigest = typeof GovernedActionPolicyDigest.Type\n\n/** Stable identity of one governed-action policy family. */\nexport const GovernedActionPolicyId = boundedIdentifier(\"GovernedActionPolicyId\", 200)\n\n/** Decoded governed-action policy identity. */\nexport type GovernedActionPolicyId = typeof GovernedActionPolicyId.Type\n\n/** Workspace-connection scoped key that deduplicates one governed provider mutation. */\nexport const GovernedActionIdempotencyKey = Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(512)\n).pipe(Schema.brand(\"GovernedActionIdempotencyKey\"))\n\n/** Decoded governed-action idempotency key. */\nexport type GovernedActionIdempotencyKey = typeof GovernedActionIdempotencyKey.Type\n\n/** Optimistic revision of the exact configured plugin connection authorized for dispatch. */\nexport const GovernedActionPluginConnectionRevision = PositiveInteger.pipe(\n Schema.brand(\"GovernedActionPluginConnectionRevision\")\n)\n\n/** Decoded configured-connection revision bound to a governed action. */\nexport type GovernedActionPluginConnectionRevision = typeof GovernedActionPluginConnectionRevision.Type\n\n/** Non-secret digest that changes with configuration, credentials, or resolved provider account. */\nexport const GovernedActionPluginConnectionAuthorityDigest = sha256Digest(\n \"GovernedActionPluginConnectionAuthorityDigest\"\n)\n\n/** Decoded configured-connection authority generation. */\nexport type GovernedActionPluginConnectionAuthorityDigest = typeof GovernedActionPluginConnectionAuthorityDigest.Type\n\n/** Versioned policy and permission snapshot bound into an action proposal. */\nexport const GovernedActionPolicyBinding = Schema.Struct({\n policyId: GovernedActionPolicyId,\n policyVersion: PositiveInteger,\n policyDigest: GovernedActionPolicyDigest,\n requiredPermission: Role\n})\n\n/** Decoded governed-action policy binding. */\nexport type GovernedActionPolicyBinding = typeof GovernedActionPolicyBinding.Type\n\n/** Fresh policy result recomputed immediately before a provider mutation may dispatch. */\nexport const GovernedActionPolicyEvaluationV1 = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n policy: GovernedActionPolicyBinding,\n payloadDigest: PluginActionPayloadDigest,\n evidenceSetDigest: GovernedActionEvidenceSetDigest,\n expectedRevision: Revision,\n decision: Schema.Literals([\"allowed\", \"denied\"]),\n evaluatedAt: UtcTimestamp\n})\n\n/** Decoded fresh policy evaluation for one exact governed action. */\nexport type GovernedActionPolicyEvaluationV1 = typeof GovernedActionPolicyEvaluationV1.Type\n\n/** Current normalized target and exact provider provenance checked before dispatch. */\nexport const GovernedActionTargetSnapshotV1 = Schema.Struct({\n workspaceId: WorkspaceId,\n entityId: EntityId,\n entityType: PluginEntityType,\n sourceRevision: SourceRevision\n})\n\n/** Decoded current target snapshot used by governed-action authority. */\nexport type GovernedActionTargetSnapshotV1 = typeof GovernedActionTargetSnapshotV1.Type\n\n/** Exact immutable evidence state considered by policy at proposal time. */\nexport const GovernedActionEvidenceReference = Schema.Struct({\n workspaceId: WorkspaceId,\n evidenceId: EvidenceId,\n evidenceClaimIds: Schema.Array(EvidenceClaimId).check(\n Schema.isUnique(),\n Schema.makeFilter(isCanonicalText, { expected: \"evidence claim identities in canonical order\" }),\n Schema.makeFilter((evidenceClaimIds) => evidenceClaimIds.length <= 100, {\n expected: \"at most 100 evidence claims per evidence item\"\n })\n ),\n observedAt: UtcTimestamp,\n validUntil: Schema.NullOr(UtcTimestamp),\n currentUntil: Schema.NullOr(UtcTimestamp),\n evaluatedAt: UtcTimestamp,\n source: Schema.Literals([\"current\", \"stale\", \"missing\", \"unavailable\"]),\n validity: Schema.Literals([\"valid\", \"expired\"])\n}).check(\n Schema.makeFilter(\n ({ evaluatedAt, observedAt }) => DateTime.Order(observedAt, evaluatedAt) <= 0,\n { expected: \"evidence evaluation not to precede observation\" }\n ),\n Schema.makeFilter(\n ({ observedAt, validUntil }) => validUntil === null || DateTime.Order(observedAt, validUntil) < 0,\n { expected: \"evidence validity to end after observation\" }\n ),\n Schema.makeFilter(\n ({ currentUntil, observedAt }) => currentUntil === null || DateTime.Order(observedAt, currentUntil) < 0,\n { expected: \"evidence freshness to end after observation\" }\n ),\n Schema.makeFilter(\n ({ currentUntil, evaluatedAt, source }) => {\n if (source === \"current\") return currentUntil === null || DateTime.Order(evaluatedAt, currentUntil) < 0\n if (source === \"stale\") return currentUntil !== null && DateTime.Order(evaluatedAt, currentUntil) >= 0\n return currentUntil === null\n },\n { expected: \"evidence source state to match its evaluation and freshness window\" }\n ),\n Schema.makeFilter(\n ({ evaluatedAt, validUntil, validity }) => {\n const expectedValidity = validUntil === null || DateTime.Order(evaluatedAt, validUntil) < 0\n ? \"valid\"\n : \"expired\"\n return validity === expectedValidity\n },\n { expected: \"evidence validity to match its evaluation and validity window\" }\n )\n)\n\n/** Decoded immutable evidence reference. */\nexport type GovernedActionEvidenceReference = typeof GovernedActionEvidenceReference.Type\n\n/** Human or agent provenance for a proposal; neither form grants execution authority. */\nexport const GovernedActionProposalOrigin = Schema.TaggedUnion({\n human: {\n actor: HumanActor,\n sessionId: SessionId\n },\n agent: {\n actor: AgentActor,\n jobId: JobId,\n initiatingSessionId: Schema.NullOr(SessionId)\n }\n})\n\n/** Decoded governed-action proposal provenance. */\nexport type GovernedActionProposalOrigin = typeof GovernedActionProposalOrigin.Type\n\nconst canonicalEvidenceReferences = Schema.makeFilter(\n (evidence: ReadonlyArray<GovernedActionEvidenceReference>) =>\n isCanonicalText(evidence.map(({ evidenceId }) => evidenceId)),\n { expected: \"unique evidence references in canonical evidence-id order\" }\n)\n\n/** Bounded canonical set of immutable evidence references used by action authority. */\nexport const GovernedActionEvidenceSet = Schema.Array(GovernedActionEvidenceReference).check(\n Schema.makeFilter((evidence) => evidence.length <= 100, { expected: \"at most 100 evidence references\" }),\n canonicalEvidenceReferences\n)\n\n/** Decoded governed-action evidence set. */\nexport type GovernedActionEvidenceSet = typeof GovernedActionEvidenceSet.Type\n\nconst governedActionEnvelopeMaterialFields = {\n schemaVersion: Schema.Literal(1),\n actionId: GovernedActionId,\n idempotencyKey: GovernedActionIdempotencyKey,\n workspaceId: WorkspaceId,\n pluginConnectionId: PluginConnectionId,\n pluginConnectionRevision: GovernedActionPluginConnectionRevision,\n pluginConnectionAuthorityDigest: GovernedActionPluginConnectionAuthorityDigest,\n pluginId: PluginId,\n pluginContractVersion: SemanticVersion,\n pluginAdapterVersion: SemanticVersion,\n providerId: ProviderId,\n capability: Schema.Struct({\n capabilityId: Schema.Literal(\"action.execute\"),\n version: PositiveInteger\n }),\n targetEntityId: EntityId,\n proposal: PluginActionProposalV1,\n evidence: GovernedActionEvidenceSet,\n evidenceSetDigest: GovernedActionEvidenceSetDigest,\n policy: GovernedActionPolicyBinding,\n origin: GovernedActionProposalOrigin,\n proposalExpiresAt: UtcTimestamp,\n causationId: Schema.NullOr(DomainEventId),\n correlationId: Schema.NullOr(DomainEventCorrelationId)\n}\n\n/** Complete digest-free material used to derive an immutable action envelope identity. */\nexport const GovernedActionEnvelopeMaterialV1 = Schema.Struct(governedActionEnvelopeMaterialFields).check(\n Schema.makeFilter(\n ({ capability, proposal }) => capability.version === proposal.capabilityVersion,\n { expected: \"envelope capability version to match the proposal capability version\" }\n ),\n Schema.makeFilter(\n ({ proposal, proposalExpiresAt }) => DateTime.Order(proposal.proposedAt, proposalExpiresAt) < 0,\n { expected: \"action proposal to expire after it is created\" }\n ),\n Schema.makeFilter(\n ({ evidence, workspaceId }) => evidence.every((reference) => reference.workspaceId === workspaceId),\n { expected: \"every governed-action evidence reference to belong to the action workspace\" }\n )\n)\n\n/** Decoded digest-free V1 governed-action envelope material. */\nexport type GovernedActionEnvelopeMaterialV1 = typeof GovernedActionEnvelopeMaterialV1.Type\n\n/** Immutable, versioned host authority for one proposed provider mutation. */\nexport const GovernedActionEnvelopeV1 = Schema.Struct({\n ...governedActionEnvelopeMaterialFields,\n envelopeDigest: GovernedActionEnvelopeDigest\n}).check(\n Schema.makeFilter(\n ({ capability, proposal }) => capability.version === proposal.capabilityVersion,\n { expected: \"envelope capability version to match the proposal capability version\" }\n ),\n Schema.makeFilter(\n ({ proposal, proposalExpiresAt }) => DateTime.Order(proposal.proposedAt, proposalExpiresAt) < 0,\n { expected: \"action proposal to expire after it is created\" }\n ),\n Schema.makeFilter(\n ({ evidence, workspaceId }) => evidence.every((reference) => reference.workspaceId === workspaceId),\n { expected: \"every governed-action evidence reference to belong to the action workspace\" }\n )\n)\n\n/** Decoded immutable V1 governed-action envelope. */\nexport type GovernedActionEnvelopeV1 = typeof GovernedActionEnvelopeV1.Type\n\n/** Human authorization bound to the complete immutable action and policy inputs. */\nexport const GovernedActionAuthorizationV1 = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n authorizationId: GovernedActionAuthorizationId,\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n pluginConnectionId: PluginConnectionId,\n pluginConnectionRevision: GovernedActionPluginConnectionRevision,\n pluginConnectionAuthorityDigest: GovernedActionPluginConnectionAuthorityDigest,\n actionEnvelopeDigest: GovernedActionEnvelopeDigest,\n idempotencyKey: GovernedActionIdempotencyKey,\n payloadDigest: PluginActionPayloadDigest,\n evidenceSetDigest: GovernedActionEvidenceSetDigest,\n policyDigest: GovernedActionPolicyDigest,\n expectedRevision: Revision,\n capabilityVersion: PositiveInteger,\n actor: HumanActor,\n sessionId: SessionId,\n sessionPermission: Role,\n sessionExpiresAt: UtcTimestamp,\n requiredPermission: Role,\n authorizedAt: UtcTimestamp,\n expiresAt: UtcTimestamp\n}).check(\n Schema.makeFilter(\n ({ authorizedAt, expiresAt }) => DateTime.Order(authorizedAt, expiresAt) < 0,\n { expected: \"governed-action authorization to expire after it is issued\" }\n ),\n Schema.makeFilter(\n ({ expiresAt, sessionExpiresAt }) => DateTime.Order(expiresAt, sessionExpiresAt) <= 0,\n { expected: \"governed-action authorization not to outlive its authenticated session\" }\n )\n)\n\n/** Decoded immutable human authorization. */\nexport type GovernedActionAuthorizationV1 = typeof GovernedActionAuthorizationV1.Type\n\n/** Durable dispatch intent created only after an exact ready preflight. */\nexport const GovernedActionAttemptV1 = Schema.Struct({\n schemaVersion: Schema.Literal(1),\n attemptId: GovernedActionAttemptId,\n authorizationId: GovernedActionAuthorizationId,\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n pluginConnectionId: PluginConnectionId,\n idempotencyKey: GovernedActionIdempotencyKey,\n attemptNumber: Schema.Literal(1),\n actionEnvelopeDigest: GovernedActionEnvelopeDigest,\n expectedRevision: Revision,\n policyEvaluationDigest: GovernedActionPolicyEvaluationDigest,\n preflight: ReadyPluginActionPreflightV1,\n startedAt: UtcTimestamp\n}).check(\n Schema.makeFilter(\n ({ expectedRevision, preflight }) => expectedRevision === preflight.checkedRevision,\n { expected: \"dispatch intent revision to match the ready preflight revision\" }\n ),\n Schema.makeFilter(\n ({ preflight, startedAt }) => DateTime.Order(preflight.checkedAt, startedAt) <= 0,\n { expected: \"dispatch intent not to precede its ready preflight\" }\n )\n)\n\n/** Decoded immutable dispatch intent. */\nexport type GovernedActionAttemptV1 = typeof GovernedActionAttemptV1.Type\n","import * as DateTime from \"effect/DateTime\"\nimport * as Schema from \"effect/Schema\"\n\nimport type { Role } from \"../actors.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport { GovernedActionAttemptV1, GovernedActionAuthorizationV1, GovernedActionEnvelopeV1 } from \"./model.js\"\nimport type { GovernedActionTransitionV1 } from \"./stateMachine.js\"\n\n/** Closed reasons why durable authorization or dispatch intent does not match its action. */\nexport const GovernedActionAuthorityMismatch = Schema.Literals([\n \"authorization-action-mismatch\",\n \"authorization-workspace-mismatch\",\n \"authorization-connection-mismatch\",\n \"authorization-connection-revision-mismatch\",\n \"authorization-connection-authority-mismatch\",\n \"authorization-envelope-mismatch\",\n \"authorization-idempotency-mismatch\",\n \"authorization-payload-mismatch\",\n \"authorization-evidence-mismatch\",\n \"authorization-policy-mismatch\",\n \"authorization-revision-mismatch\",\n \"authorization-capability-mismatch\",\n \"authorization-permission-mismatch\",\n \"authorization-outside-proposal-window\",\n \"authorization-expired\",\n \"authorization-session-expired\",\n \"evidence-not-current\",\n \"evidence-set-changed\",\n \"evidence-workspace-mismatch\",\n \"session-id-mismatch\",\n \"session-actor-mismatch\",\n \"session-workspace-mismatch\",\n \"session-permission-mismatch\",\n \"session-revoked\",\n \"authorization-session-chronology\",\n \"current-plugin-connection-mismatch\",\n \"current-plugin-workspace-mismatch\",\n \"current-plugin-provider-mismatch\",\n \"current-plugin-revision-mismatch\",\n \"current-plugin-authority-mismatch\",\n \"current-plugin-unavailable\",\n \"current-plugin-mismatch\",\n \"current-capability-unavailable\",\n \"current-capability-version-mismatch\",\n \"current-policy-denied\",\n \"current-policy-mismatch\",\n \"current-target-workspace-mismatch\",\n \"current-target-entity-mismatch\",\n \"current-target-type-mismatch\",\n \"current-target-source-mismatch\",\n \"current-target-revision-mismatch\",\n \"attempt-action-mismatch\",\n \"attempt-authorization-mismatch\",\n \"attempt-workspace-mismatch\",\n \"attempt-connection-mismatch\",\n \"attempt-envelope-mismatch\",\n \"attempt-idempotency-mismatch\",\n \"attempt-policy-evaluation-mismatch\",\n \"attempt-revision-mismatch\",\n \"attempt-outside-authorization-window\"\n])\n\n/** Decoded governed-action authority mismatch. */\nexport type GovernedActionAuthorityMismatch = typeof GovernedActionAuthorityMismatch.Type\n\n/** Complete aggregate authority checked immediately before durable dispatch intent. */\nexport const GovernedActionAuthorityBindingInput = Schema.Struct({\n envelope: GovernedActionEnvelopeV1,\n authorization: GovernedActionAuthorizationV1,\n attempt: GovernedActionAttemptV1,\n evaluatedAt: UtcTimestamp\n})\n\n/** Decoded aggregate authority inputs checked immediately before dispatch. */\nexport type GovernedActionAuthorityBindingInput = typeof GovernedActionAuthorityBindingInput.Type\n\n/** Immutable authorization inputs that can be verified before a dispatch attempt exists. */\nexport const GovernedActionAuthorizationBindingInput = Schema.Struct({\n envelope: GovernedActionEnvelopeV1,\n authorization: GovernedActionAuthorizationV1\n})\n\n/** Decoded authorization-only binding inputs. */\nexport type GovernedActionAuthorizationBindingInput = typeof GovernedActionAuthorizationBindingInput.Type\n\n/** Explicit V1 permission implication: workspace owner or an exact scoped role. */\nexport const governedActionPermissionGrants = (sessionPermission: Role, requiredPermission: Role): boolean =>\n sessionPermission === \"workspace-owner\" || sessionPermission === requiredPermission\n\n/** Return every fail-closed mismatch between an envelope and its human grant. */\nexport const governedActionAuthorizationMismatches = ({\n authorization,\n envelope\n}: GovernedActionAuthorizationBindingInput): ReadonlyArray<GovernedActionAuthorityMismatch> => {\n const mismatches: Array<GovernedActionAuthorityMismatch> = []\n const addMismatch = (condition: boolean, mismatch: GovernedActionAuthorityMismatch): void => {\n if (condition) mismatches.push(mismatch)\n }\n\n addMismatch(authorization.actionId !== envelope.actionId, \"authorization-action-mismatch\")\n addMismatch(authorization.workspaceId !== envelope.workspaceId, \"authorization-workspace-mismatch\")\n addMismatch(\n authorization.pluginConnectionId !== envelope.pluginConnectionId,\n \"authorization-connection-mismatch\"\n )\n addMismatch(\n authorization.pluginConnectionRevision !== envelope.pluginConnectionRevision,\n \"authorization-connection-revision-mismatch\"\n )\n addMismatch(\n authorization.pluginConnectionAuthorityDigest !== envelope.pluginConnectionAuthorityDigest,\n \"authorization-connection-authority-mismatch\"\n )\n addMismatch(\n authorization.actionEnvelopeDigest !== envelope.envelopeDigest,\n \"authorization-envelope-mismatch\"\n )\n addMismatch(authorization.idempotencyKey !== envelope.idempotencyKey, \"authorization-idempotency-mismatch\")\n addMismatch(\n authorization.payloadDigest !== envelope.proposal.payloadDigest,\n \"authorization-payload-mismatch\"\n )\n addMismatch(\n authorization.evidenceSetDigest !== envelope.evidenceSetDigest,\n \"authorization-evidence-mismatch\"\n )\n addMismatch(authorization.policyDigest !== envelope.policy.policyDigest, \"authorization-policy-mismatch\")\n addMismatch(\n authorization.expectedRevision !== envelope.proposal.request.expectedRevision,\n \"authorization-revision-mismatch\"\n )\n addMismatch(\n authorization.capabilityVersion !== envelope.capability.version,\n \"authorization-capability-mismatch\"\n )\n addMismatch(\n authorization.requiredPermission !== envelope.policy.requiredPermission,\n \"authorization-permission-mismatch\"\n )\n addMismatch(\n !governedActionPermissionGrants(authorization.sessionPermission, authorization.requiredPermission),\n \"authorization-permission-mismatch\"\n )\n addMismatch(\n DateTime.Order(authorization.authorizedAt, envelope.proposal.proposedAt) < 0 ||\n DateTime.Order(authorization.authorizedAt, envelope.proposalExpiresAt) >= 0 ||\n DateTime.Order(authorization.expiresAt, envelope.proposalExpiresAt) > 0,\n \"authorization-outside-proposal-window\"\n )\n\n return mismatches\n}\n\n/** Whether a human grant is attributable to its exact immutable authorize transition. */\nexport const governedActionAuthorizationMatchesTransition = (\n authorization: GovernedActionAuthorizationV1,\n transition: GovernedActionTransitionV1\n): boolean =>\n transition.command._tag === \"authorize\" &&\n transition.command.authorizationId === authorization.authorizationId &&\n transition.actionId === authorization.actionId &&\n transition.workspaceId === authorization.workspaceId &&\n transition.actionEnvelopeDigest === authorization.actionEnvelopeDigest &&\n DateTime.Order(transition.occurredAt, authorization.authorizedAt) === 0 &&\n transition.cause._tag === \"human\" &&\n transition.cause.actor.personId === authorization.actor.personId &&\n transition.cause.sessionId === authorization.sessionId\n\n/** Return every fail-closed mismatch between an envelope, human grant, and dispatch intent. */\nexport const governedActionAuthorityMismatches = ({\n attempt,\n authorization,\n envelope,\n evaluatedAt\n}: GovernedActionAuthorityBindingInput): ReadonlyArray<GovernedActionAuthorityMismatch> => {\n const mismatches: Array<GovernedActionAuthorityMismatch> = [\n ...governedActionAuthorizationMismatches({ authorization, envelope })\n ]\n const addMismatch = (condition: boolean, mismatch: GovernedActionAuthorityMismatch): void => {\n if (condition) mismatches.push(mismatch)\n }\n\n addMismatch(\n DateTime.Order(evaluatedAt, authorization.expiresAt) >= 0 ||\n DateTime.Order(evaluatedAt, envelope.proposalExpiresAt) >= 0,\n \"authorization-expired\"\n )\n addMismatch(\n DateTime.Order(evaluatedAt, authorization.sessionExpiresAt) >= 0,\n \"authorization-session-expired\"\n )\n addMismatch(\n envelope.evidence.some(({ currentUntil, source, validUntil }) =>\n source !== \"current\" ||\n (currentUntil !== null && DateTime.Order(evaluatedAt, currentUntil) >= 0) ||\n (validUntil !== null && DateTime.Order(evaluatedAt, validUntil) >= 0)\n ),\n \"evidence-not-current\"\n )\n\n addMismatch(attempt.actionId !== envelope.actionId, \"attempt-action-mismatch\")\n addMismatch(attempt.authorizationId !== authorization.authorizationId, \"attempt-authorization-mismatch\")\n addMismatch(attempt.workspaceId !== envelope.workspaceId, \"attempt-workspace-mismatch\")\n addMismatch(attempt.pluginConnectionId !== envelope.pluginConnectionId, \"attempt-connection-mismatch\")\n addMismatch(attempt.actionEnvelopeDigest !== envelope.envelopeDigest, \"attempt-envelope-mismatch\")\n addMismatch(attempt.idempotencyKey !== envelope.idempotencyKey, \"attempt-idempotency-mismatch\")\n addMismatch(attempt.expectedRevision !== envelope.proposal.request.expectedRevision, \"attempt-revision-mismatch\")\n addMismatch(\n DateTime.Order(attempt.preflight.checkedAt, authorization.authorizedAt) < 0 ||\n DateTime.Order(attempt.startedAt, authorization.authorizedAt) < 0 ||\n DateTime.Order(attempt.startedAt, authorization.expiresAt) >= 0 ||\n DateTime.Order(attempt.startedAt, envelope.proposalExpiresAt) >= 0 ||\n DateTime.Order(attempt.startedAt, evaluatedAt) > 0,\n \"attempt-outside-authorization-window\"\n )\n\n return mismatches\n}\n","import * as Schema from \"effect/Schema\"\n\nimport { AgentActor, HumanActor } from \"../actors.js\"\nimport { DomainEventCorrelationId } from \"../domainEvent.js\"\nimport {\n DomainEventId,\n GovernedActionAttemptId,\n GovernedActionAuthorizationId,\n GovernedActionId,\n GovernedActionTransitionId,\n JobId,\n SessionId,\n WorkspaceId\n} from \"../identifiers.js\"\nimport {\n PluginAcceptedProviderReceiptV1,\n PluginActionReconciliationKey,\n PluginProviderOperationId,\n PluginTerminalProviderReceiptV1\n} from \"../plugins/actions.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\nimport { GovernedActionEnvelopeDigest } from \"./model.js\"\n\nconst PositiveInteger = Schema.Int.check(Schema.isGreaterThan(0))\nconst SafeReason = Schema.String.check(Schema.isTrimmed(), Schema.isNonEmpty(), Schema.isMaxLength(1_000))\nconst boundedIdentifier = (name: string, maximumLength: number) =>\n Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(maximumLength),\n Schema.isPattern(/^[A-Za-z0-9._:/-]+$/u, { expected: \"a bounded action identifier\" })\n ).pipe(Schema.brand(name))\n\n/** Complete persisted lifecycle states for a governed action. */\nexport const GovernedActionState = Schema.Literals([\n \"proposed\",\n \"authorized\",\n \"denied\",\n \"expired\",\n \"cancelled\",\n \"started\",\n \"cancel-requested\",\n \"cancel-requested-unknown\",\n \"succeeded\",\n \"failed\",\n \"unknown\"\n])\n\n/** Decoded governed-action lifecycle state. */\nexport type GovernedActionState = typeof GovernedActionState.Type\n\n/** Stable identity supplied by a caller to deduplicate one lifecycle command. */\nexport const GovernedActionCommandId = boundedIdentifier(\"GovernedActionCommandId\", 512)\n\n/** Decoded governed-action command identity. */\nexport type GovernedActionCommandId = typeof GovernedActionCommandId.Type\n\n/** Digest of one canonical transition command used to reject changed command retries. */\nexport const GovernedActionCommandDigest = Schema.String.check(\n Schema.isPattern(/^sha256:[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n).pipe(Schema.brand(\"GovernedActionCommandDigest\"))\n\n/** Decoded governed-action command digest. */\nexport type GovernedActionCommandDigest = typeof GovernedActionCommandDigest.Type\n\n/** Digest of every immutable field in one governed-action transition. */\nexport const GovernedActionTransitionDigest = Schema.String.check(\n Schema.isPattern(/^sha256:[0-9a-f]{64}$/u, { expected: \"a lowercase SHA-256 digest\" })\n).pipe(Schema.brand(\"GovernedActionTransitionDigest\"))\n\n/** Decoded governed-action transition digest. */\nexport type GovernedActionTransitionDigest = typeof GovernedActionTransitionDigest.Type\n\n/** Closed reason why authorization or preflight failed without calling a provider. */\nexport const GovernedActionDenialReason = Schema.Literals([\n \"revision-changed\",\n \"evidence-stale\",\n \"evidence-invalid\",\n \"policy-denied\",\n \"session-invalid\",\n \"capability-changed\",\n \"plugin-unavailable\",\n \"preflight-blocked\"\n])\n\n/** Decoded governed-action denial reason. */\nexport type GovernedActionDenialReason = typeof GovernedActionDenialReason.Type\n\n/** Unknown provider outcome that is either safely reconcilable or explicitly manual. */\nexport const GovernedActionUnknownOutcome = Schema.TaggedUnion({\n reconcilable: {\n reconciliationKey: PluginActionReconciliationKey,\n observedAt: UtcTimestamp,\n safeSummary: SafeReason\n },\n manual: {\n observedAt: UtcTimestamp,\n safeSummary: SafeReason,\n reason: Schema.Literals([\n \"dispatch-deadline-exceeded\",\n \"interrupted-after-intent\",\n \"provider-defect-after-intent\",\n \"malformed-provider-result\",\n \"receipt-persistence-failed\",\n \"missing-reconciliation-locator\"\n ])\n }\n})\n\n/** Decoded truthful unknown-outcome detail. */\nexport type GovernedActionUnknownOutcome = typeof GovernedActionUnknownOutcome.Type\n\nconst SucceededReceipt = PluginTerminalProviderReceiptV1.check(\n Schema.makeFilter(({ status }) => status === \"succeeded\", { expected: \"a succeeded provider receipt\" })\n)\nconst FailedReceipt = PluginTerminalProviderReceiptV1.check(\n Schema.makeFilter(({ status }) => status === \"failed\", { expected: \"a failed provider receipt\" })\n)\nconst CancelledReceipt = PluginTerminalProviderReceiptV1.check(\n Schema.makeFilter(({ status }) => status === \"cancelled\", { expected: \"a cancelled provider receipt\" })\n)\n\n/** Whether a terminal receipt came from dispatch or reconciliation by provider/idempotency identity. */\nexport const GovernedActionOutcomeSource = Schema.TaggedUnion({\n direct: {},\n providerOperation: { providerOperationId: PluginProviderOperationId },\n reconciliation: { reconciliationKey: Schema.NullOr(PluginActionReconciliationKey) }\n})\n\n/** Decoded terminal provider-outcome source. */\nexport type GovernedActionOutcomeSource = typeof GovernedActionOutcomeSource.Type\n\n/** Closed commands that may append one governed-action lifecycle transition. */\nexport const GovernedActionTransitionCommand = Schema.TaggedUnion({\n propose: {},\n authorize: { authorizationId: GovernedActionAuthorizationId },\n deny: {\n reason: GovernedActionDenialReason,\n safeSummary: SafeReason\n },\n expire: {\n reason: Schema.Literals([\"proposal-expired\", \"authorization-expired\"])\n },\n cancel: { safeSummary: SafeReason },\n start: { attemptId: GovernedActionAttemptId },\n requestCancellation: { safeSummary: SafeReason },\n recordAccepted: { receipt: PluginAcceptedProviderReceiptV1 },\n recordSucceeded: { receipt: SucceededReceipt, source: GovernedActionOutcomeSource },\n recordFailed: { receipt: FailedReceipt, source: GovernedActionOutcomeSource },\n recordUnknown: { outcome: GovernedActionUnknownOutcome },\n recordCancelled: { receipt: CancelledReceipt, source: GovernedActionOutcomeSource },\n reconciliationPending: {\n checkedAt: UtcTimestamp,\n reconciliationKey: Schema.NullOr(PluginActionReconciliationKey)\n }\n})\n\n/** Decoded governed-action lifecycle command. */\nexport type GovernedActionTransitionCommand = typeof GovernedActionTransitionCommand.Type\n\n/** Attributable human, agent, or internal component responsible for a transition. */\nexport const GovernedActionTransitionCause = Schema.TaggedUnion({\n human: {\n actor: HumanActor,\n sessionId: SessionId\n },\n agent: {\n actor: AgentActor,\n jobId: JobId\n },\n system: {\n component: boundedIdentifier(\"GovernedActionSystemComponent\", 200)\n }\n})\n\n/** Decoded governed-action transition attribution. */\nexport type GovernedActionTransitionCause = typeof GovernedActionTransitionCause.Type\n\nconst canRecordTerminalOutcome = (\n currentState: GovernedActionState | null,\n source: GovernedActionOutcomeSource\n): boolean =>\n currentState === \"started\" ||\n currentState === \"cancel-requested\" ||\n ((currentState === \"unknown\" || currentState === \"cancel-requested-unknown\") &&\n source._tag === \"reconciliation\")\n\n/**\n * Resolve a lifecycle command without side effects.\n * A null result means the command is not legal from the supplied state.\n */\nexport const reduceGovernedActionState = (\n currentState: GovernedActionState | null,\n command: GovernedActionTransitionCommand\n): GovernedActionState | null => {\n switch (command._tag) {\n case \"propose\":\n return currentState === null ? \"proposed\" : null\n case \"authorize\":\n return currentState === \"proposed\" ? \"authorized\" : null\n case \"deny\":\n return currentState === \"proposed\" || currentState === \"authorized\" ? \"denied\" : null\n case \"expire\":\n return currentState === \"proposed\" || currentState === \"authorized\" ? \"expired\" : null\n case \"cancel\":\n return currentState === \"proposed\" || currentState === \"authorized\" ? \"cancelled\" : null\n case \"start\":\n return currentState === \"authorized\" ? \"started\" : null\n case \"requestCancellation\":\n return currentState === \"started\"\n ? \"cancel-requested\"\n : currentState === \"unknown\"\n ? \"cancel-requested-unknown\"\n : null\n case \"recordAccepted\":\n return currentState === \"started\" || currentState === \"cancel-requested\" ? currentState : null\n case \"recordUnknown\":\n return currentState === \"started\"\n ? \"unknown\"\n : currentState === \"cancel-requested\"\n ? \"cancel-requested-unknown\"\n : null\n case \"recordSucceeded\":\n return canRecordTerminalOutcome(currentState, command.source) ? \"succeeded\" : null\n case \"recordFailed\":\n return canRecordTerminalOutcome(currentState, command.source) ? \"failed\" : null\n case \"recordCancelled\":\n return canRecordTerminalOutcome(currentState, command.source) ? \"cancelled\" : null\n case \"reconciliationPending\":\n return currentState === \"started\" ||\n currentState === \"cancel-requested\" ||\n currentState === \"unknown\" ||\n currentState === \"cancel-requested-unknown\"\n ? currentState\n : null\n }\n}\n\n/** Whether a governed action has reached a state that cannot execute more provider work. */\nexport const isGovernedActionTerminalState = (state: GovernedActionState): boolean =>\n state === \"denied\" ||\n state === \"expired\" ||\n state === \"cancelled\" ||\n state === \"succeeded\" ||\n state === \"failed\"\n\nconst commandCauseIsAllowed = (\n command: GovernedActionTransitionCommand,\n cause: GovernedActionTransitionCause\n): boolean => {\n switch (cause._tag) {\n case \"agent\":\n return command._tag === \"propose\"\n case \"human\":\n return command._tag === \"propose\" ||\n command._tag === \"authorize\" ||\n command._tag === \"deny\" ||\n command._tag === \"cancel\" ||\n command._tag === \"requestCancellation\"\n case \"system\":\n return command._tag === \"deny\" ||\n command._tag === \"expire\" ||\n command._tag === \"cancel\" ||\n command._tag === \"start\" ||\n command._tag === \"requestCancellation\" ||\n command._tag === \"recordAccepted\" ||\n command._tag === \"recordSucceeded\" ||\n command._tag === \"recordFailed\" ||\n command._tag === \"recordUnknown\" ||\n command._tag === \"recordCancelled\" ||\n command._tag === \"reconciliationPending\"\n }\n}\n\nconst governedActionTransitionMaterialFields = {\n schemaVersion: Schema.Literal(1),\n transitionId: GovernedActionTransitionId,\n previousTransitionId: Schema.NullOr(GovernedActionTransitionId),\n commandId: GovernedActionCommandId,\n actionId: GovernedActionId,\n workspaceId: WorkspaceId,\n sequence: PositiveInteger,\n fromState: Schema.NullOr(GovernedActionState),\n toState: GovernedActionState,\n actionEnvelopeDigest: GovernedActionEnvelopeDigest,\n command: GovernedActionTransitionCommand,\n cause: GovernedActionTransitionCause,\n occurredAt: UtcTimestamp,\n causationId: Schema.NullOr(DomainEventId),\n correlationId: Schema.NullOr(DomainEventCorrelationId)\n}\n\n/** Digest-free transition fields used only by the trusted transition constructor. */\nexport const GovernedActionTransitionMaterialV1 = Schema.Struct(\n governedActionTransitionMaterialFields\n).check(\n Schema.makeFilter(\n ({ command, fromState, toState }) => reduceGovernedActionState(fromState, command) === toState,\n { expected: \"a legal governed-action state transition\" }\n ),\n Schema.makeFilter(\n ({ cause, command }) => commandCauseIsAllowed(command, cause),\n { expected: \"transition cause to have authority for the command\" }\n ),\n Schema.makeFilter(\n ({ fromState, previousTransitionId, sequence }) =>\n sequence === 1\n ? fromState === null && previousTransitionId === null\n : fromState !== null && previousTransitionId !== null,\n { expected: \"the first transition to be the only transition without a predecessor\" }\n )\n)\n\n/** Decoded digest-free governed-action transition material. */\nexport type GovernedActionTransitionMaterialV1 = typeof GovernedActionTransitionMaterialV1.Type\n\n/** Immutable append-only audit record for one legal lifecycle command. */\nexport const GovernedActionTransitionV1 = Schema.Struct({\n ...governedActionTransitionMaterialFields,\n commandDigest: GovernedActionCommandDigest\n}).check(\n Schema.makeFilter(\n ({ command, fromState, toState }) => reduceGovernedActionState(fromState, command) === toState,\n { expected: \"a legal governed-action state transition\" }\n ),\n Schema.makeFilter(\n ({ cause, command }) => commandCauseIsAllowed(command, cause),\n { expected: \"transition cause to have authority for the command\" }\n ),\n Schema.makeFilter(\n ({ fromState, previousTransitionId, sequence }) =>\n sequence === 1\n ? fromState === null && previousTransitionId === null\n : fromState !== null && previousTransitionId !== null,\n { expected: \"the first transition to be the only transition without a predecessor\" }\n )\n)\n\n/** Decoded immutable governed-action transition. */\nexport type GovernedActionTransitionV1 = typeof GovernedActionTransitionV1.Type\n","import * as Schema from \"effect/Schema\"\n\nimport {\n PluginAcceptedProviderReceiptV1,\n PluginActionReconciliationKey,\n PluginProviderOperationId,\n PluginTerminalProviderReceiptV1\n} from \"../plugins/actions.js\"\nimport {\n GovernedActionState,\n type GovernedActionState as GovernedActionStateType,\n type GovernedActionTransitionCommand,\n reduceGovernedActionState\n} from \"./stateMachine.js\"\n\n/** Provider identity retained by the durable action head across async and ambiguous work. */\nexport const GovernedActionProviderLineage = Schema.TaggedUnion({\n none: {},\n accepted: { receipt: PluginAcceptedProviderReceiptV1 },\n reconcilable: {\n providerOperationId: Schema.NullOr(PluginProviderOperationId),\n reconciliationKey: PluginActionReconciliationKey\n },\n manual: {\n providerOperationId: Schema.NullOr(PluginProviderOperationId)\n },\n terminal: { receipt: PluginTerminalProviderReceiptV1 }\n})\n\n/** Decoded provider lineage retained by a governed-action lifecycle head. */\nexport type GovernedActionProviderLineage = typeof GovernedActionProviderLineage.Type\n\nconst stateMatchesLineage = (\n state: GovernedActionStateType,\n lineage: GovernedActionProviderLineage\n): boolean => {\n switch (state) {\n case \"proposed\":\n case \"authorized\":\n case \"denied\":\n case \"expired\":\n return lineage._tag === \"none\"\n case \"cancelled\":\n return lineage._tag === \"none\" || (lineage._tag === \"terminal\" && lineage.receipt.status === \"cancelled\")\n case \"started\":\n case \"cancel-requested\":\n return lineage._tag === \"none\" || lineage._tag === \"accepted\"\n case \"unknown\":\n case \"cancel-requested-unknown\":\n return lineage._tag === \"reconcilable\" || lineage._tag === \"manual\"\n case \"succeeded\":\n return lineage._tag === \"terminal\" && lineage.receipt.status === \"succeeded\"\n case \"failed\":\n return lineage._tag === \"terminal\" && lineage.receipt.status === \"failed\"\n }\n}\n\n/** Durable lifecycle state plus the exact provider identity needed for safe recovery. */\nexport const GovernedActionLifecycleHeadV1 = Schema.Struct({\n state: GovernedActionState,\n lineage: GovernedActionProviderLineage\n}).check(\n Schema.makeFilter(\n ({ lineage, state }) => stateMatchesLineage(state, lineage),\n { expected: \"governed-action state and provider lineage to agree\" }\n )\n)\n\n/** Decoded governed-action lifecycle head. */\nexport type GovernedActionLifecycleHeadV1 = typeof GovernedActionLifecycleHeadV1.Type\n\nconst providerOperationIdFromLineage = (\n lineage: GovernedActionProviderLineage\n): PluginProviderOperationId | null => {\n switch (lineage._tag) {\n case \"accepted\":\n return lineage.receipt.providerOperationId\n case \"reconcilable\":\n case \"manual\":\n return lineage.providerOperationId\n case \"none\":\n case \"terminal\":\n return null\n }\n}\n\nconst reconciliationKeyFromLineage = (\n lineage: GovernedActionProviderLineage\n): PluginActionReconciliationKey | null => {\n switch (lineage._tag) {\n case \"accepted\":\n return lineage.receipt.reconciliationKey\n case \"reconcilable\":\n return lineage.reconciliationKey\n case \"none\":\n case \"manual\":\n case \"terminal\":\n return null\n }\n}\n\nconst unknownLineage = (\n current: GovernedActionProviderLineage,\n command: Extract<GovernedActionTransitionCommand, { readonly _tag: \"recordUnknown\" }>\n): GovernedActionProviderLineage => {\n const providerOperationId = providerOperationIdFromLineage(current)\n if (command.outcome._tag === \"reconcilable\") {\n return {\n _tag: \"reconcilable\",\n providerOperationId,\n reconciliationKey: command.outcome.reconciliationKey\n }\n }\n const retainedReconciliationKey = reconciliationKeyFromLineage(current)\n return retainedReconciliationKey === null\n ? { _tag: \"manual\", providerOperationId }\n : { _tag: \"reconcilable\", providerOperationId, reconciliationKey: retainedReconciliationKey }\n}\n\nconst acceptedReceiptMatches = (\n lineage: GovernedActionProviderLineage,\n command: Extract<GovernedActionTransitionCommand, { readonly _tag: \"recordAccepted\" }>\n): boolean =>\n lineage._tag === \"none\" ||\n (lineage._tag === \"accepted\" &&\n lineage.receipt.providerOperationId === command.receipt.providerOperationId &&\n lineage.receipt.reconciliationKey === command.receipt.reconciliationKey)\n\n/** Null is the action envelope's immutable idempotency identity, never a missing provider key. */\nconst reconciliationLocatorMatches = (\n lineage: GovernedActionProviderLineage,\n reconciliationKey: PluginActionReconciliationKey | null\n): boolean =>\n reconciliationKey === null\n ? lineage._tag === \"none\" || lineage._tag === \"manual\"\n : reconciliationKeyFromLineage(lineage) === reconciliationKey\n\nconst terminalSourceMatches = (\n lineage: GovernedActionProviderLineage,\n command: Extract<\n GovernedActionTransitionCommand,\n { readonly _tag: \"recordSucceeded\" | \"recordFailed\" | \"recordCancelled\" }\n >\n): boolean => {\n const providerOperationId = providerOperationIdFromLineage(lineage)\n switch (command.source._tag) {\n case \"direct\":\n return lineage._tag === \"none\"\n case \"providerOperation\":\n return providerOperationId !== null &&\n command.source.providerOperationId === providerOperationId &&\n command.receipt.providerOperationId === providerOperationId\n case \"reconciliation\":\n return reconciliationLocatorMatches(lineage, command.source.reconciliationKey) &&\n (providerOperationId === null || command.receipt.providerOperationId === providerOperationId)\n }\n}\n\nconst reconciliationPendingMatches = (\n lineage: GovernedActionProviderLineage,\n command: Extract<GovernedActionTransitionCommand, { readonly _tag: \"reconciliationPending\" }>\n): boolean => reconciliationLocatorMatches(lineage, command.reconciliationKey)\n\n/**\n * Advance a durable lifecycle head while retaining and matching opaque provider identity.\n * A null result rejects illegal edges, fabricated locators, and unrelated receipts.\n */\nexport const advanceGovernedActionLifecycle = (\n current: GovernedActionLifecycleHeadV1 | null,\n command: GovernedActionTransitionCommand\n): GovernedActionLifecycleHeadV1 | null => {\n const nextState = reduceGovernedActionState(current?.state ?? null, command)\n if (nextState === null) return null\n const currentLineage: GovernedActionProviderLineage = current?.lineage ?? { _tag: \"none\" }\n\n switch (command._tag) {\n case \"recordAccepted\":\n return acceptedReceiptMatches(currentLineage, command)\n ? { state: nextState, lineage: { _tag: \"accepted\", receipt: command.receipt } }\n : null\n case \"recordUnknown\":\n return { state: nextState, lineage: unknownLineage(currentLineage, command) }\n case \"recordSucceeded\":\n case \"recordFailed\":\n case \"recordCancelled\":\n return terminalSourceMatches(currentLineage, command)\n ? { state: nextState, lineage: { _tag: \"terminal\", receipt: command.receipt } }\n : null\n case \"reconciliationPending\":\n return reconciliationPendingMatches(currentLineage, command)\n ? { state: nextState, lineage: currentLineage }\n : null\n case \"propose\":\n case \"authorize\":\n case \"deny\":\n case \"expire\":\n case \"cancel\":\n case \"start\":\n case \"requestCancellation\":\n return { state: nextState, lineage: currentLineage }\n }\n}\n","import * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport * as SchemaGetter from \"effect/SchemaGetter\"\n\nimport { SourceUrl } from \"../sourceRevision.js\"\nimport { UtcTimestamp } from \"../utcTimestamp.js\"\n\nconst SafeProviderIdentifier = Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(512)\n)\nconst SafeProviderLabel = Schema.String.check(\n Schema.isTrimmed(),\n Schema.isNonEmpty(),\n Schema.isMaxLength(200)\n)\nconst SafeDiscoveryEndpointUrl = SourceUrl.pipe(\n Schema.check(\n Schema.makeFilter(\n ({ hash, search }) => hash.length === 0 && search.length === 0,\n { expected: \"a provider endpoint URL without query parameters or fragments\" }\n )\n )\n)\n\nconst ProviderContainer = Schema.Struct({\n providerImmutableId: SafeProviderIdentifier,\n displayName: SafeProviderLabel\n})\nconst NullableProviderContainer = Schema.NullOr(ProviderContainer)\n\n/** Secret-free provider endpoint advertised during connection discovery. */\nexport const PluginDiscoveryEndpointV1 = Schema.Struct({\n kind: Schema.Literals([\"api\", \"web\", \"graphql\", \"webhook\"]),\n url: SafeDiscoveryEndpointUrl,\n label: Schema.NullOr(SafeProviderLabel)\n})\n\n/** Decoded safe provider endpoint metadata. */\nexport type PluginDiscoveryEndpointV1 = typeof PluginDiscoveryEndpointV1.Type\n\n/**\n * Safe connection metadata discovered from the provider.\n * Credentials, raw headers, and provider response bodies are deliberately absent.\n */\nexport const PluginDiscoveryV1 = Schema.Struct({\n account: NullableProviderContainer,\n workspace: NullableProviderContainer,\n resource: Schema.optional(NullableProviderContainer).pipe(\n Schema.decodeTo(Schema.toType(NullableProviderContainer), {\n decode: SchemaGetter.withDefault(Effect.succeed<typeof NullableProviderContainer.Type>(null)),\n encode: SchemaGetter.required()\n })\n ),\n endpoints: Schema.Array(PluginDiscoveryEndpointV1).check(\n Schema.makeFilter(\n (endpoints) => endpoints.length <= 20,\n { expected: \"at most 20 safe provider endpoints\" }\n )\n ),\n discoveredAt: UtcTimestamp\n}).annotate({ identifier: \"PluginDiscoveryV1\" })\n\n/** Decoded secret-free connection discovery metadata. */\nexport type PluginDiscoveryV1 = typeof PluginDiscoveryV1.Type\n","import * as Schema from \"effect/Schema\"\n\nimport { EnvironmentId, ReadinessAssessmentId, ReleaseId, WorkspaceId } from \"../identifiers.js\"\nimport {\n MAX_READINESS_EVIDENCE_REFERENCES,\n ReadinessArtifactRevision,\n ReadinessCandidateDigest,\n ReadinessFactDefinition,\n type ReadinessFactDefinition as ReadinessFactDefinitionType,\n ReadinessFactObservation,\n type ReadinessFactObservation as ReadinessFactObservationType,\n ReadinessReleaseRevision,\n ReadinessRuleId,\n ReadinessRuleVersion\n} from \"./model.js\"\nimport { compareReadinessText, readinessDefinitionsShapeIsV1, readinessPolicyShapeIsV1 } from \"./policy.js\"\n\nconst unique = <Value>(values: ReadonlyArray<Value>): boolean => new Set(values).size === values.length\n\nconst CandidateMaterialBase = {\n workspaceId: WorkspaceId,\n releaseRevision: ReadinessReleaseRevision,\n artifactRevision: ReadinessArtifactRevision\n}\n\nconst readinessFactsAreValid = (input: {\n readonly definitions: ReadonlyArray<ReadinessFactDefinitionType>\n readonly observations: ReadonlyArray<ReadinessFactObservationType>\n}): boolean => {\n const definitionsById = new Map(input.definitions.map((definition) => [definition.factId, definition]))\n return unique(input.definitions.map(({ factId }) => factId)) &&\n unique(input.observations.map(({ factId }) => factId)) &&\n input.observations.every((observation) =>\n definitionsById.get(observation.factId)?.kind === observation.state._tag\n ) &&\n readinessPolicyShapeIsV1(input.definitions, input.observations) &&\n input.observations.reduce((total, observation) => total + observation.evidence.length, 0) <=\n MAX_READINESS_EVIDENCE_REFERENCES\n}\n\n/** Digest-free, complete material for one target-environment candidate. */\nexport const EnvironmentReadinessCandidateMaterial = Schema.Struct({\n ...CandidateMaterialBase,\n scope: Schema.TaggedStruct(\"environment\", {\n releaseId: ReleaseId,\n environmentId: EnvironmentId\n }),\n complete: Schema.Boolean,\n definitions: Schema.Array(ReadinessFactDefinition).check(Schema.isMaxLength(512)),\n observations: Schema.Array(ReadinessFactObservation).check(Schema.isMaxLength(512))\n}).check(\n Schema.makeFilter(readinessFactsAreValid, {\n expected: \"complete, unique, evidence-bounded V1 readiness candidate material\"\n })\n)\n\n/** Decoded environment candidate material before deterministic normalization. */\nexport type EnvironmentReadinessCandidateMaterial = typeof EnvironmentReadinessCandidateMaterial.Type\n\n/** Exact child assessment bound into a release-scope candidate. */\nexport const ReleaseReadinessChildMaterial = Schema.Struct({\n assessmentId: ReadinessAssessmentId,\n environmentId: EnvironmentId,\n candidateDigest: ReadinessCandidateDigest\n})\n\n/** Decoded release child material. */\nexport type ReleaseReadinessChildMaterial = typeof ReleaseReadinessChildMaterial.Type\n\n/** Digest-free material for one release candidate and its exact environment assessments. */\nexport const ReleaseReadinessCandidateMaterial = Schema.Struct({\n ...CandidateMaterialBase,\n scope: Schema.TaggedStruct(\"release\", { releaseId: ReleaseId }),\n environments: Schema.NonEmptyArray(ReleaseReadinessChildMaterial).check(Schema.isMaxLength(512))\n}).check(\n Schema.makeFilter(({ environments }) => unique(environments.map(({ environmentId }) => environmentId)), {\n expected: \"release candidate environment identities to be unique\"\n }),\n Schema.makeFilter(({ environments }) => unique(environments.map(({ assessmentId }) => assessmentId)), {\n expected: \"release candidate assessment identities to be unique\"\n })\n)\n\n/** Decoded release candidate material before deterministic normalization. */\nexport type ReleaseReadinessCandidateMaterial = typeof ReleaseReadinessCandidateMaterial.Type\n\n/** Digest-free immutable readiness-rule snapshot. */\nexport const ReadinessRuleMaterial = Schema.Struct({\n ruleId: ReadinessRuleId,\n version: ReadinessRuleVersion,\n definitions: Schema.Array(ReadinessFactDefinition).check(Schema.isNonEmpty(), Schema.isMaxLength(512))\n}).check(\n Schema.makeFilter(({ definitions }) => unique(definitions.map(({ factId }) => factId)), {\n expected: \"readiness rule fact identities to be unique\"\n }),\n Schema.makeFilter(({ definitions }) => readinessDefinitionsShapeIsV1(definitions), {\n expected: \"readiness rule material to contain the complete V1 policy shape\"\n })\n)\n\n/** Decoded rule material before deterministic normalization. */\nexport type ReadinessRuleMaterial = typeof ReadinessRuleMaterial.Type\n\nconst normalizeDefinitions = (\n definitions: ReadonlyArray<ReadinessFactDefinitionType>\n): Array<ReadinessFactDefinitionType> =>\n [...definitions].sort((left, right) => compareReadinessText(left.factId, right.factId))\n\nconst normalizeObservations = (\n observations: ReadonlyArray<ReadinessFactObservationType>\n): Array<ReadinessFactObservationType> =>\n observations\n .map((observation) => ({\n ...observation,\n evidence: [...observation.evidence].sort((left, right) => compareReadinessText(left.evidenceId, right.evidenceId))\n }))\n .sort((left, right) => compareReadinessText(left.factId, right.factId))\n\n/** Return the only JSON ordering accepted for environment-candidate hashing. */\nexport const normalizeEnvironmentReadinessCandidateMaterial = (\n material: EnvironmentReadinessCandidateMaterial\n): EnvironmentReadinessCandidateMaterial => ({\n ...material,\n definitions: normalizeDefinitions(material.definitions),\n observations: normalizeObservations(material.observations)\n})\n\n/** Return the only JSON ordering accepted for release-candidate hashing. */\nexport const normalizeReleaseReadinessCandidateMaterial = (\n material: ReleaseReadinessCandidateMaterial\n): ReleaseReadinessCandidateMaterial => {\n const [first, ...remaining] = material.environments\n const environments: [ReleaseReadinessChildMaterial, ...Array<ReleaseReadinessChildMaterial>] = [\n first,\n ...remaining\n ]\n environments.sort((left, right) => compareReadinessText(left.environmentId, right.environmentId))\n return { ...material, environments }\n}\n\n/** Return the only JSON ordering accepted for rule hashing. */\nexport const normalizeReadinessRuleMaterial = (\n material: ReadinessRuleMaterial\n): ReadinessRuleMaterial => ({\n ...material,\n definitions: normalizeDefinitions(material.definitions)\n})\n","import type {\n EnvironmentReadinessAssessment,\n ReleaseReadinessAssessment,\n ReleaseReadinessRollupInput\n} from \"./model.js\"\nimport {\n compareReadinessText,\n deriveReleaseReadinessFindings,\n deriveReleaseReadinessNextEvaluationAt,\n deriveReleaseReadinessSourceSummaries,\n deriveReleaseReadinessStages,\n deriveReleaseReadinessVerdict,\n sortedReadinessUnique\n} from \"./policy.js\"\n\n/** Exact compact projection retained when an environment is rolled into a release. */\nexport const summarizeEnvironmentReadiness = (\n assessment: EnvironmentReadinessAssessment\n): ReleaseReadinessAssessment[\"environments\"][number] => ({\n assessmentId: assessment.assessmentId,\n environmentId: assessment.candidate.scope.environmentId,\n candidateDigest: assessment.candidate.digest,\n inputComplete: assessment.inputComplete,\n facts: assessment.facts,\n nextEvaluationAt: assessment.nextEvaluationAt,\n verdict: assessment.verdict,\n stages: assessment.stages,\n blockers: assessment.blockers,\n warnings: assessment.warnings,\n gaps: assessment.gaps,\n sourceFreshness: assessment.sourceFreshness,\n evidenceIds: assessment.evidenceIds\n})\n\n/** Pure deterministic roll-up of current target-environment assessments. */\nexport const rollUpReleaseReadiness = (\n input: ReleaseReadinessRollupInput\n): ReleaseReadinessAssessment => {\n const environments = input.environments\n .slice()\n .sort((left, right) => {\n return compareReadinessText(\n left.candidate.scope.environmentId,\n right.candidate.scope.environmentId\n )\n })\n const first = environments.reduce((earliest, assessment) =>\n compareReadinessText(\n assessment.candidate.scope.environmentId,\n earliest.candidate.scope.environmentId\n ) < 0\n ? assessment\n : earliest, input.environments[0])\n const environmentSummaries: ReleaseReadinessAssessment[\"environments\"] = [\n summarizeEnvironmentReadiness(first),\n ...environments.filter((assessment) => assessment !== first).map(summarizeEnvironmentReadiness)\n ]\n const findings = deriveReleaseReadinessFindings(environmentSummaries)\n\n return {\n _tag: \"release\",\n assessmentId: input.assessmentId,\n previousAssessmentId: input.previousAssessmentId,\n candidate: input.candidate,\n rule: first.rule,\n derivationVersion: first.derivationVersion,\n evaluatedAt: input.evaluatedAt,\n nextEvaluationAt: deriveReleaseReadinessNextEvaluationAt(environmentSummaries),\n verdict: deriveReleaseReadinessVerdict(environmentSummaries),\n stages: deriveReleaseReadinessStages(environmentSummaries),\n environments: environmentSummaries,\n blockers: findings.blockers,\n warnings: findings.warnings,\n gaps: findings.gaps,\n sourceFreshness: deriveReleaseReadinessSourceSummaries(environmentSummaries),\n evidenceIds: sortedReadinessUnique(environments.flatMap(({ evidenceIds }) => evidenceIds))\n }\n}\n"],"mappings":";;;;;;;;;AAOA,IAAa,wBAAwB,OAAO,aAAa,UAAU,EACjE,UAAU,SACZ,CAAC;;AAMD,IAAa,uBAAuB,OAAO,OAAO;CAChD,aAAa;CACb,SAAS;CACT,QAAQ;CACR,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,WAAW;CACX,WAAW;CACX,WAAW,OAAO,OAAO,YAAY;AACvC,CAAC,CAAC,CAAC,MACD,OAAO,YACJ,EAAE,WAAW,gBAAgB,SAAS,MAAM,WAAW,SAAS,IAAI,GACrE,EAAE,UAAU,yCAAyC,CACvD,GACA,OAAO,YACJ,EAAE,WAAW,gBAAgB,cAAc,QAAQ,SAAS,MAAM,WAAW,SAAS,KAAK,GAC5F,EAAE,UAAU,mDAAmD,CACjE,CACF;;;ACrBA,IAAM,mBAAiB,MAAc,YACnC,OAAO,OAAO,MAAM,OAAO,UAAU,GAAG,OAAO,WAAW,GAAG,OAAO,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,IAAI,CAAC;;AAGnH,IAAa,gBAAgB,gBAAc,iBAAiB,GAAG;;AAM/D,IAAa,qBAAqB,gBAAc,sBAAsB,IAAK;;AAM3E,IAAa,qBAAqB,gBAAc,sBAAsB,IAAK;;AAM3E,IAAa,mBAAmB,gBAAc,oBAAoB,GAAG;AAKrE,IAAM,gBAAc,OAAO,OAAO,MAAM,OAAO,UAAU,GAAG,OAAO,WAAW,GAAG,OAAO,YAAY,GAAG,CAAC;AACxG,IAAM,0BAA0B;AAChC,IAAM,qCAAqC,IAAI,KAAK,KAAK,0BAA0B,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eACrB,MAAM,UAAU,MAAM,aACxB;CACF,CAAC;CACH,MAAM,QAAQ,aAAa,QAAQ,UAAU,eAC3C,qBACI,WAAW,UAAU,MAAM,eAC3B,SAAS,UAAU,MAAM,aAC3B,IAAI,IACF,aACA,UAAU,MAAM,aAAa,EAAE;CACrC,MAAM,uBAAmE,CACvE,8BAA8B,KAAK,GACnC,GAAG,aAAa,QAAQ,eAAe,eAAe,KAAK,CAAC,CAAC,IAAI,6BAA6B,CAChG;CACA,MAAM,WAAW,+BAA+B,oBAAoB;CAEpE,OAAO;EACL,MAAM;EACN,cAAc,MAAM;EACpB,sBAAsB,MAAM;EAC5B,WAAW,MAAM;EACjB,MAAM,MAAM;EACZ,mBAAmB,MAAM;EACzB,aAAa,MAAM;EACnB,kBAAkB,uCAAuC,oBAAoB;EAC7E,SAAS,8BAA8B,oBAAoB;EAC3D,QAAQ,6BAA6B,oBAAoB;EACzD,cAAc;EACd,UAAU,SAAS;EACnB,UAAU,SAAS;EACnB,MAAM,SAAS;EACf,iBAAiB,sCAAsC,oBAAoB;EAC3E,aAAa,sBAAsB,aAAa,SAAS,EAAE,kBAAkB,WAAW,CAAC;CAC3F;AACF"}
@@ -989,6 +989,7 @@
989
989
  "src/domain/release.ts",
990
990
  "src/domain/releaseRelay.ts",
991
991
  "src/domain/sourceRevision.ts",
992
+ "src/domain/utcTimestamp.ts",
992
993
  "src/server/persistence/Persistence.ts",
993
994
  "src/server/persistence/repositories/deliveryGraphRepository.ts",
994
995
  "src/server/application/pluginSynchronizationAuthority.ts",
@@ -162,6 +162,13 @@ export declare const DeliveryEntityDetails: Schema.toTaggedUnion<"_tag", readonl
162
162
  readonly targetBranch: Schema.String;
163
163
  readonly headRevision: Schema.String;
164
164
  readonly reviewState: Schema.Literals<readonly ["not-requested", "requested", "changes-requested", "approved", "merged"]>;
165
+ readonly lifecycle: Schema.optionalKey<Schema.NullOr<Schema.Literals<readonly ["open", "closed", "merged"]>>>;
166
+ readonly description: Schema.optionalKey<Schema.NullOr<Schema.String>>;
167
+ readonly authorReference: Schema.optionalKey<Schema.NullOr<Schema.String>>;
168
+ readonly baseRevision: Schema.optionalKey<Schema.NullOr<Schema.String>>;
169
+ readonly mergeBaseRevision: Schema.optionalKey<Schema.NullOr<Schema.String>>;
170
+ readonly createdAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
171
+ readonly updatedAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
165
172
  }>, Schema.TaggedStruct<"page", {
166
173
  readonly spaceKey: Schema.String;
167
174
  readonly revision: Schema.String;
@@ -337,6 +344,13 @@ export declare const DeliveryEntityProjection: Schema.Struct<{
337
344
  readonly targetBranch: Schema.String;
338
345
  readonly headRevision: Schema.String;
339
346
  readonly reviewState: Schema.Literals<readonly ["not-requested", "requested", "changes-requested", "approved", "merged"]>;
347
+ readonly lifecycle: Schema.optionalKey<Schema.NullOr<Schema.Literals<readonly ["open", "closed", "merged"]>>>;
348
+ readonly description: Schema.optionalKey<Schema.NullOr<Schema.String>>;
349
+ readonly authorReference: Schema.optionalKey<Schema.NullOr<Schema.String>>;
350
+ readonly baseRevision: Schema.optionalKey<Schema.NullOr<Schema.String>>;
351
+ readonly mergeBaseRevision: Schema.optionalKey<Schema.NullOr<Schema.String>>;
352
+ readonly createdAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
353
+ readonly updatedAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
340
354
  }>, Schema.TaggedStruct<"page", {
341
355
  readonly spaceKey: Schema.String;
342
356
  readonly revision: Schema.String;