245 lines
14 KiB
Markdown
245 lines
14 KiB
Markdown
# Dedicated Preflight Command
|
|
|
|
Status: Design decisions agreed. The ordered work is defined in the
|
|
[implementation plan](implementation.md). Implementation has not begun.
|
|
|
|
## Purpose and Targeted End State
|
|
|
|
Provide `audita preflight` so operators and orchestration applications such as
|
|
Narratio can check a proposed processing invocation without executing its
|
|
correction pipeline. Retain the existing `audita process` command and add
|
|
`audita run` as an alias. Both names use the same processing command definition,
|
|
arguments, execution path, and outcome behavior; no separate implementation or
|
|
deprecation of `process` is intended.
|
|
|
|
Preflight accepts the same transcript argument and processing options, including
|
|
configuration, overlay, runtime glossary files, profile and collection selections,
|
|
and intended output/report/debug settings. It adds a boolean `--smoke` option,
|
|
enabled by default:
|
|
|
|
```sh
|
|
audita preflight --config audita.yml --overlay selected \
|
|
--glossary-file session-glossaries.yml --output polished.json transcript.json
|
|
|
|
audita preflight --smoke=false --config audita.yml \
|
|
--output polished.json transcript.json
|
|
```
|
|
|
|
These are target commands, not implemented interfaces. Default preflight runs
|
|
shared local preparation followed by native PromptKit structured-output smoke
|
|
diagnostics for the selected profiles. `--smoke=false` runs local checks only.
|
|
CommandKit reports which scope was checked and the outcome. No persistent
|
|
preflight report format is required for this feature; callers can use exit status.
|
|
|
|
Ordinary `process` (also invoked as `run`) reuses shared preparation and proceeds
|
|
to execution without adding smoke requests to every processing run. Native
|
|
configuration inspection and individual PromptKit diagnostic commands remain
|
|
available for their existing purposes.
|
|
|
|
## Current Baseline
|
|
|
|
Reviewed at Audita commit `8411a69`. Runtime glossary inputs and collection
|
|
instructions are implemented. Dependencies include ConfigKit v1.4.0, PromptKit
|
|
v0.25.0, CommandKit v0.8.0, ckconfig v0.11.0, and ckprompt v0.12.0.
|
|
|
|
- `internal/cli/loadProcessInputs` acquires combined configuration and runtime
|
|
glossary inputs, constructs the PromptKit runtime, reads/parses the transcript,
|
|
and collects source paths for collision checks. It also enforces the current
|
|
quiet-processing destination rule.
|
|
- `internal/framework/preflight.ProcessingPlan` checks glossary-stage content,
|
|
proposal and validation profiles, and repair profiles when repair is enabled.
|
|
It resolves stage specifications and prepares shared glossary context.
|
|
- `preflight.Prepare`, called through CLI preparation, then selects and prepares
|
|
an output session, initializes reports, and may create debug artifacts. Calling
|
|
this whole function from the new command would perform unwanted output work.
|
|
- Normalization currently occurs later in `runProcess`; chunking occurs in the
|
|
runner. A standalone readiness check needs these deterministic preparation
|
|
steps without executing proposal, validation, repair, or correction application.
|
|
- PromptKit already exposes `Engine.SmokeTest` with a structured-output diagnostic
|
|
and native observations. A nil Go error means the diagnostic concluded, not
|
|
that its observations establish success.
|
|
|
|
The [CLI contract](../cli.md), [operations guide](../operations.md),
|
|
[pipeline internals](../internal/pipeline.md), and
|
|
[configuration/CLI guide](../internal/cli-config.md) describe current behavior.
|
|
PromptKit's [v0.25.0 consumer guide](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/consumers/pkg-promptkit.md#run-explicit-smoke-diagnostics)
|
|
owns the diagnostic API and its native semantics.
|
|
|
|
## Shared Preparation and Execution Boundaries
|
|
|
|
Refactor as needed for correctness and clear ownership, including substantial
|
|
changes where warranted. Minimizing the diff or preserving current helper/package
|
|
boundaries is not a design objective. Keep the resulting design proportionate;
|
|
this feature needs a shared preparation path, not a new workflow framework.
|
|
|
|
### Shared Local Preparation
|
|
|
|
Both commands use the same argument bindings and acquisition path, retaining
|
|
ConfigKit's source composition, configured secrets bootstrap, CLI precedence,
|
|
and runtime glossary handling. Do not duplicate configuration interpretation in
|
|
the preflight command.
|
|
|
|
Prepare an invocation-local execution plan containing the data needed for actual
|
|
processing: resolved settings and stages, prepared glossary context, normalized
|
|
transcript and normalization summary, fixed chunks, selected profile references,
|
|
and intended destination information. Exact Go types and package placement belong
|
|
to implementation planning. Retain an expressly named preflight package for
|
|
Audita's domain readiness orchestration.
|
|
|
|
Perform existing transcript, glossary, profile, normalization, chunking-feasibility,
|
|
and destination checks in their appropriate owners. For example, an infeasible
|
|
requested section count should fail before smoke testing or model processing.
|
|
Reuse stage/profile inspection and prepared context rather than doing the same
|
|
work separately for each command. Preserve collection instructions and all
|
|
existing protection and role-fallback rules.
|
|
|
|
Processing consumes this plan rather than normalizing, chunking, or resolving
|
|
stage selections independently again. This is shared code and invocation-local
|
|
data, not a persisted plan, cross-process cache, or a promise that a subsequent
|
|
invocation reuses the same configuration snapshot.
|
|
|
|
### Provider Verification
|
|
|
|
After local readiness succeeds, default standalone preflight calls PromptKit's
|
|
native structured-output smoke diagnostic once per distinct selected profile ID.
|
|
Include proposal, validation, and enabled correction-repair profiles from the
|
|
resolved plan. Repeated uses of one profile share a check; two profiles on the
|
|
same backend remain distinct targets because their models or settings can differ.
|
|
Do not inspect the whole bundled catalog to invent additional smoke targets.
|
|
An empty pipeline has no model profiles to smoke-test and remains valid.
|
|
|
|
Use the existing captured PromptKit engine and native effective profile settings.
|
|
Keep transport, credentials, diagnostic request construction, retries, admission,
|
|
and observations in PromptKit. Do not substitute a custom miniature Audita prompt
|
|
or execute production transcript requests. Reachability, authentication, and
|
|
text-only diagnostics remain accessible through existing native commands; this
|
|
command does not automatically run the entire diagnostic inventory.
|
|
|
|
Audita owns the small outcome adaptation: when smoke is enabled, every selected
|
|
profile needs a positive structured-output result. Evaluate the native report's
|
|
completion, support/applicability, execution failure, and generation/schema
|
|
observations; a nil error or completed report alone is insufficient. Negative,
|
|
unsupported, or inconclusive results do not establish successful preflight and
|
|
must be identified distinctly in diagnostics. Do not require unrelated HTTP-only
|
|
facts to be present for an inference diagnostic. Preserve native errors and
|
|
available partial observations, especially on cancellation.
|
|
|
|
`--smoke=false` skips this provider-verification phase, not local profile selection
|
|
or ordinary configuration/credential resolution. It does not introduce a new
|
|
credential-relaxation mode or alter ConfigKit bootstrap behavior. Use upstream
|
|
defaults for diagnostic execution controls unless an existing applicable setting
|
|
must be passed through; add no new retry loop, aggregate budget, or timeout policy.
|
|
|
|
### Output Resources and Processing
|
|
|
|
Standalone preflight checks intended output paths and the existing collision and
|
|
placement rules without creating or truncating transcript/report files, initializing
|
|
processing reports, or retaining processing debug artifacts. Reporting and debug
|
|
flags remain accepted, describing the intended invocation; they do not initiate
|
|
the output lifecycle. CommandKit's diagnostic reporting still applies.
|
|
|
|
Separate destination checking and temporary readiness probes from acquisition
|
|
and publication of processing outputs. For each active regular-file transcript
|
|
or report destination, apply the normal path, destination-type, and collision
|
|
checks, then create/open a temporary sibling file for writing, close it, and
|
|
remove it. This mirrors the directory access used for regular-file output
|
|
preparation while leaving the final destination untouched. Creating the probe
|
|
alone does not replace checks on the intended destination itself. Perform these
|
|
probes regardless of quiet mode and before provider verification, including when
|
|
`--smoke=false` selects local checks only.
|
|
|
|
Use standard filesystem operations and reuse output-adapter logic where useful.
|
|
Attempt cleanup on failures and cancellation and report probe/close/cleanup errors
|
|
through existing output-error handling rather than silently reporting readiness.
|
|
Do not open the final path with create/truncate flags or initialize ordinary
|
|
reports as a write test. Required output parents retain their existing requirements;
|
|
preflight does not create missing output directories to make a probe succeed.
|
|
|
|
Preserve existing in-place transcript support, inactive-destination handling, and
|
|
optional-debug failure severity. Pipes and devices use their destination-specific
|
|
handling rather than a regular-file probe; preflight must not block waiting for a
|
|
pipe reader or write to a stream. Stdout has no transcript-file probe. Required
|
|
report destinations are probed only when reporting is enabled. Do not introduce
|
|
permission-bit simulations or stronger filesystem guarantees: probes check present
|
|
write readiness, while actual output preparation and publication still occur
|
|
when processing runs.
|
|
|
|
Processing performs local preparation, then acquires output resources, initializes
|
|
its reports/debug evidence, and executes the prepared stages and chunks. Preserve
|
|
cleanup, cancellation, publication, and partial-failure semantics at that boundary.
|
|
Moving normalization/chunking before output initialization intentionally means
|
|
those early failures need not leave processing reports; document that lifecycle
|
|
change rather than fabricating an execution session during readiness checking.
|
|
|
|
## Reporting and Command Semantics
|
|
|
|
Use CommandKit's reporter and outcome handling for progress, summaries, errors,
|
|
and quiet mode. Progress can identify local preparation and each profile being
|
|
checked. The completion summary identifies local-only versus local-plus-smoke
|
|
scope, including when there were no profiles to test. Preserve native usage
|
|
reporting integration where applicable rather than adding local accounting.
|
|
|
|
Use existing exit categories: success is `0`, invalid usage/input is `2`, and
|
|
operational failure is `1`. Continue native configuration diagnostic classification.
|
|
An unsuccessful or inconclusive provider verification is an operational failure;
|
|
missing required profile selections remain input failures. No new exit-code family,
|
|
machine-report schema, or mandatory retained artifacts are selected.
|
|
|
|
Destination flags describe the would-be processing outputs; standalone preflight
|
|
does not emit a corrected transcript. Quiet preflight requires `--output`, including
|
|
`/dev/null` when deliberately selected, just as `process`/`run` does. Supplying the
|
|
intended destination allows preflight to check where processing would write;
|
|
a placeholder does not validate a different eventual output path. Nonquiet
|
|
invocations may retain the existing stdout selection when output is omitted.
|
|
Help/version continue to avoid configuration loading.
|
|
Do not turn the command into a general side-effect-free guarantee: temporary
|
|
write probes and configured secrets bootstrap apply, and provider verification
|
|
is enabled by default. Link upstream documentation for standard diagnostic
|
|
behavior rather than maintaining an Audita copy of the smoke-test reference.
|
|
|
|
## Delivery Scope
|
|
|
|
Delivery includes the shared local execution plan, standalone `preflight`,
|
|
default native structured-output verification, non-destructive final-destination
|
|
checks with temporary probes, and `run` as an alias of `process`. The
|
|
[implementation plan](implementation.md) owns the ordered refactoring and
|
|
implementation steps. Canonical CLI, operations, subprocess and internal
|
|
pipeline/output documentation will describe delivered behavior when it lands.
|
|
Narratio can adopt readiness independently; D&D-specific processing rules and
|
|
consumer adapter changes remain outside Audita.
|
|
|
|
## Validation
|
|
|
|
Follow the [testing policy](../policy/testing.md). Use real local collaborators
|
|
and controlled provider responses; default tests remain offline and require no
|
|
real credentials. Focus coverage on:
|
|
|
|
- Argument/configuration parity, including overlays, runtime glossaries, stage
|
|
overrides, profile fallback, and rejection of quiet preflight without output.
|
|
- A representative CLI invocation through `run` exercising the same processing
|
|
arguments and outcome behavior as `process`, without duplicating the processing
|
|
test suite for the alias.
|
|
- Shared normalized transcript/chunk/stage preparation, including an infeasible
|
|
chunk count, and processing consumption of the prepared plan.
|
|
- Local failures stopping before smoke calls; `--smoke=false` making none; default
|
|
smoke selecting distinct used profiles and omitting disabled repair roles.
|
|
- Positive and negative structured-output facts, nil-error negative reports,
|
|
unknown/unsupported outcomes, provider errors, and cancellation.
|
|
- Preflight preserving existing transcript/report files and avoiding output/debug
|
|
initialization, while detecting existing destination collisions and invalid
|
|
destination types. Verify temporary sibling creation and removal for enabled
|
|
regular-file destinations, including local-only and nonquiet invocations.
|
|
- Probe, close, and cleanup failures and cancellation; missing required parents;
|
|
inactive reports remaining unprobed; and pipes/devices avoiding blocking delivery
|
|
opens and stream writes. Use controlled failures rather than permission tests
|
|
that depend on the test process's user privileges.
|
|
- Processing retaining its output publication and cleanup behavior after the
|
|
refactor, without automatically performing smoke tests.
|
|
- CommandKit completion, progress, quiet, and exit behavior at representative CLI
|
|
boundaries, without freezing incidental presentation or upstream report layouts.
|
|
|
|
Reuse existing coverage for unchanged domain logic and upstream behavior. Run
|
|
focused tests during implementation and the repository's normal full suite and
|
|
build before completion. This documentation pass does not execute provider tests
|
|
or implement the command.
|