Document standalone preflight and complete verification
This commit is contained in:
35
docs/cli.md
35
docs/cli.md
@@ -5,13 +5,13 @@
|
||||
```text
|
||||
narratio
|
||||
├── run SESSION
|
||||
├── preflight SESSION
|
||||
├── artifacts
|
||||
│ ├── list
|
||||
│ └── regenerate SESSION
|
||||
├── session
|
||||
│ ├── init SESSION
|
||||
│ ├── plan SESSION
|
||||
│ ├── validate SESSION
|
||||
│ ├── status SESSION
|
||||
│ ├── restore SESSION
|
||||
│ ├── 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
|
||||
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
|
||||
do not. `artifacts regenerate` uses the same check.
|
||||
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
|
||||
predict unknown output identities.
|
||||
|
||||
## Session validate
|
||||
## Preflight
|
||||
|
||||
```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,
|
||||
publication, and lock readiness. Audita preflight uses existing prepared inputs,
|
||||
probes temporary destinations under `runs/.validation`, and may contact configured
|
||||
providers. It also inspects enabled trim
|
||||
and analysis definitions and their configured prerequisites, regardless of
|
||||
output reuse. Missing prompt requirements or unsuccessful inspection invalidate
|
||||
the report; incomplete or conditional discovery alone is a warning. Material
|
||||
findings remain in the report regardless of diagnostic visibility. Invalid
|
||||
configuration uses the native input classification; readiness failures are
|
||||
operational failures.
|
||||
Preflight resolves the same session and configuration selectors as `run`,
|
||||
prepares or reuses inputs, and checks enabled downstream capabilities and
|
||||
prompt prerequisites even when their processing outputs are reusable. It may
|
||||
create a workspace, download inputs, update the manifest, and contact providers.
|
||||
It stops before processing and publication. Required failures or blocked
|
||||
checks prevent readiness; conditional or incomplete prompt discovery can warn
|
||||
without failing. Preparation remains reusable after a later readiness failure.
|
||||
See [operations](operations.md#prompt-requirements-preflight) for details.
|
||||
|
||||
## 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` |
|
||||
| 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 |
|
||||
| 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` |
|
||||
| Init | `campaign`, `session_id`, `destination`, `remote`, `written` |
|
||||
| Locks | Identities, `operation`, `result`, `complete`, optional `source`, `locks` |
|
||||
| Restore | Identities/run, `dry_run`, `complete`, `status`, `downloaded`, `conflicts`, `actions` |
|
||||
| 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,
|
||||
including failures and self-skips. `skipped` includes reuse and self-skips.
|
||||
Each `stage_results` entry has `name`, `attempted`, `outcome`
|
||||
|
||||
@@ -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
|
||||
files with a synthetic transcript. Audita's provider smoke checks remain enabled;
|
||||
they can contact providers and destination probes can create directories.
|
||||
`session validate` uses existing prepared records and a validation probe
|
||||
namespace. A successful check is not a guarantee about later real-transcript
|
||||
processing or editorial quality. See [operations](../operations.md#prompt-requirements-preflight)
|
||||
Standalone `preflight` prepares or reuses inputs and checks Audita regardless
|
||||
of output reuse, using invocation-scoped probe destinations. A successful check
|
||||
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).
|
||||
|
||||
Each `pipeline.audita.credentials` value is an exact ConfigKit secret reference.
|
||||
|
||||
@@ -62,9 +62,10 @@ command configuration loader may still use object storage to retrieve a missing
|
||||
remote session file before planning begins.
|
||||
|
||||
After preparation, the application projects remaining selected work and uses
|
||||
invocation-owned Audita, Notarius, and Scriptorium runners for applicable readiness checks.
|
||||
The same runners are available to processing. Explicit session validation uses
|
||||
existing prepared inputs and invocation-owned factories. See
|
||||
invocation-owned Audita, Notarius, and Scriptorium runners for applicable
|
||||
readiness checks. The same runners are available to processing. Standalone
|
||||
preflight prepares inputs through the same lifecycle and uses invocation-owned
|
||||
factories for all enabled readiness checks. See
|
||||
[preflight internals](preflight.md).
|
||||
|
||||
Notarius is composed only when extraction is enabled. The stage resolves
|
||||
|
||||
@@ -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.
|
||||
The lock remains held from manifest initialization through finalization, and a
|
||||
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
|
||||
|
||||
@@ -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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
@@ -119,7 +121,7 @@ so any earlier replacement can stale a prior cleanup result.
|
||||
- [Adapter Internals](adapters.md): external adapter boundaries, composition,
|
||||
failure behavior, and test surfaces.
|
||||
- [Preflight Internals](preflight.md): projected target selection and shared
|
||||
requirements assessment.
|
||||
requirements assessment and standalone preparation.
|
||||
- [Artifact Internals](artifacts.md): source identities, runtime catalog,
|
||||
resolution, previous requirements, and current-state helpers.
|
||||
- [Manifest Internals](manifest.md): session records, persistence, and execution
|
||||
|
||||
@@ -1,44 +1,41 @@
|
||||
# Internal: Downstream Preflight
|
||||
|
||||
The application performs downstream checks after selected preparation completes
|
||||
or is reused and before remaining selected processing. It projects remaining
|
||||
work against a clone of the locked manifest using the same stage decisions and
|
||||
analysis planner as `session plan`. Projected polish selects Audita; projected
|
||||
enabled extraction selects Notarius inspection and preflight; enabled trim and
|
||||
analysis select Scriptorium requirements. A projection is not
|
||||
an execution commitment. Empty target sets invoke no checker.
|
||||
The application runs automatic downstream checks after selected preparation and
|
||||
before selected processing. It projects remaining work against a clone of the
|
||||
locked manifest, using the stage decisions and analysis planner shared with
|
||||
`session plan`. Projected polish selects Audita; projected enabled extraction
|
||||
selects Notarius; projected trim and analysis select Scriptorium requirements.
|
||||
A projection is not an execution commitment, and an empty target set invokes no
|
||||
checker.
|
||||
|
||||
Audita receives the verified four prepared glossary files and the same
|
||||
processing selectors and destinations, with an embedded synthetic transcript.
|
||||
The adapter runs native preflight with provider smoke enabled, captures its
|
||||
transient diagnostics, and preserves exit classification. No preflight result
|
||||
is cached as a stage. A failure stops later processing without presenting it as
|
||||
complete.
|
||||
Standalone `preflight` acquires configuration once and uses the runner's locked
|
||||
invocation lifecycle to execute or reuse `prepare`. Within that same lock it
|
||||
selects all enabled capabilities and prompt prerequisites regardless of reuse,
|
||||
then invokes the shared downstream request builders and checkers. A preparation
|
||||
failure blocks probes requiring prepared inputs but permits independent prompt
|
||||
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
|
||||
checks an available verified transcript or reports that a synthetic one was used.
|
||||
Readiness warnings and native failures remain visible; checks do not publish work.
|
||||
|
||||
For `session validate`, the application selects enabled downstream definitions
|
||||
independently of reuse and checks the existing prepared manifest. It does not
|
||||
resolve live files into candidate glossary projections or run prepare. The
|
||||
Audita probe under `runs/.validation` can create or probe directories and contact
|
||||
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.
|
||||
Audita receives verified prepared glossary files and production selections with
|
||||
an embedded synthetic transcript. Its adapter performs native provider smoke
|
||||
checks and retains failure causes. Notarius receives production controls and
|
||||
verified reference snapshots, which are checked again after its native call.
|
||||
The application projects transcript-producing work before allowing a verified
|
||||
current transcript; otherwise it reports the synthetic fallback. Neither probe
|
||||
publishes work, and the synthetic input cannot establish real-transcript
|
||||
feasibility or editorial quality.
|
||||
|
||||
Scriptorium input-map keys remain binding names distinct from Narratio source
|
||||
IDs. Missing required bindings or variables and inspection failures are errors;
|
||||
optional sources for required inputs, conditional requirements, incomplete
|
||||
discovery, and discovery issues produce warnings. The checker preserves earlier
|
||||
findings and stops on cancellation. Actual input resolution remains authoritative.
|
||||
discovery, and discovery issues produce warnings. Findings survive independent
|
||||
failures and cancellation stops new work.
|
||||
|
||||
See [Audita](../integrations/audita.md), [Scriptorium](../integrations/scriptorium.md),
|
||||
[CLI](../cli.md#session-validate), and [operations](../operations.md#prompt-requirements-preflight).
|
||||
Implementation and tests are in `internal/preflight`, `internal/app/runner_preflight.go`,
|
||||
`internal/app/session_inspection_command.go`, and `internal/adapters/audita/preflight.go`.
|
||||
Probe files use invocation-scoped destinations under `runs/`, protected by the
|
||||
session lock through report consumption, reference verification, and terminal
|
||||
persistence. A later authorized cleanup can remove those files without removing
|
||||
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`.
|
||||
|
||||
@@ -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
|
||||
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.
|
||||
Standalone validation uses the same lock for its prepared-state reads and
|
||||
session-local readiness probes, keeping active probe files outside concurrent
|
||||
cleanup. Validation leaves stage progress unchanged.
|
||||
Standalone preflight holds the same lock through preparation, readiness probes,
|
||||
and finalization, keeping active probe files outside concurrent cleanup.
|
||||
Preparation uses ordinary manifest transitions and invalidation.
|
||||
|
||||
The runner assigns every invocation a run-workspace identity but creates the
|
||||
physical run directory and its `runs/` parent only when an executing stage
|
||||
requires them. Fully reused invocations and cleanup-only invocations therefore do not accumulate
|
||||
empty run directories.
|
||||
physical stage run directory only when an executing stage requires it. Fully
|
||||
reused pipeline invocations and cleanup-only invocations do not accumulate
|
||||
empty run directories. Readiness probes create their separate invocation-scoped
|
||||
diagnostic directories when checks run, including during a reused preparation.
|
||||
|
||||
## Cleanup Semantics
|
||||
|
||||
|
||||
@@ -72,11 +72,10 @@ This guidance does not create a release or publish any changes.
|
||||
## Standard Session Workflow
|
||||
|
||||
1. Select pipeline/campaign/session config.
|
||||
2. Prepare inputs, then validate session readiness:
|
||||
2. Prepare inputs and check session readiness:
|
||||
|
||||
```bash
|
||||
narratio run 2026-04-04 --stage prepare
|
||||
narratio session validate 2026-04-04
|
||||
narratio preflight 2026-04-04
|
||||
```
|
||||
|
||||
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.
|
||||
`session plan` does not invoke these downstream checks.
|
||||
|
||||
`session validate` checks enabled downstream definitions against existing
|
||||
prepared glossary records. It does not prepare inputs. Its Audita probe uses a
|
||||
`runs/.validation` destination namespace, may create or probe directories and
|
||||
may contact configured providers. The synthetic check establishes readiness for
|
||||
that probe, not feasibility for a real transcript or editorial quality. See
|
||||
[Audita](integrations/audita.md) and [Scriptorium](integrations/scriptorium.md).
|
||||
Session-local Audita and Notarius probes share the session lock with pipeline
|
||||
runs and restore. Validation waits while that lock is held, honors cancellation,
|
||||
and leaves stage progress unchanged. Cleanup can remove finished probe files
|
||||
after validation releases the lock.
|
||||
Standalone `preflight` prepares or reuses the session's real inputs before
|
||||
checking every enabled downstream capability and prompt prerequisite, including
|
||||
work whose outputs could be reused. It may create workspace state, download
|
||||
inputs, update the manifest, and contact providers. Changed inputs can stale
|
||||
dependent stage records through ordinary preparation rules. Preparation remains
|
||||
available for reuse if a later readiness check fails. Preflight stops before
|
||||
processing, publishing, notification, or cleanup.
|
||||
|
||||
Audita checks a synthetic transcript. Notarius uses a verified trimmed
|
||||
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
|
||||
|
||||
|
||||
@@ -130,8 +130,9 @@ not configurable.
|
||||
|
||||
Downstream readiness is an invocation check after selected preparation and
|
||||
before the selected processing work. It does not create a stage success.
|
||||
Session validation uses existing prepared inputs; its downstream checks may
|
||||
probe destinations and contact configured providers.
|
||||
Standalone preflight prepares or reuses session inputs and checks enabled
|
||||
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
|
||||
outcome is persisted, clears older outputs owned by the stage, and is
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Standalone Session Preflight Implementation Plan
|
||||
|
||||
Status: In progress.
|
||||
Status: Complete.
|
||||
|
||||
## 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
|
||||
|
||||
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),
|
||||
[Troubleshooting](../troubleshooting.md), [Internal Overview](../internal/overview.md),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Standalone Session Preflight
|
||||
|
||||
Status: Planned; not implemented.
|
||||
Status: Implemented. The next release notes must identify the migration from
|
||||
`session validate` to `preflight`.
|
||||
|
||||
## 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
|
||||
different rules for selecting what to check.
|
||||
|
||||
## Current Baseline
|
||||
## Baseline Before Implementation
|
||||
|
||||
- `session validate` already checks configuration, stable inputs, local or remote
|
||||
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
|
||||
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
|
||||
[CLI reference](../cli.md#session-validate). Principal implementation owners are
|
||||
`internal/app/session_inspection_command.go`, `operator_inspection.go`,
|
||||
`runner.go`, `runner_preflight.go`, `preflight_targets.go`, `internal/preflight`,
|
||||
[CLI reference](../cli.md#preflight). Principal implementation owners are
|
||||
`internal/app/session_readiness.go`, `downstream_readiness.go`, `runner.go`,
|
||||
`runner_preflight.go`, `preflight_targets.go`, `internal/preflight`,
|
||||
and the existing stage request builders and downstream adapters.
|
||||
|
||||
## Targeted End State
|
||||
|
||||
@@ -39,7 +39,7 @@ Likely cause:
|
||||
Diagnostics:
|
||||
|
||||
```bash
|
||||
narratio session validate 2026-04-04 --session-file /path/session.yml
|
||||
narratio preflight 2026-04-04 --session-file /path/session.yml
|
||||
```
|
||||
|
||||
Safe fix:
|
||||
@@ -150,7 +150,7 @@ Likely cause:
|
||||
Diagnostics:
|
||||
|
||||
```bash
|
||||
narratio session validate 2026-04-04
|
||||
narratio preflight 2026-04-04
|
||||
```
|
||||
|
||||
Safe fix:
|
||||
@@ -348,12 +348,12 @@ Relevant references: [Secrets](./config.md#secrets-handling) and
|
||||
|
||||
## 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
|
||||
campaign inline contribution. Re-run `prepare` after correcting the 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).
|
||||
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
|
||||
|
||||
@@ -451,7 +451,7 @@ Diagnostics:
|
||||
|
||||
```bash
|
||||
narratio session status 2026-04-04
|
||||
narratio session validate 2026-04-04
|
||||
narratio preflight 2026-04-04
|
||||
```
|
||||
|
||||
Safe fix:
|
||||
@@ -701,7 +701,7 @@ and [Manifest Internals](./internal/manifest.md#transcribe-owned-speaker-state).
|
||||
|
||||
## 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
|
||||
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
|
||||
@@ -771,7 +771,7 @@ Likely causes:
|
||||
Diagnostics:
|
||||
|
||||
```bash
|
||||
narratio session validate 2026-04-04
|
||||
narratio preflight 2026-04-04
|
||||
narratio session status 2026-04-04
|
||||
```
|
||||
|
||||
@@ -968,7 +968,7 @@ Likely causes:
|
||||
Diagnostics:
|
||||
|
||||
```bash
|
||||
narratio session validate 2026-04-04
|
||||
narratio preflight 2026-04-04
|
||||
```
|
||||
|
||||
Safe fix:
|
||||
|
||||
@@ -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"})
|
||||
}
|
||||
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()
|
||||
}
|
||||
@@ -50,6 +51,7 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
|
||||
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)
|
||||
@@ -69,6 +71,7 @@ func checkDownstreamReadiness(runtime *invocationRuntime, targets preflight.Targ
|
||||
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...)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,6 +82,7 @@ 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()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestDownstreamReadinessContinuesAfterIndependentFailures(t *testing.T) {
|
||||
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()}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ func TestPreflightCommandReportsNativeFormats(t *testing.T) {
|
||||
if format != "auto" {
|
||||
args = append(args, "--format", format)
|
||||
}
|
||||
if format == "json" {
|
||||
args = append(args, "--progress")
|
||||
}
|
||||
outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostics})
|
||||
if outcome.Status != 0 {
|
||||
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 {
|
||||
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")
|
||||
|
||||
@@ -98,6 +98,11 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
|
||||
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()))
|
||||
}
|
||||
@@ -112,9 +117,15 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
|
||||
if prepared {
|
||||
report.Findings = append(report.Findings, okFinding("inputs", "prepared session inputs and audio are current"))
|
||||
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)))
|
||||
}
|
||||
if _, required := record.Metadata["previous_requirements_count"]; !required {
|
||||
report.Findings = append(report.Findings, infoFinding("previous", "no previous-session artifacts required"))
|
||||
}
|
||||
}
|
||||
}
|
||||
var failures []error
|
||||
@@ -195,3 +206,20 @@ func assessSessionReadiness(runtime *invocationRuntime, report *sessionReadiness
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"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"
|
||||
"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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,3 +173,96 @@ func TestSessionValidationCancellationWhileSessionIsLocked(t *testing.T) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user