Index manifest input candidates within each operation
This commit is contained in:
@@ -37,6 +37,7 @@ type analyzeArtifactExecutionResult struct {
|
||||
}
|
||||
|
||||
type analyzeExecutionContext struct {
|
||||
InputLookup *artifacts.InputLookup
|
||||
Graph *artifactdeps.Graph
|
||||
Env *Env
|
||||
Manifest *manifest.Manifest
|
||||
@@ -124,6 +125,7 @@ func (analyzeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
|
||||
SessionID: sessionID,
|
||||
TranscriptRefs: discoverAnalyzeTranscriptRefs(m, paths),
|
||||
Catalog: runtimeCatalog,
|
||||
InputLookup: artifacts.NewInputLookup(paths, m),
|
||||
}
|
||||
reconciliation, err := reconcileAnalyzeArtifacts(scriptoriumCfg, execution)
|
||||
if err != nil {
|
||||
|
||||
@@ -131,6 +131,9 @@ func computeAnalyzeArtifactFingerprint(
|
||||
scriptoriumCfg *config.ScriptoriumConfig,
|
||||
execution analyzeExecutionContext,
|
||||
) (string, resolvedAnalyzeInputs, []analyzeDependencyOutputIdentity, error) {
|
||||
if execution.InputLookup == nil {
|
||||
execution.InputLookup = artifacts.NewInputLookup(execution.Paths, execution.Manifest)
|
||||
}
|
||||
artifactCfg, ok := artifactCfgMap(execution)[key]
|
||||
if !ok {
|
||||
return "", resolvedAnalyzeInputs{}, nil, fmt.Errorf("configured artifact %q is not defined", key)
|
||||
|
||||
@@ -75,6 +75,9 @@ func resolveAnalyzeInputIdentities(
|
||||
inputs map[string]config.ScriptoriumInputConfig,
|
||||
execution analyzeExecutionContext,
|
||||
) (resolvedAnalyzeInputs, error) {
|
||||
if execution.InputLookup == nil {
|
||||
execution.InputLookup = artifacts.NewInputLookup(execution.Paths, execution.Manifest)
|
||||
}
|
||||
result := resolvedAnalyzeInputs{
|
||||
Ordered: make([]analyzeInputIdentity, 0, len(inputs)),
|
||||
paths: make(map[string]string, len(inputs)),
|
||||
@@ -115,7 +118,7 @@ func resolveAnalyzeInputIdentity(
|
||||
}
|
||||
|
||||
if descriptor.Source.Kind == artifactpolicy.SourceKindStableInput {
|
||||
prepared, preparedErr := artifacts.ResolvePreparedInput(execution.Paths, execution.Manifest, descriptor.Source.ID)
|
||||
prepared, preparedErr := artifacts.ResolvePreparedInputWithLookup(execution.Paths, execution.InputLookup, descriptor.Source.ID)
|
||||
if preparedErr == nil {
|
||||
identity.Present = true
|
||||
identity.Checksum = prepared.Checksum
|
||||
@@ -143,8 +146,8 @@ func resolveAnalyzeInputIdentity(
|
||||
|
||||
var resolved artifacts.ResolvedSessionArtifact
|
||||
if descriptor.Source.Kind == artifactpolicy.SourceKindPreviousArtifact {
|
||||
resolved, err = artifacts.ResolvePreviousSessionArtifactWithCatalog(
|
||||
execution.Paths, execution.Manifest, descriptor.Source.ID, execution.Catalog,
|
||||
resolved, err = artifacts.ResolvePreviousSessionArtifactWithLookup(
|
||||
execution.Paths, execution.InputLookup, descriptor.Source.ID, execution.Catalog,
|
||||
)
|
||||
} else {
|
||||
resolved, err = artifacts.ResolveSessionArtifactWithCatalog(
|
||||
|
||||
@@ -54,6 +54,7 @@ func (analyzeStage) ValidateResume(_ context.Context, env *Env, m *manifest.Mani
|
||||
Graph: graph,
|
||||
Env: env, Manifest: m, Paths: paths, SessionID: sessionID,
|
||||
TranscriptRefs: discoverAnalyzeTranscriptRefs(m, paths), Catalog: catalog,
|
||||
InputLookup: artifacts.NewInputLookup(paths, m),
|
||||
}
|
||||
reconciliation, err := reconcileAnalyzeArtifacts(cfg, execution)
|
||||
if err != nil {
|
||||
|
||||
@@ -263,10 +263,11 @@ func resolveExtractReferences(
|
||||
Bindings: make([]notarius.ReferenceBinding, 0, len(configured)),
|
||||
Identities: make([]extractReferenceIdentity, 0, len(configured)),
|
||||
}
|
||||
lookup := artifacts.NewInputLookup(paths, m)
|
||||
for _, reference := range configured {
|
||||
selector := reference.selector
|
||||
sourceID := reference.sourceID
|
||||
identity, err := artifacts.ResolvePreparedInput(paths, m, sourceID)
|
||||
identity, err := artifacts.ResolvePreparedInputWithLookup(paths, lookup, sourceID)
|
||||
if err != nil {
|
||||
return resolvedExtractReferences{}, fmt.Errorf(
|
||||
"reference %q source %q is unavailable or invalid; run narratio run %s --stage prepare --force: %w",
|
||||
|
||||
@@ -37,8 +37,9 @@ func polishGlossaryEvidence(paths artifacts.SessionPaths, m *manifest.Manifest)
|
||||
Source, Checksum string
|
||||
Size int64
|
||||
}
|
||||
lookup := artifacts.NewInputLookup(paths, m)
|
||||
for _, descriptor := range artifactpolicy.GlossaryInputSources() {
|
||||
identity, err := artifacts.ResolvePreparedInput(paths, m, descriptor.SourceID)
|
||||
identity, err := artifacts.ResolvePreparedInputWithLookup(paths, lookup, descriptor.SourceID)
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("prepared glossary %s is unavailable or invalid; run prepare: %w", descriptor.SourceID, err)
|
||||
}
|
||||
|
||||
@@ -68,8 +68,9 @@ func (prepareStage) ValidateResume(ctx context.Context, env *Env, m *manifest.Ma
|
||||
return NonResumable(fmt.Sprintf("prepared sources could not be verified; rerun prepare: %v", err)), nil
|
||||
}
|
||||
paths := sessionPathsForEnv(env, m.SessionID)
|
||||
lookup := artifacts.NewInputLookup(paths, m)
|
||||
for _, source := range []string{artifactpolicy.SourceInputGlossaryParty, artifactpolicy.SourceInputGlossaryCampaign, artifactpolicy.SourceInputGlossarySetting, artifactpolicy.SourceInputGlossarySpells, artifactpolicy.SourceInputGlossaryCombined} {
|
||||
if _, err := artifacts.ResolvePreparedInput(paths, m, source); err != nil {
|
||||
if _, err := artifacts.ResolvePreparedInputWithLookup(paths, lookup, source); err != nil {
|
||||
return NonResumable(prepareResumeChangedReason), nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ func collectPublishPreparedInputs(store artifacts.Store, paths artifacts.Session
|
||||
filenames[combined.ManifestKind] = combined.Filename
|
||||
glossaries[combined.ManifestKind] = combined
|
||||
var result []publishUploadFile
|
||||
lookup := artifacts.NewInputLookup(paths, &manifest.Manifest{Inputs: records})
|
||||
seen := make(map[string]bool)
|
||||
for _, record := range records {
|
||||
name, ok := filenames[record.Kind]
|
||||
@@ -57,7 +58,7 @@ func collectPublishPreparedInputs(store artifacts.Store, paths artifacts.Session
|
||||
return nil, fmt.Errorf("prepared input %q lacks canonical path or checksum", record.Kind)
|
||||
}
|
||||
if descriptor, ok := glossaries[record.Kind]; ok {
|
||||
if _, err := artifacts.ResolvePreparedInput(paths, &manifest.Manifest{Inputs: records}, descriptor.SourceID); err != nil {
|
||||
if _, err := artifacts.ResolvePreparedInputWithLookup(paths, lookup, descriptor.SourceID); err != nil {
|
||||
return nil, fmt.Errorf("verify prepared glossary: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user