Document standalone preflight and complete verification

This commit is contained in:
2026-11-30 15:42:21 +00:00
parent 727ed783d1
commit b2877c1ea0
17 changed files with 276 additions and 97 deletions

View File

@@ -5,13 +5,13 @@
```text ```text
narratio narratio
├── run SESSION ├── run SESSION
├── preflight SESSION
├── artifacts ├── artifacts
│ ├── list │ ├── list
│ └── regenerate SESSION │ └── regenerate SESSION
├── session ├── session
│ ├── init SESSION │ ├── init SESSION
│ ├── plan SESSION │ ├── plan SESSION
│ ├── validate SESSION
│ ├── status SESSION │ ├── status SESSION
│ ├── restore SESSION │ ├── restore SESSION
│ ├── clean [SESSION | --all] │ ├── clean [SESSION | --all]
@@ -94,7 +94,7 @@ reruns selected work; dependent invalidation can extend beyond that range.
Bounded starts require valid preceding manifest state. Ordinary execution uses Bounded starts require valid preceding manifest state. Ordinary execution uses
semantic resume checks rather than rerunning all selected work. semantic resume checks rather than rerunning all selected work.
After preparation, `run` checks projected Audita and Scriptorium work before After preparation, `run` checks projected Audita, Notarius, and Scriptorium work before
processing continues. Failed checks stop the invocation; prompt warnings alone processing continues. Failed checks stop the invocation; prompt warnings alone
do not. `artifacts regenerate` uses the same check. do not. `artifacts regenerate` uses the same check.
See [operations](operations.md#prompt-requirements-preflight) for recovery. See [operations](operations.md#prompt-requirements-preflight) for recovery.
@@ -143,22 +143,21 @@ without creating a workspace, changing manifests, acquiring execution locks, or
initializing stage adapters or invoking requirements inspection. It does not initializing stage adapters or invoking requirements inspection. It does not
predict unknown output identities. predict unknown output identities.
## Session validate ## Preflight
```sh ```sh
narratio session validate SESSION --session-file ./session.yml narratio preflight SESSION --session-file ./session.yml
narratio preflight SESSION --format json
``` ```
Validation checks configuration and required input, audio, previous-session, Preflight resolves the same session and configuration selectors as `run`,
publication, and lock readiness. Audita preflight uses existing prepared inputs, prepares or reuses inputs, and checks enabled downstream capabilities and
probes temporary destinations under `runs/.validation`, and may contact configured prompt prerequisites even when their processing outputs are reusable. It may
providers. It also inspects enabled trim create a workspace, download inputs, update the manifest, and contact providers.
and analysis definitions and their configured prerequisites, regardless of It stops before processing and publication. Required failures or blocked
output reuse. Missing prompt requirements or unsuccessful inspection invalidate checks prevent readiness; conditional or incomplete prompt discovery can warn
the report; incomplete or conditional discovery alone is a warning. Material without failing. Preparation remains reusable after a later readiness failure.
findings remain in the report regardless of diagnostic visibility. Invalid See [operations](operations.md#prompt-requirements-preflight) for details.
configuration uses the native input classification; readiness failures are
operational failures.
## Session status ## Session status
@@ -337,13 +336,19 @@ manifests, resolved credentials, or internal dependency containers.
| Run/regenerate | `campaign`, `session_id`, `run_id`, `stages`, `executed`, `skipped`, `stage_results`, `available_artifacts`, `artifact_targets`, `complete` | | Run/regenerate | `campaign`, `session_id`, `run_id`, `stages`, `executed`, `skipped`, `stage_results`, `available_artifacts`, `artifact_targets`, `complete` |
| Plan | `campaign`, `session_id`, `stages` with `name`, `action`, `reason`, optional `analysis`; `publication_actions` | | Plan | `campaign`, `session_id`, `stages` with `name`, `action`, `reason`, optional `analysis`; `publication_actions` |
| Catalog | `artifacts` with source, producer, output, enabled state, dependencies, optional concrete key and family/member/source provenance | | Catalog | `artifacts` with source, producer, output, enabled state, dependencies, optional concrete key and family/member/source provenance |
| Validation | `campaign`, `session_id`, `session_source`, `valid`, `findings` with severity, category, message | | Preflight | `campaign`, `session_id`, optional `session_source` and `run_id`, `preparation` with outcome and optional reason, `ready`, `checks` with group, outcome and optional message, `findings` with severity, category and message |
| Status/artifacts | Identities/source, `local_manifest`, `stages`, `artifacts`, optional `remote`, configuration provenance, audio/previous-artifact readiness, `findings` | | Status/artifacts | Identities/source, `local_manifest`, `stages`, `artifacts`, optional `remote`, configuration provenance, audio/previous-artifact readiness, `findings` |
| Init | `campaign`, `session_id`, `destination`, `remote`, `written` | | Init | `campaign`, `session_id`, `destination`, `remote`, `written` |
| Locks | Identities, `operation`, `result`, `complete`, optional `source`, `locks` | | Locks | Identities, `operation`, `result`, `complete`, optional `source`, `locks` |
| Restore | Identities/run, `dry_run`, `complete`, `status`, `downloaded`, `conflicts`, `actions` | | Restore | Identities/run, `dry_run`, `complete`, `status`, `downloaded`, `conflicts`, `actions` |
| Clean | Optional identities, `all`, `dry_run`, `complete`, `cache`, `actions`, optional `error` | | Clean | Optional identities, `all`, `dry_run`, `complete`, `cache`, `actions`, optional `error` |
Preflight preparation outcomes are `completed`, `reused`, `failed`, or
`not_attempted`. Check outcomes are `succeeded`, `failed`, or `blocked`;
inapplicable groups may be omitted. Findings include errors, warnings, and
information where available. Quiet mode suppresses the report and retains
failure diagnostics on stderr.
Run `stages` is the complete selection. `executed` includes attempted work, Run `stages` is the complete selection. `executed` includes attempted work,
including failures and self-skips. `skipped` includes reuse and self-skips. including failures and self-skips. `skipped` includes reuse and self-skips.
Each `stage_results` entry has `name`, `attempted`, `outcome` Each `stage_results` entry has `name`, `attempted`, `outcome`

View File

@@ -19,9 +19,10 @@ After preparation, Narratio runs native Audita preflight when projected polish
work needs execution. The adapter supplies the same selections and prepared work needs execution. The adapter supplies the same selections and prepared
files with a synthetic transcript. Audita's provider smoke checks remain enabled; files with a synthetic transcript. Audita's provider smoke checks remain enabled;
they can contact providers and destination probes can create directories. they can contact providers and destination probes can create directories.
`session validate` uses existing prepared records and a validation probe Standalone `preflight` prepares or reuses inputs and checks Audita regardless
namespace. A successful check is not a guarantee about later real-transcript of output reuse, using invocation-scoped probe destinations. A successful check
processing or editorial quality. See [operations](../operations.md#prompt-requirements-preflight) does not guarantee later real-transcript processing or editorial quality. See
[operations](../operations.md#prompt-requirements-preflight)
and [Audita preflight](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/cli.md#preflight). and [Audita preflight](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/cli.md#preflight).
Each `pipeline.audita.credentials` value is an exact ConfigKit secret reference. Each `pipeline.audita.credentials` value is an exact ConfigKit secret reference.

View File

@@ -62,9 +62,10 @@ command configuration loader may still use object storage to retrieve a missing
remote session file before planning begins. remote session file before planning begins.
After preparation, the application projects remaining selected work and uses After preparation, the application projects remaining selected work and uses
invocation-owned Audita, Notarius, and Scriptorium runners for applicable readiness checks. invocation-owned Audita, Notarius, and Scriptorium runners for applicable
The same runners are available to processing. Explicit session validation uses readiness checks. The same runners are available to processing. Standalone
existing prepared inputs and invocation-owned factories. See preflight prepares inputs through the same lifecycle and uses invocation-owned
factories for all enabled readiness checks. See
[preflight internals](preflight.md). [preflight internals](preflight.md).
Notarius is composed only when extraction is enabled. The stage resolves Notarius is composed only when extraction is enabled. The stage resolves

View File

@@ -36,6 +36,8 @@ cancellation; active work retains the canceled operation context. Cleanup, when
selected, is the ordinary final stage rather than runner finalization work. selected, is the ordinary final stage rather than runner finalization work.
The lock remains held from manifest initialization through finalization, and a The lock remains held from manifest initialization through finalization, and a
failed stage or required manifest save prevents later stages from starting. failed stage or required manifest save prevents later stages from starting.
Standalone preflight shares that lifecycle, runs only preparation, and checks
enabled capabilities while holding the same lock.
## Components ## Components
@@ -46,7 +48,7 @@ failed stage or required manifest save prevents later stages from starting.
| Configuration | [`internal/config`](configuration.md) | Typed ConfigKit results and lifecycle defaults, imports/overlays, canonical party loading, separate catalog/player/publication derivation, session templating, and validation. | | Configuration | [`internal/config`](configuration.md) | Typed ConfigKit results and lifecycle defaults, imports/overlays, canonical party loading, separate catalog/player/publication derivation, session templating, and validation. |
| Pipeline stages | `internal/stage` | Canonical stage registry, shared stage contract, execution dependencies, and implemented stage behavior. | | Pipeline stages | `internal/stage` | Canonical stage registry, shared stage contract, execution dependencies, and implemented stage behavior. |
| Glossaries | `internal/glossary` | Native vocabulary resolution, schema validation, party projection, and deterministic documents. | | Glossaries | `internal/glossary` | Native vocabulary resolution, schema validation, party projection, and deterministic documents. |
| Downstream preflight | [`internal/preflight`](preflight.md) | Assess Audita readiness and native prompt requirements for execution and validation. | | Downstream preflight | [`internal/preflight`](preflight.md) | Assess Audita, Notarius, and prompt requirements for execution and standalone preflight. |
| External boundaries | `internal/adapters`, `internal/audio` | WhisperX HTTP, downstream subprocesses, notification, object storage, and S3 audio materialization behind Narratio contracts. | | External boundaries | `internal/adapters`, `internal/audio` | WhisperX HTTP, downstream subprocesses, notification, object storage, and S3 audio materialization behind Narratio contracts. |
| Manifests | `internal/manifest` | Durable session progress, stage transitions, validation, and atomic persistence. | | Manifests | `internal/manifest` | Durable session progress, stage transitions, validation, and atomic persistence. |
| Artifacts and paths | `internal/artifacts`, `internal/pathsafe` | Artifact identities and resolution, local and remote path/key models, current-state discovery, and confined relative destinations. | | Artifacts and paths | `internal/artifacts`, `internal/pathsafe` | Artifact identities and resolution, local and remote path/key models, current-state discovery, and confined relative destinations. |
@@ -119,7 +121,7 @@ so any earlier replacement can stale a prior cleanup result.
- [Adapter Internals](adapters.md): external adapter boundaries, composition, - [Adapter Internals](adapters.md): external adapter boundaries, composition,
failure behavior, and test surfaces. failure behavior, and test surfaces.
- [Preflight Internals](preflight.md): projected target selection and shared - [Preflight Internals](preflight.md): projected target selection and shared
requirements assessment. requirements assessment and standalone preparation.
- [Artifact Internals](artifacts.md): source identities, runtime catalog, - [Artifact Internals](artifacts.md): source identities, runtime catalog,
resolution, previous requirements, and current-state helpers. resolution, previous requirements, and current-state helpers.
- [Manifest Internals](manifest.md): session records, persistence, and execution - [Manifest Internals](manifest.md): session records, persistence, and execution

View File

@@ -1,44 +1,41 @@
# Internal: Downstream Preflight # Internal: Downstream Preflight
The application performs downstream checks after selected preparation completes The application runs automatic downstream checks after selected preparation and
or is reused and before remaining selected processing. It projects remaining before selected processing. It projects remaining work against a clone of the
work against a clone of the locked manifest using the same stage decisions and locked manifest, using the stage decisions and analysis planner shared with
analysis planner as `session plan`. Projected polish selects Audita; projected `session plan`. Projected polish selects Audita; projected enabled extraction
enabled extraction selects Notarius inspection and preflight; enabled trim and selects Notarius; projected trim and analysis select Scriptorium requirements.
analysis select Scriptorium requirements. A projection is not A projection is not an execution commitment, and an empty target set invokes no
an execution commitment. Empty target sets invoke no checker. checker.
Audita receives the verified four prepared glossary files and the same Standalone `preflight` acquires configuration once and uses the runner's locked
processing selectors and destinations, with an embedded synthetic transcript. invocation lifecycle to execute or reuse `prepare`. Within that same lock it
The adapter runs native preflight with provider smoke enabled, captures its selects all enabled capabilities and prompt prerequisites regardless of reuse,
transient diagnostics, and preserves exit classification. No preflight result then invokes the shared downstream request builders and checkers. A preparation
is cached as a stage. A failure stops later processing without presenting it as failure blocks probes requiring prepared inputs but permits independent prompt
complete. and remote-lock inspection while the context remains active. Preparation success
is persisted even when later readiness fails; readiness itself creates no stage
or reusable success record.
Notarius uses the same execution controls and verified reference snapshots. It Audita receives verified prepared glossary files and production selections with
checks an available verified transcript or reports that a synthetic one was used. an embedded synthetic transcript. Its adapter performs native provider smoke
Readiness warnings and native failures remain visible; checks do not publish work. checks and retains failure causes. Notarius receives production controls and
verified reference snapshots, which are checked again after its native call.
For `session validate`, the application selects enabled downstream definitions The application projects transcript-producing work before allowing a verified
independently of reuse and checks the existing prepared manifest. It does not current transcript; otherwise it reports the synthetic fallback. Neither probe
resolve live files into candidate glossary projections or run prepare. The publishes work, and the synthetic input cannot establish real-transcript
Audita probe under `runs/.validation` can create or probe directories and contact feasibility or editorial quality.
providers; it does not update the session manifest. Discovery and provider
checks do not establish real-transcript feasibility or editorial quality.
Standalone validation acquires the context-aware session lock before reading
prepared evidence for Audita or Notarius probes. It holds the lock through probe
execution, report consumption and reference verification, serializing these
files with runner cleanup and restore. Missing preparation is reported without
creating a workspace. Automatic preflight uses the runner's existing lock.
Scriptorium input-map keys remain binding names distinct from Narratio source Scriptorium input-map keys remain binding names distinct from Narratio source
IDs. Missing required bindings or variables and inspection failures are errors; IDs. Missing required bindings or variables and inspection failures are errors;
optional sources for required inputs, conditional requirements, incomplete optional sources for required inputs, conditional requirements, incomplete
discovery, and discovery issues produce warnings. The checker preserves earlier discovery, and discovery issues produce warnings. Findings survive independent
findings and stops on cancellation. Actual input resolution remains authoritative. failures and cancellation stops new work.
See [Audita](../integrations/audita.md), [Scriptorium](../integrations/scriptorium.md), Probe files use invocation-scoped destinations under `runs/`, protected by the
[CLI](../cli.md#session-validate), and [operations](../operations.md#prompt-requirements-preflight). session lock through report consumption, reference verification, and terminal
Implementation and tests are in `internal/preflight`, `internal/app/runner_preflight.go`, persistence. A later authorized cleanup can remove those files without removing
`internal/app/session_inspection_command.go`, and `internal/adapters/audita/preflight.go`. durable prepared inputs. See [workspace internals](workspace.md),
[CLI](../cli.md#preflight), and [operations](../operations.md#prompt-requirements-preflight).
Implementation is in `internal/preflight`, `internal/app/downstream_readiness.go`,
`internal/app/runner_preflight.go`, and `internal/app/session_readiness.go`.

View File

@@ -51,14 +51,15 @@ operating-system lock held on `.lock` (`ErrLockConflict` on contention). The
file retains owner metadata after release or process death; its existence is file retains owner metadata after release or process death; its existence is
not evidence that a lock is active. Command and restore flows wait for this not evidence that a lock is active. Command and restore flows wait for this
lock only while their context remains active, and report a release failure. lock only while their context remains active, and report a release failure.
Standalone validation uses the same lock for its prepared-state reads and Standalone preflight holds the same lock through preparation, readiness probes,
session-local readiness probes, keeping active probe files outside concurrent and finalization, keeping active probe files outside concurrent cleanup.
cleanup. Validation leaves stage progress unchanged. Preparation uses ordinary manifest transitions and invalidation.
The runner assigns every invocation a run-workspace identity but creates the The runner assigns every invocation a run-workspace identity but creates the
physical run directory and its `runs/` parent only when an executing stage physical stage run directory only when an executing stage requires it. Fully
requires them. Fully reused invocations and cleanup-only invocations therefore do not accumulate reused pipeline invocations and cleanup-only invocations do not accumulate
empty run directories. empty run directories. Readiness probes create their separate invocation-scoped
diagnostic directories when checks run, including during a reused preparation.
## Cleanup Semantics ## Cleanup Semantics

View File

@@ -72,11 +72,10 @@ This guidance does not create a release or publish any changes.
## Standard Session Workflow ## Standard Session Workflow
1. Select pipeline/campaign/session config. 1. Select pipeline/campaign/session config.
2. Prepare inputs, then validate session readiness: 2. Prepare inputs and check session readiness:
```bash ```bash
narratio run 2026-04-04 --stage prepare narratio preflight 2026-04-04
narratio session validate 2026-04-04
``` ```
3. (Optional) inspect stage decisions: 3. (Optional) inspect stage decisions:
@@ -124,16 +123,24 @@ required binding or failed check stops the invocation; incomplete or conditional
prompt discovery can produce warnings. Already completed work remains recorded. prompt discovery can produce warnings. Already completed work remains recorded.
`session plan` does not invoke these downstream checks. `session plan` does not invoke these downstream checks.
`session validate` checks enabled downstream definitions against existing Standalone `preflight` prepares or reuses the session's real inputs before
prepared glossary records. It does not prepare inputs. Its Audita probe uses a checking every enabled downstream capability and prompt prerequisite, including
`runs/.validation` destination namespace, may create or probe directories and work whose outputs could be reused. It may create workspace state, download
may contact configured providers. The synthetic check establishes readiness for inputs, update the manifest, and contact providers. Changed inputs can stale
that probe, not feasibility for a real transcript or editorial quality. See dependent stage records through ordinary preparation rules. Preparation remains
[Audita](integrations/audita.md) and [Scriptorium](integrations/scriptorium.md). available for reuse if a later readiness check fails. Preflight stops before
Session-local Audita and Notarius probes share the session lock with pipeline processing, publishing, notification, or cleanup.
runs and restore. Validation waits while that lock is held, honors cancellation,
and leaves stage progress unchanged. Cleanup can remove finished probe files Audita checks a synthetic transcript. Notarius uses a verified trimmed
after validation releases the lock. transcript only when the normal work projection indicates its producers will
not rerun; otherwise it uses a synthetic input. These checks do not establish
real-transcript feasibility, editorial quality, or future provider availability.
See [Audita](integrations/audita.md) and [Scriptorium](integrations/scriptorium.md).
The session lock covers preparation, probes, and finalization. Probe diagnostics
under `runs/` are disposable and can be removed by a later authorized cleanup;
prepared inputs remain durable. Preflight itself does not run cleanup or rotate
processing-stage diagnostic views. See [cleanup](#cleanup).
## Stage Execution and Continuation Behavior ## Stage Execution and Continuation Behavior

View File

@@ -130,8 +130,9 @@ not configurable.
Downstream readiness is an invocation check after selected preparation and Downstream readiness is an invocation check after selected preparation and
before the selected processing work. It does not create a stage success. before the selected processing work. It does not create a stage success.
Session validation uses existing prepared inputs; its downstream checks may Standalone preflight prepares or reuses session inputs and checks enabled
probe destinations and contact configured providers. capabilities under the same session lock; its checks may probe destinations and
contact configured providers.
A stage may explicitly self-skip with a stable reason and no outputs. That A stage may explicitly self-skip with a stable reason and no outputs. That
outcome is persisted, clears older outputs owned by the stage, and is outcome is persisted, clears older outputs owned by the stage, and is

View File

@@ -1,6 +1,6 @@
# Standalone Session Preflight Implementation Plan # Standalone Session Preflight Implementation Plan
Status: In progress. Status: Complete.
## Scope And Working Instructions ## Scope And Working Instructions
@@ -310,7 +310,7 @@ duplicating the suite or introducing stricter readiness rules.
## Stage 7: Update Canonical Documentation And Verify The Sprint ## Stage 7: Update Canonical Documentation And Verify The Sprint
Status: Pending. Status: Complete. Verified with Go 1.27.4: `go test ./...`, `go test -race ./...`, `go vet ./...`, `go build ./...`, `go test ./internal/doccheck`, and `git diff --check`.
Read the affected sections of [CLI](../cli.md), [Operations](../operations.md), Read the affected sections of [CLI](../cli.md), [Operations](../operations.md),
[Troubleshooting](../troubleshooting.md), [Internal Overview](../internal/overview.md), [Troubleshooting](../troubleshooting.md), [Internal Overview](../internal/overview.md),

View File

@@ -1,6 +1,7 @@
# Standalone Session Preflight # Standalone Session Preflight
Status: Planned; not implemented. Status: Implemented. The next release notes must identify the migration from
`session validate` to `preflight`.
## Goal ## Goal
@@ -13,7 +14,7 @@ Build this command from existing production paths. Automatic preflight and the
standalone command should share checking machinery, while retaining their standalone command should share checking machinery, while retaining their
different rules for selecting what to check. different rules for selecting what to check.
## Current Baseline ## Baseline Before Implementation
- `session validate` already checks configuration, stable inputs, local or remote - `session validate` already checks configuration, stable inputs, local or remote
audio availability, previous-session requirements, and publication locks. It audio availability, previous-session requirements, and publication locks. It
@@ -29,11 +30,11 @@ different rules for selecting what to check.
has separate validation and execution orchestration, including duplicated has separate validation and execution orchestration, including duplicated
prepared-manifest acquisition and downstream request setup. prepared-manifest acquisition and downstream request setup.
The current contracts are described in [preflight internals](../internal/preflight.md), The current contracts are now described in [preflight internals](../internal/preflight.md),
[preparation](../internal/stage-prepare.md), and the [preparation](../internal/stage-prepare.md), and the
[CLI reference](../cli.md#session-validate). Principal implementation owners are [CLI reference](../cli.md#preflight). Principal implementation owners are
`internal/app/session_inspection_command.go`, `operator_inspection.go`, `internal/app/session_readiness.go`, `downstream_readiness.go`, `runner.go`,
`runner.go`, `runner_preflight.go`, `preflight_targets.go`, `internal/preflight`, `runner_preflight.go`, `preflight_targets.go`, `internal/preflight`,
and the existing stage request builders and downstream adapters. and the existing stage request builders and downstream adapters.
## Targeted End State ## Targeted End State

View File

@@ -39,7 +39,7 @@ Likely cause:
Diagnostics: Diagnostics:
```bash ```bash
narratio session validate 2026-04-04 --session-file /path/session.yml narratio preflight 2026-04-04 --session-file /path/session.yml
``` ```
Safe fix: Safe fix:
@@ -150,7 +150,7 @@ Likely cause:
Diagnostics: Diagnostics:
```bash ```bash
narratio session validate 2026-04-04 narratio preflight 2026-04-04
``` ```
Safe fix: Safe fix:
@@ -348,12 +348,12 @@ Relevant references: [Secrets](./config.md#secrets-handling) and
## Prepared glossary is unavailable or invalid ## Prepared glossary is unavailable or invalid
If validation or downstream work reports missing, changed, or invalid prepared If preflight or downstream work reports missing, changed, or invalid prepared
glossary evidence, check the selected catalog IDs, source-relative files, and glossary evidence, check the selected catalog IDs, source-relative files, and
campaign inline contribution. Re-run `prepare` after correcting the source; campaign inline contribution. Re-run `prepare` after correcting the source;
use `--force` when an explicit refresh is needed. Update old monolithic source use `--force` when an explicit refresh is needed. Update old monolithic source
bindings and glossary files using the [glossary input guidance](config.md#glossary-inputs). bindings and glossary files using the [glossary input guidance](config.md#glossary-inputs).
Validation uses existing prepared inputs and does not regenerate them. Preflight runs or reuses preparation; after correcting the source, retry it.
## Audita configuration or credential failure ## Audita configuration or credential failure
@@ -451,7 +451,7 @@ Diagnostics:
```bash ```bash
narratio session status 2026-04-04 narratio session status 2026-04-04
narratio session validate 2026-04-04 narratio preflight 2026-04-04
``` ```
Safe fix: Safe fix:
@@ -701,7 +701,7 @@ and [Manifest Internals](./internal/manifest.md#transcribe-owned-speaker-state).
## Prompt requirements fail during preflight ## Prompt requirements fail during preflight
If a run or `session validate` reports a missing prompt input, compare the exact If a run or `preflight` reports a missing prompt input, compare the exact
input name in the finding with the configured binding key, not just the source input name in the finding with the configured binding key, not just the source
ID. Supply a missing required variable, or correct the selected prompt and ID. Supply a missing required variable, or correct the selected prompt and
profile. An optional source warning means the source may be omitted later; make profile. An optional source warning means the source may be omitted later; make
@@ -771,7 +771,7 @@ Likely causes:
Diagnostics: Diagnostics:
```bash ```bash
narratio session validate 2026-04-04 narratio preflight 2026-04-04
narratio session status 2026-04-04 narratio session status 2026-04-04
``` ```
@@ -968,7 +968,7 @@ Likely causes:
Diagnostics: Diagnostics:
```bash ```bash
narratio session validate 2026-04-04 narratio preflight 2026-04-04
``` ```
Safe fix: Safe fix:

View File

@@ -40,6 +40,7 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
result.Checks = append(result.Checks, readinessCheck{Group: group, Outcome: "blocked", Message: "prepared inputs are unavailable"}) result.Checks = append(result.Checks, readinessCheck{Group: group, Outcome: "blocked", Message: "prepared inputs are unavailable"})
} }
if len(targets.Scriptorium) > 0 && runtime.ctx.Err() == nil { if len(targets.Scriptorium) > 0 && runtime.ctx.Err() == nil {
runtime.env.Progress("checking prompt requirements")
if runtime.env.Scriptorium == nil { if runtime.env.Scriptorium == nil {
runtime.env.Scriptorium = runtime.dependencies.newScriptorium() runtime.env.Scriptorium = runtime.dependencies.newScriptorium()
} }
@@ -50,6 +51,7 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
if !prepared { if !prepared {
blocked("audita") blocked("audita")
} else { } else {
runtime.env.Progress("checking Audita readiness")
var err error var err error
if runtime.env.Audita == nil { if runtime.env.Audita == nil {
runtime.env.Audita, err = runtime.dependencies.newAudita(runtime.cfg) runtime.env.Audita, err = runtime.dependencies.newAudita(runtime.cfg)
@@ -69,6 +71,7 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
err = fmt.Errorf("build audita preflight: %w", buildErr) err = fmt.Errorf("build audita preflight: %w", buildErr)
} else { } else {
checked, err = preflight.CheckAudita(runtime.ctx, checker, request) 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...)
} }
} }
} }
@@ -79,6 +82,7 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
if !prepared { if !prepared {
blocked("notarius") blocked("notarius")
} else { } else {
runtime.env.Progress("checking Notarius readiness")
if runtime.env.Notarius == nil { if runtime.env.Notarius == nil {
runtime.env.Notarius = runtime.dependencies.newNotarius() runtime.env.Notarius = runtime.dependencies.newNotarius()
} }

View File

@@ -26,7 +26,7 @@ func TestDownstreamReadinessContinuesAfterIndependentFailures(t *testing.T) {
provider := &audita.FakeRunner{PreflightErr: auditaFailure} provider := &audita.FakeRunner{PreflightErr: auditaFailure}
runtime := &invocationRuntime{ctx: context.Background(), cfg: cfg, paths: paths, manifest: m, identity: invocationIdentity{RunID: "probe"}, env: &stage.Env{Scriptorium: inspector, Audita: provider}, dependencies: invocationDependencies{}.normalized()} runtime := &invocationRuntime{ctx: context.Background(), cfg: cfg, paths: paths, manifest: m, identity: invocationIdentity{RunID: "probe"}, env: &stage.Env{Scriptorium: inspector, Audita: provider}, dependencies: invocationDependencies{}.normalized()}
result, err := checkDownstreamReadiness(runtime, preflight.Targets{Polish: true, Scriptorium: []preflight.Target{{Stage: "trim"}}}, true, false, false) result, err := checkDownstreamReadiness(runtime, preflight.Targets{Polish: true, Scriptorium: []preflight.Target{{Stage: "trim"}}}, true, false, false)
if !errors.Is(err, scriptFailure) || !errors.Is(err, auditaFailure) || len(result.Checks) != 2 || len(result.Findings) != 2 || len(provider.PreflightRequests) != 1 { if !errors.Is(err, scriptFailure) || !errors.Is(err, auditaFailure) || len(result.Checks) != 2 || len(result.Findings) != 3 || len(provider.PreflightRequests) != 1 {
t.Fatalf("result = %+v, error = %v", result, err) t.Fatalf("result = %+v, error = %v", result, err)
} }
} }

View File

@@ -32,6 +32,9 @@ func TestPreflightCommandReportsNativeFormats(t *testing.T) {
if format != "auto" { if format != "auto" {
args = append(args, "--format", format) args = append(args, "--format", format)
} }
if format == "json" {
args = append(args, "--progress")
}
outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostics}) outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostics})
if outcome.Status != 0 { if outcome.Status != 0 {
t.Fatalf("outcome=%+v diagnostics=%s", outcome, diagnostics.String()) t.Fatalf("outcome=%+v diagnostics=%s", outcome, diagnostics.String())
@@ -45,6 +48,9 @@ func TestPreflightCommandReportsNativeFormats(t *testing.T) {
if err != nil || report["ready"] != true || report["session_id"] != "2026-05-03" || report["checks"] == nil { if err != nil || report["ready"] != true || report["session_id"] != "2026-05-03" || report["checks"] == nil {
t.Fatalf("report=%+v output=%s error=%v", report, out.String(), err) t.Fatalf("report=%+v output=%s error=%v", report, out.String(), err)
} }
if format == "json" && !strings.Contains(diagnostics.String(), "checking Audita readiness") {
t.Fatalf("missing check progress on stderr: %s", diagnostics.String())
}
}) })
} }
provider.PreflightErr = errors.New("synthetic provider failure") provider.PreflightErr = errors.New("synthetic provider failure")

View File

@@ -98,6 +98,11 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
report.Preparation = preparationAssessment{Outcome: item.Outcome, Reason: item.Reason} report.Preparation = preparationAssessment{Outcome: item.Outcome, Reason: item.Reason}
prepared = prepareErr == nil && (item.Outcome == "completed" || item.Outcome == "reused") 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 { if prepareErr != nil {
report.Findings = append(report.Findings, errorFinding("preparation", prepareErr.Error())) report.Findings = append(report.Findings, errorFinding("preparation", prepareErr.Error()))
} }
@@ -112,9 +117,15 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
if prepared { if prepared {
report.Findings = append(report.Findings, okFinding("inputs", "prepared session inputs and audio are current")) report.Findings = append(report.Findings, okFinding("inputs", "prepared session inputs and audio are current"))
if record := runtime.manifest.Stages["prepare"]; record != nil { if record := runtime.manifest.Stages["prepare"]; record != nil {
if missing, ok := record.Metadata["previous_artifacts_missing_optional"]; ok { 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))) 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"))
}
} }
} }
var failures []error var failures []error
@@ -195,3 +206,20 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
} }
return errors.Join(append(failures, runtime.ctx.Err())...) return errors.Join(append(failures, runtime.ctx.Err())...)
} }
func previousArtifactNames(value any) []string {
switch items := value.(type) {
case []string:
return items
case []any:
var names []string
for _, item := range items {
if name, ok := item.(string); ok {
names = append(names, name)
}
}
return names
default:
return nil
}
}

View File

@@ -14,6 +14,7 @@ import (
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest" "gitea.maximumdirect.net/eric/narratio/internal/manifest"
"gitea.maximumdirect.net/eric/narratio/internal/stage"
"go.maximumdirect.net/commandkit" "go.maximumdirect.net/commandkit"
) )
@@ -197,3 +198,34 @@ func TestPreflightDoesNotProbeSupersededPreparationAfterFailure(t *testing.T) {
t.Fatalf("failed=%+v calls=%d error=%v", failed, len(provider.PreflightRequests), err) t.Fatalf("failed=%+v calls=%d error=%v", failed, len(provider.PreflightRequests), err)
} }
} }
func TestPreflightCannotSucceedWithoutPreparedEvidence(t *testing.T) {
cfg := testConfig(t)
deps := normalizeCommandDependencies(fakeCommandDependencies(&storage.FakeBackend{}, nil))
report := &sessionReadinessReport{Preparation: preparationAssessment{Outcome: "not_attempted"}}
plan := BoundedPlan{stages: []stage.Stage{resultStage{name: "prepare", result: &stage.StageResult{Disposition: stage.StageDispositionSkipped, SkipReason: "no inputs"}}}}
summary, err := withLockedInvocation(context.Background(), cfg, plan, RunOptions{}, invocationDependencies{newAudita: deps.newAudita, newScriptorium: deps.newScriptorium}, func(runtime *invocationRuntime) error {
return assessSessionReadiness(runtime, report, deps)
})
if err == nil || summary == nil || summary.Complete || report.Preparation.Outcome != "failed" {
t.Fatalf("summary=%+v report=%+v error=%v", summary, report, err)
}
}
func TestPreflightReportsOptionalPreviousInputsAcrossReuse(t *testing.T) {
pipeline, campaign, session := writeValidConfigFilesWithScriptoriumArtifacts(t, t.TempDir())
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
if err != nil {
t.Fatal(err)
}
artifact := cfg.ArtifactCatalog.Artifacts["player_handout"]
artifact.Inputs["recap"] = config.ScriptoriumInputConfig{Source: "narratio.previous_session.artifact.session_recap", Required: false}
cfg.ArtifactCatalog.Artifacts["player_handout"] = artifact
deps := fakeCommandDependencies(&storage.FakeBackend{}, nil)
for _, want := range []string{"completed", "reused"} {
report, err := inspectConfiguredForTest(context.Background(), cfg, deps)
if err != nil || !report.Ready || report.Preparation.Outcome != want || !findingMatches(report.Findings, "INFO", "previous", "session_recap") {
t.Fatalf("report=%+v error=%v", report, err)
}
}
}

View File

@@ -173,3 +173,96 @@ func TestSessionValidationCancellationWhileSessionIsLocked(t *testing.T) {
t.Fatalf("waiting validation created probe paths: %v", err) t.Fatalf("waiting validation created probe paths: %v", err)
} }
} }
type observedPreparationStore struct {
manifest.Store
saved chan struct{}
proceed chan struct{}
}
func (s *observedPreparationStore) Save(ctx context.Context, path string, m *manifest.Manifest) error {
if err := s.Store.Save(ctx, path, m); err != nil {
return err
}
if record := m.Stages["prepare"]; record != nil && record.Status == manifest.StatusSucceeded {
select {
case s.saved <- struct{}{}:
case <-ctx.Done():
return ctx.Err()
}
select {
case <-s.proceed:
case <-ctx.Done():
return ctx.Err()
}
}
return nil
}
func TestPreflightKeepsLockFromPreparationThroughProbe(t *testing.T) {
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
cfg, err := config.Load(pipeline, campaign, session)
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
save := &observedPreparationStore{Store: &manifest.LocalStore{}, saved: make(chan struct{}, 1), proceed: make(chan struct{})}
entered, release := make(chan struct{}), make(chan struct{})
probe := &lockedAuditaProbe{check: func(ctx context.Context, _, _ string) error {
close(entered)
select {
case <-release:
return nil
case <-ctx.Done():
return ctx.Err()
}
}}
deps := normalizeCommandDependencies(fakeCommandDependencies(&storage.FakeBackend{}, nil))
deps.newAudita = func(*config.Config) (audita.Runner, error) { return probe, nil }
plan, err := BuildBoundedPlan("prepare", "prepare")
if err != nil {
t.Fatal(err)
}
report := &sessionReadinessReport{}
done := make(chan error, 1)
go func() {
_, err := withLockedInvocation(ctx, cfg, plan, RunOptions{Env: &Env{ManifestStore: save}}, invocationDependencies{newAudita: deps.newAudita, newScriptorium: deps.newScriptorium}, func(runtime *invocationRuntime) error { return assessSessionReadiness(runtime, report, deps) })
done <- err
}()
store := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root)
assertLocked := func() {
t.Helper()
lock, err := store.AcquireSessionLockFor(cfg.Session.Campaign, cfg.Session.SessionID)
if lock != nil {
_ = store.ReleaseSessionLock(lock)
}
if !errors.Is(err, artifacts.ErrLockConflict) {
t.Fatalf("session lock is not held: %v", err)
}
}
select {
case <-save.saved:
case err := <-done:
t.Fatalf("preparation stopped: %v", err)
case <-ctx.Done():
t.Fatal(ctx.Err())
}
assertLocked()
close(save.proceed)
select {
case <-entered:
case err := <-done:
t.Fatalf("probe did not start: %v", err)
case <-ctx.Done():
t.Fatal(ctx.Err())
}
assertLocked()
close(release)
if err := <-done; err != nil {
t.Fatal(err)
}
if report.Preparation.Outcome != "completed" {
t.Fatalf("preparation=%+v", report.Preparation)
}
}