Skip to content

feat: gate the exported API that other repos compile against (#679) - #763

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/679-cross-repo-api-gate
Oct 8, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/679-cross-repo-api-gate

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #679. Its item 4 is split out to #764 rather than dropped — see the bottom.

What #679 found, confirmed

pkg/taskproto.GenerateWrapper gained a parameter in v0.111.1, a PATCH
release
. Checked against the tags:

v0.111.0  func GenerateWrapper(spec *TaskSpec, resultsBucket, region string) string
v0.111.1  func GenerateWrapper(spec *TaskSpec, resultsBucket, region string, gpu bool) string
v0.112.0  ... gpu bool, runID string) string      ← MINOR, compliant

spore-host-mcp called it with three arguments, so its Dependabot bump became a
red build in a different repository and sat red for six days. A consumer is
entitled to treat a patch bump as safe, and Dependabot is configured across these
repos on exactly that assumption.

The surface is eight packages, not three

#679 names pkg/taskproto, pkg/launcher and pkg/aws. Measured from each
consumer's actual imports:

package imported by
pkg/aws spore-host-mcp, lagotto, calque
pkg/launcher spore-host-mcp, lagotto, calque
pkg/taskproto spore-host-mcp
pkg/ecrref spore-host-mcp
pkg/launchererr lagotto
pkg/taskcohort calque
pkg/taskpool calque
pkg/storage calque

Five were missing from the issue, so a gate built from its list would have left
them unguarded. Worth noting separately: lagotto is currently pinned to
v0.111.1
, the bad release, and calque to v0.100.0.

The gate

api/public-surface.txt — a committed snapshot of every exported declaration in
those packages. api_surface_test.go recomputes and diffs it, classifying the
change:

REMOVED or CHANGED — breaks a consumer, so the release bumps MINOR, not PATCH:
  - func GenerateWrapper(spec *TaskSpec, resultsPrefix, region string, gpu bool, runID string) string
ADDED — backward-compatible:
  + func GenerateWrapper(spec *TaskSpec, resultsPrefix, region string, gpu bool) string

Syntactic — go/parser, stdlib only, no network, no git tags — so it runs under
the same conditions as every other gate here and can't fail for an unrelated
reason. It doesn't block intended changes; it puts them on the diff next to the
CHANGELOG entry and the version decision. make api-snapshot regenerates.

Exported struct fields are included. Removing or retyping one breaks a
consumer as surely as a signature change, and is easier to do by accident.

One design point worth flagging

Members render one per line, and that's load-bearing. With one line per type,
adding a struct field changes that line — so a set difference sees a line vanish
and another appear, and the gate reports a backward-compatible addition as
"breaks a consumer." The first version of this did exactly that, which is why
the rendering changed. A gate that cries wolf on a safe change is one people
learn to regenerate without reading, which is worse than no gate.

Verification

Four directions, each against a compiling tree — a build failure is not a
passing gate:

probe expected result
reproduce the #679 break (drop runID, fix the in-repo caller) REMOVED/CHANGED ✅
add an exported struct field ADDED only, breaking bucket empty ✅
add an unexported field silent ✅
publicPackages entry for a nonexistent dir fail ✅

Plus the CLAUDE.md drift gate, both ways: a guarded-but-undocumented package
fails, and a documented-but-unguarded one fails.

Locally: format, vet ./..., -short ./..., all 12 nested modules, the
changelog gate, the docs-drift gate, and semgrep --config=auto --error — clean.
make api-snapshot is idempotent.

Item 3: naming the surface

CLAUDE.md now carries the table and the SemVer rule, which is what #679 asked
for — the policy had nothing concrete to attach to. A third test keeps that table
and publicPackages in step, since the alternative was a comment asking a reader
to maintain two lists by hand: the same category of promise that produced #679.

Not in this PR

#764 — making GenerateWrapper take an options struct (#679 item 4). It has gained two
parameters in two releases and the reasoning in the issue is sound, but it is
itself a breaking change to a package three repos import, so it wants its own
decision — and now the gate would report it as one.

Also surfaced but out of scope: lagotto's pin to the broken v0.111.1 and calque's
to v0.100.0 are both worth their own bumps.

#679: pkg/taskproto.GenerateWrapper gained a parameter in v0.111.1, a PATCH
release. Confirmed against the tags:

  v0.111.0  func GenerateWrapper(spec *TaskSpec, resultsBucket, region string) string
  v0.111.1  func GenerateWrapper(spec *TaskSpec, resultsBucket, region string, gpu bool) string
  v0.112.0  ... gpu bool, runID string) string     (MINOR — compliant)

spore-host-mcp called it with three arguments, so its Dependabot bump from
v0.111.0 to v0.111.1 became a red build in a DIFFERENT repository and sat
red for six days before anyone connected it to the cause. A consumer is
entitled to treat a patch bump as safe, and Dependabot is configured across
these repos on exactly that assumption.

The underlying problem was that nothing here knew these packages had
outside callers, so re-shaping an exported symbol looked like cleanup.

## The public surface is eight packages, not three

Measured from each consumer's imports rather than assumed:

  pkg/aws          spore-host-mcp, lagotto, calque
  pkg/launcher     spore-host-mcp, lagotto, calque
  pkg/taskproto    spore-host-mcp
  pkg/ecrref       spore-host-mcp
  pkg/launchererr  lagotto
  pkg/taskcohort   calque
  pkg/taskpool     calque
  pkg/storage      calque

#679 named taskproto, launcher and aws. Five of the eight were missing, so
a gate built from the issue's list would have left them unguarded.

## The gate

api/public-surface.txt is a committed snapshot of every exported
declaration in those packages; api_surface_test.go recomputes it and fails
on drift. Syntactic (go/parser, stdlib only, no network, no git tags) so it
runs under the same conditions as every other gate here and cannot fail for
an unrelated reason.

It does not block intended changes — it makes them visible on the diff,
next to the CHANGELOG entry and the version decision, instead of days later
as someone else's red CI. `make api-snapshot` regenerates.

Exported struct FIELDS are included: removing or retyping one breaks a
consumer as surely as a signature change, and is easier to do by accident.

Members are rendered ONE PER LINE, which is load-bearing. Rendered as one
line per type, adding a struct field changes that line, so a set difference
sees one line vanish and another appear — and the gate reports a
backward-compatible addition as "breaks a consumer". The first version did
exactly that. A gate that cries wolf on a safe change is one people learn
to regenerate without reading.

Verified in four directions, each against a COMPILING tree:

  - the exact #679 break (drop runID, fix the in-repo caller) -> reported
    under REMOVED or CHANGED;
  - adding an exported field -> reported under ADDED only, nothing in the
    breaking bucket;
  - adding an UNEXPORTED field -> silent, no churn;
  - a publicPackages entry naming a directory that does not exist -> fails.

## Naming the surface

CLAUDE.md now carries the table and the SemVer rule, which is #679's third
item: the policy had nothing concrete to attach to. A third test keeps that
table and publicPackages in step, because the alternative was a comment
asking a reader to maintain two lists by hand — the same category of
promise that produced #679.

Not addressed here: #679's fourth item, making GenerateWrapper take an
options struct. That is itself a breaking change and wants its own decision
now that the gate would report it.
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 44dcbc7 into main Oct 8, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/679-cross-repo-api-gate branch October 8, 2026 20:23
scttfrdmn added a commit that referenced this pull request Oct 8, 2026
…n an error (#765)

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.
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.
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.

pkg/taskproto broke an exported API in a PATCH release (v0.111.1); no gate knows it has external consumers

1 participant