spawnfile 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -11
- package/dist/audit/auditCli.d.ts +19 -0
- package/dist/audit/auditCli.js +63 -0
- package/dist/audit/checks.d.ts +100 -0
- package/dist/audit/checks.js +279 -0
- package/dist/audit/checksShared.d.ts +74 -0
- package/dist/audit/checksShared.js +37 -0
- package/dist/audit/generateAudit.d.ts +19 -0
- package/dist/audit/generateAudit.js +122 -0
- package/dist/audit/index.d.ts +4 -0
- package/dist/audit/index.js +4 -0
- package/dist/audit/readAudit.d.ts +50 -0
- package/dist/audit/readAudit.js +59 -0
- package/dist/audit/types.d.ts +40 -0
- package/dist/audit/types.js +8 -0
- package/dist/auth/credentialEnvFile.d.ts +11 -0
- package/dist/auth/credentialEnvFile.js +60 -0
- package/dist/auth/credentialProvisioning.d.ts +15 -0
- package/dist/auth/credentialProvisioning.js +75 -0
- package/dist/auth/credentialProvisioningReceipt.d.ts +28 -0
- package/dist/auth/credentialProvisioningReceipt.js +70 -0
- package/dist/auth/credentialProvisioningRequest.d.ts +51 -0
- package/dist/auth/credentialProvisioningRequest.js +169 -0
- package/dist/auth/credentialWorldBindings.d.ts +21 -0
- package/dist/auth/credentialWorldBindings.js +104 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.js +7 -0
- package/dist/auth/paths.d.ts +11 -0
- package/dist/auth/paths.js +21 -0
- package/dist/auth/targetSecretSourceAuthor.d.ts +18 -0
- package/dist/auth/targetSecretSourceAuthor.js +52 -0
- package/dist/auth/targetSecretSourceFsPublish.d.ts +15 -0
- package/dist/auth/targetSecretSourceFsPublish.js +49 -0
- package/dist/auth/targetSecretSourceFsPublishImmutable.d.ts +16 -0
- package/dist/auth/targetSecretSourceFsPublishImmutable.js +435 -0
- package/dist/auth/targetSecretSourceFsRead.d.ts +14 -0
- package/dist/auth/targetSecretSourceFsRead.js +198 -0
- package/dist/auth/targetSecretSourceGrant.d.ts +16 -0
- package/dist/auth/targetSecretSourceGrant.js +99 -0
- package/dist/auth/targetSecretSourceGrantRecords.d.ts +84 -0
- package/dist/auth/targetSecretSourceGrantRecords.js +214 -0
- package/dist/auth/targetSecretSourceLifecycle.d.ts +30 -0
- package/dist/auth/targetSecretSourceLifecycle.js +52 -0
- package/dist/auth/targetSecretSourceOwnerEntropy.d.ts +6 -0
- package/dist/auth/targetSecretSourceOwnerEntropy.js +28 -0
- package/dist/auth/targetSecretSourceRecordCommon.d.ts +14 -0
- package/dist/auth/targetSecretSourceRecordCommon.js +100 -0
- package/dist/auth/targetSecretSourceRecordPublish.d.ts +10 -0
- package/dist/auth/targetSecretSourceRecordPublish.js +104 -0
- package/dist/auth/targetSecretSourceResolver.d.ts +10 -0
- package/dist/auth/targetSecretSourceResolver.js +137 -0
- package/dist/auth/targetSecretSourceRevoke.d.ts +20 -0
- package/dist/auth/targetSecretSourceRevoke.js +92 -0
- package/dist/auth/targetSecretSourceRotate.d.ts +19 -0
- package/dist/auth/targetSecretSourceRotate.js +121 -0
- package/dist/auth/targetSecretSourceVersionRecords.d.ts +49 -0
- package/dist/auth/targetSecretSourceVersionRecords.js +166 -0
- package/dist/cli/artifactsCommands.d.ts +27 -0
- package/dist/cli/artifactsCommands.js +132 -0
- package/dist/cli/authCommands.d.ts +5 -0
- package/dist/cli/authCommands.js +221 -0
- package/dist/cli/compileBuildCommands.d.ts +3 -0
- package/dist/cli/compileBuildCommands.js +35 -0
- package/dist/cli/containerBundleCommand.d.ts +6 -0
- package/dist/cli/containerBundleCommand.js +116 -0
- package/dist/cli/downCommand.d.ts +25 -0
- package/dist/cli/downCommand.js +134 -0
- package/dist/cli/index.js +6 -3
- package/dist/cli/lifecycleCommands.d.ts +1 -1
- package/dist/cli/lifecycleCommands.js +11 -181
- package/dist/cli/lifecycleMachine.d.ts +19 -0
- package/dist/cli/lifecycleMachine.js +78 -0
- package/dist/cli/lifecyclePlan.d.ts +35 -0
- package/dist/cli/lifecyclePlan.js +240 -0
- package/dist/cli/lifecyclePlanningCommands.d.ts +3 -0
- package/dist/cli/lifecyclePlanningCommands.js +30 -0
- package/dist/cli/runCli.d.ts +9 -2
- package/dist/cli/runCli.js +27 -71
- package/dist/cli/runPublishCommands.d.ts +3 -0
- package/dist/cli/runPublishCommands.js +70 -0
- package/dist/cli/statusCommand.d.ts +3 -33
- package/dist/cli/statusCommand.js +19 -249
- package/dist/cli/statusCommandLive.d.ts +20 -0
- package/dist/cli/statusCommandLive.js +188 -0
- package/dist/cli/statusCommandOptions.d.ts +40 -0
- package/dist/cli/statusCommandOptions.js +42 -0
- package/dist/cli/targetCliRoute.d.ts +2 -0
- package/dist/cli/targetCliRoute.js +30 -0
- package/dist/cli/targetCommands.d.ts +33 -0
- package/dist/cli/targetCommands.js +257 -0
- package/dist/cli/targetComposedPreparationCommand.d.ts +6 -0
- package/dist/cli/targetComposedPreparationCommand.js +39 -0
- package/dist/cli/targetDefaultArtifactAuthority.d.ts +5 -0
- package/dist/cli/targetDefaultArtifactAuthority.js +28 -0
- package/dist/cli/targetDefaultAuthorities.d.ts +53 -0
- package/dist/cli/targetDefaultAuthorities.js +210 -0
- package/dist/cli/targetDefaultConfig.d.ts +68 -0
- package/dist/cli/targetDefaultConfig.js +317 -0
- package/dist/cli/targetDefaultConfigStdin.d.ts +13 -0
- package/dist/cli/targetDefaultConfigStdin.js +215 -0
- package/dist/cli/targetDefaultEnvelope.d.ts +1 -0
- package/dist/cli/targetDefaultEnvelope.js +13 -0
- package/dist/cli/targetDefaultHandlerFactory.d.ts +28 -0
- package/dist/cli/targetDefaultHandlerFactory.js +247 -0
- package/dist/cli/targetDefaultHandlers.d.ts +21 -0
- package/dist/cli/targetDefaultHandlers.js +72 -0
- package/dist/cli/targetDefaultJournalAuthority.d.ts +35 -0
- package/dist/cli/targetDefaultJournalAuthority.js +135 -0
- package/dist/cli/targetDefaultWorldClock.d.ts +4 -0
- package/dist/cli/targetDefaultWorldClock.js +14 -0
- package/dist/cli/targetDefaultWorldQueries.d.ts +5 -0
- package/dist/cli/targetDefaultWorldQueries.js +11 -0
- package/dist/cli/targetDefaultWorldReadiness.d.ts +4 -0
- package/dist/cli/targetDefaultWorldReadiness.js +17 -0
- package/dist/cli/targetEvidenceHelperResolution.d.ts +14 -0
- package/dist/cli/targetEvidenceHelperResolution.js +23 -0
- package/dist/cli/targetLookupCli.d.ts +3 -0
- package/dist/cli/targetLookupCli.js +31 -0
- package/dist/cli/targetLookupCommands.d.ts +12 -0
- package/dist/cli/targetLookupCommands.js +69 -0
- package/dist/cli/targetOperationDispatch.d.ts +58 -0
- package/dist/cli/targetOperationDispatch.js +21 -0
- package/dist/cli/targetReceiptOutput.d.ts +14 -0
- package/dist/cli/targetReceiptOutput.js +21 -0
- package/dist/cli/targetRequestFile.d.ts +14 -0
- package/dist/cli/targetRequestFile.js +63 -0
- package/dist/cli/targetSecretSourceInput.d.ts +28 -0
- package/dist/cli/targetSecretSourceInput.js +121 -0
- package/dist/cli/targetWorldClockCommand.d.ts +10 -0
- package/dist/cli/targetWorldClockCommand.js +42 -0
- package/dist/cli/targetWorldClockCrossProcess.test-helper.d.ts +13 -0
- package/dist/cli/targetWorldClockCrossProcess.test-helper.js +109 -0
- package/dist/cli/targetWorldReadinessCommand.d.ts +10 -0
- package/dist/cli/targetWorldReadinessCommand.js +43 -0
- package/dist/cli/upCommand.d.ts +3 -0
- package/dist/cli/upCommand.js +133 -0
- package/dist/cli/upImageCommand.d.ts +11 -0
- package/dist/cli/upImageCommand.js +41 -0
- package/dist/cli/upLifecycleInvocation.d.ts +41 -0
- package/dist/cli/upLifecycleInvocation.js +48 -0
- package/dist/cli/upLifecycleRecovery.d.ts +4 -0
- package/dist/cli/upLifecycleRecovery.js +53 -0
- package/dist/compiler/agentNodeMerge.d.ts +2 -0
- package/dist/compiler/agentNodeMerge.js +79 -0
- package/dist/compiler/agentSurfaces.js +11 -1
- package/dist/compiler/buildCompilePlan.js +17 -0
- package/dist/compiler/buildCompilePlanAgent.d.ts +11 -0
- package/dist/compiler/buildCompilePlanAgent.js +56 -0
- package/dist/compiler/buildCompilePlanTeams.d.ts +1 -0
- package/dist/compiler/buildCompilePlanTeams.js +4 -1
- package/dist/compiler/buildCompilePlanTraversal.js +75 -82
- package/dist/compiler/buildProject.d.ts +11 -0
- package/dist/compiler/buildProject.js +77 -2
- package/dist/compiler/compilePlanHelpers.js +2 -0
- package/dist/compiler/compileProject.d.ts +13 -0
- package/dist/compiler/compileProject.js +26 -74
- package/dist/compiler/compileProjectPolicy.d.ts +5 -0
- package/dist/compiler/compileProjectPolicy.js +21 -0
- package/dist/compiler/compileProjectReports.d.ts +9 -0
- package/dist/compiler/compileProjectReports.js +52 -0
- package/dist/compiler/containerArtifactSummaries.d.ts +7 -0
- package/dist/compiler/containerArtifactSummaries.js +138 -0
- package/dist/compiler/containerArtifacts.d.ts +10 -0
- package/dist/compiler/containerArtifacts.js +126 -125
- package/dist/compiler/containerArtifactsPlans.d.ts +5 -3
- package/dist/compiler/containerArtifactsPlans.js +31 -118
- package/dist/compiler/containerArtifactsRender.d.ts +3 -1
- package/dist/compiler/containerArtifactsRender.js +15 -12
- package/dist/compiler/containerArtifactsTypes.d.ts +12 -0
- package/dist/compiler/containerConfigEnvRender.d.ts +3 -0
- package/dist/compiler/containerConfigEnvRender.js +54 -0
- package/dist/compiler/containerEntrypointRender.d.ts +1 -0
- package/dist/compiler/containerEntrypointRender.js +56 -52
- package/dist/compiler/containerEntrypointShell.d.ts +5 -0
- package/dist/compiler/containerEntrypointShell.js +29 -0
- package/dist/compiler/containerPackageOverrides.d.ts +27 -0
- package/dist/compiler/containerPackageOverrides.js +63 -0
- package/dist/compiler/containerTargetPlanResolution.d.ts +20 -0
- package/dist/compiler/containerTargetPlanResolution.js +97 -0
- package/dist/compiler/daimonTelemetryArtifacts.d.ts +22 -0
- package/dist/compiler/daimonTelemetryArtifacts.js +61 -0
- package/dist/compiler/dockerBuildContext.d.ts +16 -0
- package/dist/compiler/dockerBuildContext.js +159 -0
- package/dist/compiler/dockerBuildSkip.d.ts +30 -0
- package/dist/compiler/dockerBuildSkip.js +81 -0
- package/dist/compiler/index.d.ts +4 -0
- package/dist/compiler/index.js +4 -0
- package/dist/compiler/memoryArtifacts.d.ts +26 -0
- package/dist/compiler/memoryArtifacts.js +134 -0
- package/dist/compiler/memoryResolution.d.ts +4 -0
- package/dist/compiler/memoryResolution.js +147 -0
- package/dist/compiler/modelEnv.d.ts +2 -0
- package/dist/compiler/modelEnv.js +6 -0
- package/dist/compiler/moltnetAllowedWakeSendersValidation.d.ts +2 -0
- package/dist/compiler/moltnetAllowedWakeSendersValidation.js +42 -0
- package/dist/compiler/moltnetArtifactPaths.d.ts +26 -0
- package/dist/compiler/moltnetArtifactPaths.js +49 -0
- package/dist/compiler/moltnetArtifactTypes.d.ts +46 -0
- package/dist/compiler/moltnetArtifactTypes.js +1 -0
- package/dist/compiler/moltnetArtifacts.d.ts +2 -40
- package/dist/compiler/moltnetArtifacts.js +43 -97
- package/dist/compiler/moltnetBinaries.d.ts +21 -4
- package/dist/compiler/moltnetBinaries.js +134 -27
- package/dist/compiler/moltnetClientConfig.js +7 -2
- package/dist/compiler/moltnetConfigLowering.d.ts +16 -1
- package/dist/compiler/moltnetConfigLowering.js +67 -5
- package/dist/compiler/moltnetExternalParticipantArtifact.d.ts +38 -0
- package/dist/compiler/moltnetExternalParticipantArtifact.js +188 -0
- package/dist/compiler/moltnetNodeConfig.js +7 -2
- package/dist/compiler/moltnetReleaseAuthority.d.ts +17 -0
- package/dist/compiler/moltnetReleaseAuthority.js +73 -0
- package/dist/compiler/moltnetReleaseDownload.d.ts +12 -0
- package/dist/compiler/moltnetReleaseDownload.js +85 -0
- package/dist/compiler/moltnetRepresentativeResolution.d.ts +1 -0
- package/dist/compiler/moltnetRepresentativeResolution.js +16 -2
- package/dist/compiler/moltnetResolution.js +72 -20
- package/dist/compiler/moltnetRoomMemberships.js +37 -9
- package/dist/compiler/moltnetServerPlans.d.ts +9 -0
- package/dist/compiler/moltnetServerPlans.js +132 -0
- package/dist/compiler/organizationIdentity.d.ts +27 -0
- package/dist/compiler/organizationIdentity.js +297 -0
- package/dist/compiler/organizationReadyEvidence.d.ts +49 -0
- package/dist/compiler/organizationReadyEvidence.js +261 -0
- package/dist/compiler/projectManifestGraph.d.ts +4 -0
- package/dist/compiler/projectManifestGraph.js +24 -0
- package/dist/compiler/runProject.d.ts +4 -0
- package/dist/compiler/runProject.js +30 -21
- package/dist/compiler/runProjectAuth.d.ts +7 -1
- package/dist/compiler/runProjectAuth.js +87 -9
- package/dist/compiler/runProjectDocker.d.ts +7 -0
- package/dist/compiler/runProjectDocker.js +31 -8
- package/dist/compiler/runProjectLifecycle.d.ts +7 -0
- package/dist/compiler/runProjectLifecycle.js +40 -0
- package/dist/compiler/syncProjectAuth.js +4 -1
- package/dist/compiler/teamContextActiveEnvironments.d.ts +13 -0
- package/dist/compiler/teamContextActiveEnvironments.js +255 -0
- package/dist/compiler/teamContextSupport.js +32 -40
- package/dist/compiler/teamContextTypes.d.ts +2 -0
- package/dist/compiler/types.d.ts +82 -1
- package/dist/compiler/upProject.d.ts +5 -0
- package/dist/compiler/upProject.js +256 -20
- package/dist/compiler/upReceipt.d.ts +36 -0
- package/dist/compiler/upReceipt.js +82 -0
- package/dist/compiler/updateProjectModels.js +42 -60
- package/dist/compiler/updateProjectRuntime.js +22 -35
- package/dist/compiler/updateProjectSurfaces.js +53 -47
- package/dist/compiler/worldBindings.d.ts +39 -0
- package/dist/compiler/worldBindings.js +247 -0
- package/dist/compiler/worldBindingsFile.d.ts +5 -0
- package/dist/compiler/worldBindingsFile.js +162 -0
- package/dist/deployment/artifactsExport.d.ts +49 -0
- package/dist/deployment/artifactsExport.js +217 -0
- package/dist/deployment/artifactsExportDocker.d.ts +48 -0
- package/dist/deployment/artifactsExportDocker.js +91 -0
- package/dist/deployment/artifactsExportPlan.d.ts +24 -0
- package/dist/deployment/artifactsExportPlan.js +135 -0
- package/dist/deployment/artifactsExportTypes.d.ts +50 -0
- package/dist/deployment/artifactsExportTypes.js +52 -0
- package/dist/deployment/buildImageCacheStore.d.ts +23 -0
- package/dist/deployment/buildImageCacheStore.js +54 -0
- package/dist/deployment/deploymentLifecycleCorrelation.d.ts +11 -0
- package/dist/deployment/deploymentLifecycleCorrelation.js +33 -0
- package/dist/deployment/dockerInspect.d.ts +9 -0
- package/dist/deployment/dockerInspect.js +24 -1
- package/dist/deployment/dockerLabels.d.ts +2 -0
- package/dist/deployment/dockerLabels.js +2 -0
- package/dist/deployment/dockerLogs.js +2 -10
- package/dist/deployment/dockerManager.d.ts +51 -0
- package/dist/deployment/dockerManager.js +118 -1
- package/dist/deployment/dockerProbeGateway.js +64 -5
- package/dist/deployment/dockerRecover.js +9 -1
- package/dist/deployment/dockerTeardown.d.ts +32 -0
- package/dist/deployment/dockerTeardown.js +61 -0
- package/dist/deployment/downDeployment.d.ts +34 -0
- package/dist/deployment/downDeployment.js +147 -0
- package/dist/deployment/downReceiptTypes.d.ts +21 -0
- package/dist/deployment/downReceiptTypes.js +30 -0
- package/dist/deployment/index.d.ts +16 -0
- package/dist/deployment/index.js +17 -0
- package/dist/deployment/lifecycleCompletion.d.ts +37 -0
- package/dist/deployment/lifecycleCompletion.js +236 -0
- package/dist/deployment/lifecycleCompletionContracts.d.ts +158 -0
- package/dist/deployment/lifecycleCompletionContracts.js +106 -0
- package/dist/deployment/lifecycleCompletionHeartbeat.d.ts +2 -0
- package/dist/deployment/lifecycleCompletionHeartbeat.js +50 -0
- package/dist/deployment/lifecycleCompletionLookup.d.ts +18 -0
- package/dist/deployment/lifecycleCompletionLookup.js +88 -0
- package/dist/deployment/lifecycleCompletionOwner.d.ts +8 -0
- package/dist/deployment/lifecycleCompletionOwner.js +31 -0
- package/dist/deployment/lifecycleCompletionParsing.d.ts +12 -0
- package/dist/deployment/lifecycleCompletionParsing.js +108 -0
- package/dist/deployment/lifecycleCompletionPaths.d.ts +9 -0
- package/dist/deployment/lifecycleCompletionPaths.js +16 -0
- package/dist/deployment/lifecycleCompletionPublication.d.ts +5 -0
- package/dist/deployment/lifecycleCompletionPublication.js +35 -0
- package/dist/deployment/lifecycleCompletionRecovery.d.ts +21 -0
- package/dist/deployment/lifecycleCompletionRecovery.js +56 -0
- package/dist/deployment/lifecycleCompletionRoot.d.ts +21 -0
- package/dist/deployment/lifecycleCompletionRoot.js +243 -0
- package/dist/deployment/lifecycleCompletionStore.d.ts +6 -0
- package/dist/deployment/lifecycleCompletionStore.js +151 -0
- package/dist/deployment/organizationHandoffAuthorityFsClient.d.ts +17 -0
- package/dist/deployment/organizationHandoffAuthorityFsClient.js +132 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorker.d.ts +1 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorker.js +285 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorkerParent.fixture.d.ts +1 -0
- package/dist/deployment/organizationHandoffAuthorityFsWorkerParent.fixture.js +26 -0
- package/dist/deployment/organizationHandoffAuthorityStore.d.ts +41 -0
- package/dist/deployment/organizationHandoffAuthorityStore.js +348 -0
- package/dist/deployment/organizationHandoffAuthorityTypes.d.ts +76 -0
- package/dist/deployment/organizationHandoffAuthorityTypes.js +148 -0
- package/dist/deployment/organizationHandoffTypes.d.ts +29 -0
- package/dist/deployment/organizationHandoffTypes.js +80 -0
- package/dist/deployment/organizationReady.d.ts +52 -0
- package/dist/deployment/organizationReady.js +200 -0
- package/dist/deployment/privateArtifactsExport.d.ts +18 -0
- package/dist/deployment/privateArtifactsExport.js +80 -0
- package/dist/deployment/providerRuntimeBoundaryScanner.test-helper.d.ts +8 -0
- package/dist/deployment/providerRuntimeBoundaryScanner.test-helper.js +60 -0
- package/dist/deployment/record.d.ts +26 -1
- package/dist/deployment/record.js +49 -4
- package/dist/deployment/simfileFixtureBoundary.test-helper.d.ts +8 -0
- package/dist/deployment/simfileFixtureBoundary.test-helper.js +103 -0
- package/dist/deployment/target.d.ts +1 -35
- package/dist/deployment/target.js +1 -96
- package/dist/deployment/upReceiptTypes.d.ts +111 -0
- package/dist/deployment/upReceiptTypes.js +164 -0
- package/dist/dev/project.js +15 -9
- package/dist/distribution/buildDistributionReport.d.ts +2 -1
- package/dist/distribution/buildDistributionReport.js +2 -1
- package/dist/distribution/distributionReportSchema.d.ts +5 -0
- package/dist/distribution/distributionReportSchema.js +7 -2
- package/dist/distribution/index.d.ts +2 -2
- package/dist/distribution/index.js +1 -1
- package/dist/distribution/types.d.ts +7 -0
- package/dist/distribution/types.js +1 -0
- package/dist/filesystem/paths.js +10 -1
- package/dist/ledger/causalConformanceCli.d.ts +1 -0
- package/dist/ledger/causalConformanceCli.js +41 -0
- package/dist/ledger/causeNamespace.d.ts +8 -0
- package/dist/ledger/causeNamespace.js +24 -0
- package/dist/ledger/conformance.d.ts +83 -0
- package/dist/ledger/conformance.js +259 -0
- package/dist/ledger/emitters.d.ts +76 -0
- package/dist/ledger/emitters.js +188 -0
- package/dist/ledger/index.d.ts +4 -0
- package/dist/ledger/index.js +4 -0
- package/dist/ledger/principal.d.ts +96 -0
- package/dist/ledger/principal.js +121 -0
- package/dist/manifest/externalParticipantSchemas.d.ts +18 -0
- package/dist/manifest/externalParticipantSchemas.js +17 -0
- package/dist/manifest/index.d.ts +1 -0
- package/dist/manifest/index.js +1 -0
- package/dist/manifest/inlineAgentMember.d.ts +2 -0
- package/dist/manifest/inlineAgentMember.js +9 -0
- package/dist/manifest/loadManifest.js +14 -8
- package/dist/manifest/mcpSchemas.d.ts +17 -0
- package/dist/manifest/mcpSchemas.js +41 -0
- package/dist/manifest/memorySchemas.d.ts +245 -0
- package/dist/manifest/memorySchemas.js +148 -0
- package/dist/manifest/renderSpawnfile.js +22 -131
- package/dist/manifest/renderSpawnfileNetworks.js +9 -2
- package/dist/manifest/renderSpawnfileSurfaces.d.ts +2 -0
- package/dist/manifest/renderSpawnfileSurfaces.js +134 -0
- package/dist/manifest/schemas.d.ts +1868 -99
- package/dist/manifest/schemas.js +78 -32
- package/dist/manifest/surfaceSchemas.d.ts +17 -0
- package/dist/manifest/surfaceSchemas.js +24 -1
- package/dist/manifest/teamNetworkAccessSchemas.d.ts +1 -1
- package/dist/manifest/teamNetworkAuthSchemas.d.ts +48 -0
- package/dist/manifest/teamNetworkAuthSchemas.js +103 -0
- package/dist/manifest/teamNetworkSchemas.d.ts +8 -187
- package/dist/manifest/teamNetworkSchemas.js +3 -317
- package/dist/manifest/teamNetworkServerSchemas.d.ts +150 -0
- package/dist/manifest/teamNetworkServerSchemas.js +199 -0
- package/dist/ownership/siblingBuildFreshness.d.ts +20 -0
- package/dist/ownership/siblingBuildFreshness.js +20 -0
- package/dist/ownership/simfileRunOperatorInputs.d.ts +103 -0
- package/dist/ownership/simfileRunOperatorInputs.js +139 -0
- package/dist/report/types.d.ts +142 -0
- package/dist/runtime/common.d.ts +35 -0
- package/dist/runtime/common.js +55 -0
- package/dist/runtime/container.d.ts +28 -1
- package/dist/runtime/container.js +38 -5
- package/dist/runtime/containerPackageOverrides.d.ts +37 -0
- package/dist/runtime/containerPackageOverrides.js +33 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/mnemeMcp.d.ts +15 -0
- package/dist/runtime/mnemeMcp.js +109 -0
- package/dist/runtime/openclaw/adapter.js +15 -4
- package/dist/runtime/openclaw/mcp.d.ts +10 -0
- package/dist/runtime/openclaw/mcp.js +69 -0
- package/dist/runtime/openclaw/runAuth.js +2 -2
- package/dist/runtime/openclaw/scaffold.js +1 -1
- package/dist/runtime/openclaw/schedules.d.ts +38 -0
- package/dist/runtime/openclaw/schedules.js +74 -0
- package/dist/runtime/pi/adapter.d.ts +1 -1
- package/dist/runtime/pi/adapter.js +86 -53
- package/dist/runtime/pi/appActivitySource.js +114 -2
- package/dist/runtime/pi/appAgentConfig.d.ts +11 -0
- package/dist/runtime/pi/appAgentConfig.js +264 -0
- package/dist/runtime/pi/appCliEnginesSource.d.ts +1 -0
- package/dist/runtime/pi/appCliEnginesSource.js +183 -0
- package/dist/runtime/pi/appCliSource.d.ts +1 -0
- package/dist/runtime/pi/appCliSource.js +353 -0
- package/dist/runtime/pi/appControlSource.d.ts +1 -0
- package/dist/runtime/pi/appControlSource.js +390 -0
- package/dist/runtime/pi/appControlWakeIdentitySource.d.ts +1 -0
- package/dist/runtime/pi/appControlWakeIdentitySource.js +19 -0
- package/dist/runtime/pi/appCoreSource.d.ts +4 -1
- package/dist/runtime/pi/appCoreSource.js +104 -214
- package/dist/runtime/pi/appPreludeSource.js +140 -52
- package/dist/runtime/pi/appScheduleSource.d.ts +1 -0
- package/dist/runtime/pi/appScheduleSource.js +80 -0
- package/dist/runtime/pi/appScriptedEngine.d.ts +31 -0
- package/dist/runtime/pi/appScriptedEngine.js +42 -0
- package/dist/runtime/pi/appSource.d.ts +4 -1
- package/dist/runtime/pi/appSource.js +6 -2
- package/dist/runtime/pi/appTemplate.d.ts +8 -22
- package/dist/runtime/pi/appTemplate.js +9 -126
- package/dist/runtime/pi/appTemplateTypes.d.ts +64 -0
- package/dist/runtime/pi/appTemplateTypes.js +18 -0
- package/dist/runtime/pi/appWakeContextSource.d.ts +1 -0
- package/dist/runtime/pi/appWakeContextSource.js +398 -0
- package/dist/runtime/pi/containerTargets.d.ts +4 -0
- package/dist/runtime/pi/containerTargets.js +57 -0
- package/dist/runtime/pi/runAuth.js +126 -9
- package/dist/runtime/pi/testHelpers.d.ts +2 -0
- package/dist/runtime/pi/testHelpers.js +40 -0
- package/dist/runtime/picoclaw/adapter.js +23 -27
- package/dist/runtime/picoclaw/mcp.d.ts +4 -0
- package/dist/runtime/picoclaw/mcp.js +43 -0
- package/dist/runtime/picoclaw/memory.d.ts +7 -0
- package/dist/runtime/picoclaw/memory.js +17 -0
- package/dist/runtime/picoclaw/runAuth.js +1 -1
- package/dist/runtime/picoclaw/scaffold.js +1 -1
- package/dist/runtime/picoclaw/schedules.d.ts +26 -0
- package/dist/runtime/picoclaw/schedules.js +62 -3
- package/dist/runtime/scheduleUtils.d.ts +2 -0
- package/dist/runtime/scheduleUtils.js +15 -0
- package/dist/runtime/types.d.ts +25 -2
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +2 -2
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/redaction.d.ts +2 -0
- package/dist/shared/redaction.js +10 -0
- package/dist/status/buildStatus.d.ts +1 -0
- package/dist/status/buildStatus.js +2 -0
- package/dist/status/compileReport.d.ts +22 -0
- package/dist/status/compileReport.js +16 -2
- package/dist/status/compiledProbeCollection.d.ts +21 -0
- package/dist/status/compiledProbeCollection.js +27 -0
- package/dist/status/imageStatusReport.js +6 -0
- package/dist/status/index.d.ts +3 -0
- package/dist/status/index.js +3 -0
- package/dist/status/lifecycleProbes.d.ts +19 -0
- package/dist/status/lifecycleProbes.js +174 -0
- package/dist/status/moltnetProbes.d.ts +7 -8
- package/dist/status/moltnetProbes.js +27 -198
- package/dist/status/moltnetWiringProbes.d.ts +19 -0
- package/dist/status/moltnetWiringProbes.js +178 -0
- package/dist/target/cleanupRun.d.ts +41 -0
- package/dist/target/cleanupRun.js +139 -0
- package/dist/target/cleanupRunDocker.d.ts +16 -0
- package/dist/target/cleanupRunDocker.js +66 -0
- package/dist/target/cleanupRunDocker.test-helper.d.ts +67 -0
- package/dist/target/cleanupRunDocker.test-helper.js +238 -0
- package/dist/target/cleanupRunDockerPreflight.d.ts +17 -0
- package/dist/target/cleanupRunDockerPreflight.js +224 -0
- package/dist/target/composedPreparation.d.ts +205 -0
- package/dist/target/composedPreparation.js +223 -0
- package/dist/target/containerBundle.d.ts +82 -0
- package/dist/target/containerBundle.js +243 -0
- package/dist/target/containerBundleArchive.d.ts +31 -0
- package/dist/target/containerBundleArchive.js +140 -0
- package/dist/target/containerBundleAuthority.d.ts +25 -0
- package/dist/target/containerBundleAuthority.js +65 -0
- package/dist/target/containerBundleContracts.d.ts +114 -0
- package/dist/target/containerBundleContracts.js +173 -0
- package/dist/target/containerBundleFilesystemStore.d.ts +3 -0
- package/dist/target/containerBundleFilesystemStore.js +247 -0
- package/dist/target/containerBundlePolicy.d.ts +33 -0
- package/dist/target/containerBundlePolicy.js +64 -0
- package/dist/target/containerBundleStore.d.ts +127 -0
- package/dist/target/containerBundleStore.js +284 -0
- package/dist/target/contracts.d.ts +538 -0
- package/dist/target/contracts.js +373 -0
- package/dist/target/dockerArtifactIdentityTypes.d.ts +56 -0
- package/dist/target/dockerArtifactIdentityTypes.js +1 -0
- package/dist/target/dockerArtifactInspection.d.ts +40 -0
- package/dist/target/dockerArtifactInspection.js +125 -0
- package/dist/target/dockerArtifacts.d.ts +21 -0
- package/dist/target/dockerArtifacts.js +110 -0
- package/dist/target/dockerArtifactsProvider.d.ts +41 -0
- package/dist/target/dockerArtifactsProvider.js +449 -0
- package/dist/target/dockerCommandExecutor.d.ts +27 -0
- package/dist/target/dockerCommandExecutor.js +200 -0
- package/dist/target/dockerCommandExecutorCore.d.ts +34 -0
- package/dist/target/dockerCommandExecutorCore.js +273 -0
- package/dist/target/dockerContainerBundleBuilder.d.ts +8 -0
- package/dist/target/dockerContainerBundleBuilder.js +256 -0
- package/dist/target/dockerContextSnapshot.d.ts +21 -0
- package/dist/target/dockerContextSnapshot.js +158 -0
- package/dist/target/dockerEndpointFingerprint.d.ts +1 -0
- package/dist/target/dockerEndpointFingerprint.js +9 -0
- package/dist/target/dockerPreparedArtifact.d.ts +48 -0
- package/dist/target/dockerPreparedArtifact.js +131 -0
- package/dist/target/dockerProjectionJson.d.ts +1 -0
- package/dist/target/dockerProjectionJson.js +80 -0
- package/dist/target/dockerPublicArtifactSnapshot.d.ts +17 -0
- package/dist/target/dockerPublicArtifactSnapshot.js +99 -0
- package/dist/target/dockerResources.d.ts +26 -0
- package/dist/target/dockerResources.js +162 -0
- package/dist/target/dockerResourcesProvider.d.ts +44 -0
- package/dist/target/dockerResourcesProvider.js +207 -0
- package/dist/target/dockerSecrets.d.ts +39 -0
- package/dist/target/dockerSecrets.js +249 -0
- package/dist/target/dockerSecretsAuthority.d.ts +26 -0
- package/dist/target/dockerSecretsAuthority.js +216 -0
- package/dist/target/dockerSecretsLifecycle.d.ts +25 -0
- package/dist/target/dockerSecretsLifecycle.js +133 -0
- package/dist/target/dockerSecretsProvider.d.ts +68 -0
- package/dist/target/dockerSecretsProvider.js +329 -0
- package/dist/target/dockerTarget.d.ts +52 -0
- package/dist/target/dockerTarget.js +48 -0
- package/dist/target/dockerTargetBinding.d.ts +14 -0
- package/dist/target/dockerTargetBinding.js +96 -0
- package/dist/target/dockerWorldClock.d.ts +17 -0
- package/dist/target/dockerWorldClock.js +111 -0
- package/dist/target/dockerWorldReadiness.d.ts +17 -0
- package/dist/target/dockerWorldReadiness.js +119 -0
- package/dist/target/dockerWorldService.d.ts +23 -0
- package/dist/target/dockerWorldService.js +216 -0
- package/dist/target/dockerWorldServiceAuthority.d.ts +80 -0
- package/dist/target/dockerWorldServiceAuthority.js +182 -0
- package/dist/target/dockerWorldServiceLifecycle.d.ts +41 -0
- package/dist/target/dockerWorldServiceLifecycle.js +275 -0
- package/dist/target/dockerWorldServiceProvider.d.ts +60 -0
- package/dist/target/dockerWorldServiceProvider.js +318 -0
- package/dist/target/dockerWorldServiceStore.d.ts +73 -0
- package/dist/target/dockerWorldServiceStore.js +367 -0
- package/dist/target/evidenceExport.d.ts +55 -0
- package/dist/target/evidenceExport.js +518 -0
- package/dist/target/evidenceExportArchive.d.ts +10 -0
- package/dist/target/evidenceExportArchive.js +302 -0
- package/dist/target/evidenceExportContract.d.ts +27 -0
- package/dist/target/evidenceExportContract.js +40 -0
- package/dist/target/evidenceExportOperationsTestKit.d.ts +87 -0
- package/dist/target/evidenceExportOperationsTestKit.js +312 -0
- package/dist/target/evidenceExportProvider.d.ts +85 -0
- package/dist/target/evidenceExportProvider.js +187 -0
- package/dist/target/evidenceExportPublicationTypes.d.ts +16 -0
- package/dist/target/evidenceExportPublicationTypes.js +1 -0
- package/dist/target/evidenceExportStore.d.ts +70 -0
- package/dist/target/evidenceExportStore.js +498 -0
- package/dist/target/evidenceExportStorePublication.d.ts +7 -0
- package/dist/target/evidenceExportStorePublication.js +395 -0
- package/dist/target/handles.d.ts +20 -0
- package/dist/target/handles.js +56 -0
- package/dist/target/index.d.ts +12 -0
- package/dist/target/index.js +11 -0
- package/dist/target/journal.d.ts +59 -0
- package/dist/target/journal.js +529 -0
- package/dist/target/journalFilesystem.d.ts +3 -0
- package/dist/target/journalFilesystem.js +111 -0
- package/dist/target/journalRoot.d.ts +4 -0
- package/dist/target/journalRoot.js +6 -0
- package/dist/target/organizationAttachment.d.ts +23 -0
- package/dist/target/organizationAttachment.js +263 -0
- package/dist/target/organizationAttachmentAuthority.d.ts +65 -0
- package/dist/target/organizationAttachmentAuthority.js +161 -0
- package/dist/target/organizationAttachmentLifecycle.d.ts +17 -0
- package/dist/target/organizationAttachmentLifecycle.js +101 -0
- package/dist/target/organizationAttachmentProvider.d.ts +76 -0
- package/dist/target/organizationAttachmentProvider.js +289 -0
- package/dist/target/organizationAttachmentStore.d.ts +51 -0
- package/dist/target/organizationAttachmentStore.js +316 -0
- package/dist/target/publicArtifactSnapshot.d.ts +41 -0
- package/dist/target/publicArtifactSnapshot.js +150 -0
- package/dist/target/topologyActivation.d.ts +51 -0
- package/dist/target/topologyActivation.js +149 -0
- package/dist/target/topologyAttestation.d.ts +37 -0
- package/dist/target/topologyAttestation.js +300 -0
- package/dist/target/topologyAttestationErrors.d.ts +1 -0
- package/dist/target/topologyAttestationErrors.js +1 -0
- package/dist/target/worldClock.d.ts +60 -0
- package/dist/target/worldClock.js +129 -0
- package/dist/target/worldReadiness.d.ts +103 -0
- package/dist/target/worldReadiness.js +153 -0
- package/moltnet-releases.json +20 -0
- package/package.json +27 -11
- package/runtimes.yaml +8 -23
- package/dist/runtime/openclaw/scaffold-assets/CLAUDE.md +0 -5
- package/dist/runtime/picoclaw/scaffold-assets/CLAUDE.md +0 -5
- /package/dist/runtime/openclaw/scaffold-assets/{AGENTS.md → WORKSPACE_AGENTS.md} +0 -0
- /package/dist/runtime/picoclaw/scaffold-assets/{AGENTS.md → WORKSPACE_AGENTS.md} +0 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { lstat, mkdir, open } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { resolveSpawnfileHome } from "../auth/index.js";
|
|
6
|
+
import { parseOpaqueTargetHandle } from "../target/index.js";
|
|
7
|
+
import { ORGANIZATION_HANDOFF_AUTHORITY_ERROR, createOrganizationHandoffCapabilityPending, createOrganizationHandoffDockerObservation, createOrganizationHandoffHandle, createOrganizationHandoffRecoveryKey, parseOrganizationAttachmentAuthorizationForDeployment, parseOrganizationHandoffCapability, parseOrganizationHandoffDockerObservation } from "./organizationHandoffAuthorityTypes.js";
|
|
8
|
+
import { parseOrganizationHandoff } from "./organizationHandoffTypes.js";
|
|
9
|
+
import { initializeOrganizationHandoffAuthorityFsClient } from "./organizationHandoffAuthorityFsClient.js";
|
|
10
|
+
const owner = typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
11
|
+
const fail = () => { throw new Error(ORGANIZATION_HANDOFF_AUTHORITY_ERROR); };
|
|
12
|
+
const key = (value) => Buffer.from(value, "utf8").toString("hex");
|
|
13
|
+
const same = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
14
|
+
const pendingKey = (value) => typeof value === "string" && /^[a-f0-9]{64}$/u.test(value) ? value : fail();
|
|
15
|
+
const recoveryName = (value) => `${key(createOrganizationHandoffRecoveryKey(value))}.json`;
|
|
16
|
+
const closeRequest = (value) => {
|
|
17
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)
|
|
18
|
+
|| Object.getPrototypeOf(value) !== Object.prototype
|
|
19
|
+
|| Object.keys(value).length !== 2
|
|
20
|
+
|| !Object.hasOwn(value, "expectedHandoff")
|
|
21
|
+
|| !Object.hasOwn(value, "organizationHandoffHandle"))
|
|
22
|
+
return fail();
|
|
23
|
+
const input = value;
|
|
24
|
+
try {
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
expectedHandoff: parseOrganizationHandoff(input.expectedHandoff),
|
|
27
|
+
organizationHandoffHandle: parseOpaqueTargetHandle(input.organizationHandoffHandle)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return fail();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export const resolveOrganizationHandoffAuthorityRoot = () => path.join(resolveSpawnfileHome(), "deployments", "organization-handoff-authority");
|
|
35
|
+
const checkDirectory = async (directory) => {
|
|
36
|
+
const home = resolveSpawnfileHome();
|
|
37
|
+
const root = path.resolve(directory);
|
|
38
|
+
if (root !== home && !root.startsWith(`${home}${path.sep}`))
|
|
39
|
+
return fail();
|
|
40
|
+
await mkdir(home, { mode: 0o700, recursive: true }).catch(fail);
|
|
41
|
+
const homeStat = await lstat(home).catch(fail);
|
|
42
|
+
if (!homeStat.isDirectory() || homeStat.isSymbolicLink() || (homeStat.mode & 0o077) !== 0
|
|
43
|
+
|| owner !== undefined && homeStat.uid !== owner)
|
|
44
|
+
return fail();
|
|
45
|
+
let current = home;
|
|
46
|
+
for (const part of path.relative(home, root).split(path.sep).filter(Boolean)) {
|
|
47
|
+
current = path.join(current, part);
|
|
48
|
+
let stat;
|
|
49
|
+
try {
|
|
50
|
+
stat = await lstat(current);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (error.code !== "ENOENT")
|
|
54
|
+
return fail();
|
|
55
|
+
await mkdir(current, { mode: 0o700 }).catch((mkdirError) => {
|
|
56
|
+
if (mkdirError.code !== "EEXIST")
|
|
57
|
+
fail();
|
|
58
|
+
});
|
|
59
|
+
stat = await lstat(current).catch(fail);
|
|
60
|
+
}
|
|
61
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 0o077) !== 0
|
|
62
|
+
|| owner !== undefined && stat.uid !== owner)
|
|
63
|
+
return fail();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const parse = (content) => {
|
|
67
|
+
let value;
|
|
68
|
+
try {
|
|
69
|
+
value = JSON.parse(content);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return fail();
|
|
73
|
+
}
|
|
74
|
+
const parsed = parseOrganizationHandoffCapability(value);
|
|
75
|
+
if (JSON.stringify(parsed) !== content)
|
|
76
|
+
return fail();
|
|
77
|
+
return parsed;
|
|
78
|
+
};
|
|
79
|
+
const parseObservation = (content) => {
|
|
80
|
+
let value;
|
|
81
|
+
try {
|
|
82
|
+
value = JSON.parse(content);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return fail();
|
|
86
|
+
}
|
|
87
|
+
const parsed = parseOrganizationHandoffDockerObservation(value);
|
|
88
|
+
if (JSON.stringify(parsed) !== content)
|
|
89
|
+
return fail();
|
|
90
|
+
return parsed;
|
|
91
|
+
};
|
|
92
|
+
class Store {
|
|
93
|
+
#anchors;
|
|
94
|
+
#clients;
|
|
95
|
+
#disposed = false;
|
|
96
|
+
#hooks;
|
|
97
|
+
#root;
|
|
98
|
+
resolver;
|
|
99
|
+
constructor(root, anchors, clients, hooks) {
|
|
100
|
+
this.#root = root;
|
|
101
|
+
this.#anchors = anchors;
|
|
102
|
+
this.#clients = clients;
|
|
103
|
+
this.#hooks = hooks;
|
|
104
|
+
this.resolver = Object.freeze({ resolve: async (input) => this.resolve(input) });
|
|
105
|
+
}
|
|
106
|
+
async validateDirectories() {
|
|
107
|
+
if (this.#disposed)
|
|
108
|
+
return fail();
|
|
109
|
+
await Promise.all([...this.#anchors.entries()].map(async ([part, anchor]) => {
|
|
110
|
+
await checkDirectory(path.join(this.#root, part));
|
|
111
|
+
const pathStat = await lstat(path.join(this.#root, part)).catch(fail);
|
|
112
|
+
const fdStat = await anchor.handle.stat().catch(fail);
|
|
113
|
+
if (pathStat.dev !== anchor.dev || pathStat.ino !== anchor.ino || fdStat.dev !== anchor.dev || fdStat.ino !== anchor.ino)
|
|
114
|
+
fail();
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
async dispose() {
|
|
118
|
+
if (this.#disposed)
|
|
119
|
+
return;
|
|
120
|
+
this.#disposed = true;
|
|
121
|
+
await Promise.all([...this.#clients.values()].map(async (client) => client.dispose()));
|
|
122
|
+
await Promise.all([...this.#anchors.values()].map(async ({ handle }) => { await handle.close().catch(() => undefined); }));
|
|
123
|
+
}
|
|
124
|
+
client(part) { return this.#clients.get(part) ?? fail(); }
|
|
125
|
+
async hook(kind) { await this.#hooks?.beforeLeafOperation?.(kind); }
|
|
126
|
+
async reserve(input) {
|
|
127
|
+
await this.validateDirectories();
|
|
128
|
+
const pending = createOrganizationHandoffCapabilityPending(input);
|
|
129
|
+
const publish = async () => this.client("pending").write(`${key(pending.pending_key)}.json`, JSON.stringify(pending));
|
|
130
|
+
if (this.#hooks?.duringLeafOperation)
|
|
131
|
+
await this.#hooks.duringLeafOperation("reserve", publish);
|
|
132
|
+
else {
|
|
133
|
+
await this.hook("reserve");
|
|
134
|
+
await this.validateDirectories();
|
|
135
|
+
await publish();
|
|
136
|
+
}
|
|
137
|
+
await this.validateDirectories();
|
|
138
|
+
return pending;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Elects the one Docker mutator before Docker is invoked. Once the durable
|
|
142
|
+
* reservation exists, an absent observed-id checkpoint is intentionally
|
|
143
|
+
* incomplete: automatic retry could create an unprovable second container.
|
|
144
|
+
*/
|
|
145
|
+
async begin(input) {
|
|
146
|
+
const pending = await this.reserve(input);
|
|
147
|
+
await this.validateDirectories();
|
|
148
|
+
await this.hook("reserve");
|
|
149
|
+
await this.validateDirectories();
|
|
150
|
+
const name = recoveryName(pending.pending_key);
|
|
151
|
+
const serialized = JSON.stringify(pending);
|
|
152
|
+
const existing = await this.client("recovery-reserved").read(name);
|
|
153
|
+
if (existing !== null) {
|
|
154
|
+
const prior = parse(existing);
|
|
155
|
+
if (prior.state !== "pending" || !same(prior, pending))
|
|
156
|
+
return fail();
|
|
157
|
+
await this.validateDirectories();
|
|
158
|
+
return Object.freeze({ created: false, pending });
|
|
159
|
+
}
|
|
160
|
+
const created = await this.client("recovery-reserved").create(name, serialized);
|
|
161
|
+
if (!created) {
|
|
162
|
+
const prior = await this.client("recovery-reserved").read(name);
|
|
163
|
+
if (prior === null || !same(parse(prior), pending))
|
|
164
|
+
return fail();
|
|
165
|
+
}
|
|
166
|
+
await this.validateDirectories();
|
|
167
|
+
return Object.freeze({ created, pending });
|
|
168
|
+
}
|
|
169
|
+
async observeDockerMutation(pendingKeyRaw, container) {
|
|
170
|
+
await this.validateDirectories();
|
|
171
|
+
await this.hook("finalize");
|
|
172
|
+
await this.validateDirectories();
|
|
173
|
+
const value = pendingKey(pendingKeyRaw);
|
|
174
|
+
const reservation = await this.client("recovery-reserved").read(recoveryName(value));
|
|
175
|
+
if (reservation === null)
|
|
176
|
+
return fail();
|
|
177
|
+
const pending = parse(reservation);
|
|
178
|
+
if (pending.state !== "pending" || pending.pending_key !== value)
|
|
179
|
+
return fail();
|
|
180
|
+
const observation = createOrganizationHandoffDockerObservation({ containerId: container?.containerId,
|
|
181
|
+
deploymentLabels: container?.deploymentLabels, imageId: container?.imageId, pendingKey: value });
|
|
182
|
+
if (!same(observation.deployment_labels, pending.deployment_labels))
|
|
183
|
+
return fail();
|
|
184
|
+
const name = recoveryName(value);
|
|
185
|
+
const serialized = JSON.stringify(observation);
|
|
186
|
+
const existing = await this.client("recovery-docker-observed").read(name);
|
|
187
|
+
if (existing !== null) {
|
|
188
|
+
if (!same(parseObservation(existing), observation))
|
|
189
|
+
return fail();
|
|
190
|
+
await this.validateDirectories();
|
|
191
|
+
return observation;
|
|
192
|
+
}
|
|
193
|
+
const created = await this.client("recovery-docker-observed").create(name, serialized);
|
|
194
|
+
if (!created) {
|
|
195
|
+
const prior = await this.client("recovery-docker-observed").read(name);
|
|
196
|
+
if (prior === null || !same(parseObservation(prior), observation))
|
|
197
|
+
return fail();
|
|
198
|
+
}
|
|
199
|
+
await this.validateDirectories();
|
|
200
|
+
return observation;
|
|
201
|
+
}
|
|
202
|
+
async readDockerMutation(pendingKeyRaw) {
|
|
203
|
+
await this.validateDirectories();
|
|
204
|
+
await this.hook("finalize");
|
|
205
|
+
await this.validateDirectories();
|
|
206
|
+
const value = pendingKey(pendingKeyRaw);
|
|
207
|
+
const reservation = await this.client("recovery-reserved").read(recoveryName(value));
|
|
208
|
+
if (reservation === null)
|
|
209
|
+
return null;
|
|
210
|
+
const pending = parse(reservation);
|
|
211
|
+
if (pending.state !== "pending" || pending.pending_key !== value)
|
|
212
|
+
return fail();
|
|
213
|
+
const raw = await this.client("recovery-docker-observed").read(recoveryName(value));
|
|
214
|
+
if (raw === null)
|
|
215
|
+
return null;
|
|
216
|
+
const observation = parseObservation(raw);
|
|
217
|
+
if (observation.pending_key !== value || !same(observation.deployment_labels, pending.deployment_labels))
|
|
218
|
+
return fail();
|
|
219
|
+
await this.validateDirectories();
|
|
220
|
+
return observation;
|
|
221
|
+
}
|
|
222
|
+
async finalize(pendingKey, container) {
|
|
223
|
+
await this.validateDirectories();
|
|
224
|
+
await this.hook("finalize");
|
|
225
|
+
await this.validateDirectories();
|
|
226
|
+
if (typeof pendingKey !== "string" || !/^[a-f0-9]{64}$/u.test(pendingKey) || !container)
|
|
227
|
+
return fail();
|
|
228
|
+
const source = await this.client("pending").read(`${key(pendingKey)}.json`);
|
|
229
|
+
if (source === null)
|
|
230
|
+
return fail();
|
|
231
|
+
const pending = parse(source);
|
|
232
|
+
if (pending.state !== "pending" || pending.pending_key !== pendingKey || !same(pending.deployment_labels, container.deploymentLabels))
|
|
233
|
+
return fail();
|
|
234
|
+
// S3's begin path has a durable reservation leaf. Once that leaf exists,
|
|
235
|
+
// finalization is allowed only from the direct inspected-id checkpoint.
|
|
236
|
+
// Legacy low-level reserve/finalize callers retain their S1 behavior.
|
|
237
|
+
const reserved = await this.client("recovery-reserved").read(recoveryName(pendingKey));
|
|
238
|
+
if (reserved !== null) {
|
|
239
|
+
if (!same(parse(reserved), pending))
|
|
240
|
+
return fail();
|
|
241
|
+
const observed = await this.client("recovery-docker-observed").read(recoveryName(pendingKey));
|
|
242
|
+
if (observed === null)
|
|
243
|
+
return fail();
|
|
244
|
+
const observation = parseObservation(observed);
|
|
245
|
+
if (observation.container_id !== container.containerId || !same(observation.deployment_labels, container.deploymentLabels))
|
|
246
|
+
return fail();
|
|
247
|
+
}
|
|
248
|
+
const parsed = parseOrganizationHandoffCapability({ ...pending, container_id: container.containerId,
|
|
249
|
+
organization_handoff_handle: createOrganizationHandoffHandle(pending, container.containerId), state: "finalized" });
|
|
250
|
+
if (parsed.state !== "finalized")
|
|
251
|
+
return fail();
|
|
252
|
+
const finalized = parsed;
|
|
253
|
+
const existing = await this.client("finalized-pending").read(`${key(pending.pending_key)}.json`);
|
|
254
|
+
if (existing !== null) {
|
|
255
|
+
const prior = parse(existing);
|
|
256
|
+
if (prior.state !== "finalized" || !same(prior, finalized))
|
|
257
|
+
return fail();
|
|
258
|
+
await this.validateDirectories();
|
|
259
|
+
return finalized;
|
|
260
|
+
}
|
|
261
|
+
const bytes = JSON.stringify(finalized);
|
|
262
|
+
await this.client("finalized").write(`${key(finalized.organization_handoff_handle)}.json`, bytes);
|
|
263
|
+
await this.client("finalized-pending").write(`${key(pending.pending_key)}.json`, bytes);
|
|
264
|
+
await this.validateDirectories();
|
|
265
|
+
return finalized;
|
|
266
|
+
}
|
|
267
|
+
async close(input) {
|
|
268
|
+
await this.validateDirectories();
|
|
269
|
+
await this.hook("close");
|
|
270
|
+
await this.validateDirectories();
|
|
271
|
+
const request = closeRequest(input);
|
|
272
|
+
const content = await this.client("finalized").read(`${key(request.organizationHandoffHandle)}.json`);
|
|
273
|
+
if (content === null)
|
|
274
|
+
return fail();
|
|
275
|
+
const final = parse(content);
|
|
276
|
+
if (final.state !== "finalized"
|
|
277
|
+
|| final.organization_handoff_handle !== request.organizationHandoffHandle
|
|
278
|
+
|| !same(final.handoff, request.expectedHandoff))
|
|
279
|
+
return fail();
|
|
280
|
+
const closed = parseOrganizationHandoffCapability({ ...final, state: "attach_closed" });
|
|
281
|
+
await this.client("attach-closed").write(`${key(request.organizationHandoffHandle)}.json`, JSON.stringify(closed));
|
|
282
|
+
await this.validateDirectories();
|
|
283
|
+
}
|
|
284
|
+
async resolve(input) {
|
|
285
|
+
try {
|
|
286
|
+
if (input?.signal?.aborted)
|
|
287
|
+
return fail();
|
|
288
|
+
const auth = parseOrganizationAttachmentAuthorizationForDeployment(input?.authorization);
|
|
289
|
+
await this.validateDirectories();
|
|
290
|
+
await this.hook("resolve");
|
|
291
|
+
await this.validateDirectories();
|
|
292
|
+
if (await this.client("attach-closed").read(`${key(auth.organization_handoff_handle)}.json`) !== null)
|
|
293
|
+
return fail();
|
|
294
|
+
const content = await this.client("finalized").read(`${key(auth.organization_handoff_handle)}.json`);
|
|
295
|
+
if (content === null)
|
|
296
|
+
return fail();
|
|
297
|
+
const final = parse(content);
|
|
298
|
+
const pendingFinal = await this.client("finalized-pending").read(`${key(final.pending_key)}.json`);
|
|
299
|
+
if (pendingFinal === null || !same(parse(pendingFinal), final) || final.state !== "finalized" || final.organization_handoff_handle !== auth.organization_handoff_handle
|
|
300
|
+
|| final.descriptor_digest !== auth.descriptor_digest || final.handoff.run_id !== auth.run_id
|
|
301
|
+
|| auth.operation_handle === final.handoff.network_attachment_handle
|
|
302
|
+
|| final.selected_target.handle !== auth.selected_target.handle || final.selected_target.fingerprint !== auth.selected_target.fingerprint)
|
|
303
|
+
return fail();
|
|
304
|
+
if (input.signal?.aborted)
|
|
305
|
+
return fail();
|
|
306
|
+
await this.validateDirectories();
|
|
307
|
+
return Object.freeze({ authorization: auth, descriptor_binding: Object.freeze({ binding_digest: final.binding_digest, descriptor_digest: final.descriptor_digest }),
|
|
308
|
+
handoff: final.handoff, network_attachment: Object.freeze({ container_id: final.container_id, deployment_labels: final.deployment_labels,
|
|
309
|
+
network_attachment_handle: final.handoff.network_attachment_handle }), selected_target_binding: Object.freeze({ receipt: final.selected_target,
|
|
310
|
+
receipt_digest: final.selected_target_receipt_digest }) });
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
return fail();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
export const initializeOrganizationHandoffAuthorityStore = async (options = {}) => {
|
|
318
|
+
const root = resolveOrganizationHandoffAuthorityRoot();
|
|
319
|
+
const parts = ["pending", "finalized", "finalized-pending", "attach-closed", "recovery-reserved", "recovery-docker-observed"];
|
|
320
|
+
await Promise.all(parts.map(async (part) => checkDirectory(path.join(root, part))));
|
|
321
|
+
const anchors = new Map();
|
|
322
|
+
const clients = new Map();
|
|
323
|
+
try {
|
|
324
|
+
for (const part of parts) {
|
|
325
|
+
const handle = await open(path.join(root, part), constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW).catch(fail);
|
|
326
|
+
// Register ownership before any operation that could throw, so the
|
|
327
|
+
// common rollback below closes even a validation-failing descriptor.
|
|
328
|
+
anchors.set(part, { handle, ino: 0, dev: 0 });
|
|
329
|
+
const stat = await handle.stat().catch(fail);
|
|
330
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 0o077) !== 0 || owner !== undefined && stat.uid !== owner)
|
|
331
|
+
return fail();
|
|
332
|
+
anchors.set(part, { handle, ino: stat.ino, dev: stat.dev });
|
|
333
|
+
}
|
|
334
|
+
const initializeClient = options.testInitializeFsClient ?? initializeOrganizationHandoffAuthorityFsClient;
|
|
335
|
+
for (const [part, anchor] of anchors) {
|
|
336
|
+
const client = await initializeClient({ cwd: path.join(root, part), dev: anchor.dev, ino: anchor.ino,
|
|
337
|
+
...(owner === undefined ? {} : { uid: owner }), ...(options.workerPath === undefined ? {} : { workerPath: options.workerPath }) });
|
|
338
|
+
// Transfer each completed helper into rollback ownership immediately.
|
|
339
|
+
clients.set(part, client);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
await Promise.all([...clients.values()].map(async (client) => client.dispose()));
|
|
344
|
+
await Promise.all([...anchors.values()].map(async ({ handle }) => { await handle.close().catch(() => undefined); }));
|
|
345
|
+
return fail();
|
|
346
|
+
}
|
|
347
|
+
return new Store(root, anchors, clients, options.testHooks);
|
|
348
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type OpaqueTargetHandle, type SelectedTargetReceipt } from "../target/index.js";
|
|
2
|
+
import { type OrganizationHandoff } from "./organizationHandoffTypes.js";
|
|
3
|
+
export declare const ORGANIZATION_HANDOFF_CAPABILITY_VERSION: "spawnfile.organization-handoff-capability.private.v1";
|
|
4
|
+
export declare const ORGANIZATION_HANDOFF_RECOVERY_VERSION: "spawnfile.organization-handoff-recovery.private.v1";
|
|
5
|
+
export declare const ORGANIZATION_HANDOFF_AUTHORITY_ERROR = "Organization handoff authority failed";
|
|
6
|
+
declare const labels: ("com.spawnfile.compile_fingerprint" | "com.spawnfile.project" | "com.spawnfile.deployment" | "com.spawnfile.run_id" | "com.spawnfile.unit" | "com.spawnfile.version")[];
|
|
7
|
+
export type OrganizationHandoffCapabilityState = "pending" | "finalized" | "attach_closed";
|
|
8
|
+
export type OrganizationHandoffDeploymentLabels = Readonly<Record<(typeof labels)[number], string>>;
|
|
9
|
+
export interface OrganizationHandoffCapabilityPending {
|
|
10
|
+
readonly binding_digest: string;
|
|
11
|
+
readonly container_name: string;
|
|
12
|
+
readonly deployment_labels: OrganizationHandoffDeploymentLabels;
|
|
13
|
+
readonly descriptor_digest: string;
|
|
14
|
+
readonly handoff: OrganizationHandoff;
|
|
15
|
+
readonly pending_key: string;
|
|
16
|
+
readonly selected_target: SelectedTargetReceipt;
|
|
17
|
+
readonly selected_target_receipt_digest: string;
|
|
18
|
+
readonly state: "pending";
|
|
19
|
+
readonly version: typeof ORGANIZATION_HANDOFF_CAPABILITY_VERSION;
|
|
20
|
+
}
|
|
21
|
+
export interface OrganizationHandoffCapabilityFinalized extends Omit<OrganizationHandoffCapabilityPending, "state"> {
|
|
22
|
+
readonly container_id: string;
|
|
23
|
+
readonly organization_handoff_handle: OpaqueTargetHandle;
|
|
24
|
+
readonly state: "finalized";
|
|
25
|
+
}
|
|
26
|
+
export interface OrganizationHandoffCapabilityClosed extends Omit<OrganizationHandoffCapabilityFinalized, "state"> {
|
|
27
|
+
readonly state: "attach_closed";
|
|
28
|
+
}
|
|
29
|
+
export type OrganizationHandoffCapability = OrganizationHandoffCapabilityPending | OrganizationHandoffCapabilityFinalized | OrganizationHandoffCapabilityClosed;
|
|
30
|
+
/**
|
|
31
|
+
* A direct, host-local checkpoint made only after Docker returned the exact
|
|
32
|
+
* container id and its inspected deployment labels. It deliberately does not
|
|
33
|
+
* represent a new capability state: capability authority remains
|
|
34
|
+
* pending -> finalized -> attach_closed.
|
|
35
|
+
*/
|
|
36
|
+
export interface OrganizationHandoffDockerObservation {
|
|
37
|
+
readonly container_id: string;
|
|
38
|
+
readonly deployment_labels: OrganizationHandoffDeploymentLabels;
|
|
39
|
+
readonly image_id: string;
|
|
40
|
+
readonly pending_key: string;
|
|
41
|
+
readonly version: typeof ORGANIZATION_HANDOFF_RECOVERY_VERSION;
|
|
42
|
+
}
|
|
43
|
+
export declare const createOrganizationHandoffPendingKey: (input: Omit<OrganizationHandoffCapabilityPending, "pending_key" | "state" | "version">) => string;
|
|
44
|
+
/** A domain-separated storage key; never use a raw capability pending key as a leaf name. */
|
|
45
|
+
export declare const createOrganizationHandoffRecoveryKey: (value: unknown) => string;
|
|
46
|
+
export declare const createOrganizationHandoffDockerObservation: (input: {
|
|
47
|
+
readonly containerId: unknown;
|
|
48
|
+
readonly deploymentLabels: unknown;
|
|
49
|
+
readonly imageId: unknown;
|
|
50
|
+
readonly pendingKey: unknown;
|
|
51
|
+
}) => OrganizationHandoffDockerObservation;
|
|
52
|
+
export declare const parseOrganizationHandoffDockerObservation: (raw: unknown) => OrganizationHandoffDockerObservation;
|
|
53
|
+
export declare const createOrganizationHandoffHandle: (pending: OrganizationHandoffCapabilityPending, containerId: unknown) => OpaqueTargetHandle;
|
|
54
|
+
export declare const createOrganizationHandoffCapabilityPending: (input: {
|
|
55
|
+
readonly bindingDigest: unknown;
|
|
56
|
+
readonly containerName: unknown;
|
|
57
|
+
readonly deploymentLabels: unknown;
|
|
58
|
+
readonly descriptorDigest: unknown;
|
|
59
|
+
readonly handoff: unknown;
|
|
60
|
+
readonly selectedTarget: unknown;
|
|
61
|
+
readonly selectedTargetReceiptDigest: unknown;
|
|
62
|
+
}) => OrganizationHandoffCapabilityPending;
|
|
63
|
+
export declare const parseOrganizationHandoffCapability: (raw: unknown) => OrganizationHandoffCapability;
|
|
64
|
+
export declare const parseOrganizationAttachmentAuthorizationForDeployment: (raw: unknown) => {
|
|
65
|
+
readonly descriptor_digest: string;
|
|
66
|
+
readonly operation_handle: OpaqueTargetHandle;
|
|
67
|
+
readonly organization_handoff_handle: OpaqueTargetHandle;
|
|
68
|
+
readonly request_digest: string;
|
|
69
|
+
readonly run_id: string;
|
|
70
|
+
readonly selected_target: {
|
|
71
|
+
readonly fingerprint: string;
|
|
72
|
+
readonly handle: OpaqueTargetHandle;
|
|
73
|
+
};
|
|
74
|
+
readonly version: "spawnfile.target-organization-attachment.authorization.v1";
|
|
75
|
+
};
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { assertOrdinaryJsonGraph, createCanonicalSelectedTargetReceiptBytes, parseOpaqueTargetHandle, parseRunId, parseSelectedTargetReceipt } from "../target/index.js";
|
|
3
|
+
import { dockerDeploymentLabelKeys } from "./dockerLabels.js";
|
|
4
|
+
import { parseOrganizationHandoff } from "./organizationHandoffTypes.js";
|
|
5
|
+
export const ORGANIZATION_HANDOFF_CAPABILITY_VERSION = "spawnfile.organization-handoff-capability.private.v1";
|
|
6
|
+
export const ORGANIZATION_HANDOFF_RECOVERY_VERSION = "spawnfile.organization-handoff-recovery.private.v1";
|
|
7
|
+
export const ORGANIZATION_HANDOFF_AUTHORITY_ERROR = "Organization handoff authority failed";
|
|
8
|
+
const DIGEST = /^sha256:[a-f0-9]{64}$/u;
|
|
9
|
+
const CONTAINER = /^[a-f0-9]{64}$/u;
|
|
10
|
+
const NAME = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/u;
|
|
11
|
+
const labels = Object.values(dockerDeploymentLabelKeys).sort();
|
|
12
|
+
const fail = () => { throw new Error(ORGANIZATION_HANDOFF_AUTHORITY_ERROR); };
|
|
13
|
+
const exact = (value, keys) => value !== null && typeof value === "object" && !Array.isArray(value)
|
|
14
|
+
&& Object.getPrototypeOf(value) === Object.prototype
|
|
15
|
+
&& Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
|
|
16
|
+
const digest = (value) => typeof value === "string" && DIGEST.test(value) ? value : fail();
|
|
17
|
+
const canonicalSelectedDigest = (selected) => `sha256:${createHash("sha256").update(createCanonicalSelectedTargetReceiptBytes(selected), "utf8").digest("hex")}`;
|
|
18
|
+
const exactLabels = (value) => {
|
|
19
|
+
if (!exact(value, labels))
|
|
20
|
+
return fail();
|
|
21
|
+
for (const key of labels)
|
|
22
|
+
if (typeof value[key] !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/u.test(value[key]))
|
|
23
|
+
fail();
|
|
24
|
+
return Object.freeze(Object.fromEntries(labels.map((key) => [key, value[key]])));
|
|
25
|
+
};
|
|
26
|
+
const key = (domain, value) => createHash("sha256")
|
|
27
|
+
.update(`spawnfile.organization-handoff-authority.${domain}.v1\0`, "utf8").update(value, "utf8").digest("hex");
|
|
28
|
+
const pendingKey = (value) => typeof value === "string" && /^[a-f0-9]{64}$/u.test(value) ? value : fail();
|
|
29
|
+
export const createOrganizationHandoffPendingKey = (input) => key("reservation", JSON.stringify(input));
|
|
30
|
+
/** A domain-separated storage key; never use a raw capability pending key as a leaf name. */
|
|
31
|
+
export const createOrganizationHandoffRecoveryKey = (value) => key("recovery", pendingKey(value));
|
|
32
|
+
export const createOrganizationHandoffDockerObservation = (input) => {
|
|
33
|
+
if (typeof input.containerId !== "string" || !CONTAINER.test(input.containerId)
|
|
34
|
+
|| typeof input.imageId !== "string" || !/^sha256:[a-f0-9]{64}$/u.test(input.imageId))
|
|
35
|
+
return fail();
|
|
36
|
+
return Object.freeze({
|
|
37
|
+
container_id: input.containerId,
|
|
38
|
+
deployment_labels: exactLabels(input.deploymentLabels),
|
|
39
|
+
image_id: input.imageId,
|
|
40
|
+
pending_key: pendingKey(input.pendingKey),
|
|
41
|
+
version: ORGANIZATION_HANDOFF_RECOVERY_VERSION
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export const parseOrganizationHandoffDockerObservation = (raw) => {
|
|
45
|
+
try {
|
|
46
|
+
assertOrdinaryJsonGraph(raw);
|
|
47
|
+
if (!exact(raw, ["container_id", "deployment_labels", "image_id", "pending_key", "version"])
|
|
48
|
+
|| raw.version !== ORGANIZATION_HANDOFF_RECOVERY_VERSION)
|
|
49
|
+
return fail();
|
|
50
|
+
const value = raw;
|
|
51
|
+
return createOrganizationHandoffDockerObservation({
|
|
52
|
+
containerId: value.container_id,
|
|
53
|
+
deploymentLabels: value.deployment_labels,
|
|
54
|
+
imageId: value.image_id,
|
|
55
|
+
pendingKey: value.pending_key
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return fail();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export const createOrganizationHandoffHandle = (pending, containerId) => {
|
|
63
|
+
if (typeof containerId !== "string" || !CONTAINER.test(containerId))
|
|
64
|
+
return fail();
|
|
65
|
+
const handle = parseOpaqueTargetHandle(`opaque_${key("capability", JSON.stringify({
|
|
66
|
+
binding_digest: pending.binding_digest, container_id: containerId, container_name: pending.container_name,
|
|
67
|
+
deployment_labels: pending.deployment_labels, descriptor_digest: pending.descriptor_digest,
|
|
68
|
+
handoff: pending.handoff, pending_key: pending.pending_key, selected_target: pending.selected_target,
|
|
69
|
+
selected_target_receipt_digest: pending.selected_target_receipt_digest
|
|
70
|
+
}))}`);
|
|
71
|
+
if (handle === pending.handoff.network_attachment_handle || handle === pending.selected_target.handle)
|
|
72
|
+
return fail();
|
|
73
|
+
return handle;
|
|
74
|
+
};
|
|
75
|
+
export const createOrganizationHandoffCapabilityPending = (input) => {
|
|
76
|
+
const handoff = parseOrganizationHandoff(input.handoff);
|
|
77
|
+
const selected = parseSelectedTargetReceipt(input.selectedTarget);
|
|
78
|
+
const selectedDigest = digest(input.selectedTargetReceiptDigest);
|
|
79
|
+
if (selectedDigest !== canonicalSelectedDigest(selected) || handoff.selected_target_receipt_digest !== selectedDigest
|
|
80
|
+
|| handoff.binding_digest !== digest(input.bindingDigest) || handoff.network_attachment_handle === selected.handle || typeof input.containerName !== "string"
|
|
81
|
+
|| !NAME.test(input.containerName))
|
|
82
|
+
return fail();
|
|
83
|
+
const body = { binding_digest: handoff.binding_digest, container_name: input.containerName,
|
|
84
|
+
deployment_labels: exactLabels(input.deploymentLabels), descriptor_digest: digest(input.descriptorDigest), handoff,
|
|
85
|
+
selected_target: selected,
|
|
86
|
+
selected_target_receipt_digest: selectedDigest };
|
|
87
|
+
return Object.freeze({ ...body, pending_key: createOrganizationHandoffPendingKey(body), state: "pending",
|
|
88
|
+
version: ORGANIZATION_HANDOFF_CAPABILITY_VERSION });
|
|
89
|
+
};
|
|
90
|
+
export const parseOrganizationHandoffCapability = (raw) => {
|
|
91
|
+
try {
|
|
92
|
+
assertOrdinaryJsonGraph(raw);
|
|
93
|
+
if (!raw || typeof raw !== "object")
|
|
94
|
+
return fail();
|
|
95
|
+
const record = raw;
|
|
96
|
+
const state = record.state;
|
|
97
|
+
const base = ["binding_digest", "container_name", "deployment_labels", "descriptor_digest", "handoff", "pending_key", "selected_target", "selected_target_receipt_digest", "state", "version"];
|
|
98
|
+
const extra = state === "pending" ? [] : ["container_id", "organization_handoff_handle"];
|
|
99
|
+
if (!exact(raw, [...base, ...extra]) || record.version !== ORGANIZATION_HANDOFF_CAPABILITY_VERSION
|
|
100
|
+
|| state !== "pending" && state !== "finalized" && state !== "attach_closed")
|
|
101
|
+
return fail();
|
|
102
|
+
const pending = createOrganizationHandoffCapabilityPending({ bindingDigest: record.binding_digest,
|
|
103
|
+
containerName: record.container_name, deploymentLabels: record.deployment_labels,
|
|
104
|
+
descriptorDigest: record.descriptor_digest, handoff: record.handoff,
|
|
105
|
+
selectedTarget: record.selected_target, selectedTargetReceiptDigest: record.selected_target_receipt_digest });
|
|
106
|
+
if (pending.pending_key !== record.pending_key)
|
|
107
|
+
return fail();
|
|
108
|
+
if (state === "pending")
|
|
109
|
+
return pending;
|
|
110
|
+
const containerId = record.container_id;
|
|
111
|
+
if (typeof containerId !== "string" || !CONTAINER.test(containerId))
|
|
112
|
+
return fail();
|
|
113
|
+
const handle = createOrganizationHandoffHandle(pending, containerId);
|
|
114
|
+
if (record.organization_handoff_handle !== handle || handle === pending.handoff.network_attachment_handle
|
|
115
|
+
|| handle === pending.selected_target.handle)
|
|
116
|
+
return fail();
|
|
117
|
+
if (state === "finalized")
|
|
118
|
+
return Object.freeze({ ...pending, container_id: containerId,
|
|
119
|
+
organization_handoff_handle: handle, state: "finalized" });
|
|
120
|
+
return Object.freeze({ ...pending, container_id: containerId, organization_handoff_handle: handle,
|
|
121
|
+
state: "attach_closed" });
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return fail();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
export const parseOrganizationAttachmentAuthorizationForDeployment = (raw) => {
|
|
128
|
+
try {
|
|
129
|
+
assertOrdinaryJsonGraph(raw);
|
|
130
|
+
const record = raw;
|
|
131
|
+
const keys = ["descriptor_digest", "operation_handle", "organization_handoff_handle", "request_digest", "run_id", "selected_target", "version"];
|
|
132
|
+
if (!exact(raw, keys) || record.version !== "spawnfile.target-organization-attachment.authorization.v1"
|
|
133
|
+
|| !exact(record.selected_target, ["fingerprint", "handle"]))
|
|
134
|
+
return fail();
|
|
135
|
+
const selected = parseSelectedTargetReceipt({ ...record.selected_target, version: "spawnfile.target-resource.selected-target.v1" });
|
|
136
|
+
const operationHandle = parseOpaqueTargetHandle(record.operation_handle);
|
|
137
|
+
const handoffHandle = parseOpaqueTargetHandle(record.organization_handoff_handle);
|
|
138
|
+
if (operationHandle === handoffHandle || operationHandle === selected.handle || handoffHandle === selected.handle)
|
|
139
|
+
return fail();
|
|
140
|
+
return Object.freeze({ descriptor_digest: digest(record.descriptor_digest), operation_handle: operationHandle,
|
|
141
|
+
organization_handoff_handle: handoffHandle, request_digest: digest(record.request_digest),
|
|
142
|
+
run_id: parseRunId(record.run_id), selected_target: Object.freeze({ fingerprint: selected.fingerprint, handle: selected.handle }),
|
|
143
|
+
version: "spawnfile.target-organization-attachment.authorization.v1" });
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return fail();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type OpaqueTargetHandle, type RunId } from "../target/index.js";
|
|
2
|
+
export declare const ORGANIZATION_HANDOFF_VERSION: "spawnfile.organization-handoff.v1";
|
|
3
|
+
declare const canonicalSha256Digest: unique symbol;
|
|
4
|
+
export type CanonicalSha256Digest = string & {
|
|
5
|
+
readonly [canonicalSha256Digest]: "CanonicalSha256Digest";
|
|
6
|
+
};
|
|
7
|
+
export interface OrganizationHandoffInput {
|
|
8
|
+
bindingDigest: CanonicalSha256Digest;
|
|
9
|
+
networkAttachmentHandle: OpaqueTargetHandle;
|
|
10
|
+
selectedTargetReceiptDigest: CanonicalSha256Digest;
|
|
11
|
+
}
|
|
12
|
+
export interface OrganizationHandoff {
|
|
13
|
+
binding_digest: CanonicalSha256Digest;
|
|
14
|
+
deployment_handle: string;
|
|
15
|
+
lifecycle_receipts: {
|
|
16
|
+
down: "spawnfile.down-receipt.v1";
|
|
17
|
+
export: "spawnfile.export-index.v1";
|
|
18
|
+
up: "spawnfile.up-receipt.v1";
|
|
19
|
+
};
|
|
20
|
+
network_attachment_handle: OpaqueTargetHandle;
|
|
21
|
+
run_id: RunId;
|
|
22
|
+
selected_target_receipt_digest: CanonicalSha256Digest;
|
|
23
|
+
version: typeof ORGANIZATION_HANDOFF_VERSION;
|
|
24
|
+
}
|
|
25
|
+
export declare const parseCanonicalSha256Digest: (value: unknown, label?: string) => CanonicalSha256Digest;
|
|
26
|
+
export declare const createOrganizationDeploymentHandle: (input: Omit<OrganizationHandoff, "deployment_handle" | "version">) => string;
|
|
27
|
+
export declare const createOrganizationHandoff: (runId: unknown, input: OrganizationHandoffInput) => OrganizationHandoff;
|
|
28
|
+
export declare const parseOrganizationHandoff: (value: unknown) => OrganizationHandoff;
|
|
29
|
+
export {};
|