Skip to content

core: key a filtered collection view by an origin that holds no per-call Workspace - #15045

Open
yasyf wants to merge 1 commit into
dagger:mainfrom
yasyf:artifact-view-origin
Open

yasyf wants to merge 1 commit into
dagger:mainfrom
yasyf:artifact-view-origin

Conversation

@yasyf

@yasyf yasyf commented Nov 3, 2026

Copy link
Copy Markdown

Key a filtered collection's view by an origin that holds nothing per-session, so checks under a filter can cache across sessions. #15044 has the details.

artifactViewOrigin hashed the collection's recipe, which held the host Workspace's cachePerCall input, the module recipe of each rebuilt call, and the cache-per-call inputs of any argument Append rebuilt. It now changes only what varies per session:

  • On the source's own call chain, the ambient Workspace, a currentWorkspace with no receiver, becomes its type name. An explicit or overlaid Workspace keeps its identity, so two collections built from different overlays keep different origins.
  • A call with nothing to change keeps its ID, so a digest the engine set survives. "Unchanged" compares digests, since two ID pointers can carry one digest.
  • A rebuilt call carries its module's name as an implicit input instead of the module. A recipe differs per load and a ref per checkout. The name still separates two modules' root constructors.

artifact_collection.go now sorts sources by origin, then recipe, with Keys and Origins moved together, so a per-call Workspace can't reorder them.

The risk in this change is a wrong cache hit, so what follows measures that first. TestArtifactViewOriginHoldsNoPerSessionInputs covers the origin itself: equal across differing cachePerCall inputs and view wrappers, different across modules, fields and overlaid Workspaces. On one engine, two Go packages that differ only in one input file, one passing and one failing, selected through collection filters:

Selected Inputs Result
a and b a passes, b fails a passes, b fails
a alone same passes
b alone same fails
a and b swapped a fails, b passes
b alone b given a's input passes

The cost, on one package of 466 test files under a filter, on one engine, across committed README-only changes:

Before After
Checks evaluated 466, 297 s summed 0, all CACHED
Execs 0 0

A one-line edit to one source file still evaluates the collection's checks, since the collection's content changed, and runs 34 execs: the tests whose imports hold that file. Two README-only changes over that edit evaluate none.

Fixes #15044.

…all Workspace

A filtered check selection wraps each module object in __withArtifactView,
whose state carries Origins from artifactViewOrigin. That hash held inputs
that differ in every session: the host Workspace's cachePerCall input, the
module recipe of each rebuilt call, and the cache-per-call inputs of any
argument Append rebuilt. So the view argument changed per session, every
receiver below it got a new digest, and no check under a filter cached
across sessions, however little its inputs read.

An origin now normalizes only what varies per session and keeps what tells
two collections apart. On the source's own call chain, the ambient
Workspace, a currentWorkspace with no receiver, becomes its type name; an
explicit or overlaid Workspace keeps its identity. A call with nothing to
change keeps its ID, so a digest the engine set survives. A rebuilt call
replaces its module with the module's name, since a recipe differs per load
and a ref per checkout. Sources sort by origin, then recipe, so a per-call
Workspace cannot reorder them against their keys.

Signed-off-by: Yasyf Mohamedali <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A filtered check selection re-keys every module object per session, so its checks never cache across sessions

1 participant