From dbfcfa3f750f8e8e7e3c37f2fe430924efbabf71 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Mon, 30 Nov 2026 04:00:26 +0000 Subject: [PATCH] Correct runtime recovery commands --- docs/roadmap/remediation.md | 6 +++++- internal/stage/analyze.go | 4 ++-- internal/stage/analyze_input_identity.go | 8 ++++---- internal/stage/analyze_input_identity_test.go | 2 +- internal/stage/analyze_test.go | 20 +++++++++---------- internal/stage/extract_references.go | 2 +- internal/stage/extract_test.go | 4 ++-- internal/stage/render.go | 4 ++-- internal/stage/render_test.go | 4 ++-- 9 files changed, 29 insertions(+), 25 deletions(-) diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index 0a05159..67dc18d 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -104,7 +104,11 @@ must remain untouched and eligible run cleanup must still complete. **Priority:** P2 -**Status:** Pending +**Status:** Complete + +Active input-recovery diagnostics now use the native `run SESSION --stage STAGE +--force` route. Corresponding missing/corrupt-input tests were updated; retired +command rejection tests remain intact. Verified stage and application tests. **Stages:** 9, 12, 16, and the integration/documentation reconciliation in 21–23. diff --git a/internal/stage/analyze.go b/internal/stage/analyze.go index 8fe515c..92c3687 100644 --- a/internal/stage/analyze.go +++ b/internal/stage/analyze.go @@ -384,10 +384,10 @@ func requiredBuiltInInputError(source string, execution analyzeExecutionContext) return fmt.Errorf("required built-in source %q is unavailable", source) } return fmt.Errorf( - "required built-in source %q is unavailable; run narratio run-stage %s %s --force", + "required built-in source %q is unavailable; run narratio run %s --stage %s --force", source, - entry.ProducerStage, execution.SessionID, + entry.ProducerStage, ) } diff --git a/internal/stage/analyze_input_identity.go b/internal/stage/analyze_input_identity.go index 0ba5ee7..493aba3 100644 --- a/internal/stage/analyze_input_identity.go +++ b/internal/stage/analyze_input_identity.go @@ -128,13 +128,13 @@ func resolveAnalyzeInputIdentity( return identity, "", nil, nil } return analyzeInputIdentity{}, "", nil, fmt.Errorf( - "required prepared input source %q is unavailable; run narratio run-stage prepare %s --force", + "required prepared input source %q is unavailable; run narratio run %s --stage prepare --force", descriptor.Source.ID, execution.SessionID, ) } return analyzeInputIdentity{}, "", nil, fmt.Errorf( - "prepared input source %q is invalid; run narratio run-stage prepare %s --force: %w", + "prepared input source %q is invalid; run narratio run %s --stage prepare --force: %w", descriptor.Source.ID, execution.SessionID, preparedErr, @@ -184,13 +184,13 @@ func missingAnalyzeInputError( switch descriptor.Source.Kind { case artifactpolicy.SourceKindPreviousArtifact: return fmt.Errorf( - "required previous-session input source %q is unavailable; run narratio run-stage prepare %s --force", + "required previous-session input source %q is unavailable; run narratio run %s --stage prepare --force", source, execution.SessionID, ) case artifactpolicy.SourceKindExtraction: return fmt.Errorf( - "required extraction source %q is unavailable; enable and configure pipeline.notarius output %q, then run narratio run-stage extract %s --force", + "required extraction source %q is unavailable; enable and configure pipeline.notarius output %q, then run narratio run %s --stage extract --force", source, descriptor.Source.ConfiguredKey, execution.SessionID, diff --git a/internal/stage/analyze_input_identity_test.go b/internal/stage/analyze_input_identity_test.go index 41aa442..c645110 100644 --- a/internal/stage/analyze_input_identity_test.go +++ b/internal/stage/analyze_input_identity_test.go @@ -160,7 +160,7 @@ func TestResolveAnalyzeInputIdentitiesRecordsOptionalAbsenceAndRejectsRequiredAb _, err = resolveAnalyzeInputIdentities(map[string]config.ScriptoriumInputConfig{ "players": {Source: sourceID, Required: true}, }, execution) - if err == nil || !strings.Contains(err.Error(), "run narratio run-stage prepare") { + if err == nil || !strings.Contains(err.Error(), "run narratio run 2026-05-03 --stage prepare") { t.Fatalf("required input error = %v, want prepare guidance", err) } } diff --git a/internal/stage/analyze_test.go b/internal/stage/analyze_test.go index 83b7cdb..f4a44e2 100644 --- a/internal/stage/analyze_test.go +++ b/internal/stage/analyze_test.go @@ -458,7 +458,7 @@ func TestAnalyzeFailsWhenRequiredCanonicalPreviousRecapMissing(t *testing.T) { if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "narratio run-stage prepare 2026-05-03 --force") { + if !strings.Contains(err.Error(), "narratio run 2026-05-03 --stage prepare --force") { t.Fatalf("error = %q, want executable prepare guidance", err.Error()) } } @@ -828,7 +828,7 @@ func TestAnalyzeRequiredPreviousSessionArtifactInputGuidesPrepareForce(t *testin if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "narratio run-stage prepare 2026-05-03 --force") { + if !strings.Contains(err.Error(), "narratio run 2026-05-03 --stage prepare --force") { t.Fatalf("error = %q, want executable prepare guidance", err.Error()) } } @@ -973,7 +973,7 @@ func TestAnalyzeFailsWhenTrimmedTranscriptMissing(t *testing.T) { if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "narratio.transcript.final_trimmed") || !strings.Contains(err.Error(), "narratio run-stage trim 2026-05-03 --force") { + if !strings.Contains(err.Error(), "narratio.transcript.final_trimmed") || !strings.Contains(err.Error(), "narratio run 2026-05-03 --stage trim --force") { t.Fatalf("error = %q, want executable trimmed transcript guidance", err.Error()) } } @@ -1042,7 +1042,7 @@ func TestAnalyzeMissingRequiredBuiltInInputsProvideExecutableGuidance(t *testing if err == nil { t.Fatal("Run() error = nil, want required input error") } - command := "narratio run-stage " + tt.stage + " 2026-05-03 --force" + command := "narratio run 2026-05-03 --stage " + tt.stage + " --force" if !strings.Contains(err.Error(), tt.source) || !strings.Contains(err.Error(), command) { t.Fatalf("Run() error = %q, want source %q and command %q", err, tt.source, command) } @@ -1225,7 +1225,7 @@ func TestAnalyzeMissingRequiredPreparedStableInputFailsWithPrepareGuidance(t *te t.Fatal("expected error, got nil") } if !strings.Contains(err.Error(), "prepared input source \"narratio.input.players\" is unavailable") || - !strings.Contains(err.Error(), "run narratio run-stage prepare 2026-05-03 --force") { + !strings.Contains(err.Error(), "run narratio run 2026-05-03 --stage prepare --force") { t.Fatalf("error = %q, want prepared input guidance", err.Error()) } } @@ -1271,7 +1271,7 @@ func TestAnalyzeInvalidOptionalPreparedStableInputFailsWithPrepareGuidance(t *te _, err := (analyzeStage{}).Run(context.Background(), env, m) if err == nil || !strings.Contains(err.Error(), "prepared input source \"narratio.input.players\" is invalid") || - !strings.Contains(err.Error(), "run narratio run-stage prepare 2026-05-03 --force") { + !strings.Contains(err.Error(), "run narratio run 2026-05-03 --stage prepare --force") { t.Fatalf("Run() error = %v, want invalid prepared input guidance", err) } } @@ -1345,7 +1345,7 @@ func TestAnalyzeFailsWhenNormalizedTranscriptMissing(t *testing.T) { if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "narratio.transcript.final") || !strings.Contains(err.Error(), "narratio run-stage normalize 2026-05-03 --force") { + if !strings.Contains(err.Error(), "narratio.transcript.final") || !strings.Contains(err.Error(), "narratio run 2026-05-03 --stage normalize --force") { t.Fatalf("error = %q, want executable normalized transcript guidance", err.Error()) } if len(fake.RunRequests) != 0 { @@ -1366,7 +1366,7 @@ func TestAnalyzeFailsWhenRenderedMarkdownTranscriptMissing(t *testing.T) { if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "run narratio run-stage render") || !strings.Contains(err.Error(), "--force") { + if !strings.Contains(err.Error(), "run narratio run 2026-05-03 --stage render") || !strings.Contains(err.Error(), "--force") { t.Fatalf("error = %q, want render guidance", err.Error()) } } @@ -1384,7 +1384,7 @@ func TestAnalyzeFailsWhenRenderedTrimmedMarkdownTranscriptMissing(t *testing.T) if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "run narratio run-stage render") || !strings.Contains(err.Error(), "--force") { + if !strings.Contains(err.Error(), "run narratio run 2026-05-03 --stage render") || !strings.Contains(err.Error(), "--force") { t.Fatalf("error = %q, want render guidance", err.Error()) } } @@ -1601,7 +1601,7 @@ func TestAnalyzeRequiredUnavailableExtractionFailsWithGuidance(t *testing.T) { env.Config.ArtifactCatalog.Artifacts["session_recap"] = artifact _, err := (analyzeStage{}).Run(context.Background(), env, m) - if err == nil || !strings.Contains(err.Error(), "pipeline.notarius output \"encounters\"") || !strings.Contains(err.Error(), "narratio run-stage extract 2026-05-03 --force") { + if err == nil || !strings.Contains(err.Error(), "pipeline.notarius output \"encounters\"") || !strings.Contains(err.Error(), "narratio run 2026-05-03 --stage extract --force") { t.Fatalf("Run() error = %v, want actionable extraction guidance", err) } if len(fake.RunRequests) != 0 { diff --git a/internal/stage/extract_references.go b/internal/stage/extract_references.go index 88df9e0..3eadbb3 100644 --- a/internal/stage/extract_references.go +++ b/internal/stage/extract_references.go @@ -275,7 +275,7 @@ func resolveExtractReferences( identity, err := artifacts.ResolvePreparedInput(paths, m, sourceID) if err != nil { return resolvedExtractReferences{}, fmt.Errorf( - "reference %q source %q is unavailable or invalid; run narratio run-stage prepare %s --force: %w", + "reference %q source %q is unavailable or invalid; run narratio run %s --stage prepare --force: %w", selector, sourceID, sessionID, diff --git a/internal/stage/extract_test.go b/internal/stage/extract_test.go index a10ccbd..56a49a0 100644 --- a/internal/stage/extract_test.go +++ b/internal/stage/extract_test.go @@ -573,7 +573,7 @@ func TestExtractStageRejectsUnavailableReferenceBeforeInvocationOrRunDirectoryCr } result, err := (extractStage{}).Run(context.Background(), env, m) - if err == nil || !strings.Contains(err.Error(), "run narratio run-stage prepare ") || !strings.Contains(err.Error(), "--force") { + if err == nil || !strings.Contains(err.Error(), "run narratio run "+m.SessionID+" --stage prepare ") || !strings.Contains(err.Error(), "--force") { t.Fatalf("Run() result = %#v error = %v", result, err) } if len(fake.Requests) != 0 { @@ -798,7 +798,7 @@ func TestExtractStageResumeValidationErrorsForUnavailablePreparedReference(t *te test.mutate(t, path, m) validation, err := (extractStage{}).ValidateResume(context.Background(), env, m) - if err == nil || !strings.Contains(err.Error(), "run narratio run-stage prepare ") || !strings.Contains(err.Error(), "--force") { + if err == nil || !strings.Contains(err.Error(), "run narratio run "+m.SessionID+" --stage prepare ") || !strings.Contains(err.Error(), "--force") { t.Fatalf("ValidateResume() validation = %#v error = %v", validation, err) } }) diff --git a/internal/stage/render.go b/internal/stage/render.go index 2a743bb..efc5725 100644 --- a/internal/stage/render.go +++ b/internal/stage/render.go @@ -249,10 +249,10 @@ func wrapRenderInputResolveError(err error, sessionID, sourceID, guidanceStage s var notFound *artifacts.SessionArtifactNotFoundError if errors.As(err, ¬Found) { return fmt.Errorf( - "render: required input %q is unavailable; run narratio run-stage %s %s --force", + "render: required input %q is unavailable; run narratio run %s --stage %s --force", sourceID, - guidanceStage, sessionID, + guidanceStage, ) } return fmt.Errorf("render: resolve %q input: %w", sourceID, err) diff --git a/internal/stage/render_test.go b/internal/stage/render_test.go index 3835153..ec6511e 100644 --- a/internal/stage/render_test.go +++ b/internal/stage/render_test.go @@ -105,7 +105,7 @@ func TestRenderStageFailsWhenFinalInputMissing(t *testing.T) { if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "run narratio run-stage normalize") || !strings.Contains(err.Error(), "--force") { + if !strings.Contains(err.Error(), "run narratio run 2026-05-03 --stage normalize") || !strings.Contains(err.Error(), "--force") { t.Fatalf("error = %q, want normalize guidance", err.Error()) } } @@ -120,7 +120,7 @@ func TestRenderStageFailsWhenFinalTrimmedInputMissing(t *testing.T) { if err == nil { t.Fatal("expected error, got nil") } - if !strings.Contains(err.Error(), "run narratio run-stage trim") || !strings.Contains(err.Error(), "--force") { + if !strings.Contains(err.Error(), "run narratio run 2026-05-03 --stage trim") || !strings.Contains(err.Error(), "--force") { t.Fatalf("error = %q, want trim guidance", err.Error()) } }