Add native Notarius readiness checks
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
@@ -19,6 +20,7 @@ type commandDependencies struct {
|
||||
newObjectStore func(context.Context, *config.Config) (storage.ObjectStore, error)
|
||||
newScriptorium func() scriptorium.Runner
|
||||
newAudita func(*config.Config) (audita.Runner, error)
|
||||
newNotarius func() notarius.Runner
|
||||
discoverRemoteCurrentState func(context.Context, *config.Config, storage.ObjectStore) (*RemoteCurrentState, error)
|
||||
buildRestorePlan func(context.Context, *config.Config, *RemoteCurrentState, storage.ObjectStore, RestorePlanOptions) (*RestorePlan, error)
|
||||
executeRestorePlan func(context.Context, *config.Config, *RemoteCurrentState, *RestorePlan, *RestoreReport, storage.ObjectStore) (*RestoreExecutionResult, error)
|
||||
@@ -39,6 +41,9 @@ func normalizeCommandDependencies(deps commandDependencies) commandDependencies
|
||||
if deps.newAudita == nil {
|
||||
deps.newAudita = buildDefaultAuditaRunner
|
||||
}
|
||||
if deps.newNotarius == nil {
|
||||
deps.newNotarius = func() notarius.Runner { return notarius.NewSubprocessRunner() }
|
||||
}
|
||||
if deps.newScriptorium == nil {
|
||||
deps.newScriptorium = defaultScriptoriumRunner
|
||||
}
|
||||
|
||||
168
internal/app/notarius_preflight_test.go
Normal file
168
internal/app/notarius_preflight_test.go
Normal file
@@ -0,0 +1,168 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/stage"
|
||||
)
|
||||
|
||||
func configureNotariusProbe(t *testing.T, cfg *config.Config) {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
binary := filepath.Join(dir, "notarius")
|
||||
path := filepath.Join(dir, "config.yml")
|
||||
if err := os.WriteFile(binary, []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte("pipelines: {}\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg.Pipeline.Notarius = &config.NotariusConfig{Enabled: true, Binary: binary, ConfigPath: path, PipelineID: "campaign", WorkingDirectory: dir, Timeout: "1m", Outputs: map[string]config.NotariusOutputConfig{"events": {LaneID: "events"}}}
|
||||
}
|
||||
|
||||
func TestSessionValidationUsesPreparedNotariusProbeWithoutChangingManifest(t *testing.T) {
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
configureNotariusProbe(t, cfg)
|
||||
paths := seedValidationPrepared(t, cfg)
|
||||
before, err := os.ReadFile(paths.ManifestPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
native := ¬arius.FakeRunner{PreflightResult: ¬arius.ReadinessResult{Pipeline: "campaign", Lanes: []string{"events"}, InspectionComplete: true, AssessmentComplete: true, Ready: true, Checks: []notarius.ReadinessCheck{{ID: "cache", Result: "warning", Message: "cache inaccessible"}}}}
|
||||
deps := fakeCommandDependencies(&storage.FakeBackend{}, nil)
|
||||
deps.newAudita = func(*config.Config) (audita.Runner, error) { return &audita.FakeRunner{}, nil }
|
||||
deps.newNotarius = func() notarius.Runner { return native }
|
||||
report, err := inspectSessionValidation(context.Background(), cfg, deps)
|
||||
if err != nil || !report.Valid || len(native.PreflightRequests) != 1 {
|
||||
t.Fatalf("report=%#v requests=%#v err=%v", report, native.PreflightRequests, err)
|
||||
}
|
||||
request := native.PreflightRequests[0]
|
||||
if !strings.Contains(request.InputDescription, "synthetic") || !strings.HasPrefix(request.OutputRoot, artifacts.SessionValidationNotariusDir(paths)) {
|
||||
t.Fatalf("probe = %#v", request)
|
||||
}
|
||||
if !findingMatches(report.Findings, "INFO", "notarius", "synthetic transcript") {
|
||||
t.Fatalf("findings = %#v", report.Findings)
|
||||
}
|
||||
if !findingMatches(report.Findings, "WARN", "notarius", "cache inaccessible") {
|
||||
t.Fatalf("cache warning missing: %#v", report.Findings)
|
||||
}
|
||||
after, err := os.ReadFile(paths.ManifestPath)
|
||||
if err != nil || !bytes.Equal(before, after) {
|
||||
t.Fatalf("manifest changed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusPreflightFollowsPrepareAndSkipsReusedWork(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
configureNotariusProbe(t, cfg)
|
||||
var prepared, extracted int
|
||||
failure := errors.New("synthetic provider failure")
|
||||
native := ¬arius.FakeRunner{PreflightErr: failure}
|
||||
selected := []stage.Stage{preparationFixture{runs: &prepared}, countingStage{name: "extract", runs: &extracted}}
|
||||
summary, err := executeStages(context.Background(), cfg, selected, RunOptions{Env: &Env{Notarius: native}})
|
||||
if !errors.Is(err, failure) || summary == nil || prepared != 1 || extracted != 0 || len(native.PreflightRequests) != 1 {
|
||||
t.Fatalf("summary=%#v prepared=%d extracted=%d requests=%d err=%v", summary, prepared, extracted, len(native.PreflightRequests), err)
|
||||
}
|
||||
stored, err := (&manifest.LocalStore{}).Load(context.Background(), summary.ManifestPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if stored.Stages["prepare"] == nil || stored.Stages["prepare"].Status != manifest.StatusSucceeded || stored.Stages["extract"] != nil {
|
||||
t.Fatalf("stages = %#v", stored.Stages)
|
||||
}
|
||||
request := native.PreflightRequests[0]
|
||||
if !strings.Contains(request.InputDescription, "synthetic") || !strings.Contains(request.OutputRoot, filepath.Join("runs", ".preflight")) {
|
||||
t.Fatalf("request = %#v", request)
|
||||
}
|
||||
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
for _, view := range []string{artifacts.SessionLatestLogsPath(paths, "extract"), artifacts.SessionLatestDebugPath(paths, "extract")} {
|
||||
if _, err := os.Lstat(view); !os.IsNotExist(err) {
|
||||
t.Fatalf("probe changed latest view %q: %v", view, err)
|
||||
}
|
||||
}
|
||||
native.PreflightErr = nil
|
||||
summary, err = executeStages(context.Background(), cfg, selected, RunOptions{Env: &Env{Notarius: native}})
|
||||
if err != nil || prepared != 1 || extracted != 1 || summary.StageResults[0].Outcome != "reused" {
|
||||
t.Fatalf("retry=%#v prepared=%d extracted=%d err=%v", summary, prepared, extracted, err)
|
||||
}
|
||||
_, err = executeStages(context.Background(), cfg, selected, RunOptions{Env: &Env{Notarius: native}})
|
||||
if err != nil || len(native.PreflightRequests) != 2 || extracted != 1 {
|
||||
t.Fatalf("reuse calls=%d extracted=%d err=%v", len(native.PreflightRequests), extracted, err)
|
||||
}
|
||||
initialized := 0
|
||||
deps := invocationDependencies{newNotarius: func() notarius.Runner { initialized++; return ¬arius.FakeRunner{} }}
|
||||
_, err = executePlanWithDependencies(context.Background(), cfg, BoundedPlan{stages: selected}, RunOptions{}, deps)
|
||||
if err != nil || initialized != 0 {
|
||||
t.Fatalf("reused work initialized Notarius %d times: %v", initialized, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnrelatedWorkDoesNotInitializeNotarius(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
configureNotariusProbe(t, cfg)
|
||||
initialized, attempts := 0, 0
|
||||
deps := invocationDependencies{newNotarius: func() notarius.Runner { initialized++; return ¬arius.FakeRunner{} }}
|
||||
_, err := executePlanWithDependencies(context.Background(), cfg, BoundedPlan{stages: []stage.Stage{countingStage{name: "prepare", runs: &attempts}}}, RunOptions{}, deps)
|
||||
if err != nil || initialized != 0 || attempts != 1 {
|
||||
t.Fatalf("initialized=%d attempts=%d error=%v", initialized, attempts, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestForcedNotariusPreflightUsesRefresh(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
configureNotariusProbe(t, cfg)
|
||||
cache := "bypass"
|
||||
cfg.Pipeline.Notarius.Cache = &cache
|
||||
native := ¬arius.FakeRunner{}
|
||||
var attempts int
|
||||
_, err := executeStages(context.Background(), cfg, []stage.Stage{countingStage{name: "extract", runs: &attempts}}, RunOptions{Force: true, Env: &Env{Notarius: native}})
|
||||
if err != nil || attempts != 1 || len(native.PreflightRequests) != 1 || native.PreflightRequests[0].Cache == nil || *native.PreflightRequests[0].Cache != "refresh" {
|
||||
t.Fatalf("requests=%#v attempts=%d err=%v", native.PreflightRequests, attempts, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusPreflightFailurePreservesCompletedExtraction(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
configureNotariusProbe(t, cfg)
|
||||
store := &manifest.LocalStore{}
|
||||
seed := manifest.New(cfg.Session.SessionID, time.Now().UTC())
|
||||
seed.Campaign = cfg.Session.Campaign
|
||||
seed.MarkStageSucceeded("extract", time.Now().UTC(), nil)
|
||||
seed.Stages["extract"].Metadata = map[string]any{"prior": "retained"}
|
||||
if err := store.Save(context.Background(), manifestPathFor(cfg), seed); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
before, err := store.Load(context.Background(), manifestPathFor(cfg))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
failure := errors.New("notarius provider unavailable")
|
||||
native := ¬arius.FakeRunner{PreflightErr: failure}
|
||||
var attempts int
|
||||
summary, err := executeStages(context.Background(), cfg, []stage.Stage{countingStage{name: "extract", runs: &attempts}}, RunOptions{Force: true, Env: &Env{Notarius: native}})
|
||||
if !errors.Is(err, failure) || summary == nil || attempts != 0 || summary.StageResults[0].Attempted {
|
||||
t.Fatalf("summary=%#v attempts=%d error=%v", summary, attempts, err)
|
||||
}
|
||||
after, err := store.Load(context.Background(), manifestPathFor(cfg))
|
||||
if err != nil || !reflect.DeepEqual(before.Stages["extract"], after.Stages["extract"]) {
|
||||
t.Fatalf("completed extraction changed: before=%#v after=%#v error=%v", before.Stages["extract"], after.Stages["extract"], err)
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,9 @@ func executionDownstreamTargets(cfg *config.Config, sessionID string, projection
|
||||
if item.Name == "polish" && item.Decision.action == stageActionRun {
|
||||
result.Polish = true
|
||||
}
|
||||
if item.Name == "extract" && item.Decision.action == stageActionRun && cfg.Pipeline.Notarius != nil && cfg.Pipeline.Notarius.Enabled {
|
||||
result.Notarius = true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -102,5 +105,5 @@ func validationDownstreamTargets(cfg *config.Config, sessionID string) (prefligh
|
||||
return preflight.Targets{}, err
|
||||
}
|
||||
// Polish is a canonical pipeline stage and has no enable/disable setting.
|
||||
return preflight.Targets{Polish: true, Scriptorium: targets}, nil
|
||||
return preflight.Targets{Polish: true, Notarius: cfg.Pipeline.Notarius != nil && cfg.Pipeline.Notarius.Enabled, Scriptorium: targets}, nil
|
||||
}
|
||||
|
||||
@@ -151,3 +151,51 @@ func TestDownstreamTargetSelectionForPolish(t *testing.T) {
|
||||
t.Fatalf("validation targets: %+v %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownstreamTargetSelectionForNotarius(t *testing.T) {
|
||||
cfg := &config.Config{Pipeline: &config.PipelineConfig{Notarius: &config.NotariusConfig{Enabled: true}}}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
stages []projectedStage
|
||||
want bool
|
||||
}{
|
||||
{"selected", []projectedStage{{Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, true},
|
||||
{"reused", []projectedStage{{Name: "extract", Decision: preExecutionDecision{action: stageActionSkip}}}, false},
|
||||
{"unrelated", []projectedStage{{Name: "analyze", Decision: preExecutionDecision{action: stageActionRun}}}, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got, err := executionDownstreamTargets(cfg, "session", &workProjection{Stages: tc.stages})
|
||||
if err != nil || got.Notarius != tc.want {
|
||||
t.Fatalf("targets = %#v, %v", got, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
got, err := validationDownstreamTargets(cfg, "session")
|
||||
if err != nil || !got.Notarius {
|
||||
t.Fatalf("validation targets = %#v, %v", got, err)
|
||||
}
|
||||
cfg.Pipeline.Notarius.Enabled = false
|
||||
got, err = validationDownstreamTargets(cfg, "session")
|
||||
if err != nil || got.Notarius {
|
||||
t.Fatalf("disabled targets = %#v, %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusPreflightUsesCurrentTranscriptOnlyWhenUpstreamIsReused(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
stages []projectedStage
|
||||
want bool
|
||||
}{
|
||||
{"extract only", []projectedStage{{Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, true},
|
||||
{"reused trim", []projectedStage{{Name: "trim", Decision: preExecutionDecision{action: stageActionSkip}}, {Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, true},
|
||||
{"running trim", []projectedStage{{Name: "trim", Decision: preExecutionDecision{action: stageActionRun}}, {Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, false},
|
||||
{"running polish", []projectedStage{{Name: "polish", Decision: preExecutionDecision{action: stageActionRun}}, {Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := currentTranscriptUsableForNotarius(&workProjection{Stages: tc.stages}); got != tc.want {
|
||||
t.Fatalf("got %v, want %v", got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
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"
|
||||
)
|
||||
|
||||
func inspectInvocationRequirements(runtime *invocationRuntime, start int) error {
|
||||
if !stagesContainAny(runtime.stages[start:], "polish", "trim", "analyze") {
|
||||
if !stagesContainAny(runtime.stages[start:], "polish", "trim", "extract", "analyze") {
|
||||
return nil
|
||||
}
|
||||
remaining := runtime.plan
|
||||
@@ -23,7 +26,7 @@ func inspectInvocationRequirements(runtime *invocationRuntime, start int) error
|
||||
if err != nil {
|
||||
return fmt.Errorf("select downstream preflight targets: %w", err)
|
||||
}
|
||||
if !targets.Polish && len(targets.Scriptorium) == 0 {
|
||||
if !targets.Polish && !targets.Notarius && len(targets.Scriptorium) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(targets.Scriptorium) > 0 && runtime.env.Scriptorium == nil {
|
||||
@@ -44,7 +47,7 @@ func inspectInvocationRequirements(runtime *invocationRuntime, start int) error
|
||||
if !ok || checker == nil {
|
||||
return fmt.Errorf("audita runner does not support preflight")
|
||||
}
|
||||
root := filepath.Join(runtime.identity.LocalWorkDir, "polish")
|
||||
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 {
|
||||
@@ -52,9 +55,36 @@ func inspectInvocationRequirements(runtime *invocationRuntime, start int) error
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
for _, finding := range result.Findings {
|
||||
if finding.Severity == preflight.SeverityWarning {
|
||||
runtime.env.Warn(formatPromptFinding(finding), "stage", finding.Stage, "artifact", finding.Artifact, "prompt", finding.PromptID, "issue", finding.IssueCode, "input", finding.InputName, "variable", finding.VariableName)
|
||||
message := formatPromptFinding(finding)
|
||||
if finding.Stage == "extract" {
|
||||
message = "Notarius: " + finding.Message
|
||||
}
|
||||
runtime.env.Warn(message, "stage", finding.Stage, "artifact", finding.Artifact, "prompt", finding.PromptID, "issue", finding.IssueCode, "input", finding.InputName, "variable", finding.VariableName)
|
||||
} else if finding.Severity == preflight.SeverityInfo && finding.Stage == "extract" {
|
||||
runtime.env.Info(finding.Message)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -63,6 +93,18 @@ func inspectInvocationRequirements(runtime *invocationRuntime, start int) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func currentTranscriptUsableForNotarius(projection *workProjection) bool {
|
||||
for _, item := range projection.Stages {
|
||||
if item.Name == "extract" {
|
||||
break
|
||||
}
|
||||
if item.Decision.action == stageActionRun && (item.Name == "transcribe" || item.Name == "merge" || item.Name == "polish" || item.Name == "normalize" || item.Name == "trim") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func formatPromptFinding(item preflight.Finding) string {
|
||||
context := fmt.Sprintf("%s prompt %q", item.Stage, item.PromptID)
|
||||
if item.Artifact != "" {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
@@ -169,12 +170,58 @@ func inspectSessionValidation(ctx context.Context, cfg *config.Config, deps comm
|
||||
}
|
||||
}
|
||||
}
|
||||
var native notarius.ReadinessChecker
|
||||
var probe stage.NotariusReadiness
|
||||
if targets.Notarius {
|
||||
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
local, present, loadErr := loadManifestAtPathIfPresent(ctx, &manifest.LocalStore{}, paths.ManifestPath)
|
||||
switch {
|
||||
case loadErr != nil:
|
||||
fail("notarius", fmt.Errorf("load prepared manifest; run prepare: %w", loadErr))
|
||||
targets.Notarius = false
|
||||
case !present:
|
||||
fail("notarius", fmt.Errorf("prepared inputs are unavailable; run prepare"))
|
||||
targets.Notarius = false
|
||||
default:
|
||||
identityErr := (invocationIdentity{Campaign: cfg.Session.Campaign, SessionID: cfg.Session.SessionID}).validateSessionManifest(local)
|
||||
if identityErr != nil {
|
||||
fail("notarius", fmt.Errorf("prepared manifest is invalid; run prepare: %w", identityErr))
|
||||
targets.Notarius = false
|
||||
} else if local.Stages["prepare"] == nil || local.Stages["prepare"].Status != manifest.StatusSucceeded {
|
||||
fail("notarius", fmt.Errorf("prepared inputs are not current; run prepare"))
|
||||
targets.Notarius = false
|
||||
} else {
|
||||
probe, loadErr = stage.BuildNotariusReadiness(cfg, paths, local, artifacts.SessionValidationNotariusDir(paths), true, false)
|
||||
if loadErr != nil {
|
||||
fail("notarius", loadErr)
|
||||
targets.Notarius = false
|
||||
} else {
|
||||
var ok bool
|
||||
native, ok = deps.newNotarius().(notarius.ReadinessChecker)
|
||||
if !ok || native == nil {
|
||||
fail("notarius", fmt.Errorf("notarius runner does not support preflight"))
|
||||
targets.Notarius = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
checked, checkErr := preflight.CheckDownstream(ctx, inspector, checker, targets, request)
|
||||
if targets.Notarius && ctx.Err() == nil {
|
||||
nativeResult, nativeErr := preflight.CheckNotarius(ctx, native, probe.Request)
|
||||
checked.Findings = append(checked.Findings, nativeResult.Findings...)
|
||||
if verifyErr := probe.VerifyReferences(); verifyErr != nil {
|
||||
nativeErr = errors.Join(nativeErr, fmt.Errorf("verify Notarius probe references: %w", verifyErr))
|
||||
}
|
||||
checkErr = errors.Join(checkErr, nativeErr)
|
||||
}
|
||||
hasError := false
|
||||
for _, item := range checked.Findings {
|
||||
category, message := "scriptorium", formatPromptFinding(item)
|
||||
if item.Stage == "polish" {
|
||||
category, message = "audita", item.Message
|
||||
} else if item.Stage == "extract" {
|
||||
category, message = "notarius", item.Message
|
||||
}
|
||||
switch item.Severity {
|
||||
case preflight.SeverityError:
|
||||
|
||||
Reference in New Issue
Block a user