Define canonical session workspace paths
This commit is contained in:
@@ -1,11 +1,40 @@
|
||||
package artifacts
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCanonicalSessionLayout(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
store := NewLocalStore(root)
|
||||
paths, err := store.EnsureLayoutFor("campaign", "session")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for name, got := range map[string]string{
|
||||
"inputs": paths.InputsDir, "audio": paths.AudioDir, "transcripts": paths.TranscriptsDir,
|
||||
"transcripts/raw": paths.TranscriptsRawDir, "artifacts": paths.ArtifactsDir,
|
||||
"inputs/previous": paths.PreviousDir, "inputs/references": paths.ReferencesDir,
|
||||
"logs": paths.LogsDir, "debug": paths.DebugDir, "runs": paths.RunsDir,
|
||||
"logs/polish": SessionLatestLogsPath(paths, "polish"),
|
||||
"debug/polish": SessionLatestDebugPath(paths, "polish"),
|
||||
"runs/run/polish/logs": SessionRunLogsDir(paths, "run", "polish"),
|
||||
"runs/run/polish/debug": SessionRunDebugDir(paths, "run", "polish"),
|
||||
} {
|
||||
if want := filepath.Join(paths.Root, filepath.FromSlash(name)); got != want {
|
||||
t.Errorf("%s = %q, want %q", name, got, want)
|
||||
}
|
||||
}
|
||||
for _, name := range []string{"transcripts/trimmed", "current", "runs/run", "logs/polish", "debug/polish"} {
|
||||
if _, err := os.Lstat(filepath.Join(paths.Root, filepath.FromSlash(name))); !os.IsNotExist(err) {
|
||||
t.Errorf("%s exists or inaccessible: %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionWorkDirForCampaign(t *testing.T) {
|
||||
root := "/tmp/workspace"
|
||||
got := SessionWorkDirForCampaign(root, "forsaken", "2026-04-19")
|
||||
@@ -74,7 +103,7 @@ func TestSessionNotariusReferenceSnapshotPath(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("SessionNotariusReferenceSnapshotPath() error = %v", err)
|
||||
}
|
||||
wantRoot := filepath.Join(paths.Root, "cache", "notarius", "references")
|
||||
wantRoot := filepath.Join(paths.Root, "inputs", "references")
|
||||
if root := SessionNotariusReferenceCacheDir(paths); root != wantRoot {
|
||||
t.Fatalf("SessionNotariusReferenceCacheDir() = %q, want %q", root, wantRoot)
|
||||
}
|
||||
@@ -107,25 +136,25 @@ func TestSessionNotariusReferenceSnapshotPathRejectsUnsafeIdentity(t *testing.T)
|
||||
func TestSessionPreviousPathsForCampaign(t *testing.T) {
|
||||
root := "/tmp/workspace"
|
||||
previousDir := SessionPreviousDirForCampaign(root, "forsaken", "2026-04-19")
|
||||
wantPreviousDir := filepath.Join(root, "work", "forsaken", "2026-04-19", "previous")
|
||||
wantPreviousDir := filepath.Join(root, "work", "forsaken", "2026-04-19", "inputs", "previous")
|
||||
if previousDir != wantPreviousDir {
|
||||
t.Fatalf("SessionPreviousDirForCampaign() = %q, want %q", previousDir, wantPreviousDir)
|
||||
}
|
||||
|
||||
manifestPath := SessionPreviousManifestPathForCampaign(root, "forsaken", "2026-04-19")
|
||||
wantManifestPath := filepath.Join(root, "work", "forsaken", "2026-04-19", "previous", "manifest.json")
|
||||
wantManifestPath := filepath.Join(root, "work", "forsaken", "2026-04-19", "inputs", "previous", "manifest.json")
|
||||
if manifestPath != wantManifestPath {
|
||||
t.Fatalf("SessionPreviousManifestPathForCampaign() = %q, want %q", manifestPath, wantManifestPath)
|
||||
}
|
||||
|
||||
artifactsDir := SessionPreviousArtifactsDirForCampaign(root, "forsaken", "2026-04-19")
|
||||
wantArtifactsDir := filepath.Join(root, "work", "forsaken", "2026-04-19", "previous", "artifacts")
|
||||
wantArtifactsDir := filepath.Join(root, "work", "forsaken", "2026-04-19", "inputs", "previous", "artifacts")
|
||||
if artifactsDir != wantArtifactsDir {
|
||||
t.Fatalf("SessionPreviousArtifactsDirForCampaign() = %q, want %q", artifactsDir, wantArtifactsDir)
|
||||
}
|
||||
|
||||
artifactPath := mustSessionPreviousArtifactPathForCampaign(t, root, "forsaken", "2026-04-19", "session_recap.md")
|
||||
wantArtifactPath := filepath.Join(root, "work", "forsaken", "2026-04-19", "previous", "artifacts", "session_recap.md")
|
||||
wantArtifactPath := filepath.Join(root, "work", "forsaken", "2026-04-19", "inputs", "previous", "artifacts", "session_recap.md")
|
||||
if artifactPath != wantArtifactPath {
|
||||
t.Fatalf("mustSessionPreviousArtifactPathForCampaign(t, ) = %q, want %q", artifactPath, wantArtifactPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user