Skip to content

Withdraw spawn stage - #854

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/805-withdraw-stage
Oct 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/805-withdraw-stage

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #805. Correctness audit 2026-10. Phase 5 decision, per your approval.

Why withdraw rather than finish

  • It uploads to a bucket it never creates.
  • Nothing downloads the staged data — there is no reader anywhere in the tree.
  • No staging bucket exists in the account, so it has never run.
  • Meanwhile spawn stage estimate printed "Savings: $85.70 (93% reduction)" to anyone
    who typed it. That figure was the most concrete thing the feature produced.

~1,600 lines removed: the command, its three subcommands, and the seven stage-only
functions in pkg/staging.

pkg/staging/cost.go and its 295 lines of tests went too. The model is entirely
staging-specific — EstimateStagingCost, "Data Staging Cost Comparison" — and has nothing
to estimate once the feature is gone. Recoverable from history if the idea is revived.

pkg/staging is NOT removed

This is the trap the audit plan flagged, and it is real: NewClient,
resolveSchedulesBucket, ensureBucket and UploadScheduleParams are live on the
spawn schedule path, and three spawn-schedules-* buckets exist in the account.

So each of the seven removed functions was checked for callers outside the command first:

GenerateStagingID:     0        UploadScheduleParams: 2   ← live
UploadToPrimaryRegion: 0        NewClient:            2   ← live
ReplicateToRegion:     0
RecordMetadata:        0
GetMetadata:           0
ListStagedData:        0
DeleteStaging:         0

The coverage swap is the part worth reviewing

pkg/staging/staging_test.go's five tests covered only the functions removed here. So
deleting it would have left the live half of the package with no behavioural coverage at
all
— including resolveSchedulesBucket, the function #804 had just made load-bearing,
since the caller now persists which bucket it chose.

Four tests against the Substrate emulator replace them:

  • the shared spawn-schedules-<region> is preferred;
  • the returned name is a bucket that actually exists — a function that creates the
    right bucket and reports the wrong name is precisely what broke scheduled sweeps;
  • the account-scoped fallback works and carries the account id, so it cannot collide the
    way the shared name does;
  • two calls return the same name, since every schedule creation calls this and a second
    call returning something different would make the persisted name wrong for every
    schedule after the first.

Swapping dead-code coverage for live-code coverage is why both halves belong in one change
rather than a deletion now and a test later.

The e2e coverage gate caught one of these itself

tier0_coverage_test.go:117: stale coverage classifications for commands no longer in
  the binary: [covered:stage]

That is the right shape for a gate over a classification list, and worth noting after a
day of finding ones that were not.

TestTier0_StageListEmpty also went.

Docs

examples/README.md's first staging step told users to run spawn stage upload. It now
says what to do instead — aws s3 cp, or an FSx data-repository association via
--fsx-import-path — and the parameter file in step 2 still works for a normal launch.

Verification

make check (all nested modules), make check-docs with docs-gen/stage.md removed by
regeneration, changelog gate, semgrep 0 findings, make api-snapshot no drift
(pkg/staging is not in the public-surface set), Tier 0 e2e with -count=1, and
spawn stage now exits 1 with unknown command "stage".

It uploaded to a bucket it never created, nothing ever downloaded the
staged data, and no staging bucket exists in the account — so it had
never run. Meanwhile `spawn stage estimate` published "Savings: $85.70
(93% reduction)" to anyone who typed it, which was the most concrete
thing the feature produced.

~1,600 lines: the command, its three subcommands, and the seven
stage-only functions in pkg/staging. pkg/staging/cost.go and its tests
went too — the model is entirely staging-specific ("Data Staging Cost
Comparison", EstimateStagingCost) and has nothing to estimate once the
feature is gone. Recoverable from history if the idea is revived.

pkg/staging is NOT removed. NewClient, resolveSchedulesBucket,
ensureBucket and UploadScheduleParams are live on the `spawn schedule`
path — three spawn-schedules-* buckets exist — so each of the seven
removed functions was checked for callers outside the command first, and
each had zero.

Deleting staging_test.go would have left the live half with no
behavioural coverage at all: its five tests covered only the functions
removed here, and resolveSchedulesBucket is the function #804 had just
made load-bearing, since the caller now persists which bucket it chose.
So four tests replace them, against the Substrate emulator: the shared
name is preferred; the RETURNED name is a bucket that actually exists,
because a function that creates the right bucket and reports the wrong
one is exactly what broke scheduled sweeps; the account-scoped fallback
works and carries the account id; and two calls agree. Swapping
dead-code coverage for live-code coverage is why both halves belong in
one change.

Two e2e tests referenced the command, and the coverage gate caught the
first by itself — "stale coverage classifications for commands no longer
in the binary: [covered:stage]", which is the right shape for a gate
over a classification list.

examples/README.md told users to run it; it now says what to do instead
(aws s3 cp, or an FSx data-repository association via --fsx-import-path).

Closes #805
@scttfrdmn scttfrdmn added this to the Correctness audit 2026-10 milestone Oct 11, 2026
@codecov

codecov Bot commented Oct 11, 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 a448e76 into main Oct 11, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/805-withdraw-stage branch October 11, 2026 23:26
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.

spawn stage cannot work: nothing downloads the staged data, and the bucket it uploads to is never created

1 participant