Skip to content

core: make WorkspaceGit persistable in the dagql disk cache - #13700

Merged
shykes merged 1 commit into
mainfrom
fix-workspace-git-cache-persistence
Jul 21, 2026
Merged

shykes merged 1 commit into
mainfrom
fix-workspace-git-cache-persistence

Conversation

@shykes

@shykes shykes commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

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.

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]>
@shykes
shykes requested review from TomChv, Copilot, grouville, sipsma, tiborvass and vito and removed request for Copilot July 21, 2026 11:03
@shykes
shykes merged commit fcf46b7 into main Jul 21, 2026
88 checks passed
@shykes
shykes deleted the fix-workspace-git-cache-persistence branch July 21, 2026 12:54
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]>
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