Write workspace checkpoints during runs

This commit is contained in:
2026-07-08 02:46:38 +00:00
parent f044c00a7c
commit 1d3a444df8
11 changed files with 1258 additions and 9 deletions

View File

@@ -2180,6 +2180,41 @@ func TestRunPipelineWritesWorkspaceDiagnosticsArtifactsOnSuccess(t *testing.T) {
assertPathNotExist(t, filepath.Join(workspaceDir, "debug"))
}
func TestRunPipelineWritesCheckpointsWhenWorkspaceResumeEnabled(t *testing.T) {
workspaceDir := filepath.Join(t.TempDir(), "workspace")
outputDir := t.TempDir()
configPath := writeTestConfig(t, mvpConfigYAMLWithWorkspaceResumeEnabled("dnd-session", workspaceDir, "always"))
inputPath := writeSeriatimInput(t)
var stdout bytes.Buffer
var stderr bytes.Buffer
code := RunWithOptions([]string{"run", "dnd-session", "--config", configPath, "--input", inputPath, "--output-dir", outputDir}, &stdout, &stderr, Options{
LLMClientFactory: fakeLLMFactory(newFakeRunLLMClient(false), nil),
})
if code != 0 {
t.Fatalf("RunWithOptions() code = %d, stderr=%q", code, stderr.String())
}
checkpointDir := onlyCheckpointIdentityDir(t, workspaceDir)
for _, name := range []string{
"source/manifest.json",
"source/source-document.json",
"chunk/manifest.json",
"chunk/chunks.json",
"extract/spells/manifest.json",
"extract/spells/outputs.json",
"merge/spells/manifest.json",
"merge/spells/output.json",
"normalize/spells/manifest.json",
"normalize/spells/output.json",
} {
if _, err := os.Stat(filepath.Join(checkpointDir, name)); err != nil {
t.Fatalf("expected checkpoint artifact %q: %v", name, err)
}
}
assertPathNotExist(t, filepath.Join(workspaceDir, "debug"))
}
func TestRunPipelineSkipsDiagnosticsWhenWorkspaceDiagnosticsDisabled(t *testing.T) {
workspaceDir := filepath.Join(t.TempDir(), "workspace")
outputDir := t.TempDir()
@@ -2335,7 +2370,9 @@ func TestRunPipelineDiagnosticsDirFlagOverridesWorkspaceDiagnosticsOnly(t *testi
t.Fatalf("override diagnostics dir entries = %v, want one run dir", entries)
}
assertPathNotExist(t, filepath.Join(workspaceDir, "diagnostics"))
assertPathNotExist(t, filepath.Join(workspaceDir, "checkpoints"))
if entries := childDirs(t, filepath.Join(workspaceDir, "checkpoints")); len(entries) != 1 {
t.Fatalf("workspace checkpoint pipeline dirs = %v, want one", entries)
}
assertPathNotExist(t, filepath.Join(workspaceDir, "debug"))
}
@@ -2868,6 +2905,24 @@ pipelines:
`
}
func mvpConfigYAMLWithWorkspaceResumeEnabled(pipelineID, workspaceDir, retention string) string {
return `version: 2
workspace:
directory: ` + workspaceDir + `
diagnostics:
enabled: true
retention: ` + retention + `
resume:
enabled: true
pipelines:
` + pipelineID + `:
input: seriatim
artifacts:
spells:
extract: dnd/spells
`
}
func mvpConfigYAMLWithWorkspaceDiagnosticsDisabled(pipelineID, workspaceDir string) string {
return `version: 2
workspace:
@@ -3231,6 +3286,13 @@ func onlyChildDir(t *testing.T, root string) string {
return children[0]
}
func onlyCheckpointIdentityDir(t *testing.T, workspaceDir string) string {
t.Helper()
pipelineDir := onlyChildDir(t, filepath.Join(workspaceDir, "checkpoints"))
inputDir := onlyChildDir(t, pipelineDir)
return onlyChildDir(t, inputDir)
}
func childDirs(t *testing.T, root string) []string {
t.Helper()
entries, err := os.ReadDir(root)