Durable workflow deploy source for every placement (CL-6581 phase 1) - #289
Merged
Conversation
Shared-placement native workflow deploys have no durable hub-side record of their WorkflowDefinitionSource today -- only the sidecar's local deployment.json carries it. These tests define the contract for a new @corbits/workflow-deploy-source package: recording and reading back a deploy source, surviving a fresh Postgres connection with no sidecar input (the CL-6581 phase 1 acceptance check), and wrapping a SessionService so every shared deploy records its source without touching vendored session-service.ts.
…ment A native workflow's deploy source (an npm name@range pin or a hub-asset commit) is a real external pin that cannot be regenerated -- only remembered. Exclusive placement already remembers it in workflow_run_launch_spec; shared placement, the dev default, remembered it nowhere in Postgres, only in the sidecar's local deployment.json, which is why boot replays every record the sidecar happens to have on disk. Add @corbits/workflow-deploy-source: a package-owned workflow_deploy_source table storing the deploy call's WorkflowDefinitionSource verbatim (the same discriminated union POST /workflows/deployments already accepts -- an asset commit today, a registry name@range or any future source arm with no schema change), plus entry/pin/definitionAssetId/deploymentDomain/sourceRef, keyed on anchor run id. withDeploySourceRecording wraps the session service's deployWorkflowFromSource and deployAdoptedWorkflowFromSource -- the shared-capacity deploy entry points POST /workflows/deployments and the routine launcher's adopted-anchor deploy both drive -- so every shared deploy records its source after the deploy succeeds, without editing vendored session-service.ts. Wired at the composition root in apps/hub/src/index.ts, the only place createSessionService is instantiated, so no caller can bypass it. Migrations wired into scripts/db-setup.ts alongside every other installed package.
RepoStore holds the source bytes; workflow_definition_version holds the body projection (wireProjection, grantSnapshot, approvedWireHash). Neither stores the deploy PARAMETERS -- entry, pin, sourceRef, deploymentDomain, and the WorkflowDefinitionSource union itself -- that select and apply those bytes. workflow_deploy_source is that missing record, not a duplicate of either.
TheGreatAxios
force-pushed
the
cl-6581-durable-source
branch
from
August 22, 2026 02:31
235e80f to
b04373d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 of CL-6581 (sub-issue: CL-6583). A native workflow's deploy source (an npm
name@rangepin or a hub-asset commit) is a real external pin that cannot be regenerated, only remembered. Exclusive placement already remembers it inworkflow_run_launch_spec(written by vendoredworkflow-allocation-service.ts, untouched here). Shared placement — the dev default, whatworkbench seedcreates — remembered it nowhere in Postgres, only in the sidecar's localdeployment.json. That file being the sole record is why boot replays every record the sidecar happens to have on disk.This adds
@corbits/workflow-deploy-source: a package-ownedworkflow_deploy_sourcetable that stores the deploy call'sWorkflowDefinitionSourceverbatim — the same discriminated unionPOST /workflows/deploymentsalready accepts (kind: "asset"today;kind: "registry"is defined by the union but the route currently 400s it as unsupported) — plusentry/pin/definitionAssetId/deploymentDomain/sourceRef, keyed on anchor run id. Nothing about the record is hub-git-specific: it is{source, entry, pin?}wheresourcenames its own origin, so a future source arm needs no schema change, just a new case inside the same jsonb value.withDeploySourceRecordingwraps the session service'sdeployWorkflowFromSourceanddeployAdoptedWorkflowFromSource— the shared-capacity deploy entry pointsPOST /workflows/deploymentsand the routine launcher's adopted-anchor deploy both drive — so every shared deploy records its source after the deploy succeeds, without editing vendoredsession-service.ts. It's wired at the composition root inapps/hub/src/index.ts, the only placecreateSessionServiceis instantiated in the app, so no caller can bypass it.This is not rebuilding what
RepoStore+populateAssetalready doRaised in review and worth stating precisely, since the instinct is understandable: two other places already hold related data, and neither holds what this table holds.
RepoStoreholds the definition's bytes — the git tree at a commit. It answers "what does the source code look like."workflow_definition_versionholds the body projection —wireProjection,grantSnapshot,approvedWireHash— the result of evaluating those bytes. It answers "what did the frozen definition resolve to."entry(which module the sidecar evaluates),pin(thename@rangeselecting a package member),sourceRef(which ref inside the asset carries the pinned commit),deploymentDomain, and theWorkflowDefinitionSourceunion itself (which arm — asset vs. registry — and itsassetId/format). These are the inputs that select and apply the bytes and body above; they exist today only as the in-memory arguments of one HTTP request, gone the moment that request completes for shared placement.workflow_deploy_sourceis that missing record — a third, disjoint concern from bytes and body, not a duplicate of either.scripts/checks/no-product-tenancy.ts's new allowlist entry states this same distinction inline, so the next reader hits it at the point of the violation, not just in this PR description.Why this shape, not a bigger one
vendor/intx/is never touched. The natural capture point (workflows.ts's route handler) is vendored, so the seam is a decorator around the already-workbench-composedsessionService, mirroring howcreateLaunchCachesalready wrapsrepoStore/assetServiceat the same composition root.source.kind === "registry"today (unsupported_source, 400) — there is currently nothing to durably record for that arm. The schema already accommodates it losslessly (the whole union is stored, not just the asset arm), so no follow-up migration is needed when the route grows registry support.createSessionService(...)call site, and it's the wrapped one — every shared-placement deploy (route, routine launcher,workbench seed, agent-authoreddeploy_workflow) funnels through it. Exclusive placement's existing durability is untouched, not duplicated.deployment.jsonand the boot-restore scan are deliberately untouched — deleting them is phases 3/4 of CL-6581 and depends on this landing first.What this proves
test/store.test.ts's"a redeploy's full source-call intent survives a fresh connection, with no sidecar record involved"writes a deploy-source record on one Postgres connection, opens an entirely fresh connection and store instance (standing in for a hub restart), and reconstructs the exactDeployWorkflowFromSourceParamsshape a redeploy needs from the row alone — proving the record, not any sidecar file, is sufficient to redrive the deploy call. This is the deliberate, non-package-test check the task asked for, scoped to the layer this PR owns (hub-side durability); it does not exercise a live sidecar process, since the dev stack on :3000 was off-limits to restart for this lane.Test plan
bun testinpackages/workflow-deploy-source(10 tests, DB-gated tests run against a scratch database derived from local Postgres)bun run typecheckinpackages/workflow-deploy-sourceandapps/hubcheck:no-product-tenancy,check:licensespassbunx eslintclean on all changed filesbunx prettier --checkclean on all changed files