Reuse supplied analysis products without rebuilding their history
This commit is contained in:
@@ -92,9 +92,10 @@ Supported source families:
|
|||||||
generation inputs or fingerprint.
|
generation inputs or fingerprint.
|
||||||
- owns a read-only typed work planner. Its explicit targets are enabled
|
- owns a read-only typed work planner. Its explicit targets are enabled
|
||||||
artifacts by default or the exact normalized `--artifacts` selection when
|
artifacts by default or the exact normalized `--artifacts` selection when
|
||||||
supplied. It closes targets over configured prerequisites, orders the closure
|
supplied. It closes targets over configured prerequisites, stopping at valid
|
||||||
topologically, reuses current members, and schedules every non-current member
|
supplied products unless they are explicit forced targets. It orders the work
|
||||||
before its dependents.
|
topologically, reuses current or supplied members, and schedules non-current
|
||||||
|
members before their dependents.
|
||||||
- force applies only to explicit targets. A current prerequisite is reused
|
- force applies only to explicit targets. A current prerequisite is reused
|
||||||
unless it is itself an explicit forced target; disabled prerequisites may be
|
unless it is itself an explicit forced target; disabled prerequisites may be
|
||||||
rebuilt when required, while unrelated disabled artifacts are excluded.
|
rebuilt when required, while unrelated disabled artifacts are excluded.
|
||||||
|
|||||||
@@ -11,7 +11,13 @@ product requirements or an implementation plan.
|
|||||||
|
|
||||||
## 1. P2: Stop dependency work at accepted supplied analysis products
|
## 1. P2: Stop dependency work at accepted supplied analysis products
|
||||||
|
|
||||||
Status: Open
|
Status: Complete
|
||||||
|
|
||||||
|
Resolution: the analysis planner closes the active work graph at accepted
|
||||||
|
supplied products, except explicit forced targets. Behavioral regressions cover
|
||||||
|
preview and execution for a supplied target and a new child, with absent
|
||||||
|
historical inputs, plus forced replacement. Verified with
|
||||||
|
`go test ./internal/stage ./internal/artifacts ./internal/manifest`.
|
||||||
|
|
||||||
Affected stages: 4, 5, and 12.
|
Affected stages: 4, 5, and 12.
|
||||||
|
|
||||||
|
|||||||
@@ -63,10 +63,6 @@ func planAnalyzeWork(
|
|||||||
}
|
}
|
||||||
targets := effective.Keys()
|
targets := effective.Keys()
|
||||||
targetSet := stringSet(targets)
|
targetSet := stringSet(targets)
|
||||||
order, err := artifacts.AnalyzeTargetClosure(configured, targets)
|
|
||||||
if err != nil {
|
|
||||||
return analyzeWorkPlan{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
reconciled := make(map[string]analyzeArtifactReconciliation, len(reconciliation.Ordered))
|
reconciled := make(map[string]analyzeArtifactReconciliation, len(reconciliation.Ordered))
|
||||||
removed := make([]analyzePlanItem, 0)
|
removed := make([]analyzePlanItem, 0)
|
||||||
@@ -79,6 +75,21 @@ func planAnalyzeWork(
|
|||||||
}
|
}
|
||||||
sort.Slice(removed, func(i, j int) bool { return removed[i].Key < removed[j].Key })
|
sort.Slice(removed, func(i, j int) bool { return removed[i].Key < removed[j].Key })
|
||||||
|
|
||||||
|
// A supplied product is an input to this invocation. Its historical
|
||||||
|
// prerequisites become work only when the product is explicitly regenerated.
|
||||||
|
workGraph := make(map[string]config.ScriptoriumArtifactConfig, len(configured))
|
||||||
|
for key, definition := range configured {
|
||||||
|
_, target := targetSet[key]
|
||||||
|
if reconciled[key].Reason == analyzeReconciliationSupplied && !(force && target) {
|
||||||
|
definition.DependsOn = nil
|
||||||
|
}
|
||||||
|
workGraph[key] = definition
|
||||||
|
}
|
||||||
|
order, err := artifacts.AnalyzeTargetClosure(workGraph, targets)
|
||||||
|
if err != nil {
|
||||||
|
return analyzeWorkPlan{}, err
|
||||||
|
}
|
||||||
|
|
||||||
plan := analyzeWorkPlan{
|
plan := analyzeWorkPlan{
|
||||||
ExplicitTargets: append([]string(nil), targets...),
|
ExplicitTargets: append([]string(nil), targets...),
|
||||||
Removed: removed,
|
Removed: removed,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package stage
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
|
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
|
||||||
@@ -54,6 +55,60 @@ func TestAnalyzeSuppliedPrerequisiteAndNewTarget(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAnalyzeSuppliedProductsStopHistoricalDependencyWork(t *testing.T) {
|
||||||
|
for _, child := range []bool{false, true} {
|
||||||
|
name := "supplied target"
|
||||||
|
if child {
|
||||||
|
name = "new child of supplied prerequisite"
|
||||||
|
}
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
env, m := suppliedAnalyzeFixture(t)
|
||||||
|
parent := env.Config.ArtifactCatalog.Artifacts["session_recap"]
|
||||||
|
parent.DependsOn = []string{"historical"}
|
||||||
|
env.Config.ArtifactCatalog.Artifacts["session_recap"] = parent
|
||||||
|
env.Config.ArtifactCatalog.Artifacts["historical"] = config.ScriptoriumArtifactConfig{
|
||||||
|
PromptID: "historical", OutputPath: "artifacts/historical.md",
|
||||||
|
Inputs: map[string]config.ScriptoriumInputConfig{
|
||||||
|
"transcript": {Source: artifacts.ArtifactTranscriptBase, Required: true},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
env.SelectedArtifactKeys = []string{"session_recap"}
|
||||||
|
runner := &orderedScriptoriumRunner{RunBody: "new handout\n"}
|
||||||
|
env.Scriptorium = runner
|
||||||
|
if child {
|
||||||
|
addAnalyzeDependentArtifact(env)
|
||||||
|
env.SelectedArtifactKeys = []string{"player_handout"}
|
||||||
|
}
|
||||||
|
preview, err := (analyzeStage{}).ValidateResume(context.Background(), env, m)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
wantWork := 0
|
||||||
|
if child {
|
||||||
|
wantWork = 1
|
||||||
|
}
|
||||||
|
if len(preview.Analyze.ExecutionOrder) != wantWork || len(preview.Analyze.PrerequisiteWork) != 0 {
|
||||||
|
t.Fatalf("historical work in preview: %+v", preview.Analyze)
|
||||||
|
}
|
||||||
|
if _, err := (analyzeStage{}).Run(context.Background(), env, m); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(runner.Calls) != wantWork {
|
||||||
|
t.Fatalf("calls %v, want %d generations", runner.Calls, wantWork)
|
||||||
|
}
|
||||||
|
if _, ok := m.SuppliedProducts.Products[artifacts.ConfiguredArtifactSourceID("session_recap")]; !ok {
|
||||||
|
t.Fatal("lost accepted supplied product")
|
||||||
|
}
|
||||||
|
// Force reopens the supplied target's generation requirements.
|
||||||
|
env.SelectedArtifactKeys = []string{"session_recap"}
|
||||||
|
env.Force = true
|
||||||
|
if _, err := (analyzeStage{}).Run(context.Background(), env, m); err == nil || !strings.Contains(err.Error(), "historical") {
|
||||||
|
t.Fatalf("forced replacement should require historical input: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAnalyzeForcedSuppliedTargetBecomesLocalCheckpoint(t *testing.T) {
|
func TestAnalyzeForcedSuppliedTargetBecomesLocalCheckpoint(t *testing.T) {
|
||||||
env, m := suppliedAnalyzeFixture(t)
|
env, m := suppliedAnalyzeFixture(t)
|
||||||
env.SelectedArtifactKeys = []string{"session_recap"}
|
env.SelectedArtifactKeys = []string{"session_recap"}
|
||||||
|
|||||||
Reference in New Issue
Block a user