Skip to content

feat(task): task run --wait -o json emits the CompletionRecord (spawn#386) - #412

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/386-taskrun-wait-json
Jul 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/386-taskrun-wait-json

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Small enabling change for the workflow-adapter migration (spawn#386). Makes spawn task run --wait -o json emit the CompletionRecord so an adapter can launch-and-collect in one call.

Before: runTaskReal encoded the LaunchResult (instance id) and returned before the --wait poll block — so task run --wait -o json never emitted the terminal record. The CompletionRecord was only reachable via a separate spawn task status <id> -o json.

After:

  • --wait + -o json → poll, then encode the CompletionRecord (exit code, state, timings, logs), exit with the task's exit code.
  • --wait + human → unchanged (printCompletion).
  • no --wait + -o json → LaunchResult (unchanged).

So an adapter does: build TaskSpec → spawn task run --spec f --wait -o json → parse the record. This is the one-shot the cwl-spawn port (and the other three adapters) will use — landing it first de-risks all of them.

Testing

  • Behavior-only control-flow change over already-tested pieces: the CompletionRecord JSON contract is covered by pkg/taskproto/completion_test.go (round-trip + wrapper-shape); the poll path is AWS-bound and validated by the gated real-AWS smoke tests already run for task run.
  • go build ./..., go vet, gofmt clean; TestFlagConventions/TestTier0 pass; no docs-gen drift (no flag/command change); Semgrep clean. Only the pre-existing TestCatalogValid fails in cmd (unrelated, fails on main too).

Refs #386

…#386)

Previously runTaskReal encoded the LaunchResult and returned before the --wait
poll block, so 'task run --wait -o json' never emitted the terminal
CompletionRecord — adapters had to launch, then separately poll
'task status <id> -o json'. Restructure so --wait + json polls and encodes the
CompletionRecord (exit code, state, timings, logs) and exits with the task's
exit code; without --wait, json still emits the LaunchResult; human output
unchanged in both modes.

This gives workflow adapters (cwl-spawn et al.) a one-shot: build a TaskSpec,
'spawn task run --spec f --wait -o json', parse the record. De-risks the
adapter-migration work (spawn#386).

Refs #386
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/task.go 0.00% 26 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6e273fb into main Jul 20, 2026
7 checks passed
scttfrdmn added a commit that referenced this pull request Jul 20, 2026
MINOR: spawn#386 workflow-adapter contract — task run --wait -o json emits the
CompletionRecord (#412) + TaskSpec resources.s3_read_write & placement block
(#414). Unblocks the snakemake + nf-spawn adapter migrations.
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