Allow artifact-only continuation from imported products
This commit is contained in:
@@ -91,9 +91,10 @@ The default is the full canonical pipeline:
|
|||||||
`--from` and `--through` select inclusive contiguous bounds. `--stage` selects
|
`--from` and `--through` select inclusive contiguous bounds. `--stage` selects
|
||||||
one stage and cannot accompany explicitly supplied range flags. `--force`
|
one stage and cannot accompany explicitly supplied range flags. `--force`
|
||||||
reruns selected work; dependent invalidation can extend beyond that range.
|
reruns selected work; dependent invalidation can extend beyond that range.
|
||||||
Bounded starts require valid preceding state or applicable supplied-product
|
Bounded starts use valid preceding state or an imported-product baseline.
|
||||||
coverage. When covered transcript work permits a downstream start, Narratio
|
In an imported workspace, selected consumers require their actual inputs;
|
||||||
prepares required references before downstream checks. Ordinary execution uses
|
unrelated producer-stage history is unnecessary. Narratio prepares required
|
||||||
|
references before downstream checks. Ordinary execution uses
|
||||||
semantic resume checks rather than rerunning all selected work.
|
semantic resume checks rather than rerunning all selected work.
|
||||||
|
|
||||||
After preparation, `run` checks projected Audita, Notarius, and Scriptorium work before
|
After preparation, `run` checks projected Audita, Notarius, and Scriptorium work before
|
||||||
|
|||||||
@@ -182,6 +182,10 @@ Validation by content type:
|
|||||||
- merges required and optional references (required wins);
|
- merges required and optional references (required wins);
|
||||||
- returns deterministic ordering and source locations.
|
- returns deterministic ordering and source locations.
|
||||||
|
|
||||||
|
`PreviousArtifactRequirementsForKeys` applies the same source collection to an
|
||||||
|
already planned set of generation keys. Bounded reference preparation uses it
|
||||||
|
after analysis planning has resolved supplied-product reuse boundaries.
|
||||||
|
|
||||||
## Current-State Helpers
|
## Current-State Helpers
|
||||||
|
|
||||||
Artifacts package owns shared remote current-state loading mechanics used by
|
Artifacts package owns shared remote current-state loading mechanics used by
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ Materialize canonical current-session inputs before processing stages.
|
|||||||
- bounded downstream runs may prepare or reuse references under the workspace
|
- bounded downstream runs may prepare or reuse references under the workspace
|
||||||
lock before readiness checks, even when prepare lies outside the selected range.
|
lock before readiness checks, even when prepare lies outside the selected range.
|
||||||
Existing audio input records remain available without being recertified by
|
Existing audio input records remain available without being recertified by
|
||||||
reference-only preparation.
|
reference-only preparation. An imported configured or extraction product can
|
||||||
|
support this workflow without any transcript. Reference-only validation
|
||||||
|
explicitly excludes audio acquisition and source checks.
|
||||||
- derives the party glossary and resolves the remaining named collections through
|
- derives the party glossary and resolves the remaining named collections through
|
||||||
`internal/glossary`; writes four individual shared envelopes and a combined
|
`internal/glossary`; writes four individual shared envelopes and a combined
|
||||||
envelope with checksums, sizes, and provenance. The combined record declares
|
envelope with checksums, sizes, and provenance. The combined record declares
|
||||||
@@ -54,6 +56,8 @@ Materialize canonical current-session inputs before processing stages.
|
|||||||
- collects `narratio.previous_session.artifact.*` requirements from the selected
|
- collects `narratio.previous_session.artifact.*` requirements from the selected
|
||||||
targets and their full prerequisite closure, including disabled prerequisites;
|
targets and their full prerequisite closure, including disabled prerequisites;
|
||||||
see [previous requirement collection](artifacts.md#previous-requirement-collection).
|
see [previous requirement collection](artifacts.md#previous-requirement-collection).
|
||||||
|
Bounded reference preparation uses the actual projected generation keys,
|
||||||
|
preserving history needed by new work while excluding reused products' history.
|
||||||
- clears managed `inputs/previous/` state on every invocation, then, when requirements exist:
|
- clears managed `inputs/previous/` state on every invocation, then, when requirements exist:
|
||||||
- resolves the pointer-selected previous source through the shared resolver;
|
- resolves the pointer-selected previous source through the shared resolver;
|
||||||
- downloads declared previous artifacts;
|
- downloads declared previous artifacts;
|
||||||
|
|||||||
@@ -51,7 +51,16 @@ inputs for independent supplied products, contrary to the agreed import model.
|
|||||||
|
|
||||||
## 2. P2: Permit downstream continuation without a supplied transcript
|
## 2. P2: Permit downstream continuation without a supplied transcript
|
||||||
|
|
||||||
Status: Open
|
Status: Complete
|
||||||
|
|
||||||
|
Resolution: bounded import continuation checks actual consumer inputs rather
|
||||||
|
than requiring transcript-producer statuses. Reference-only acquisition and
|
||||||
|
reuse exclude audio checks and collect history for projected generation work.
|
||||||
|
The import context survives replacement of its last supplied product by a local
|
||||||
|
checkpoint. Regressions cover configured and extraction inputs, required
|
||||||
|
references, absent real inputs, historical-input exclusion, and local reuse
|
||||||
|
after an actual import/replacement. Verified with
|
||||||
|
`go test ./internal/app ./internal/stage ./internal/artifacts ./internal/config`.
|
||||||
|
|
||||||
Affected stages: 5, 7, and 12.
|
Affected stages: 5, 7, and 12.
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,20 @@ func validateBoundedPrerequisites(plan BoundedPlan, m *manifest.Manifest, cfg *c
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
coverage := suppliedCompletion(cfg, m)
|
coverage := suppliedCompletion(cfg, m)
|
||||||
hasTranscript := coverage["transcribe"]
|
supplied := hasSuppliedBaseline(m)
|
||||||
for _, name := range plan.PrefixNames() {
|
for _, name := range plan.PrefixNames() {
|
||||||
if coverage[name] || (hasTranscript && (name == "prepare" || name == "render" || name == "extract")) {
|
if coverage[name] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if supplied {
|
||||||
|
// Imported products replace producer history as the starting point.
|
||||||
|
// Selected consumers validate their actual inputs. Publication and
|
||||||
|
// post-publication actions retain their own execution prerequisites.
|
||||||
|
switch name {
|
||||||
|
case "prepare", "transcribe", "merge", "polish", "normalize", "trim", "render", "extract", "analyze":
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
status := "absent"
|
status := "absent"
|
||||||
if m != nil && m.Stages != nil && m.Stages[name] != nil {
|
if m != nil && m.Stages != nil && m.Stages[name] != nil {
|
||||||
stageStatus := m.Stages[name].Status
|
stageStatus := m.Stages[name].Status
|
||||||
|
|||||||
@@ -119,9 +119,13 @@ func buildSessionPlan(ctx context.Context, cfg *config.Config, input *executionI
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
report := &sessionPlanReport{Campaign: config.CampaignID(cfg.Campaign), SessionID: cfg.Session.SessionID, Stages: []plannedStage{}, Publication: []plannedPublication{}}
|
report := &sessionPlanReport{Campaign: config.CampaignID(cfg.Campaign), SessionID: cfg.Session.SessionID, Stages: []plannedStage{}, Publication: []plannedPublication{}}
|
||||||
if m != nil && !input.plan.Contains("prepare") && suppliedCompletion(cfg, m)["transcribe"] && projectionNeedsReferences(projection) {
|
if m != nil && !input.plan.Contains("prepare") && hasSuppliedBaseline(m) && projectionNeedsReferences(projection) {
|
||||||
report.ReferencePreparation = &preparationAssessment{Outcome: "planned", Reason: "reference-only preparation before downstream work"}
|
report.ReferencePreparation = &preparationAssessment{Outcome: "planned", Reason: "reference-only preparation before downstream work"}
|
||||||
current, checkErr := referencePreparationCurrent(ctx, cfg, m, store, effective)
|
requirements, requirementErr := referenceHistoryRequirements(cfg, effective, projection)
|
||||||
|
if requirementErr != nil {
|
||||||
|
return report, requirementErr
|
||||||
|
}
|
||||||
|
current, checkErr := referencePreparationCurrent(ctx, cfg, m, store, effective, requirements)
|
||||||
if checkErr != nil {
|
if checkErr != nil {
|
||||||
return report, checkErr
|
return report, checkErr
|
||||||
}
|
}
|
||||||
@@ -133,10 +137,6 @@ func buildSessionPlan(ctx context.Context, cfg *config.Config, input *executionI
|
|||||||
report.ReferencePreparation.Outcome = "blocked"
|
report.ReferencePreparation.Outcome = "blocked"
|
||||||
report.ReferencePreparation.Reason = validationErr.Error()
|
report.ReferencePreparation.Reason = validationErr.Error()
|
||||||
}
|
}
|
||||||
requirements, requirementErr := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective)
|
|
||||||
if requirementErr != nil {
|
|
||||||
return report, requirementErr
|
|
||||||
}
|
|
||||||
if strings.TrimSpace(cfg.Session.PreviousSessionID) == "" {
|
if strings.TrimSpace(cfg.Session.PreviousSessionID) == "" {
|
||||||
for _, requirement := range requirements {
|
for _, requirement := range requirements {
|
||||||
if requirement.Required {
|
if requirement.Required {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
// unavailablePlannedBuiltIns reports selected real inputs that neither exist
|
// unavailablePlannedBuiltIns reports selected real inputs that neither exist
|
||||||
// nor have a producer scheduled by this projection.
|
// nor have a producer scheduled by this projection.
|
||||||
func unavailablePlannedBuiltIns(cfg *config.Config, m *manifest.Manifest, projection *workProjection) []string {
|
func unavailablePlannedBuiltIns(cfg *config.Config, m *manifest.Manifest, projection *workProjection) []string {
|
||||||
if cfg == nil || cfg.Pipeline == nil || cfg.Session == nil || m == nil || !suppliedCompletion(cfg, m)["transcribe"] {
|
if cfg == nil || cfg.Pipeline == nil || cfg.Session == nil || !hasSuppliedBaseline(m) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
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)
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// prepareBoundedReferences makes current references available before downstream
|
// prepareBoundedReferences makes current references available before downstream
|
||||||
// checks when a supplied transcript replaces the normal preparation prefix.
|
// checks when supplied products replace the normal preparation prefix.
|
||||||
func prepareBoundedReferences(runtime *invocationRuntime) error {
|
func prepareBoundedReferences(runtime *invocationRuntime) error {
|
||||||
if runtime.plan.Contains("prepare") || !suppliedCompletion(runtime.cfg, runtime.manifest)["transcribe"] {
|
if runtime.plan.Contains("prepare") || !hasSuppliedBaseline(runtime.manifest) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !stagesContainAny(runtime.stages, "polish", "trim", "extract", "analyze") {
|
if !stagesContainAny(runtime.stages, "polish", "trim", "extract", "analyze") {
|
||||||
@@ -34,17 +34,19 @@ func prepareBoundedReferences(runtime *invocationRuntime) error {
|
|||||||
}
|
}
|
||||||
env := *runtime.env
|
env := *runtime.env
|
||||||
env.Force = false
|
env.Force = false
|
||||||
current, err := referencePreparationCurrent(runtime.ctx, runtime.cfg, runtime.manifest, runtime.artifactStore, runtime.effectiveArtifacts)
|
env.ReferenceOnly = true
|
||||||
|
requirements, err := referenceHistoryRequirements(runtime.cfg, runtime.effectiveArtifacts, projection)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("reference preparation requirements: %w", err)
|
||||||
|
}
|
||||||
|
env.PreparePreviousRequirements = requirements
|
||||||
|
current, err := referencePreparationCurrent(runtime.ctx, runtime.cfg, runtime.manifest, runtime.artifactStore, runtime.effectiveArtifacts, requirements)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if current {
|
if current {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
requirements, err := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(runtime.cfg), runtime.effectiveArtifacts)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("reference preparation requirements: %w", err)
|
|
||||||
}
|
|
||||||
if len(requirements) > 0 && strings.TrimSpace(runtime.cfg.Session.PreviousSessionID) != "" && runtime.env.ObjectStore == nil {
|
if len(requirements) > 0 && strings.TrimSpace(runtime.cfg.Session.PreviousSessionID) != "" && runtime.env.ObjectStore == nil {
|
||||||
runtime.env.ObjectStore, err = runtime.dependencies.newObjectStore(runtime.ctx, runtime.cfg)
|
runtime.env.ObjectStore, err = runtime.dependencies.newObjectStore(runtime.ctx, runtime.cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -52,7 +54,9 @@ func prepareBoundedReferences(runtime *invocationRuntime) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
priorInputs := append([]manifest.InputRecord(nil), runtime.manifest.Inputs...)
|
priorInputs := append([]manifest.InputRecord(nil), runtime.manifest.Inputs...)
|
||||||
result, err := stage.PrepareReferences(runtime.ctx, runtime.env, runtime.manifest)
|
// Preserve any lazily composed history store on the reference environment.
|
||||||
|
env.ObjectStore = runtime.env.ObjectStore
|
||||||
|
result, err := stage.PrepareReferences(runtime.ctx, &env, runtime.manifest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare references: %w", err)
|
return fmt.Errorf("prepare references: %w", err)
|
||||||
}
|
}
|
||||||
@@ -75,7 +79,7 @@ func prepareBoundedReferences(runtime *invocationRuntime) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *manifest.Manifest, store artifacts.Store, effective artifacts.EffectiveArtifactSet) (bool, error) {
|
func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *manifest.Manifest, store artifacts.Store, effective artifacts.EffectiveArtifactSet, requirements []artifacts.PreviousArtifactRequirement) (bool, error) {
|
||||||
if recordedStageStatus(m, "prepare") != manifest.StatusSucceeded {
|
if recordedStageStatus(m, "prepare") != manifest.StatusSucceeded {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@@ -83,7 +87,7 @@ func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *man
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
env := &stage.Env{Config: cfg, ArtifactStore: store, EffectiveArtifacts: effective}
|
env := &stage.Env{Config: cfg, ArtifactStore: store, EffectiveArtifacts: effective, ReferenceOnly: true, PreparePreviousRequirements: requirements}
|
||||||
semantic, err := currentStageSemanticConfig(prepare, env)
|
semantic, err := currentStageSemanticConfig(prepare, env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -95,6 +99,28 @@ func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *man
|
|||||||
return validation != nil && validation.Resumable, nil
|
return validation != nil && validation.Resumable, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func referenceHistoryRequirements(cfg *config.Config, effective artifacts.EffectiveArtifactSet, projection *workProjection) ([]artifacts.PreviousArtifactRequirement, error) {
|
||||||
|
var keys []string
|
||||||
|
for _, item := range projection.Stages {
|
||||||
|
if item.Name != "analyze" || item.Decision.action != stageActionRun {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if item.Analysis == nil {
|
||||||
|
return artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective)
|
||||||
|
}
|
||||||
|
for _, work := range item.Analysis.ExecutionOrder {
|
||||||
|
keys = append(keys, work.Key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requirements, err := artifacts.PreviousArtifactRequirementsForKeys(configuredScriptoriumArtifacts(cfg), keys)
|
||||||
|
// An explicit empty set distinguishes no planned history from the ordinary
|
||||||
|
// preparation default, which collects the full structural target closure.
|
||||||
|
if requirements == nil {
|
||||||
|
requirements = []artifacts.PreviousArtifactRequirement{}
|
||||||
|
}
|
||||||
|
return requirements, err
|
||||||
|
}
|
||||||
|
|
||||||
func projectionNeedsReferences(projection *workProjection) bool {
|
func projectionNeedsReferences(projection *workProjection) bool {
|
||||||
needsReferences := false
|
needsReferences := false
|
||||||
for _, item := range projection.Stages {
|
for _, item := range projection.Stages {
|
||||||
|
|||||||
@@ -83,6 +83,160 @@ func TestBoundedAnalysisPreparesReferencesForSuppliedTranscript(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBoundedAnalysisConsumesSuppliedProductsWithoutTranscripts(t *testing.T) {
|
||||||
|
for _, extraction := range []bool{false, true} {
|
||||||
|
name := "configured artifact"
|
||||||
|
if extraction {
|
||||||
|
name = "extraction product"
|
||||||
|
}
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
pipeline, campaign, session := writeValidConfigFilesWithScriptoriumArtifacts(t, t.TempDir())
|
||||||
|
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
cfg.Session.Inputs.AudioDir = ""
|
||||||
|
cfg.Session.Inputs.AudioFiles = nil
|
||||||
|
cfg.Session.Inputs.AudioS3 = nil
|
||||||
|
source, relative, body := artifacts.ConfiguredArtifactSourceID("parent"), "artifacts/parent.md", "supplied parent\n"
|
||||||
|
cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{
|
||||||
|
"parent": {PromptID: "parent", OutputPath: relative, Inputs: map[string]config.ScriptoriumInputConfig{
|
||||||
|
"old_history": {Source: artifactpolicy.PreviousSessionSourceID("parent"), Required: true},
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
if extraction {
|
||||||
|
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.ArtifactCatalog.Artifacts["child"] = config.ScriptoriumArtifactConfig{
|
||||||
|
Enabled: true, PromptID: "child", OutputPath: "artifacts/child.md",
|
||||||
|
Inputs: map[string]config.ScriptoriumInputConfig{
|
||||||
|
"parent": {Source: source, Required: true},
|
||||||
|
"party": {Source: artifactpolicy.SourceInputParty, Required: true},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if !extraction {
|
||||||
|
child := cfg.ArtifactCatalog.Artifacts["child"]
|
||||||
|
child.DependsOn = []string{"parent"}
|
||||||
|
cfg.ArtifactCatalog.Artifacts["child"] = child
|
||||||
|
}
|
||||||
|
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||||
|
path := filepath.Join(paths.Root, relative)
|
||||||
|
mustWriteTestFile(t, path, body)
|
||||||
|
sum, err := artifacts.SHA256File(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
m := manifest.New(cfg.Session.SessionID, time.Now().UTC())
|
||||||
|
m.Campaign = cfg.Session.Campaign
|
||||||
|
m.SuppliedProducts = &manifest.SuppliedProductCollection{Version: manifest.SuppliedProductVersion, Products: map[string]manifest.SuppliedProduct{
|
||||||
|
source: {Path: relative, Checksum: sum, Size: int64(len(body))},
|
||||||
|
}}
|
||||||
|
saveBoundedManifest(t, cfg, m)
|
||||||
|
plan := mustBoundedPlan(t, "analyze", "analyze")
|
||||||
|
effective, err := resolveEffectiveArtifacts(cfg, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
preview, err := buildSessionPlan(ctx, cfg, &executionInput{plan: plan}, nil, effective, commandDependencies{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(preview.InputIssues) != 0 || preview.ReferencePreparation == nil || preview.ReferencePreparation.Outcome != "planned" {
|
||||||
|
t.Fatalf("preview %+v", preview)
|
||||||
|
}
|
||||||
|
if len(preview.Stages) != 1 || len(preview.Stages[0].Analysis.Execute) != 1 || preview.Stages[0].Analysis.Execute[0].Key != "child" {
|
||||||
|
t.Fatalf("analysis preview %+v", preview.Stages)
|
||||||
|
}
|
||||||
|
if _, err := os.Stat(filepath.Join(paths.InputsDir, "party.yml")); !os.IsNotExist(err) {
|
||||||
|
t.Fatalf("plan wrote references: %v", err)
|
||||||
|
}
|
||||||
|
runner := &scriptorium.FakeRunner{}
|
||||||
|
result, err := executePlan(ctx, cfg, plan, RunOptions{Env: &Env{Scriptorium: runner}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(runner.RunRequests) != 1 || runner.RunRequests[0].InputPaths["parent"] != path || runner.RunRequests[0].InputPaths["party"] != filepath.Join(paths.InputsDir, "party.yml") {
|
||||||
|
t.Fatalf("requests %+v", runner.RunRequests)
|
||||||
|
}
|
||||||
|
saved, err := (&manifest.LocalStore{}).Load(ctx, result.ManifestPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if saved.Stages["prepare"].Metadata["audio_prepared"] != false || saved.Stages["transcribe"] != nil || saved.Stages["extract"] != nil {
|
||||||
|
t.Fatalf("fabricated producer evidence: %+v", saved.Stages)
|
||||||
|
}
|
||||||
|
if current, err := referencePreparationCurrent(ctx, cfg, saved, artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root), effective, []artifacts.PreviousArtifactRequirement{}); err != nil || !current {
|
||||||
|
t.Fatalf("reference-only reuse = %v, %v", current, err)
|
||||||
|
}
|
||||||
|
// Available imported inputs do not substitute for another required file.
|
||||||
|
child := cfg.ArtifactCatalog.Artifacts["child"]
|
||||||
|
child.Inputs["missing"] = config.ScriptoriumInputConfig{Source: artifacts.ArtifactTranscriptFinalTrimmed, Required: true}
|
||||||
|
cfg.ArtifactCatalog.Artifacts["child"] = child
|
||||||
|
input := &executionInput{plan: plan}
|
||||||
|
input.Force.Value = true
|
||||||
|
preview, err = buildSessionPlan(ctx, cfg, input, nil, effective, commandDependencies{})
|
||||||
|
if err != nil || preview == nil || !strings.Contains(strings.Join(preview.InputIssues, " "), artifacts.ArtifactTranscriptFinalTrimmed) {
|
||||||
|
t.Fatalf("missing actual input preview %+v, %v", preview, err)
|
||||||
|
}
|
||||||
|
if _, err := executePlan(ctx, cfg, plan, RunOptions{Force: true, Env: &Env{Scriptorium: runner}}); err == nil || !strings.Contains(err.Error(), artifacts.ArtifactTranscriptFinalTrimmed) {
|
||||||
|
t.Fatalf("missing actual input error = %v", err)
|
||||||
|
}
|
||||||
|
if len(runner.RunRequests) != 1 {
|
||||||
|
t.Fatal("generated output despite missing required input")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBoundedAnalysisContinuesAfterLastSuppliedProductIsReplaced(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
pipeline, campaign, session := writeValidConfigFilesWithScriptoriumArtifacts(t, t.TempDir())
|
||||||
|
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
cfg.Session.Inputs.AudioDir = ""
|
||||||
|
cfg.ArtifactCatalog.Artifacts = map[string]config.ScriptoriumArtifactConfig{
|
||||||
|
"session_recap": {Enabled: true, PromptID: "recap", OutputPath: "artifacts/session_recap.md", Inputs: map[string]config.ScriptoriumInputConfig{
|
||||||
|
"party": {Source: artifactpolicy.SourceInputParty, Required: true},
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
remote := &storage.FakeBackend{}
|
||||||
|
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 {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
plan := mustBoundedPlan(t, "analyze", "analyze")
|
||||||
|
runner := &scriptorium.FakeRunner{}
|
||||||
|
result, err := executePlan(ctx, cfg, plan, RunOptions{Force: true, Env: &Env{Scriptorium: runner}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
saved, err := (&manifest.LocalStore{}).Load(ctx, result.ManifestPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(saved.SuppliedProducts.Products) != 0 || saved.Stages["transcribe"] != nil {
|
||||||
|
t.Fatalf("replacement baseline %+v", saved)
|
||||||
|
}
|
||||||
|
effective, err := resolveEffectiveArtifacts(cfg, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
preview, err := buildSessionPlan(ctx, cfg, &executionInput{plan: plan}, nil, effective, commandDependencies{})
|
||||||
|
if err != nil || preview == nil || len(preview.InputIssues) != 0 || len(preview.Stages[0].Analysis.Execute) != 0 {
|
||||||
|
t.Fatalf("local checkpoint preview %+v, %v", preview, err)
|
||||||
|
}
|
||||||
|
if _, err := executePlan(ctx, cfg, plan, RunOptions{Env: &Env{Scriptorium: runner}}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(runner.RunRequests) != 1 {
|
||||||
|
t.Fatalf("ordinary continuation regenerated a local checkpoint: %+v", runner.RunRequests)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFullRunWithSuppliedTranscriptPreparesAndRendersSelectedVariant(t *testing.T) {
|
func TestFullRunWithSuppliedTranscriptPreparesAndRendersSelectedVariant(t *testing.T) {
|
||||||
root := t.TempDir()
|
root := t.TempDir()
|
||||||
pipeline, campaign, session := writeValidConfigFilesWithScriptoriumArtifacts(t, root)
|
pipeline, campaign, session := writeValidConfigFilesWithScriptoriumArtifacts(t, root)
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ func suppliedCompletion(cfg *config.Config, m *manifest.Manifest) map[string]boo
|
|||||||
return covered
|
return covered
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hasSuppliedBaseline identifies an import context, including after its supplied
|
||||||
|
// products become local checkpoints. It grants no product availability or stage
|
||||||
|
// completion: selected consumers still resolve and validate their actual inputs.
|
||||||
|
func hasSuppliedBaseline(m *manifest.Manifest) bool {
|
||||||
|
return m != nil && m.SuppliedProducts != nil && manifest.ValidateSuppliedProducts(m.SuppliedProducts) == nil
|
||||||
|
}
|
||||||
|
|
||||||
// retireSuppliedForAttempt prevents older supplied completion from returning
|
// retireSuppliedForAttempt prevents older supplied completion from returning
|
||||||
// after a selected producer begins replacement work.
|
// after a selected producer begins replacement work.
|
||||||
func retireSuppliedForAttempt(cfg *config.Config, m *manifest.Manifest, name string) {
|
func retireSuppliedForAttempt(cfg *config.Config, m *manifest.Manifest, name string) {
|
||||||
|
|||||||
@@ -30,11 +30,23 @@ func CollectPreviousArtifactRequirements(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sort.Strings(artifactNames)
|
return PreviousArtifactRequirementsForKeys(artifactsCfg, artifactNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreviousArtifactRequirementsForKeys collects history for an already planned
|
||||||
|
// set of generation work. It does not expand historical dependencies of reused
|
||||||
|
// products. Structural prerequisite collection uses the wrapper above.
|
||||||
|
func PreviousArtifactRequirementsForKeys(
|
||||||
|
artifactsCfg map[string]config.ScriptoriumArtifactConfig,
|
||||||
|
artifactNames []string,
|
||||||
|
) ([]PreviousArtifactRequirement, error) {
|
||||||
byName := map[string]PreviousArtifactRequirement{}
|
byName := map[string]PreviousArtifactRequirement{}
|
||||||
|
|
||||||
for _, artifactName := range artifactNames {
|
for _, artifactName := range artifactNames {
|
||||||
artifactCfg := artifactsCfg[artifactName]
|
artifactCfg, ok := artifactsCfg[artifactName]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("analysis artifact %q is not configured", artifactName)
|
||||||
|
}
|
||||||
|
|
||||||
inputNames := sortedScriptoriumInputKeys(artifactCfg.Inputs)
|
inputNames := sortedScriptoriumInputKeys(artifactCfg.Inputs)
|
||||||
for _, inputName := range inputNames {
|
for _, inputName := range inputNames {
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ func PrepareReferences(ctx context.Context, env *Env, m *manifest.Manifest) (*St
|
|||||||
}
|
}
|
||||||
|
|
||||||
func prepareNeedsAudio(env *Env, m *manifest.Manifest) bool {
|
func prepareNeedsAudio(env *Env, m *manifest.Manifest) bool {
|
||||||
|
if env != nil && env.ReferenceOnly {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if env == nil || env.Config == nil || env.Config.Session == nil || env.ArtifactStore == nil || m == nil || env.Force {
|
if env == nil || env.Config == nil || env.Config.Session == nil || env.ArtifactStore == nil || m == nil || env.Force {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -241,7 +244,7 @@ func prepareInputs(ctx context.Context, env *Env, m *manifest.Manifest, acquireA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
previousRequirements, err := collectPreparePreviousRequirements(env.Config, env.EffectiveArtifacts)
|
previousRequirements, err := preparePreviousRequirements(env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("prepare: resolve previous artifact requirements: %w", err)
|
return nil, fmt.Errorf("prepare: resolve previous artifact requirements: %w", err)
|
||||||
}
|
}
|
||||||
@@ -441,6 +444,13 @@ func countAudioInputs(inputs []manifest.InputRecord) int {
|
|||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func preparePreviousRequirements(env *Env) ([]artifacts.PreviousArtifactRequirement, error) {
|
||||||
|
if env.PreparePreviousRequirements != nil {
|
||||||
|
return env.PreparePreviousRequirements, nil
|
||||||
|
}
|
||||||
|
return collectPreparePreviousRequirements(env.Config, env.EffectiveArtifacts)
|
||||||
|
}
|
||||||
|
|
||||||
func collectPreparePreviousRequirements(cfg *config.Config, effective artifacts.EffectiveArtifactSet) ([]artifacts.PreviousArtifactRequirement, error) {
|
func collectPreparePreviousRequirements(cfg *config.Config, effective artifacts.EffectiveArtifactSet) ([]artifacts.PreviousArtifactRequirement, error) {
|
||||||
if cfg == nil || cfg.Pipeline == nil || cfg.Pipeline.Scriptorium == nil {
|
if cfg == nil || cfg.Pipeline == nil || cfg.Pipeline.Scriptorium == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func ValidateReferenceSources(ctx context.Context, env *Env, m *manifest.Manifes
|
|||||||
}
|
}
|
||||||
copyEnv := *env
|
copyEnv := *env
|
||||||
copyEnv.Force = false
|
copyEnv.Force = false
|
||||||
|
copyEnv.ReferenceOnly = true
|
||||||
_, err := currentPrepareSourceInputs(ctx, ©Env, m)
|
_, err := currentPrepareSourceInputs(ctx, ©Env, m)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func buildPrepareSemanticConfig(env *Env) (prepareSemanticConfig, error) {
|
|||||||
return prepareSemanticConfig{}, fmt.Errorf("prepare semantic configuration requires resolved pipeline and session config")
|
return prepareSemanticConfig{}, fmt.Errorf("prepare semantic configuration requires resolved pipeline and session config")
|
||||||
}
|
}
|
||||||
cfg := env.Config
|
cfg := env.Config
|
||||||
requirements, err := collectPreparePreviousRequirements(cfg, env.EffectiveArtifacts)
|
requirements, err := preparePreviousRequirements(env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return prepareSemanticConfig{}, fmt.Errorf("resolve previous artifact requirements: %w", err)
|
return prepareSemanticConfig{}, fmt.Errorf("resolve previous artifact requirements: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ type Env struct {
|
|||||||
ManifestStore manifest.Store
|
ManifestStore manifest.Store
|
||||||
Reporter logging.Reporter
|
Reporter logging.Reporter
|
||||||
Force bool
|
Force bool
|
||||||
|
ReferenceOnly bool // Preparation checks and materialization exclude audio.
|
||||||
|
// Nil uses the selection's structural prerequisite closure. Bounded reference
|
||||||
|
// preparation supplies the history needed by its actual generation plan.
|
||||||
|
PreparePreviousRequirements []artifacts.PreviousArtifactRequirement
|
||||||
|
|
||||||
WhisperX whisperx.Client
|
WhisperX whisperx.Client
|
||||||
Seriatim seriatim.Runner
|
Seriatim seriatim.Runner
|
||||||
|
|||||||
Reference in New Issue
Block a user