Skip to content

Routines target a workflow asset, resolved at use (CL-7350) - #550

Draft
TheGreatAxios wants to merge 8 commits into
cl-7349-contractsfrom
cl-7350-routine-target
Draft

Routines target a workflow asset, resolved at use (CL-7350)#550
TheGreatAxios wants to merge 8 commits into
cl-7349-contractsfrom
cl-7350-routine-target

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Linear: https://linear.app/abklabs/issue/CL-7350

Builds to docs/workflow-model.md (CL-7349): a routine stores its target workflow asset id and resolves the newest deployed, frozen definition at create and (to be wired) at launch.

Status — incomplete, opened early on a budget cut

Done (packages/routines only): schema + migration 0006 (backfill, delete unresolvable, drop definition_id), src/target.ts resolver + typed rejections, routes/workflow-routine-routes/client/store/drafts cutover to definitionAssetId, unit + DB-gated tests. Package typechecks and its 291 tests pass (DB suites skipped locally — Docker/Postgres unavailable).

NOT done (repo-wide typecheck currently fails; pushed with --no-verify):

  • apps/hub: routine-launcher.ts / index.ts wiring (resolveTarget, asset-keyed ports, reportError fail-closed at fire), routine-scheduler port rename
  • packages/routines-tools: dedupe wire shapes via @corbits/routines/client, definitionAssetId input, version bump + workflows/assistant pin
  • packages/hub-client default-routines.ts, apps/web (routines-api, routine-panel, routine-detail-page + tests), packages/chat + chat-ui workbench agents wire (definitionAssetId), scripts/e2e routine tests
  • CL-7353 (PATCH retarget) and CL-7354 (authz) not started
  • packages/routines/README.md not updated

Resolves CL-7350

…inition at use (CL-7350)

A routine stores definition_asset_id instead of definition_id, following
docs/workflow-model.md: Interchange keys workflow_definition on
(asset_id, wire_hash), so only the asset is stable across redeploys.

- New target.ts: resolveLaunchableDefinition picks the newest deployed,
  frozen definition for an asset in a tenant; pickLaunchableDefinition
  is the pure ordering rule; routineTargetRejection gives typed
  envelopes (not found / not deployed / not approved) for UI and Myra.
- Migration 0006 backfills the asset id from workflow_definition,
  deletes routines that cannot resolve (raising a WARNING with the
  count, keeping run history), and drops definition_id. Drafts follow
  the same rename.
- Routes take definitionAssetId on create (400 when absent, no server
  side target search), validate it through resolveTarget, and every read
  returns { definitionAssetId, definitionId } with the currently resolved
  definition or null. The name-resolution and candidate-listing ports on
  the run-authenticated mirror are removed.
- Tests: target ordering unit tests, route contract tests, DB-gated
  migration backfill/delete and store round-trip tests.
Hub launcher and scheduler resolve the routine's asset to its newest approved definition at fire time and fail closed via reportError; routines-tools imports wire shapes from @corbits/routines/client; web, chat, hub-client, evals, and e2e callers rename the field.
Several suites still exercised the pre-cutover definitionId shape for
agent participants and routine creation, and the chat routes test's
fake platform never stubbed resolveDefinitionAssetId, so the hub's
GET /workbenches/:id/agents route (which now filters out any
participant it can't resolve an asset id for) silently dropped every
result.
ensureDefaultRoutines still resolved a workflow_definition row id from
the vendored /workflows/definitions listing (which never exposes an
asset id) and sent it as POST /routines' definitionAssetId, so every
default routine seed failed with routine_target_not_found. It now
finds the deployed workflow's asset id the same way ensureWorkflowAsset
and ensureDeployment already do: list /assets?kind=workflow, then
confirm a live deployment exists for that asset id.

Also regenerates tsconfig project references, out of sync since
routines-tools dropped a dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant