Separate readiness checks from report presentation
This commit is contained in:
@@ -40,6 +40,8 @@ optional sources for required inputs, conditional requirements, incomplete
|
||||
discovery, and discovery issues produce warnings. Findings survive independent
|
||||
failures and cancellation stops new work. Each report is interpreted by a pure
|
||||
assessment; the surrounding loop owns provider calls and ordered failure handling.
|
||||
Tool-specific readiness operations retain initialized adapters on the invocation;
|
||||
preparation and transcript projection are assessed before report presentation.
|
||||
|
||||
Probe files use invocation-scoped destinations under `runs/`, protected by the
|
||||
workspace lock through report consumption, reference verification, and terminal
|
||||
|
||||
@@ -41,10 +41,10 @@ their scope. Unless assigned otherwise, a finding remains independent audit
|
||||
remediation. Shared code does not make a refactoring a prerequisite or assign
|
||||
the whole finding to a roadmap.
|
||||
|
||||
Thirty-six entries are closed by the safety, transfer, audio discovery, S3
|
||||
Thirty-seven entries are closed by the safety, transfer, audio discovery, S3
|
||||
planning, prerequisite-history, publication-import, CLI classification,
|
||||
inspection aggregation, test maintenance, dead-code removal, and associated
|
||||
documentation work; 7 remain open. **Planned** identifies
|
||||
documentation work; 6 remain open. **Planned** identifies
|
||||
an agreed remedy awaiting implementation. **Potentially eliminated** requires verification that the offending
|
||||
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
|
||||
that a related feature implements the entire finding. Findings close only after their
|
||||
@@ -725,7 +725,11 @@ Related: [CAT-23](#cat-23--p3-move-notarius-native-output-mapping-and-executable
|
||||
|
||||
### CAT-25 — P3: Separate inspection/readiness collection, assessment, and presentation
|
||||
|
||||
Status: Open
|
||||
Status: Closed
|
||||
|
||||
**Closure.** Prompt interpretation, session inspection collection, preparation
|
||||
assessment and tool readiness operations are separated from report projection.
|
||||
Preflight, app and stage tests cover partial failures and cancellation.
|
||||
|
||||
**Disposition / owner.** Coordinate — [publication import](../../internal/command-restore.md)
|
||||
supports inspection and readiness for supplied inputs. The broader separation of
|
||||
|
||||
@@ -573,7 +573,7 @@ Validation: `go test ./internal/app -run 'Test.*(Inspection|SessionState|Session
|
||||
|
||||
## Stage 21: Separate Readiness Operations And Presentation
|
||||
|
||||
CAT IDs: CAT-25, completion. Status: Pending.
|
||||
CAT IDs: CAT-25, completion. Status: Complete.
|
||||
|
||||
Read Stage 19's CX-04 section and `app/session_readiness.go`,
|
||||
`downstream_readiness.go`, `preflight_targets.go`, and preflight tests.
|
||||
|
||||
@@ -40,41 +40,14 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
|
||||
result.Checks = append(result.Checks, readinessCheck{Group: group, Outcome: "blocked", Message: "prepared inputs are unavailable"})
|
||||
}
|
||||
if len(targets.Scriptorium) > 0 && runtime.ctx.Err() == nil {
|
||||
runtime.env.Progress("checking prompt requirements")
|
||||
if runtime.env.Scriptorium == nil {
|
||||
runtime.env.Scriptorium = runtime.dependencies.newScriptorium()
|
||||
}
|
||||
checked, err := preflight.Check(runtime.ctx, runtime.env.Scriptorium, targets.Scriptorium)
|
||||
checked, err := checkScriptoriumReadiness(runtime, targets.Scriptorium)
|
||||
record("prompt requirements", checked, err)
|
||||
}
|
||||
if targets.Polish && runtime.ctx.Err() == nil {
|
||||
if !prepared {
|
||||
blocked("audita")
|
||||
} else {
|
||||
runtime.env.Progress("checking Audita readiness")
|
||||
var err error
|
||||
if runtime.env.Audita == nil {
|
||||
runtime.env.Audita, err = runtime.dependencies.newAudita(runtime.cfg)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("initialize audita runner: %w", err)
|
||||
}
|
||||
}
|
||||
var checked preflight.Result
|
||||
if err == nil {
|
||||
checker, ok := runtime.env.Audita.(preflight.AuditaChecker)
|
||||
if !ok || checker == nil {
|
||||
err = fmt.Errorf("audita runner does not support preflight")
|
||||
} else {
|
||||
root := artifacts.SessionInvocationProbeDir(runtime.paths, runtime.identity.RunID, "audita")
|
||||
request, _, buildErr := stage.BuildPolishRequest(runtime.paths, runtime.manifest, "", filepath.Join(root, "outputs", "transcripts", "polished.json"), filepath.Join(root, "logs"), filepath.Join(root, "debug"))
|
||||
if buildErr != nil {
|
||||
err = fmt.Errorf("build audita preflight: %w", buildErr)
|
||||
} else {
|
||||
checked, err = preflight.CheckAudita(runtime.ctx, checker, request)
|
||||
checked.Findings = append([]preflight.Finding{{Severity: preflight.SeverityInfo, Stage: "polish", Message: "Audita checks a synthetic transcript and may contact providers"}}, checked.Findings...)
|
||||
}
|
||||
}
|
||||
}
|
||||
checked, err := checkAuditaReadiness(runtime)
|
||||
record("audita", checked, err)
|
||||
}
|
||||
}
|
||||
@@ -82,29 +55,62 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
|
||||
if !prepared {
|
||||
blocked("notarius")
|
||||
} else {
|
||||
runtime.env.Progress("checking Notarius readiness")
|
||||
if runtime.env.Notarius == nil {
|
||||
runtime.env.Notarius = runtime.dependencies.newNotarius()
|
||||
}
|
||||
var checked preflight.Result
|
||||
var err error
|
||||
native, ok := runtime.env.Notarius.(notarius.ReadinessChecker)
|
||||
if !ok || native == nil {
|
||||
err = fmt.Errorf("notarius runner does not support preflight")
|
||||
} else {
|
||||
root := artifacts.SessionInvocationProbeDir(runtime.paths, runtime.identity.RunID, "notarius")
|
||||
probe, buildErr := stage.BuildNotariusReadiness(runtime.cfg, runtime.paths, runtime.manifest, root, useCurrent, force)
|
||||
if buildErr != nil {
|
||||
err = fmt.Errorf("build notarius preflight: %w", buildErr)
|
||||
} else {
|
||||
checked, err = preflight.CheckNotarius(runtime.ctx, native, probe.Request)
|
||||
if verifyErr := probe.VerifyReferences(); verifyErr != nil {
|
||||
err = errors.Join(err, fmt.Errorf("verify Notarius probe references: %w", verifyErr))
|
||||
}
|
||||
}
|
||||
}
|
||||
checked, err := checkNotariusReadiness(runtime, useCurrent, force)
|
||||
record("notarius", checked, err)
|
||||
}
|
||||
}
|
||||
|
||||
return result, errors.Join(append(failures, runtime.ctx.Err())...)
|
||||
}
|
||||
|
||||
func checkScriptoriumReadiness(runtime *invocationRuntime, targets []preflight.Target) (preflight.Result, error) {
|
||||
runtime.env.Progress("checking prompt requirements")
|
||||
if runtime.env.Scriptorium == nil {
|
||||
runtime.env.Scriptorium = runtime.dependencies.newScriptorium()
|
||||
}
|
||||
return preflight.Check(runtime.ctx, runtime.env.Scriptorium, targets)
|
||||
}
|
||||
|
||||
func checkAuditaReadiness(runtime *invocationRuntime) (preflight.Result, error) {
|
||||
runtime.env.Progress("checking Audita readiness")
|
||||
if runtime.env.Audita == nil {
|
||||
var err error
|
||||
runtime.env.Audita, err = runtime.dependencies.newAudita(runtime.cfg)
|
||||
if err != nil {
|
||||
return preflight.Result{}, fmt.Errorf("initialize audita runner: %w", err)
|
||||
}
|
||||
}
|
||||
checker, ok := runtime.env.Audita.(preflight.AuditaChecker)
|
||||
if !ok || checker == nil {
|
||||
return preflight.Result{}, fmt.Errorf("audita runner does not support preflight")
|
||||
}
|
||||
root := artifacts.SessionInvocationProbeDir(runtime.paths, runtime.identity.RunID, "audita")
|
||||
request, _, err := stage.BuildPolishRequest(runtime.paths, runtime.manifest, "", filepath.Join(root, "outputs", "transcripts", "polished.json"), filepath.Join(root, "logs"), filepath.Join(root, "debug"))
|
||||
if err != nil {
|
||||
return preflight.Result{}, fmt.Errorf("build audita preflight: %w", err)
|
||||
}
|
||||
checked, err := preflight.CheckAudita(runtime.ctx, checker, request)
|
||||
checked.Findings = append([]preflight.Finding{{Severity: preflight.SeverityInfo, Stage: "polish", Message: "Audita checks a synthetic transcript and may contact providers"}}, checked.Findings...)
|
||||
return checked, err
|
||||
}
|
||||
|
||||
func checkNotariusReadiness(runtime *invocationRuntime, useCurrent, force bool) (preflight.Result, error) {
|
||||
runtime.env.Progress("checking Notarius readiness")
|
||||
if runtime.env.Notarius == nil {
|
||||
runtime.env.Notarius = runtime.dependencies.newNotarius()
|
||||
}
|
||||
native, ok := runtime.env.Notarius.(notarius.ReadinessChecker)
|
||||
if !ok || native == nil {
|
||||
return preflight.Result{}, fmt.Errorf("notarius runner does not support preflight")
|
||||
}
|
||||
root := artifacts.SessionInvocationProbeDir(runtime.paths, runtime.identity.RunID, "notarius")
|
||||
probe, err := stage.BuildNotariusReadiness(runtime.cfg, runtime.paths, runtime.manifest, root, useCurrent, force)
|
||||
if err != nil {
|
||||
return preflight.Result{}, fmt.Errorf("build notarius preflight: %w", err)
|
||||
}
|
||||
checked, err := preflight.CheckNotarius(runtime.ctx, native, probe.Request)
|
||||
if verifyErr := probe.VerifyReferences(); verifyErr != nil {
|
||||
err = errors.Join(err, fmt.Errorf("verify Notarius probe references: %w", verifyErr))
|
||||
}
|
||||
return checked, err
|
||||
}
|
||||
|
||||
@@ -91,47 +91,12 @@ func inspectConfiguredSessionReadiness(ctx context.Context, cfg *config.Config,
|
||||
}
|
||||
|
||||
func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadinessReport, deps commandDependencies) error {
|
||||
prepareErr := executeSelectedStages(runtime)
|
||||
prepared := false
|
||||
if len(runtime.stageResults) > 0 {
|
||||
item := runtime.stageResults[0]
|
||||
report.Preparation = preparationAssessment{Outcome: item.Outcome, Reason: item.Reason}
|
||||
prepared = prepareErr == nil && (item.Outcome == "completed" || item.Outcome == "reused")
|
||||
}
|
||||
if !prepared && prepareErr == nil {
|
||||
prepareErr = fmt.Errorf("preparation did not produce reusable input evidence")
|
||||
report.Preparation.Outcome = "failed"
|
||||
report.Preparation.Reason = prepareErr.Error()
|
||||
}
|
||||
if prepareErr != nil {
|
||||
report.Findings = append(report.Findings, errorFinding("preparation", prepareErr.Error()))
|
||||
}
|
||||
outcome, message := "succeeded", ""
|
||||
if !prepared {
|
||||
outcome = "failed"
|
||||
if prepareErr != nil {
|
||||
message = prepareErr.Error()
|
||||
}
|
||||
}
|
||||
report.Checks = append(report.Checks, readinessCheck{Group: "preparation", Outcome: outcome, Message: message})
|
||||
if prepared {
|
||||
message := "prepared session inputs and audio are current"
|
||||
if record := runtime.manifest.Stages["prepare"]; record != nil && record.Metadata["audio_prepared"] == false {
|
||||
message = "prepared session references are current"
|
||||
}
|
||||
report.Findings = append(report.Findings, okFinding("inputs", message))
|
||||
if record := runtime.manifest.Stages["prepare"]; record != nil {
|
||||
if hydrated := previousArtifactNames(record.Metadata["previous_artifacts_hydrated"]); len(hydrated) > 0 {
|
||||
report.Findings = append(report.Findings, okFinding("previous", fmt.Sprintf("prepared previous artifacts: %v", hydrated)))
|
||||
}
|
||||
if missing := previousArtifactNames(record.Metadata["previous_artifacts_missing_optional"]); len(missing) > 0 {
|
||||
report.Findings = append(report.Findings, infoFinding("previous", fmt.Sprintf("optional previous artifacts unavailable: %v", missing)))
|
||||
}
|
||||
if _, required := record.Metadata["previous_requirements_count"]; !required {
|
||||
report.Findings = append(report.Findings, infoFinding("previous", "no previous-session artifacts required"))
|
||||
}
|
||||
}
|
||||
}
|
||||
preparation := assessPreparation(runtime, executeSelectedStages(runtime))
|
||||
report.Preparation = preparation.preparation
|
||||
report.Findings = append(report.Findings, preparation.findings...)
|
||||
report.Checks = append(report.Checks, preparation.check)
|
||||
prepared, prepareErr := preparation.prepared, preparation.err
|
||||
|
||||
var failures []error
|
||||
failures = append(failures, prepareErr)
|
||||
if runtime.ctx.Err() != nil {
|
||||
@@ -143,45 +108,14 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
|
||||
report.Checks = append(report.Checks, readinessCheck{Group: "prompt requirements", Outcome: "failed", Message: err.Error()})
|
||||
report.Findings = append(report.Findings, errorFinding("preflight", err.Error()))
|
||||
} else {
|
||||
useCurrent := false
|
||||
if prepared && targets.Notarius {
|
||||
plan, planErr := BuildBoundedPlan("transcribe", "trim")
|
||||
if planErr == nil {
|
||||
var projection *workProjection
|
||||
projection, planErr = projectSelectedWork(runtime.ctx, runtime.cfg, plan, false, nil, runtime.effectiveArtifacts, runtime.artifactStore, runtime.env.ObjectStore, runtime.manifest)
|
||||
if planErr == nil {
|
||||
useCurrent = currentTranscriptUsableForNotarius(projection)
|
||||
}
|
||||
}
|
||||
if planErr != nil {
|
||||
failures = append(failures, fmt.Errorf("project transcript readiness: %w", planErr))
|
||||
report.Findings = append(report.Findings, errorFinding("notarius", planErr.Error()))
|
||||
}
|
||||
useCurrent, planErr := projectNotariusTranscriptReadiness(runtime, prepared && targets.Notarius)
|
||||
if planErr != nil {
|
||||
failures = append(failures, fmt.Errorf("project transcript readiness: %w", planErr))
|
||||
report.Findings = append(report.Findings, errorFinding("notarius", planErr.Error()))
|
||||
}
|
||||
checked, checkErr := checkDownstreamReadiness(runtime, targets, prepared, useCurrent, false)
|
||||
report.Checks = append(report.Checks, checked.Checks...)
|
||||
projectDownstreamReadiness(report, checked)
|
||||
failures = append(failures, checkErr)
|
||||
for _, check := range checked.Checks {
|
||||
if check.Outcome == "failed" && check.Message != "" {
|
||||
report.Findings = append(report.Findings, errorFinding(check.Group, check.Message))
|
||||
}
|
||||
}
|
||||
for _, item := range checked.Findings {
|
||||
category, text := "scriptorium", formatPromptFinding(item)
|
||||
if item.Stage == "polish" {
|
||||
category, text = "audita", item.Message
|
||||
} else if item.Stage == "extract" {
|
||||
category, text = "notarius", item.Message
|
||||
}
|
||||
switch item.Severity {
|
||||
case preflight.SeverityError:
|
||||
report.Findings = append(report.Findings, errorFinding(category, text))
|
||||
case preflight.SeverityWarning:
|
||||
report.Findings = append(report.Findings, warnFinding(category, text))
|
||||
default:
|
||||
report.Findings = append(report.Findings, infoFinding(category, text))
|
||||
}
|
||||
}
|
||||
}
|
||||
if runtime.ctx.Err() == nil {
|
||||
store := runtime.env.ObjectStore
|
||||
@@ -211,6 +145,101 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
|
||||
return errors.Join(append(failures, runtime.ctx.Err())...)
|
||||
}
|
||||
|
||||
func projectNotariusTranscriptReadiness(runtime *invocationRuntime, needed bool) (bool, error) {
|
||||
if !needed {
|
||||
return false, nil
|
||||
}
|
||||
plan, err := BuildBoundedPlan("transcribe", "trim")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
projection, err := projectSelectedWork(runtime.ctx, runtime.cfg, plan, false, nil, runtime.effectiveArtifacts, runtime.artifactStore, runtime.env.ObjectStore, runtime.manifest)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return currentTranscriptUsableForNotarius(projection), nil
|
||||
}
|
||||
|
||||
func projectDownstreamReadiness(report *sessionReadinessReport, checked downstreamReadiness) {
|
||||
report.Checks = append(report.Checks, checked.Checks...)
|
||||
for _, check := range checked.Checks {
|
||||
if check.Outcome == "failed" && check.Message != "" {
|
||||
report.Findings = append(report.Findings, errorFinding(check.Group, check.Message))
|
||||
}
|
||||
}
|
||||
for _, item := range checked.Findings {
|
||||
category, text := "scriptorium", formatPromptFinding(item)
|
||||
if item.Stage == "polish" {
|
||||
category, text = "audita", item.Message
|
||||
} else if item.Stage == "extract" {
|
||||
category, text = "notarius", item.Message
|
||||
}
|
||||
switch item.Severity {
|
||||
case preflight.SeverityError:
|
||||
report.Findings = append(report.Findings, errorFinding(category, text))
|
||||
case preflight.SeverityWarning:
|
||||
report.Findings = append(report.Findings, warnFinding(category, text))
|
||||
default:
|
||||
report.Findings = append(report.Findings, infoFinding(category, text))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type preparationReadiness struct {
|
||||
preparation preparationAssessment
|
||||
prepared bool
|
||||
check readinessCheck
|
||||
findings []finding
|
||||
err error
|
||||
}
|
||||
|
||||
func assessPreparation(runtime *invocationRuntime, executionErr error) preparationReadiness {
|
||||
assessment := preparationReadiness{preparation: preparationAssessment{Outcome: "not_attempted"}}
|
||||
prepareErr := executionErr
|
||||
prepared := false
|
||||
if len(runtime.stageResults) > 0 {
|
||||
item := runtime.stageResults[0]
|
||||
assessment.preparation = preparationAssessment{Outcome: item.Outcome, Reason: item.Reason}
|
||||
prepared = prepareErr == nil && (item.Outcome == "completed" || item.Outcome == "reused")
|
||||
}
|
||||
if !prepared && prepareErr == nil {
|
||||
prepareErr = fmt.Errorf("preparation did not produce reusable input evidence")
|
||||
assessment.preparation.Outcome = "failed"
|
||||
assessment.preparation.Reason = prepareErr.Error()
|
||||
}
|
||||
if prepareErr != nil {
|
||||
assessment.findings = append(assessment.findings, errorFinding("preparation", prepareErr.Error()))
|
||||
}
|
||||
outcome, message := "succeeded", ""
|
||||
if !prepared {
|
||||
outcome = "failed"
|
||||
if prepareErr != nil {
|
||||
message = prepareErr.Error()
|
||||
}
|
||||
}
|
||||
assessment.check = readinessCheck{Group: "preparation", Outcome: outcome, Message: message}
|
||||
if prepared {
|
||||
message := "prepared session inputs and audio are current"
|
||||
if record := runtime.manifest.Stages["prepare"]; record != nil && record.Metadata["audio_prepared"] == false {
|
||||
message = "prepared session references are current"
|
||||
}
|
||||
assessment.findings = append(assessment.findings, okFinding("inputs", message))
|
||||
if record := runtime.manifest.Stages["prepare"]; record != nil {
|
||||
if hydrated := previousArtifactNames(record.Metadata["previous_artifacts_hydrated"]); len(hydrated) > 0 {
|
||||
assessment.findings = append(assessment.findings, okFinding("previous", fmt.Sprintf("prepared previous artifacts: %v", hydrated)))
|
||||
}
|
||||
if missing := previousArtifactNames(record.Metadata["previous_artifacts_missing_optional"]); len(missing) > 0 {
|
||||
assessment.findings = append(assessment.findings, infoFinding("previous", fmt.Sprintf("optional previous artifacts unavailable: %v", missing)))
|
||||
}
|
||||
if _, required := record.Metadata["previous_requirements_count"]; !required {
|
||||
assessment.findings = append(assessment.findings, infoFinding("previous", "no previous-session artifacts required"))
|
||||
}
|
||||
}
|
||||
}
|
||||
assessment.prepared, assessment.err = prepared, prepareErr
|
||||
return assessment
|
||||
}
|
||||
|
||||
func previousArtifactNames(value any) []string {
|
||||
switch items := value.(type) {
|
||||
case []string:
|
||||
|
||||
Reference in New Issue
Block a user