Skip to content

Add --mode, --track-state flags to aspect delivery#1023

Merged
gregmagolan merged 1 commit intomainfrom
delivery_updates
Apr 27, 2026
Merged

Add --mode, --track-state flags to aspect delivery#1023
gregmagolan merged 1 commit intomainfrom
delivery_updates

Conversation

@gregmagolan
Copy link
Copy Markdown
Member

@gregmagolan gregmagolan commented Apr 27, 2026

Summary

Reshape aspect delivery around three orthogonal flags so it can run in environments without persistent state (local development, non-Aspect-Workflows CI) and supports always-deliver semantics:

  • --mode={selective,always} (default selective) — selective uses change detection (only runs candidates that haven't already been delivered for the --task-key[:--salt] prefix). always skips change detection and runs every resolved target — closest analogue to the legacy only_on_change: false rule attribute. Useful for use cases where you want to deliver every target on every commit.
  • --track-state={true,false} (default true) — opt out of recording/querying delivery state across runs. Required false for environments where the state backend isn't available.
  • --dry-run (existing) is now strictly orthogonal to --mode — composes with both.

The current state backend is deliveryd. The flag is named --track-state rather than --deliveryd so the public API doesn't leak the service name; deliveryd continues to be referenced internally where it's an accurate implementation detail.

Rejected combination

--mode=selective --track-state=false is rejected at startup: change detection cannot decide what to deliver without persisted state. The error message points users to --mode=always.

Best-effort preview

--mode=always --dry-run --track-state=false is the only combination tolerant of a missing remote cache:

  • With a remote cache: computes action digests and shows them in the dry-run output.
  • Without one: prints a NOTE: and falls back to listing candidates without digests; everything else still works.

Every other mode still hard-errors on missing remote cache because they need digests for correctness (recording or change-detection decisions).

Combination matrix

Combination phase 1/2 phase 3 record query run deliver
--mode=selective (default)
--mode=selective --dry-run
--mode=selective --track-state=false rejected at startup
--mode=always
--mode=always --dry-run
--mode=always --track-state=false
--mode=always --dry-run --track-state=false optional

Phase 3 is the same code path across all modes (same bazel build call, same flags). What differs is what's already in any configured remote cache going in — when phase 1/2 ran first, phase 3 typically downloads its outputs; when phase 1/2 was skipped, phase 3 may build more from source / local cache, or hit cache from prior unrelated jobs.

Why --mode=always records by default

When state tracking is enabled, --mode=always records the digests and deliveries it produces. A subsequent --mode=selective run sees those digests in its change-detection check and skips them — usually what you want from a backfill. Pass --track-state=false if you specifically want --mode=always to skip recording.

Hook dispatch

bazel_trait.build_end hooks fire once per invocation, with the relevant build's exit code: phase 1/2 status when phase 1/2 ran, phase 3 status when only phase 3 ran (--mode=always --track-state=false). Features registered to that hook (e.g., ArtifactUpload's testlogs flush + profile/execlog/BEP upload) work in all modes.

Documentation

  • Module docstring at the top of delivery.axl is rewritten as the public-facing reference: pipeline phases, flag set, combination matrix, failure modes, and design rationale. User-facing prose uses "change detection" to describe the what; implementation comments retain action_digest / deduplication prefix terminology where they describe the how.
  • User-facing migration guide updated separately at docs.aspect.build/cli/migration/delivery (in the docs repo).

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da09e721de

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/aspect-cli/src/builtins/aspect/delivery.axl
gregmagolan added a commit that referenced this pull request Apr 27, 2026
When `--mode=force-all --track-state=false` (non-dry-run), `phase_1_2_runs`
is False so the existing build_end dispatch at lines 448-449 is skipped.
Phase 3 still does a real Bazel build, but no path invokes
`bazel_trait.build_end` afterwards. Features registered to that hook —
notably `ArtifactUpload` ([feature/artifacts.axl:476](feature/artifacts.axl#L476))
which finalizes testlogs flushing and uploads profile/execlog/BEP — never
fire in this mode.

Fix: when phase 1/2 was skipped, dispatch build_end with phase 3's status
right after `build.wait()`. The phase-1/2-having-run cases already
dispatched build_end with their own build_code and are unaffected.

Reported by Codex during PR #1023 review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gregmagolan gregmagolan force-pushed the delivery_updates branch 2 times, most recently from 746ea40 to 72ed637 Compare April 27, 2026 22:00
@gregmagolan gregmagolan changed the title Add --mode, --deliveryd flags to aspect delivery Add --mode, --track-state flags to aspect delivery Apr 27, 2026
@gregmagolan gregmagolan force-pushed the delivery_updates branch 2 times, most recently from 36de390 to eb40724 Compare April 27, 2026 22:19
@gregmagolan gregmagolan merged commit 01f175b into main Apr 27, 2026
17 checks passed
@gregmagolan gregmagolan deleted the delivery_updates branch April 27, 2026 22:43
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.

2 participants