Repository navigation
feat(taskproto)!: script generators take WrapperOptions and return an error (#764) - #765
Merged
Merged
Conversation
…n an error BREAKING for pkg/taskproto. #764, split from #679. GenerateWrapper, GeneratePooledJobScript and GenerateFlushScript shared four positional parameters, two of which were added in separate releases: v0.111.0 GenerateWrapper(spec, resultsBucket, region string) string v0.111.1 ... gpu bool) string <- PATCH. broke mcp v0.112.0 ... gpu bool, runID string) string <- MINOR, compliant Both additions are per-launch decisions with no safe default, so neither could be defaulted away. The problem is that both have a zero value that compiles and reads as deliberate. spore-host-mcp's own regression test records what actually happened: the quickest way to make the package build again was GenerateWrapper(spec, bucket, region, false, "") which compiles, passes every test, and emits an empty run_id while dropping --gpus all. That is #608 and #606 reintroduced by a padding edit, in the MCP path only, found days later. ## Why a struct alone is not the fix An options struct makes that failure MORE likely, not less. A new positional parameter at least forces a compile error at every call site, so somebody has to look; an omitted struct field is silence. So the struct ships with Validate, and the generators return ErrMissingRunID / ErrMissingResultsPrefix instead of a script. That trades a compile error for a loud runtime error at the point of misuse, rather than an unattributable S3 record discovered weeks later. The old doc comment already warned that "" emits an unattributable run_id — which is the evidence that documenting it was not enough. Region is deliberately NOT required. It is used only for the ECR login of a private-registry image, so a host-command task legitimately has none, and a check that fires on correct input is one people route around. RunID is NOT defaulted here either, though an empty value is always wrong. The caller needs the same id for the work it does around the launch — clearing the previous attempt's record, and verifying run_id when polling for completion (cmd/task.go uses it in five places). An id minted privately inside the library would be invisible to exactly the code that has to match it, defeating #608's verification rather than protecting it. GenerateFlushScript takes the same options so the three stay in step and the next per-launch input is non-breaking for all of them. It ignores GPU; it does not run the container. Asserted, not assumed. ## No positional shim Deliberate. A deprecated positional form would preserve the exact hazard being removed, and there is ONE external caller (spore-host-mcp/launch.go). Hard cutover, MINOR bump, coordinated mcp update. ## Verification - The #763 API gate reports all three signatures under "REMOVED or CHANGED", which is its first real use and the behaviour it exists for. Snapshot regenerated. - New tests cover what is new: all three generators reject an empty RunID and an empty ResultsPrefix, an empty Region is ACCEPTED (pinning the non-requirement), the options reach the emitted script, and the flush hook's output is byte-identical with GPU true vs false. - Both confirmed to fail on revert, with compiling edits: dropping the RunID check from Validate, and dropping the Validate call from GenerateWrapper alone — the partial regression a single shared check would otherwise hide. Not changed: pkg/taskpool and cmd/task.go mint their run ids exactly as before. cmd/task.go now builds ONE options value for both the wrapper and the flush hook, so they cannot disagree about the prefix or the run id.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
scttfrdmn
added a commit
that referenced
this pull request
Oct 8, 2026
Promotes [Unreleased] to [0.126.0] and adds the compare link. MINOR, not PATCH, because this release contains a breaking change to a package other repos compile against: pkg/taskproto's three script generators now take a WrapperOptions struct and return an error (#765/#764). Pre-1.0 the project's rule is that a breaking change bumps MINOR. Also in this release: the cross-repo API surface gate that will report the next such change before it ships (#763/#679), `spawn logs` (#761), the spored console log tail it reads (#759), the MPI peer-SSH readiness poll (#758), and the remaining sleep-audit fixes plus the creation-stamp/orphan reaper work (#752, #755, #756, #757, #762). Release guard passed: both binaries report 0.126.0 for tag v0.126.0.
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.
Closes #764.
The decision
Four options were on the table. This takes the third, and the reasoning for
rejecting the others is the useful part.
Rejected — leave it positional. The hazard is live, not theoretical. See
below.
Rejected — a struct, and nothing else. This is what #764 literally asked for,
and on its own it makes the failure more likely. A new positional parameter at
least forces a compile error at every call site, so somebody has to look. An
omitted struct field is silence.
Rejected — move GPU detection into
taskproto. Tempting, becausespore-host-mcphad to reimplement spawn's rule(
spec.Resources.GPUs > 0 || aws.DetectGPUInstance(sizedType)). ButDetectGPUInstancelives inpkg/aws, andpkg/taskprotocurrently has zerodependency on
pkg/awsor the AWS SDK — its only spawn-internal import ispkg/ecrref. That is a valuable property for the wire-contract package sixworkflow adapters use just to parse a
CompletionRecord, and not worth spendingto deduplicate one boolean.
Taken — a struct, plus validation that makes the dangerous zero value loud.
Why validation, not just a struct
spore-host-mcp's own regression test records what actually happened after thev0.111.1 signature change — the quickest way to make the package build again was:
That compiles, passes every test, and emits an empty
run_idwhile dropping--gpus all. It is #608 and #606 reintroduced by a padding edit, in the MCPpath only, discovered days later. The old doc comment already warned that
""reads downstream as "unattributable" — which is the evidence that documenting it
was not enough.
So
WrapperOptionscarriesValidate, and the generators returnErrMissingRunID/ErrMissingResultsPrefixinstead of a script.Two non-obvious calls
Regionis deliberately not required. It is used only for the ECR login of aprivate-registry image, so a host-command task legitimately has none. Validating
it would make the check fire on correct input, and a check that cries wolf is one
people route around — which is how the original bug survived a documented
warning. Pinned by a test.
RunIDis not defaulted, even though empty is always wrong. Minting oneinside the library looks like the obvious safe fix and is actually the dangerous
one:
cmd/task.gouses the same id in five places — clearing the previousattempt's record, the flush script, displayed output, and
pollCompletion(..., runID, ...)for--waitverification. An id mintedprivately in here would be invisible to exactly the code that has to match it,
defeating #608's verification rather than protecting it.
No positional shim
There is one external caller (
spore-host-mcp/launch.go:237, already on thecurrent signature);
GeneratePooledJobScriptandGenerateFlushScripthavenone. A deprecated positional form would preserve the exact hazard being removed
in exchange for almost nothing. Hard cutover.
Verification
The #763 API gate's first real use, and it reported exactly what it exists to
report:
New tests cover what is new: all three generators reject an empty
RunIDand anempty
ResultsPrefix, an emptyRegionis accepted, the options reach theemitted script, and the flush hook's output is byte-identical with
GPUtrue vsfalse.
Both confirmed to fail on revert, with compiling edits — a build failure is
not a passing gate:
RunIDcheck fromValidateValidatecall fromGenerateWrapperonlyLocally: format,
vet ./...,-short ./..., all 12 nested modules, changeloggate, docs-drift gate,
semgrep --config=auto --error— clean.Downstream — your call, not done here
This needs a MINOR release to be consumable, and then a coordinated
spore-host-mcpupdate. Neither is in this PR: tagging is yours to approve, andmcp is a separate repo.
Migration is mechanical:
Also still outstanding from #679's measurement, unrelated to this change:
lagotto is pinned to
spawn v0.111.1— the broken patch release itself — andcalque to v0.100.0.