57f5219628
Each recorded artifact now carries a server group (deliverable or debug). public/ files are deliverables; input/memory/history/output.md, session exports and private/ scratch are debugging files. The app's Artifacts tab lists deliverables and the Debug toggle reveals a separate Debugging files group (older servers fall back to the filename rule); the TUI lists deliverables first and marks debug rows; artifact search excludes debug files unless include_debug / --debug-files is set.
63 lines
2.2 KiB
Go
63 lines
2.2 KiB
Go
package protocol
|
|
|
|
import "strings"
|
|
|
|
// Artifact presentation groups. A deliverable is a file the stage published to
|
|
// the run's public/ directory (or, for a visit recorded before the turn layout,
|
|
// any file it left). A debug file is one of the runner's own turn files or the
|
|
// visit's private/ scratch: evidence for debugging a stage, not its output.
|
|
const (
|
|
ArtifactGroupDeliverable = "deliverable"
|
|
ArtifactGroupDebug = "debug"
|
|
)
|
|
|
|
// TurnArtifactNames are the files the server itself writes into a model visit's
|
|
// turn directory. They are always debugging files.
|
|
var TurnArtifactNames = []string{"input.md", "memory.md", "history.md", "output.md", "session.html"}
|
|
|
|
// IsDebug reports whether the artifact is a runner-internal debugging file.
|
|
func (a StageArtifact) IsDebug() bool { return a.Group == ArtifactGroupDebug }
|
|
|
|
func isTurnArtifactName(name string) bool {
|
|
for _, turn := range TurnArtifactNames {
|
|
if name == turn {
|
|
return true
|
|
}
|
|
}
|
|
return name == LegacySessionMarkdownArtifact || strings.HasPrefix(name, "session-repair-")
|
|
}
|
|
|
|
// ClassifyArtifacts returns one visit's artifacts with Group set. public/ files
|
|
// are deliverables. Turn files, session exports and their repairs, and private/
|
|
// scratch are debug files; so is every other unprefixed file of a turn-layout
|
|
// visit (one that recorded any turn file), because a stage publishes only
|
|
// through public/. A visit recorded before the turn layout keeps its other
|
|
// files as deliverables. The rule uses only the recorded names, so runs stored
|
|
// before the field existed classify identically on read. It never mutates the
|
|
// input. Pure, O(artifacts).
|
|
func ClassifyArtifacts(files []StageArtifact) []StageArtifact {
|
|
if len(files) == 0 {
|
|
return files
|
|
}
|
|
turnVisit := false
|
|
for _, file := range files {
|
|
if isTurnArtifactName(file.Name) {
|
|
turnVisit = true
|
|
break
|
|
}
|
|
}
|
|
classified := make([]StageArtifact, len(files))
|
|
for i, file := range files {
|
|
switch {
|
|
case strings.HasPrefix(file.Name, "public/"):
|
|
file.Group = ArtifactGroupDeliverable
|
|
case turnVisit, isTurnArtifactName(file.Name), strings.HasPrefix(file.Name, "private/"):
|
|
file.Group = ArtifactGroupDebug
|
|
default:
|
|
file.Group = ArtifactGroupDeliverable
|
|
}
|
|
classified[i] = file
|
|
}
|
|
return classified
|
|
}
|