Unify analysis product path identity
This commit is contained in:
@@ -209,7 +209,7 @@ func currentAnalyzeArtifactRecord(
|
||||
return manifest.AnalyzeArtifactRecord{}, fmt.Errorf("execution result is required")
|
||||
}
|
||||
producerRunID := analyzeProducerRunID(execution)
|
||||
relativePath, err := normalizedAnalyzeOutputIdentity(plan.Cfg.OutputPath)
|
||||
relativePath, err := normalizedAnalyzeOutputIdentity(execution.Paths, plan.Cfg.OutputPath)
|
||||
if err != nil {
|
||||
return manifest.AnalyzeArtifactRecord{}, err
|
||||
}
|
||||
|
||||
45
internal/stage/analyze_absolute_path_test.go
Normal file
45
internal/stage/analyze_absolute_path_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package stage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
)
|
||||
|
||||
func TestAnalyzeAbsolutePathSharesPortableIdentity(t *testing.T) {
|
||||
env, m, _ := currentAnalyzeFixture(t, true)
|
||||
paths := sessionPathsForEnv(env, m.SessionID)
|
||||
item := env.Config.ArtifactCatalog.Artifacts["session_recap"]
|
||||
item.OutputPath = filepath.Join(paths.ArtifactsDir, "session_recap.md")
|
||||
env.Config.ArtifactCatalog.Artifacts["session_recap"] = item
|
||||
validation, err := (analyzeStage{}).ValidateResume(context.Background(), env, m)
|
||||
if err != nil || !validation.Resumable {
|
||||
t.Fatalf("equivalent path not reusable: %#v, %v", validation, err)
|
||||
}
|
||||
env.Force = true
|
||||
if _, err := (analyzeStage{}).Run(context.Background(), env, m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := m.Stages["analyze"].AnalyzeArtifacts["session_recap"].Output.LocalPath; got != "artifacts/session_recap.md" {
|
||||
t.Fatalf("checkpoint is not portable: %q", got)
|
||||
}
|
||||
catalog, err := buildPublishRuntimeArtifactCatalog(paths, m, env.Config.ConcreteArtifacts(), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source := artifacts.ConfiguredArtifactSourceID("session_recap")
|
||||
resolved, err := artifacts.ResolveSessionArtifactWithCatalog(paths, m, source, catalog)
|
||||
if err != nil || resolved.Path != item.OutputPath {
|
||||
t.Fatalf("current product unavailable: %#v, %v", resolved, err)
|
||||
}
|
||||
actions, err := PlanPublicationOutputs(catalog, []config.PublishOutputRule{{Source: source}}, nil)
|
||||
if err != nil || len(actions) != 1 || actions[0].Destination != "artifacts/session_recap.md" {
|
||||
t.Fatalf("publication mapping: %#v, %v", actions, err)
|
||||
}
|
||||
if env.Config.ConcreteArtifacts()["session_recap"].OutputPath != item.OutputPath {
|
||||
t.Fatal("configuration was mutated")
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ func validateAndMaterializeAnalyzeArtifact(
|
||||
contract := &artifactmodel.ContractMetadata{
|
||||
MediaType: "text/markdown", SchemaID: "narratio." + prepared.name, SchemaVersion: "1",
|
||||
}
|
||||
relativeOutputPath, err := normalizedAnalyzeOutputIdentity(plan.Cfg.OutputPath)
|
||||
relativeOutputPath, err := normalizedAnalyzeOutputIdentity(execution.Paths, plan.Cfg.OutputPath)
|
||||
if err != nil {
|
||||
return analyzeArtifactMaterialization{}, fmt.Errorf("analyze: normalize output identity for artifact %q: %w", prepared.name, err)
|
||||
}
|
||||
|
||||
@@ -5,14 +5,12 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/pathsafe"
|
||||
)
|
||||
|
||||
type analyzeFingerprintCandidate struct {
|
||||
@@ -156,7 +154,7 @@ func computeAnalyzeArtifactFingerprint(
|
||||
if err != nil {
|
||||
return "", inputs, dependencyOutputs, err
|
||||
}
|
||||
outputIdentity, err := normalizedAnalyzeOutputIdentity(artifactCfg.OutputPath)
|
||||
outputIdentity, err := normalizedAnalyzeOutputIdentity(execution.Paths, artifactCfg.OutputPath)
|
||||
if err != nil {
|
||||
return "", inputs, dependencyOutputs, err
|
||||
}
|
||||
@@ -248,12 +246,12 @@ func normalizedAnalyzeDependencyKeys(values []string) []string {
|
||||
return result
|
||||
}
|
||||
|
||||
func normalizedAnalyzeOutputIdentity(value string) (string, error) {
|
||||
func normalizedAnalyzeOutputIdentity(paths artifacts.SessionPaths, value string) (string, error) {
|
||||
trimmed := strings.TrimSpace(value)
|
||||
if trimmed == "" {
|
||||
return "", nil
|
||||
}
|
||||
normalized, err := pathsafe.NormalizeRelativeDestination(filepath.ToSlash(trimmed))
|
||||
normalized, err := artifacts.ProductRelativePath(paths.Root, trimmed)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("normalize configured output identity %q: %w", value, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user