Commit 377fb0b

Eric Bower  ·  2026-05-08 15:29:38 -0400 EDT
parent 9772fc9
chore: sessions dir
2 files changed,  +22, -30
+19, -27
......@@ -1061,7 +1061,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10611061 log.Error("fetch history html", "session", s.Name, "err", err)
10621062 continue
10631063 }
1064- if err := stageArtifact(cfg.ArtifactDir, name, jobID, s.Short, html, ".html"); err != nil {
1064+ if err := stageArtifact(cfg.ArtifactDir, name, jobID, filepath.Join("sessions", s.Short), html, ".html"); err != nil {
10651065 log.Error("stage html artifact", "session", s.Short, "err", err)
10661066 }
10671067
......@@ -1070,7 +1070,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10701070 log.Error("fetch history plain", "session", s.Name, "err", err)
10711071 continue
10721072 }
1073- if err := stageArtifact(cfg.ArtifactDir, name, jobID, s.Short, plain, ".txt"); err != nil {
1073+ if err := stageArtifact(cfg.ArtifactDir, name, jobID, filepath.Join("sessions", s.Short), plain, ".txt"); err != nil {
10741074 log.Error("stage txt artifact", "session", s.Short, "err", err)
10751075 }
10761076 }
......@@ -1795,7 +1795,7 @@ func formatTimestamp(ts string) string {
17951795
17961796 // generateJobIndex produces HTML and plain-text index pages listing all
17971797 // sessions for a job with links and metadata (status, exit code, ended at).
1798-// It also includes any other artifacts in the job directory (e.g., event.json, workspace.tar).
1798+// It also includes any other artifacts in the job directory (e.g., event.json, attestation.json, workspace.tar).
17991799 func generateJobIndex(artifactDir, name, jobID string, sessions []SessionInfo) (htmlContent, txtContent string) {
18001800 rows := make([]sessionRow, 0, len(sessions))
18011801 for _, s := range sessions {
......@@ -1819,35 +1819,27 @@ func generateJobIndex(artifactDir, name, jobID string, sessions []SessionInfo) (
18191819 rows = append(rows, row)
18201820 }
18211821
1822- // Gather other artifacts in the job directory
1822+ // Gather artifacts by scanning the job directory (excluding sessions/)
18231823 var artifacts []artifactRow
18241824 jobDir := filepath.Join(artifactDir, name, jobID)
18251825
1826- // Always add workspace.tar (it's uploaded before pici runs)
1827- artifacts = append(artifacts, artifactRow{Name: "workspace.tar", Size: "—", ModTime: "—"})
1828-
1829- // Add event.json if it exists
1830- eventJSON := filepath.Join(jobDir, "event.json")
1831- if info, err := os.Stat(eventJSON); err == nil {
1832- artifacts = append(artifacts, artifactRow{
1833- Name: "event.json",
1834- Size: formatFileSize(info.Size()),
1835- ModTime: formatTimestamp(fmt.Sprintf("%d", info.ModTime().Unix())),
1836- })
1837- }
1838-
1839- // Add published.json if it exists
1840- publishedJSON := filepath.Join(jobDir, "published.json")
1841- if info, err := os.Stat(publishedJSON); err == nil {
1842- artifacts = append(artifacts, artifactRow{
1843- Name: "published.json",
1844- Size: formatFileSize(info.Size()),
1845- ModTime: formatTimestamp(fmt.Sprintf("%d", info.ModTime().Unix())),
1846- })
1826+ if entries, err := os.ReadDir(jobDir); err == nil {
1827+ for _, entry := range entries {
1828+ if entry.IsDir() {
1829+ continue // skip subdirectories (e.g. sessions/)
1830+ }
1831+ info, err := entry.Info()
1832+ if err != nil {
1833+ continue
1834+ }
1835+ artifacts = append(artifacts, artifactRow{
1836+ Name: entry.Name(),
1837+ Size: formatFileSize(info.Size()),
1838+ ModTime: formatTimestamp(fmt.Sprintf("%d", info.ModTime().Unix())),
1839+ })
1840+ }
18471841 }
18481842
1849- // Skip zmx task artifacts (runner.html, runner.txt, etc.) — already in tasks table
1850-
18511843 // Resolve overall job status
18521844 jobStatus := "success"
18531845 hasRunning := false
+3, -3
......@@ -126,8 +126,8 @@ zmx run step2 echo "hello from step2"
126126
127127 // Track per-session artifacts
128128 for _, s := range p.Sessions {
129- htmlPath := filepath.Join(artifactDir, p.Name, p.JobID, s.Short+".html")
130- txtPath := filepath.Join(artifactDir, p.Name, p.JobID, s.Short+".txt")
129+ htmlPath := filepath.Join(artifactDir, p.Name, p.JobID, "sessions", s.Short+".html")
130+ txtPath := filepath.Join(artifactDir, p.Name, p.JobID, "sessions", s.Short+".txt")
131131 if _, err := os.Stat(htmlPath); err == nil {
132132 sessionArtifactShorts[s.Short+"_html"] = true
133133 }
......@@ -215,7 +215,7 @@ zmx run step2 echo "hello from step2"
215215
216216 // 8. Assert HTML artifacts were staged for each session
217217 for _, s := range finalPayload.Sessions {
218- artifactPath := filepath.Join(cfg.ArtifactDir, finalPayload.Name, finalPayload.JobID, s.Short+".html")
218+ artifactPath := filepath.Join(cfg.ArtifactDir, finalPayload.Name, finalPayload.JobID, "sessions", s.Short+".html")
219219 data, err := os.ReadFile(artifactPath)
220220 if err != nil {
221221 t.Errorf("read artifact %s: %v", artifactPath, err)