Repository navigation
Description
Summary
Add a seedable task-completion outcome for spore.host spawn task run — a programmable per-task {exit_code, state} that the emulator serves as the task's completion record, on the simulated clock. This is the same shape as #345's proposed SSM programmable-response hook and the existing capacity-error/seeded-result mechanism — not workload execution, so it stays inside Substrate's scope boundary.
Framing (corrected — thanks to reading docs/scope.md)
My first draft asked Substrate to "write completion.json to S3 after the instance runs," which fights the scope boundary (that's simulating a workload side-effect). The scope doc already describes the right model:
"[a workload input is] captured as recorded intent with a seedable success/failure/completion signal ... a command invocation going Pending → InProgress → Success"
So the completion record is a seedable outcome, exactly like a seeded SSM GetCommandInvocation (#345) or a seeded CapacityError — the caller seeds {exit_code, state} per task; Substrate serves it deterministically over the simulated clock. No user-data execution, no scope violation.
Context / why
The spore.host workflow adapters (nf-spawn, miniwdl-spawn, cwl-spawn, snakemake-executor-plugin-spawn, airflow-spawn, pegasus-spawn) run each task via spawn task run, which launches an ephemeral EC2 instance; the task writes a durable completion record to s3://<results-bucket>/tasks/<task_id>/completion.json (+ .exitcode), and the adapter polls it. We want these adapters' engine-composition tests to run in CI against Substrate (AWS_ENDPOINT_URL → emulator) — real engine + real spawn task run + real aws s3 staging, all against the emulated S3/EC2 APIs (verified spawn task run honors AWS_ENDPOINT_URL). The only missing piece is the completion signal, which today never appears because Substrate (correctly) doesn't run the instance's workload.
Ask (pick whichever fits Substrate's seeding model — team decides)
A programmable-response hook for the spore task lifecycle, e.g.:
- Seed by task id / instance tag: register
{exit_code:int, state:"completed"|"failed", started_at, ended_at}for aspawn:task-id(a tagspawn task runalready sets), served as thecompletion.jsonobject when the S3 GET arrives — mirroring how SSM: SendCommand should (optionally) execute the shell command, not always return empty Success #345 proposes per-(instance, command) SSM canned results. - Default nominal path: absent a seed, return
exit_code:0 / completed(the nominal success path, per the seeding philosophy) so the happy path needs no seeding at all. - Clock-aware: a poll observes "not yet present / still running" then "completed" over the simulated clock, so the adapters' real poll loops are exercised.
Record schema (from spawn/pkg/taskproto/completion.go):
{"task_id":"<id>","exit_code":0,"state":"completed","started_at":"<rfc3339>","ended_at":"<rfc3339>"}Payoff
- All six spore.host workflow adapters get faithful, hermetic, no-AWS engine-composition CI (real spawn + real staging; only the completion outcome seeded).
- spawn's own Tier-0 can then assert
task run→ completion → exit-code end-to-end against Substrate (today Tier-0 covers launch/list/terminate, not task completion). - Natural companion to SSM: SendCommand should (optionally) execute the shell command, not always return empty Success #345 (both are "seedable result for a recorded-intent workload," same design question).
Interim
Until this lands, the adapter CI tests hand-seed the record with a one-line aws s3 cp of a completion.json into the emulated bucket (works against today's Substrate); they drop that line once the seeding hook exists.
Filed per the spore.host workflow: substrate changes are requested via issue, not PR'd from consumer repos. Corrected framing after studying docs/scope.md + the #345 precedent. Found while scoping real-engine-in-CI regression guards for the workflow adapters (spore-host#397).
Activity
scttfrdmn commentedon Jul 26, 2026
Accepted — this is in-scope and well-framed. Thanks for course-correcting against
docs/scope.md; the seedable-completion-signal model is exactly right, and it lands as a direct sibling of #345 (seededGetCommandInvocation, shipped in v0.74.0) and the SageMaker/Bedrock/Athena seed pattern. No workload execution — just a seedable, clock-aware completion observation.Design (proposed)
S3-GET intercept, not materialize-on-seed. The adapters do a real
aws s3GET oftasks/<task_id>/completion.jsonagainst the emulated S3 (you confirmedspawn task runhonorsAWS_ENDPOINT_URL), so keeping the S3 API observation authentic is the priority. A seeded completion resolves insidegetObject, gated on the simulated clock in one place, rather than pre-writing a real object.POST /v1/spawn/task-completionwith{"task_id","exit_code","state","started_at","ended_at"}, plusDELETE /v1/spawn/task-completion?taskId=...(or clear-all), following the/v1/ssm/command-invocationconvention.tasks/<task_id>/completion.json(and the.exitcodecompanion) checks the seed store first. Before the seed'sended_at(on the simulated clock viaTimeController) →404 NoSuchKey(i.e. "still running"); at/afterended_at→ synthesize the record body. This exercises the adapters' real poll loops (not-present → completed) deterministically.aws s3 cpstaging keeps working. Note: the "no seed → exit 0/completed" default only makes sense scoped to keys matching the task-completion pattern; a bare unseeded GET of a non-existent key must still 404. I'll scope any synthesized default to thetasks/*/completion.jsonkey shape so we don't turn every 404 into a fake success.One thing to confirm before I implement
From
spawn/pkg/taskproto/completion.go, please pin:completion.json(issue showstask_id/exit_code/state/started_at/ended_atsnake_case — confirm that's the wire form)..exitcodecompanion object — plain-text body (just the integer?), and is it polled independently or onlycompletion.json?statevalue set —"completed"/"failed"only, or others?Once those are pinned I'll implement against
emulator/s3_plugin.gogetObject+ a newemulator/spawn_control.go, mirroringssm_control.go. Targeting the next minor (v0.75.0).scttfrdmn commentedon Jul 26, 2026
Great — the S3-GET-intercept design (resolve inside
getObject, clock-gated, scoped to thetasks/*/completion.jsonkey shape so a bare 404 stays a 404) is exactly right. Pinning your three questions fromspawn/pkg/taskproto/completion.go+cmd/task.go:1.
completion.jsonwire form — snake_case, confirmedMarshalled from
taskproto.CompletionRecord:So the minimal synthesized body is exactly the five fields the issue listed;
cost_estimate/logs/retry_classareomitemptyand the consumer tolerates their absence — you can omit them.2.
.exitcodecompanion — the CLI does NOT read it; you can skip itThis is the useful simplifier. The wrapper writes
.exitcodeas a plain-integer body (printf '%s' "$rc"→ e.g.0) alongsidecompletion.json, but it's a legacy/external signal — I grepped the whole CLI (cmd/,pkg/taskproto,pkg/aws) and nothing reads.exitcode.spawn task status— both--check-completeand-o json— resolves solely throughfetchCompletion(), which GETstasks/<task_id>/completion.jsononly (NoSuchKey⇒ "still running"). So:completion.json..exitcode(plain integer text attasks/<id>/.exitcode) is optional — nice for fidelity/external consumers, not required by any spawn CLI path.3.
statevalue setThe
TaskStateenum issubmitted | launching | running | completed | failed | cancelled, but a completion record only ever carries a terminal value:"completed"(exit 0) or"failed"(nonzero/cancelled). So for the seed,state ∈ {completed, failed}is the complete set — default seedexit_code:0 / state:"completed".Net for your implementation
getObjecton thetasks/*/completion.jsonkey shape.ended_at(simulated clock) →NoSuchKey; at/after → synthesize the 5-field JSON above.exit_code:0 / completed; non-matching key → normal 404 (as you said)..exitcodesynthesis: optional.Seed endpoint
POST /v1/spawn/task-completion{task_id, exit_code, state, started_at, ended_at}mirroring/v1/ssm/command-invocationis perfect. That fully unblocks the adapters' engine-composition CI (real spawn + realaws s3staging vs. Substrate; only the completion outcome seeded). Thanks — will migrate the adapters off the interimaws s3 cpseed to this once v0.75.0 ships.test(s3): cover spawn task-completion malformed-seed and no-ended-at …
feat(s3): seedable spore.host task-completion outcomes (#360) (#361)
scttfrdmn commentedon Jul 26, 2026
Landed on `main` in #361 (commit 18a7919). Ships in v0.75.0.
Implemented exactly as agreed:
You can migrate the adapters off the interim `aws s3 cp` seed to `POST /v1/spawn/task-completion` once v0.75.0 tags. Ill comment here when the release goes out.
chore(release): v0.75.0 (#362)
scttfrdmn commentedon Jul 26, 2026
Released in v0.75.0 — https://github.com/scttfrdmn/substrate/releases/tag/v0.75.0 (`go get github.com/scttfrdmn/[email protected]`). You can now migrate the adapters off the interim `aws s3 cp` seed to `POST /v1/spawn/task-completion`.
fix(s3): resolve task completions on HeadObject so HEAD matches GET (#…