Add family artifact selection and provenance
This commit is contained in:
@@ -53,6 +53,8 @@ type AnalyzeArtifactRecord struct {
|
||||
Status AnalyzeArtifactStatus `json:"status"`
|
||||
FingerprintVersion int `json:"fingerprint_version,omitempty"`
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
Family string `json:"family,omitempty"`
|
||||
CharacterID string `json:"character_id,omitempty"`
|
||||
Dependencies []string `json:"dependencies,omitempty"`
|
||||
Output *ArtifactRecord `json:"output,omitempty"`
|
||||
OutputSize int64 `json:"output_size,omitempty"`
|
||||
@@ -134,6 +136,14 @@ func validateAnalyzeArtifactRecord(mapKey string, record AnalyzeArtifactRecord)
|
||||
if err := validateAnalyzeDependencies(record.Dependencies); err != nil {
|
||||
return err
|
||||
}
|
||||
if (record.Family == "") != (record.CharacterID == "") {
|
||||
return fmt.Errorf("family and character_id must be present together")
|
||||
}
|
||||
if record.Family != "" {
|
||||
if !artifactpolicy.IsConfiguredKey(record.Family) || !artifactpolicy.IsConfiguredKey(record.CharacterID) {
|
||||
return fmt.Errorf("family and character_id must match ^[a-z][a-z0-9_]*$")
|
||||
}
|
||||
}
|
||||
if err := validateAnalyzeFingerprint(record.FingerprintVersion, record.Fingerprint, record.Status == AnalyzeArtifactCurrent); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ func TestAnalyzeArtifactStateRoundTripsEveryStatusDeterministically(t *testing.T
|
||||
records["session_recap"] = func() AnalyzeArtifactRecord {
|
||||
record := records["session_recap"]
|
||||
record.Dependencies = []string{"quest_log", "gm_notes"}
|
||||
record.Family = "character_meta"
|
||||
record.CharacterID = "arannis"
|
||||
return record
|
||||
}()
|
||||
|
||||
@@ -74,6 +76,9 @@ func TestAnalyzeArtifactStateRoundTripsEveryStatusDeterministically(t *testing.T
|
||||
if got := analyze.AnalyzeArtifacts["session_recap"].Dependencies; !reflect.DeepEqual(got, []string{"gm_notes", "quest_log"}) {
|
||||
t.Fatalf("canonical dependencies = %#v", got)
|
||||
}
|
||||
if got := analyze.AnalyzeArtifacts["session_recap"]; got.Family != "character_meta" || got.CharacterID != "arannis" {
|
||||
t.Fatalf("family provenance = %#v", got)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user