Skip to content

Record task output regeneration cost and provenance (#1076, phase 1) - #1088

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/1076-phase1-record
Oct 17, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/1076-phase1-record

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Refs #1076. Phase 1 of docs/recompute-tag-design.md: record only; nothing is tiered or deleted. Applies the owner's 2026-10-17 decisions:

  • cheap is < $1 and < 1 h; expensive is ≥ $25 or ≥ 12 h;
  • deletion is opt-in per spec;
  • task results only.

What a task output now carries

  • Tags, set in the same request as the upload: spawn:regen-class, spawn:regen-usd, spawn:regen-hours, spawn:run-id, and spawn:regenerable (only when opted in and every input was readable).
  • An S3 object annotation spawn.provenance (JSON):
    • recipe: command, env names (never values), image plus the digest that actually ran (docker inspect after the pull), AMI, instance type, spawn/spored versions;
    • each input's ETag and version as read;
    • the cost, with its rate source: spot (price paid), on-demand:live, on-demand:static, or on-demand (source not recorded). Windows is marked as a lower bound.
  • completion.json cost_estimate, defined and never written until now.
  • An unknown rate means no class, so nothing can match a rule: kept, not cheap.

How

  • pkg/provenance: classification, cost, the record, tags, and ObjectKey. The key mapping is pinned against the real aws s3 cp on a throwaway bucket (recursive with and without a trailing slash, root, single file to a key or a prefix).
  • spored provenance stage-in | cost | upload. upload replaces the wrapper's aws s3 cp for outputs, which is how tags are set at write time. Only an object this run just wrote is ever tagged, and the task role needs no read access to verify anything. The annotation is bound to the uploaded ETag (ObjectIfMatch).
  • The wrapper calls it at three points, gated on spored provenance --help succeeding. With an older spored, everything falls back to plain aws s3 cp, exactly as before; otherwise "unknown command" would fail the output upload. The spec copy for spored has env values stripped.
  • IAM: spawn task run's role gains s3:PutObjectTagging + s3:PutObjectAnnotation on its write buckets only (action names from AWS's machine-readable service reference). The shared taskStagingPolicy used by launch --s3-write and sweeps is unchanged.
  • spawn:price-source (live/static) tagged at launch from what resolvePricePerHour already knew, so a cost built from a static rate is labelled static.
  • Public API, additive: TaskSpec.Regenerable, LaunchConfig.PriceSource, aws.PriceSourceTag. Snapshot updated.

Verified on real AWS (dev account; everything cleaned up)

  • spored provenance upload from a workstation, against a throwaway bucket: keys match aws s3 cp --recursive, all four tags were present at upload, and the spawn.provenance annotation is present and round-trips (run id, class, USD, rate source).
  • PutObjectAnnotation + ObjectIfMatch: right ETag accepted; wrong ETag refused with PreconditionFailed.
  • PutRolePolicy accepts the exact generated task policy. Simulation: tagging and annotation are allowed on the write bucket and denied on the read bucket.

Not yet verified: a real spawn task run writing tagged outputs. The instance's spored comes from a release, and without the subcommand the wrapper (correctly) falls back. That's the post-release check.

Gates

14 reverts, each kept compiling; every one fails:

  • the cheap-AND rule; unknown → unclassified; the recursive key mapping;
  • tagging at write; the annotation bound to the ETag; symlinks not followed;
  • the static rate label; an incomplete input record blocking regenerable; upload using the record;
  • the wrapper's capability check; cost sanitizing; env values stripped;
  • the task IAM statement; the price-source tag.

Wrapper behaviour is tested by executing it under bash with a fake spored and aws. Also fixed a vacuous negative test (launch_s3_buckets_test) that matched a literal JSON fragment and would have passed whatever the policy said.

go vet, staticcheck (GOOS=linux), the hermetic suite, nested modules, check-docs and semgrep all pass.

@scttfrdmn
scttfrdmn force-pushed the feat/1076-phase1-record branch from 4f6e1a6 to fdb0ce1 Compare October 17, 2026 20:57
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.35616% with 79 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/spored/provenance.go 67.25% 41 Missing and 15 partials ⚠️
pkg/provenance/upload.go 81.53% 6 Missing and 6 partials ⚠️
pkg/taskproto/wrapper.go 84.00% 5 Missing and 3 partials ⚠️
pkg/provenance/provenance.go 97.14% 1 Missing and 1 partial ⚠️
cmd/task.go 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn force-pushed the feat/1076-phase1-record branch from f18f3d5 to 5ae8e44 Compare October 17, 2026 21:23
@scttfrdmn
scttfrdmn merged commit c597acf into main Oct 17, 2026
8 checks passed
@scttfrdmn scttfrdmn mentioned this pull request Oct 17, 2026
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