GeezerVison is showing github.com — core: make WorkspaceGit persistable in the dagql disk cache by shykes · Pull Request #13700 · dagger/dagger
Conversation
shykes
commented
Jul 21, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Blocker for #13508
Context
The engine caches computed results so it doesn't redo expensive work. That cache lives in memory. On shutdown, the engine writes it to disk, so a restart can resume instead of rebuilding everything.
Writing to disk means each result has to be serializable — packed into bytes on the way out, rebuilt on the way back in. Types that support this implement dagql.PersistedObject: EncodePersistedObject ("pack me") and DecodePersistedObject ("unpack me").
Problem
WorkspaceGit, returned by Workspace.git(), never implemented PersistedObject. Every other type in the family does — Workspace, GitRef, Changeset, WorkspaceModule.
So any build whose cache touched Workspace.git() couldn't be saved. On shutdown the engine walks the cache, hits the un-packable WorkspaceGit, and aborts the whole save:
dagql cache close exiting with error:
encode persisted object payload: type "WorkspaceGit"
does not implement persisted object encoding
Nothing persists. After a restart, the engine rebuilds from scratch.
Solution
Teach WorkspaceGit to pack itself.
It's trivial, because a WorkspaceGit is just a pointer to its Workspace:
type WorkspaceGit struct {
Workspace dagql.ObjectResult[*Workspace]
}
And Workspace already persists. So packing is "write down a reference to that Workspace," and unpacking is "load it back and wrap it" — the pattern the other types already follow.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
WorkspaceGit (returned by Workspace.git()) was the only type in the
workspace/git family that did not implement dagql.PersistedObject.
Workspace, GitRef, Changeset, WorkspaceModule, etc. all do. As a result,
any build whose dagql cache closure touched Workspace.git() failed to
persist its cache to disk on engine shutdown:
dagql cache close exiting with error:
encode persisted object payload: type "WorkspaceGit"
does not implement persisted object encoding
...which aborted the whole cache-close, so nothing persisted and the
build could not be reused across an engine restart.
WorkspaceGit's entire state is a reference to its Workspace, which is
already persistable, so encode/decode reduce to persisting that one ref,
mirroring Workspace.EncodePersistedObject and the other core encoders.
Signed-off-by: Solomon Hykes <[email protected]>
shykes
added a commit
that referenced
this pull request
Jul 21, 2026
The previous approach stored the auto-injected Workspace as a field on
EngineDev (and Builder), and passed it down to the go/cli-dev toolchains.
Because a module object's cache key is its field values, holding a
session-scoped Workspace tainted the cache key of *every* EngineDev
method — so their build results could not be reused across a session or
an engine restart.
Resolve the Workspace to scalar commit/dirty values once, at the point
where it is auto-injected, and thread only those strings through the
toolchains. No module stores or receives a Workspace object for stamping
anymore, so builds stay content-addressed. go/cli-dev gain optional
vcsCommit/vcsDirty args (which take precedence over ws); dev/docs-dev/
release are unchanged and keep passing the Workspace, which is now
resolved to scalars internally.
Regenerated the affected dagger runtime bindings.
Note: cross-restart cache persistence for git-touching builds also
requires WorkspaceGit to be persistable in the dagql disk cache, fixed
separately in #13700.
Signed-off-by: Solomon Hykes <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
shykes
added a commit
that referenced
this pull request
Jul 21, 2026
The previous approach stored the auto-injected Workspace as a field on
EngineDev (and Builder), and passed it down to the go/cli-dev toolchains.
Because a module object's cache key is its field values, holding a
session-scoped Workspace tainted the cache key of *every* EngineDev
method — so their build results could not be reused across a session or
an engine restart.
Resolve the Workspace to scalar commit/dirty values once, at the point
where it is auto-injected, and thread only those strings through the
toolchains. No module stores or receives a Workspace object for stamping
anymore, so builds stay content-addressed. go/cli-dev gain optional
vcsCommit/vcsDirty args (which take precedence over ws); dev/docs-dev/
release are unchanged and keep passing the Workspace, which is now
resolved to scalars internally.
Regenerated the affected dagger runtime bindings.
Note: cross-restart cache persistence for git-touching builds also
requires WorkspaceGit to be persistable in the dagql disk cache, fixed
separately in #13700.
Signed-off-by: Solomon Hykes <[email protected]>
shykes
added a commit
that referenced
this pull request
Jul 21, 2026
The previous approach stored the auto-injected Workspace as a field on
EngineDev (and Builder), and passed it down to the go/cli-dev toolchains.
Because a module object's cache key is its field values, holding a
session-scoped Workspace tainted the cache key of *every* EngineDev
method — so their build results could not be reused across a session or
an engine restart.
Resolve the Workspace to scalar commit/dirty values once, at the point
where it is auto-injected, and thread only those strings through the
toolchains. No module stores or receives a Workspace object for stamping
anymore, so builds stay content-addressed. go/cli-dev gain optional
vcsCommit/vcsDirty args (which take precedence over ws); dev/docs-dev/
release are unchanged and keep passing the Workspace, which is now
resolved to scalars internally.
Regenerated the affected dagger runtime bindings.
Note: cross-restart cache persistence for git-touching builds also
requires WorkspaceGit to be persistable in the dagql disk cache, fixed
separately in #13700.
Signed-off-by: Solomon Hykes <[email protected]>
marcosnils
pushed a commit
that referenced
this pull request
Jul 22, 2026
The previous approach stored the auto-injected Workspace as a field on
EngineDev (and Builder), and passed it down to the go/cli-dev toolchains.
Because a module object's cache key is its field values, holding a
session-scoped Workspace tainted the cache key of *every* EngineDev
method — so their build results could not be reused across a session or
an engine restart.
Resolve the Workspace to scalar commit/dirty values once, at the point
where it is auto-injected, and thread only those strings through the
toolchains. No module stores or receives a Workspace object for stamping
anymore, so builds stay content-addressed. go/cli-dev gain optional
vcsCommit/vcsDirty args (which take precedence over ws); dev/docs-dev/
release are unchanged and keep passing the Workspace, which is now
resolved to scalars internally.
Regenerated the affected dagger runtime bindings.
Note: cross-restart cache persistence for git-touching builds also
requires WorkspaceGit to be persistable in the dagql disk cache, fixed
separately in #13700.
Signed-off-by: Solomon Hykes <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|