Share downstream readiness checks across invocations
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/preflight"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/stage"
|
||||
)
|
||||
@@ -29,53 +24,7 @@ func inspectInvocationRequirements(runtime *invocationRuntime, start int) error
|
||||
if !targets.Polish && !targets.Notarius && len(targets.Scriptorium) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(targets.Scriptorium) > 0 && runtime.env.Scriptorium == nil {
|
||||
runtime.env.Scriptorium = runtime.dependencies.newScriptorium()
|
||||
}
|
||||
var checker preflight.AuditaChecker
|
||||
var request audita.PolishRequest
|
||||
if targets.Polish {
|
||||
if runtime.env.Audita == nil {
|
||||
runner, err := runtime.dependencies.newAudita(runtime.cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("initialize audita runner: %w", err)
|
||||
}
|
||||
runtime.env.Audita = runner
|
||||
}
|
||||
var ok bool
|
||||
checker, ok = runtime.env.Audita.(preflight.AuditaChecker)
|
||||
if !ok || checker == nil {
|
||||
return fmt.Errorf("audita runner does not support preflight")
|
||||
}
|
||||
root := artifacts.SessionInvocationProbeDir(runtime.paths, runtime.identity.RunID, "audita")
|
||||
output := filepath.Join(root, "outputs", "transcripts", "polished.json")
|
||||
request, _, err = stage.BuildPolishRequest(runtime.paths, runtime.manifest, "", output, filepath.Join(root, "logs"), filepath.Join(root, "debug"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("build audita preflight: %w", err)
|
||||
}
|
||||
}
|
||||
result, err := preflight.CheckDownstream(runtime.ctx, runtime.env.Scriptorium, checker, targets, request)
|
||||
if err == nil && targets.Notarius {
|
||||
if runtime.env.Notarius == nil {
|
||||
runtime.env.Notarius = runtime.dependencies.newNotarius()
|
||||
}
|
||||
native, ok := runtime.env.Notarius.(notarius.ReadinessChecker)
|
||||
if !ok || native == nil {
|
||||
return fmt.Errorf("notarius runner does not support preflight")
|
||||
}
|
||||
useCurrent := currentTranscriptUsableForNotarius(projection)
|
||||
root := artifacts.SessionInvocationProbeDir(runtime.paths, runtime.identity.RunID, "notarius")
|
||||
probe, buildErr := stage.BuildNotariusReadiness(runtime.cfg, runtime.paths, runtime.manifest, root, useCurrent, runtime.opts.Force)
|
||||
if buildErr != nil {
|
||||
return fmt.Errorf("build notarius preflight: %w", buildErr)
|
||||
}
|
||||
checked, checkErr := preflight.CheckNotarius(runtime.ctx, native, probe.Request)
|
||||
result.Findings = append(result.Findings, checked.Findings...)
|
||||
if verifyErr := probe.VerifyReferences(); verifyErr != nil {
|
||||
checkErr = errors.Join(checkErr, fmt.Errorf("verify Notarius probe references: %w", verifyErr))
|
||||
}
|
||||
err = checkErr
|
||||
}
|
||||
result, err := checkDownstreamReadiness(runtime, targets, true, currentTranscriptUsableForNotarius(projection), runtime.opts.Force)
|
||||
for _, finding := range result.Findings {
|
||||
if finding.Severity == preflight.SeverityWarning {
|
||||
message := formatPromptFinding(finding)
|
||||
|
||||
Reference in New Issue
Block a user