everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 61.3 kB
Source Map (JSON)
{"version":3,"file":"train.mjs","names":[],"sources":["../../../src/services/deploy/train.ts"],"sourcesContent":["import { existsSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport { Context, Effect, Layer, Option } from \"effect\";\nimport { hasFolderFormUi } from \"every-plugin/build/ui\";\nimport { findConfigPath, isAppDescriptorPath, resolveUiRuntimeName } from \"../../config\";\nimport type { WorkspaceDeployResult } from \"../../contract\";\nimport {\n type ResolvedBootShape,\n resolveBootShape,\n verifyBootPayload,\n verifyResolvedBootShape,\n} from \"../../services/resolution/boot-check\";\nimport { openResolution } from \"../../services/resolution/session\";\nimport type { BosConfig, BosConfigInput, RuntimeConfig } from \"../../types\";\nimport { run } from \"../../utils/run\";\nimport { padRight } from \"../../utils/string\";\nimport { colors, icons } from \"../../utils/theme\";\nimport { ensureCustodyBalance, submitRegistryWriteCustody } from \"../auth/custody-signer\";\nimport { ensureDelegateKey, submitRegistryWriteDelegated } from \"../auth/delegate-signer\";\nimport { submitRegistryWrite } from \"../auth/near-signer\";\nimport { dispatchSubmit, SignerService, type SignerServiceShape } from \"../auth/signer\";\nimport { generateCodeArtifacts } from \"../codegen/artifacts\";\nimport { type PlatformReleaseManifest, PlatformReleaseManifestSchema } from \"../platform/manifest\";\nimport { confirmPublish, describeConfirmTimeout } from \"../registry/confirm\";\nimport { fetchBosConfigFromFastKv, fetchConfigHistory } from \"../registry/fastkv\";\nimport { pointerFingerprint, slotPins } from \"../registry/fingerprint\";\nimport { keyPathOf, parseRuntimeRef, runtimeRefOf } from \"../registry/keys\";\nimport {\n deployAuditKeyOf,\n platformPointerKeyOf,\n platformVersionSlotKeyOf,\n readPlatformPointer,\n readPlatformVersionSlot,\n} from \"../registry/pointer\";\nimport { mergeAuthoredOverPublished, stripLocalDevelopmentTargets } from \"../resolution/merge\";\nimport {\n type BuildTargetsDeps,\n type BuildTargetsInput,\n type BuildTargetsResult,\n BuildTrainService,\n buildWorkspaceTargets,\n resolveWorkspaceTarget,\n} from \"../workspace/build-train\";\nimport {\n resolveReleaseManifestForDeploy,\n runCompositionGate,\n stampInheritedSlotsFromRelease,\n} from \"./composition\";\nimport { BundleStorage, RegistryStore, type RegistryStoreShape } from \"./deps\";\nimport {\n type PreviousPin,\n pinsFromDeployState,\n pinsFromPublishedConfig,\n upsertDeployStatePins,\n} from \"./diff\";\nimport { PublishTrainError, type PublishTrainFailureResult, type PublishTrainOk } from \"./errors\";\nimport { formatNearError } from \"./format\";\nimport { readFrameworkVersion } from \"./image\";\nimport { applyDeployResults, type DeployResultEntry } from \"./integrity\";\nimport { computeOwedWork } from \"./owed\";\nimport { platformUrlDeployEntries, pluginUiUrlDeployEntries } from \"./platform\";\nimport {\n compatWindowViolations,\n composePlatformManifestPublishEntry,\n type PlatformManifestPublishEntry,\n platformTruthViolations,\n} from \"./platform-manifest\";\nimport { type PublishPreflightPlan, preflightPublish } from \"./preflight\";\nimport { type DeployTrainRender, DeployTrainRenderService } from \"./render\";\nimport { verifyRollbackSnapshot } from \"./rollback\";\nimport {\n realStorageLegDeps,\n type StorageLegDeps,\n sourceLegDirs,\n uploadWorkspaceBundle,\n} from \"./upload-leg\";\n\n/** Best-effort repo HEAD for the version manifest (`gitSha`): non-git\n * contexts (child bundles built outside a repo) omit the field silently —\n * it never fails the deploy. */\nasync function resolveGitSha(cwd: string): Promise<string | undefined> {\n try {\n const result = await run(\"git\", [\"rev-parse\", \"HEAD\"], { cwd, capture: true });\n const sha = result?.stdout.trim();\n return result && result.exitCode === 0 && sha ? sha : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport async function isConfigAlreadyPublished(opts: {\n account: string;\n gateway: string;\n publishConfig: BosConfigInput;\n registry?: string;\n fetchConfig?: typeof fetchBosConfigFromFastKv;\n}): Promise<boolean> {\n const fetchConfig = opts.fetchConfig ?? fetchBosConfigFromFastKv;\n try {\n const current = await fetchConfig<BosConfigInput>(\n `bos://${opts.account}/${opts.gateway}`,\n opts.registry,\n );\n return JSON.stringify(current) === JSON.stringify(opts.publishConfig);\n } catch {\n return false;\n }\n}\n\n/** Per-workspace upload facts the renderer needs (#431) — the leg reports,\n * the renderer shows. */\nexport interface UploadUnitDetail {\n base: string;\n uploaded: number;\n skipped: number;\n durationMs: number;\n notes: string[];\n}\n\nexport interface TrainDeps {\n storage: StorageLegDeps;\n registry: RegistryStoreShape;\n signer: SignerServiceShape;\n /** presentation seam (#431) — sections render; the train never prints */\n render?: DeployTrainRender;\n buildTrain: {\n buildTargets: (\n input: BuildTargetsInput,\n deps?: BuildTargetsDeps,\n ) => Promise<BuildTargetsResult>;\n };\n}\n\nexport interface DeployTrainInput {\n bosConfig: BosConfig;\n runtimeConfig: RuntimeConfig | null;\n configDir: string;\n env: \"production\" | \"staging\";\n build: boolean;\n dryRun: boolean;\n verbose: boolean;\n packages: string;\n network?: \"mainnet\" | \"testnet\";\n privateKey?: string;\n wallet?: boolean;\n registry?: string;\n /** Skip the diff upload and re-upload every dist file (escape hatch). */\n fullUpload?: boolean;\n /** Force every prerequisite rebuild even when the content-hash oracle judges\n * them fresh (the pre-#430 behavior; escape hatch for the oracle). */\n forceBuild?: boolean;\n /** Publish `bosConfig` verbatim — no authored/published merge, no ts-form\n * config-only guard. Rollbacks use this: the payload is the previous\n * snapshot, already assembled. */\n exactPayload?: boolean;\n /** Rollback-only pointer restore (#573): a smoke-failed release rolls the\n * config AND the platform pointer back in the same atomic write. Ignored\n * unless `exactPayload` — normal deploys cannot smuggle manifest writes\n * past the release gate. */\n restorePlatformPointer?: { key: string; value: string };\n}\n\n/**\n * The deploy-train publish core (ADR 0020, as amended): preflight\n * (storage/CDN creds + signing) fails fast before the build, then build →\n * upload → version-manifest pin → config write-back → FastKV publish +\n * read-back. Scoped to one plugin via `packages`, a single-plugin redeploy\n * ships real bytes to the storage origin — same as the full train, nothing\n * image-native left.\n *\n * Terminal failures throw `PublishTrainError` (the typed channel, ticket\n * #422); callers behind the service map it to wire shapes mechanically.\n */\nexport async function runPublishTrain(\n input: DeployTrainInput,\n deps: TrainDeps,\n): Promise<PublishTrainOk> {\n const preflight = await preflightPublish(input);\n if (preflight.kind === \"error\") {\n throw new PublishTrainError({\n kind: \"preflight\",\n registryUrl: preflight.registryUrl,\n error: preflight.error,\n });\n }\n if (preflight.kind === \"dry-run\") {\n return { status: \"dry-run\", registryUrl: preflight.registryUrl };\n }\n const plan: PublishPreflightPlan = preflight.plan;\n const {\n isStaging,\n account,\n gateway,\n network,\n registryUrl,\n registryNamespace,\n targets,\n useWallet,\n useCustody,\n strategy,\n } = plan;\n const storageOrigin = plan.storageOrigin;\n const storageApiKey = plan.storageApiKey;\n\n const { configDir } = input;\n const render = deps.render;\n let bosConfig = input.bosConfig;\n const runtimeConfig = input.runtimeConfig;\n let built: string[] | undefined;\n let skipped: string[] | undefined;\n let deployResults: WorkspaceDeployResult[] | undefined;\n const urlOrigin = plan.cdnOrigin ?? `https://${gateway}`;\n const platformEntries: DeployResultEntry[] = [];\n const fullUpload = input.fullUpload === true || process.env.BOS_FULL_UPLOAD === \"1\";\n const sourcePublish = bosConfig.publish?.sourcePublish === true;\n const gitSha = await resolveGitSha(configDir);\n const memoryBackendAbort = () =>\n new PublishTrainError({\n kind: \"memory-backend\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error:\n \"The receiving instance is serving bundle storage from memory (BOS_STORAGE_* R2 credentials are not configured there) — uploaded bytes would be lost on restart. Aborting before publish.\",\n });\n\n // Previous per-workspace pins for the diff upload: the local pointer wins\n // (written after every confirmed publish), the published config is the\n // fallback. Neither → full upload. Hoisted above the build so pipelined\n // uploads can read it the moment a build completes.\n const prevPins: Record<string, PreviousPin> = fullUpload\n ? {}\n : {\n ...pinsFromPublishedConfig(\n (plan.publishedConfig ?? {}) as BosConfigInput,\n account,\n gateway,\n ),\n ...pinsFromDeployState(configDir, account, gateway),\n };\n\n const authoredPath = findConfigPath(configDir);\n const tsForm = authoredPath !== null && isAppDescriptorPath(authoredPath);\n // Resolved before the build phase: pipelined uploads (#430) start the moment\n // a workspace build completes and the folder-form plugin-ui leg reads the\n // authored config — the binding must be live by then, never first\n // initialized after the train. The post-build refresh reassigns\n // publishRawConfig for the publish payload.\n const openedRaw = await openResolution({ cwd: configDir });\n if (!openedRaw?.rawConfig) {\n throw new PublishTrainError({\n kind: \"reload\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: \"Failed to load the authored config for publish\",\n });\n }\n const authoredRawConfig = openedRaw.rawConfig;\n let publishRawConfig: BosConfigInput = authoredRawConfig;\n\n render?.cdnBanner?.(storageOrigin);\n\n // One workspace = one upload unit: the workspace bundle, then (for\n // folder-form plugin workspaces) its <plugin>/ui/dist as its own bundle\n // key. Workspace paths resolve from the authored config — identical before\n // and after the post-build config refresh — so pipelined uploads (#430) can\n // start the moment a build completes.\n const uploadOneWorkspace = async (\n key: string,\n rawConfig: BosConfigInput,\n ): Promise<{\n entries: DeployResultEntry[];\n detail: UploadUnitDetail;\n shared: Record<string, Record<string, string>>;\n }> => {\n const startedAt = Date.now();\n const ws = resolveWorkspaceTarget(key, bosConfig, runtimeConfig, configDir);\n if (!ws)\n return {\n entries: [],\n detail: { base: \"\", uploaded: 0, skipped: 0, durationMs: 0, notes: [] },\n shared: {},\n };\n\n const outcome = await uploadWorkspaceBundle({\n account,\n gateway,\n workspaceKey: key,\n distDir: join(ws.path, \"dist\"),\n storageOrigin,\n storageApiKey,\n urlOrigin,\n previousPin: prevPins[key],\n ...(sourcePublish ? { source: sourceLegDirs(ws.path) } : {}),\n ...(gitSha ? { gitSha } : {}),\n deps: deps.storage,\n });\n if (outcome.kind === \"error\") {\n throw new PublishTrainError({\n kind: \"upload\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: outcome.message,\n });\n }\n if (outcome.kind === \"memory\") throw memoryBackendAbort();\n if (outcome.kind === \"missing-manifest\") {\n throw new PublishTrainError({\n kind: \"missing-manifest\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `bundle upload for ${key}: version manifest missing — the dist predates hashed entry names (rebuild required; atomic-deploys hard break)`,\n });\n }\n\n if (sourcePublish && outcome.storage === \"memory\") throw memoryBackendAbort();\n\n const entries = platformUrlDeployEntries({\n origin: urlOrigin,\n account,\n gateway,\n key,\n kind: ws.kind,\n integrity: outcome.entryIntegrity,\n ssrIntegrity: outcome.ssrEntryIntegrity,\n pin: outcome.pin,\n });\n\n // Folder-form plugin ui: the workspace build also produces <plugin>/ui/dist\n // (web remoteEntry + ssr container) — upload it as its own bundle key and\n // pin <slot>.<key>.ui.* so the host can compose the ui surface in production.\n let uiOutcomeShared: Record<string, string> | undefined;\n if (hasFolderFormUi(ws.path)) {\n const uiDistDir = join(ws.path, \"ui\", \"dist\");\n const uiSlot = ws.kind === \"app\" ? \"app\" : \"plugins\";\n const rawSlot = (uiSlot === \"app\" ? rawConfig.app : rawConfig.plugins) as\n | Record<string, Record<string, unknown> | undefined>\n | undefined;\n const rawUi = rawSlot?.[key]?.ui as Record<string, unknown> | undefined;\n const uiName = resolveUiRuntimeName(rawUi, join(ws.path, \"ui\"), key);\n let uiIntegrity: string | undefined;\n let uiSsrIntegrity: string | undefined;\n let uiPin: (typeof outcome)[\"pin\"] | undefined;\n if (existsSync(uiDistDir)) {\n const uiOutcome = await uploadWorkspaceBundle({\n account,\n gateway,\n workspaceKey: `${key}-ui`,\n distDir: uiDistDir,\n storageOrigin,\n storageApiKey,\n urlOrigin,\n previousPin: prevPins[`${key}-ui`],\n deps: deps.storage,\n });\n if (uiOutcome.kind === \"error\") {\n throw new PublishTrainError({\n kind: \"upload\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: uiOutcome.message,\n });\n }\n if (uiOutcome.kind === \"memory\") throw memoryBackendAbort();\n if (uiOutcome.kind === \"missing-manifest\") {\n throw new PublishTrainError({\n kind: \"missing-manifest\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `bundle upload for ${key}-ui: version manifest missing — the dist predates hashed entry names (rebuild required; atomic-deploys hard break)`,\n });\n }\n uiIntegrity = uiOutcome.entryIntegrity;\n uiSsrIntegrity = uiOutcome.ssrEntryIntegrity;\n uiPin = uiOutcome.pin;\n uiOutcomeShared = uiOutcome.shared;\n } else {\n console.log(\n ` ${colors.green(icons.ok)} ${padRight(`${key}-ui`, 28)} → ${urlOrigin}/bundles/${account}/${gateway}/${key}-ui/`,\n );\n }\n\n entries.push(\n ...pluginUiUrlDeployEntries({\n origin: urlOrigin,\n account,\n gateway,\n key,\n kind: ws.kind,\n integrity: uiIntegrity,\n ssrIntegrity: uiSsrIntegrity,\n name: uiName,\n pin: uiPin,\n }),\n );\n }\n\n return {\n entries,\n detail: {\n base: outcome.detail.base,\n uploaded: outcome.uploaded,\n skipped: outcome.skipped,\n durationMs: Date.now() - startedAt,\n notes: outcome.detail.notes,\n },\n shared: {\n ...(outcome.shared ? { [key]: outcome.shared } : {}),\n ...(uiOutcomeShared ? { [`${key}-ui`]: uiOutcomeShared } : {}),\n },\n };\n };\n\n // Uploads are independent bundle keys (#430): bounded concurrency, and —\n // when building — each workspace's upload pipelines as its build completes\n // instead of waiting for the whole train. The merged config assembles in\n // target order (byte-identical to the serial train); the first failure in\n // that order is the one thrown.\n const uploadConcurrency = Math.max(1, Number(process.env.BOS_UPLOAD_CONCURRENCY) || 4);\n interface UploadUnitResult {\n entries: DeployResultEntry[];\n detail: UploadUnitDetail;\n /** Shared-singleton versions per uploaded bundle key (#546) — the truth\n * gate cross-checks these against the platform release manifest. */\n shared: Record<string, Record<string, string>>;\n }\n const uploaded = new Map<string, Promise<UploadUnitResult>>();\n // Rejections stay in the map until the drain's allSettled — deleting would\n // both swallow the failure (the drain substitutes an empty result) and let\n // the fallback loop silently re-attempt the upload. The immediate no-op\n // catch keeps the pipelined rejection handled while the build continues.\n const trackUpload = (key: string, pending: Promise<UploadUnitResult>) => {\n uploaded.set(key, pending);\n pending.catch(() => {});\n };\n let inFlight = 0;\n const waiters: Array<() => void> = [];\n const acquireUploadSlot = () => {\n if (inFlight < uploadConcurrency) {\n inFlight++;\n return Promise.resolve();\n }\n return new Promise<void>((resolve) => waiters.push(resolve));\n };\n const releaseUploadSlot = () => {\n inFlight--;\n waiters.shift()?.();\n };\n const startUpload = (key: string) => {\n if (uploaded.has(key)) return;\n trackUpload(\n key,\n (async () => {\n await acquireUploadSlot();\n try {\n return await uploadOneWorkspace(key, authoredRawConfig);\n } finally {\n releaseUploadSlot();\n }\n })(),\n );\n };\n\n if (input.build) {\n await generateCodeArtifacts(configDir, bosConfig, {\n env: \"production\",\n runtimeConfig: runtimeConfig ?? undefined,\n });\n\n const result = await deps.buildTrain.buildTargets(\n {\n configDir,\n bosConfig,\n runtimeConfig,\n targets,\n deploy: true,\n verbose: input.verbose,\n ...(input.forceBuild ? { forceBuild: true } : {}),\n },\n {\n onWorkspaceBuilt: (key) => {\n if (targets.includes(key)) startUpload(key);\n },\n },\n );\n built = result.built;\n skipped = result.skipped;\n deployResults = result.deployResults;\n\n if (deployResults) {\n const failures = deployResults.filter((r) => !r.success);\n if (failures.length > 0) {\n const total = deployResults.length;\n console.log();\n console.log(\n colors.error(\n ` ${icons.err} Deploy failed — ${failures.length} of ${total} workspace${total > 1 ? \"s\" : \"\"} failed`,\n ),\n );\n console.log();\n for (const f of failures) {\n const errorLine = (f.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${padRight(f.key, 28)} ${errorLine}`);\n }\n console.log();\n if (!input.verbose) {\n console.log(colors.dim(\" Run with --verbose for full build output.\"));\n console.log();\n }\n throw new PublishTrainError({\n kind: \"build\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `${failures.length} of ${total} workspaces failed to deploy`,\n });\n }\n }\n\n const refreshed = await openResolution({ cwd: configDir });\n if (!refreshed?.config) {\n throw new PublishTrainError({\n kind: \"reload\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: \"Failed to reload the config after build\",\n });\n }\n\n bosConfig = refreshed.config;\n if (refreshed.rawConfig) publishRawConfig = refreshed.rawConfig;\n }\n\n if (\n tsForm &&\n !input.build &&\n input.exactPayload !== true &&\n plan.publishedConfigState === \"unreachable\"\n ) {\n // A config-only TS-form publish derives its pipeline state from the live\n // published config — publishing without it would wipe bundle URLs.\n throw new PublishTrainError({\n kind: \"config-state\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error:\n \"Cannot read the currently published config from the registry — a config-only publish would overwrite live bundle URLs. Retry when the registry is reachable, or run a full deploy.\",\n });\n }\n let publishPayload: BosConfigInput =\n input.exactPayload === true\n ? // The rollback payload is a previous snapshot: Zod-parsed form, already\n // assembled — the hand-written input shape and the parsed shape agree\n // at runtime; the declared types don't (pre-existing publish.ts:779).\n (input.bosConfig as unknown as BosConfigInput)\n : tsForm && !input.build\n ? // Config-only publish on a TS-form project: the authored config owns\n // composition (hand-edits win) while live pipeline state (bundle\n // URLs, integrity) carries over from the published config.\n mergeAuthoredOverPublished(\n (plan.publishedConfig ?? {}) as BosConfigInput,\n publishRawConfig,\n )\n : publishRawConfig;\n\n // Everything the pipeline has not already started uploads now — same\n // bounded pool. With build:false there is nothing to upload (config-only).\n for (const key of built ?? []) {\n if (targets.includes(key)) startUpload(key);\n }\n\n const deployTargets = (built ?? []).filter((key) => targets.includes(key));\n const settled = await Promise.allSettled(\n deployTargets.map(\n (key) =>\n uploaded.get(key) ??\n Promise.resolve({\n entries: [],\n detail: { base: \"\", uploaded: 0, skipped: 0, durationMs: 0, notes: [] },\n shared: {},\n }),\n ),\n );\n // Shared-singleton versions per uploaded bundle key (#546) — the truth gate\n // consumes this before the platform manifest rides the atomic publish.\n const sharedByWorkspace = new Map<string, Record<string, string>>();\n\n const uploadFailures = settled\n .map((result, index) =>\n result.status === \"rejected\"\n ? { key: deployTargets[index], error: result.reason as unknown }\n : null,\n )\n .filter((entry): entry is { key: string; error: unknown } => entry !== null);\n\n for (let index = 0; index < deployTargets.length; index++) {\n const result = settled[index];\n const key = deployTargets[index];\n if (result.status === \"fulfilled\") {\n platformEntries.push(...result.value.entries);\n for (const [bundleKey, shared] of Object.entries(result.value.shared)) {\n sharedByWorkspace.set(bundleKey, shared);\n }\n render?.uploadOutcome?.({\n key,\n ok: true,\n ...(input.verbose ? { detailNotes: result.value.detail.notes } : {}),\n ...result.value.detail,\n });\n } else {\n render?.uploadOutcome?.({ key, ok: false });\n }\n }\n\n if (uploadFailures.length > 0) {\n const thrown = uploadFailures[0].error;\n if (thrown instanceof PublishTrainError) throw thrown;\n throw new PublishTrainError({\n kind: \"upload\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: thrown instanceof Error ? thrown.message : String(thrown),\n });\n }\n\n if (platformEntries.length > 0) {\n const merged = applyDeployResults(publishRawConfig as Record<string, unknown>, platformEntries);\n if (!tsForm) {\n // Legacy JSON-form children keep their local write-back; TS-form keeps\n // pipeline state in FastKV only — a write-back would shadow the\n // authored bos.app.ts descriptor.\n try {\n writeFileSync(join(configDir, \"bos.config.json\"), `${JSON.stringify(merged, null, 2)}\\n`);\n } catch (error) {\n throw new PublishTrainError({\n kind: \"config-write\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `Failed to write bundle URLs to bos.config.json: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n }\n publishPayload = merged as BosConfigInput;\n }\n if (isStaging) {\n publishPayload = { ...publishPayload, domain: gateway };\n }\n // Publish canonicalization (#584): the published payload never carries\n // `local:` development targets — workspace-relative refs are meaningless\n // across an extends boundary, and children inheriting one cannot spawn it.\n // The authored surface keeps them for the parent's own dev; children fall\n // back to the slot's published URL. Rollback payloads are already\n // canonical — republished verbatim.\n if (input.exactPayload !== true) {\n publishPayload = stripLocalDevelopmentTargets(publishPayload);\n }\n\n // KEEP: release-scoped extends inheritance (ADR 0034 amendment) — every\n // remote slot the authored config does not declare is a base-runtime slot\n // whose bytes re-point at the authored platform pin's release, so the\n // parent's live config pointer can move (a root rc.N+1 publish) without\n // skewing a pinned child's composition. Resolution failures warn and\n // continue unpinned; the composition gate below still cross-checks bytes.\n let resolvedRelease: PlatformReleaseManifest | null = null;\n if (input.exactPayload !== true) {\n try {\n resolvedRelease = await resolveReleaseManifestForDeploy({\n configDir,\n authoredConfig: publishRawConfig as Record<string, unknown>,\n });\n if (resolvedRelease) {\n const stamped = stampInheritedSlotsFromRelease({\n payload: publishPayload as Record<string, unknown>,\n authoredConfig: publishRawConfig as Record<string, unknown>,\n manifest: resolvedRelease,\n });\n if (stamped.stamped.length > 0) {\n console.log(\n colors.dim(\n ` Release-scoped slots (${resolvedRelease.frameworkVersion}): stamped ${stamped.stamped.join(\", \")}`,\n ),\n );\n }\n }\n } catch (error) {\n console.log(\n colors.dim(\n ` Note: release-manifest resolution failed — continuing without release-scoped slots: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n }\n\n // KEEP: this check re-runs the consumer boot's own walk-merge-parse\n // (BosConfigSchema via resolvePublishedConfig) with the payload as the leaf,\n // so it shares one walk with the composition gate below via\n // verifyResolvedBootShape instead of re-walking.\n let bootShape: ResolvedBootShape | null = null;\n try {\n bootShape = await resolveBootShape(\n publishPayload,\n { account, gateway },\n {\n ...(input.registry ? { registry: input.registry } : {}),\n },\n );\n } catch {\n // KEEP: re-walked by verifyBootPayload, which owns the chain-failure report\n }\n const bootCheck = bootShape\n ? verifyResolvedBootShape(publishPayload, bootShape)\n : await verifyBootPayload(\n publishPayload,\n { account, gateway },\n {\n ...(input.registry ? { registry: input.registry } : {}),\n },\n );\n if (!bootCheck.ok) {\n const detail = bootCheck.issues\n .slice(0, 5)\n .map((issue) => ` ${issue.path ? `${issue.path}: ` : \"\"}${issue.message}`)\n .join(\"\\n\");\n const chainNote =\n bootCheck.chain.length > 0 ? ` (extends chain: ${bootCheck.chain.join(\" -> \")})` : \"\";\n throw new PublishTrainError({\n kind: \"preflight\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `Canonicalized publish payload fails a consumer boot${chainNote} — booting it would fail everywhere:\\n${detail}`,\n });\n }\n\n const pinVerification = await verifyRollbackSnapshot(publishPayload);\n if (pinVerification.verifiable && !pinVerification.ok) {\n const failures = pinVerification.slots\n .filter((check) => !check.ok)\n .map((check) => ` ${check.slot}: ${check.reason}`)\n .join(\"\\n\");\n console.error(\n ` ${colors.error(icons.err)} Publish blocked — a pinned slot's bytes do not serve at its production URL:\\n${failures}`,\n );\n throw new PublishTrainError({\n kind: \"pin-verification\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `Publish blocked — pinned slot bytes missing or SRI mismatched:\\n${failures}`,\n });\n }\n\n if (input.exactPayload !== true) {\n // KEEP: a rollback republishes a snapshot that was a valid deploy — the\n // gate must never block the recovery path (its snapshot's inherited\n // slots merge over the parent's moved-on pins; boot-check + pin\n // verification above already gate the bytes).\n if (!bootShape) {\n throw new PublishTrainError({\n kind: \"composition\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: \"the extends walk failed without a boot-check rejection\",\n });\n }\n const verifiedSlots = pinVerification.verifiable\n ? new Set(pinVerification.slots.filter((check) => check.ok).map((check) => check.slot))\n : undefined;\n const compositionGate = await runCompositionGate({\n configDir,\n authoredConfig: publishRawConfig as Record<string, unknown>,\n resolvedShape: bootShape.config as Record<string, unknown>,\n resolvedRelease,\n ...(verifiedSlots ? { verifiedSlots } : {}),\n });\n if (!compositionGate.ok) {\n throw new PublishTrainError({\n kind: \"composition\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error:\n `Publish blocked — a consumer boot would refuse this composition:\\n` +\n compositionGate.violations.map((line) => ` ${line}`).join(\"\\n\"),\n });\n }\n }\n\n const registryKey = keyPathOf({\n kind: \"runtimeConfig\",\n ref: runtimeRefOf({ accountId: account, gatewayId: gateway }),\n });\n const publishedAt = new Date().toISOString();\n // version identity printed + returned for every deploy (atomic-deploys 12)\n const fingerprint = pointerFingerprint(publishPayload as never);\n const publishSlotPins = slotPins(publishPayload as never);\n const registryEntries: Record<string, string> = {\n [registryKey]: JSON.stringify(publishPayload),\n };\n const manifestKey = deployAuditKeyOf(account, gateway, publishedAt);\n // ADR 0034 + #573: the platform release manifest rides the same atomic\n // write as the config. The truth gate (shared-singleton cross-check) runs\n // on every production build deploy — but only the **release leg** writes\n // keys: the immutable `platform-versions/<version>` slot plus the\n // `platform.json` pointer flip. Non-release deploys write no manifest\n // keys at all. The preflight npm gate guarantees npm is published before\n // the build (npmOwed is impossible in-train until #575 moves the npm leg\n // in), so the release classifier is the pointer alone — and its read MUST\n // succeed: an unknown state must never silently classify a release as\n // non-release (the skip path is deleted, #573). Satellites keep\n // independent npm releases and are not gating for the platform; the\n // manifest records the composition as smoke-tested at the release SHA.\n // A release that cannot complete cleanly burns its counter — never reuse\n // a version.\n let platformManifest: PlatformManifestPublishEntry | null = null;\n if (!isStaging && input.build) {\n let pointer: PlatformReleaseManifest | null;\n try {\n const pointerBytes = await readPlatformPointer<unknown>(account, gateway, input.registry);\n pointer = pointerBytes ? PlatformReleaseManifestSchema.parse(pointerBytes) : null;\n } catch (error) {\n throw new PublishTrainError({\n kind: \"platform-manifest\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error:\n `could not read the published platform release — the release classifier and ` +\n `the compat floor must never be guessed: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n const owed = computeOwedWork({\n pointer: pointer\n ? { state: \"present\", frameworkVersion: pointer.frameworkVersion }\n : { state: \"absent\" },\n localFrameworkVersion: readFrameworkVersion(configDir),\n });\n const releaseLeg = owed.release;\n console.log(\n releaseLeg\n ? colors.cyan(\n ` Release leg: the platform pointer (${owed.detail.pointerFrameworkVersion ?? \"unset\"}) trails the repo (${owed.detail.localFrameworkVersion}) — the release manifest moves`,\n )\n : colors.dim(\" No release work owed — the platform manifest stays put\"),\n );\n\n const composed = composePlatformManifestPublishEntry({\n configDir,\n account,\n gateway,\n previousFrameworkVersion: pointer?.frameworkVersion,\n gitSha,\n publishPayload: publishPayload as Record<string, unknown>,\n });\n // The truth gate (#546, extended by #573): runs on EVERY production\n // deploy against the composed release manifest — a workspace whose\n // installed shared versions drifted from the catalog (stale install,\n // misaligned bump) would publish bundles that lie about the compat\n // window. Refuses loudly until the next rc realigns them.\n if (composed) {\n const violations = platformTruthViolations(composed.manifest, sharedByWorkspace);\n if (violations.length > 0) {\n throw new PublishTrainError({\n kind: \"platform-truth\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error:\n `platform manifest does not match the uploaded bundles:\\n` +\n violations.map((line) => ` ${line}`).join(\"\\n\"),\n });\n }\n if (!releaseLeg) {\n const windowViolations = compatWindowViolations(pointer?.sharedDeps, sharedByWorkspace);\n if (windowViolations.length > 0) {\n throw new PublishTrainError({\n kind: \"compat-window\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error:\n `non-release deploy bakes a chain the pinned compat window doesn't serve — ` +\n `pinned children would resolve skew under an unchanged platform manifest:\\n` +\n windowViolations.map((line) => ` ${line}`).join(\"\\n\"),\n });\n }\n }\n if (releaseLeg) {\n const frameworkVersion = composed.manifest.frameworkVersion;\n const slotKey = platformVersionSlotKeyOf(account, gateway, frameworkVersion);\n let existingSlot: unknown;\n try {\n existingSlot = await readPlatformVersionSlot<unknown>(\n account,\n gateway,\n frameworkVersion,\n input.registry,\n );\n } catch (error) {\n throw new PublishTrainError({\n kind: \"platform-manifest\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `the release leg could not verify the version slot's immutability (${slotKey}): ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n if (existingSlot !== null) {\n const existingValue =\n typeof existingSlot === \"string\" ? existingSlot : JSON.stringify(existingSlot);\n if (existingValue !== composed.value) {\n throw new PublishTrainError({\n kind: \"platform-manifest\",\n registryUrl,\n built,\n skipped,\n deployResults,\n error: `version ${frameworkVersion} is burned — the immutable slot ${slotKey} already holds different bytes. Bump the version and cut a fresh release; never reuse a burned one.`,\n });\n }\n console.log(\n colors.dim(\n ` version slot ${frameworkVersion} already holds identical bytes — idempotent republish`,\n ),\n );\n }\n platformManifest = { ...composed, key: slotKey };\n }\n }\n }\n registryEntries[manifestKey] = JSON.stringify({\n account,\n gateway,\n network,\n publishedAt,\n registryUrl,\n ...(platformManifest\n ? {\n platformManifest: {\n file: platformManifest.key,\n integrity: platformManifest.integrity,\n version: platformManifest.manifest.frameworkVersion,\n pointer: platformPointerKeyOf(account, gateway),\n },\n }\n : {}),\n });\n if (platformManifest) {\n // One atomic write (#573): the immutable version slot + the pointer flip.\n registryEntries[platformManifest.key] = platformManifest.value;\n registryEntries[platformPointerKeyOf(account, gateway)] = platformManifest.value;\n }\n if (input.exactPayload && input.restorePlatformPointer) {\n registryEntries[input.restorePlatformPointer.key] = input.restorePlatformPointer.value;\n }\n\n render?.publish?.({\n registryUrl,\n fingerprint,\n slotPins: Object.entries(publishSlotPins),\n auditManifestFile: manifestKey.split(\"/\").pop() ?? manifestKey,\n });\n\n // Record the live pins for the next deploy's diff upload — only after the\n // config is confirmed published, so the pointer never claims undeployed state.\n const persistDeployState = () => {\n try {\n const pins = pinsFromPublishedConfig(publishPayload as BosConfigInput, account, gateway);\n if (Object.keys(pins).length > 0) {\n upsertDeployStatePins(configDir, account, gateway, pins);\n }\n } catch (error) {\n console.log(\n colors.dim(\n ` Note: could not update .bos/deploy-state.json — ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n };\n\n try {\n // NOT deduped with the preflight's published-config read (#430): that\n // fetch returns the raw stored JSON, while the idempotency comparison is\n // normalization-sensitive (the registry reader Zod-parses — defaults and\n // key order differ) — comparing across the two readers misdetects drift\n // and would republish every run. The equality fetch stays.\n const alreadyPublished = await isConfigAlreadyPublished({\n account,\n gateway,\n publishConfig: publishPayload,\n registry: input.registry,\n fetchConfig: deps.registry.fetchConfig,\n });\n if (alreadyPublished) {\n console.log(\" Already up to date — skipping transaction\");\n persistDeployState();\n return {\n status: \"published\",\n registryUrl,\n built,\n skipped,\n deployResults,\n publishConfig: publishPayload,\n };\n }\n\n console.log(` Submitting transaction on ${network}...`);\n\n // Auth handles were validated once in preflight (guards once per run,\n // ticket #422) — the dispatch consumes the plan's handles.\n const result = await (async (): Promise<{ success: boolean; txHash?: string }> => {\n if (useCustody) {\n if (!plan.custodyWallet) {\n throw new PublishTrainError({\n kind: \"submit\",\n registryUrl,\n error: \"custody publish requires the preflight custody wallet\",\n });\n }\n return deps.signer.submit({\n mode: \"custody\",\n account,\n contract: registryNamespace,\n args: registryEntries,\n custodyWallet: plan.custodyWallet,\n idempotencyKey: `bos-publish-${fingerprint}`,\n });\n }\n if (useWallet) {\n const credential = plan.credential;\n if (!credential || credential.accountId !== account) {\n throw new PublishTrainError({\n kind: \"submit\",\n registryUrl,\n error: `--wallet requires a CLI session under ${account}. Run bos login first.`,\n });\n }\n return deps.signer.submit({\n mode: \"wallet\",\n account,\n contract: registryNamespace,\n network,\n args: registryEntries,\n credential,\n configDir,\n });\n }\n if (!strategy) {\n throw new PublishTrainError({\n kind: \"submit\",\n registryUrl,\n error: \"non-wallet publish requires a resolved signing strategy\",\n });\n }\n return deps.signer.submit({\n mode: \"key\",\n account,\n contract: registryNamespace,\n network,\n args: registryEntries,\n privateKey: input.privateKey,\n strategy,\n });\n })();\n\n if (result.txHash) {\n console.log(` Transaction submitted: ${colors.dim(result.txHash)}`);\n }\n\n console.log(\" Waiting for publish confirmation...\");\n try {\n const confirmLegs = [\n {\n kind: \"runtimeConfig\" as const,\n key: {\n kind: \"runtimeConfig\" as const,\n ref: runtimeRefOf({ accountId: account, gatewayId: gateway }),\n },\n expected: publishPayload,\n },\n // The release leg's pointer flip is a written leg like any other —\n // it reads back through the pre-cutover transport until it serves\n // the manifest this train just published (the Nov-03 smoke caught\n // these reads resolving a double-prefixed key; a leg that never\n // verified is how a broken read hides).\n ...(platformManifest\n ? [\n {\n kind: \"platformPointer\" as const,\n wireKey: platformPointerKeyOf(account, gateway),\n expected: platformManifest.manifest,\n read: () => readPlatformPointer<unknown>(account, gateway, input.registry),\n },\n ]\n : []),\n ];\n const verdict = await confirmPublish({\n legs: confirmLegs,\n ...(result.txHash ? { txHash: result.txHash } : {}),\n read: (key) => deps.registry.fetchConfig(key.ref, input.registry),\n history: (key, limit) => {\n const { accountId, gatewayId } = parseRuntimeRef(key.ref);\n return deps.registry.fetchHistory({\n accountId,\n gatewayId,\n registry: input.registry,\n limit,\n keyPath: keyPathOf(key),\n });\n },\n });\n if (!verdict.ok) {\n throw new Error(describeConfirmTimeout(confirmLegs, verdict));\n }\n } catch (error) {\n throw new PublishTrainError({\n kind: \"confirm\",\n registryUrl,\n error: formatNearError(error),\n built,\n skipped,\n deployResults,\n });\n }\n persistDeployState();\n\n return {\n status: \"published\",\n registryUrl,\n txHash: result.txHash,\n fingerprint,\n slotPins: publishSlotPins,\n built,\n skipped,\n deployResults,\n publishConfig: publishPayload,\n releaseLeg: platformManifest !== null,\n ...(platformManifest ? { frameworkVersion: platformManifest.manifest.frameworkVersion } : {}),\n };\n } catch (error) {\n if (error instanceof PublishTrainError) throw error;\n throw new PublishTrainError({\n kind: \"sign\",\n registryUrl,\n error: formatNearError(error),\n built,\n skipped,\n deployResults,\n });\n }\n}\n\n/** Procedural entry point: the train behind a plain promise — legacy callers\n * and tests see the string-error result shape, the Effect service maps the\n * typed channel. */\nexport async function publishToFastKv(input: DeployTrainInput): Promise<PublishToFastKvResult> {\n try {\n const ok = await runPublishTrain(input, realTrainDeps);\n return ok;\n } catch (error) {\n if (error instanceof PublishTrainError) return error.toResult();\n throw error;\n }\n}\n\nconst defaultBuildTrain = {\n buildTargets: (input: BuildTargetsInput, deps?: BuildTargetsDeps) =>\n buildWorkspaceTargets(input, deps),\n};\n\nexport const realTrainDeps: TrainDeps = {\n buildTrain: defaultBuildTrain,\n storage: realStorageLegDeps,\n registry: { fetchConfig: fetchBosConfigFromFastKv, fetchHistory: fetchConfigHistory },\n signer: {\n submitRegistryWrite,\n submitRegistryWriteDelegated,\n submitRegistryWriteCustody,\n ensureDelegateKey,\n ensureCustodyBalance,\n submit: dispatchSubmit,\n },\n};\n\nexport type PublishToFastKvResult = PublishTrainOk | PublishTrainFailureResult;\n\n/**\n * The train as a Context.Service (ticket #422): `publish` fails with the\n * typed `PublishTrainError`; handlers yield the service and map failures\n * mechanically.\n */\nexport class DeployTrainService extends Context.Service<\n DeployTrainService,\n {\n publish: (input: DeployTrainInput) => Effect.Effect<PublishTrainOk, PublishTrainError>;\n }\n>()(\"everything-dev/deploy/train\") {\n static readonly Live = Layer.effect(\n this,\n Effect.gen(function* () {\n const storage = yield* BundleStorage;\n const registry = yield* RegistryStore;\n const signer = yield* SignerService;\n const buildTrainOption = yield* Effect.serviceOption(BuildTrainService);\n const renderOption = yield* Effect.serviceOption(DeployTrainRenderService);\n return DeployTrainService.of({\n publish: (input: DeployTrainInput) =>\n Effect.tryPromise({\n try: () =>\n runPublishTrain(input, {\n storage,\n registry,\n signer,\n buildTrain: Option.getOrUndefined(buildTrainOption) ?? defaultBuildTrain,\n render: Option.getOrUndefined(renderOption),\n }),\n catch: (error) =>\n error instanceof PublishTrainError\n ? error\n : new PublishTrainError({ kind: \"submit\", registryUrl: \"\", error: String(error) }),\n }),\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFA,eAAe,cAAc,KAA0C;CACrE,IAAI;EACF,MAAM,SAAS,MAAM,IAAI,OAAO,CAAC,aAAa,MAAM,GAAG;GAAE;GAAK,SAAS;EAAK,CAAC;EAC7E,MAAM,MAAM,QAAQ,OAAO,KAAK;EAChC,OAAO,UAAU,OAAO,aAAa,KAAK,MAAM,MAAM;CACxD,QAAQ;EACN;CACF;AACF;AAEA,eAAsB,yBAAyB,MAM1B;CACnB,MAAM,cAAc,KAAK,eAAe;CACxC,IAAI;EACF,MAAM,UAAU,MAAM,YACpB,SAAS,KAAK,QAAQ,GAAG,KAAK,WAC9B,KAAK,QACP;EACA,OAAO,KAAK,UAAU,OAAO,MAAM,KAAK,UAAU,KAAK,aAAa;CACtE,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;AAkEA,eAAsB,gBACpB,OACA,MACyB;CACzB,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