Skip to content

feat(task): taskproto foundation + task run --dry-run (#386 increment 1) - #399

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/386-taskproto-foundation
Jul 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/386-taskproto-foundation

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

First increment of the workflow-adapter task-execution protocol RFC (docs/workflow-adapter-protocol-rfc.md, tracking #386). Foundation + dry-run only — launches nothing.

What

pkg/taskproto — the shared contract the five adapters would target instead of each reimplementing sizing/staging/launch/completion:

  • Wire types: TaskSpec, ResourceRequest, input/output Manifest, Lifecycle, TaskState, with offline Validate (required fields, enum values, TTL parse).
  • Size() — cheapest instance type meeting a ResourceRequest, over an injectable InstanceFinder. Adds a multi-family allow-list and memory headroom (both absent from truffle's single-family filter), ranks by on-demand price (unknown prices sort last).

spawn task run --spec task.json --dry-run — parses + validates the spec, sizes via a truffle-backed finder, prints the plan (instance type, rate, TTL, est. max cost = rate × TTL, input/output manifests). --dry-run is currently required; a bare task run errors out pointing to it, so we never half-launch. Example at examples/task-spec.json.

Design for testability / cost-safety

renderTaskDryRun is split from the cobra RunE (which builds the AWS-backed truffle finder), so it's unit-tested against a fake finder — no AWS, no launch. The sizer likewise takes an interface. Nothing here calls aws.Client.Launch.

Tests

  • pkg/taskproto: spec parse/validate (good + 9 failure cases), sizer ranking (cheapest wins, family allow-list filters, GPU requirement, unknown-price-sorts-last, no-match error), headroom math.
  • cmd: renderTaskDryRun prints the expected plan with the cheapest instance + est. cost and asserts it never claims to launch.

Scope (later increments, #386 stays open)

Real launch, the durable .exitcode-in-S3 CompletionRecord, RetryClassification, and adapter migration — all deferred per the RFC.

Refs #386

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.37321% with 87 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/task.go 37.11% 58 Missing and 3 partials ⚠️
pkg/taskproto/taskspec.go 69.49% 12 Missing and 6 partials ⚠️
pkg/taskproto/sizer.go 84.90% 7 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

First increment of the workflow-adapter task-execution protocol RFC.

New pkg/taskproto:
- TaskSpec / ResourceRequest / Manifest / Lifecycle / TaskState wire
  types with offline Validate (required fields, enum values, TTL).
- Size(): cheapest instance type meeting a ResourceRequest, over an
  injectable InstanceFinder — adds a multi-family allow-list and memory
  headroom on top of what truffle's single-family filter offers, ranks by
  on-demand price (unknown prices sort last).

New `spawn task run --spec <file> --dry-run`:
- Parses+validates the spec, sizes via a truffle-backed finder, and
  prints the plan (instance, rate, TTL, est. max cost = rate × TTL,
  staging manifests). --dry-run is currently required; a bare run errors
  out pointing to it, so we never half-launch. Launches nothing.

renderTaskDryRun is split from the RunE so it's unit-tested with a fake
finder (no AWS). Example spec at examples/task-spec.json.

Real launch + durable .exitcode-in-S3 completion are later increments;

Refs #386
@scttfrdmn
scttfrdmn force-pushed the feat/386-taskproto-foundation branch from 4c31a43 to bb56dc9 Compare July 19, 2026 16:55
@scttfrdmn
scttfrdmn merged commit a7a745e into main Jul 19, 2026
6 of 7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/386-taskproto-foundation branch July 19, 2026 16:58
scttfrdmn added a commit that referenced this pull request Aug 1, 2026
* chore(deps): bump substrate test dependency to v0.81.0

Test-only; no runtime or API change (root + lambda/dns-updater).

The reason to take it now is substrate#412: RunInstances previously accepted an
empty ImageId and launched an instance, so our guard against launching without a
resolved AMI had no offline test that could fail -- the bug we filed it for
shipped, and was caught only by a paid smoke test against real AWS. Substrate now
returns MissingParameter / HTTP 400 when no AMI resolves from any source
(request or launch template), so that path is reachable in -short tests.

Fixing it also surfaced a substrate request-parser defect: an explicitly-empty
query-protocol body parameter was coerced to the bare-key sentinel "1", so
ImageId= arrived as the string 1 and launched from an AMI named 1 -- affecting
every EC2/IAM/STS/SQS/SNS parameter sent empty.

Also newly testable offline: Invalid*ID.NotFound for explicit EC2 IDs (#391),
symbolic Error.Code per service (#392), Lambda invoke omitting FunctionError and
LogResult (#393), S3 Range and conditional requests (#396, #397),
x-amz-checksum-* verification (#399), storage classes and CopyObject metadata
directives (#398), Content-Encoding surviving a multipart upload (#406), and a
seedable SQS create-then-lookup consistency window with the correct
QueueDoesNotExist code -- the legacy dotted form was uncatchable as a typed
error in either SDK, which is what the taskpool queue-lifecycle tests assert on
(#413).

Note: cmd's TestCatalogValid fails on main already (two private ECR images in
the shipped app catalog, #392) and is unrelated to this bump.

* fix(ttl-reaper): bump accountlifecycle past the substrate import move

The Security job on this branch (and on main — this is not PR-introduced) failed
with `go: updates to go.mod needed` in lambda/ttl-reaper. Cause is Go MVS plus
upstream tag timing, not any commit here:

  ttl-reaper requires spore-host/lambda/accountlifecycle at a pseudo-version
  whose *test* imported substrate at its old root path. Substrate moved that
  package to /emulator in v0.70.0, so once v0.80.0 (2026-08-01 02:11Z) and
  v0.81.0 (06:12Z) were tagged — after spawn main's last green Security run
  (2026-07-31 17:52Z) — resolution broke with no local change involved.

#509 fixed the import; this bumps the pin to that merged commit
(14e273c). Verified: `go mod tidy -diff` clean, `go build ./...` clean, and
govulncheck (v1.3.0, as CI pins) reports no vulnerabilities.

Note the go.sum-only tidy drift in alert-handler, autoscale-orchestrator and
sweep-orchestrator is pre-existing on main and does not affect govulncheck,
which is what the job actually runs. Left alone here to keep this fix scoped.
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