Separate Notarius invocation from extraction product promotion
This commit is contained in:
@@ -12,7 +12,9 @@ pipeline, cache, validation and completion protocol; see the
|
|||||||
|
|
||||||
Disabled extraction records a skip. An execution resolves manifest-backed input
|
Disabled extraction records a skip. An execution resolves manifest-backed input
|
||||||
identities, creates immutable content-addressed reference snapshots, and invokes
|
identities, creates immutable content-addressed reference snapshots, and invokes
|
||||||
Notarius with run-local output, log and debug destinations. The adapter accepts a
|
Notarius with run-local output, log and debug destinations. Execution and
|
||||||
|
readiness share resolved binary, configuration, credential, timeout and cache
|
||||||
|
options while retaining their own input and diagnostic paths. The adapter accepts a
|
||||||
successful native completion report for the expected pipeline and confined output
|
successful native completion report for the expected pipeline and confined output
|
||||||
directory. The stage reads each configured lane JSON, validates its safe path and
|
directory. The stage reads each configured lane JSON, validates its safe path and
|
||||||
content, then promotes all required products to flat artifact paths before
|
content, then promotes all required products to flat artifact paths before
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ Validation: `go test ./internal/adapters/notarius ./internal/stage ./internal/ap
|
|||||||
|
|
||||||
## Stage 17: Separate Extraction Invocation And Product Acceptance
|
## Stage 17: Separate Extraction Invocation And Product Acceptance
|
||||||
|
|
||||||
CAT IDs: CAT-24, extraction half. Status: Pending.
|
CAT IDs: CAT-24, extraction half. Status: Complete.
|
||||||
|
|
||||||
Read [CX-03](audit/03-complexity.md#cx-03--p3-trim-and-extraction-mix-invocation-mechanics-with-product-acceptance).
|
Read [CX-03](audit/03-complexity.md#cx-03--p3-trim-and-extraction-mix-invocation-mechanics-with-product-acceptance).
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
||||||
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
|
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
|
||||||
@@ -76,102 +75,26 @@ func (extractStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (re
|
|||||||
return nil, fmt.Errorf("extract: run id %q is not a safe path segment", runID)
|
return nil, fmt.Errorf("extract: run id %q is not a safe path segment", runID)
|
||||||
}
|
}
|
||||||
|
|
||||||
paths := sessionPathsForEnv(env, sessionID)
|
invocation, err := prepareExtractionInvocation(env, m, notariusConfig, sessionID, campaign, runID)
|
||||||
input, err := artifacts.ResolveExtractionInputIdentity(paths, m)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("extract: resolve final-trimmed transcript identity: %w", err)
|
return nil, err
|
||||||
}
|
|
||||||
references, err := resolveExtractReferences(paths, m, notariusConfig, sessionID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve Notarius references: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout, err := time.ParseDuration(strings.TrimSpace(notariusConfig.Timeout))
|
|
||||||
if err != nil || timeout <= 0 {
|
|
||||||
return nil, fmt.Errorf("extract: invalid notarius timeout %q", notariusConfig.Timeout)
|
|
||||||
}
|
|
||||||
resolvedBinary, err := notarius.ResolveExecutable(notariusConfig.Binary)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve notarius binary: %w", err)
|
|
||||||
}
|
|
||||||
configPath, err := absolutePath(notariusConfig.ConfigPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve notarius config path: %w", err)
|
|
||||||
}
|
|
||||||
inputPath := input.Path
|
|
||||||
workingDirectory, err := absolutePath(notariusConfig.WorkingDirectory)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve notarius working directory: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
workspaceRoot := strings.TrimSpace(paths.WorkspaceRoot)
|
|
||||||
if workspaceRoot == "" {
|
|
||||||
workspaceRoot = env.Config.Pipeline.Workspace.Root
|
|
||||||
}
|
|
||||||
reportPath, err := absolutePath(artifacts.SessionRunNotariusReportPathForCampaign(workspaceRoot, campaign, sessionID, runID))
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve completion report path: %w", err)
|
|
||||||
}
|
|
||||||
logPath, err := absolutePath(artifacts.SessionRunNotariusLogPathForCampaign(workspaceRoot, campaign, sessionID, runID))
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve stderr path: %w", err)
|
|
||||||
}
|
|
||||||
outputRoot, err := absolutePath(artifacts.SessionRunNotariusOutputRootForCampaign(workspaceRoot, campaign, sessionID, runID))
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve output root: %w", err)
|
|
||||||
}
|
|
||||||
directories := []string{filepath.Dir(reportPath), outputRoot}
|
|
||||||
for _, directory := range directories {
|
|
||||||
if err := fileops.EnsureWorkspaceDirectory(directory); err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: create directory %q: %w", directory, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
referenceBindings, err := materializeExtractReferenceSnapshots(paths, references)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: materialize Notarius reference snapshots: %w", err)
|
|
||||||
}
|
|
||||||
fingerprint, err := extractionFingerprint(notariusConfig, input, references.Identities)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: build configuration fingerprint: %w", err)
|
|
||||||
}
|
|
||||||
cache := notariusConfig.Cache
|
|
||||||
if env.Force {
|
|
||||||
refresh := "refresh"
|
|
||||||
cache = &refresh
|
|
||||||
}
|
|
||||||
debugDirectory, err := absolutePath(artifacts.SessionRunDebugDir(paths, runID, "extract"))
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: resolve debug directory: %w", err)
|
|
||||||
}
|
|
||||||
request := notarius.RunRequest{
|
|
||||||
Binary: resolvedBinary, Credentials: notariusConfig.Credentials, ConfigOverlay: notariusConfig.ConfigOverlay,
|
|
||||||
ConfigPath: configPath, PipelineID: notariusConfig.PipelineID,
|
|
||||||
InputPath: inputPath, OutputRoot: outputRoot, WorkingDirectory: workingDirectory,
|
|
||||||
ReportPath: reportPath, LogPath: logPath, Timeout: timeout, Cache: cache,
|
|
||||||
Debug: notariusConfig.Debug, DebugDirectory: debugDirectory, References: referenceBindings,
|
|
||||||
}
|
|
||||||
// Producer files remain inspectable even when completion delivery fails.
|
// Producer files remain inspectable even when completion delivery fails.
|
||||||
// Only Narratio's temporary promotion copies are cleaned below.
|
// Only Narratio's temporary promotion copies are cleaned below.
|
||||||
adapterResult, err := env.Notarius.Run(ctx, request)
|
adapterResult, err := env.Notarius.Run(ctx, invocation.request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("extract: run notarius: %w", err)
|
return nil, fmt.Errorf("extract: run notarius: %w", err)
|
||||||
}
|
}
|
||||||
report := adapterResult.Report
|
accepted, err := acceptExtractionBundle(adapterResult, invocation.request.OutputRoot, notariusConfig.PipelineID)
|
||||||
bundle := filepath.Clean(adapterResult.BundleRoot)
|
if err != nil {
|
||||||
if report.Pipeline != notariusConfig.PipelineID || report.ArtifactCount < 0 || report.FallbackCount < 0 ||
|
|
||||||
!filepath.IsAbs(bundle) || filepath.Clean(report.OutputDirectory) != bundle {
|
|
||||||
return nil, fmt.Errorf("extract: notarius completion report is missing or incompatible")
|
|
||||||
}
|
|
||||||
if err := validateExtractBundleRoot(outputRoot, bundle); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := normalizeNotariusBundle(bundle); err != nil {
|
if err := verifyExtractReferenceSnapshots(invocation.paths, invocation.references); err != nil {
|
||||||
return nil, fmt.Errorf("extract: validate Notarius bundle: %w", err)
|
|
||||||
}
|
|
||||||
if err := verifyExtractReferenceSnapshots(paths, references); err != nil {
|
|
||||||
return nil, fmt.Errorf("extract: verify Notarius reference snapshots: %w", err)
|
return nil, fmt.Errorf("extract: verify Notarius reference snapshots: %w", err)
|
||||||
}
|
}
|
||||||
staging, err := os.MkdirTemp(filepath.Dir(outputRoot), ".products-")
|
|
||||||
|
staging, err := os.MkdirTemp(filepath.Dir(invocation.request.OutputRoot), ".products-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("extract: create product staging directory: %w", err)
|
return nil, fmt.Errorf("extract: create product staging directory: %w", err)
|
||||||
}
|
}
|
||||||
@@ -180,10 +103,119 @@ func (extractStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (re
|
|||||||
resultErr = errors.Join(resultErr, fmt.Errorf("extract: remove staged products: %w", cleanupErr))
|
resultErr = errors.Join(resultErr, fmt.Errorf("extract: remove staged products: %w", cleanupErr))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
selected, err := stageRequiredNotariusLanes(bundle, staging, notariusConfig.Outputs)
|
selected, err := stageRequiredNotariusLanes(accepted.bundle, staging, notariusConfig.Outputs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
outputs, err := promoteExtractionProducts(invocation.paths, sessionID, accepted.report.Pipeline, selected)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
report, bundle := accepted.report, accepted.bundle
|
||||||
|
|
||||||
|
if report.FallbackCount > 0 {
|
||||||
|
env.Warn(fmt.Sprintf("Notarius completed with %d fallback operations", report.FallbackCount))
|
||||||
|
}
|
||||||
|
metadataReferences := invocation.references.Identities
|
||||||
|
if len(metadataReferences) > config.MaxNotariusReferenceBindings {
|
||||||
|
metadataReferences = metadataReferences[:config.MaxNotariusReferenceBindings]
|
||||||
|
}
|
||||||
|
metadata := map[string]any{"stage": "extract", "notarius_enabled": true, "bundle_root": bundle, "diagnostic_path": invocation.request.LogPath}
|
||||||
|
for key, value := range artifacts.EncodeExtractionMetadata(artifacts.ExtractionMetadata{
|
||||||
|
RunID: runID, ConfigurationFingerprint: invocation.fingerprint, Input: invocation.input, References: metadataReferences, ReferenceCount: len(invocation.references.Identities),
|
||||||
|
Completion: artifacts.ExtractionCompletion{Pipeline: report.Pipeline, ArtifactCount: report.ArtifactCount, OutputDirectory: bundle, DebugDirectory: report.DebugDirectory, FallbackCount: report.FallbackCount},
|
||||||
|
}) {
|
||||||
|
metadata[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &StageResult{Outputs: outputs, Logs: []string{invocation.request.ReportPath, invocation.request.LogPath}, Metadata: metadata}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type extractInvocation struct {
|
||||||
|
paths artifacts.SessionPaths
|
||||||
|
input artifacts.ExtractionInputIdentity
|
||||||
|
references resolvedExtractReferences
|
||||||
|
fingerprint string
|
||||||
|
request notarius.RunRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
func prepareExtractionInvocation(env *Env, m *manifest.Manifest, notariusConfig *config.NotariusConfig, sessionID, campaign, runID string) (extractInvocation, error) {
|
||||||
|
paths := sessionPathsForEnv(env, sessionID)
|
||||||
|
input, err := artifacts.ResolveExtractionInputIdentity(paths, m)
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: resolve final-trimmed transcript identity: %w", err)
|
||||||
|
}
|
||||||
|
references, err := resolveExtractReferences(paths, m, notariusConfig, sessionID)
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: resolve Notarius references: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
options, err := resolveNotariusOptions(notariusConfig, env.Force)
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaceRoot := strings.TrimSpace(paths.WorkspaceRoot)
|
||||||
|
if workspaceRoot == "" {
|
||||||
|
workspaceRoot = env.Config.Pipeline.Workspace.Root
|
||||||
|
}
|
||||||
|
reportPath, err := absolutePath(artifacts.SessionRunNotariusReportPathForCampaign(workspaceRoot, campaign, sessionID, runID))
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: resolve completion report path: %w", err)
|
||||||
|
}
|
||||||
|
logPath, err := absolutePath(artifacts.SessionRunNotariusLogPathForCampaign(workspaceRoot, campaign, sessionID, runID))
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: resolve stderr path: %w", err)
|
||||||
|
}
|
||||||
|
outputRoot, err := absolutePath(artifacts.SessionRunNotariusOutputRootForCampaign(workspaceRoot, campaign, sessionID, runID))
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: resolve output root: %w", err)
|
||||||
|
}
|
||||||
|
directories := []string{filepath.Dir(reportPath), outputRoot}
|
||||||
|
for _, directory := range directories {
|
||||||
|
if err := fileops.EnsureWorkspaceDirectory(directory); err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: create directory %q: %w", directory, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
referenceBindings, err := materializeExtractReferenceSnapshots(paths, references)
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: materialize Notarius reference snapshots: %w", err)
|
||||||
|
}
|
||||||
|
fingerprint, err := extractionFingerprint(notariusConfig, input, references.Identities)
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: build configuration fingerprint: %w", err)
|
||||||
|
}
|
||||||
|
debugDirectory, err := absolutePath(artifacts.SessionRunDebugDir(paths, runID, "extract"))
|
||||||
|
if err != nil {
|
||||||
|
return extractInvocation{}, fmt.Errorf("extract: resolve debug directory: %w", err)
|
||||||
|
}
|
||||||
|
request := options.request(input.Path, outputRoot, reportPath, logPath, debugDirectory, referenceBindings)
|
||||||
|
|
||||||
|
return extractInvocation{paths: paths, input: input, references: references, fingerprint: fingerprint, request: request}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type acceptedExtractionBundle struct {
|
||||||
|
report notarius.CompletionReport
|
||||||
|
bundle string
|
||||||
|
}
|
||||||
|
|
||||||
|
func acceptExtractionBundle(result notarius.RunResult, outputRoot, pipelineID string) (acceptedExtractionBundle, error) {
|
||||||
|
report := result.Report
|
||||||
|
bundle := filepath.Clean(result.BundleRoot)
|
||||||
|
if report.Pipeline != pipelineID || report.ArtifactCount < 0 || report.FallbackCount < 0 || !filepath.IsAbs(bundle) || filepath.Clean(report.OutputDirectory) != bundle {
|
||||||
|
return acceptedExtractionBundle{}, fmt.Errorf("extract: notarius completion report is missing or incompatible")
|
||||||
|
}
|
||||||
|
if err := validateExtractBundleRoot(outputRoot, bundle); err != nil {
|
||||||
|
return acceptedExtractionBundle{}, err
|
||||||
|
}
|
||||||
|
if err := normalizeNotariusBundle(bundle); err != nil {
|
||||||
|
return acceptedExtractionBundle{}, fmt.Errorf("extract: validate Notarius bundle: %w", err)
|
||||||
|
}
|
||||||
|
return acceptedExtractionBundle{report: report, bundle: bundle}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func promoteExtractionProducts(paths artifacts.SessionPaths, sessionID, pipelineID string, selected []stagedNotariusLane) ([]artifacts.Ref, error) {
|
||||||
root, err := absolutePath(paths.Root)
|
root, err := absolutePath(paths.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("extract: resolve session root: %w", err)
|
return nil, fmt.Errorf("extract: resolve session root: %w", err)
|
||||||
@@ -213,26 +245,10 @@ func (extractStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (re
|
|||||||
Kind: extractLaneOutputKind, SourceID: artifacts.ExtractionArtifactSourceID(lane.Key),
|
Kind: extractLaneOutputKind, SourceID: artifacts.ExtractionArtifactSourceID(lane.Key),
|
||||||
Category: "artifacts", SessionID: sessionID, RelativePath: filepath.ToSlash(filepath.Join("artifacts", lane.Filename)),
|
Category: "artifacts", SessionID: sessionID, RelativePath: filepath.ToSlash(filepath.Join("artifacts", lane.Filename)),
|
||||||
AbsolutePath: destination, Checksum: checksum, Size: lane.Size,
|
AbsolutePath: destination, Checksum: checksum, Size: lane.Size,
|
||||||
ExternalProvenance: &artifactmodel.ExternalProvenance{System: "notarius", PipelineID: report.Pipeline, ArtifactID: lane.LaneID},
|
ExternalProvenance: &artifactmodel.ExternalProvenance{System: "notarius", PipelineID: pipelineID, ArtifactID: lane.LaneID},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if report.FallbackCount > 0 {
|
return outputs, nil
|
||||||
env.Warn(fmt.Sprintf("Notarius completed with %d fallback operations", report.FallbackCount))
|
|
||||||
}
|
|
||||||
metadataReferences := references.Identities
|
|
||||||
if len(metadataReferences) > config.MaxNotariusReferenceBindings {
|
|
||||||
metadataReferences = metadataReferences[:config.MaxNotariusReferenceBindings]
|
|
||||||
}
|
|
||||||
metadata := map[string]any{"stage": "extract", "notarius_enabled": true, "bundle_root": bundle, "diagnostic_path": logPath}
|
|
||||||
for key, value := range artifacts.EncodeExtractionMetadata(artifacts.ExtractionMetadata{
|
|
||||||
RunID: runID, ConfigurationFingerprint: fingerprint, Input: input, References: metadataReferences, ReferenceCount: len(references.Identities),
|
|
||||||
Completion: artifacts.ExtractionCompletion{Pipeline: report.Pipeline, ArtifactCount: report.ArtifactCount, OutputDirectory: bundle, DebugDirectory: report.DebugDirectory, FallbackCount: report.FallbackCount},
|
|
||||||
}) {
|
|
||||||
metadata[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
result = &StageResult{Outputs: outputs, Logs: []string{reportPath, logPath}, Metadata: metadata}
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeNotariusBundle(root string) error {
|
func normalizeNotariusBundle(root string) error {
|
||||||
|
|||||||
48
internal/stage/extract_options.go
Normal file
48
internal/stage/extract_options.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package stage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
||||||
|
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||||
|
configkit "go.maximumdirect.net/configkit"
|
||||||
|
)
|
||||||
|
|
||||||
|
type resolvedNotariusOptions struct {
|
||||||
|
binary, configPath, workingDirectory, pipelineID string
|
||||||
|
timeout time.Duration
|
||||||
|
credentials []configkit.Secret
|
||||||
|
overlay, cache *string
|
||||||
|
debug bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func resolveNotariusOptions(cfg *config.NotariusConfig, force bool) (resolvedNotariusOptions, error) {
|
||||||
|
timeout, err := time.ParseDuration(strings.TrimSpace(cfg.Timeout))
|
||||||
|
if err != nil || timeout <= 0 {
|
||||||
|
return resolvedNotariusOptions{}, fmt.Errorf("invalid Notarius timeout %q", cfg.Timeout)
|
||||||
|
}
|
||||||
|
binary, err := notarius.ResolveExecutable(cfg.Binary)
|
||||||
|
if err != nil {
|
||||||
|
return resolvedNotariusOptions{}, fmt.Errorf("resolve Notarius binary: %w", err)
|
||||||
|
}
|
||||||
|
configPath, err := absolutePath(cfg.ConfigPath)
|
||||||
|
if err != nil {
|
||||||
|
return resolvedNotariusOptions{}, fmt.Errorf("resolve Notarius config path: %w", err)
|
||||||
|
}
|
||||||
|
working, err := absolutePath(cfg.WorkingDirectory)
|
||||||
|
if err != nil {
|
||||||
|
return resolvedNotariusOptions{}, fmt.Errorf("resolve Notarius working directory: %w", err)
|
||||||
|
}
|
||||||
|
cache := cfg.Cache
|
||||||
|
if force {
|
||||||
|
refresh := "refresh"
|
||||||
|
cache = &refresh
|
||||||
|
}
|
||||||
|
return resolvedNotariusOptions{binary: binary, configPath: configPath, workingDirectory: working, pipelineID: cfg.PipelineID, timeout: timeout, credentials: cfg.Credentials, overlay: cfg.ConfigOverlay, cache: cache, debug: cfg.Debug}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o resolvedNotariusOptions) request(input, output, report, log, debug string, references []notarius.ReferenceBinding) notarius.RunRequest {
|
||||||
|
return notarius.RunRequest{Binary: o.binary, Credentials: o.credentials, ConfigOverlay: o.overlay, ConfigPath: o.configPath, PipelineID: o.pipelineID, InputPath: input, OutputRoot: output, WorkingDirectory: o.workingDirectory, ReportPath: report, LogPath: log, Timeout: o.timeout, Cache: o.cache, Debug: o.debug, DebugDirectory: debug, References: references}
|
||||||
|
}
|
||||||
@@ -4,8 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
||||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
||||||
@@ -63,37 +61,19 @@ func BuildNotariusReadiness(cfg *config.Config, paths artifacts.SessionPaths, m
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return NotariusReadiness{}, err
|
return NotariusReadiness{}, err
|
||||||
}
|
}
|
||||||
binary, err := notarius.ResolveExecutable(n.Binary)
|
options, err := resolveNotariusOptions(n, force)
|
||||||
if err != nil {
|
|
||||||
return NotariusReadiness{}, fmt.Errorf("resolve Notarius binary: %w", err)
|
|
||||||
}
|
|
||||||
configPath, err := absolutePath(n.ConfigPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return NotariusReadiness{}, err
|
return NotariusReadiness{}, err
|
||||||
}
|
}
|
||||||
working, err := absolutePath(n.WorkingDirectory)
|
|
||||||
if err != nil {
|
|
||||||
return NotariusReadiness{}, err
|
|
||||||
}
|
|
||||||
timeout, err := time.ParseDuration(strings.TrimSpace(n.Timeout))
|
|
||||||
if err != nil || timeout <= 0 {
|
|
||||||
return NotariusReadiness{}, fmt.Errorf("invalid Notarius timeout %q", n.Timeout)
|
|
||||||
}
|
|
||||||
cache := n.Cache
|
|
||||||
if force {
|
|
||||||
refresh := "refresh"
|
|
||||||
cache = &refresh
|
|
||||||
}
|
|
||||||
lanes := make([]string, 0, len(n.Outputs))
|
lanes := make([]string, 0, len(n.Outputs))
|
||||||
for _, output := range n.Outputs {
|
for _, output := range n.Outputs {
|
||||||
lanes = append(lanes, output.LaneID)
|
lanes = append(lanes, output.LaneID)
|
||||||
}
|
}
|
||||||
sort.Strings(lanes)
|
sort.Strings(lanes)
|
||||||
request := notarius.ReadinessRequest{RunRequest: notarius.RunRequest{
|
request := notarius.ReadinessRequest{
|
||||||
Binary: binary, Credentials: n.Credentials, ConfigOverlay: n.ConfigOverlay, ConfigPath: configPath,
|
RunRequest: options.request(transcript, output, filepath.Join(logs, "assessment.json"), filepath.Join(logs, "preflight.stderr.log"), debug, bindings),
|
||||||
PipelineID: n.PipelineID, InputPath: transcript, OutputRoot: output, WorkingDirectory: working,
|
RequiredLanes: lanes, InputDescription: description, InspectionPath: filepath.Join(logs, "pipeline.json"), InspectionLogPath: filepath.Join(logs, "pipeline.stderr.log"),
|
||||||
ReportPath: filepath.Join(logs, "assessment.json"), LogPath: filepath.Join(logs, "preflight.stderr.log"),
|
}
|
||||||
Timeout: timeout, Cache: cache, Debug: n.Debug, DebugDirectory: debug, References: bindings,
|
|
||||||
}, RequiredLanes: lanes, InputDescription: description, InspectionPath: filepath.Join(logs, "pipeline.json"), InspectionLogPath: filepath.Join(logs, "pipeline.stderr.log")}
|
|
||||||
return NotariusReadiness{Request: request, paths: paths, references: references}, nil
|
return NotariusReadiness{Request: request, paths: paths, references: references}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user