Add native Notarius readiness checks
This commit is contained in:
@@ -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