Skip to content

Add Override, to replace the task which provides a key - #6

Merged
sengjea merged 4 commits into
masterfrom
override-bindings
Nov 25, 2026
Merged

sengjea merged 4 commits into
masterfrom
override-bindings

Conversation

@sengjea

@sengjea sengjea commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Tasks often create things for themselves, such as clients of other services, so a graph can't be given
fakes in a test. RunWithOverrides(ctx, graph, inputs, overrides) runs a graph with the tasks which
provide the keys of the overrides replaced by them; the replaced tasks do not run.

It makes a graph like the original with each replaced task swapped for one with no dependencies which
provides the overrides, and runs that. The engine is unchanged.

  • A key can only be replaced on purpose: an input for a key which a task provides is still a duplicate.
    Overriding an unknown key, only some of a task's keys, a key twice, or a key which is also an input is
    an error.
  • key.BindError(err) replaces the task with a failure. Overrides are in the returned Binder, and
    inputs only a replaced task needed are no longer required.
  • CheckWithOverrides validates without running. Overrider holds one set of overrides for code which
    runs several graphs (such as create and delete), running each with those it provides.
  • taskgraphtest.Test and Suite take Overrides.

Note: go test -race fails taskgraphtest.TestOverrides, from the engine's existing close-versus-send
race on signal channels (TestGraph already fails the same way on master). CI runs without -race.

@sengjea
sengjea force-pushed the override-bindings branch 4 times, most recently from 55a4614 to 0fb03f6 Compare November 3, 2026 17:05
@sengjea
sengjea force-pushed the override-bindings branch 2 times, most recently from 90401f2 to 7cea013 Compare November 17, 2026 11:01
Tasks often create things for themselves, such as clients of other
services, which leaves a graph with no way to give it fakes in a test.
RunWithOverrides runs a graph with the tasks providing the keys of some
bindings replaced by them. The replaced tasks do not run.

It does this by making a graph like the original, in which each task
that is replaced is a task with no dependencies which provides the
overrides, and running that. The engine is not changed, nor are
Graph.Run and Graph.Check. An input for a key which a task provides is
still a duplicate binding, so a key is only ever replaced on purpose.

Overriding a key no task provides, or only some of the keys a task
provides, is an error, as is overriding a key twice or a key which is
also an input. An absent override replaces the task with a failure.
Overrides are part of the Binder returned, and inputs only a replaced
task needed are no longer required. CheckWithOverrides validates them
without running the graph.

A replacing task has no dependencies, so the tasks which fed the task it
replaces have nothing to signal, and inputs which only a replaced task
needed are not required. Those tasks still run.

Overrider holds one set of overrides for code which runs several graphs,
such as an operator with a graph to create and one to delete: each graph
takes the overrides for the keys it provides, and Check finds any which
are for none of them. taskgraphtest's Test and Suite take Overrides,
those of a Test replacing those of its Suite for the same key.
Comment thread README.md Resolved

@OrestisIon OrestisIon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sengjea
sengjea requested a review from OrestisIon November 20, 2026 09:36
Comment thread taskgraphtest/taskgraphtest_test.go Resolved
Comment thread taskgraphtest/taskgraphtest_test.go Resolved
Comment thread taskgraphtest/taskgraphtest_test.go Resolved
Comment thread taskgraphtest/taskgraphtest_test.go Resolved
Comment thread taskgraphtest/taskgraphtest_test.go Resolved
Comment thread override_plan.go Resolved
Comment thread taskgraphtest/taskgraphtest_test.go Resolved
@sengjea
sengjea removed the request for review from OrestisIon November 20, 2026 11:40
@sengjea
sengjea merged commit ce1dd12 into master Nov 25, 2026
1 check passed
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.

3 participants