@tearleads/client-sdk 0.1.63 → 0.1.64

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 (616) hide show
  1. package/data/documents/blob/shared/projection.js +1 -1
  2. package/data/documents/blob/shared/projection.js.map +1 -1
  3. package/data/documents/shared/projectionContentKeys.js +1 -1
  4. package/data/documents/shared/projectionContentKeys.js.map +1 -1
  5. package/data/documents/shared/syncResponseAuthorization.js +1 -1
  6. package/data/documents/shared/syncResponseAuthorization.js.map +1 -1
  7. package/data/keyingProjectionVerification/{accessManifestCheckpointEnforcement.js → checkpoints/accessManifestCheckpointEnforcement.js} +2 -2
  8. package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map +1 -0
  9. package/data/keyingProjectionVerification/{bundleVerification.js → checkpoints/bundleVerification.js} +5 -5
  10. package/data/keyingProjectionVerification/checkpoints/bundleVerification.js.map +1 -0
  11. package/data/keyingProjectionVerification/{checkpointContext.d.ts → checkpoints/checkpointContext.d.ts} +6 -6
  12. package/data/keyingProjectionVerification/{checkpointContext.js → checkpoints/checkpointContext.js} +6 -6
  13. package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -0
  14. package/data/keyingProjectionVerification/{manifestCheckpointVerification.js → checkpoints/manifestCheckpointVerification.js} +2 -2
  15. package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js.map +1 -0
  16. package/data/keyingProjectionVerification/{containerAncestorCitations.js → container/containerAncestorCitations.js} +4 -4
  17. package/data/keyingProjectionVerification/container/containerAncestorCitations.js.map +1 -0
  18. package/data/keyingProjectionVerification/{containerCreateManifest.js → container/containerCreateManifest.js} +1 -1
  19. package/data/keyingProjectionVerification/{containerDestinationVerification.js → container/containerDestinationVerification.js} +4 -4
  20. package/data/keyingProjectionVerification/container/containerDestinationVerification.js.map +1 -0
  21. package/data/keyingProjectionVerification/{containerManifestVerification.js → container/containerManifestVerification.js} +7 -7
  22. package/data/keyingProjectionVerification/container/containerManifestVerification.js.map +1 -0
  23. package/data/keyingProjectionVerification/{containerPathVerification.js → container/containerPathVerification.js} +2 -2
  24. package/data/keyingProjectionVerification/container/containerPathVerification.js.map +1 -0
  25. package/data/keyingProjectionVerification/{containerProjectionVerification.d.ts → container/containerProjectionVerification.d.ts} +7 -7
  26. package/data/keyingProjectionVerification/{containerProjectionVerification.js → container/containerProjectionVerification.js} +9 -9
  27. package/data/keyingProjectionVerification/container/containerProjectionVerification.js.map +1 -0
  28. package/data/keyingProjectionVerification/{documentDependencyPaths.d.ts → document/documentDependencyPaths.d.ts} +1 -1
  29. package/data/keyingProjectionVerification/{documentDependencyPaths.js → document/documentDependencyPaths.js} +3 -3
  30. package/data/keyingProjectionVerification/document/documentDependencyPaths.js.map +1 -0
  31. package/data/keyingProjectionVerification/{documentManifestPolicies.js → document/documentManifestPolicies.js} +2 -2
  32. package/data/keyingProjectionVerification/document/documentManifestPolicies.js.map +1 -0
  33. package/data/keyingProjectionVerification/{documentManifestPredecessor.js → document/documentManifestPredecessor.js} +1 -1
  34. package/data/keyingProjectionVerification/{documentManifestVerification.js → document/documentManifestVerification.js} +5 -5
  35. package/data/keyingProjectionVerification/document/documentManifestVerification.js.map +1 -0
  36. package/data/keyingProjectionVerification/{documentProjectionVerification.d.ts → document/documentProjectionVerification.d.ts} +4 -4
  37. package/data/keyingProjectionVerification/{documentProjectionVerification.js → document/documentProjectionVerification.js} +9 -9
  38. package/data/keyingProjectionVerification/document/documentProjectionVerification.js.map +1 -0
  39. package/data/keyingProjectionVerification/{documentPurgeCheckpointCurrency.js → documentPurge/documentPurgeCheckpointCurrency.js} +12 -12
  40. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js.map +1 -0
  41. package/data/keyingProjectionVerification/{documentPurgeCheckpointEnforcement.js → documentPurge/documentPurgeCheckpointEnforcement.js} +2 -2
  42. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js.map +1 -0
  43. package/data/keyingProjectionVerification/{documentPurgeDocumentChainVerification.js → documentPurge/documentPurgeDocumentChainVerification.js} +8 -8
  44. package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js.map +1 -0
  45. package/data/keyingProjectionVerification/{documentPurgePolicyCheckpoints.js → documentPurge/documentPurgePolicyCheckpoints.js} +2 -2
  46. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js.map +1 -0
  47. package/data/keyingProjectionVerification/{documentPurgePolicyCurrency.js → documentPurge/documentPurgePolicyCurrency.js} +4 -4
  48. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js.map +1 -0
  49. package/data/keyingProjectionVerification/{documentPurgePrincipalEvidence.js → documentPurge/documentPurgePrincipalEvidence.js} +3 -3
  50. package/data/keyingProjectionVerification/documentPurge/documentPurgePrincipalEvidence.js.map +1 -0
  51. package/data/keyingProjectionVerification/{documentPurgeProofVerification.d.ts → documentPurge/documentPurgeProofVerification.d.ts} +5 -5
  52. package/data/keyingProjectionVerification/{documentPurgeProofVerification.js → documentPurge/documentPurgeProofVerification.js} +10 -10
  53. package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.js.map +1 -0
  54. package/data/keyingProjectionVerification/index.d.ts +4 -4
  55. package/data/keyingProjectionVerification/index.js +4 -4
  56. package/data/keyingProjectionVerification/index.js.map +1 -1
  57. package/data/keyingProjectionVerification/{mergeProjectionPolicyEvidence.js → principalPolicy/mergeProjectionPolicyEvidence.js} +2 -2
  58. package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -0
  59. package/data/keyingProjectionVerification/{organizationFounderBinding.js → principalPolicy/organizationFounderBinding.js} +3 -3
  60. package/data/keyingProjectionVerification/principalPolicy/organizationFounderBinding.js.map +1 -0
  61. package/data/keyingProjectionVerification/{principalPolicyCache.js → principalPolicy/principalPolicyCache.js} +6 -6
  62. package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js.map +1 -0
  63. package/data/keyingProjectionVerification/{principalPolicyVerification.js → principalPolicy/principalPolicyVerification.js} +12 -12
  64. package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js.map +1 -0
  65. package/data/keyingProjectionVerification/{projectionAuthorizationEvidence.js → principalPolicy/projectionAuthorizationEvidence.js} +3 -3
  66. package/data/keyingProjectionVerification/principalPolicy/projectionAuthorizationEvidence.js.map +1 -0
  67. package/data/keyingProjectionVerification/{projectionPolicyEvidence.js → principalPolicy/projectionPolicyEvidence.js} +3 -3
  68. package/data/keyingProjectionVerification/principalPolicy/projectionPolicyEvidence.js.map +1 -0
  69. package/data/keyingProjectionVerification/{resolvedPrincipalPolicy.js → principalPolicy/resolvedPrincipalPolicy.js} +6 -6
  70. package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js.map +1 -0
  71. package/package.json +1 -1
  72. package/stores/container-contents/accessRestorationSweep.js +1 -1
  73. package/stores/container-contents/accessRestorationSweep.js.map +1 -1
  74. package/stores/container-contents/containerContentsStore.d.ts +1 -1
  75. package/stores/container-contents/containerContentsStore.js +12 -12
  76. package/stores/container-contents/containerContentsStore.js.map +1 -1
  77. package/stores/container-contents/containerState/containerStateMap.js.map +1 -0
  78. package/stores/container-contents/{containerStatePersistence.js → containerState/containerStatePersistence.js} +2 -2
  79. package/stores/container-contents/containerState/containerStatePersistence.js.map +1 -0
  80. package/stores/container-contents/{missingContainerState.js → containerState/missingContainerState.js} +1 -1
  81. package/stores/container-contents/containerState/missingContainerState.js.map +1 -0
  82. package/stores/container-contents/containerState/missingSyncedContainerState.js.map +1 -0
  83. package/stores/container-contents/{reconcilableContainer.d.ts → containerState/reconcilableContainer.d.ts} +1 -1
  84. package/stores/container-contents/containerState/reconcilableContainer.js.map +1 -0
  85. package/stores/container-contents/{documentRecovery.js → documentWork/documentRecovery.js} +6 -6
  86. package/stores/container-contents/documentWork/documentRecovery.js.map +1 -0
  87. package/stores/container-contents/{documentRotation.js → documentWork/documentRotation.js} +2 -2
  88. package/stores/container-contents/documentWork/documentRotation.js.map +1 -0
  89. package/stores/container-contents/{documentWork.js → documentWork/index.js} +1 -1
  90. package/stores/container-contents/documentWork/index.js.map +1 -0
  91. package/stores/container-contents/{backgroundHydration.js → hydration/backgroundHydration.js} +3 -3
  92. package/stores/container-contents/hydration/backgroundHydration.js.map +1 -0
  93. package/stores/container-contents/{remoteHydrationRequest.js → hydration/remoteHydrationRequest.js} +3 -3
  94. package/stores/container-contents/hydration/remoteHydrationRequest.js.map +1 -0
  95. package/stores/container-contents/{startupHydration.js → hydration/startupHydration.js} +3 -3
  96. package/stores/container-contents/hydration/startupHydration.js.map +1 -0
  97. package/stores/container-contents/index.d.ts +3 -3
  98. package/stores/container-contents/index.js +2 -2
  99. package/stores/container-contents/index.js.map +1 -1
  100. package/stores/container-contents/localRefresh.js +2 -2
  101. package/stores/container-contents/localRefresh.js.map +1 -1
  102. package/stores/container-contents/{containerPurgeCore.js → operations/containerPurgeCore.js} +4 -4
  103. package/stores/container-contents/operations/containerPurgeCore.js.map +1 -0
  104. package/stores/container-contents/operations/emptyTrashOperation.js.map +1 -0
  105. package/stores/container-contents/{groupRewrapOperation.js → operations/groupRewrapOperation.js} +2 -2
  106. package/stores/container-contents/operations/groupRewrapOperation.js.map +1 -0
  107. package/stores/container-contents/{operations.js → operations/index.js} +18 -18
  108. package/stores/container-contents/operations/index.js.map +1 -0
  109. package/stores/container-contents/operations/purgeContainerOperation.js.map +1 -0
  110. package/stores/container-contents/{reportShareFailure.js → operations/reportShareFailure.js} +4 -4
  111. package/stores/container-contents/operations/reportShareFailure.js.map +1 -0
  112. package/stores/container-contents/{setContainerIconOperation.js → operations/setContainerIconOperation.js} +6 -6
  113. package/stores/container-contents/operations/setContainerIconOperation.js.map +1 -0
  114. package/stores/container-contents/{shareOperations.js → operations/shareOperations.js} +6 -6
  115. package/stores/container-contents/operations/shareOperations.js.map +1 -0
  116. package/stores/container-contents/remoteEvents/remoteBackedContainerState.js.map +1 -0
  117. package/stores/container-contents/{remoteContainerIngestion.js → remoteEvents/remoteContainerIngestion.js} +4 -4
  118. package/stores/container-contents/remoteEvents/remoteContainerIngestion.js.map +1 -0
  119. package/stores/container-contents/{remoteEventProjectionInvalidation.js → remoteEvents/remoteEventProjectionInvalidation.js} +1 -1
  120. package/stores/container-contents/remoteEvents/remoteEventProjectionInvalidation.js.map +1 -0
  121. package/stores/container-contents/{remoteEventSync.js → remoteEvents/remoteEventSync.js} +4 -4
  122. package/stores/container-contents/remoteEvents/remoteEventSync.js.map +1 -0
  123. package/stores/container-contents/{remoteWriteGuards.js → remoteWrites/remoteWriteGuards.js} +2 -2
  124. package/stores/container-contents/remoteWrites/remoteWriteGuards.js.map +1 -0
  125. package/stores/container-contents/{remoteWriteQueue.js → remoteWrites/remoteWriteQueue.js} +1 -1
  126. package/stores/container-contents/remoteWrites/remoteWriteQueue.js.map +1 -0
  127. package/stores/container-contents/remoteWrites/writeGeneration.js.map +1 -0
  128. package/stores/container-contents/state.d.ts +1 -1
  129. package/stores/container-contents/state.js +2 -2
  130. package/stores/container-contents/state.js.map +1 -1
  131. package/stores/container-contents/{syncAgent.d.ts → syncAgent/index.d.ts} +2 -2
  132. package/stores/container-contents/{syncAgent.js → syncAgent/index.js} +14 -14
  133. package/stores/container-contents/syncAgent/index.js.map +1 -0
  134. package/stores/container-contents/{metadataSyncSignal.js → syncAgent/metadataSyncSignal.js} +1 -1
  135. package/stores/container-contents/{metadataSyncSignal.js.map → syncAgent/metadataSyncSignal.js.map} +1 -1
  136. package/stores/container-contents/{syncAgentTypes.d.ts → syncAgent/syncAgentTypes.d.ts} +5 -5
  137. package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -0
  138. package/stores/container-contents/{syncLaneIteration.js → syncAgent/syncLaneIteration.js} +11 -11
  139. package/stores/container-contents/syncAgent/syncLaneIteration.js.map +1 -0
  140. package/stores/container-contents/{existingSystemContainer.js → systemContainers/existingSystemContainer.js} +4 -4
  141. package/stores/container-contents/systemContainers/existingSystemContainer.js.map +1 -0
  142. package/stores/container-contents/{organizationMetadataSystemContainer.js → systemContainers/organizationMetadataSystemContainer.js} +2 -2
  143. package/stores/container-contents/systemContainers/organizationMetadataSystemContainer.js.map +1 -0
  144. package/stores/container-contents/{systemContainerHydration.js → systemContainers/systemContainerHydration.js} +3 -3
  145. package/stores/container-contents/systemContainers/systemContainerHydration.js.map +1 -0
  146. package/stores/container-contents/{systemContainerIcon.js → systemContainers/systemContainerIcon.js} +5 -5
  147. package/stores/container-contents/systemContainers/systemContainerIcon.js.map +1 -0
  148. package/stores/container-contents/systemContainers/systemContainerLookup.js.map +1 -0
  149. package/stores/container-contents/{systemContainerPostCreate.js → systemContainers/systemContainerPostCreate.js} +2 -2
  150. package/stores/container-contents/systemContainers/systemContainerPostCreate.js.map +1 -0
  151. package/stores/container-contents/{systemContainerPromotion.js → systemContainers/systemContainerPromotion.js} +1 -1
  152. package/stores/container-contents/systemContainers/systemContainerPromotion.js.map +1 -0
  153. package/stores/container-contents/types.d.ts +2 -2
  154. package/stores/container-contents/types.js.map +1 -1
  155. package/stores/documents/documentStore/{attachmentSourceUpload.js → attachmentUpload/attachmentSourceUpload.js} +4 -4
  156. package/stores/documents/documentStore/attachmentUpload/attachmentSourceUpload.js.map +1 -0
  157. package/stores/documents/documentStore/{attachmentStaging.js → attachmentUpload/attachmentStaging.js} +5 -5
  158. package/stores/documents/documentStore/attachmentUpload/attachmentStaging.js.map +1 -0
  159. package/stores/documents/documentStore/{attachmentUploadAttempt.js → attachmentUpload/attachmentUploadAttempt.js} +2 -2
  160. package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js.map +1 -0
  161. package/stores/documents/documentStore/{attachmentUploadLane.js → attachmentUpload/attachmentUploadLane.js} +1 -1
  162. package/stores/documents/documentStore/attachmentUpload/attachmentUploadLane.js.map +1 -0
  163. package/stores/documents/documentStore/{attachmentUploadResume.js → attachmentUpload/attachmentUploadResume.js} +4 -4
  164. package/stores/documents/documentStore/attachmentUpload/attachmentUploadResume.js.map +1 -0
  165. package/stores/documents/documentStore/{attachmentDetachState.js → attachments/attachmentDetachState.js} +1 -1
  166. package/stores/documents/documentStore/attachments/attachmentDetachState.js.map +1 -0
  167. package/stores/documents/documentStore/{attachmentHydration.js → attachments/attachmentHydration.js} +5 -5
  168. package/stores/documents/documentStore/attachments/attachmentHydration.js.map +1 -0
  169. package/stores/documents/documentStore/{attachmentHydrationCommit.js → attachments/attachmentHydrationCommit.js} +3 -3
  170. package/stores/documents/documentStore/attachments/attachmentHydrationCommit.js.map +1 -0
  171. package/stores/documents/documentStore/{attachmentIntents.js → attachments/attachmentIntents.js} +2 -2
  172. package/stores/documents/documentStore/attachments/attachmentIntents.js.map +1 -0
  173. package/stores/documents/documentStore/{attachmentMutationPersistence.js → attachments/attachmentMutationPersistence.js} +4 -4
  174. package/stores/documents/documentStore/attachments/attachmentMutationPersistence.js.map +1 -0
  175. package/stores/documents/documentStore/attachments/attachmentPersistFollowup.js.map +1 -0
  176. package/stores/documents/documentStore/{attachmentPersistence.js → attachments/attachmentPersistence.js} +4 -4
  177. package/stores/documents/documentStore/attachments/attachmentPersistence.js.map +1 -0
  178. package/stores/documents/documentStore/{attachmentRemoval.js → attachments/attachmentRemoval.js} +11 -11
  179. package/stores/documents/documentStore/attachments/attachmentRemoval.js.map +1 -0
  180. package/stores/documents/documentStore/attachments/attachmentSnapshot.js.map +1 -0
  181. package/stores/documents/documentStore/{attachmentWriteGeneration.js → attachments/attachmentWriteGeneration.js} +2 -2
  182. package/stores/documents/documentStore/attachments/attachmentWriteGeneration.js.map +1 -0
  183. package/stores/documents/documentStore/{attachments.js → attachments/index.js} +11 -11
  184. package/stores/documents/documentStore/attachments/index.js.map +1 -0
  185. package/stores/documents/documentStore/{documentHistoryCompaction.js → history/documentHistoryCompaction.js} +4 -4
  186. package/stores/documents/documentStore/history/documentHistoryCompaction.js.map +1 -0
  187. package/stores/documents/documentStore/{durableDocumentReload.js → history/durableDocumentReload.js} +6 -6
  188. package/stores/documents/documentStore/history/durableDocumentReload.js.map +1 -0
  189. package/stores/documents/documentStore/{historyRebuild.js → history/historyRebuild.js} +6 -6
  190. package/stores/documents/documentStore/history/historyRebuild.js.map +1 -0
  191. package/stores/documents/{documentStore.d.ts → documentStore/index.d.ts} +5 -5
  192. package/stores/documents/{documentStore.js → documentStore/index.js} +18 -18
  193. package/stores/documents/documentStore/index.js.map +1 -0
  194. package/stores/documents/documentStore/{deferredInitialUpdate.js → initialization/deferredInitialUpdate.js} +9 -9
  195. package/stores/documents/documentStore/initialization/deferredInitialUpdate.js.map +1 -0
  196. package/stores/documents/documentStore/{initialization.js → initialization/index.js} +14 -14
  197. package/stores/documents/documentStore/initialization/index.js.map +1 -0
  198. package/stores/documents/documentStore/{initializationAttachments.js → initialization/initializationAttachments.js} +1 -1
  199. package/stores/documents/documentStore/initialization/initializationAttachments.js.map +1 -0
  200. package/stores/documents/documentStore/{initializationHistory.js → initialization/initializationHistory.js} +3 -3
  201. package/stores/documents/documentStore/initialization/initializationHistory.js.map +1 -0
  202. package/stores/documents/documentStore/{initializationRecovery.js → initialization/initializationRecovery.js} +7 -7
  203. package/stores/documents/documentStore/initialization/initializationRecovery.js.map +1 -0
  204. package/stores/documents/documentStore/mutationIdentityRevalidation.js.map +1 -1
  205. package/stores/documents/documentStore/mutations.js +2 -2
  206. package/stores/documents/documentStore/mutations.js.map +1 -1
  207. package/stores/documents/documentStore/pendingUpdateRefusal.js +1 -1
  208. package/stores/documents/documentStore/pendingUpdateRefusal.js.map +1 -1
  209. package/stores/documents/documentStore/persistence.js +3 -3
  210. package/stores/documents/documentStore/persistence.js.map +1 -1
  211. package/stores/documents/documentStore/{rotation.js → rotation/index.js} +14 -14
  212. package/stores/documents/documentStore/rotation/index.js.map +1 -0
  213. package/stores/documents/documentStore/{rotationProvenance.js → rotation/rotationProvenance.js} +2 -2
  214. package/stores/documents/documentStore/rotation/rotationProvenance.js.map +1 -0
  215. package/stores/documents/documentStore/{rotationSettlement.js → rotation/rotationSettlement.js} +9 -9
  216. package/stores/documents/documentStore/rotation/rotationSettlement.js.map +1 -0
  217. package/stores/documents/documentStore/rows.js +2 -2
  218. package/stores/documents/documentStore/rows.js.map +1 -1
  219. package/stores/documents/documentStore/state.js +1 -1
  220. package/stores/documents/documentStore/state.js.map +1 -1
  221. package/stores/documents/documentStore/{sync.js → sync/index.js} +7 -7
  222. package/stores/documents/documentStore/sync/index.js.map +1 -0
  223. package/stores/documents/documentStore/{pullContinuationInvalidation.js → sync/pullContinuationInvalidation.js} +3 -3
  224. package/stores/documents/documentStore/sync/pullContinuationInvalidation.js.map +1 -0
  225. package/stores/documents/documentStore/{remoteRevalidationTelemetry.js → sync/remoteRevalidationTelemetry.js} +1 -1
  226. package/stores/documents/documentStore/sync/remoteRevalidationTelemetry.js.map +1 -0
  227. package/stores/documents/documentStore/sync/remoteWork.js.map +1 -0
  228. package/stores/documents/documentStore/sync/syncAcceptedUpdateIds.js.map +1 -0
  229. package/stores/documents/documentStore/{syncAttachmentSettlement.js → sync/syncAttachmentSettlement.js} +3 -3
  230. package/stores/documents/documentStore/sync/syncAttachmentSettlement.js.map +1 -0
  231. package/stores/documents/documentStore/{syncAttachments.js → sync/syncAttachments.js} +7 -7
  232. package/stores/documents/documentStore/sync/syncAttachments.js.map +1 -0
  233. package/stores/documents/documentStore/{syncDetachedAttachments.js → sync/syncDetachedAttachments.js} +7 -7
  234. package/stores/documents/documentStore/sync/syncDetachedAttachments.js.map +1 -0
  235. package/stores/documents/documentStore/{syncFinalize.js → sync/syncFinalize.js} +9 -9
  236. package/stores/documents/documentStore/sync/syncFinalize.js.map +1 -0
  237. package/stores/documents/documentStore/sync/syncGeneration.js.map +1 -0
  238. package/stores/documents/documentStore/{syncOutgoingCoverage.js → sync/syncOutgoingCoverage.js} +4 -4
  239. package/stores/documents/documentStore/sync/syncOutgoingCoverage.js.map +1 -0
  240. package/stores/documents/documentStore/{syncRemoteSignals.js → sync/syncRemoteSignals.js} +4 -4
  241. package/stores/documents/documentStore/sync/syncRemoteSignals.js.map +1 -0
  242. package/stores/documents/documentStore/{syncRequest.js → sync/syncRequest.js} +8 -8
  243. package/stores/documents/documentStore/sync/syncRequest.js.map +1 -0
  244. package/stores/documents/documentStore/{syncShared.js → sync/syncShared.js} +8 -8
  245. package/stores/documents/documentStore/sync/syncShared.js.map +1 -0
  246. package/stores/documents/documentStore/{syncUpdateImport.js → sync/syncUpdateImport.js} +3 -3
  247. package/stores/documents/documentStore/sync/syncUpdateImport.js.map +1 -0
  248. package/stores/documents/documentStore/{versionCoverage.js → sync/versionCoverage.js} +1 -1
  249. package/stores/documents/index.d.ts +1 -1
  250. package/stores/documents/index.js +1 -1
  251. package/stores/local-projection/localProjectionStore.d.ts +1 -1
  252. package/stores/local-projection/localProjectionStore.js +1 -1
  253. package/stores/local-projection/localProjectionStore.js.map +1 -1
  254. package/stores/local-projection/registry.d.ts +1 -1
  255. package/stores/local-projection/types.d.ts +1 -1
  256. package/workflows/blobs/hydration/decrypt.js +1 -1
  257. package/workflows/blobs/hydration/decrypt.js.map +1 -1
  258. package/workflows/container-contents/container-state/{createAdoption.js → create/createAdoption.js} +6 -6
  259. package/workflows/container-contents/container-state/create/createAdoption.js.map +1 -0
  260. package/workflows/container-contents/container-state/{createChild.js → create/createChild.js} +7 -7
  261. package/workflows/container-contents/container-state/create/createChild.js.map +1 -0
  262. package/workflows/container-contents/container-state/{createIntentDepth.js → create/createIntentDepth.js} +2 -2
  263. package/workflows/container-contents/container-state/create/createIntentDepth.js.map +1 -0
  264. package/workflows/container-contents/container-state/create/createIntentSettlement.js.map +1 -0
  265. package/workflows/container-contents/container-state/{createIntentSync.js → create/createIntentSync.js} +7 -7
  266. package/workflows/container-contents/container-state/create/createIntentSync.js.map +1 -0
  267. package/workflows/container-contents/container-state/{createTerminalFailure.js → create/createTerminalFailure.js} +2 -2
  268. package/workflows/container-contents/container-state/create/createTerminalFailure.js.map +1 -0
  269. package/workflows/container-contents/container-state/{createWithMetadata.js → create/createWithMetadata.js} +9 -9
  270. package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -0
  271. package/workflows/container-contents/container-state/{createWithMetadataPlan.js → create/createWithMetadataPlan.js} +4 -4
  272. package/workflows/container-contents/container-state/create/createWithMetadataPlan.js.map +1 -0
  273. package/workflows/container-contents/container-state/{localPurgeScope.js → purge/localPurgeScope.js} +1 -1
  274. package/workflows/container-contents/container-state/purge/localPurgeScope.js.map +1 -0
  275. package/workflows/container-contents/container-state/{purgeTree.js → purge/purgeTree.js} +5 -5
  276. package/workflows/container-contents/container-state/purge/purgeTree.js.map +1 -0
  277. package/workflows/container-contents/container-state/purge/purgeTreeCollection.js.map +1 -0
  278. package/workflows/container-contents/container-state/{purgeTreeContainerDeletion.js → purge/purgeTreeContainerDeletion.js} +1 -1
  279. package/workflows/container-contents/container-state/purge/purgeTreeContainerDeletion.js.map +1 -0
  280. package/workflows/container-contents/container-state/{purgeTreeScope.js → purge/purgeTreeScope.js} +8 -8
  281. package/workflows/container-contents/container-state/purge/purgeTreeScope.js.map +1 -0
  282. package/workflows/container-contents/container-state/{readLocalPurgeScope.js → purge/readLocalPurgeScope.js} +3 -3
  283. package/workflows/container-contents/container-state/purge/readLocalPurgeScope.js.map +1 -0
  284. package/workflows/container-contents/container-state/remote.js +2 -2
  285. package/workflows/container-contents/container-state/remote.js.map +1 -1
  286. package/workflows/container-contents/container-state/{groupGrantVerification.js → share/groupGrantVerification.js} +8 -8
  287. package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -0
  288. package/workflows/container-contents/container-state/{groupShareEpoch.js → share/groupShareEpoch.js} +2 -2
  289. package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -0
  290. package/workflows/container-contents/container-state/{share.js → share/index.js} +8 -8
  291. package/workflows/container-contents/container-state/share/index.js.map +1 -0
  292. package/workflows/container-contents/container-state/{sharePersistence.js → share/sharePersistence.js} +3 -3
  293. package/workflows/container-contents/container-state/share/sharePersistence.js.map +1 -0
  294. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js +1 -1
  295. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js.map +1 -1
  296. package/workflows/container-contents/documentDiscovery/index.js +1 -1
  297. package/workflows/container-contents/documentDiscovery/index.js.map +1 -1
  298. package/workflows/container-contents/metadata/metadataSyncErrors.js +1 -1
  299. package/workflows/container-contents/metadata/metadataSyncErrors.js.map +1 -1
  300. package/workflows/container-contents/remoteHydration/destination/destinationPrefetch.js.map +1 -0
  301. package/workflows/container-contents/remoteHydration/destination/destinationRoleCache.js.map +1 -0
  302. package/workflows/container-contents/remoteHydration/{destinationRootReload.js → destination/destinationRootReload.js} +1 -1
  303. package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js.map +1 -0
  304. package/workflows/container-contents/remoteHydration/{replacementBinding.js → destination/replacementBinding.js} +5 -5
  305. package/workflows/container-contents/remoteHydration/destination/replacementBinding.js.map +1 -0
  306. package/workflows/container-contents/remoteHydration/{verifiedDestination.js → destination/verifiedDestination.js} +9 -9
  307. package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -0
  308. package/workflows/container-contents/remoteHydration/index.js +4 -4
  309. package/workflows/container-contents/remoteHydration/index.js.map +1 -1
  310. package/workflows/container-contents/remoteHydration/lanes/childIndex.js.map +1 -0
  311. package/workflows/container-contents/remoteHydration/{laneFetchMarkers.js → lanes/laneFetchMarkers.js} +1 -1
  312. package/workflows/container-contents/remoteHydration/lanes/laneFetchMarkers.js.map +1 -0
  313. package/workflows/container-contents/remoteHydration/{parentLaneFetch.js → lanes/parentLaneFetch.js} +2 -2
  314. package/workflows/container-contents/remoteHydration/lanes/parentLaneFetch.js.map +1 -0
  315. package/workflows/container-contents/remoteHydration/lanes/parentLaneQueue.js.map +1 -0
  316. package/workflows/container-contents/remoteHydration/principalPolicyCache.js +1 -1
  317. package/workflows/container-contents/remoteHydration/principalPolicyCache.js.map +1 -1
  318. package/workflows/container-contents/remoteHydration/reconciliation.js +2 -2
  319. package/workflows/container-contents/remoteHydration/reconciliation.js.map +1 -1
  320. package/workflows/container-contents/remoteHydration/remoteContainers/containerStateFingerprint.js.map +1 -0
  321. package/workflows/container-contents/remoteHydration/{insertRemoteContainer.js → remoteContainers/insertRemoteContainer.js} +6 -6
  322. package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js.map +1 -0
  323. package/workflows/container-contents/remoteHydration/{remoteContainerPageHydration.js → remoteContainers/remoteContainerPageHydration.js} +7 -7
  324. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerPageHydration.js.map +1 -0
  325. package/workflows/container-contents/remoteHydration/{remoteContainerState.js → remoteContainers/remoteContainerState.js} +9 -9
  326. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -0
  327. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerTimestamps.js.map +1 -0
  328. package/workflows/container-contents/remoteHydration/tombstoneApplication.js +2 -2
  329. package/workflows/container-contents/remoteHydration/tombstoneApplication.js.map +1 -1
  330. package/workflows/containers/child/{createProjection.d.ts → create/createProjection.d.ts} +2 -2
  331. package/workflows/containers/child/{createProjection.js → create/createProjection.js} +2 -2
  332. package/workflows/containers/child/create/createProjection.js.map +1 -0
  333. package/workflows/containers/child/{createSubmission.d.ts → create/createSubmission.d.ts} +7 -7
  334. package/workflows/containers/child/{createSubmission.js → create/createSubmission.js} +2 -2
  335. package/workflows/containers/child/create/createSubmission.js.map +1 -0
  336. package/workflows/containers/child/{create.d.ts → create/index.d.ts} +5 -5
  337. package/workflows/containers/child/{create.js → create/index.js} +15 -15
  338. package/workflows/containers/child/create/index.js.map +1 -0
  339. package/workflows/containers/child/{move.d.ts → move/index.d.ts} +5 -5
  340. package/workflows/containers/child/{move.js → move/index.js} +12 -12
  341. package/workflows/containers/child/move/index.js.map +1 -0
  342. package/workflows/containers/child/{moveArtifacts.js → move/moveArtifacts.js} +3 -3
  343. package/workflows/containers/child/move/moveArtifacts.js.map +1 -0
  344. package/workflows/containers/child/{moveRotation.js → move/moveRotation.js} +3 -3
  345. package/workflows/containers/child/move/moveRotation.js.map +1 -0
  346. package/workflows/containers/child/{moveWraps.js → move/moveWraps.js} +5 -5
  347. package/workflows/containers/child/move/moveWraps.js.map +1 -0
  348. package/workflows/containers/child/mutationSubmit.js +1 -1
  349. package/workflows/containers/child/mutationSubmit.js.map +1 -1
  350. package/workflows/containers/child/{carriedDescendantRekeys.js → rekey/carriedDescendantRekeys.js} +4 -4
  351. package/workflows/containers/child/rekey/carriedDescendantRekeys.js.map +1 -0
  352. package/workflows/containers/child/{rekey.d.ts → rekey/index.d.ts} +6 -6
  353. package/workflows/containers/child/{rekey.js → rekey/index.js} +13 -13
  354. package/workflows/containers/child/rekey/index.js.map +1 -0
  355. package/workflows/containers/child/{keyringOverrideLineage.d.ts → rekey/keyringOverrideLineage.d.ts} +1 -1
  356. package/workflows/containers/child/{keyringOverrideLineage.js → rekey/keyringOverrideLineage.js} +1 -1
  357. package/workflows/containers/child/{rekeyProjection.d.ts → rekey/rekeyProjection.d.ts} +2 -2
  358. package/workflows/containers/child/{rekeyProjection.js → rekey/rekeyProjection.js} +3 -3
  359. package/workflows/containers/child/rekey/rekeyProjection.js.map +1 -0
  360. package/workflows/containers/child/{rekeyRemote.d.ts → rekey/rekeyRemote.d.ts} +6 -6
  361. package/workflows/containers/child/{rekeyRemote.js → rekey/rekeyRemote.js} +2 -2
  362. package/workflows/containers/child/rekey/rekeyRemote.js.map +1 -0
  363. package/workflows/containers/child/revoke.js +5 -5
  364. package/workflows/containers/child/revoke.js.map +1 -1
  365. package/workflows/containers/child/{replacementPrincipalPolicyReferences.js → rotation/replacementPrincipalPolicyReferences.js} +2 -2
  366. package/workflows/containers/child/rotation/replacementPrincipalPolicyReferences.js.map +1 -0
  367. package/workflows/containers/child/{rotationContext.js → rotation/rotationContext.js} +5 -5
  368. package/workflows/containers/child/rotation/rotationContext.js.map +1 -0
  369. package/workflows/containers/child/{rotationPrincipalPolicies.js → rotation/rotationPrincipalPolicies.js} +2 -2
  370. package/workflows/containers/child/rotation/rotationPrincipalPolicies.js.map +1 -0
  371. package/workflows/containers/child/{rotationWraps.js → rotation/rotationWraps.js} +1 -1
  372. package/workflows/containers/child/rotation/rotationWraps.js.map +1 -0
  373. package/workflows/containers/child/{currentShareGrantMutation.js → share/currentShareGrantMutation.js} +6 -6
  374. package/workflows/containers/child/share/currentShareGrantMutation.js.map +1 -0
  375. package/workflows/containers/child/{currentSharePrincipalPolicy.js → share/currentSharePrincipalPolicy.js} +10 -10
  376. package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +1 -0
  377. package/workflows/containers/child/{share.d.ts → share/index.d.ts} +8 -8
  378. package/workflows/containers/child/{share.js → share/index.js} +10 -10
  379. package/workflows/containers/child/share/index.js.map +1 -0
  380. package/workflows/containers/child/{runtimeCurrentGroupShare.js → share/runtimeCurrentGroupShare.js} +6 -6
  381. package/workflows/containers/child/share/runtimeCurrentGroupShare.js.map +1 -0
  382. package/workflows/containers/child/{shareAncestorRepair.js → share/shareAncestorRepair.js} +4 -4
  383. package/workflows/containers/child/share/shareAncestorRepair.js.map +1 -0
  384. package/workflows/containers/child/{shareMaterialization.d.ts → share/shareMaterialization.d.ts} +5 -5
  385. package/workflows/containers/child/{shareMaterialization.js → share/shareMaterialization.js} +7 -7
  386. package/workflows/containers/child/share/shareMaterialization.js.map +1 -0
  387. package/workflows/containers/child/{sharePlanCore.d.ts → share/sharePlanCore.d.ts} +7 -7
  388. package/workflows/containers/child/{sharePlanCore.js → share/sharePlanCore.js} +6 -6
  389. package/workflows/containers/child/share/sharePlanCore.js.map +1 -0
  390. package/workflows/containers/child/{sharePrincipalPolicy.d.ts → share/sharePrincipalPolicy.d.ts} +9 -9
  391. package/workflows/containers/child/{sharePrincipalPolicy.js → share/sharePrincipalPolicy.js} +13 -13
  392. package/workflows/containers/child/share/sharePrincipalPolicy.js.map +1 -0
  393. package/workflows/containers/child/share/shareProjection.js.map +1 -0
  394. package/workflows/containers/index.d.ts +10 -10
  395. package/workflows/containers/index.js +10 -10
  396. package/workflows/containers/index.js.map +1 -1
  397. package/workflows/documents/linkSet/linkSetAuthority.js +1 -1
  398. package/workflows/documents/linkSet/linkSetAuthority.js.map +1 -1
  399. package/workflows/documents/linkSet/linkSetBlobRewraps.js +1 -1
  400. package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -1
  401. package/workflows/documents/linkSet/linkSetProjectionSeed.js +1 -1
  402. package/workflows/documents/linkSet/linkSetProjectionSeed.js.map +1 -1
  403. package/workflows/documents/purge/index.js +1 -1
  404. package/workflows/documents/purge/index.js.map +1 -1
  405. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js +2 -2
  406. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -1
  407. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js +1 -1
  408. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +1 -1
  409. package/workflows/organizations/rematerialization/principalContainerRematerialization.js +5 -5
  410. package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +1 -1
  411. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js +1 -1
  412. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +1 -1
  413. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js +1 -1
  414. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +1 -1
  415. package/workflows/principals/policyCache/index.js +1 -1
  416. package/workflows/principals/policyCache/index.js.map +1 -1
  417. package/workflows/principals/policyRepair.js +1 -1
  418. package/workflows/principals/policyRepair.js.map +1 -1
  419. package/workflows/registration/organizationProvisioningArtifacts.d.ts +1 -1
  420. package/workflows/registration/provisioningBootstrapBuilders.js +1 -1
  421. package/data/keyingProjectionVerification/accessManifestCheckpointEnforcement.js.map +0 -1
  422. package/data/keyingProjectionVerification/bundleVerification.js.map +0 -1
  423. package/data/keyingProjectionVerification/checkpointContext.js.map +0 -1
  424. package/data/keyingProjectionVerification/containerAncestorCitations.js.map +0 -1
  425. package/data/keyingProjectionVerification/containerDestinationVerification.js.map +0 -1
  426. package/data/keyingProjectionVerification/containerManifestVerification.js.map +0 -1
  427. package/data/keyingProjectionVerification/containerPathVerification.js.map +0 -1
  428. package/data/keyingProjectionVerification/containerProjectionVerification.js.map +0 -1
  429. package/data/keyingProjectionVerification/documentDependencyPaths.js.map +0 -1
  430. package/data/keyingProjectionVerification/documentManifestPolicies.js.map +0 -1
  431. package/data/keyingProjectionVerification/documentManifestVerification.js.map +0 -1
  432. package/data/keyingProjectionVerification/documentProjectionVerification.js.map +0 -1
  433. package/data/keyingProjectionVerification/documentPurgeCheckpointCurrency.js.map +0 -1
  434. package/data/keyingProjectionVerification/documentPurgeCheckpointEnforcement.js.map +0 -1
  435. package/data/keyingProjectionVerification/documentPurgeDocumentChainVerification.js.map +0 -1
  436. package/data/keyingProjectionVerification/documentPurgePolicyCheckpoints.js.map +0 -1
  437. package/data/keyingProjectionVerification/documentPurgePolicyCurrency.js.map +0 -1
  438. package/data/keyingProjectionVerification/documentPurgePrincipalEvidence.js.map +0 -1
  439. package/data/keyingProjectionVerification/documentPurgeProofVerification.js.map +0 -1
  440. package/data/keyingProjectionVerification/manifestCheckpointVerification.js.map +0 -1
  441. package/data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js.map +0 -1
  442. package/data/keyingProjectionVerification/organizationFounderBinding.js.map +0 -1
  443. package/data/keyingProjectionVerification/principalPolicyCache.js.map +0 -1
  444. package/data/keyingProjectionVerification/principalPolicyVerification.js.map +0 -1
  445. package/data/keyingProjectionVerification/projectionAuthorizationEvidence.js.map +0 -1
  446. package/data/keyingProjectionVerification/projectionPolicyEvidence.js.map +0 -1
  447. package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js.map +0 -1
  448. package/stores/container-contents/backgroundHydration.js.map +0 -1
  449. package/stores/container-contents/containerPurgeCore.js.map +0 -1
  450. package/stores/container-contents/containerStateMap.js.map +0 -1
  451. package/stores/container-contents/containerStatePersistence.js.map +0 -1
  452. package/stores/container-contents/documentRecovery.js.map +0 -1
  453. package/stores/container-contents/documentRotation.js.map +0 -1
  454. package/stores/container-contents/documentWork.js.map +0 -1
  455. package/stores/container-contents/emptyTrashOperation.js.map +0 -1
  456. package/stores/container-contents/existingSystemContainer.js.map +0 -1
  457. package/stores/container-contents/groupRewrapOperation.js.map +0 -1
  458. package/stores/container-contents/missingContainerState.js.map +0 -1
  459. package/stores/container-contents/missingSyncedContainerState.js.map +0 -1
  460. package/stores/container-contents/operations.js.map +0 -1
  461. package/stores/container-contents/organizationMetadataSystemContainer.js.map +0 -1
  462. package/stores/container-contents/purgeContainerOperation.js.map +0 -1
  463. package/stores/container-contents/reconcilableContainer.js.map +0 -1
  464. package/stores/container-contents/remoteBackedContainerState.js.map +0 -1
  465. package/stores/container-contents/remoteContainerIngestion.js.map +0 -1
  466. package/stores/container-contents/remoteEventProjectionInvalidation.js.map +0 -1
  467. package/stores/container-contents/remoteEventSync.js.map +0 -1
  468. package/stores/container-contents/remoteHydrationRequest.js.map +0 -1
  469. package/stores/container-contents/remoteWriteGuards.js.map +0 -1
  470. package/stores/container-contents/remoteWriteQueue.js.map +0 -1
  471. package/stores/container-contents/reportShareFailure.js.map +0 -1
  472. package/stores/container-contents/setContainerIconOperation.js.map +0 -1
  473. package/stores/container-contents/shareOperations.js.map +0 -1
  474. package/stores/container-contents/startupHydration.js.map +0 -1
  475. package/stores/container-contents/syncAgent.js.map +0 -1
  476. package/stores/container-contents/syncAgentTypes.js.map +0 -1
  477. package/stores/container-contents/syncLaneIteration.js.map +0 -1
  478. package/stores/container-contents/systemContainerHydration.js.map +0 -1
  479. package/stores/container-contents/systemContainerIcon.js.map +0 -1
  480. package/stores/container-contents/systemContainerLookup.js.map +0 -1
  481. package/stores/container-contents/systemContainerPostCreate.js.map +0 -1
  482. package/stores/container-contents/systemContainerPromotion.js.map +0 -1
  483. package/stores/container-contents/writeGeneration.js.map +0 -1
  484. package/stores/documents/documentStore/attachmentDetachState.js.map +0 -1
  485. package/stores/documents/documentStore/attachmentHydration.js.map +0 -1
  486. package/stores/documents/documentStore/attachmentHydrationCommit.js.map +0 -1
  487. package/stores/documents/documentStore/attachmentIntents.js.map +0 -1
  488. package/stores/documents/documentStore/attachmentMutationPersistence.js.map +0 -1
  489. package/stores/documents/documentStore/attachmentPersistFollowup.js.map +0 -1
  490. package/stores/documents/documentStore/attachmentPersistence.js.map +0 -1
  491. package/stores/documents/documentStore/attachmentRemoval.js.map +0 -1
  492. package/stores/documents/documentStore/attachmentSnapshot.js.map +0 -1
  493. package/stores/documents/documentStore/attachmentSourceUpload.js.map +0 -1
  494. package/stores/documents/documentStore/attachmentStaging.js.map +0 -1
  495. package/stores/documents/documentStore/attachmentUploadAttempt.js.map +0 -1
  496. package/stores/documents/documentStore/attachmentUploadLane.js.map +0 -1
  497. package/stores/documents/documentStore/attachmentUploadResume.js.map +0 -1
  498. package/stores/documents/documentStore/attachmentWriteGeneration.js.map +0 -1
  499. package/stores/documents/documentStore/attachments.js.map +0 -1
  500. package/stores/documents/documentStore/deferredInitialUpdate.js.map +0 -1
  501. package/stores/documents/documentStore/documentHistoryCompaction.js.map +0 -1
  502. package/stores/documents/documentStore/durableDocumentReload.js.map +0 -1
  503. package/stores/documents/documentStore/historyRebuild.js.map +0 -1
  504. package/stores/documents/documentStore/initialization.js.map +0 -1
  505. package/stores/documents/documentStore/initializationAttachments.js.map +0 -1
  506. package/stores/documents/documentStore/initializationHistory.js.map +0 -1
  507. package/stores/documents/documentStore/initializationRecovery.js.map +0 -1
  508. package/stores/documents/documentStore/pullContinuationInvalidation.js.map +0 -1
  509. package/stores/documents/documentStore/remoteRevalidationTelemetry.js.map +0 -1
  510. package/stores/documents/documentStore/remoteWork.js.map +0 -1
  511. package/stores/documents/documentStore/rotation.js.map +0 -1
  512. package/stores/documents/documentStore/rotationProvenance.js.map +0 -1
  513. package/stores/documents/documentStore/rotationSettlement.js.map +0 -1
  514. package/stores/documents/documentStore/sync.js.map +0 -1
  515. package/stores/documents/documentStore/syncAcceptedUpdateIds.js.map +0 -1
  516. package/stores/documents/documentStore/syncAttachmentSettlement.js.map +0 -1
  517. package/stores/documents/documentStore/syncAttachments.js.map +0 -1
  518. package/stores/documents/documentStore/syncDetachedAttachments.js.map +0 -1
  519. package/stores/documents/documentStore/syncFinalize.js.map +0 -1
  520. package/stores/documents/documentStore/syncGeneration.js.map +0 -1
  521. package/stores/documents/documentStore/syncOutgoingCoverage.js.map +0 -1
  522. package/stores/documents/documentStore/syncRemoteSignals.js.map +0 -1
  523. package/stores/documents/documentStore/syncRequest.js.map +0 -1
  524. package/stores/documents/documentStore/syncShared.js.map +0 -1
  525. package/stores/documents/documentStore/syncUpdateImport.js.map +0 -1
  526. package/stores/documents/documentStore.js.map +0 -1
  527. package/workflows/container-contents/container-state/createAdoption.js.map +0 -1
  528. package/workflows/container-contents/container-state/createChild.js.map +0 -1
  529. package/workflows/container-contents/container-state/createIntentDepth.js.map +0 -1
  530. package/workflows/container-contents/container-state/createIntentSettlement.js.map +0 -1
  531. package/workflows/container-contents/container-state/createIntentSync.js.map +0 -1
  532. package/workflows/container-contents/container-state/createTerminalFailure.js.map +0 -1
  533. package/workflows/container-contents/container-state/createWithMetadata.js.map +0 -1
  534. package/workflows/container-contents/container-state/createWithMetadataPlan.js.map +0 -1
  535. package/workflows/container-contents/container-state/groupGrantVerification.js.map +0 -1
  536. package/workflows/container-contents/container-state/groupShareEpoch.js.map +0 -1
  537. package/workflows/container-contents/container-state/localPurgeScope.js.map +0 -1
  538. package/workflows/container-contents/container-state/purgeTree.js.map +0 -1
  539. package/workflows/container-contents/container-state/purgeTreeCollection.js.map +0 -1
  540. package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js.map +0 -1
  541. package/workflows/container-contents/container-state/purgeTreeScope.js.map +0 -1
  542. package/workflows/container-contents/container-state/readLocalPurgeScope.js.map +0 -1
  543. package/workflows/container-contents/container-state/share.js.map +0 -1
  544. package/workflows/container-contents/container-state/sharePersistence.js.map +0 -1
  545. package/workflows/container-contents/remoteHydration/childIndex.js.map +0 -1
  546. package/workflows/container-contents/remoteHydration/containerStateFingerprint.js.map +0 -1
  547. package/workflows/container-contents/remoteHydration/destinationPrefetch.js.map +0 -1
  548. package/workflows/container-contents/remoteHydration/destinationRoleCache.js.map +0 -1
  549. package/workflows/container-contents/remoteHydration/destinationRootReload.js.map +0 -1
  550. package/workflows/container-contents/remoteHydration/insertRemoteContainer.js.map +0 -1
  551. package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +0 -1
  552. package/workflows/container-contents/remoteHydration/parentLaneFetch.js.map +0 -1
  553. package/workflows/container-contents/remoteHydration/parentLaneQueue.js.map +0 -1
  554. package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js.map +0 -1
  555. package/workflows/container-contents/remoteHydration/remoteContainerState.js.map +0 -1
  556. package/workflows/container-contents/remoteHydration/remoteContainerTimestamps.js.map +0 -1
  557. package/workflows/container-contents/remoteHydration/replacementBinding.js.map +0 -1
  558. package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +0 -1
  559. package/workflows/containers/child/carriedDescendantRekeys.js.map +0 -1
  560. package/workflows/containers/child/create.js.map +0 -1
  561. package/workflows/containers/child/createProjection.js.map +0 -1
  562. package/workflows/containers/child/createSubmission.js.map +0 -1
  563. package/workflows/containers/child/currentShareGrantMutation.js.map +0 -1
  564. package/workflows/containers/child/currentSharePrincipalPolicy.js.map +0 -1
  565. package/workflows/containers/child/move.js.map +0 -1
  566. package/workflows/containers/child/moveArtifacts.js.map +0 -1
  567. package/workflows/containers/child/moveRotation.js.map +0 -1
  568. package/workflows/containers/child/moveWraps.js.map +0 -1
  569. package/workflows/containers/child/rekey.js.map +0 -1
  570. package/workflows/containers/child/rekeyProjection.js.map +0 -1
  571. package/workflows/containers/child/rekeyRemote.js.map +0 -1
  572. package/workflows/containers/child/replacementPrincipalPolicyReferences.js.map +0 -1
  573. package/workflows/containers/child/rotationContext.js.map +0 -1
  574. package/workflows/containers/child/rotationPrincipalPolicies.js.map +0 -1
  575. package/workflows/containers/child/rotationWraps.js.map +0 -1
  576. package/workflows/containers/child/runtimeCurrentGroupShare.js.map +0 -1
  577. package/workflows/containers/child/share.js.map +0 -1
  578. package/workflows/containers/child/shareAncestorRepair.js.map +0 -1
  579. package/workflows/containers/child/shareMaterialization.js.map +0 -1
  580. package/workflows/containers/child/sharePlanCore.js.map +0 -1
  581. package/workflows/containers/child/sharePrincipalPolicy.js.map +0 -1
  582. package/workflows/containers/child/shareProjection.js.map +0 -1
  583. /package/data/keyingProjectionVerification/{containerCreateManifest.js.map → container/containerCreateManifest.js.map} +0 -0
  584. /package/data/keyingProjectionVerification/{documentContainerProjections.js → document/documentContainerProjections.js} +0 -0
  585. /package/data/keyingProjectionVerification/{documentContainerProjections.js.map → document/documentContainerProjections.js.map} +0 -0
  586. /package/data/keyingProjectionVerification/{documentManifestPredecessor.js.map → document/documentManifestPredecessor.js.map} +0 -0
  587. /package/stores/container-contents/{containerStateMap.js → containerState/containerStateMap.js} +0 -0
  588. /package/stores/container-contents/{missingSyncedContainerState.js → containerState/missingSyncedContainerState.js} +0 -0
  589. /package/stores/container-contents/{reconcilableContainer.js → containerState/reconcilableContainer.js} +0 -0
  590. /package/stores/container-contents/{remoteHydrationRefresh.js → hydration/remoteHydrationRefresh.js} +0 -0
  591. /package/stores/container-contents/{remoteHydrationRefresh.js.map → hydration/remoteHydrationRefresh.js.map} +0 -0
  592. /package/stores/container-contents/{emptyTrashOperation.js → operations/emptyTrashOperation.js} +0 -0
  593. /package/stores/container-contents/{purgeContainerOperation.js → operations/purgeContainerOperation.js} +0 -0
  594. /package/stores/container-contents/{remoteBackedContainerState.js → remoteEvents/remoteBackedContainerState.js} +0 -0
  595. /package/stores/container-contents/{writeGeneration.js → remoteWrites/writeGeneration.js} +0 -0
  596. /package/stores/container-contents/{syncAgentTypes.js → syncAgent/syncAgentTypes.js} +0 -0
  597. /package/stores/container-contents/{systemContainerLookup.js → systemContainers/systemContainerLookup.js} +0 -0
  598. /package/stores/documents/documentStore/{attachmentPersistFollowup.js → attachments/attachmentPersistFollowup.js} +0 -0
  599. /package/stores/documents/documentStore/{attachmentSnapshot.js → attachments/attachmentSnapshot.js} +0 -0
  600. /package/stores/documents/documentStore/{remoteWork.js → sync/remoteWork.js} +0 -0
  601. /package/stores/documents/documentStore/{syncAcceptedUpdateIds.js → sync/syncAcceptedUpdateIds.js} +0 -0
  602. /package/stores/documents/documentStore/{syncGeneration.js → sync/syncGeneration.js} +0 -0
  603. /package/stores/documents/documentStore/{versionCoverage.js.map → sync/versionCoverage.js.map} +0 -0
  604. /package/workflows/container-contents/container-state/{createIntentSettlement.js → create/createIntentSettlement.js} +0 -0
  605. /package/workflows/container-contents/container-state/{purgeProgress.d.ts → purge/purgeProgress.d.ts} +0 -0
  606. /package/workflows/container-contents/container-state/{purgeProgress.js → purge/purgeProgress.js} +0 -0
  607. /package/workflows/container-contents/container-state/{purgeProgress.js.map → purge/purgeProgress.js.map} +0 -0
  608. /package/workflows/container-contents/container-state/{purgeTreeCollection.js → purge/purgeTreeCollection.js} +0 -0
  609. /package/workflows/container-contents/remoteHydration/{destinationPrefetch.js → destination/destinationPrefetch.js} +0 -0
  610. /package/workflows/container-contents/remoteHydration/{destinationRoleCache.js → destination/destinationRoleCache.js} +0 -0
  611. /package/workflows/container-contents/remoteHydration/{childIndex.js → lanes/childIndex.js} +0 -0
  612. /package/workflows/container-contents/remoteHydration/{parentLaneQueue.js → lanes/parentLaneQueue.js} +0 -0
  613. /package/workflows/container-contents/remoteHydration/{containerStateFingerprint.js → remoteContainers/containerStateFingerprint.js} +0 -0
  614. /package/workflows/container-contents/remoteHydration/{remoteContainerTimestamps.js → remoteContainers/remoteContainerTimestamps.js} +0 -0
  615. /package/workflows/containers/child/{keyringOverrideLineage.js.map → rekey/keyringOverrideLineage.js.map} +0 -0
  616. /package/workflows/containers/child/{shareProjection.js → share/shareProjection.js} +0 -0
@@ -1 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C,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;gBACnD,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,oDAAoD,CACvE;gBACE,IAAI;gBACJ,eAAe,EAAE,CAAC,WAAW,EAAE,EAAE,CAC/B,qBAAqB,CAAC,GAAG,CAAC,WAAW,CAAC;gBACxC,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;gBAC9C,MAAM;gBACN,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;gBAC9D,KAAK;aACN,CACF,CAAC;YACF,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC3B,OAAO,YAAY,CAAC;YACtB,CAAC;YAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,SAAS;YACX,CAAC;YAED,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YACjD,UAAU,GAAG,MAAM,KAAK,SAAS,IAAI,UAAU,CAAC;YAChD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,YAAY,IAAI,CAAC,CAAC;gBAClB,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { ContainerPathTooDeepError } from \"../../../data/containers/shared/containerPathLimits\";\nimport { reportAndRethrowKeyingVerificationError } from \"../../../data/keyingProjectionVerification/error\";\nimport { ContainerCreateIntentSupersededError } from \"../../../data/persistence/container-contents/containerIntentPersistence\";\nimport { errorMessage } from \"../../../data/shared/errorMessage\";\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../metadata/metadataStateIsolation\";\nimport type { ContainerState } from \"../remoteHydration\";\nimport { hasRemoteContainerMetadataState } from \"../remoteHydration/reconciliation\";\nimport { syncListedContainerCreate } from \"./createAdoption\";\nimport {\n deferTooDeepCreate,\n recordRefusedTooDeepCreate,\n} from \"./createIntentDepth\";\nimport { CONTAINER_ALREADY_COMMITTED } from \"./createWithMetadata\";\nimport { createRemoteContainer, deleteRemoteContainer } from \"./remote\";\nimport type {\n ContainerCreateIntentSyncHost,\n ContainerCreateIntentSyncInput,\n ContainerCreateIntentSyncState,\n CreatedRemoteContainerState,\n} from \"./types\";\n\nclass IncompleteContainerCreateSettlementError extends Error {}\n\ntype CreateIntentSyncResult = \"abandoned\" | \"blocked\" | \"created\" | \"failed\";\n\nfunction currentCreateResult<\n Result extends Exclude<CreateIntentSyncResult, \"abandoned\">,\n>(isCurrent: () => boolean, result: Result): \"abandoned\" | Result {\n return isCurrent() ? result : \"abandoned\";\n}\n\nasync function reportContainerCreateIntegrityFailure(input: {\n readonly containerId: string;\n readonly error: unknown;\n readonly organizationId: string;\n readonly state: ContainerCreateIntentSyncState;\n}): Promise<void> {\n await reportAndRethrowKeyingVerificationError(\n input.error,\n input.state.runtime.util.reportSecurityIncident,\n {\n objectId: input.containerId,\n objectKind: \"container\",\n operation: \"container.create.replay\",\n organizationId: input.organizationId,\n },\n );\n}\n\nasync function recordContainerCreateFailure(input: {\n readonly error: unknown;\n readonly isCurrent: () => boolean;\n readonly intent: ContainerCreateIntentSyncInput[\"intent\"];\n readonly organizationId: string;\n readonly state: ContainerCreateIntentSyncState;\n}): Promise<\"abandoned\" | \"failed\"> {\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n await reportContainerCreateIntegrityFailure({\n containerId: input.intent.containerId,\n error: input.error,\n organizationId: input.organizationId,\n state: input.state,\n });\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n await input.state.persistence.recordCreateIntentRevisionError(\n input.state.runtime.infra.execSql,\n {\n containerId: input.intent.containerId,\n expectedIntentId: input.intent.id,\n expectedUpdatedAt: input.intent.updatedAt,\n message: `${input.error instanceof IncompleteContainerCreateSettlementError ? \"Container create persistence failed\" : \"Remote container create failed\"}: ${errorMessage(input.error)}`,\n stillCurrent: input.isCurrent,\n },\n );\n return currentCreateResult(input.isCurrent, \"failed\");\n}\n\nasync function persistCreatedRemoteContainerStateFromIntent(input: {\n containerState: ContainerState;\n created: CreatedRemoteContainerState;\n host: ContainerCreateIntentSyncHost;\n isCurrent: () => boolean;\n intent: ContainerCreateIntentSyncInput[\"intent\"];\n state: ContainerCreateIntentSyncState;\n}): Promise<\n | \"abandoned\"\n | \"identity-superseded\"\n | \"intent-superseded\"\n | \"missing\"\n | \"persisted\"\n> {\n const { containerState, created, host, intent, state } = input;\n if (!input.isCurrent()) return \"abandoned\";\n const persistenceCandidate =\n await createDetachedContainerMetadataState(containerState);\n if (!input.isCurrent()) return \"abandoned\";\n persistenceCandidate.container = {\n ...persistenceCandidate.container,\n createdAt: created.createdAt,\n serverCreatedAt: created.createdAt,\n serverUpdatedAt: created.updatedAt,\n updatedAt: created.updatedAt,\n };\n\n let persistenceResult: Awaited<\n ReturnType<ContainerCreateIntentSyncHost[\"persistContainerState\"]>\n >;\n try {\n persistenceResult = await host.persistContainerState(\n persistenceCandidate,\n {\n accessEpoch: 1,\n accessStateHash: created.accessManifestHash,\n lastCommitLsn: null,\n metadataDocumentId: created.metadataDocumentId,\n systemSlot: created.systemSlot,\n organizationId: created.organizationId,\n parentId: created.parentId,\n ...created.persistedMetadataState,\n },\n false,\n {\n serverTimestamps: {\n createdAt: created.createdAt,\n updatedAt: created.updatedAt,\n },\n },\n {\n createIntentSettlement: {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n remoteContainerId: created.containerId,\n remoteMetadataAccessStateHash: created.accessManifestHash,\n remoteMetadataDocumentId: created.metadataDocumentId,\n supersededMovePreviousParentId: created.parentId,\n },\n expectedStateWhenMissing: containerState,\n isCurrent: input.isCurrent,\n preserveDurableStructureWhenPending: true,\n },\n );\n } catch (error) {\n if (error instanceof ContainerCreateIntentSupersededError) {\n return \"intent-superseded\";\n }\n throw error;\n }\n if (!input.isCurrent() || persistenceResult.status === \"stale-generation\") {\n return \"abandoned\";\n }\n if (persistenceResult.status !== \"persisted\") return persistenceResult.status;\n if (persistenceResult.createIntentSettled !== true) {\n throw new IncompleteContainerCreateSettlementError(\n \"Container create persistence must settle the intent atomically\",\n );\n }\n const { record: nextRecord } = persistenceResult;\n if (!input.isCurrent()) return \"abandoned\";\n const currentContainerState = state.containersById.get(intent.containerId);\n if (!currentContainerState) return \"missing\";\n if (currentContainerState !== containerState) return \"identity-superseded\";\n\n installDetachedContainerMetadataState(containerState, persistenceCandidate, {\n candidateRecord: nextRecord,\n preserveConcurrentMetadataEdit: true,\n });\n containerState.container = {\n ...containerState.container,\n metadataDocumentId: created.metadataDocumentId,\n systemSlot: created.systemSlot,\n organizationId: created.organizationId,\n parentId: persistenceCandidate.container.parentId,\n serverCreatedAt: created.createdAt,\n serverUpdatedAt: created.updatedAt,\n createdAt: created.createdAt,\n updatedAt: created.updatedAt,\n };\n return \"persisted\";\n}\n\nasync function discardOrphanedRemoteContainer(input: {\n created: CreatedRemoteContainerState;\n isCurrent: () => boolean;\n state: ContainerCreateIntentSyncState;\n}): Promise<void> {\n if (!input.isCurrent()) {\n return;\n }\n const discardFailure = await deleteRemoteContainer({\n containerId: input.created.containerId,\n organizationId: input.created.organizationId,\n runtime: input.state.runtime,\n }).then(\n (deleted) => (deleted ? null : \"the server rejected the delete\"),\n (error: unknown) => errorMessage(error),\n );\n if (input.isCurrent() && discardFailure !== null) {\n input.state.runtime.util.log(\n `Container contents: failed to discard orphaned remote container ${input.created.containerId} after local delete: ${discardFailure}`,\n );\n }\n}\n\nasync function settleRemoteContainerCreate(input: {\n containerState: ContainerState;\n created: Awaited<ReturnType<typeof createRemoteContainer>>;\n syncInput: ContainerCreateIntentSyncInput;\n}): Promise<CreateIntentSyncResult> {\n const { containerState, created, syncInput } = input;\n const { host, intent, state } = syncInput;\n if (created === CONTAINER_ALREADY_COMMITTED) {\n // A lost create response leaves the intent pending until hydration installs\n // the committed remote metadata state.\n state.runtime.util.log(\n `Container contents: deferred create intent for ${intent.containerId}; container already committed remotely, awaiting hydration.`,\n );\n syncInput.requestRemoteReconciliation(intent.parentContainerId);\n return \"blocked\";\n }\n if (!created) {\n await state.persistence.recordCreateIntentRevisionError(\n state.runtime.infra.execSql,\n {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n message: \"Remote container create was rejected or unavailable\",\n stillCurrent: syncInput.isCurrent,\n },\n );\n return currentCreateResult(syncInput.isCurrent, \"failed\");\n }\n if (!state.containersById.has(intent.containerId)) {\n // A same-generation local delete wins; discard the remote orphan instead\n // of resurrecting the deleted local container.\n await discardOrphanedRemoteContainer({\n created,\n isCurrent: syncInput.isCurrent,\n state,\n });\n return currentCreateResult(syncInput.isCurrent, \"failed\");\n }\n\n const persistenceStatus = await persistCreatedRemoteContainerStateFromIntent({\n containerState,\n created,\n host,\n isCurrent: syncInput.isCurrent,\n intent,\n state,\n });\n if (persistenceStatus === \"abandoned\") {\n syncInput.requestRemoteReconciliation(intent.parentContainerId);\n return \"abandoned\";\n }\n if (persistenceStatus === \"missing\") {\n await discardOrphanedRemoteContainer({\n created,\n isCurrent: syncInput.isCurrent,\n state,\n });\n return currentCreateResult(syncInput.isCurrent, \"failed\");\n }\n if (persistenceStatus === \"identity-superseded\") {\n state.runtime.util.log(\n `Container contents: deferred create intent for ${intent.containerId}; another writer persisted its remote identity.`,\n );\n syncInput.requestRemoteReconciliation(intent.parentContainerId);\n return \"blocked\";\n }\n if (persistenceStatus === \"intent-superseded\") {\n state.runtime.util.log(\n `Container contents: deferred create intent for ${intent.containerId}; a newer local intent superseded this pass.`,\n );\n return \"blocked\";\n }\n state.runtime.util.log(\n `Container contents: synced local container create ${containerState.container.id}`,\n );\n return \"created\";\n}\n\nasync function createPendingRemoteContainer(input: {\n containerState: ContainerState;\n parentState: ContainerState;\n syncInput: ContainerCreateIntentSyncInput;\n}): Promise<CreateIntentSyncResult> {\n const { containerState, parentState, syncInput } = input;\n const { intent, state } = syncInput;\n let created: Awaited<ReturnType<typeof createRemoteContainer>>;\n try {\n created = await createRemoteContainer({\n systemSlot: containerState.container.systemSlot,\n containerId: containerState.container.id,\n parentContainerId: parentState.container.id,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: syncInput.isCurrent,\n });\n } catch (error) {\n if (error instanceof ContainerPathTooDeepError)\n return recordRefusedTooDeepCreate(syncInput);\n return recordContainerCreateFailure({\n error,\n isCurrent: syncInput.isCurrent,\n intent,\n organizationId: parentState.container.organizationId,\n state,\n });\n }\n if (!syncInput.isCurrent()) {\n syncInput.requestRemoteReconciliation(intent.parentContainerId);\n return \"abandoned\";\n }\n try {\n return await settleRemoteContainerCreate({\n containerState,\n created,\n syncInput,\n });\n } catch (error) {\n if (!(error instanceof IncompleteContainerCreateSettlementError))\n throw error;\n return recordContainerCreateFailure({\n error,\n isCurrent: syncInput.isCurrent,\n intent,\n organizationId: parentState.container.organizationId,\n state,\n });\n }\n}\n\nasync function trySyncPendingContainerContentsContainerCreateIntent(\n input: ContainerCreateIntentSyncInput,\n): Promise<CreateIntentSyncResult> {\n const { intent, state } = input;\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n const containerState = state.containersById.get(intent.containerId);\n const parentState = state.containersById.get(intent.parentContainerId);\n\n if (!containerState || !parentState) {\n const execSql = state.runtime.infra.execSql;\n await state.persistence.recordCreateIntentRevisionError(execSql, {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n message: \"Container create intent references a missing local container\",\n stillCurrent: input.isCurrent,\n });\n return currentCreateResult(input.isCurrent, \"failed\");\n }\n\n if (typeof state.persistence.markCreateIntentRevisionSynced !== \"function\") {\n await state.persistence.recordCreateIntentRevisionError(\n state.runtime.infra.execSql,\n {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n message: \"Container create replay requires revision-CAS persistence\",\n stillCurrent: input.isCurrent,\n },\n );\n return currentCreateResult(input.isCurrent, \"failed\");\n }\n\n if (input.isRemoteSyncBlocked(parentState.container.organizationId)) {\n return \"blocked\";\n }\n\n if (hasRemoteContainerMetadataState(containerState)) {\n return syncListedContainerCreate({\n containerState,\n parentState,\n syncInput: input,\n });\n }\n\n // A parent whose own create has not settled may carry a listed identity\n // adoption has not verified, or has refused; nothing is created under it.\n if (\n !hasRemoteContainerMetadataState(parentState) ||\n input.isCreatePending(parentState.container.id)\n ) {\n return \"blocked\";\n }\n\n if (await deferTooDeepCreate(input)) {\n return currentCreateResult(input.isCurrent, \"blocked\");\n }\n\n return createPendingRemoteContainer({\n containerState,\n parentState,\n syncInput: input,\n });\n}\n\nexport async function syncPendingContainerCreateIntents(input: {\n host: ContainerCreateIntentSyncHost;\n isCurrent: () => boolean;\n isRemoteSyncBlocked: (organizationId: string) => boolean;\n requestRemoteReconciliation: (parentContainerId: string | null) => void;\n state: ContainerCreateIntentSyncState;\n}): Promise<number> {\n if (!input.isCurrent()) {\n return 0;\n }\n const { host } = input;\n const state = { ...input.state };\n const execSql = state.runtime.infra.execSql;\n const pendingIntents =\n await state.persistence.listPendingCreateIntents(execSql);\n if (!input.isCurrent()) {\n return 0;\n }\n const remainingContainerIds = new Set(\n pendingIntents.map((intent) => intent.containerId),\n );\n // Only a create that settles in this pass leaves the pending set; a failed\n // or parked one stays pending even though this pass stops retrying it.\n const unsettledContainerIds = new Set(remainingContainerIds);\n let createdCount = 0;\n let progressed = true;\n\n while (progressed && input.isCurrent()) {\n progressed = false;\n\n for (const intent of pendingIntents) {\n if (!remainingContainerIds.has(intent.containerId)) {\n continue;\n }\n\n const result = await trySyncPendingContainerContentsContainerCreateIntent(\n {\n host,\n isCreatePending: (containerId) =>\n unsettledContainerIds.has(containerId),\n isCurrent: input.isCurrent,\n isRemoteSyncBlocked: input.isRemoteSyncBlocked,\n intent,\n requestRemoteReconciliation: input.requestRemoteReconciliation,\n state,\n },\n );\n if (result === \"abandoned\") {\n return createdCount;\n }\n\n if (result === \"blocked\") {\n continue;\n }\n\n remainingContainerIds.delete(intent.containerId);\n progressed = result === \"created\" || progressed;\n if (result === \"created\") {\n createdCount += 1;\n unsettledContainerIds.delete(intent.containerId);\n }\n }\n }\n\n return createdCount;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTerminalFailure.js","sourceRoot":"","sources":["createTerminalFailure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAC;AAChG,OAAO,EACL,wCAAwC,EACxC,6BAA6B,GAC9B,MAAM,kDAAkD,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAuC,EACvC,YAAyC;IAEzC,IAAI,wCAAwC,CAAC,OAAO,CAAC;QAAE,OAAO,WAAW,CAAC;IAC1E,IAAI,6BAA6B,CAAC,OAAO,CAAC;QACxC,MAAM,IAAI,yBAAyB,EAAE,CAAC;IACxC,IAAI,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IACjD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { ContainerPathTooDeepError } from \"../../../data/containers/shared/containerPathLimits\";\nimport {\n isContainerManifestAlreadyExistsConflict,\n isContainerPathTooDeepFailure,\n} from \"../../../data/containers/shared/mutationFailures\";\nimport type { ContainerMutationSubmitFailure } from \"../../../data/containers/shared/types\";\n\n/**\n * Classify a create refusal that no repair can answer. A lost response re-sends\n * the same stable ids and the server reports the manifest already exists: the\n * container committed remotely, the benign outcome of an idempotent retry that\n * reconciles via hydration (as document creates do), so it is not reported. A\n * path-length refusal is final: the intent waits for a local move.\n */\nexport function settleTerminalCreateFailure(\n failure: ContainerMutationSubmitFailure,\n stillCurrent: (() => boolean) | undefined,\n): \"committed\" | \"failed\" {\n if (isContainerManifestAlreadyExistsConflict(failure)) return \"committed\";\n if (isContainerPathTooDeepFailure(failure))\n throw new ContainerPathTooDeepError();\n if (stillCurrent?.() !== false) failure.report();\n return \"failed\";\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createWithMetadata.js","sourceRoot":"","sources":["createWithMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qBAAqB,GACtB,MAAM,2CAA2C,CAAC;AAMnD,OAAO,EAAE,wCAAwC,EAAE,MAAM,yDAAyD,CAAC;AAEnH,OAAO,EAAE,wCAAwC,EAAE,MAAM,2CAA2C,CAAC;AAErG,OAAO,EACL,uDAAuD,EACvD,iCAAiC,GAClC,MAAM,oEAAoE,CAAC;AAE5E,OAAO,EAEL,uCAAuC,GACxC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAEL,0CAA0C,EAC1C,wCAAwC,EACxC,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,+BAA+B,GAEhC,MAAM,0BAA0B,CAAC;AAMlC;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAG/E,KAAK,UAAU,mCAAmC,CAAC,KAKlD;IAQC,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAClD,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,yCAAyC,CACtE,KAAK,CAAC,OAAO,EACb;QACE,qCAAqC,EAAE,KAAK,CAAC,cAAc;QAC3D,YAAY,EAAE,KAAK;KACpB,CACF,CAAC;IACF,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E,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAC5C,MAAM,gBAAgB,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClD,OAAO,sCAAsC,CAAC;QAC5C,MAAM;QACN,gBAAgB;QAChB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY;QACZ,iBAAiB;QACjB,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAChB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,gBAAgB;QAChB,eAAe;QACf,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;QACxD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,UAAU,EAAE,KAAK,CAAC,UAAU;KAC7B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ContainerAccessManifestState } from \"@tearleads/crypto\";\nimport {\n type ContainerSystemSlot,\n isContainerSystemSlot,\n} from \"@tearleads/validators/containerSystemSlot\";\nimport type { ContainerCreateWithMetadataDocumentRequest } from \"@tearleads/validators/request\";\nimport type {\n ContainerCreateWithMetadataDocumentResponse,\n ContainerWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport { locallyAcknowledgedContainerMutationHead } from \"../../../data/containers/shared/mutationAcknowledgement\";\nimport type { ContainerMutationSubmitFailure } from \"../../../data/containers/shared/types\";\nimport { assertDocumentWriterProjectionConsistent } from \"../../../data/documents/shared/projection\";\nimport type { ProjectionUserKeyResolver } from \"../../../data/keyingProjectionVerification\";\nimport {\n advanceLocallyAcknowledgedAccessManifestHeadsAtomically,\n locallyAuthoredAccessManifestHead,\n} from \"../../../data/persistence/locallyAcknowledgedCheckpointPersistence\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport {\n type buildMaterializedContainerCreatePlan,\n readContainerMutationMetadataDocumentId,\n} from \"../../containers\";\nimport { repairContainerCreateFailure } from \"../../containers/child/createSubmission\";\nimport {\n type buildMaterializedDocumentCreatePlan,\n documentWriterProjectionFromCreateResponse,\n persistedDocumentCreateStateFromResponse,\n resolveDocumentCreateAuthor,\n} from \"../../documents\";\nimport { PrincipalPolicyRepairBudget } from \"../../principals/policyRepairBudget\";\nimport { createRuntimePrincipalPolicyWarmer } from \"../../principals/runtimePolicyWarmer\";\nimport { settleTerminalCreateFailure } from \"./createTerminalFailure\";\nimport {\n buildContainerWithMetadataPlans,\n type ContainerWithMetadataPlanInput,\n} from \"./createWithMetadataPlan\";\nimport type {\n ContainerWorkflowRuntime,\n CreatedRemoteContainerState,\n} from \"./types\";\n\n/**\n * Sentinel for a lost-response retry whose manifest already exists remotely.\n * Callers avoid a duplicate; the next parent hydration settles local state.\n */\nexport const CONTAINER_ALREADY_COMMITTED = Symbol(\"containerAlreadyCommitted\");\nexport type ContainerAlreadyCommitted = typeof CONTAINER_ALREADY_COMMITTED;\n\nasync function submitContainerWithMetadataDocument(input: {\n readonly organizationId: string;\n readonly request: ContainerCreateWithMetadataDocumentRequest;\n readonly runtime: ContainerWorkflowRuntime;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<\n | {\n readonly ok: true;\n readonly response: ContainerCreateWithMetadataDocumentResponse;\n }\n | ContainerMutationSubmitFailure\n | null\n> {\n if (input.stillCurrent?.() === false) return null;\n const { apiClient } = input.runtime;\n const result = await apiClient.createContainerWithMetadataDocumentResult(\n input.request,\n {\n expectedPaymentRequiredOrganizationId: input.organizationId,\n reportErrors: false,\n },\n );\n return result.ok ? { ok: true, response: result.data } : result;\n}\n\n/**\n * Seed the metadata document's writer projection from the create response so the\n * first read after the container is created (its own metadata sync, contents\n * hydration) resolves locally instead of a cold `GET writer-projection`. The\n * authorizing path is the child container projection the create was authored\n * against — locally built rather than server-fetched, so unlike the plain\n * document-create path this is gated on the projection's internal consistency;\n * on any mismatch the seed is skipped and the next read falls back to a fetch.\n */\nasync function seedMetadataDocumentWriterProjection(input: {\n readonly runtime: ContainerWorkflowRuntime;\n readonly childProjection: ContainerWriterProjectionResponse;\n readonly response: ContainerCreateWithMetadataDocumentResponse;\n readonly execSql?: ExecSql | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<void> {\n const projection = documentWriterProjectionFromCreateResponse({\n containerProjection: input.childProjection,\n response: input.response.metadataDocument,\n });\n try {\n await assertDocumentWriterProjectionConsistent(projection, {\n execSql: input.execSql,\n stillCurrent: input.stillCurrent,\n trustedLocalProjection: true,\n });\n } catch {\n return;\n }\n if (input.stillCurrent?.() === false) return;\n input.runtime.apiClient.primeDocumentWriterProjection(\n input.response.metadataDocument.id,\n projection,\n );\n}\n\nasync function acknowledgeContainerWithMetadata(input: {\n containerPlan: Parameters<\n typeof locallyAcknowledgedContainerMutationHead\n >[0][\"plan\"];\n execSql: ExecSql;\n metadataDocumentPlan: Parameters<\n typeof persistedDocumentCreateStateFromResponse\n >[0];\n response: ContainerCreateWithMetadataDocumentResponse;\n stillCurrent?: (() => boolean) | undefined;\n}) {\n const persistedState = persistedDocumentCreateStateFromResponse(\n input.metadataDocumentPlan,\n input.response.metadataDocument,\n );\n const containerHead = await locallyAcknowledgedContainerMutationHead({\n plan: input.containerPlan,\n response: input.response.container,\n });\n await advanceLocallyAcknowledgedAccessManifestHeadsAtomically({\n execSql: input.execSql,\n heads: [\n containerHead,\n locallyAuthoredAccessManifestHead(input.metadataDocumentPlan),\n ],\n stillCurrent: input.stillCurrent,\n });\n return persistedState;\n}\n\n/**\n * Prime the new container's writer projection from the create plan the client\n * just authored, so the first write under it (a child folder, a document)\n * resolves locally instead of a cold `GET writer-projection`. Only primed when\n * the locally-built projection matches what the server created — the create\n * response echoes the container id and manifest head — so a mismatch skips the\n * seed and the next write falls back to a fetch (same fail-closed contract as\n * the metadata-document seed). Priming is safe for writes: the server still\n * validates every mutation, so a projection that later goes stale (rekey/share/\n * move evict it) just yields a rejected write that retries with a fresh fetch.\n */\nfunction seedChildContainerWriterProjection(input: {\n readonly childProjection: ContainerWriterProjectionResponse;\n readonly response: ContainerCreateWithMetadataDocumentResponse;\n readonly runtime: ContainerWorkflowRuntime;\n}): void {\n const createdManifestHash =\n input.response.container.manifestHead.manifestHash;\n const projectedManifestHash = input.childProjection.path.at(-1)?.manifestHash;\n // Both hashes must be present and equal, or two undefined hashes would compare\n // equal and prime an empty/invalid projection.\n if (\n !createdManifestHash ||\n !projectedManifestHash ||\n input.childProjection.containerId !==\n input.response.container.containerId ||\n projectedManifestHash !== createdManifestHash\n ) {\n return;\n }\n\n input.runtime.apiClient.primeContainerWriterProjection(\n input.response.container.containerId,\n input.childProjection,\n );\n}\n\n/**\n * The persisted slot is the one this client signed into the manifest state.\n * The acknowledgement already refused a response that echoed anything else,\n * so the server's column never chooses which local record becomes Trash.\n */\nfunction signedCreateSystemSlot(\n state: ContainerAccessManifestState,\n): ContainerSystemSlot | null {\n if (state.systemSlot === null) return null;\n if (!isContainerSystemSlot(state.systemSlot)) {\n throw new Error(\"Container create plan signed an invalid system slot\");\n }\n return state.systemSlot;\n}\n\nasync function settleContainerWithMetadataCreate(input: {\n readonly childProjection: ContainerWriterProjectionResponse;\n readonly containerPlan: Awaited<\n ReturnType<typeof buildMaterializedContainerCreatePlan>\n >;\n readonly execSql: ExecSql;\n readonly metadataDocumentPlan: Awaited<\n ReturnType<typeof buildMaterializedDocumentCreatePlan>\n >;\n readonly response: ContainerCreateWithMetadataDocumentResponse;\n readonly runtime: ContainerWorkflowRuntime;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<{\n readonly ok: true;\n readonly state: CreatedRemoteContainerState;\n} | null> {\n if (\n input.response.container.containerId !==\n input.containerPlan.plan.containerId\n ) {\n throw new Error(\"Container metadata create response container mismatch\");\n }\n // The acknowledgement echoed the signed parent, which a child always names.\n const parentId = input.containerPlan.plan.state.parentContainerId;\n if (parentId === null) {\n throw new Error(\"A container create must commit under a parent\");\n }\n const metadataDocumentId = readContainerMutationMetadataDocumentId({\n response: input.response.container,\n });\n if (\n metadataDocumentId !== input.containerPlan.plan.metadataDocumentId ||\n input.response.metadataDocument.id !==\n input.metadataDocumentPlan.plan.documentId\n ) {\n throw new Error(\"Container metadata create response document mismatch\");\n }\n const persistedMetadataState = await acknowledgeContainerWithMetadata({\n containerPlan: input.containerPlan.plan,\n execSql: input.execSql,\n metadataDocumentPlan: input.metadataDocumentPlan.plan,\n response: input.response,\n stillCurrent: input.stillCurrent,\n });\n if (input.stillCurrent?.() === false) return null;\n await seedMetadataDocumentWriterProjection({\n childProjection: input.childProjection,\n execSql: input.execSql,\n response: input.response,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n });\n if (input.stillCurrent?.() === false) return null;\n seedChildContainerWriterProjection({\n childProjection: input.childProjection,\n response: input.response,\n runtime: input.runtime,\n });\n return {\n ok: true,\n state: {\n accessManifestHash: input.response.container.manifestHead.manifestHash,\n systemSlot: signedCreateSystemSlot(input.containerPlan.plan.state),\n containerId: input.response.container.containerId,\n createdAt: input.response.container.createdAt,\n metadataDocumentId,\n organizationId: input.response.container.organizationId,\n parentId,\n persistedMetadataState,\n updatedAt: input.response.container.updatedAt,\n },\n };\n}\n\nasync function createRemoteContainerWithMetadataDocumentAttempt(\n input: ContainerWithMetadataPlanInput,\n): Promise<\n | {\n readonly ok: true;\n readonly state: CreatedRemoteContainerState;\n }\n | ContainerMutationSubmitFailure\n | null\n> {\n const execSql = input.runtime.infra.execSql;\n const plans = await buildContainerWithMetadataPlans(input);\n if (!plans) return null;\n const { containerPlan, childProjection, metadataDocumentPlan } = plans;\n const submitted = await submitContainerWithMetadataDocument({\n organizationId: containerPlan.plan.state.organizationId,\n request: {\n systemSlot: input.systemSlot ?? null,\n container: containerPlan.plan.request,\n metadataDocument: metadataDocumentPlan.plan.request,\n },\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n });\n if (!submitted?.ok) {\n return submitted;\n }\n return settleContainerWithMetadataCreate({\n childProjection,\n containerPlan,\n execSql,\n metadataDocumentPlan,\n response: submitted.response,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n });\n}\n\nasync function createContainerWithMetadataWithRepairs(\n input: Parameters<\n typeof createRemoteContainerWithMetadataDocumentAttempt\n >[0] & {\n readonly parentContainerId: string;\n },\n): Promise<CreatedRemoteContainerState | ContainerAlreadyCommitted | null> {\n const { apiClient } = input.runtime;\n let parentProjection = input.parentProjection;\n const repairState = {\n didRepairStaleParent: false,\n policyRepairs: new PrincipalPolicyRepairBudget(),\n };\n for (;;) {\n const submitted = await createRemoteContainerWithMetadataDocumentAttempt({\n ...input,\n parentProjection,\n });\n if (!submitted) {\n return null;\n }\n if (submitted.ok) {\n return submitted.state;\n }\n const repair = await repairContainerCreateFailure({\n apiClient,\n failure: submitted,\n parentContainerId: input.parentContainerId,\n parentProjection,\n state: repairState,\n warmReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n input.runtime,\n ),\n stillCurrent: input.stillCurrent,\n });\n if (repair.kind === \"retry\") {\n parentProjection = repair.parentProjection;\n continue;\n }\n if (repair.kind === \"unavailable\") return null;\n return settleTerminalCreateFailure(submitted, input.stillCurrent) ===\n \"committed\"\n ? CONTAINER_ALREADY_COMMITTED\n : null;\n }\n}\n\nexport async function createRemoteContainerWithMetadataDocument(input: {\n systemSlot?: ContainerSystemSlot | null | undefined;\n containerId: string;\n parentContainerId: string;\n parentProjection?: ContainerWriterProjectionResponse | undefined;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<CreatedRemoteContainerState | ContainerAlreadyCommitted | null> {\n const author = resolveDocumentCreateAuthor(input.runtime);\n const { apiClient } = input.runtime;\n const parentSecretKey = input.runtime.crypto.encapsulationKeyPair?.secretKey;\n if (!author || !parentSecretKey) {\n input.runtime.util.log(\n \"Container contents: skipped container create because the writer context is unavailable.\",\n );\n return null;\n }\n\n const parentProjection =\n input.parentProjection ??\n (await apiClient.getContainerWriterProjection(input.parentContainerId));\n if (!parentProjection) {\n return null;\n }\n\n const containerEventId = crypto.randomUUID();\n const containerKey = crypto.getRandomValues(new Uint8Array(32));\n const containerSignedAt = new Date().toISOString();\n const metadataContentKey = crypto.getRandomValues(new Uint8Array(32));\n const metadataEventId = crypto.randomUUID();\n const metadataSignedAt = new Date().toISOString();\n return createContainerWithMetadataWithRepairs({\n author,\n containerEventId,\n containerId: input.containerId,\n containerKey,\n containerSignedAt,\n metadataContentKey,\n metadataEventId,\n metadataSignedAt,\n parentContainerId: input.parentContainerId,\n parentProjection,\n parentSecretKey,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n systemSlot: input.systemSlot,\n });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createWithMetadataPlan.js","sourceRoot":"","sources":["createWithMetadataPlan.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oCAAoC,EAAE,MAAM,kEAAkE,CAAC;AACxH,OAAO,EACL,oCAAoC,EACpC,4CAA4C,GAC7C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mCAAmC,GAEpC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAoB1F,KAAK,UAAU,UAAU,CAAC,KAAqC;IAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5C,8EAA8E;IAC9E,4EAA4E;IAC5E,MAAM,aAAa,GAAG,MAAM,oCAAoC,CAAC;QAC/D,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,OAAO;QACP,OAAO,EAAE,KAAK,CAAC,gBAAgB;QAC/B,kBAAkB,EAAE,KAAK,CAAC,WAAW;QACrC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,eA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EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAClD,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;IACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC;IACpD,SAAS,CAAC,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,gBAAgB,GACpB,MAAM,SAAS,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IACvE,IACE,gBAAgB,CAAC,WAAW,KAAK,QAAQ;QACzC,gBAAgB,CAAC,cAAc,KAAK,KAAK,CAAC,gBAAgB,CAAC,cAAc,EACzE,CAAC;QACD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC,EAAE,GAAG,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { ContainerSystemSlot } from \"@tearleads/validators/containerSystemSlot\";\nimport type { ContainerWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport type { ProjectionUserKeyResolver } from \"../../../data/keyingProjectionVerification\";\nimport { ProjectionDependencyUnavailableError } from \"../../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport {\n buildMaterializedContainerCreatePlan,\n childContainerWriterProjectionFromCreatePlan,\n} from \"../../containers\";\nimport {\n buildMaterializedDocumentCreatePlan,\n type resolveDocumentCreateAuthor,\n} from \"../../documents\";\nimport { createRuntimePrincipalPolicyWarmer } from \"../../principals/runtimePolicyWarmer\";\nimport type { ContainerWorkflowRuntime } from \"./types\";\n\nexport interface ContainerWithMetadataPlanInput {\n readonly author: NonNullable<ReturnType<typeof resolveDocumentCreateAuthor>>;\n readonly containerEventId: string;\n readonly containerId: string;\n readonly containerKey: Uint8Array;\n readonly containerSignedAt: string;\n readonly metadataContentKey: Uint8Array;\n readonly metadataEventId: string;\n readonly metadataSignedAt: string;\n readonly parentProjection: ContainerWriterProjectionResponse;\n readonly parentSecretKey: Uint8Array;\n readonly resolveProjectionUserKey: ProjectionUserKeyResolver;\n readonly runtime: ContainerWorkflowRuntime;\n readonly systemSlot?: ContainerSystemSlot | null | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n}\n\nasync function buildPlans(input: ContainerWithMetadataPlanInput) {\n const execSql = input.runtime.infra.execSql;\n // Rebuild parent- and policy-dependent hashes, signatures, and wraps on every\n // attempt while retaining the logical mutation identities and key material.\n const containerPlan = await buildMaterializedContainerCreatePlan({\n author: input.author,\n containerId: input.containerId,\n containerKey: input.containerKey,\n execSql,\n eventId: input.containerEventId,\n metadataDocumentId: input.containerId,\n systemSlot: input.systemSlot,\n parentProjection: input.parentProjection,\n parentSecretKey: input.parentSecretKey,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n signedAt: input.containerSignedAt,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n input.runtime,\n ),\n });\n const childProjection = childContainerWriterProjectionFromCreatePlan({\n materializedPlan: containerPlan,\n parentProjection: input.parentProjection,\n });\n const metadataDocumentPlan = await buildMaterializedDocumentCreatePlan({\n author: input.author,\n containerProjection: childProjection,\n contentKey: input.metadataContentKey,\n documentId: containerPlan.plan.metadataDocumentId,\n eventId: input.metadataEventId,\n execSql,\n knownContainerKeks: new Map([\n [containerPlan.plan.containerKeyEpochId, containerPlan.containerKey],\n ]),\n signedAt: input.metadataSignedAt,\n stillCurrent: input.stillCurrent,\n targetSecretKey: input.parentSecretKey,\n trustedLocalProjection: true,\n });\n return { containerPlan, childProjection, metadataDocumentPlan };\n}\n\n/** Refresh stale history evidence once, strictly before submitting the write. */\nexport async function buildContainerWithMetadataPlans(\n input: ContainerWithMetadataPlanInput,\n) {\n try {\n return await buildPlans(input);\n } catch (error) {\n if (!(error instanceof ProjectionDependencyUnavailableError)) throw error;\n }\n if (input.stillCurrent?.() === false) return null;\n const { apiClient } = input.runtime;\n const parentId = input.parentProjection.containerId;\n apiClient.evictContainerWriterProjection(parentId);\n const parentProjection =\n await apiClient.getContainerWriterProjection(parentId);\n if (!parentProjection || input.stillCurrent?.() === false) return null;\n if (\n parentProjection.containerId !== parentId ||\n parentProjection.organizationId !== input.parentProjection.organizationId\n ) {\n throw new Error(\n \"Refreshed parent projection belongs to another container or organization\",\n );\n }\n return buildPlans({ ...input, parentProjection });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupGrantVerification.js","sourceRoot":"","sources":["groupGrantVerification.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,wCAAwC,EAExC,+BAA+B,GAChC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,oCAAoC,EAAE,MAAM,kEAAkE,CAAC;AACxH,OAAO,EAAE,uCAAuC,EAAE,MAAM,iEAAiE,CAAC;AAC1H,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,wCAAwC,EAAE,MAAM,oDAAoD,CAAC;AAC9G,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE1F,OAAO,EAAE,qCAAqC,EAAE,MAAM,mBAAmB,CAAC;AAK1E,SAAS,8BAA8B,CAAC,KASvC;IACC,MAAM,KAAK,GAAG,kBAAkB,CAC9B,yBAAyB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,CACrD,CAAC;IACF,OAAO,CACL,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,mBAAmB;QAC/C,KAAK,CAAC,cAAc,KAAK,KAAK,CAAC,sBAAsB;QACrD,KAAK,CAAC,YAAY,CAAC,IAAI,CACrB,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,WAAW,KAAK,O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,IAAI,KAAK,CACZ,CAAC;AACJ,CAAC","sourcesContent":["import type { ReferencedPrincipalHead } from \"@tearleads/crypto\";\nimport {\n getTargetContainerContext,\n readContainerState,\n} from \"../../../data/containers/shared/projection\";\nimport {\n nullOnProjectionVerificationCancellation,\n type ProjectionUserKeyResolver,\n verifyContainerWriterProjection,\n} from \"../../../data/keyingProjectionVerification\";\nimport { ProjectionDependencyUnavailableError } from \"../../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport { principalPolicyCacheForVerifiedPolicies } from \"../../../data/keyingProjectionVerification/principalPolicyCache\";\nimport { referencedPrincipalHeadFromPolicy } from \"../../containers\";\nimport { createRuntimeCurrentSharePrincipalPolicy } from \"../../containers/child/currentSharePrincipalPolicy\";\nimport { createRuntimePrincipalPolicyWarmer } from \"../../principals/runtimePolicyWarmer\";\nimport type { ContainerState } from \"../remoteHydration\";\nimport { loadContainerWriterProjectionForState } from \"./projectionCache\";\nimport type { ContainerWorkflowRuntime } from \"./types\";\n\ntype GroupGrantAccessLevel = \"read\" | \"write\" | \"admin\";\n\nfunction projectionHasCurrentGroupGrant(input: {\n accessLevel: GroupGrantAccessLevel;\n expectedContainerId: string;\n expectedOrganizationId: string;\n groupId: string;\n currentHead: ReferencedPrincipalHead;\n projection: NonNullable<\n Awaited<ReturnType<typeof loadContainerWriterProjectionForState>>\n >;\n}): boolean {\n const state = readContainerState(\n getTargetContainerContext(input.projection).manifest,\n );\n return (\n state.containerId === input.expectedContainerId &&\n state.organizationId === input.expectedOrganizationId &&\n state.directGrants.some(\n (grant) =>\n grant.subjectType === \"group\" &&\n grant.subjectId === input.groupId &&\n grant.accessLevel === input.accessLevel,\n ) &&\n state.referencedPrincipalHeads.some(\n (head) =>\n head.principalType === input.currentHead.principalType &&\n head.principalId === input.currentHead.principalId &&\n head.version === input.currentHead.version &&\n head.keyEpoch === input.currentHead.keyEpoch &&\n head.stateHash === input.currentHead.stateHash &&\n head.keyFingerprint === input.currentHead.keyFingerprint,\n )\n );\n}\n\nasync function containerStateHasCurrentGroupGrantInternal(input: {\n accessLevel: GroupGrantAccessLevel;\n containerState: ContainerState;\n expectedContainerId: string;\n expectedGroupHead: ReferencedPrincipalHead;\n expectedOrganizationId: string;\n groupId: string;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<boolean> {\n if (input.stillCurrent?.() === false) return false;\n const projection = await loadContainerWriterProjectionForState({\n containerState: input.containerState,\n runtime: input.runtime,\n });\n if (\n !projection ||\n input.stillCurrent?.() === false ||\n input.expectedGroupHead.principalType !== \"group\" ||\n input.expectedGroupHead.principalId !== input.groupId ||\n input.containerState.container.id !== input.expectedContainerId ||\n input.containerState.container.organizationId !==\n input.expectedOrganizationId ||\n projection.containerId !== input.expectedContainerId ||\n projection.organizationId !== input.expectedOrganizationId\n ) {\n return false;\n }\n\n const readCurrent = createRuntimeCurrentSharePrincipalPolicy(input.runtime);\n if (!readCurrent)\n throw new ProjectionDependencyUnavailableError(\n \"Group sharing requires private paged recovery\",\n );\n return readCurrent(\n {\n expectedGroupHead: input.expectedGroupHead,\n groupId: input.groupId,\n organizationId: input.expectedOrganizationId,\n stillCurrent: input.stillCurrent ?? (() => true),\n },\n async ({ checkpointPolicies, policy, stillCurrent }) => {\n await verifyContainerWriterProjection({\n execSql: input.runtime.infra.execSql,\n principalPolicyCache:\n principalPolicyCacheForVerifiedPolicies(checkpointPolicies),\n projection,\n resolveUserKey: input.resolveProjectionUserKey,\n stillCurrent,\n warmReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n input.runtime,\n ),\n });\n return projectionHasCurrentGroupGrant({\n accessLevel: input.accessLevel,\n currentHead: referencedPrincipalHeadFromPolicy(policy),\n expectedContainerId: input.expectedContainerId,\n expectedOrganizationId: input.expectedOrganizationId,\n groupId: input.groupId,\n projection,\n });\n },\n );\n}\n\nexport async function containerStateHasCurrentGroupGrant(\n input: Parameters<typeof containerStateHasCurrentGroupGrantInternal>[0],\n): Promise<boolean> {\n return (\n (await nullOnProjectionVerificationCancellation(() =>\n containerStateHasCurrentGroupGrantInternal(input),\n )) ?? false\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupShareEpoch.js","sourceRoot":"","sources":["groupShareEpoch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,kEAAkE,CAAC;AACxH,OAAO,EAAE,wCAAwC,EAAE,MAAM,oDAAoD,CAAC;AAG9G,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,KAQjD;IACC,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAClD,MAAM,WAAW,GAAG,wCAAwC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5E,IAAI,CAAC,WAAW;QACd,MAAM,IAAI,oCAAoC,CAC5C,+CAA+C,CAChD,CAAC;IACJ,OAAO,WAAW,CAChB;QACE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;KACjD,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CACtC,CAAC;AACJ,CAAC","sourcesContent":["import { ProjectionDependencyUnavailableError } from \"../../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport { createRuntimeCurrentSharePrincipalPolicy } from \"../../containers/child/currentSharePrincipalPolicy\";\nimport type { ContainerWorkflowRuntime } from \"./types\";\n\nexport async function resolveCurrentGroupKeyEpoch(input: {\n // Bound here, in the one verified load a duplicate share performs, so a\n // duplicate never reports success for a group the user did not choose.\n expectedGroupName?: string | undefined;\n groupId: string;\n organizationId: string;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<number | null> {\n if (input.stillCurrent?.() === false) return null;\n const readCurrent = createRuntimeCurrentSharePrincipalPolicy(input.runtime);\n if (!readCurrent)\n throw new ProjectionDependencyUnavailableError(\n \"Group sharing requires private paged recovery\",\n );\n return readCurrent(\n {\n expectedGroupName: input.expectedGroupName,\n groupId: input.groupId,\n organizationId: input.organizationId,\n stillCurrent: input.stillCurrent ?? (() => true),\n },\n async ({ policy }) => policy.keyEpoch,\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"localPurgeScope.js","sourceRoot":"","sources":["localPurgeScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,qEAAqE,CAAC;AAgBpH,SAAS,mBAAmB,CAAC,KAA2B;IACtD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC;IAClC,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,MAAM,YAAY,EAAE,CAAC;QAC5D,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACpB,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC1B,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;YAC/D,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrB,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ;YAAE,MAAM,YAAY,EAAE,CAAC;QACpC,IAAI,SAAS,KAAK,KAAK,CAAC,eAAe;YAAE,MAAM;QAC/C,SAAS,GAAG,QAAQ,CAAC,SA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C,MAAM,YAAY,EAAE,CAAC;AACzB,CAAC;AAED,SAAS,YAAY;IACnB,OAAO,IAAI,KAAK,CACd,6DAA6D,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["import { hasUnsettledDocumentPlacement } from \"../../../data/persistence/container-contents/documentPurgePlacement\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport type { ContainerContentsPersistence } from \"../containerPersistence\";\nimport type { ContainerState } from \"../remoteHydration\";\n\ninterface LocalPurgeScopeInput {\n containerId: string | null | undefined;\n containersById: ReadonlyMap<string, ContainerState>;\n execSql: ExecSql;\n localId?: string | undefined;\n persistence: ContainerContentsPersistence;\n rootContainerId: string;\n stillCurrent?: (() => boolean) | undefined;\n verifiedAncestorsById: ReadonlyMap<string, readonly string[]>;\n}\n\nfunction guardedContainerIds(input: LocalPurgeScopeInput): ReadonlySet<string> {\n const guardedIds = new Set<string>();\n const seen = new Set<string>();\n let currentId = input.containerId;\n while (true) {\n if (!currentId || seen.has(currentId)) throw changedScope();\n seen.add(currentId);\n guardedIds.add(currentId);\n for (const id of input.verifiedAncestorsById.get(currentId) ?? [])\n guardedIds.add(id);\n const expected = input.containersById.get(currentId);\n if (!expected) throw changedScope();\n if (currentId === input.rootContainerId) break;\n currentId = expected.container.parentId;\n }\n return guardedIds;\n}\n\n/** Called inside the document deletion transaction; performs no remote I/O. */\nexport async function assertLocalPurgeScope(\n input: LocalPurgeScopeInput,\n): Promise<void> {\n if (\n input.localId !== undefined &&\n (await hasUnsettledDocumentPlacement(input.execSql, input.localId))\n )\n throw changedScope();\n const guardedIds = guardedContainerIds(input);\n // Include every known signed ancestor as well as the local selection chain.\n // A dishonest listing can give these chains different intermediate nodes.\n for (const id of guardedIds) {\n const expected = input.containersById.get(id);\n if (!expected) continue;\n const current = await input.persistence.loadContainerMetadataState(\n input.execSql,\n id,\n );\n if (\n !current?.record ||\n current.container.parentId !== expected.container.parentId ||\n current.container.organizationId !== expected.container.organizationId ||\n current.record.documentId !== expected.record.documentId\n )\n throw changedScope();\n }\n const pending = await input.persistence.listUnsyncedMoveIntents(\n input.execSql,\n );\n if (\n pending.some((intent) => guardedIds.has(intent.containerId)) ||\n input.stillCurrent?.() === false\n )\n throw changedScope();\n}\n\nfunction changedScope(): Error {\n return new Error(\n \"Local subtree purge scope changed before deletion committed\",\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"purgeTree.js","sourceRoot":"","sources":["purgeTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAGlF,OAAO,EAAE,yCAAyC,EAAE,MAAM,6EAA6E,CAAC;AACxI,OAAO,EAAE,wCAAwC,EAAE,MAAM,0DAA0D,CAAC;AAGpH,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AA4DhE,+EAA+E;AAC/E,gFAAgF;AAChF,uEAAuE;AACvE,MAAM,UAAU,uBAAuB,CAAC,KAKvC;IACC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IACjC,CAAC;IACD,MAAM,eAAe,GAAG,KAAK,CAAC,kBAAkB,CAAC,IAAI,CACnD,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,CAC7D,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,kBAAkB,GAAG,KAAK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KAAK,CAAC,eAAe;YACtC,6BAA6B,EAAE,KAAK,CAAC,6BAA6B;YAClE,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC;YAChC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,UAAU;YACV,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,aAAa,EAAE,uBAAuB;SACvC,CAAC,CAAC;QACH,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAC;QACjD,yBAAyB,GAAG,QAAQ,CAAC,yBAAyB,CAAC;QAC/D,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO;QACP,cAAc;QACd,WAAW;QACX,kBAAkB;QAClB,yBAAyB;QACzB,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import { DEFAULT_DOCUMENT_KIND } from \"../../../data/documents/documentConstants\";\nimport type { DocumentSummary } from \"../../../data/documents/documentSummary\";\nimport type { ProjectionUserKeyResolver } from \"../../../data/keyingProjectionVerification\";\nimport { sqlDocumentContainerProjectionPersistence } from \"../../../data/persistence/containers/documentContainerProjectionPersistence\";\nimport { listDocumentsByContainerIdsOrDocumentIds } from \"../../../data/persistence/documents/documentsPersistence\";\nimport type { SubtreePurgeRoot } from \"../../documents/purge/subtreePurgeScope\";\nimport type { ContainerContentsPersistence } from \"../containerPersistence\";\nimport { unlinkRemoteContainerDocument } from \"../documentLinks\";\nimport type { ContainerState } from \"../remoteHydration\";\nimport type { ContainerContentsWorkflowRuntime } from \"../runtime\";\nimport {\n purgeLocalContainerDocument,\n purgeRemoteContainerDocument,\n} from \"../tombstones/documentPurge\";\nimport type { PurgeProgress } from \"./purgeProgress\";\nimport {\n collectSubtreeLeafFirst,\n snapshotContainerStates,\n} from \"./purgeTreeCollection\";\nimport { deleteSubtreeContainers } from \"./purgeTreeContainerDeletion\";\nimport { createSubtreePurgeScope } from \"./purgeTreeScope\";\n\nexport { collectSubtreeLeafFirst } from \"./purgeTreeCollection\";\n\n// The store runtime satisfies the per-document purge/unlink workflows, so the\n// cascade reuses it verbatim.\ntype PurgeContainerTreeRuntime = ContainerContentsWorkflowRuntime;\n\ninterface PurgeContainerTreeInput {\n readonly containersById: ReadonlyMap<string, ContainerState>;\n readonly documentOperations?: SubtreeDocumentOperations | undefined;\n // When true, tear down everything UNDER the root (its documents plus every\n // descendant container) but never delete the root container itself. This is\n // how \"Empty Trash\" reuses the same engine: the Trash bin is a protected system\n // container that must survive while its whole contents are destroyed.\n readonly keepRootContainer?: boolean;\n readonly onProgress?: ((progress: PurgeProgress) => void) | undefined;\n readonly persistence: ContainerContentsPersistence;\n readonly prepareDocumentRotationSnapshot: (\n document: DocumentSummary,\n ) => Promise<Uint8Array | null>;\n readonly resolveProjectionUserKey: ProjectionUserKeyResolver;\n readonly rootContainerId: string;\n readonly runtime: PurgeContainerTreeRuntime;\n /** Stops a stale store generation between complete destructive units. */\n readonly stillCurrent?: (() => boolean) | undefined;\n // Checked at each unit boundary (between whole documents / whole containers),\n // never mid-remote-call, so a cancelled run stops on a consistent prefix.\n readonly signal?: AbortSignal | undefined;\n}\n\ninterface PurgeContainerTreeResult {\n readonly aborted: boolean;\n readonly completedCount: number;\n readonly failedCount: number;\n readonly purgedContainerIds: readonly string[];\n readonly remoteDeletedContainerIds: readonly string[];\n readonly totalCount: number;\n}\n\ninterface SubtreeDocumentPlan {\n // Synced documents whose every link falls inside the subtree: reduce them to\n // one retained link, as required by the purge endpoint, then destroy them.\n readonly purge: readonly {\n document: DocumentSummary;\n unlinkContainerIds: readonly string[];\n }[];\n // Synced documents also linked outside the subtree: keep them, but unlink\n // from each in-subtree container so the containers can be deleted.\n readonly unlinkByDocument: ReadonlyMap<\n string,\n { document: DocumentSummary; containerIds: readonly string[] }\n >;\n // Never-synced documents (no remote id): destroy locally only.\n readonly purgeLocal: readonly DocumentSummary[];\n}\n\ntype SubtreeDocumentDisposition =\n | { kind: \"purge\"; unlinkContainerIds: readonly string[] }\n | { kind: \"purge-local\" }\n | { kind: \"unlink\"; containerIds: readonly string[] };\n\n// Destroy local-only documents locally. Destroy synced documents only when all\n// links are in the subtree; preserve documents with an external link. The purge\n// plan reduces owned documents to the server-required sole link first.\nexport function classifySubtreeDocument(input: {\n readonly documentId: string | null;\n readonly linkedContainerIds: readonly string[];\n readonly preferredContainerId?: string | null | undefined;\n readonly subtreeContainerIds: ReadonlySet<string>;\n}): SubtreeDocumentDisposition {\n if (!input.documentId) {\n return { kind: \"purge-local\" };\n }\n const hasExternalLink = input.linkedContainerIds.some(\n (containerId) => !input.subtreeContainerIds.has(containerId),\n );\n if (!hasExternalLink) {\n const linkedContainerIds = Array.from(\n new Set(\n input.linkedContainerIds.filter((containerId) =>\n input.subtreeContainerIds.has(containerId),\n ),\n ),\n );\n const retainedContainerId =\n input.preferredContainerId &&\n linkedContainerIds.includes(input.preferredContainerId)\n ? input.preferredContainerId\n : linkedContainerIds[0];\n return {\n kind: \"purge\",\n unlinkContainerIds: linkedContainerIds.filter(\n (containerId) => containerId !== retainedContainerId,\n ),\n };\n }\n return {\n kind: \"unlink\",\n containerIds: input.linkedContainerIds.filter((containerId) =>\n input.subtreeContainerIds.has(containerId),\n ),\n };\n}\n\nasync function planSubtreeDocuments(input: {\n readonly execSql: PurgeContainerTreeRuntime[\"infra\"][\"execSql\"];\n readonly subtreeContainerIds: ReadonlySet<string>;\n}): Promise<SubtreeDocumentPlan> {\n const documents = await listDocumentsByContainerIdsOrDocumentIds(\n input.execSql,\n {\n containerIds: [...input.subtreeContainerIds],\n documentIds: [],\n },\n );\n const remoteDocumentIds = documents.flatMap((document) =>\n document.documentId ? [document.documentId] : [],\n );\n const linkedContainerIdsByDocumentId =\n await sqlDocumentContainerProjectionPersistence.listLinkedContainerIdsByDocumentIds(\n input.execSql,\n remoteDocumentIds,\n );\n\n const purge: Array<{\n document: DocumentSummary;\n unlinkContainerIds: readonly string[];\n }> = [];\n const purgeLocal: DocumentSummary[] = [];\n const unlinkByDocument = new Map<\n string,\n { document: DocumentSummary; containerIds: readonly string[] }\n >();\n for (const document of documents) {\n const disposition = classifySubtreeDocument({\n documentId: document.documentId ?? null,\n linkedContainerIds: document.documentId\n ? (linkedContainerIdsByDocumentId.get(document.documentId) ?? [])\n : [],\n preferredContainerId: document.containerId,\n subtreeContainerIds: input.subtreeContainerIds,\n });\n if (disposition.kind === \"purge-local\") {\n purgeLocal.push(document);\n } else if (disposition.kind === \"purge\") {\n purge.push({\n document,\n unlinkContainerIds: disposition.unlinkContainerIds,\n });\n } else if (document.documentId) {\n unlinkByDocument.set(document.documentId, {\n document,\n containerIds: disposition.containerIds,\n });\n }\n }\n\n return { purge, purgeLocal, unlinkByDocument };\n}\n\nasync function unlinkSubtreeDocument(input: {\n /** Rechecks the document and this exact unlink target before dispatch. */\n readonly beforeSubmit: (targetContainerId: string) => Promise<boolean>;\n readonly expectedSubtreeRoot: SubtreePurgeRoot;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly containerIds: readonly string[];\n readonly document: DocumentSummary;\n readonly prepareDocumentRotationSnapshot: PurgeContainerTreeInput[\"prepareDocumentRotationSnapshot\"];\n readonly resolveProjectionUserKey: ProjectionUserKeyResolver;\n readonly runtime: PurgeContainerTreeRuntime;\n}): Promise<boolean> {\n const documentId = input.document.documentId;\n if (!documentId) {\n return true;\n }\n let rotationSnapshot: Uint8Array | null;\n try {\n rotationSnapshot = await input.prepareDocumentRotationSnapshot(\n input.document,\n );\n } catch {\n return false;\n }\n if (!rotationSnapshot) {\n return false;\n }\n for (const containerId of input.containerIds) {\n const result = await unlinkRemoteContainerDocument({\n beforeSubmit: () => input.beforeSubmit(containerId),\n documentId,\n expectedSubtreeRoot: input.expectedSubtreeRoot,\n isCurrent: input.stillCurrent,\n noteId: input.document.id,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n rotationSnapshot,\n runtime: input.runtime,\n targetContainerId: containerId,\n });\n if (result === null) {\n return false;\n }\n }\n return true;\n}\n\ninterface SubtreeDocumentOperations {\n readonly purgeLocal: (document: DocumentSummary) => Promise<boolean>;\n readonly purgeRemote: (document: DocumentSummary) => Promise<boolean>;\n readonly unlink: (\n document: DocumentSummary,\n containerIds: readonly string[],\n ) => Promise<boolean>;\n}\n\nfunction resolveSubtreeDocumentOperations(\n input: PurgeContainerTreeInput,\n scope: ReturnType<typeof createSubtreePurgeScope>,\n): SubtreeDocumentOperations {\n const expectedSubtreeRoot = selectedSubtreeRoot(input);\n const operations: SubtreeDocumentOperations = input.documentOperations ?? {\n purgeLocal: async (document) =>\n (await purgeLocalContainerDocument({\n beforeDeleteInTransaction: (execSql) =>\n scope.assertLocalScopeInTransaction(\n execSql,\n document.containerId,\n document.id,\n ),\n noteId: document.id,\n expectedContainerId: document.containerId,\n runtime: input.runtime,\n })) !== null,\n purgeRemote: async (document) =>\n Boolean(\n document.documentId &&\n (await purgeRemoteContainerDocument({\n beforeSubmit: () => scope.allowsDocument(document),\n documentId: document.documentId,\n expectedSubtreeRoot,\n stillCurrent: input.stillCurrent,\n documentKind: document.documentKind ?? DEFAULT_DOCUMENT_KIND,\n noteId: document.id,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n runtime: input.runtime,\n })),\n ),\n unlink: (document, containerIds) =>\n unlinkSubtreeDocument({\n // Target preparation and signing can outlast the upfront checks.\n beforeSubmit: async (containerId) =>\n (await scope.allowsDocument(document)) &&\n (await scope.allowsContainer(containerId)),\n containerIds,\n document,\n expectedSubtreeRoot,\n stillCurrent: input.stillCurrent,\n prepareDocumentRotationSnapshot: input.prepareDocumentRotationSnapshot,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n runtime: input.runtime,\n }),\n };\n return {\n purgeLocal: async (document) =>\n (await scope.allowsDocument(document)) &&\n (await operations.purgeLocal(document)),\n purgeRemote: async (document) =>\n (await scope.allowsDocument(document)) &&\n (await operations.purgeRemote(document)),\n unlink: async (document, containerIds) => {\n if (!(await scope.allowsDocument(document))) return false;\n for (const containerId of containerIds) {\n if (!(await scope.allowsContainer(containerId))) return false;\n }\n return operations.unlink(document, containerIds);\n },\n };\n}\n\ninterface SubtreeTeardownResult {\n readonly aborted: boolean;\n}\n\n// Signed request paths must keep the root under the parent it was selected\n// from; a settled restore elsewhere preserves the root's own documents too.\nfunction selectedSubtreeRoot(\n input: Pick<PurgeContainerTreeInput, \"containersById\" | \"rootContainerId\">,\n): SubtreePurgeRoot {\n return {\n id: input.rootContainerId,\n parentId:\n input.containersById.get(input.rootContainerId)?.container.parentId ??\n null,\n };\n}\n\nfunction purgeWasCancelled(input: {\n readonly signal?: AbortSignal | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): boolean {\n return input.signal?.aborted === true || input.stillCurrent?.() === false;\n}\n\n// Tear down one whole document per progress step. A failed document is skipped,\n// leaving its container undeletable while the remaining subtree work continues.\n// Cancellation is honored only between complete document operations.\nasync function teardownSubtreeDocuments(input: {\n readonly documentOperations: SubtreeDocumentOperations;\n readonly plan: SubtreeDocumentPlan;\n readonly reportStep: (ok: boolean) => void;\n readonly signal?: AbortSignal | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<SubtreeTeardownResult> {\n for (const {\n document,\n containerIds,\n } of input.plan.unlinkByDocument.values()) {\n if (purgeWasCancelled(input)) {\n return { aborted: true };\n }\n const unlinked = await input.documentOperations.unlink(\n document,\n containerIds,\n );\n input.reportStep(unlinked);\n }\n for (const { document, unlinkContainerIds } of input.plan.purge) {\n if (purgeWasCancelled(input)) {\n return { aborted: true };\n }\n if (\n unlinkContainerIds.length > 0 &&\n !(await input.documentOperations.unlink(document, unlinkContainerIds))\n ) {\n input.reportStep(false);\n continue;\n }\n input.reportStep(await input.documentOperations.purgeRemote(document));\n }\n for (const document of input.plan.purgeLocal) {\n if (purgeWasCancelled(input)) {\n return { aborted: true };\n }\n input.reportStep(await input.documentOperations.purgeLocal(document));\n }\n return { aborted: false };\n}\n\n// Permanently destroy a folder that lives inside Trash, including everything\n// under it (or, with keepRootContainer, everything under the Trash bin while\n// leaving the bin in place — this is \"Empty Trash\"). Documents are destroyed only\n// when the subtree holds their last link; multi-folder documents are unlinked\n// from the subtree and preserved. Containers are deleted leaf-first so each\n// delete obeys the leaf-only constraint the store and server enforce. Every step\n// is remote-first then local (the per-document and per-container workflows handle\n// that internally), so a cancel between steps leaves local state reflecting\n// exactly the completed remote work.\n//\n// Progress is determinate: the plan (a pure read) completes before any\n// destructive step, so onProgress reports completed/failed against a total known\n// up front. A failed item is skipped rather than aborting the run, so the result\n// reports whatever prefix was actually destroyed alongside completed/failed\n// counts and whether a cancellation cut it short. Returns null only when the\n// target container is absent from the snapshot.\nexport async function purgeContainerTree(\n request: PurgeContainerTreeInput,\n): Promise<PurgeContainerTreeResult | null> {\n if (purgeWasCancelled(request)) {\n return null;\n }\n const input = {\n ...request,\n containersById: snapshotContainerStates(request.containersById),\n };\n const subtreeStates = collectSubtreeLeafFirst(\n input.containersById,\n input.rootContainerId,\n );\n if (subtreeStates.length === 0) {\n return null;\n }\n const subtreeContainerIds = new Set(\n subtreeStates.map((containerState) => containerState.container.id),\n );\n\n const plan = await planSubtreeDocuments({\n execSql: input.runtime.infra.execSql,\n subtreeContainerIds,\n });\n if (purgeWasCancelled(input)) {\n return null;\n }\n\n // Empty Trash keeps the Trash bin itself: tear down everything it holds, but\n // exclude the root from the container deletions (deleting a system container\n // would be rejected anyway).\n const containerStatesToDelete = input.keepRootContainer\n ? subtreeStates.filter(\n (containerState) =>\n containerState.container.id !== input.rootContainerId,\n )\n : subtreeStates;\n\n // The total is fully known here — planning is a pure read that completes before\n // any destructive step. Unlink work is counted per document (not per container\n // link) so completed can never exceed total even when a document has several\n // in-subtree links.\n const totalCount =\n plan.unlinkByDocument.size +\n plan.purge.length +\n plan.purgeLocal.length +\n containerStatesToDelete.length;\n\n let completedCount = 0;\n let failedCount = 0;\n const emitProgress = () => {\n input.onProgress?.({ completedCount, failedCount, totalCount });\n };\n const reportStep = (ok: boolean) => {\n if (ok) {\n completedCount += 1;\n } else {\n failedCount += 1;\n }\n emitProgress();\n };\n // Emit the initial 0/total so a determinate bar renders immediately, before the\n // first (potentially slow) remote call.\n emitProgress();\n\n const scope = createSubtreePurgeScope(input);\n const teardown = await teardownSubtreeDocuments({\n documentOperations: resolveSubtreeDocumentOperations(input, scope),\n plan,\n reportStep,\n signal: input.signal,\n stillCurrent: input.stillCurrent,\n });\n\n let purgedContainerIds: readonly string[] = [];\n let remoteDeletedContainerIds: readonly string[] = [];\n let aborted = teardown.aborted;\n if (!teardown.aborted) {\n const deletion = await deleteSubtreeContainers({\n allowsContainer: scope.allowsContainer,\n allowsLocalScopeInTransaction: scope.allowsLocalScopeInTransaction,\n root: selectedSubtreeRoot(input),\n persistence: input.persistence,\n reportStep,\n runtime: input.runtime,\n signal: input.signal,\n stillCurrent: input.stillCurrent,\n subtreeStates: containerStatesToDelete,\n });\n purgedContainerIds = deletion.purgedContainerIds;\n remoteDeletedContainerIds = deletion.remoteDeletedContainerIds;\n aborted = deletion.aborted;\n }\n\n return {\n aborted,\n completedCount,\n failedCount,\n purgedContainerIds,\n remoteDeletedContainerIds,\n totalCount,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"purgeTreeCollection.js","sourceRoot":"","sources":["purgeTreeCollection.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,MAAM,UAAU,uBAAuB,CACrC,MAA2C;IAE3C,OAAO,IAAI,GAAG,CACZ,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC/B,EAAE;QACF;YACE,GAAG,KAAK;YACR,SAAS,EAAE,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE;YACjC,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE;SAC5B;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC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,CAAC,OAAO,CAAC,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import type { ContainerState } from \"../remoteHydration\";\n\n/** Own the placement fields; live store updates cannot revise purge intent. */\nexport function snapshotContainerStates(\n states: ReadonlyMap<string, ContainerState>,\n): ReadonlyMap<string, ContainerState> {\n return new Map(\n [...states].map(([id, state]) => [\n id,\n {\n ...state,\n container: { ...state.container },\n record: { ...state.record },\n },\n ]),\n );\n}\n\n// Collect the target and descendants leaf-first because container deletion is\n// leaf-only. The enqueued set guards self/cyclic parent chains.\nexport function collectSubtreeLeafFirst(\n containersById: ReadonlyMap<string, ContainerState>,\n rootContainerId: string,\n): ContainerState[] {\n const childIdsByParentId = new Map<string, string[]>();\n for (const containerState of containersById.values()) {\n const parentId = containerState.container.parentId;\n if (parentId === null) continue;\n const siblings = childIdsByParentId.get(parentId) ?? [];\n siblings.push(containerState.container.id);\n childIdsByParentId.set(parentId, siblings);\n }\n\n const ordered: ContainerState[] = [];\n const enqueued = new Set<string>([rootContainerId]);\n // Read through the queue with a head index rather than shift(): shift() is\n // O(N) per call, which would make the whole walk O(N^2).\n const queue = [rootContainerId];\n for (let head = 0; head < queue.length; head++) {\n const containerId = queue[head];\n if (containerId === undefined) continue;\n const containerState = containersById.get(containerId);\n if (containerState) ordered.push(containerState);\n for (const childId of childIdsByParentId.get(containerId) ?? []) {\n if (!enqueued.has(childId)) {\n enqueued.add(childId);\n queue.push(childId);\n }\n }\n }\n\n return ordered.reverse();\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"purgeTreeContainerDeletion.js","sourceRoot":"","sources":["purgeTreeContainerDeletion.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAuBhD,+EAA+E;AAC/E,4EAA4E;AAC5E,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oBACb,kBAAkB;oBAClB,yBAAyB;iBAC1B,CAAC;YACJ,CAAC;YACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtB,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC;YACD,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,CAAC;AAC3E,CAAC","sourcesContent":["import type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport type { SubtreePurgeRoot } from \"../../documents/purge/subtreePurgeScope\";\nimport type { ContainerContentsPersistence } from \"../containerPersistence\";\nimport type { ContainerState } from \"../remoteHydration\";\nimport type { ContainerContentsWorkflowRuntime } from \"../runtime\";\nimport { deleteContainerState } from \"./delete\";\n\ninterface SubtreeContainerDeletionResult {\n readonly aborted: boolean;\n readonly purgedContainerIds: string[];\n readonly remoteDeletedContainerIds: string[];\n}\n\ninterface DeleteSubtreeContainersInput {\n readonly allowsContainer: (containerId: string) => Promise<boolean>;\n readonly allowsLocalScopeInTransaction: (\n execSql: ExecSql,\n containerId: string,\n ) => Promise<boolean>;\n readonly persistence: ContainerContentsPersistence;\n readonly reportStep: (ok: boolean) => void;\n readonly root: SubtreePurgeRoot;\n readonly runtime: ContainerContentsWorkflowRuntime;\n readonly signal?: AbortSignal | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n readonly subtreeStates: readonly ContainerState[];\n}\n\n// Descendants stay under the selected root. A root with a captured parent must\n// retain that ancestor; parentless roots have no parent constraint to send.\nfunction requiredDeletionAncestor(\n root: SubtreePurgeRoot,\n containerId: string,\n): string {\n return containerId === root.id ? (root.parentId ?? root.id) : root.id;\n}\n\nfunction deletionWasCancelled(input: DeleteSubtreeContainersInput): boolean {\n return input.signal?.aborted === true || input.stillCurrent?.() === false;\n}\n\nfunction recordContainerDeletionOutcome(input: {\n containerState: ContainerState;\n deleted: Awaited<ReturnType<typeof deleteContainerState>>;\n purgedContainerIds: string[];\n remoteDeletedContainerIds: string[];\n}): boolean {\n if (input.deleted === \"remote-deleted\") {\n input.remoteDeletedContainerIds.push(input.containerState.container.id);\n }\n if (input.deleted !== \"deleted\") return false;\n input.purgedContainerIds.push(input.containerState.container.id);\n if (input.containerState.record.documentId) {\n input.remoteDeletedContainerIds.push(input.containerState.container.id);\n }\n return true;\n}\n\n// Delete leaf-first. A surviving document or child blocks its container and all\n// ancestors; cancellation stops at a container boundary.\nexport async function deleteSubtreeContainers(\n input: DeleteSubtreeContainersInput,\n): Promise<SubtreeContainerDeletionResult> {\n const purgedContainerIds: string[] = [];\n const remoteDeletedContainerIds: string[] = [];\n const blockedParentIds = new Set<string>();\n for (const containerState of input.subtreeStates) {\n if (deletionWasCancelled(input)) {\n return { aborted: true, purgedContainerIds, remoteDeletedContainerIds };\n }\n const containerId = containerState.container.id;\n const parentId = containerState.container.parentId;\n if (\n blockedParentIds.has(containerId) ||\n !(await input.allowsContainer(containerId))\n ) {\n if (parentId !== null) {\n blockedParentIds.add(parentId);\n }\n input.reportStep(false);\n continue;\n }\n const deleted = await deleteContainerState({\n beforeDeleteInTransaction: (execSql) =>\n input.allowsLocalScopeInTransaction(execSql, containerId),\n containerState,\n requiredAncestorId: requiredDeletionAncestor(input.root, containerId),\n persistence: input.persistence,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n });\n if (\n recordContainerDeletionOutcome({\n containerState,\n deleted,\n purgedContainerIds,\n remoteDeletedContainerIds,\n })\n ) {\n input.reportStep(true);\n } else {\n if (\n (deleted === \"local-conflict\" || deleted === \"remote-deleted\") &&\n deletionWasCancelled(input)\n ) {\n return {\n aborted: true,\n purgedContainerIds,\n remoteDeletedContainerIds,\n };\n }\n if (parentId !== null) {\n blockedParentIds.add(parentId);\n }\n input.reportStep(false);\n }\n }\n return { aborted: false, purgedContainerIds, remoteDeletedContainerIds };\n}\n"]}
@@ -1 +0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KACL,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,mBAAmB,CAChC,KAA6B,EAC7B,KAA6B;IAE7B,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,sCAAsC,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,KAAK,YAAY,uBAAuB;YAAE,MAAM,KAAK,CAAC;QAC1D,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,gDAAgD,YAAY,CAAC,KAAK,CAAC,EAAE,CACtE,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { KeyingVerificationError } from \"@tearleads/crypto\";\nimport type { DocumentSummary } from \"../../../data/documents/documentSummary\";\nimport type { ProjectionUserKeyResolver } from \"../../../data/keyingProjectionVerification\";\nimport { verifyContainerWriterProjection } from \"../../../data/keyingProjectionVerification/containerProjectionVerification\";\nimport { runWithSecurityIncidentReporting } from \"../../../data/keyingProjectionVerification/error\";\nimport { rethrowProjectionVerificationCancelled } from \"../../../data/keyingProjectionVerification/types\";\nimport { hasUnsettledDocumentPlacement } from \"../../../data/persistence/container-contents/documentPurgePlacement\";\nimport { sqlDocumentsPersistence } from \"../../../data/persistence/documents/documentsPersistence\";\nimport { errorMessage } from \"../../../data/shared/errorMessage\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport { createRuntimePrincipalPolicyWarmer } from \"../../principals/runtimePolicyWarmer\";\nimport type { ContainerContentsPersistence } from \"../containerPersistence\";\nimport type { ContainerState } from \"../remoteHydration\";\nimport type { ContainerContentsWorkflowRuntime } from \"../runtime\";\nimport { assertLocalPurgeScope } from \"./localPurgeScope\";\nimport { snapshotContainerStates } from \"./purgeTreeCollection\";\nimport { readLocalPurgeScope } from \"./readLocalPurgeScope\";\n\ninterface SubtreePurgeScopeInput {\n containersById: ReadonlyMap<string, ContainerState>;\n persistence: ContainerContentsPersistence;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n rootContainerId: string;\n runtime: ContainerContentsWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n}\n\nasync function verifiedRemoteScope(\n input: SubtreePurgeScopeInput,\n current: Pick<ContainerState, \"container\" | \"record\">,\n verifiedAncestorsById: Map<string, readonly string[]>,\n): Promise<boolean> {\n const { runtime, rootContainerId } = input;\n const targetId = current.container.id;\n return runWithSecurityIncidentReporting(\n runtime.util.reportSecurityIncident,\n {\n objectId: targetId,\n objectKind: \"container\",\n operation: \"container.purge.scope\",\n },\n async () => {\n runtime.apiClient.evictContainerWriterProjection(targetId);\n const projection =\n await runtime.apiClient.getContainerWriterProjection(targetId);\n if (!projection || input.stillCurrent?.() === false) return false;\n if (\n projection.containerId !== targetId ||\n projection.organizationId !== current.container.organizationId\n ) {\n throw new KeyingVerificationError(\n \"object_mismatch\",\n \"Subtree purge container identity mismatch\",\n );\n }\n const path = await verifyContainerWriterProjection({\n execSql: runtime.infra.execSql,\n projection,\n resolveUserKey: input.resolveProjectionUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies:\n createRuntimePrincipalPolicyWarmer(runtime),\n });\n const rootIndex = path.findIndex(\n (head) => head.state.containerId === rootContainerId,\n );\n const latest = await input.persistence.loadContainerMetadataState(\n runtime.infra.execSql,\n targetId,\n );\n const pendingMoves = await readPendingMoves(input);\n const allowed =\n rootIndex >= 0 &&\n path[rootIndex]?.state.parentContainerId ===\n input.containersById.get(rootContainerId)?.container.parentId &&\n latest?.container.parentId === current.container.parentId &&\n latest.record?.documentId === current.record.documentId &&\n !path\n .slice(rootIndex)\n .some((head) => pendingMoves.has(head.state.containerId)) &&\n input.stillCurrent?.() !== false;\n if (allowed)\n verifiedAncestorsById.set(\n targetId,\n path.slice(rootIndex).map((head) => head.state.containerId),\n );\n return allowed;\n },\n );\n}\n\n/**\n * A local-only unit cites no signed request, so a remote ordinary root must\n * prove that it still sits under the parent it was selected from. A system\n * root's signed topology is fixed by its destination role.\n */\nasync function rootPlacementIsCurrent(\n input: SubtreePurgeScopeInput,\n verifiedAncestorsById: Map<string, readonly string[]>,\n): Promise<boolean> {\n const root = input.containersById.get(input.rootContainerId);\n if (!root?.record.documentId || (root.container.systemSlot ?? null) !== null)\n return true;\n return verifiedRemoteScope(input, root, verifiedAncestorsById);\n}\n\nasync function allowsContainer(\n input: SubtreePurgeScopeInput,\n containerId: string,\n verifiedAncestorsById: Map<string, readonly string[]>,\n localOnlyUnit: boolean,\n): Promise<boolean> {\n const { runtime, persistence, rootContainerId } = input;\n if (input.stillCurrent?.() === false) return false;\n const execSql = runtime.infra.execSql;\n const pendingMoves = await readPendingMoves(input);\n if (pendingMoves.has(rootContainerId)) return false;\n const seen = new Set<string>([rootContainerId]);\n let currentId: string | null = containerId;\n let verifiedRemoteAncestry = false;\n while (currentId !== rootContainerId) {\n if (!currentId || seen.has(currentId) || pendingMoves.has(currentId))\n return false;\n seen.add(currentId);\n const expected = input.containersById.get(currentId);\n const current = await persistence.loadContainerMetadataState(\n execSql,\n currentId,\n );\n if (\n !expected ||\n !current?.record ||\n current.container.parentId !== expected.container.parentId ||\n current.container.organizationId !== expected.container.organizationId ||\n current.record.documentId !== expected.record.documentId\n )\n return false;\n if (current.record.documentId) {\n if (\n !(await verifiedRemoteScope(\n input,\n {\n container: current.container,\n record: current.record,\n },\n verifiedAncestorsById,\n ))\n )\n return false;\n verifiedRemoteAncestry = true;\n break;\n }\n currentId = current.container.parentId;\n }\n if (\n localOnlyUnit &&\n !verifiedRemoteAncestry &&\n !(await rootPlacementIsCurrent(input, verifiedAncestorsById))\n )\n return false;\n return readLocalPurgeScope({\n ...input,\n containerId,\n execSql,\n verifiedAncestorsById,\n });\n}\n\nasync function readPendingMoves(input: SubtreePurgeScopeInput) {\n return new Set(\n (\n await input.persistence.listUnsyncedMoveIntents(\n input.runtime.infra.execSql,\n )\n ).map((intent) => intent.containerId),\n );\n}\n\nasync function documentPlacementIsCurrent(\n input: SubtreePurgeScopeInput,\n document: DocumentSummary,\n): Promise<boolean> {\n const execSql = input.runtime.infra.execSql;\n if (await hasUnsettledDocumentPlacement(execSql, document.id)) return false;\n const current = await sqlDocumentsPersistence.loadDocument(\n execSql,\n document.id,\n );\n return (\n current !== null &&\n current.documentId === document.documentId &&\n current.containerId === document.containerId &&\n input.stillCurrent?.() !== false\n );\n}\n\n/** Listing edges only select candidates; each destructive unit proves its scope. */\nexport function createSubtreePurgeScope(request: SubtreePurgeScopeInput) {\n const input = {\n ...request,\n containersById: snapshotContainerStates(request.containersById),\n };\n const verifiedAncestorsById = new Map<string, readonly string[]>();\n return {\n allowsLocalScopeInTransaction: (execSql: ExecSql, containerId: string) =>\n checkAvailableScope(input, async () => {\n await assertLocalPurgeScope({\n ...input,\n execSql,\n containerId,\n verifiedAncestorsById,\n });\n return true;\n }),\n assertLocalScopeInTransaction: (\n execSql: ExecSql,\n containerId: string | null | undefined,\n localId: string,\n ) =>\n assertLocalPurgeScope({\n ...input,\n execSql,\n containerId,\n localId,\n verifiedAncestorsById,\n }),\n allowsContainer: (containerId: string) =>\n checkAvailableScope(input, () =>\n allowsContainer(\n input,\n containerId,\n verifiedAncestorsById,\n !input.containersById.get(containerId)?.record.documentId,\n ),\n ),\n allowsDocument: (document: DocumentSummary) =>\n checkAvailableScope(input, async () => {\n if (\n !document.containerId ||\n !(await documentPlacementIsCurrent(input, document))\n )\n return false;\n if (\n !(await allowsContainer(\n input,\n document.containerId,\n verifiedAncestorsById,\n !document.documentId,\n ))\n )\n return false;\n // Freeze local placement checks together after all remote verification.\n return readLocalPurgeScope(\n {\n ...input,\n containerId: document.containerId,\n execSql: input.runtime.infra.execSql,\n localId: document.id,\n verifiedAncestorsById,\n },\n document,\n );\n }),\n };\n}\n\nasync function checkAvailableScope(\n input: SubtreePurgeScopeInput,\n check: () => Promise<boolean>,\n): Promise<boolean> {\n try {\n return await check();\n } catch (error) {\n rethrowProjectionVerificationCancelled(error);\n if (error instanceof KeyingVerificationError) throw error;\n input.runtime.util.log(\n `Container contents: purge scope unavailable: ${errorMessage(error)}`,\n );\n return false;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"readLocalPurgeScope.js","sourceRoot":"","sources":["readLocalPurgeScope.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AACnG,OAAO,EAAE,iCAAiC,EAAE,MAAM,+CAA+C,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CACjC,KAAkD,EAClD,QAA0B;IAE1B,OAAO,wBAAwB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,CACrE,iCAAiC,CAAC,aAAa,CAAC,CAAC,WAAW,CAC1D,KAAK,IAAI,EAAE;QACT,MAAM,qBAAqB,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3B,MAAM,OAAO,GAAG,MAAM,uBAAuB,CAAC,YAAY,CACxD,aAAa,EACb,QAAQ,CAAC,EAAE,CACZ,CAAC;QACF,OAAO,CACL,OAAO,KAAK,IAAI;YAChB,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU;YAC1C,OAAO,CAAC,WAAW,KAAK,QAAQ,CAAC,WAAW;YAC5C,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK,CACjC,CAAC;IACJ,CAAC,EACD,EAAE,QAAQ,EAAE,WAAW,EAAE,CAC1B,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { DocumentSummary } from \"../../../data/documents/documentSummary\";\nimport { sqlDocumentsPersistence } from \"../../../data/persistence/documents/documentsPersistence\";\nimport { getClientSQLitePersistenceRuntime } from \"../../../data/sqlite/sqlitePersistenceRuntime\";\nimport { runSerializedSqlMutation } from \"../../../data/sqlite/sqlSchema\";\nimport { assertLocalPurgeScope } from \"./localPurgeScope\";\n\n/** Final local scope check before HTTP dispatch, with no remote I/O under lock. */\nexport function readLocalPurgeScope(\n input: Parameters<typeof assertLocalPurgeScope>[0],\n document?: DocumentSummary,\n): Promise<boolean> {\n return runSerializedSqlMutation(input.execSql, async (lockedExecSql) =>\n getClientSQLitePersistenceRuntime(lockedExecSql).transaction(\n async () => {\n await assertLocalPurgeScope({ ...input, execSql: lockedExecSql });\n if (!document) return true;\n const current = await sqlDocumentsPersistence.loadDocument(\n lockedExecSql,\n document.id,\n );\n return (\n current !== null &&\n current.documentId === document.documentId &&\n current.containerId === document.containerId &&\n input.stillCurrent?.() !== false\n );\n },\n { behavior: \"immediate\" },\n ),\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"share.js","sourceRoot":"","sources":["share.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EACL,wCAAwC,EAExC,+BAA+B,GAChC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,qCAAqC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAEL,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAc5B,SAAS,4BAA4B,CACnC,UAA6C,EAC7C,GAAW;IAEX,MAAM,KAAK,GAAG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,kBAAkB,EAAE,YAAY,CAAC,UAAU;QAC3C,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;QACxD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAErE,OAAO,2BAA2B,CAAC;QACjC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM;QACN,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,0BAA0B;KAC3B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n ContainerWriterProjectionResponse,\n ReferencedPrincipalStateResponse,\n} from \"@tearleads/validators/response\";\nimport {\n getTargetContainerContext,\n readContainerState,\n} from \"../../../data/containers/shared/projection\";\nimport { unwrapContainerKekPath } from \"../../../data/documents/shared/projection\";\nimport {\n nullOnProjectionVerificationCancellation,\n type ProjectionUserKeyResolver,\n verifyContainerWriterProjection,\n} from \"../../../data/keyingProjectionVerification\";\nimport { createRuntimePrincipalPolicyWarmer } from \"../../principals/runtimePolicyWarmer\";\nimport type { ContainerContentsPersistence } from \"../containerPersistence\";\nimport { projectionGeneration } from \"../projectionGeneration\";\nimport type { ContainerState } from \"../remoteHydration\";\nimport { resolveCurrentGroupKeyEpoch } from \"./groupShareEpoch\";\nimport { loadContainerWriterProjectionForState } from \"./projectionCache\";\nimport { shareRemoteContainer, shareRemoteContainerWithGroup } from \"./remote\";\nimport {\n type MatchingRemoteContainerGrant,\n persistDuplicateContainerShare,\n persistSharedContainerState,\n} from \"./sharePersistence\";\nimport type {\n ContainerWorkflowRuntime,\n SharedContainerStateResult,\n} from \"./types\";\n\ntype ContainerShareSubjectType = \"group\" | \"user\";\ntype ContainerShareAccessLevel = \"read\" | \"write\" | \"admin\";\n\ninterface RemoteContainerShareContext {\n matchingGrant: MatchingRemoteContainerGrant | null;\n projection: ContainerWriterProjectionResponse;\n}\n\nfunction readOptionalProjectionString(\n projection: ContainerWriterProjectionResponse,\n key: string,\n): string | null {\n const value = Reflect.get(projection, key);\n return typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\n// A container's KEK is wrapped to a group's encapsulation key at a specific key\n// epoch, pinned into the manifest as a referenced principal head. When the group\n// rotates (org-admin add or any removal bumps the epoch and mints a fresh KEM\n// keypair), that wrap goes stale: members holding only the new epoch secret can\n// no longer unwrap it. A re-share to the same group at the same access level is\n// therefore NOT redundant when the pinned epoch trails the group's current head,\n// so it must not be deduped away. The current epoch comes from a network-fresh,\n// fully verified current policy guarded by durable local checkpoints.\nfunction groupGrantIsStale(input: {\n currentKeyEpoch: number;\n referencedPrincipalHeads: ReadonlyArray<ReferencedPrincipalStateResponse>;\n subjectId: string;\n}): boolean {\n const pinnedHead = (input.referencedPrincipalHeads ?? []).find(\n (head) =>\n head.principalType === \"group\" && head.principalId === input.subjectId,\n );\n if (!pinnedHead) {\n return true;\n }\n return pinnedHead.keyEpoch !== input.currentKeyEpoch;\n}\n\nasync function loadRemoteContainerShareContext(input: {\n accessLevel: ContainerShareAccessLevel;\n containerState: ContainerState;\n expectedGroupName?: string | undefined;\n forceExistingGrantRewrap?: boolean | undefined;\n requireExistingGrant?: boolean | undefined;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n subjectId: string;\n subjectType: ContainerShareSubjectType;\n}): Promise<RemoteContainerShareContext | null> {\n if (input.stillCurrent?.() === false) return null;\n const projection = await loadContainerWriterProjectionForState({\n containerState: input.containerState,\n runtime: input.runtime,\n });\n if (!projection || input.stillCurrent?.() === false) {\n return null;\n }\n\n const target = getTargetContainerContext(projection);\n const remoteState = readContainerState(target.manifest);\n const hasMatchingGrant = remoteState.directGrants.some(\n (grant) =>\n grant.subjectType === input.subjectType &&\n grant.subjectId === input.subjectId &&\n grant.accessLevel === input.accessLevel,\n );\n if (!hasMatchingGrant) {\n if (input.requireExistingGrant) {\n // Re-wrap-only callers must never mint a brand-new grant: the container's\n // system slot is server-supplied and could point at a container that does\n // not already grant this subject, so minting here would leak its contents.\n input.runtime.util.log(\n `Container contents: refused to create a new ${input.subjectType} grant for ${input.subjectId} on container ${input.containerState.container.id} because the re-share requires an existing grant`,\n );\n return null;\n }\n return { matchingGrant: null, projection };\n }\n\n if (\n input.subjectType === \"group\" &&\n input.requireExistingGrant &&\n input.forceExistingGrantRewrap\n ) {\n // The cheap epoch probe below reads an unverified response and cannot prove\n // that a security-critical re-wrap is current. Force the verified policy\n // load and a real same-level mutation; failures must reach the retry owner.\n input.runtime.util.log(\n `Container contents: re-sharing container ${input.containerState.container.id} with group ${input.subjectId} because an existing grant re-wrap is required`,\n );\n return { matchingGrant: null, projection };\n }\n\n if (input.subjectType === \"group\") {\n const pinnedHead = remoteState.referencedPrincipalHeads.find(\n (head) =>\n head.principalType === \"group\" && head.principalId === input.subjectId,\n );\n const currentKeyEpoch = pinnedHead\n ? await resolveCurrentGroupKeyEpoch({\n expectedGroupName: input.expectedGroupName,\n groupId: input.subjectId,\n organizationId: remoteState.organizationId,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n })\n : null;\n if (input.stillCurrent?.() === false) return null;\n if (\n !pinnedHead ||\n (currentKeyEpoch !== null &&\n groupGrantIsStale({\n currentKeyEpoch,\n referencedPrincipalHeads: remoteState.referencedPrincipalHeads,\n subjectId: input.subjectId,\n }))\n ) {\n input.runtime.util.log(\n `Container contents: re-sharing container ${input.containerState.container.id} with group ${input.subjectId} because its key epoch advanced past the pinned grant`,\n );\n return { matchingGrant: null, projection };\n }\n }\n\n return {\n matchingGrant: {\n accessEpoch: remoteState.epoch,\n accessStateHash: target.manifest.manifestHash,\n createdAt: readOptionalProjectionString(projection, \"createdAt\"),\n metadataDocumentId: remoteState.metadataDocumentId,\n referencedPrincipalHeads: remoteState.referencedPrincipalHeads,\n updatedAt: readOptionalProjectionString(projection, \"updatedAt\"),\n },\n projection,\n };\n}\n\nasync function prepareContainerStateGroupRewrapInternal(input: {\n accessLevel: ContainerShareAccessLevel;\n containerState: ContainerState;\n groupId: string;\n requireExistingGrant?: boolean | undefined;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<\n | { status: \"not-granted\" }\n | {\n knownContainerKeks: ReadonlyMap<string, Uint8Array>;\n status: \"prepared\";\n }\n | null\n> {\n if (input.stillCurrent?.() === false) return null;\n const projection = await loadContainerWriterProjectionForState({\n containerState: input.containerState,\n runtime: input.runtime,\n });\n if (!projection || input.stillCurrent?.() === false) {\n return null;\n }\n\n if (input.requireExistingGrant) {\n await verifyContainerWriterProjection({\n execSql: input.runtime.infra.execSql,\n projection,\n resolveUserKey: input.resolveProjectionUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n input.runtime,\n ),\n });\n if (input.stillCurrent?.() === false) return null;\n const verifiedState = readContainerState(\n getTargetContainerContext(projection).manifest,\n );\n if (\n projection.containerId !== input.containerState.container.id ||\n projection.organizationId !==\n input.containerState.container.organizationId ||\n verifiedState.containerId !== input.containerState.container.id ||\n verifiedState.organizationId !==\n input.containerState.container.organizationId ||\n verifiedState.parentContainerId !==\n input.containerState.container.parentId\n ) {\n throw new Error(\n \"Prepared container group re-wrap target is inconsistent\",\n );\n }\n const hasGrant = verifiedState.directGrants.some(\n (grant) =>\n grant.subjectType === \"group\" &&\n grant.subjectId === input.groupId &&\n grant.accessLevel === input.accessLevel,\n );\n if (!hasGrant) {\n return { status: \"not-granted\" };\n }\n }\n\n const targetSecretKey =\n input.runtime.crypto.encapsulationKeyPair?.secretKey ?? null;\n if (!targetSecretKey) {\n return null;\n }\n\n const target = getTargetContainerContext(projection);\n const keksByEpochId = await unwrapContainerKekPath({\n execSql: input.runtime.infra.execSql,\n projection,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n secretKey: targetSecretKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n input.runtime,\n ),\n });\n if (input.stillCurrent?.() === false) return null;\n const targetKek = keksByEpochId.get(target.kek.containerKeyEpochId);\n return targetKek\n ? {\n knownContainerKeks: new Map([\n [target.kek.containerKeyEpochId, targetKek],\n ]),\n status: \"prepared\",\n }\n : null;\n}\n\nexport function prepareContainerStateGroupRewrap(\n input: Parameters<typeof prepareContainerStateGroupRewrapInternal>[0],\n): ReturnType<typeof prepareContainerStateGroupRewrapInternal> {\n return nullOnProjectionVerificationCancellation(() =>\n prepareContainerStateGroupRewrapInternal(input),\n );\n}\n\nexport async function shareContainerState(input: {\n accessLevel: ContainerShareAccessLevel;\n containerState: ContainerState;\n persistence: ContainerContentsPersistence;\n recipientUserId: string;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<SharedContainerStateResult | null> {\n if (input.stillCurrent?.() === false) return null;\n // Before the projection load and the share request: a hint that lands during\n // either must keep the resulting projection out of the cache.\n const writerProjectionGeneration = projectionGeneration(input.containerState);\n const shareContext = await loadRemoteContainerShareContext({\n accessLevel: input.accessLevel,\n containerState: input.containerState,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n subjectId: input.recipientUserId,\n subjectType: \"user\",\n });\n if (!shareContext || input.stillCurrent?.() === false) {\n return null;\n }\n if (shareContext.matchingGrant) {\n input.runtime.util.log(\n `Container contents: skipped duplicate share for container ${input.containerState.container.id} with user ${input.recipientUserId}`,\n );\n return persistDuplicateContainerShare({\n containerState: input.containerState,\n grant: shareContext.matchingGrant,\n persistence: input.persistence,\n projection: shareContext.projection,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n writerProjectionGeneration,\n });\n }\n\n const shared = await shareRemoteContainer({\n accessLevel: input.accessLevel,\n containerId: input.containerState.container.id,\n previousProjection: shareContext.projection,\n recipientUserId: input.recipientUserId,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n });\n\n if (!shared) return null;\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n\n return persistSharedContainerState({\n containerState: input.containerState,\n persistence: input.persistence,\n runtime: input.runtime,\n shared,\n stillCurrent: input.stillCurrent,\n writerProjectionGeneration,\n });\n}\n\nexport async function shareContainerStateWithGroup(input: {\n accessLevel: ContainerShareAccessLevel;\n containerState: ContainerState;\n expectedGroupName?: string | undefined;\n knownContainerKeks?: ReadonlyMap<string, Uint8Array> | undefined;\n persistence: ContainerContentsPersistence;\n recipientGroupId: string;\n // When set, a re-share only re-wraps an already-granted group and never mints\n // a new grant. Used by organization access repair so a server cannot redirect\n // the operation onto a container the group is not entitled to. A prepared\n // re-wrap also supplies captured KEKs and must submit a real mutation.\n requireExistingGrant?: boolean | undefined;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<SharedContainerStateResult | null> {\n // A share chosen by name must carry that name so it can be bound to the\n // signed group policy. Only the grant-preserving re-wrap, which never mints\n // a grant, may run without one. Enforced here, in the workflow facade, so\n // every caller (not only the store) meets the invariant.\n if (!input.requireExistingGrant && input.expectedGroupName === undefined) {\n throw new Error(\"Container group share requires the chosen group name\");\n }\n if (input.stillCurrent?.() === false) return null;\n // Before the projection load and the share request: a hint that lands during\n // either must keep the resulting projection out of the cache.\n const writerProjectionGeneration = projectionGeneration(input.containerState);\n const shareContext = await loadRemoteContainerShareContext({\n accessLevel: input.accessLevel,\n containerState: input.containerState,\n expectedGroupName: input.expectedGroupName,\n forceExistingGrantRewrap:\n input.requireExistingGrant && input.knownContainerKeks !== undefined,\n requireExistingGrant: input.requireExistingGrant,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n subjectId: input.recipientGroupId,\n subjectType: \"group\",\n });\n if (!shareContext || input.stillCurrent?.() === false) {\n return null;\n }\n if (shareContext.matchingGrant) {\n // A duplicate share mints nothing, but it must not report success for a\n // group the user did not choose. A matching grant is only found after the\n // key-epoch probe verified the group's policy with the chosen name bound,\n // so the name is already checked here.\n input.runtime.util.log(\n `Container contents: skipped duplicate share for container ${input.containerState.container.id} with group ${input.recipientGroupId}`,\n );\n return persistDuplicateContainerShare({\n containerState: input.containerState,\n grant: shareContext.matchingGrant,\n persistence: input.persistence,\n projection: shareContext.projection,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n writerProjectionGeneration,\n });\n }\n\n const shared = await shareRemoteContainerWithGroup({\n accessLevel: input.accessLevel,\n containerId: input.containerState.container.id,\n expectedGroupName: input.expectedGroupName,\n knownContainerKeks: input.knownContainerKeks,\n previousProjection: shareContext.projection,\n recipientGroupId: input.recipientGroupId,\n resolveProjectionUserKey: input.resolveProjectionUserKey,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n });\n\n if (!shared) return null;\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n\n return persistSharedContainerState({\n containerState: input.containerState,\n persistence: input.persistence,\n runtime: input.runtime,\n shared,\n stillCurrent: input.stillCurrent,\n writerProjectionGeneration,\n });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sharePersistence.js","sourceRoot":"","sources":["sharePersistence.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,wCAAwC,GACzC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAgBrE,6EAA6E;AAC7E,gFAAgF;AAChF,MAAM,CAAC,KAAK,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@tearleads/validators/response\";\nimport type { ContainerContentsPersistence } from \"../containerPersistence\";\nimport {\n type ContainerMetadataPatch,\n persistContainerMetadataStateFromRuntime,\n} from \"../metadata\";\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../metadata/metadataStateIsolation\";\nimport type { ContainerState } from \"../remoteHydration\";\nimport { installContainerWriterProjection } from \"./projectionCache\";\nimport type {\n ContainerWorkflowRuntime,\n SharedContainerStateResult,\n SharedRemoteContainerState,\n} from \"./types\";\n\nexport interface MatchingRemoteContainerGrant {\n accessEpoch: number;\n accessStateHash: string;\n createdAt: string | null;\n metadataDocumentId: string;\n referencedPrincipalHeads: ReadonlyArray<ReferencedPrincipalStateResponse>;\n updatedAt: string | null;\n}\n\n// These helpers run only after the remote grant is verified. A skipped local\n// install does not undo that acknowledgement; reconciliation installs it later.\nexport async function persistSharedContainerState(input: {\n containerState: ContainerState;\n persistence: ContainerContentsPersistence;\n runtime: ContainerWorkflowRuntime;\n shared: SharedRemoteContainerState;\n stillCurrent?: (() => boolean) | undefined;\n /** `writerProjectionGeneration` captured before the share flow began. */\n writerProjectionGeneration: number;\n}): Promise<SharedContainerStateResult | null> {\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n const candidateState = await createDetachedContainerMetadataState(\n input.containerState,\n { writerProjectionGeneration: input.writerProjectionGeneration },\n );\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n candidateState.container = {\n ...input.containerState.container,\n createdAt: input.shared.createdAt,\n serverCreatedAt: input.shared.createdAt,\n serverUpdatedAt: input.shared.updatedAt,\n updatedAt: input.shared.updatedAt,\n };\n\n const persisted = await persistContainerMetadataStateFromRuntime({\n metadataState: candidateState,\n patch: {\n accessEpoch: input.shared.accessEpoch,\n accessStateHash: input.shared.accessManifestHash,\n documentId: input.shared.metadataDocumentId,\n metadataDocumentId: input.shared.metadataDocumentId,\n contentKeyBundle: null,\n documentKekTargets: null,\n documentManifestBundle: null,\n },\n persistence: input.persistence,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n saveOptions: {\n serverTimestamps: {\n createdAt: input.shared.createdAt,\n updatedAt: input.shared.updatedAt,\n },\n },\n });\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n if (!persisted) return { status: \"missing\" };\n candidateState.container = persisted.container;\n installDetachedContainerMetadataState(input.containerState, candidateState, {\n candidateRecord: persisted.record,\n preserveConcurrentMetadataEdit: true,\n });\n if (persisted.mutationSuperseded || persisted.syncIdentitySuperseded) {\n return {\n container: input.containerState.container,\n record: input.containerState.record,\n status: \"identity-superseded\",\n };\n }\n installContainerWriterProjection(\n input.containerState,\n input.shared.writerProjection,\n input.writerProjectionGeneration,\n );\n return {\n container: input.containerState.container,\n record: input.containerState.record,\n status: \"persisted\",\n };\n}\n\nexport async function persistDuplicateContainerShare(input: {\n containerState: ContainerState;\n grant: MatchingRemoteContainerGrant;\n persistence: ContainerContentsPersistence;\n projection: ContainerWriterProjectionResponse;\n runtime: ContainerWorkflowRuntime;\n stillCurrent?: (() => boolean) | undefined;\n /** `writerProjectionGeneration` captured before the share flow began. */\n writerProjectionGeneration: number;\n}): Promise<SharedContainerStateResult | null> {\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n const candidateState = await createDetachedContainerMetadataState(\n input.containerState,\n { writerProjectionGeneration: input.writerProjectionGeneration },\n );\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n candidateState.container = {\n ...input.containerState.container,\n ...(input.grant.createdAt\n ? {\n createdAt: input.grant.createdAt,\n serverCreatedAt: input.grant.createdAt,\n }\n : {}),\n ...(input.grant.updatedAt\n ? {\n serverUpdatedAt: input.grant.updatedAt,\n updatedAt: input.grant.updatedAt,\n }\n : {}),\n };\n const securityContextChanged =\n candidateState.record.documentId !== input.grant.metadataDocumentId ||\n candidateState.record.accessEpoch !== input.grant.accessEpoch ||\n candidateState.record.accessStateHash !== input.grant.accessStateHash;\n const patch: Partial<ContainerMetadataPatch> = {\n accessEpoch: input.grant.accessEpoch,\n accessStateHash: input.grant.accessStateHash,\n documentId: input.grant.metadataDocumentId,\n metadataDocumentId: input.grant.metadataDocumentId,\n ...(securityContextChanged\n ? {\n contentKeyBundle: null,\n documentKekTargets: null,\n documentManifestBundle: null,\n }\n : {}),\n };\n const persisted = await persistContainerMetadataStateFromRuntime({\n metadataState: candidateState,\n patch,\n persistence: input.persistence,\n runtime: input.runtime,\n stillCurrent: input.stillCurrent,\n saveOptions: {\n serverTimestamps: {\n createdAt: input.grant.createdAt,\n updatedAt: input.grant.updatedAt,\n },\n },\n });\n if (input.stillCurrent?.() === false) return { status: \"confirmed\" };\n if (!persisted) return { status: \"missing\" };\n candidateState.container = persisted.container;\n installDetachedContainerMetadataState(input.containerState, candidateState, {\n candidateRecord: persisted.record,\n preserveConcurrentMetadataEdit: true,\n });\n if (persisted.mutationSuperseded || persisted.syncIdentitySuperseded) {\n return {\n container: input.containerState.container,\n record: input.containerState.record,\n status: \"identity-superseded\",\n };\n }\n installContainerWriterProjection(\n input.containerState,\n input.projection,\n input.writerProjectionGeneration,\n );\n return {\n container: input.containerState.container,\n record: input.containerState.record,\n status: \"persisted\",\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"childIndex.js","sourceRoot":"","sources":["childIndex.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,wBAAwB,CACtC,kBAAuC,EACvC,WAAmB,EACnB,QAAuB;IAEvB,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,GAAG,EAAU,CAAC;IACvE,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC1B,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,kBAAuC,EACvC,WAAmB,EACnB,QAAuB;IAEvB,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IAED,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7B,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,kBAAmD,EACnD,WAAmB,EACnB,gBAA+B,EAC/B,YAA2B;IAE3B,IAAI,CAAC,kBAAkB,IAAI,gBAAgB,KAAK,YAAY,EAAE,CAAC;QAC7D,OAAO;IACT,CAAC;IAED,2BAA2B,CACzB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,CACjB,CAAC;IACF,wBAAwB,CAAC,kBAAkB,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,cAAmD;IAEnD,MAAM,kBAAkB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAE1D,KAAK,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,IAAI,cAAc,EAAE,CAAC;QAC3D,wBAAwB,CACtB,kBAAkB,EAClB,WAAW,EACX,cAAc,CAAC,SAAS,CAAC,QAAQ,CAClC,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["import type { ContainerChildIndex, ContainerState } from \"./types\";\n\nexport function addIndexedContainerChild(\n childIdsByParentId: ContainerChildIndex,\n containerId: string,\n parentId: string | null,\n) {\n if (parentId === null) {\n return;\n }\n\n const childIds = childIdsByParentId.get(parentId) ?? new Set<string>();\n childIds.add(containerId);\n childIdsByParentId.set(parentId, childIds);\n}\n\nexport function removeIndexedContainerChild(\n childIdsByParentId: ContainerChildIndex,\n containerId: string,\n parentId: string | null,\n) {\n if (parentId === null) {\n return;\n }\n\n const childIds = childIdsByParentId.get(parentId);\n if (!childIds) {\n return;\n }\n\n childIds.delete(containerId);\n if (childIds.size === 0) {\n childIdsByParentId.delete(parentId);\n }\n}\n\nexport function moveIndexedContainerChild(\n childIdsByParentId: ContainerChildIndex | undefined,\n containerId: string,\n previousParentId: string | null,\n nextParentId: string | null,\n) {\n if (!childIdsByParentId || previousParentId === nextParentId) {\n return;\n }\n\n removeIndexedContainerChild(\n childIdsByParentId,\n containerId,\n previousParentId,\n );\n addIndexedContainerChild(childIdsByParentId, containerId, nextParentId);\n}\n\nexport function createContainerChildIndex(\n containersById: ReadonlyMap<string, ContainerState>,\n): ContainerChildIndex {\n const childIdsByParentId: ContainerChildIndex = new Map();\n\n for (const [containerId, containerState] of containersById) {\n addIndexedContainerChild(\n childIdsByParentId,\n containerId,\n containerState.container.parentId,\n );\n }\n\n return childIdsByParentId;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"containerStateFingerprint.js","sourceRoot":"","sources":["containerStateFingerprint.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAAqB;IACnE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,KAGhD;IACC,OAAO,CACL,CAAC,KAAK,CAAC,YAAY;QACjB,CAAC,CAAC,+BAA+B,CAAC,KAAK,CAAC,YAAY,CAAC;QACrD,CAAC,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,mBAAmB,CAC7C,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerState } from \"./types\";\n\n/**\n * Immutable request-time identity for one live container state. Hydration\n * mutates ContainerState objects in place, so retaining the object reference is\n * not enough to detect a newer local or remote commit while a page is fetched.\n */\nexport function createContainerStateFingerprint(state: ContainerState): string {\n return JSON.stringify([state.container, state.record]);\n}\n\nexport function containerStateMatchesFingerprint(input: {\n currentState: ContainerState | undefined;\n expectedFingerprint: string | undefined;\n}): boolean {\n return (\n (input.currentState\n ? createContainerStateFingerprint(input.currentState)\n : undefined) === input.expectedFingerprint\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationPrefetch.js","sourceRoot":"","sources":["destinationPrefetch.ts"],"names":[],"mappings":"AAQA,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,KAIpD;IACC,MAAM,UAAU,GAAG,IAAI,GAAG,EAA2C,CAAC;IACtE,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,KAAK,IAAmB,EAAE;QAC1C,KACE,IAAI,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,EACjC,WAAW,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAC1D,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,EAC7B,CAAC;YACD,IAAI,CAAC;gBACH,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE;oBAC1B,UAAU,EACR,MAAM,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,4BAA4B,CACxD,WAAW,CACZ;iBACJ,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,8DAA8D;YAChE,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CACR,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,gCAAgC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,EACtE,SAAS,CACV,CACF,CAAC;IACF,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { ContainerWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport type { RemoteContainerHydrationState } from \"./types\";\n\n/** A projection fetched ahead of sequential verification. */\nexport interface PrefetchedDestinationProjection {\n readonly projection: ContainerWriterProjectionResponse | null;\n}\n\nconst DESTINATION_PREFETCH_CONCURRENCY = 4;\n\n/**\n * Fetch the writer projections of newly discovered folders with bounded\n * concurrency, so a fresh device does not pay one round trip per folder in\n * series. Verification stays sequential and consumes these results. A failed\n * fetch is omitted: verification refetches and reports it.\n */\nexport async function prefetchDestinationProjections(input: {\n containerIds: ReadonlyArray<string>;\n isCurrent?: (() => boolean) | undefined;\n runtime: RemoteContainerHydrationState[\"runtime\"];\n}): Promise<ReadonlyMap<string, PrefetchedDestinationProjection>> {\n const prefetched = new Map<string, PrefetchedDestinationProjection>();\n const pending = [...input.containerIds];\n const fetchNext = async (): Promise<void> => {\n for (\n let containerId = pending.shift();\n containerId !== undefined && input.isCurrent?.() !== false;\n containerId = pending.shift()\n ) {\n try {\n prefetched.set(containerId, {\n projection:\n await input.runtime.apiClient.getContainerWriterProjection(\n containerId,\n ),\n });\n } catch {\n // Verification refetches this folder and reports the failure.\n }\n }\n };\n await Promise.all(\n Array.from(\n { length: Math.min(DESTINATION_PREFETCH_CONCURRENCY, pending.length) },\n fetchNext,\n ),\n );\n return prefetched;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationRoleCache.js","sourceRoot":"","sources":["destinationRoleCache.ts"],"names":[],"mappings":"AAmBA,MAAM,eAAe,GAAG,IAAI,OAAO,EAA6B,CAAC;AACjE,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB,SAAS,cAAc,CAAC,QAA6B;IACnD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAAgB,EAChB,MAA2B;IAE3B,MAAM,KAAK,GAAG,eAAe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,EAAE,CAAC,KAAK,CAAC;QACzC,IAAI,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport type { RemoteContainer } from \"./types\";\n\nexport interface DestinationRole\n extends Pick<RemoteContainer, \"metadataDocumentId\" | \"systemSlot\"> {\n /** Fixed parent only for roots/system slots; ordinary parent edges can move. */\n readonly parentId?: string | null;\n /** Signer of the epoch-1 `container.create`; immutable through successors. */\n readonly createSignerUserId: string;\n readonly rootContainerId: string;\n readonly rootCreateManifestHash: string;\n readonly rootMetadataDocumentId: string;\n}\n/** Roles are verified and cached under the container's id and organization. */\ntype DestinationIdentity = Pick<RemoteContainer, \"id\" | \"organizationId\">;\ninterface DestinationRoles {\n fixed: Map<string, DestinationRole>;\n ordinary: Map<string, DestinationRole>;\n}\nconst rolesByDatabase = new WeakMap<ExecSql, DestinationRoles>();\nconst MAX_ROLES = 1_000;\n\nfunction destinationKey(identity: DestinationIdentity): string {\n return JSON.stringify([identity.organizationId, identity.id]);\n}\n\nexport function cachedDestinationRole(\n execSql: ExecSql,\n listed: DestinationIdentity,\n): DestinationRole | undefined {\n const roles = rolesByDatabase.get(execSql);\n const key = destinationKey(listed);\n return roles?.fixed.get(key) ?? roles?.ordinary.get(key);\n}\n\nexport function rememberDestinationRole(\n execSql: ExecSql,\n listed: DestinationIdentity,\n role: DestinationRole,\n): void {\n // Shared verification forbids moves of roots and system containers, and all\n // successors preserve the signed slot, metadata id and creator. Cache only\n // these immutable fields; authority, key material and ordinary parent edges\n // remain outside this cache. Reuse does not authorize any read or write\n // operation, so logout and identity switches do not need to invalidate these\n // roles: the session-root creator check runs on every reuse.\n if (\n role.parentId !== undefined &&\n role.parentId !== null &&\n role.systemSlot === null\n ) {\n throw new Error(\n \"Ordinary container parents cannot enter the immutable binding cache\",\n );\n }\n let cache = rolesByDatabase.get(execSql);\n if (!cache) {\n cache = { fixed: new Map(), ordinary: new Map() };\n rolesByDatabase.set(execSql, cache);\n }\n // Ordinary directory growth must not evict root/system reconciliation roles.\n // Both buckets are bounded independently.\n const roles = role.parentId === undefined ? cache.ordinary : cache.fixed;\n const key = destinationKey(listed);\n if (roles.size >= MAX_ROLES && !roles.has(key)) {\n const oldest = roles.keys().next().value;\n if (oldest !== undefined) roles.delete(oldest);\n }\n roles.set(key, role);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationRootReload.js","sourceRoot":"","sources":["destinationRootReload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAE/F;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAI3C,KAAY,EACZ,OAA0C,EAC1C,SAAqB;IAErB,OAAO,sBAAsB,CAC3B,CAAC,MAAM,EAAE,EAAE,CACT,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EACzE,SAAS,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { withMetadataRootReload } from \"../../organizations/groupMetadata/groupMetadataErrors\";\n\n/**\n * Reads a destination again once when its metadata root was behind the\n * directory. A prefetched projection is that same stale root, so the reread\n * drops it and fetches after `evictRoot` clears the cached one.\n */\nexport function resolveWithMetadataRootReload<\n Input extends { readonly prefetchedProjection?: unknown },\n Result,\n>(\n input: Input,\n resolve: (input: Input) => Promise<Result>,\n evictRoot: () => void,\n): Promise<Result> {\n return withMetadataRootReload(\n (reread) =>\n resolve(reread ? { ...input, prefetchedProjection: undefined } : input),\n evictRoot,\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"insertRemoteContainer.js","sourceRoot":"","sources":["insertRemoteContainer.ts"],"names":[],"mappings":"AACA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,eAAe,CAAC,kBAAkB,CAAC;SAC1D,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,uCAAuC,CAAC;YACjE,eAAe,EAAE,kBAAkB;SACpC,CAAC,CAAC;QACH,IACE,CAAC,YAAY;YACb,CAAC,CAAC,MAAM,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,EACjE,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,cAAc,GAAG,YAAY,CAAC;QAC9B,cAAc,CAAC,4BAA4B;YACzC,eAAe,CAAC,4BAA4B,CAAC;IACjD,CAAC;IACD,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC7D,IAAI,kBAAkB,EAAE,CAAC;QACvB,wBAAwB,CACtB,kBAAkB,EAClB,eAAe,CAAC,EAAE,EAClB,cAAc,CAAC,SAAS,CAAC,QAAQ,CAClC,CAAC;IACJ,CAAC;IACD,MAAM,gCAAgC,CAAC;QACrC,kBAAkB;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,eAAe,EAAE,cAAc;QAC/B,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;QACnD,KAAK;KACN,CAAC,CAAC;IACH,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import type { AccessManifestCheckpoint } from \"@tearleads/crypto\";\nimport {\n assertHeldContainerBinding,\n heldContainerBinding,\n} from \"../../../data/containers/containerBinding\";\nimport {\n createContainerMetadataDocument,\n getDefaultContainerName,\n} from \"../../../data/containers/containerMetadataDocument\";\nimport type { ContainerHydrationTombstone } from \"../containerPersistence\";\nimport { materializeStoredContainerStateReadOnly } from \"../storedContainerState\";\nimport { addIndexedContainerChild } from \"./childIndex\";\nimport { reattachDormantContainerMetadata } from \"./reattachMetadata\";\nimport { reconcileLocalOnlyRootContainers } from \"./reconciliation\";\nimport {\n applyRemoteContainerTimestamps,\n remoteContainerHydrationSaveOptions,\n} from \"./remoteContainerTimestamps\";\nimport type {\n ContainerChildIndex,\n ContainerState,\n RemoteContainer,\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"./types\";\n\ninterface InsertRemoteContainerStateInput {\n childIdsByParentId?: ContainerChildIndex | undefined;\n host: RemoteContainerHydrationHost;\n expectedHydrationTombstone: ContainerHydrationTombstone | null;\n expectedPlacementCheckpoint?: AccessManifestCheckpoint | undefined;\n isCurrent?: (() => boolean) | undefined;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}\n\nfunction createInsertedRemoteContainerState(input: {\n doc: ContainerState[\"doc\"];\n dormantRecord: Awaited<\n ReturnType<\n RemoteContainerHydrationState[\"persistence\"][\"loadContainerMetadataRecord\"]\n >\n >;\n remoteContainer: RemoteContainer;\n}): ContainerState {\n const { doc, dormantRecord, remoteContainer } = input;\n const reattached = reattachDormantContainerMetadata({\n defaultName: getDefaultContainerName(remoteContainer.parentId),\n doc,\n dormantRecord,\n remoteMetadataDocumentId: remoteContainer.metadataDocumentId,\n });\n return {\n container: applyRemoteContainerTimestamps(\n {\n id: remoteContainer.id,\n effectiveAccessLevel: remoteContainer.effectiveAccessLevel,\n organizationId: remoteContainer.organizationId,\n parentId: remoteContainer.parentId,\n metadataDocumentId: remoteContainer.metadataDocumentId,\n systemSlot: remoteContainer.systemSlot ?? null,\n name: reattached.name,\n icon: reattached.icon,\n },\n remoteContainer,\n ),\n metadataReferencedPrincipals: remoteContainer.metadataReferencedPrincipals,\n doc,\n record: {\n accessEpoch: remoteContainer.metadataAccessEpoch,\n accessStateHash: remoteContainer.metadataAccessStateHash,\n documentId: remoteContainer.metadataDocumentId,\n id: remoteContainer.id,\n lastCommitLsn: reattached.lastCommitLsn,\n metadataUpdates: reattached.initialSnapshot,\n ...(reattached.pullContinuation === undefined\n ? {}\n : { pullContinuation: reattached.pullContinuation }),\n ...(reattached.pullContinuationRecoveryRequired\n ? { pullContinuationRecoveryRequired: true as const }\n : {}),\n snapshotEndVersion: reattached.snapshotEndVersion,\n contentKeyBundle: null,\n documentKekTargets: null,\n documentManifestBundle: null,\n },\n };\n}\n\n/**\n * Insert a verified container the device holds no live row for, re-attaching\n * retained dormant metadata whose binding matches.\n */\nexport async function insertRemoteContainerState(\n input: InsertRemoteContainerStateInput,\n): Promise<ContainerState | null> {\n const { childIdsByParentId, host, remoteContainer, state } = input;\n const execSql = state.runtime.infra.execSql;\n const persistence = state.persistence;\n const doc = await createContainerMetadataDocument(remoteContainer.id);\n if (input.isCurrent?.() === false) {\n return null;\n }\n // A container inserted with dormant retained metadata (row 4's\n // access_revoked branch) is a re-attach, not a fresh discovery: import the\n // retained content and markers instead of overwriting them with an empty\n // document. Access and keying fields still come from the remote container —\n // revocation may have rotated them.\n const dormantRecord = await persistence.loadContainerMetadataRecord(\n execSql,\n remoteContainer.id,\n );\n if (input.isCurrent?.() === false) {\n return null;\n }\n // Destination verification refused a relisting that conflicts with the\n // retained organization or metadata target. A record committed since then\n // by a concurrent hydration is refused here; commit rechecks both durably.\n assertHeldContainerBinding(\n {\n organizationId: \"\",\n metadataDocumentId: dormantRecord?.documentId ?? null,\n },\n {\n organizationId: remoteContainer.organizationId,\n metadataDocumentIds: [remoteContainer.metadataDocumentId],\n },\n );\n const containerState = createInsertedRemoteContainerState({\n doc,\n dormantRecord,\n remoteContainer,\n });\n\n const committed = await persistence.commitHydratedContainer(execSql, {\n container: containerState.container,\n expectedDormantRecord: dormantRecord,\n expectedHydrationTombstone: input.expectedHydrationTombstone,\n expectedPlacementCheckpoint: input.expectedPlacementCheckpoint,\n record: containerState.record,\n remoteUpdatedAt: remoteContainer.updatedAt,\n saveOptions: remoteContainerHydrationSaveOptions({ remoteContainer }),\n stillCurrent: input.isCurrent,\n });\n let installedState = containerState;\n if (committed.committed) {\n installedState.container = committed.container;\n } else {\n const winningStoredState = await persistence.loadContainerMetadataState(\n execSql,\n remoteContainer.id,\n );\n if (!winningStoredState) return null;\n // A concurrent hydration that won the insert holds the binding now.\n assertHeldContainerBinding(heldContainerBinding(winningStoredState), {\n organizationId: remoteContainer.organizationId,\n metadataDocumentIds: [remoteContainer.metadataDocumentId],\n });\n const winningState = await materializeStoredContainerStateReadOnly({\n storedContainer: winningStoredState,\n });\n if (\n !winningState ||\n !(await persistence.containerExists(execSql, remoteContainer.id))\n ) {\n return null;\n }\n installedState = winningState;\n installedState.metadataReferencedPrincipals =\n remoteContainer.metadataReferencedPrincipals;\n }\n if (input.isCurrent?.() === false) {\n return null;\n }\n state.containersById.set(remoteContainer.id, installedState);\n if (childIdsByParentId) {\n addIndexedContainerChild(\n childIdsByParentId,\n remoteContainer.id,\n installedState.container.parentId,\n );\n }\n await reconcileLocalOnlyRootContainers({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n remoteRootState: installedState,\n requestDocumentPriming: host.requestDocumentPriming,\n state,\n });\n return installedState;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"laneFetchMarkers.js","sourceRoot":"","sources":["laneFetchMarkers.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qCAAqC,GACtC,MAAM,yBAAyB,CAAC;AAGjC,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,KAKpD;IACC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC5C,IAAI,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yEAAyE;IACzE,2EAA2E;IAC3E,mDAAmD;IACnD,MAAM,QAAQ,GAAG,MAAM,qCAAqC,CAC1D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAC3B,QAAQ,EACR,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,aAAa,EAAE,EACjE,KAAK,CAAC,SAAS,CAChB,CAAC;IACF,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IACE,CAAC,QAAQ,CAAC,OAAO;QACjB,QAAQ,CAAC,IAAI,KAAK,kBAAkB;QACpC,QAAQ,CAAC,QAAQ,KAAK,IAAI,EAC1B,CAAC;QACD,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { ListContainersResponse } from \"@tearleads/validators/response\";\nimport {\n type ContainerSyncWatermarkLane,\n recordContainerSyncLaneFetchIfCurrent,\n} from \"../containerPersistence\";\nimport type { RemoteContainerHydrationState } from \"./types\";\n\nexport async function markContainerParentLaneFetched(input: {\n isCurrent?: (() => boolean) | undefined;\n response: ListContainersResponse;\n state: RemoteContainerHydrationState;\n syncLane: ContainerSyncWatermarkLane;\n}): Promise<boolean> {\n const { response, state, syncLane } = input;\n if (response.hasMore && !response.nextWatermark) {\n return false;\n }\n\n // A check marker suppresses startup polling, so record it only after the\n // server confirms this parent lane is fully drained. The cursor and marker\n // share one row and land in one guarded statement.\n const recorded = await recordContainerSyncLaneFetchIfCurrent(\n state.runtime.infra.execSql,\n syncLane,\n { checked: !response.hasMore, watermark: response.nextWatermark },\n input.isCurrent,\n );\n if (!recorded || input.isCurrent?.() === false) {\n return false;\n }\n if (\n !response.hasMore &&\n syncLane.kind === \"container_parent\" &&\n syncLane.parentId === null\n ) {\n state.rootLaneHydrated = true;\n }\n\n return true;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parentLaneFetch.js","sourceRoot":"","sources":["parentLaneFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,yBAAyB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AC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QACD,OAAO;YACL,uBAAuB;YACvB,2BAA2B;YAC3B,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,YAAY,CAAC,QAAQ;SAChC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n createContainerParentSyncLane,\n loadContainerSyncWatermark,\n} from \"../containerPersistence\";\nimport { createContainerStateFingerprint } from \"./containerStateFingerprint\";\nimport type {\n ContainerParentHydrationLane,\n FetchedContainerParentLanePage,\n RemoteContainerHydrationState,\n} from \"./types\";\n\nasync function prepareContainerParentLanePage(input: {\n lane: ContainerParentHydrationLane;\n laneId: string;\n state: RemoteContainerHydrationState;\n}) {\n const { lane, laneId, state } = input;\n const syncLane = createContainerParentSyncLane(lane.parentId);\n const watermark =\n lane.watermark === undefined\n ? await loadContainerSyncWatermark(state.runtime.infra.execSql, syncLane)\n : lane.watermark;\n return {\n lane,\n request: { laneId, parentId: lane.parentId, watermark },\n syncLane,\n };\n}\n\nexport async function fetchContainerParentLaneBatch(input: {\n batch: ReadonlyArray<ContainerParentHydrationLane>;\n isCurrent?: (() => boolean) | undefined;\n state: RemoteContainerHydrationState;\n}): Promise<ReadonlyArray<FetchedContainerParentLanePage> | null> {\n const { batch, state } = input;\n const expectedContainerStates = new Map(\n Array.from(state.containersById, ([containerId, containerState]) => [\n containerId,\n {\n container: { ...containerState.container },\n fingerprint: createContainerStateFingerprint(containerState),\n },\n ]),\n );\n const preparedPages = await Promise.all(\n batch.map((lane, index) =>\n prepareContainerParentLanePage({\n lane,\n laneId: `lane-${index}`,\n state,\n }),\n ),\n );\n if (input.isCurrent?.() === false) {\n return null;\n }\n const expectedHydrationTombstones = new Map(\n (\n await state.persistence.loadContainerHydrationTombstones(\n state.runtime.infra.execSql,\n )\n ).map((tombstone) => [tombstone.containerId, tombstone]),\n );\n if (input.isCurrent?.() === false) {\n return null;\n }\n const response = await state.runtime.apiClient.listContainerParentLanes({\n lanes: preparedPages.map((page) => page.request),\n });\n if (!response) {\n return null;\n }\n\n const pagesByLaneId = new Map(\n response.results.map((result) => [result.laneId, result.page]),\n );\n if (\n pagesByLaneId.size !== preparedPages.length ||\n response.results.length !== preparedPages.length\n ) {\n throw new Error(\"Container parent lane batch response mismatch\");\n }\n\n return preparedPages.map((preparedPage) => {\n const page = pagesByLaneId.get(preparedPage.request.laneId);\n if (!page) {\n throw new Error(\"Container parent lane batch response mismatch\");\n }\n return {\n expectedContainerStates,\n expectedHydrationTombstones,\n lane: preparedPage.lane,\n response: page,\n syncLane: preparedPage.syncLane,\n };\n });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parentLaneQueue.js","sourceRoot":"","sources":["parentLaneQueue.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,mCAAmC,CAAC,KAKnD;IAIC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,MAAM,KAAK,GAAmC,EAAE,CAAC;IACjD,MAAM,eAAe,GAAG,CAAC,QAAuB,EAAE,EAAE;QAClD,MAAM,OAAO,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,QAAQ,EAAE,CAAC;QACrE,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,uEAAuE;QACvE,wEAAwE;QACxE,mDAAmD;QACnD,MAAM,cAAc,GAClB,KAAK,CAAC,sBAAsB;YAC5B,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACtD,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC;IAEF,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACpB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YAC7C,eAAe,CAAC,WAAW,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import type {\n ContainerParentHydrationLane,\n QueueContainerParentLane,\n} from \"./types\";\n\nexport function createContainerParentHydrationQueue(input: {\n containerIds: Iterable<string>;\n parentIds?: Iterable<string | null> | undefined;\n resetAllLaneWatermarks?: boolean | undefined;\n resetRootLaneWatermark?: boolean | undefined;\n}): {\n lanes: ContainerParentHydrationLane[];\n queueParentLane: QueueContainerParentLane;\n} {\n const queuedParentIds = new Set<string>();\n const lanes: ContainerParentHydrationLane[] = [];\n const queueParentLane = (parentId: string | null) => {\n const laneKey = parentId === null ? \"root\" : `container:${parentId}`;\n if (queuedParentIds.has(laneKey)) {\n return;\n }\n\n queuedParentIds.add(laneKey);\n // A restoration crawl resets every lane: a newly re-granted descendant\n // does not advance its parent's persisted watermark. Ordinary discovery\n // refreshes only need to reset the top-level lane.\n const resetWatermark =\n input.resetAllLaneWatermarks ||\n (parentId === null && input.resetRootLaneWatermark);\n lanes.push(resetWatermark ? { parentId, watermark: null } : { parentId });\n };\n\n if (input.parentIds) {\n for (const parentId of input.parentIds) {\n queueParentLane(parentId);\n }\n } else {\n queueParentLane(null);\n for (const containerId of input.containerIds) {\n queueParentLane(containerId);\n }\n }\n\n return { lanes, queueParentLane };\n}\n"]}