Skip to content

checks and cli: finish #14802's follow-ups, never lose a check's final state, discover filter flags in the command's session - #15037

Merged
sipsma merged 20 commits into
mainfrom
sipsma/checks-and-cli
Nov 2, 2026
Merged

sipsma merged 20 commits into
mainfrom
sipsma/checks-and-cli

Conversation

@sipsma

@sipsma sipsma commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This collects three changes to checks and the CLI, plus the changelog entries for #15035. Each kept its own commits. They touch some of the same files, so they're reviewed and merged together.

1. Follow-ups to #14802 (artifact filters on collection views)

Fixes found while reviewing #14802 after it merged:

  • A scale-out check whose remote request fails now shows as failed. Before, the check reported its span only from the remote engine, so a request that never reached it left no failed check in the report.
  • A never-cached check runs once per check object. Reading pass and then error on such a check ran it twice, and the two reads could disagree. Each request still gets a fresh check, as before. Artifacts.asChecks is no longer cached, so each selection gets its own checks.
  • A cached failing check replays its saved output. A fresh run rolls its exec output into the check. A cached failure has no exec spans in the trace, so it showed only the error.
  • Checks with no final state show as "not reported", never "OK". When a run ends, the frontend marks spans still running as canceled. The CHECKS and GENERATORS sections counted those as passed. They're now listed and counted apart. A span whose final state arrives after that replaces the assumed cancellation.
  • Less repeated work on large selections:
    • CLI job preparation no longer copies the job list three times per artifact, which was quadratic.
    • Legacy batch keys deduplicate through a map instead of a list search.
    • Filtered runs scope only the arguments the dynamic input hook set or replaced, instead of loading every object argument twice. The scoped arguments are recorded before the hook runs, because it can replace them in place.
  • Tests:
    • legacy generator batching through asGenerators;
    • checks that take their enclosing collection, under an installed module name, as dagger/dagger installs dagger/go as golang.
  • Go runner pin. dagger.toml pinned go: run selected tests once per module go#84's branch head. Remove build dependency on cue cli #84 has merged, so the pin moves to its merge commit, 552271d5. CI's check discovery lists that runner's Go test check, as main's CI already does with the old pin, so CI runs the Go tests on the merged runner.

2. Never drop engine spans on the way to the frontend

dagger check could report failed checks as OK, a different set each run, while its error list and exit code were right. The engine ended every check span as failed, but some final states never reached the report.

The CLI passed every span the engine streams to it into the frontend through a queue of 2048 that silently drops spans when it's full. A big run streams tens of thousands of span snapshots, so a burst such as hundreds of checks ending at once overflowed it. A check whose final snapshot was dropped stayed "running", and the report showed it as OK.

The frontend now gets its own span processor, which waits for queue space instead of dropping, as the frontend's logs already do. The engine's spans wait in the engine until the CLI reads them. The Cloud and OTEL_* exporters stay best-effort.

Measured with a reproduction of 400 failing checks, 12 runs on each side, on one machine:

Runs that lost final states Checks left "running" (of 400) Time per run
main 11 of 12 45 to 355 9–10 s
with this change 0 of 12 0 9–10 s

TestEngineSpanBurstReachesFrontend forwards a burst of 32,769 finished spans the way the CLI does. Without the fix, only 2,560 reach the frontend.

One known limit: while the CLI's output isn't being read, Ctrl-C can't stop it, because the queue waits for space.

3. Discover filter flags in the command's own session

Filter flags such as --go come from the workspace's modules, so the CLI can't parse them until it has asked the engine which flags exist. dagger check, dagger generate and dagger list <type> did that in a separate session, closed it, and then opened a second session for the command. The second session loaded the workspace's modules again, because the engine identifies the host workspace per session.

Now, when one of these commands is about to run (not --help, not shell completion), the CLI first opens the command's own progress output, telemetry and session. It discovers the flags as that session's first request, then lets Cobra parse and run the command inside it. The command's engine call takes the open session, with the modules already loaded.

  • Measured: listing all of dagger/dagger's Go tests with dagger check --go --check test -l --all got 0.18–0.19 s faster on a warm engine and 0.38 s faster on a fresh one.
    • 5 interleaved runs per side on one 16-CPU arm64 machine. The 95% bootstrap intervals were [−0.20, −0.16] s unchanged, [−0.23, −0.16] s after an edit and [−0.59, −0.21] s fresh.
    • The base was a development branch of main carrying other pending performance work. The saving on main itself wasn't measured.
    • Stdout was byte-identical in all runs. No change in engine CPU was distinguishable from noise.
  • Same output:
    • Cobra's own output (usage, deprecation and update notices) is buffered and printed after the progress output ends, as before.
    • The Cloud token check, which may sign in again and wait for the user, runs before the progress output starts.
    • A command line that still doesn't parse after discovery is reported by Cobra after the progress output, as before.
  • Same params, or a new session. A command that connects with different client params from the ones the session opened with, such as check --scale-out, gets a new session under the same progress output.
  • What keeps two sessions:
    • start, shell and agent, which set the progress output's root filter, read piped stdin, or prompt before connecting;
    • runs with --no-exit.

Changelog for #15035

#15035 (faster module evaluation and collection listings) merged without its changelog entries. They're here as one commit, written for #15035's changes:

  • Fixed: restarting an engine no longer throws away its local cache when it holds a module object with another module object in a field.
  • Fixed: listing a collection's items under a +cache="never" ancestor no longer fails when the ancestor returns different keys on another run.
  • Changed: a Dang function rebuilds each distinct object it receives once per call. Equal received copies now compare equal.

Lint

Two functions grew past golangci-lint's complexity limit, preselect in dagql and prepareArtifactCommands in the CLI. Each now has one step extracted into its own function, unchanged.

Validation

On this branch, with the dev engine:

dagger check golangci-lint/lint-all
dagger api call engine-dev test --race --pkg ./internal/cmd/dagger
dagger api call engine-dev test --race --pkg ./core
dagger api call engine-dev test --race --pkg ./core/schema
dagger api call engine-dev test --race --pkg ./dagql
dagger api call engine-dev test --race --pkg ./dagql/dagui
dagger api call engine-dev test --race --pkg ./dagql/idtui
dagger api call engine-dev test --pkg ./core/integration --run='^TestArtifacts$'
dagger api call engine-dev test --pkg ./core/integration --run='^TestCollections$'
dagger api call engine-dev test --pkg ./core/integration --run='^TestChecks$'
dagger api call engine-dev test --pkg ./core/integration --run='^TestGenerators$'

All pass. Counts are from each run's live summary:

Run Result
golangci-lint passed
./internal/cmd/dagger with -race 1128 passed
./core with -race 2595 passed
./core/schema with -race 802 passed
./dagql with -race 1239 passed
./dagql/dagui with -race 267 passed
./dagql/idtui with -race passed (693 tests; the summary's 4 failed and 8 of its skips are the golden tests' own fixture cases)
TestArtifacts 173 passed
TestCollections 49 passed
TestChecks 79 passed
TestGenerators 147 passed

Before the rebase, with the dev CLI and engine, dagger check -l "golang/**" lists the Go test check on the new pin. dagger check "golang/**/test" --golang-module=hack/sdl-diff --golang-package=hack/sdl-diff passes its 17 checks.

sipsma added 20 commits November 2, 2026 20:03
A scale-out check reports its span from the remote engine. When the
request to that engine fails, the check never runs there, and no failed
check appeared in the report. Report it locally in that case.

Signed-off-by: Erik Sipsma <[email protected]>
Each parallel.Jobs builder method copies the whole job list, and the
loop called three of them per artifact, so preparing a large selection
copied quadratically. Configure each job from empty defaults and append
it once to a preallocated list.

Signed-off-by: Erik Sipsma <[email protected]>
Under a result scope, preselect scoped the selector's inputs and then
scoped every argument again after the dynamic input hook, loading each
object argument twice. Skip arguments the hook left as scoped.

Signed-off-by: Erik Sipsma <[email protected]>
Grouping searched the batch's key list for every selected item, which is
quadratic for large collections of older modules.

Signed-off-by: Erik Sipsma <[email protected]>
A fresh check run rolls its exec output up into the check. A cached
failure has no exec spans in this trace, so the check showed only the
error. Replay the output its error retained.

Signed-off-by: Erik Sipsma <[email protected]>
The dynamic input hook can replace an argument in place in the shared
argument list. Recording the scoped arguments after it ran treated a
replacement as already scoped. Record them before the hook.

Signed-off-by: Erik Sipsma <[email protected]>
Reading pass and then error on a never-cached check ran it twice, and
the two reads could disagree. Keep the function's cache inputs on the
check projection, as before, so each request still gets a fresh check,
and let every read of one check share its run. Artifacts.asChecks is no
longer cached, so each selection gets its own checks.

Signed-off-by: Erik Sipsma <[email protected]>
A workspace can install a module under another name, as dagger/dagger
installs dagger/go as golang. Check that an item check taking its
enclosing collection is still listed and runs.

Signed-off-by: Erik Sipsma <[email protected]>
dagger/go#84 has merged. Pin its merge commit instead of the PR's head,
so CI's Go checks run the runner as released on dagger/go main. CI's
check discovery now lists the runner's Go test check, which takes the
selected collection, so the tests run again.

Signed-off-by: Erik Sipsma <[email protected]>
When a run ends, the frontend marks spans still running as canceled.
The CHECKS and GENERATORS sections showed such a span as passed, so a
failed check whose final state had not reached the CLI read as OK and
counted as passed. Show it as not reported, counted apart.

Signed-off-by: Erik Sipsma <[email protected]>
When the trace ends, the frontend marks spans still running as
canceled. A span whose final export arrived after that kept the flags,
so a check that passed late showed as not reported. Clear them when the
final export arrives; its attributes restore an explicit cancellation.

Signed-off-by: Erik Sipsma <[email protected]>
`dagger check` could report failed checks as OK, a different set each
run, while its error list and exit code were right. The engine ended
every check span as failed, but some final states never reached the
report.

The CLI forwards every span the engine streams to it into the frontend
through telemetry.Init's LiveTraceExporters, which wraps the frontend
in an OTel batch span processor with the default 2048-slot queue. That
queue drops spans when it is full. A big run streams tens of thousands
of span snapshots, so a burst, such as hundreds of checks ending at
once, could overflow it. A check whose final snapshot was dropped
stayed running in the frontend, and the report showed it as OK.

Give the frontend its own large-queue live span processor that waits
for queue space instead of dropping, as the frontend's logs already do.
Forwarded engine spans then wait in the engine's store until the CLI
reads them. The Cloud and OTEL_* hops stay best-effort.

Signed-off-by: Erik Sipsma <[email protected]>
dagger check, generate and list opened one session to discover the
workspace's filter flags, closed it, then opened a second for the command,
which loaded the workspace's modules again.

When such a command will run, open its frontend, telemetry and session
before Cobra parses the command line, discover the flags as the session's
first request, then run Cobra in that session. The command's engine call
takes the open session, or connects a new one under the same frontend when
it asks for different params.

start, shell and agent keep two sessions: they change the frontend's
options or read stdin before connecting.

Signed-off-by: Erik Sipsma <[email protected]>
Since filter discovery opens the command's frontend before Cobra runs,
what Cobra writes outside the command's engine call went into that
frontend's span logs: an available-update notice was lost once the
command set another primary span, and signing in again after a malformed
credentials file hid its instructions.

Check the Cloud token before the frontend starts, buffer Cobra's writes
outside the engine call and print them once the frontend is done, and
let a command line that still doesn't parse after discovery fail in
Cobra after the frontend, as before.

Test that a filtered check and a typed listing each connect once.

Signed-off-by: Erik Sipsma <[email protected]>
A command line Cobra rejects after discovery is reported once the
discovery's frontend ends, which --no-exit holds open until the user
quits. Keep --no-exit on its own discovery session, as before.

Signed-off-by: Erik Sipsma <[email protected]>
The report progress colors its marks, and a separate discovery session
shows one connect too, inside its own step. Strip the colors and check
the one connect comes before discovery.

Signed-off-by: Erik Sipsma <[email protected]>
preselect grew past golangci-lint's complexity limit when it learned to
skip selector inputs the dynamic input hook left scoped. Move that loop
into scopeDynamicInputs, unchanged.

Signed-off-by: Erik Sipsma <[email protected]>
prepareArtifactCommands grew past golangci-lint's complexity limit when
it learned to run discovery in the command's own session. Move the
choice and the command's params into sessionDiscovery, unchanged.

Signed-off-by: Erik Sipsma <[email protected]>
@grouville
grouville self-requested a review November 2, 2026 21:43
@sipsma
sipsma merged commit 8676d4a into main Nov 2, 2026
93 checks passed
@sipsma
sipsma deleted the sipsma/checks-and-cli branch November 2, 2026 21:50
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.

2 participants