Refactor/extra engine types - #40
Merged
SokratisVidros merged 12 commits intoJun 16, 2026
Merged
Conversation
SokratisVidros
approved these changes
Jun 16, 2026
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.
Parser detection driven by the type (
types.ts+ast-parser.ts)The AST parser's list of recognized
step.*methods was maintained by hand,disconnected from the actual step API (
StepBaseContext). That let the two drift,and the name→
StepTypemapping relied on an uncheckedas StepTypecast plus aspecial-case
sleepbranch.STEP_BASE_METHOD_TYPES, derived from_STEP_BASE_METHOD_TO_TYPE: Record<keyof StepBaseContext, StepType>. TheRecord<keyof StepBaseContext, …>annotation makes the compiler enforce twothings: every step method is mapped (add a method to
StepBaseContext→compile error until it's in the map), and every value is a real
StepType.||chain of method-name comparisons +as StepTypecast +sleep-alias ternary collapse into a singleSTEP_BASE_METHOD_TYPES.get(methodName)lookup.
undefineddoubles as the "not a step method" check, and thesleep → DELAYalias is now data in the map rather than a branch in the parser.Engine type-safety & structure (
engine.ts)StepTypeToIconasRecord<StepType, string>so a newStepTypeforcesa matching icon entry.
as WorkflowInternalDefinitioncast on theworkflows.set(...)literal. The spread already produces the correct type, andthe cast was suppressing excess-property checking (stray keys are now caught).
baseStepobject literal out ofhandleWorkflowRuninto a private
createBaseStep(run, workflowId, runId)method.createChildWorkflowRun(...)that wrapscreateWorkflowRunwith
parentRunId/parentStepIdrequired at the type level, so thechild-invocation path can't be wired up without parent linkage.
Fail loudly on a foreign
workflow_runstable (migration.ts)Previously, if a consumer already had a
workflow_runstable in the targetschema, migrations could
ALTER/index a table pg-workflows didn't create. Themigration now checks (only on a fresh install, i.e. no
workflow_schema_version)whether a
workflow_runstable already exists and throws a clear errorpointing the user at a dedicated schema/rename — before any DDL runs.
This is the one behavioral change in the PR; it only fires for genuine collisions
and is otherwise inert (healthy installs are already past version 0).
Test coverage
ast-parser.test.ts): added realexpect(...).toEqual(...)assertions to the previously no-assert
switch, nested conditional/loop, andmixed-step tests; added a test documenting the known limitation that
externally-defined handlers aren't parsed (yields
[]steps).migration.test.ts, new): fresh DB migrates to the currentversion; migrations are idempotent across repeated runs; a foreign
workflow_runstable makesrunMigrationsthrow without touching it.engine.test.ts): reusing anidempotencyKeyenqueues nosecond job and leaves the first run untouched (completed case); and the same
holds while the first run is still mid-execution (paused) — the duplicate is a
no-op and the in-flight run is undisturbed.
Testing
tsc --noEmitclean