Commit 97d87a6

Eric Bower  ·  2026-05-08 15:43:31 -0400 EDT
parent 377fb0b
chore: restructure
3 files changed,  +19, -18
+15, -14
......@@ -599,10 +599,11 @@ func eventHandler(cfg *Cfg, eventData *Event) error {
599599
600600 // Store the event in the artifact directory so the monitor can access it
601601 eventDir := filepath.Join(cfg.ArtifactDir, eventData.Name, jobID)
602- if err := os.MkdirAll(eventDir, 0755); err != nil {
603- log.Error("create event dir", "err", err)
602+ artifactsDir := filepath.Join(eventDir, "artifacts")
603+ if err := os.MkdirAll(artifactsDir, 0755); err != nil {
604+ log.Error("create artifacts dir", "err", err)
604605 } else {
605- if err := os.WriteFile(filepath.Join(eventDir, "event.json"), eventBytes, 0644); err != nil {
606+ if err := os.WriteFile(filepath.Join(artifactsDir, "event.json"), eventBytes, 0644); err != nil {
606607 log.Error("write event", "err", err)
607608 }
608609 }
......@@ -623,7 +624,7 @@ func eventHandler(cfg *Cfg, eventData *Event) error {
623624 "workspace_checksum": eng.Wk.Checksum(),
624625 }
625626 attestationBytes, _ := json.Marshal(attestation)
626- if err := os.WriteFile(filepath.Join(eventDir, "attestation.json"), attestationBytes, 0644); err != nil {
627+ if err := os.WriteFile(filepath.Join(artifactsDir, "attestation.json"), attestationBytes, 0644); err != nil {
627628 log.Error("write attestation", "err", err)
628629 }
629630
......@@ -1061,7 +1062,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10611062 log.Error("fetch history html", "session", s.Name, "err", err)
10621063 continue
10631064 }
1064- if err := stageArtifact(cfg.ArtifactDir, name, jobID, filepath.Join("sessions", s.Short), html, ".html"); err != nil {
1065+ if err := stageArtifact(cfg.ArtifactDir, name, jobID, s.Short, html, ".html"); err != nil {
10651066 log.Error("stage html artifact", "session", s.Short, "err", err)
10661067 }
10671068
......@@ -1070,7 +1071,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10701071 log.Error("fetch history plain", "session", s.Name, "err", err)
10711072 continue
10721073 }
1073- if err := stageArtifact(cfg.ArtifactDir, name, jobID, filepath.Join("sessions", s.Short), plain, ".txt"); err != nil {
1074+ if err := stageArtifact(cfg.ArtifactDir, name, jobID, s.Short, plain, ".txt"); err != nil {
10741075 log.Error("stage txt artifact", "session", s.Short, "err", err)
10751076 }
10761077 }
......@@ -1098,7 +1099,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
10981099
10991100 if allCompleted(group) {
11001101 // Check sentinel — publish terminal status exactly once
1101- sentinel := filepath.Join(cfg.ArtifactDir, name, jobID, "published.json")
1102+ sentinel := filepath.Join(cfg.ArtifactDir, name, jobID, "artifacts", "published.json")
11021103 log.Debug("checking completion", "all_completed", true, "sentinel", sentinel)
11031104 if _, err := os.Stat(sentinel); err == nil {
11041105 log.Debug("terminal status already published, skipping", "sentinel", sentinel)
......@@ -1190,7 +1191,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
11901191 // loadEvent reads the event.json for a job from the artifact directory.
11911192 func loadEvent(dir, name, jobID string) (Event, error) {
11921193 var event Event
1193- data, err := os.ReadFile(filepath.Join(dir, name, jobID, "event.json"))
1194+ data, err := os.ReadFile(filepath.Join(dir, name, jobID, "artifacts", "event.json"))
11941195 if err != nil {
11951196 return event, err
11961197 }
......@@ -1479,7 +1480,7 @@ func stageArtifact(dir, name, jobID, short, content, ext string) error {
14791480 // syncJobArtifacts syncs artifacts for a single job.
14801481 func syncJobArtifacts(cfg *Cfg, repoName, jobID string, log *slog.Logger) error {
14811482 jobDir := filepath.Join(cfg.ArtifactDir, repoName, jobID)
1482- eventPath := filepath.Join(jobDir, "event.json")
1483+ eventPath := filepath.Join(jobDir, "artifacts", "event.json")
14831484 data, err := os.ReadFile(eventPath)
14841485 if err != nil {
14851486 return fmt.Errorf("read event: %w", err)
......@@ -1536,7 +1537,7 @@ func syncArtifacts(cfg *Cfg, log *slog.Logger) error {
15361537 continue
15371538 }
15381539 jobDir := filepath.Join(cfg.ArtifactDir, entry.Name(), repoEntry.Name())
1539- publishedPath := filepath.Join(jobDir, "published.json")
1540+ publishedPath := filepath.Join(jobDir, "artifacts", "published.json")
15401541
15411542 // Skip if job is complete (published.json exists)
15421543 // In-progress jobs are synced every tick; completed jobs are skipped.
......@@ -1819,14 +1820,14 @@ func generateJobIndex(artifactDir, name, jobID string, sessions []SessionInfo) (
18191820 rows = append(rows, row)
18201821 }
18211822
1822- // Gather artifacts by scanning the job directory (excluding sessions/)
1823+ // Gather artifacts by scanning the artifacts/ subfolder
18231824 var artifacts []artifactRow
1824- jobDir := filepath.Join(artifactDir, name, jobID)
1825+ artifactsDir := filepath.Join(artifactDir, name, jobID, "artifacts")
18251826
1826- if entries, err := os.ReadDir(jobDir); err == nil {
1827+ if entries, err := os.ReadDir(artifactsDir); err == nil {
18271828 for _, entry := range entries {
18281829 if entry.IsDir() {
1829- continue // skip subdirectories (e.g. sessions/)
1830+ continue
18301831 }
18311832 info, err := entry.Info()
18321833 if err != nil {
+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, "sessions", s.Short+".html")
130- txtPath := filepath.Join(artifactDir, p.Name, p.JobID, "sessions", s.Short+".txt")
129+ htmlPath := filepath.Join(artifactDir, p.Name, p.JobID, s.Short+".html")
130+ txtPath := filepath.Join(artifactDir, p.Name, p.JobID, 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, "sessions", s.Short+".html")
218+ artifactPath := filepath.Join(cfg.ArtifactDir, finalPayload.Name, finalPayload.JobID, s.Short+".html")
219219 data, err := os.ReadFile(artifactPath)
220220 if err != nil {
221221 t.Errorf("read artifact %s: %v", artifactPath, err)
+1, -1
......@@ -37,7 +37,7 @@
3737 <tbody>
3838 {{range .Artifacts}}
3939 <tr>
40- <td><a href="{{.Name}}">{{.Name}}</a></td>
40+ <td><a href="artifacts/{{.Name}}">{{.Name}}</a></td>
4141 <td>{{.Size}}</td>
4242 <td>{{.ModTime}}</td>
4343 </tr>