Show what changed for a reused step and let the user decide
Summary
A run of selected steps carries the outputs of its skipped steps from earlier runs (outputsFromRunId, outputsFromRuns, --outputs-from, --output-from). Nothing checked whether a carried step had changed since its run, and the web UI judged that alone, so a change of the base config, the runtime profile or a resolved parameter mixed old outputs into a new run without anyone seeing it. The server now finds every change, the step run dialog shows it before the click, and the user decides: reuse the outputs anyway or run the changed steps.
This replaces the earlier versions of this PR, which kept a parameter hash in the browser's cache and then refused changed steps outright.
Changes
- A carried step that changed since its run is refused unless the request consents to it. A carried step is one whose outputs a selected step reads: from
outputsFromRuns, or fromoutputsFromRunId. A changed step after the selection carries nothing and does not count.- before: the run starts and mixes the old outputs in
- after (HTTP 400):
step build cannot be reused from run R: the step and the parameters changed since that run
- The reason names each change: the step, a step it depends on, the parameters (with the names of those whose values changed, such as
the parameters (DATE)), the runtime profile, the base config, the top-level settings, a carried change (that run itself took the step from a changed one), orwhat that run ran cannot be compared. - The 400 has
details.refusedSteps, one item per refused step withstatus,changes,changedParams, and, for a run that cannot give the step,unavailable(gone,unfinished,noStep,failed). One refusal names every problem: first the runs that cannot give a step, then the changed steps. allowChangedSteps(API) and--allow-changed(CLI) reuse changed steps anyway. The run records what changed inreusedInputs[].changes, and the audit log keeps the consent. A later run that takes such a step from that run sees the change ascarried, andreuseFromreruns it.- CLI without the flag:
...; pass --allow-changed to reuse the changed steps anyway - CLI with the flag:
reusing step produce from run R although the step changed since that runon stderr
- CLI without the flag:
POST /dags/{fileName}/start-previewandPOST /dag-runs/previewplan a run of selected steps as the start would and return each carried step withunchanged,changedorunavailable, the steps nothing gives, and the runtime profile the run would use.- Step run dialog: each previous step names what changed since its run (
changed since run R: the step), a change of the whole run gets one line, and a note says that Step only reuses the changed steps as they are. Step only sends the consent for exactly the changes it showed. Each changed step has a "rerun" box, so Changed steps (then "Selected steps") runs the checked ones and reuses the unchecked ones with consent. A cached step that changed can now be reused too.- The choices work on the browser's view at once and switch to the server's verdict when it arrives ("Checking with the server").
- The dialog names the runtime profile the run uses; a profile manager can pick another one or take the source run's profile in one click.
- If something changes after the check, the dialog opens again with the refusal, in the user's language, instead of an error. The cache is never wiped; a cache entry whose run is gone has a Forget action.
- An older remote node without the previews gets a quiet note and the browser's view, not an error.
- The INPUT column of the step view shows the server's verdict once the dialog asked for it (kept for the page for a minute), and says that its marks are unchecked until then. It never asks the server itself, since the server evaluates the parameters to check.
POST /dag-runstakesdraftOf: a run from the editor without a profile takes the default profile of its file, so a draft runs as the saved file would. The server resolves it because a browser may not read the workspace default.- What counts as the definition other than the steps, on server and browser alike:
handler_on.initcounts, since it runs before the steps; the other handlers do not. The local sub-DAGs of the file count.paramscount once, as resolved. Keys that only describe, schedule, notify, retain, or limit runs (description,labels,schedule,hist_retention_days,max_active_runs, and the like; spec 013 lists them) do not count. The base config counts by its values, the same way, so comments, layout and SMTP do not count either.
Core change
PlanSelectedSteps plans the run as SelectedStepNodes seeds it, then compares each step carried from a run with the definition that run ran, part by part. Refusal refuses the unavailable steps and the changed steps without consent. Start (API and CLI) and the previews call the same plan, so they cannot disagree.
// internal/intake/carried.go:124
func (p *SelectedStepsPlan) Refusal() *RefusedStepsError {
var unavailable, changed []CarriedStep
for _, step := range p.Carried {
switch {
case step.Unavailable != "":
unavailable = append(unavailable, step)
case step.Changed() && !p.Allowed(step.Step):
changed = append(changed, step)
}
}
...
}
// internal/intake/reuse.go:217
func (f *fingerprint) changes(earlier *fingerprint, name string) []ir.StepChange {
now := f.steps[name]
then, existed := earlier.steps[name]
if !existed || now.own != then.own { changes = append(changes, ir.StepChangeStep) }
if existed && now.deps != then.deps { changes = append(changes, ir.StepChangeDependency) }
if f.params != earlier.params { changes = append(changes, ir.StepChangeParams) }
... // profile, baseConfig, settings
}
// internal/service/frontend/api/v1/start_steps.go:162
planned, err := a.planSelectedSteps(ctx, dag, req)
...
if refused := planned.plan.Refusal(); refused != nil {
return nil, refusedStepsError(refused) // 400 with details.refusedSteps
}
Testing
TestPlanSelectedStepsBaseConfig(intake): the run's copy comes fromspec.PrepareDAGSnapshot. Comments, a mappingenv:, SMTP and handlers other than init do not count; a value does. It failed before the base config fix: every run of a base config with a mappingenv:and SMTP was refused.- intake:
TestPlanSelectedStepsChanges(each kind, handler init vs success, local sub-DAG, parameter default),ChecksTheSource,IgnoresTheStepsAfter,CollectsUnavailable,UnknownDefinition,RecordsConsent,CarriedChange,TestStepsToRun(handlers, local sub-DAG, consented step). - API:
TestStartStepsRejectsAChangedStep(source and per-step, details),TestPreviewSelectedSteps,TestSelectedStepsAudit,TestStartStepsDispatchesSeed(consent recorded), authorization of both previews,TestRuntimeProfilesAPI_DraftUsesTheDefaultProfileOfItsFile. - CLI:
TestCmdStart_Only/ChangedStep,TestRemoteStartRefusedChangedStep(hint, and the retry with consent). - Conformance:
TestChangedCarriedStep,TestPreviewCarriedSteps,TestStartOnlyChangedStep,TestDraftTakesTheDefaultProfileOfItsFile. - UI:
useReuseCheck.test.tsx(shared answer, passive reader,since, failure, older node),composeCarriers, dialog tests inuseStepRunActions.test.tsx(rows, run line, consent, rerun boxes, changed parameters, profile, take the source profile, Forget, non-blocking check, older node, check failed, reopen on refusal),UpstreamDataPanel(unchecked note, mark against a cached step's run),StepRunConfirmDialog(the focus moves to Step only once it stops waiting for a run; it failed before the fix, and the E2E testRun step runs the steps that the step reads from with Runhit it),runRequests,useEditorRunActions,inputProvenance,runSpecDiff(metadata keys, init). - Go:
TestPlanSelectedStepsNamesChangedParams, metadata cases inTestPlanSelectedStepsChangesandTestPlanSelectedStepsBaseConfig.
I ran only the Go tests above locally (go test -run), plus gofmt and Prettier. CI runs the UI tests, conformance and E2E.
Performance
- The previews run only when the step run dialog opens, when the user picks another source or profile in it, and once after a refused start: at most two POSTs per evaluation, never polled. The answer is kept for the page for 60 seconds (at most 32 answers), so reopening the dialog asks nothing, and the INPUT column only reads it. They scale with clicks on Run step, not with tabs or subscribers.
- Server cost per preview: one DAG load with parameter evaluation (for a draft, a temporary file), then for each distinct run named:
FindAttempt, a status read and adag.jsonread. Hashing is O(steps). It does not grow with total DAGs or stored runs, only with how old the named runs are, as for the start. - Start: one more
dag.jsonread whenoutputsFromRunIdis set. - Stored: about 20–60 bytes per consented changed step in the run status. No ticker, SSE change, index or migration.
Compatibility
- API and CLI: a start that carries a changed step from
outputsFromRunIdor--outputs-fromnow gets HTTP 400 (the CLI exits with the error) unless it consents. Before, it started. The same holds foroutputsFromRunsand--output-from, which this PR refused already. - The 400 of both start endpoints may carry
details.refusedSteps; other errors keep their shape. reuseFrom: a handler edit other than init no longer reruns every step; an edit of a local sub-DAG, or ofhandler_on.init, now does. A step that a run reused with consent is run again.ReusedInput.changesis new and omitted when empty, so an older binary reads the status and a downgrade is safe.POST /dag-runswithdraftOf: a draft from the editor now takes its file's default profile. WithoutdraftOf, nothing changes.- An older remote node lacks the previews: the dialog notes that the node does not check and keeps the browser's view, and that node ignores
allowChangedSteps. Coordinator and workers are unaffected. - The browser's step hashes leave out the metadata keys now, so cache entries captured before see a one-time mismatch in the browser's own view. The server's verdict, which the dialog shows, is not affected.
Review guide
- Generated:
api/v1/api.gen.go,ui/src/api/v1/schema.ts,llms.txt. About 3,900 lines are hand-written. - Decisions that need judgment:
- In the dialog, which run gives a step: an unchanged step of the source run, then an unchanged cache entry, then the changed source step, then the changed cache entry (
composeCarriers). unknownis consentable, so whole-run reuse of an old run withoutdag.jsonkeeps working.draftOfrequires DAG write on the file's workspace: the caller could save the spec there and start it anyway.carriedtaints a step whose dependency took changed outputs in that run, not only the step itself.
- In the dialog, which run gives a step: an unchanged step of the source run, then an unchanged cache entry, then the changed source step, then the changed cache entry (
flowchart LR
D[Step run dialog] -->|on open| P["Preview endpoints (new)"]
P --> L["planSelectedSteps (new)"]
S[Start API / CLI] --> L
L --> I["intake.PlanSelectedSteps (new)"]
I --> R{"Refusal (new)"}
R -->|unchanged or consented| X["Launch, reusedInputs.changes (new)"]
R -->|changed, no consent| E["400 details.refusedSteps (new)"]
E -->|onRefused| D
Security
- The previews need the permission of the matching start (run on the DAG's workspace; write and run for a spec), and remote nodes authorize them the same way. They evaluate parameters as the start does, command substitution included.
draftOfneeds DAG write on the workspace of the named file. A protected default profile needs no administrator, as for a start of that file.- Refusal details carry step names, run IDs and change kinds, never output values. The audit log records each consent.
Out of scope
- The INPUT column of the step view keeps its browser-side hints. A server check on every keystroke would evaluate parameter commands on every edit.
draftOfonPOST /dag-runs/enqueue: the editor does not enqueue drafts.- Previewing
outputsorreuseFrom. - A step's own
descriptionstill counts as a change of the step. Leaving it out is small in code, but the E2E test of the draft flow creates its change by editing a description, and needs another edit first.