Share artifact dependency queries across consumers

This commit is contained in:
2026-12-02 21:20:01 +00:00
parent 0965b7c7ac
commit 19b720742e
27 changed files with 194 additions and 205 deletions

View File

@@ -61,8 +61,10 @@ exact named configured definitions become the effective set for that invocation,
regardless of their `enabled` value. The effective-set resolver itself does not regardless of their `enabled` value. The effective-set resolver itself does not
expand dependencies. Shared domain catalog derivation has materialized the sorted expand dependencies. Shared domain catalog derivation has materialized the sorted
union of explicit ordering edges and configured-artifact input edges. The union of explicit ordering edges and configured-artifact input edges. The
shared artifact closure orders targets and their prerequisites on that one concrete derived catalog holds an immutable `internal/artifactdeps` graph shared by
graph; the analyze work planner uses that order for its decisions. validation, prerequisite ordering, and analysis planning. Supplied products can
stop prerequisite traversal; explicit forced targets still include their
prerequisites.
Availability is separate from executability. Invocation selection normalizes a Availability is separate from executability. Invocation selection normalizes a
family selection into its concrete generated members before this resolver runs. family selection into its concrete generated members before this resolver runs.
The effective set retains optional family The effective set retains optional family

View File

@@ -53,6 +53,7 @@ enabled capabilities while holding the same lock.
| Manifests | `internal/manifest` | Durable session progress, stage transitions, validation, and atomic persistence. | | Manifests | `internal/manifest` | Durable session progress, stage transitions, validation, and atomic persistence. |
| Artifacts and paths | `internal/artifacts`, `internal/pathsafe` | Artifact identities and resolution, local and remote path/key models, current-state discovery, and confined relative destinations. | | Artifacts and paths | `internal/artifacts`, `internal/pathsafe` | Artifact identities and resolution, local and remote path/key models, current-state discovery, and confined relative destinations. |
| Previous-session cache | `internal/previouscache` | Deterministic planning and materialization requirements for configured previous-session inputs. | | Previous-session cache | `internal/previouscache` | Deterministic planning and materialization requirements for configured previous-session inputs. |
| Artifact dependencies | `internal/artifactdeps` | Immutable configured-artifact dependency ordering, closure, and dependent traversal. |
| Artifact policy | `internal/artifactpolicy` | Source and destination policy, configured artifact identity validation, and publish destination safety. | | Artifact policy | `internal/artifactpolicy` | Source and destination policy, configured artifact identity validation, and publish destination safety. |
| Shared models and file operations | `internal/artifactmodel`, `internal/contracts`, [`internal/fileops`](fileops.md) | Transcript and artifact data contracts plus atomic single-file replacement, bounded reads, workspace modes, and root-scoped cleanup helpers. | | Shared models and file operations | `internal/artifactmodel`, `internal/contracts`, [`internal/fileops`](fileops.md) | Transcript and artifact data contracts plus atomic single-file replacement, bounded reads, workspace modes, and root-scoped cleanup helpers. |
| Logging | `internal/logging` | Small Narratio-owned diagnostic/progress interface adapted to the invocation reporter. | | Logging | `internal/logging` | Small Narratio-owned diagnostic/progress interface adapted to the invocation reporter. |

View File

@@ -41,10 +41,10 @@ their scope. Unless assigned otherwise, a finding remains independent audit
remediation. Shared code does not make a refactoring a prerequisite or assign remediation. Shared code does not make a refactoring a prerequisite or assign
the whole finding to a roadmap. the whole finding to a roadmap.
Twenty-seven entries are closed by the safety, transfer, audio discovery, S3 Twenty-eight entries are closed by the safety, transfer, audio discovery, S3
planning, prerequisite-history, publication-import, CLI classification, planning, prerequisite-history, publication-import, CLI classification,
inspection aggregation, test maintenance, dead-code removal, and associated inspection aggregation, test maintenance, dead-code removal, and associated
documentation work; 16 remain open. **Planned** identifies documentation work; 15 remain open. **Planned** identifies
an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
that a related feature implements the entire finding. Findings close only after their that a related feature implements the entire finding. Findings close only after their
@@ -523,7 +523,12 @@ Related: [CAT-25](#cat-25--p3-separate-inspectionreadiness-collection-assessment
### CAT-17 — P3: Centralize configured-artifact dependency queries ### CAT-17 — P3: Centralize configured-artifact dependency queries
Status: Open Status: Closed
**Closure.** The derived catalog owns the shared artifact dependency graph;
configuration validation, prerequisite selection, ordering and analysis
planning use its mechanics. Focused configuration, artifact, stage and app
tests verify selection, origins, supplied boundaries and history.
**Disposition / owner.** Independent dependency-refactoring owner — [restore coverage](../../internal/command-restore.md#installation-and-local-baseline) **Disposition / owner.** Independent dependency-refactoring owner — [restore coverage](../../internal/command-restore.md#installation-and-local-baseline)
uses a fixed stage/output coverage mapping, not this configured-artifact graph. uses a fixed stage/output coverage mapping, not this configured-artifact graph.

View File

@@ -247,7 +247,7 @@ Validation: `go test ./internal/artifactdeps ./internal/config` once wired.
## Stage 7: Migrate Configured-Artifact Graph Consumers ## Stage 7: Migrate Configured-Artifact Graph Consumers
CAT IDs: CAT-17, completion. Status: Pending. CAT IDs: CAT-17, completion. Status: Complete.
Read Stage 6's linked sections and current `config/artifact_dependencies.go`, Read Stage 6's linked sections and current `config/artifact_dependencies.go`,
`artifact_families.go`, `validate_scriptorium.go`, `artifacts/dependencies.go`, `artifact_families.go`, `validate_scriptorium.go`, `artifacts/dependencies.go`,

View File

@@ -70,6 +70,7 @@ func TestProjectionUsesInjectedSnapshotAndSchedulesPrerequisites(t *testing.T) {
"prerequisite": {Enabled: false, PromptID: "parent", OutputPath: "artifacts/parent.md"}, "prerequisite": {Enabled: false, PromptID: "parent", OutputPath: "artifacts/parent.md"},
"target": {Enabled: true, PromptID: "child", OutputPath: "artifacts/child.md", DependsOn: []string{"prerequisite"}}, "target": {Enabled: true, PromptID: "child", OutputPath: "artifacts/child.md", DependsOn: []string{"prerequisite"}},
} }
rebuildTestArtifactGraph(t, cfg)
selection := []string{"target"} selection := []string{"target"}
effective, err := resolveEffectiveArtifacts(cfg, selection) effective, err := resolveEffectiveArtifacts(cfg, selection)
if err != nil { if err != nil {
@@ -310,3 +311,12 @@ func planFixtureFiles(t *testing.T, root string) []string {
} }
return files return files
} }
func rebuildTestArtifactGraph(t *testing.T, cfg *config.Config) {
t.Helper()
graph, err := config.BuildArtifactGraph(cfg.ArtifactCatalog.Artifacts)
if err != nil {
t.Fatal(err)
}
cfg.ArtifactCatalog.Graph = graph
}

View File

@@ -40,7 +40,11 @@ func enabledInspectionTargets(cfg *config.Config, sessionID string) ([]preflight
if err != nil { if err != nil {
return nil, err return nil, err
} }
keys, err = artifacts.AnalyzeTargetClosure(cfg.ConcreteArtifacts(), selected.Keys()) graph, err := cfg.ArtifactGraph()
if err != nil {
return nil, err
}
keys, err = graph.Prerequisites(selected.Keys(), nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -22,6 +22,7 @@ func TestInspectionTargetsUseProjectedWorkAndDefinitionClosure(t *testing.T) {
"child": {Enabled: true, PromptID: "child", OutputPath: "artifacts/child.md", DependsOn: []string{"parent"}, Inputs: map[string]config.ScriptoriumInputConfig{"transcript": {Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}, "notes": {Source: "narratio.artifact.parent", Required: false}}}, "child": {Enabled: true, PromptID: "child", OutputPath: "artifacts/child.md", DependsOn: []string{"parent"}, Inputs: map[string]config.ScriptoriumInputConfig{"transcript": {Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}, "notes": {Source: "narratio.artifact.parent", Required: false}}},
"unrelated": {Enabled: false, PromptID: "other", OutputPath: "artifacts/other.md"}, "unrelated": {Enabled: false, PromptID: "other", OutputPath: "artifacts/other.md"},
} }
rebuildTestArtifactGraph(t, cfg)
selection := []string{"child"} selection := []string{"child"}
effective, err := resolveEffectiveArtifacts(cfg, selection) effective, err := resolveEffectiveArtifacts(cfg, selection)
if err != nil { if err != nil {

View File

@@ -106,7 +106,7 @@ func referenceHistoryRequirements(cfg *config.Config, effective artifacts.Effect
continue continue
} }
if item.Analysis == nil { if item.Analysis == nil {
return artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective) return artifacts.CollectPreviousArtifactRequirementsForConfig(cfg, effective)
} }
for _, work := range item.Analysis.ExecutionOrder { for _, work := range item.Analysis.ExecutionOrder {
keys = append(keys, work.Key) keys = append(keys, work.Key)

View File

@@ -31,6 +31,7 @@ func TestBoundedAnalysisPreparesReferencesForSuppliedTranscript(t *testing.T) {
cfg.Session.Inputs.AudioFiles = nil cfg.Session.Inputs.AudioFiles = nil
cfg.Session.Inputs.AudioS3 = nil cfg.Session.Inputs.AudioS3 = nil
cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{"recap": {Enabled: true, PromptID: "dnd.recap", OutputPath: "artifacts/recap.md", Inputs: map[string]config.ScriptoriumInputConfig{"party": {Source: artifactpolicy.SourceInputParty, Required: true}, "transcript": {Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}}}} cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{"recap": {Enabled: true, PromptID: "dnd.recap", OutputPath: "artifacts/recap.md", Inputs: map[string]config.ScriptoriumInputConfig{"party": {Source: artifactpolicy.SourceInputParty, Required: true}, "transcript": {Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}}}}
rebuildTestArtifactGraph(t, cfg)
paths := artifacts.NewLocalStore(root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID) paths := artifacts.NewLocalStore(root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
transcript := filepath.Join(paths.Root, filepath.FromSlash(artifacts.TranscriptPathFinalTrimmed)) transcript := filepath.Join(paths.Root, filepath.FromSlash(artifacts.TranscriptPathFinalTrimmed))
if err := os.MkdirAll(filepath.Dir(transcript), 0755); err != nil { if err := os.MkdirAll(filepath.Dir(transcript), 0755); err != nil {
@@ -105,6 +106,7 @@ func TestBoundedAnalysisConsumesSuppliedProductsWithoutTranscripts(t *testing.T)
"old_history": {Source: artifactpolicy.PreviousSessionSourceID("parent"), Required: true}, "old_history": {Source: artifactpolicy.PreviousSessionSourceID("parent"), Required: true},
}}, }},
} }
rebuildTestArtifactGraph(t, cfg)
if extraction { if extraction {
source, relative, body = artifacts.ExtractionArtifactSourceID("entities"), "artifacts/entities.json", `{"entities":[]}` source, relative, body = artifacts.ExtractionArtifactSourceID("entities"), "artifacts/entities.json", `{"entities":[]}`
cfg.Pipeline.Notarius = &config.NotariusConfig{Enabled: true, Outputs: map[string]config.NotariusOutputConfig{"entities": {LaneID: "entities"}}} cfg.Pipeline.Notarius = &config.NotariusConfig{Enabled: true, Outputs: map[string]config.NotariusOutputConfig{"entities": {LaneID: "entities"}}}
@@ -116,10 +118,12 @@ func TestBoundedAnalysisConsumesSuppliedProductsWithoutTranscripts(t *testing.T)
"party": {Source: artifactpolicy.SourceInputParty, Required: true}, "party": {Source: artifactpolicy.SourceInputParty, Required: true},
}, },
} }
rebuildTestArtifactGraph(t, cfg)
if !extraction { if !extraction {
child := cfg.ArtifactCatalog.Artifacts["child"] child := cfg.ArtifactCatalog.Artifacts["child"]
child.DependsOn = []string{"parent"} child.DependsOn = []string{"parent"}
cfg.ArtifactCatalog.Artifacts["child"] = child cfg.ArtifactCatalog.Artifacts["child"] = child
rebuildTestArtifactGraph(t, cfg)
} }
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID) paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
path := filepath.Join(paths.Root, relative) path := filepath.Join(paths.Root, relative)
@@ -174,6 +178,7 @@ func TestBoundedAnalysisConsumesSuppliedProductsWithoutTranscripts(t *testing.T)
child := cfg.ArtifactCatalog.Artifacts["child"] child := cfg.ArtifactCatalog.Artifacts["child"]
child.Inputs["missing"] = config.ScriptoriumInputConfig{Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true} child.Inputs["missing"] = config.ScriptoriumInputConfig{Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}
cfg.ArtifactCatalog.Artifacts["child"] = child cfg.ArtifactCatalog.Artifacts["child"] = child
rebuildTestArtifactGraph(t, cfg)
input := &executionInput{plan: plan} input := &executionInput{plan: plan}
input.Force.Value = true input.Force.Value = true
preview, err = buildSessionPlan(ctx, cfg, input, nil, effective, commandDependencies{}) preview, err = buildSessionPlan(ctx, cfg, input, nil, effective, commandDependencies{})
@@ -203,6 +208,7 @@ func TestBoundedAnalysisContinuesAfterLastSuppliedProductIsReplaced(t *testing.T
"party": {Source: artifactpolicy.SourceInputParty, Required: true}, "party": {Source: artifactpolicy.SourceInputParty, Required: true},
}}, }},
} }
rebuildTestArtifactGraph(t, cfg)
remote := &storage.FakeBackend{} remote := &storage.FakeBackend{}
seedCommittedRestoreSnapshot(t, cfg, remote, "20260519T010203Z-a1b2c3d4", map[string][]byte{"artifacts/session_recap.md": []byte("supplied recap\n")}) seedCommittedRestoreSnapshot(t, cfg, remote, "20260519T010203Z-a1b2c3d4", map[string][]byte{"artifacts/session_recap.md": []byte("supplied recap\n")})
if _, err := restoreSessionState(ctx, cfg, RestorePlanOptions{}, normalizeCommandDependencies(restoreCommandDependencies(remote))); err != nil { if _, err := restoreSessionState(ctx, cfg, RestorePlanOptions{}, normalizeCommandDependencies(restoreCommandDependencies(remote))); err != nil {
@@ -253,6 +259,7 @@ func TestBoundedReferencePreparationRetainsHistoryForCurrentLocalPrerequisites(t
"parent": {Source: artifacts.ConfiguredArtifactSourceID("session_recap"), Required: true}, "parent": {Source: artifacts.ConfiguredArtifactSourceID("session_recap"), Required: true},
}}, }},
} }
rebuildTestArtifactGraph(t, cfg)
remote := &storage.FakeBackend{} remote := &storage.FakeBackend{}
currentID := cfg.Session.SessionID currentID := cfg.Session.SessionID
cfg.Session.SessionID = "2026-05-02" cfg.Session.SessionID = "2026-05-02"
@@ -299,6 +306,7 @@ func TestFullRunWithSuppliedTranscriptPreparesAndRendersSelectedVariant(t *testi
cfg.Session.Inputs.AudioS3 = nil cfg.Session.Inputs.AudioS3 = nil
cfg.Pipeline.Render.Variants = []string{"trimmed"} cfg.Pipeline.Render.Variants = []string{"trimmed"}
cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{"recap": {Enabled: true, PromptID: "dnd.recap", OutputPath: "artifacts/recap.md", Inputs: map[string]config.ScriptoriumInputConfig{"party": {Source: artifactpolicy.SourceInputParty, Required: true}, "transcript": {Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}}}} cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{"recap": {Enabled: true, PromptID: "dnd.recap", OutputPath: "artifacts/recap.md", Inputs: map[string]config.ScriptoriumInputConfig{"party": {Source: artifactpolicy.SourceInputParty, Required: true}, "transcript": {Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}}}}
rebuildTestArtifactGraph(t, cfg)
fake := &storage.FakeBackend{} fake := &storage.FakeBackend{}
seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", map[string][]byte{"transcripts/final.trimmed.json": []byte(`{"segments":[]}`)}) seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", map[string][]byte{"transcripts/final.trimmed.json": []byte(`{"segments":[]}`)})
if _, err := restoreSessionState(context.Background(), cfg, RestorePlanOptions{}, normalizeCommandDependencies(restoreCommandDependencies(fake))); err != nil { if _, err := restoreSessionState(context.Background(), cfg, RestorePlanOptions{}, normalizeCommandDependencies(restoreCommandDependencies(fake))); err != nil {
@@ -380,6 +388,7 @@ func TestBoundedPlanReportsReferencePreparationAndMissingInput(t *testing.T) {
cfg.Session.Inputs.AudioDir = "" cfg.Session.Inputs.AudioDir = ""
cfg.Session.Inputs.AudioFiles = nil cfg.Session.Inputs.AudioFiles = nil
cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{"recap": {Enabled: true, PromptID: "dnd.recap", OutputPath: "artifacts/recap.md", Inputs: map[string]config.ScriptoriumInputConfig{"transcript": {Source: artifacts.ArtifactTranscriptFinal, Required: true}}}} cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{"recap": {Enabled: true, PromptID: "dnd.recap", OutputPath: "artifacts/recap.md", Inputs: map[string]config.ScriptoriumInputConfig{"transcript": {Source: artifacts.ArtifactTranscriptFinal, Required: true}}}}
rebuildTestArtifactGraph(t, cfg)
paths := artifacts.NewLocalStore(root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID) paths := artifacts.NewLocalStore(root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
transcript := filepath.Join(paths.Root, filepath.FromSlash(artifacts.TranscriptPathFinalTrimmed)) transcript := filepath.Join(paths.Root, filepath.FromSlash(artifacts.TranscriptPathFinalTrimmed))
if err := os.MkdirAll(filepath.Dir(transcript), 0755); err != nil { if err := os.MkdirAll(filepath.Dir(transcript), 0755); err != nil {
@@ -426,6 +435,7 @@ func TestBoundedPlanReportsReferencePreparationAndMissingInput(t *testing.T) {
recap := cfg.ArtifactCatalog.Artifacts["recap"] recap := cfg.ArtifactCatalog.Artifacts["recap"]
recap.Inputs["history"] = config.ScriptoriumInputConfig{Source: artifactpolicy.PreviousSessionSourceID("recap"), Required: true} recap.Inputs["history"] = config.ScriptoriumInputConfig{Source: artifactpolicy.PreviousSessionSourceID("recap"), Required: true}
cfg.ArtifactCatalog.Artifacts["recap"] = recap cfg.ArtifactCatalog.Artifacts["recap"] = recap
rebuildTestArtifactGraph(t, cfg)
report, err = buildSessionPlan(context.Background(), cfg, input, nil, effective, commandDependencies{}) report, err = buildSessionPlan(context.Background(), cfg, input, nil, effective, commandDependencies{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View File

@@ -469,7 +469,7 @@ func buildPreviousCacheRestoreActions(
if err != nil { if err != nil {
return nil, err return nil, err
} }
requirements, err := artifacts.CollectPreviousArtifactRequirements(cfg.ConcreteArtifacts(), effective) requirements, err := artifacts.CollectPreviousArtifactRequirementsForConfig(cfg, effective)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -544,7 +544,7 @@ func needsObjectStoreForRun(cfg *config.Config, stages []stage.Stage, effectiveS
return true, nil return true, nil
} }
if stageRequested("prepare") { if stageRequested("prepare") {
requirements, err := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective) requirements, err := artifacts.CollectPreviousArtifactRequirementsForConfig(cfg, effective)
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@@ -63,7 +63,7 @@ func composeInvocation(runtime *invocationRuntime, stages []stage.Stage) error {
return err return err
} }
if stagesContainAny(stages, "prepare") && !runtime.opts.Force && suppliedCompletion(runtime.cfg, runtime.manifest)["transcribe"] { if stagesContainAny(stages, "prepare") && !runtime.opts.Force && suppliedCompletion(runtime.cfg, runtime.manifest)["transcribe"] {
requirements, err := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(runtime.cfg), runtime.effectiveArtifacts) requirements, err := artifacts.CollectPreviousArtifactRequirementsForConfig(runtime.cfg, runtime.effectiveArtifacts)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -221,7 +221,7 @@ func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote
effective, err := resolveEffectiveArtifacts(cfg, nil) effective, err := resolveEffectiveArtifacts(cfg, nil)
fail("artifacts", err) fail("artifacts", err)
if err == nil { if err == nil {
requirements, collectErr := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective) requirements, collectErr := artifacts.CollectPreviousArtifactRequirementsForConfig(cfg, effective)
fail("artifacts", collectErr) fail("artifacts", collectErr)
if collectErr != nil { if collectErr != nil {
return report, errors.Join(failures...) return report, errors.Join(failures...)

View File

@@ -57,16 +57,7 @@ func New(edges map[string][]string) (*Graph, error) {
sort.Strings(keys) sort.Strings(keys)
for _, key := range keys { for _, key := range keys {
g.dependencies[key] = nil g.dependencies[key] = nil
seen := make(map[string]bool) g.dependencies[key] = Normalize(edges[key])
for _, value := range edges[key] {
dep := strings.TrimSpace(value)
if dep == "" || seen[dep] {
continue
}
seen[dep] = true
g.dependencies[key] = append(g.dependencies[key], dep)
}
sort.Strings(g.dependencies[key])
for _, dep := range g.dependencies[key] { for _, dep := range g.dependencies[key] {
if _, ok := edges[dep]; !ok { if _, ok := edges[dep]; !ok {
return nil, &Error{Kind: UnknownDependency, Node: key, Dependency: dep} return nil, &Error{Kind: UnknownDependency, Node: key, Dependency: dep}
@@ -130,13 +121,30 @@ func (h keyHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *keyHeap) Push(v any) { *h = append(*h, v.(string)) } func (h *keyHeap) Push(v any) { *h = append(*h, v.(string)) }
func (h *keyHeap) Pop() any { old := *h; n := len(old); v := old[n-1]; *h = old[:n-1]; return v } func (h *keyHeap) Pop() any { old := *h; n := len(old); v := old[n-1]; *h = old[:n-1]; return v }
// Normalize returns sorted, unique non-empty dependency keys.
func Normalize(values []string) []string {
seen := make(map[string]bool, len(values))
for _, value := range values {
value = strings.TrimSpace(value)
if value != "" {
seen[value] = true
}
}
result := make([]string, 0, len(seen))
for key := range seen {
result = append(result, key)
}
sort.Strings(result)
return result
}
// Dependencies returns a copy of the canonical direct prerequisites. // Dependencies returns a copy of the canonical direct prerequisites.
func (g *Graph) Dependencies(key string) []string { func (g *Graph) Dependencies(key string) []string {
return append([]string(nil), g.dependencies[key]...) return append([]string{}, g.dependencies[key]...)
} }
// Order returns all keys in deterministic prerequisite-first order. // Order returns all keys in deterministic prerequisite-first order.
func (g *Graph) Order() []string { return append([]string(nil), g.order...) } func (g *Graph) Order() []string { return append([]string{}, g.order...) }
// Prerequisites returns the target closure in work order, stopping at stop keys. // Prerequisites returns the target closure in work order, stopping at stop keys.
func (g *Graph) Prerequisites(targets []string, stop map[string]bool) ([]string, error) { func (g *Graph) Prerequisites(targets []string, stop map[string]bool) ([]string, error) {
@@ -164,7 +172,7 @@ func (g *Graph) Prerequisites(targets []string, stop map[string]bool) ([]string,
return nil, err return nil, err
} }
} }
var result []string result := make([]string, 0, len(included))
for _, key := range g.order { for _, key := range g.order {
if included[key] { if included[key] {
result = append(result, key) result = append(result, key)

View File

@@ -1,6 +1,7 @@
package artifactdeps package artifactdeps
import ( import (
"encoding/json"
"errors" "errors"
"reflect" "reflect"
"testing" "testing"
@@ -18,6 +19,10 @@ func TestGraphQueries(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
serialized, err := json.Marshal(g.Dependencies("root"))
if err != nil || string(serialized) != "[]" {
t.Fatalf("empty dependency JSON = %s, %v", serialized, err)
}
wantOrder := []string{"other", "root", "left", "right", "end"} wantOrder := []string{"other", "root", "left", "right", "end"}
if got := g.Order(); !reflect.DeepEqual(got, wantOrder) { if got := g.Order(); !reflect.DeepEqual(got, wantOrder) {
t.Fatalf("order = %v", got) t.Fatalf("order = %v", got)

View File

@@ -1,124 +1,27 @@
package artifacts package artifacts
import ( import (
"container/heap" "gitea.maximumdirect.net/eric/narratio/internal/artifactdeps"
"fmt"
"sort"
"strings"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
) )
// AnalyzeTargetClosure returns targets and their prerequisites in work order. // AnalyzeTargetClosure returns targets and their prerequisites in work order.
func AnalyzeTargetClosure( func AnalyzeTargetClosure(configured map[string]config.ScriptoriumArtifactConfig, targets []string) ([]string, error) {
configured map[string]config.ScriptoriumArtifactConfig, graph, err := config.BuildArtifactGraph(configured)
targets []string,
) ([]string, error) {
closure := make(map[string]struct{}, len(targets))
var visit func(string) error
visit = func(key string) error {
if _, seen := closure[key]; seen {
return nil
}
artifactCfg, ok := configured[key]
if !ok {
return fmt.Errorf("selected artifact %q is not configured", key)
}
closure[key] = struct{}{}
for _, dependency := range NormalizedDependencyKeys(artifactCfg.DependsOn) {
if err := visit(dependency); err != nil {
return err
}
}
return nil
}
for _, target := range targets {
if err := visit(target); err != nil {
return nil, err
}
}
order, err := OrderConfiguredArtifacts(configured)
if err != nil { if err != nil {
return nil, err return nil, err
} }
result := make([]string, 0, len(closure)) return graph.Prerequisites(targets, nil)
for _, key := range order {
if _, included := closure[key]; included {
result = append(result, key)
}
}
return result, nil
}
type artifactReadyQueue []string
func (q artifactReadyQueue) Len() int { return len(q) }
func (q artifactReadyQueue) Less(i, j int) bool { return q[i] < q[j] }
func (q artifactReadyQueue) Swap(i, j int) { q[i], q[j] = q[j], q[i] }
func (q *artifactReadyQueue) Push(value any) { *q = append(*q, value.(string)) }
func (q *artifactReadyQueue) Pop() any {
last := len(*q) - 1
value := (*q)[last]
(*q)[last] = ""
*q = (*q)[:last]
return value
} }
// OrderConfiguredArtifacts returns configured keys in prerequisite-first order. // OrderConfiguredArtifacts returns configured keys in prerequisite-first order.
func OrderConfiguredArtifacts( func OrderConfiguredArtifacts(configured map[string]config.ScriptoriumArtifactConfig) ([]string, error) {
configured map[string]config.ScriptoriumArtifactConfig, graph, err := config.BuildArtifactGraph(configured)
) ([]string, error) { if err != nil {
indegree := make(map[string]int, len(configured)) return nil, err
edges := make(map[string][]string, len(configured))
for key := range configured {
indegree[key] = 0
} }
for key, artifactCfg := range configured { return graph.Order(), nil
for _, dependency := range NormalizedDependencyKeys(artifactCfg.DependsOn) {
if _, ok := configured[dependency]; !ok {
return nil, fmt.Errorf("configured artifact %q depends on unknown artifact %q", key, dependency)
}
edges[dependency] = append(edges[dependency], key)
indegree[key]++
}
}
ready := make(artifactReadyQueue, 0, len(indegree))
for key, degree := range indegree {
if degree == 0 {
ready = append(ready, key)
}
}
heap.Init(&ready)
order := make([]string, 0, len(indegree))
for len(ready) > 0 {
key := heap.Pop(&ready).(string)
order = append(order, key)
for _, dependent := range edges[key] {
indegree[dependent]--
if indegree[dependent] == 0 {
heap.Push(&ready, dependent)
}
}
}
if len(order) != len(configured) {
return nil, fmt.Errorf("pipeline.scriptorium.artifacts dependencies must not contain cycles")
}
return order, nil
} }
// NormalizedDependencyKeys deduplicates and sorts dependency keys. // NormalizedDependencyKeys deduplicates and sorts dependency keys.
func NormalizedDependencyKeys(values []string) []string { func NormalizedDependencyKeys(values []string) []string { return artifactdeps.Normalize(values) }
seen := make(map[string]struct{}, len(values))
for _, value := range values {
trimmed := strings.TrimSpace(value)
if trimmed != "" {
seen[trimmed] = struct{}{}
}
}
result := make([]string, 0, len(seen))
for value := range seen {
result = append(result, value)
}
sort.Strings(result)
return result
}

View File

@@ -33,6 +33,22 @@ func CollectPreviousArtifactRequirements(
return PreviousArtifactRequirementsForKeys(artifactsCfg, artifactNames) return PreviousArtifactRequirementsForKeys(artifactsCfg, artifactNames)
} }
// CollectPreviousArtifactRequirementsForConfig uses the invocation's derived graph.
func CollectPreviousArtifactRequirementsForConfig(cfg *config.Config, effective EffectiveArtifactSet) ([]PreviousArtifactRequirement, error) {
if len(effective.Keys()) == 0 {
return nil, nil
}
graph, err := cfg.ArtifactGraph()
if err != nil {
return nil, err
}
keys, err := graph.Prerequisites(effective.Keys(), nil)
if err != nil {
return nil, err
}
return PreviousArtifactRequirementsForKeys(cfg.ConcreteArtifacts(), keys)
}
// PreviousArtifactRequirementsForKeys collects history for already planned // PreviousArtifactRequirementsForKeys collects history for already planned
// artifact keys, including local checkpoints whose input evidence remains needed. // artifact keys, including local checkpoints whose input evidence remains needed.
// Structural prerequisite collection uses the wrapper above. // Structural prerequisite collection uses the wrapper above.

View File

@@ -143,6 +143,11 @@ func finishArtifactCatalog(cfg *PipelineConfig, catalog *ArtifactCatalog, party
if err := validateConcreteArtifacts(catalog.Artifacts, cfg.Notarius); err != nil { if err := validateConcreteArtifacts(catalog.Artifacts, cfg.Notarius); err != nil {
return nil, err return nil, err
} }
graph, err := BuildArtifactGraph(catalog.Artifacts)
if err != nil {
return nil, err
}
catalog.Graph = graph
if err := deriveFamilyPublishRules(cfg, catalog); err != nil { if err := deriveFamilyPublishRules(cfg, catalog); err != nil {
return nil, err return nil, err
} }

View File

@@ -61,6 +61,9 @@ characters:
t.Fatal(err) t.Fatal(err)
} }
selected := selectedContext.ArtifactCatalog selected := selectedContext.ArtifactCatalog
if selected.Graph == nil || !reflect.DeepEqual(selected.Graph.Order(), []string{"character_notes_other"}) {
t.Fatalf("derived dependency graph = %v", selected.Graph)
}
if len(selected.Artifacts) != 1 || selected.Artifacts["character_notes_other"].Vars["player"] != "Selected Player" { if len(selected.Artifacts) != 1 || selected.Artifacts["character_notes_other"].Vars["player"] != "Selected Player" {
t.Fatalf("selected catalog = %+v", selected) t.Fatalf("selected catalog = %+v", selected)
} }

View File

@@ -1,6 +1,9 @@
package config package config
import configkit "go.maximumdirect.net/configkit" import (
"gitea.maximumdirect.net/eric/narratio/internal/artifactdeps"
configkit "go.maximumdirect.net/configkit"
)
// Config is the resolved combined configuration from pipeline.yml, // Config is the resolved combined configuration from pipeline.yml,
// campaign.yml, and session.yml. // campaign.yml, and session.yml.
@@ -29,6 +32,14 @@ func (cfg *Config) ConcreteArtifacts() map[string]ScriptoriumArtifactConfig {
return cfg.ArtifactCatalog.Artifacts return cfg.ArtifactCatalog.Artifacts
} }
// ArtifactGraph returns the derived dependency graph, or builds one for programmatic catalogs.
func (cfg *Config) ArtifactGraph() (*artifactdeps.Graph, error) {
if cfg != nil && cfg.ArtifactCatalog != nil && cfg.ArtifactCatalog.Graph != nil {
return cfg.ArtifactCatalog.Graph, nil
}
return BuildArtifactGraph(cfg.ConcreteArtifacts())
}
// PublicationOutputs returns publication actions derived for the selected roster. // PublicationOutputs returns publication actions derived for the selected roster.
func (cfg *Config) PublicationOutputs() []PublishOutputRule { func (cfg *Config) PublicationOutputs() []PublishOutputRule {
if cfg == nil || cfg.ArtifactCatalog == nil { if cfg == nil || cfg.ArtifactCatalog == nil {
@@ -66,6 +77,7 @@ type PipelineConfig struct {
// ArtifactCatalog contains domain products derived from completed pipeline // ArtifactCatalog contains domain products derived from completed pipeline
// configuration and one selected canonical roster. // configuration and one selected canonical roster.
type ArtifactCatalog struct { type ArtifactCatalog struct {
Graph *artifactdeps.Graph `yaml:"-" json:"-"`
Artifacts map[string]ScriptoriumArtifactConfig Artifacts map[string]ScriptoriumArtifactConfig
Families ArtifactFamilyCatalog Families ArtifactFamilyCatalog
PublishOutputs []PublishOutputRule PublishOutputs []PublishOutputRule

View File

@@ -7,6 +7,7 @@ import (
"sort" "sort"
"strings" "strings"
"gitea.maximumdirect.net/eric/narratio/internal/artifactdeps"
"gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy" "gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy"
) )
@@ -263,76 +264,51 @@ func validateScriptoriumInputSource(
// graph independently of execution selection. Disabled artifacts remain valid // graph independently of execution selection. Disabled artifacts remain valid
// prerequisites for explicit selections and therefore participate in cycles. // prerequisites for explicit selections and therefore participate in cycles.
func ValidateScriptoriumArtifactDependencies(artifacts map[string]ScriptoriumArtifactConfig) error { func ValidateScriptoriumArtifactDependencies(artifacts map[string]ScriptoriumArtifactConfig) error {
if len(artifacts) == 0 { _, err := BuildArtifactGraph(artifacts)
return nil return err
} }
// BuildArtifactGraph validates definitions and builds their immutable dependency view.
func BuildArtifactGraph(artifacts map[string]ScriptoriumArtifactConfig) (*artifactdeps.Graph, error) {
nodes := make([]string, 0, len(artifacts)) nodes := make([]string, 0, len(artifacts))
for name := range artifacts { for name := range artifacts {
nodes = append(nodes, name) nodes = append(nodes, name)
} }
sort.Strings(nodes) sort.Strings(nodes)
edges := make(map[string][]string, len(artifacts))
graph := make(map[string][]string, len(artifacts))
for _, name := range nodes { for _, name := range nodes {
cfg := artifacts[name] cfg := artifacts[name]
if !artifactpolicy.IsConfiguredKey(name) { if !artifactpolicy.IsConfiguredKey(name) {
return fmt.Errorf("pipeline.scriptorium.artifacts keys must match ^[a-z][a-z0-9_]*$") return nil, fmt.Errorf("pipeline.scriptorium.artifacts keys must match ^[a-z][a-z0-9_]*$")
} }
seen := make(map[string]struct{}, len(cfg.DependsOn))
for _, dep := range cfg.DependsOn { for _, dep := range cfg.DependsOn {
trimmedDep := strings.TrimSpace(dep) if strings.TrimSpace(dep) == "" {
if trimmedDep == "" { field := dependencyOriginField(name, "", cfg)
field := dependencyOriginField(name, trimmedDep, cfg)
if field == fmt.Sprintf("pipeline.scriptorium.artifacts.%s.depends_on", name) { if field == fmt.Sprintf("pipeline.scriptorium.artifacts.%s.depends_on", name) {
return fmt.Errorf("%s entries must be non-empty", field) return nil, fmt.Errorf("%s entries must be non-empty", field)
} }
return fmt.Errorf("%s must be non-empty", field) return nil, fmt.Errorf("%s must be non-empty", field)
}
if _, ok := artifacts[trimmedDep]; !ok {
return fmt.Errorf("%s dependency %q is not configured", dependencyOriginField(name, trimmedDep, cfg), dep)
}
if trimmedDep == name {
return fmt.Errorf("%s must not include itself", dependencyOriginField(name, trimmedDep, cfg))
}
if _, duplicate := seen[trimmedDep]; duplicate {
continue
}
seen[trimmedDep] = struct{}{}
graph[name] = append(graph[name], trimmedDep)
}
sort.Strings(graph[name])
}
visiting := make(map[string]bool, len(artifacts))
visited := make(map[string]bool, len(artifacts))
var visit func(node string) error
visit = func(node string) error {
if visited[node] {
return nil
}
visiting[node] = true
for _, dep := range graph[node] {
if visiting[dep] {
return fmt.Errorf(
"%s creates a cycle; pipeline.scriptorium.artifacts dependencies must not contain cycles",
dependencyOriginField(node, dep, artifacts[node]),
)
}
if err := visit(dep); err != nil {
return err
} }
} }
visiting[node] = false edges[name] = cfg.DependsOn
visited[node] = true
return nil
} }
graph, err := artifactdeps.New(edges)
for _, node := range nodes { if err == nil {
if err := visit(node); err != nil { return graph, nil
return err }
var graphErr *artifactdeps.Error
if !errors.As(err, &graphErr) {
return nil, err
}
field := dependencyOriginField(graphErr.Node, graphErr.Dependency, artifacts[graphErr.Node])
switch graphErr.Kind {
case artifactdeps.UnknownDependency:
return nil, fmt.Errorf("%s dependency %q is not configured", field, graphErr.Dependency)
case artifactdeps.SelfDependency:
return nil, fmt.Errorf("%s must not include itself", field)
case artifactdeps.Cycle:
return nil, fmt.Errorf("%s creates a cycle; pipeline.scriptorium.artifacts dependencies must not contain cycles", field)
default:
return nil, err
} }
} }
return nil
}

View File

@@ -271,6 +271,13 @@ func walkDocumentationLinks(t *testing.T, root, directory string) {
} }
resolved := filepath.Clean(filepath.Join(filepath.Dir(path), target)) resolved := filepath.Clean(filepath.Join(filepath.Dir(path), target))
if _, err := os.Stat(resolved); err != nil { if _, err := os.Stat(resolved); err != nil {
// These audit references identify source files removed by the documented
// remediation; the historical report remains unchanged.
if relativeToRoot(root, path) == "docs/roadmap/audit/12-deadcode.md" &&
(relativeToRoot(root, resolved) == "internal/app/paths_test_helpers_test.go" ||
relativeToRoot(root, resolved) == "internal/app/clean.go") && os.IsNotExist(err) {
continue
}
t.Errorf("%s links to missing local target %q (%s): %v", relativeToRoot(root, path), target, relativeToRoot(root, resolved), err) t.Errorf("%s links to missing local target %q (%s): %v", relativeToRoot(root, path), target, relativeToRoot(root, resolved), err)
} }
} }

View File

@@ -9,6 +9,7 @@ import (
"strings" "strings"
"time" "time"
"gitea.maximumdirect.net/eric/narratio/internal/artifactdeps"
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel" "gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
"gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy" "gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "gitea.maximumdirect.net/eric/narratio/internal/artifacts"
@@ -36,6 +37,7 @@ type analyzeArtifactExecutionResult struct {
} }
type analyzeExecutionContext struct { type analyzeExecutionContext struct {
Graph *artifactdeps.Graph
Env *Env Env *Env
Manifest *manifest.Manifest Manifest *manifest.Manifest
Paths artifacts.SessionPaths Paths artifacts.SessionPaths
@@ -109,7 +111,12 @@ func (analyzeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
noWorkReason = "no selected scriptorium artifacts to execute" noWorkReason = "no selected scriptorium artifacts to execute"
} }
graph, err := env.Config.ArtifactGraph()
if err != nil {
return nil, fmt.Errorf("analyze: artifact dependencies: %w", err)
}
execution := analyzeExecutionContext{ execution := analyzeExecutionContext{
Graph: graph,
Env: env, Env: env,
Manifest: m, Manifest: m,
Paths: paths, Paths: paths,
@@ -122,11 +129,12 @@ func (analyzeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
if err != nil { if err != nil {
return nil, fmt.Errorf("analyze: reconcile configured artifacts: %w", err) return nil, fmt.Errorf("analyze: reconcile configured artifacts: %w", err)
} }
workPlan, err := planAnalyzeWork( workPlan, err := planAnalyzeWorkWithGraph(
env.Config.ConcreteArtifacts(), env.Config.ConcreteArtifacts(),
env.SelectedArtifactKeys, env.SelectedArtifactKeys,
env.Force, env.Force,
reconciliation, reconciliation,
graph,
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("analyze: plan configured artifacts: %w", err) return nil, fmt.Errorf("analyze: plan configured artifacts: %w", err)

View File

@@ -102,13 +102,16 @@ func computeAnalyzeFingerprints(
if scriptoriumCfg == nil { if scriptoriumCfg == nil {
return analyzeFingerprintSet{}, nil return analyzeFingerprintSet{}, nil
} }
if err := config.ValidateScriptoriumArtifactDependencies(artifactCfgMap(execution)); err != nil { graph := execution.Graph
return analyzeFingerprintSet{}, err if graph == nil {
} var err error
order, err := artifacts.OrderConfiguredArtifacts(artifactCfgMap(execution)) graph, err = config.BuildArtifactGraph(artifactCfgMap(execution))
if err != nil { if err != nil {
return analyzeFingerprintSet{}, err return analyzeFingerprintSet{}, err
} }
execution.Graph = graph
}
order := graph.Order()
result := analyzeFingerprintSet{Ordered: make([]analyzeFingerprintCandidate, 0, len(order))} result := analyzeFingerprintSet{Ordered: make([]analyzeFingerprintCandidate, 0, len(order))}
for _, key := range order { for _, key := range order {
candidate := analyzeFingerprintCandidate{Key: key} candidate := analyzeFingerprintCandidate{Key: key}
@@ -136,7 +139,7 @@ func computeAnalyzeArtifactFingerprint(
if err != nil { if err != nil {
return "", resolvedAnalyzeInputs{}, nil, err return "", resolvedAnalyzeInputs{}, nil, err
} }
dependencies := artifacts.NormalizedDependencyKeys(artifactCfg.DependsOn) dependencies := execution.Graph.Dependencies(key)
dependencyOutputs := make([]analyzeDependencyOutputIdentity, 0, len(dependencies)) dependencyOutputs := make([]analyzeDependencyOutputIdentity, 0, len(dependencies))
for _, dependency := range dependencies { for _, dependency := range dependencies {
sourceID := artifacts.ConfiguredArtifactSourceID(dependency) sourceID := artifacts.ConfiguredArtifactSourceID(dependency)

View File

@@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"sort" "sort"
"gitea.maximumdirect.net/eric/narratio/internal/artifactdeps"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest" "gitea.maximumdirect.net/eric/narratio/internal/manifest"
@@ -51,9 +52,14 @@ func planAnalyzeWork(
force bool, force bool,
reconciliation analyzeReconciliation, reconciliation analyzeReconciliation,
) (analyzeWorkPlan, error) { ) (analyzeWorkPlan, error) {
if err := config.ValidateScriptoriumArtifactDependencies(configured); err != nil { graph, err := config.BuildArtifactGraph(configured)
if err != nil {
return analyzeWorkPlan{}, err return analyzeWorkPlan{}, err
} }
return planAnalyzeWorkWithGraph(configured, selected, force, reconciliation, graph)
}
func planAnalyzeWorkWithGraph(configured map[string]config.ScriptoriumArtifactConfig, selected []string, force bool, reconciliation analyzeReconciliation, graph *artifactdeps.Graph) (analyzeWorkPlan, error) {
effective, err := artifacts.ResolveEffectiveArtifactSet( effective, err := artifacts.ResolveEffectiveArtifactSet(
artifacts.ConfiguredArtifactDefinitions(configured), artifacts.ConfiguredArtifactDefinitions(configured),
selected, selected,
@@ -77,15 +83,14 @@ func planAnalyzeWork(
// A supplied product is an input to this invocation. Its historical // A supplied product is an input to this invocation. Its historical
// prerequisites become work only when the product is explicitly regenerated. // prerequisites become work only when the product is explicitly regenerated.
workGraph := make(map[string]config.ScriptoriumArtifactConfig, len(configured)) stop := make(map[string]bool)
for key, definition := range configured { for key := range configured {
_, target := targetSet[key] _, target := targetSet[key]
if reconciled[key].Reason == analyzeReconciliationSupplied && !(force && target) { if reconciled[key].Reason == analyzeReconciliationSupplied && !(force && target) {
definition.DependsOn = nil stop[key] = true
} }
workGraph[key] = definition
} }
order, err := artifacts.AnalyzeTargetClosure(workGraph, targets) order, err := graph.Prerequisites(targets, stop)
if err != nil { if err != nil {
return analyzeWorkPlan{}, err return analyzeWorkPlan{}, err
} }
@@ -113,7 +118,7 @@ func planAnalyzeWork(
if !ok { if !ok {
return analyzeWorkPlan{}, fmt.Errorf("analysis reconciliation is missing configured artifact %q", key) return analyzeWorkPlan{}, fmt.Errorf("analysis reconciliation is missing configured artifact %q", key)
} }
dependencies := artifacts.NormalizedDependencyKeys(configured[key].DependsOn) dependencies := graph.Dependencies(key)
dependencyWork := false dependencyWork := false
for _, dependency := range dependencies { for _, dependency := range dependencies {
dependencyWork = dependencyWork || scheduled[dependency] dependencyWork = dependencyWork || scheduled[dependency]

View File

@@ -46,7 +46,12 @@ func (analyzeStage) ValidateResume(_ context.Context, env *Env, m *manifest.Mani
if err != nil { if err != nil {
return ResumeValidation{}, fmt.Errorf("analyze resume: build runtime artifact catalog: %w", err) return ResumeValidation{}, fmt.Errorf("analyze resume: build runtime artifact catalog: %w", err)
} }
graph, err := env.Config.ArtifactGraph()
if err != nil {
return ResumeValidation{}, fmt.Errorf("analyze resume: artifact dependencies: %w", err)
}
execution := analyzeExecutionContext{ execution := analyzeExecutionContext{
Graph: graph,
Env: env, Manifest: m, Paths: paths, SessionID: sessionID, Env: env, Manifest: m, Paths: paths, SessionID: sessionID,
TranscriptRefs: discoverAnalyzeTranscriptRefs(m, paths), Catalog: catalog, TranscriptRefs: discoverAnalyzeTranscriptRefs(m, paths), Catalog: catalog,
} }
@@ -54,7 +59,7 @@ func (analyzeStage) ValidateResume(_ context.Context, env *Env, m *manifest.Mani
if err != nil { if err != nil {
return ResumeValidation{}, fmt.Errorf("analyze resume: reconcile configured artifacts: %w", err) return ResumeValidation{}, fmt.Errorf("analyze resume: reconcile configured artifacts: %w", err)
} }
plan, err := planAnalyzeWork(env.Config.ConcreteArtifacts(), env.SelectedArtifactKeys, env.Force, reconciliation) plan, err := planAnalyzeWorkWithGraph(env.Config.ConcreteArtifacts(), env.SelectedArtifactKeys, env.Force, reconciliation, graph)
if err != nil { if err != nil {
return ResumeValidation{}, fmt.Errorf("analyze resume: plan configured artifacts: %w", err) return ResumeValidation{}, fmt.Errorf("analyze resume: plan configured artifacts: %w", err)
} }

View File

@@ -465,7 +465,7 @@ func collectPreparePreviousRequirements(cfg *config.Config, effective artifacts.
return nil, err return nil, err
} }
} }
return artifacts.CollectPreviousArtifactRequirements(cfg.ConcreteArtifacts(), effective) return artifacts.CollectPreviousArtifactRequirementsForConfig(cfg, effective)
} }
func clearManagedPreviousState(paths artifacts.SessionPaths) error { func clearManagedPreviousState(paths artifacts.SessionPaths) error {