Prepare v4.2.0 notes and retire completed plans

This commit is contained in:
2026-11-27 04:19:36 +00:00
parent b96eeb57ba
commit cbb2f768be
5 changed files with 67 additions and 853 deletions

View File

@@ -1,362 +0,0 @@
# Dedicated Preflight Command: Implementation Plan
Status: Complete.
Implement the target in [Dedicated Preflight Command](preflight-command.md).
That roadmap owns the behavior and policy choices; this document defines the
ordered work for a Luna coding agent. Reviewed baseline:
`604ae631b39b48c5ab80871ffcd76cdf8db6e108`.
## Execution and scope
Execute Stage 1 through Stage 8 in order during one end-to-end sprint.
Intermediate stages need not compile. Update internal callers and tests directly;
remove obsolete paths rather than building temporary compatibility wrappers.
Run focused tests once the relevant path is complete, followed by final validation.
Follow `docs/development.md` and its applicable agent, architecture, testing and
documentation policies. Use graph-first discovery before editing code.
Deliver standalone `preflight`, default-on structured-output smoke diagnostics,
shared local preparation consumed by processing, and `run` as an alias of
`process`. Preserve the existing domain algorithms, correction resilience,
configuration semantics and publication behavior except for the explicitly
selected earlier normalization/chunking boundary. No dependency upgrades,
application schema changes, retained preflight artifacts, persisted plans,
provider-specific prompts, releases or sibling-repository changes are needed.
The plan is invocation-local and consumed once. It is not an externally supplied
or reusable execution contract. Do not add serialization, digests, cache keys,
plan authenticity checks, extra filesystem guarantees or a general workflow
framework. Local readiness remains provider-independent in the expressly named
`internal/framework/preflight` package; native provider diagnostics belong in the
LLM adapter after local readiness, consistent with ADR 0002's separation.
## Code map and selected design
| Responsibility | Starting points |
| --- | --- |
| Shared flags, registration and native alias | `internal/cli/process_command.go`, `app_wiring.go`; CommandKit `Alias("run", "process")` |
| Acquisition, source paths, bootstrap and output selection | `internal/cli/process_inputs.go`, `app_wiring.go` |
| Current readiness/output coupling | `internal/framework/preflight/preflight.go` |
| Normalization currently performed after output initialization | `internal/cli/process.go`; existing core normalizer |
| Chunk planning currently performed inside execution | `internal/framework/runner/runner.go`: `RunInput`, `Run`, `chunkWorkingTranscript`; core chunker |
| Destination checks, staging and publication | `internal/core/diagnostics/output_session.go` and its output-session/stream tests |
| Processing role clients and retained evidence | `internal/cli/process_pipeline.go`, `process_output.go`, framework LLM runtime |
| Native provider diagnostics | PromptKit v0.25.0 `Engine.SmokeTest`, `SmokeTestRequest`, `SmokeTestReport` |
Use these small internal values; names may follow local conventions while their
ownership and handoff remain as specified:
- A checked-destination value in `core/diagnostics` holds the existing display
paths, resolved publication paths and destination kinds, without open handles.
Both write probes and processing output sessions consume that value.
- `preflight.Plan` holds resolved configuration, stage specs/prepared glossary
context, normalized transcript and summary, fixed `[]chunking.Section`, and
ordered distinct selected profile IDs. It contains no native PromptKit types
or output-resource lifecycle.
- A CLI prepared-invocation value combines acquired configuration/runtime/source
evidence, the domain plan and checked destinations. Together these are the
complete processing handoff, including intended destinations.
- The LLM adapter returns per-profile verification results retaining the native
report and error, with a small success/negative/unsupported/inconclusive
classification. Native observations do not enter domain configuration.
## Stage 1: Separate checked destinations from output resources
**Completed.**
Work:
1. Extract the checking work in `diagnostics.SelectOutput` into a check operation
returning the checked-destination value. Keep current canonicalization,
symlink/hard-link comparisons, target-type rules, input protection, in-place
transcript allowance, report placement and inactive-output behavior.
2. Add output-session construction from checked destinations. Move no file opens,
report initialization or publication into the checker. Keep real preparation,
initialization, finalization and cleanup in the existing output-session owner.
Update callers directly and retire the old combined checking/construction API
once replaced; do not maintain two implementations of path policy.
3. Keep the existing late destination checks at actual preparation/publication
where they protect changed stream/file types. A checked value records what
was checked, not a guarantee against later filesystem changes.
4. Adapt output-session tests to the new entry points. Preserve existing evidence
for collisions, in-place replacement, parent requirements, symlink publication,
devices/pipes, partial failures and cleanup. Do not assert the new private
representation or create another complete path-policy matrix.
Acceptance: checking acquires no output handles or files; ordinary output sessions
retain their existing publication and cleanup behavior when constructed from it.
## Stage 2: Add temporary write-readiness probes
**Completed.**
Work:
1. Add a context-aware probe operation in the output adapter that accepts checked
destinations and visits active regular-file targets in the existing transcript,
errors, recoveries, Markdown order. Include nonexistent regular-file targets
whose checked parents exist. Skip stdout and stream/device targets; disabled
reports have no targets to probe.
2. For each target, use `os.CreateTemp` in the resolved publication parent, close
the temporary file, and remove it. Its name must differ from the intended
destination. Do not open/truncate the final path, create missing parents,
initialize a report, write to a pipe/device, simulate permission bits, or add
fsync/durability requirements. A successful writable temporary file open is
the selected readiness check; no transcript-sized write is needed.
3. Attempt removal after a close error and cleanup after cancellation. Preserve
create/close/remove failures and cancellation with contextual paths and normal
error wrapping/joining. Observe cancellation between targets and after a probe;
cleanup itself must still be attempted when the context is canceled. Return
failure rather than silently treating an unremoved probe as success.
4. Use a small package-private probe-operation seam for deterministic create,
close and remove failures in tests. Keep real filesystem collaborators for
normal checks; no general virtual filesystem or public injection framework.
5. Cover successful creation/removal with existing target contents unchanged,
representative create/close/remove failures and cancellation, disabled reports,
missing parents, and stream targets not being opened. Verify path/type/collision
checks precede probes. Reuse Stage 1 coverage for unchanged policy.
Acceptance: required file destinations are probed without acquiring a processing
session; all temporary resources receive cleanup attempts and failures are visible.
This is present readiness, not a guarantee that a later write will succeed.
## Stage 3: Build the domain preparation plan once
**Completed.**
Work:
1. Refactor `framework/preflight` into the provider-independent local planning
owner. Replace the current `Prepare` operation that initializes outputs with
preparation returning `preflight.Plan`. Move output/debug lifecycle structs
and operations to the CLI/output-adapter boundary; retain this named package.
2. Reuse `ProcessingPlan`'s complete-pipeline glossary/profile readiness checks,
stage selection, profile/backend inspection deduplication and prepared-context
reuse. Preserve collection instructions, protection, profile fallback, and
disabled-repair behavior. Select profile IDs in first-use stage order, with
proposal then validation then enabled correction repair, deduplicating by ID
with a set and retaining an ordered slice. Distinct IDs remain distinct even
when they use one backend. Empty pipelines yield an empty profile list.
3. Move the existing canonicalization/normalization call and summary production
from `runProcess` into preparation. Build chunks using the existing core
chunker and effective configuration; do not change normalization, token
estimation, balancing or chunk identity algorithms.
4. Move the configured chunk-planning responsibility out of the runner. Internal
runner tests that relied on its nil-config convenience path should prepare
explicit sections with test helpers rather than retaining a production
fallback that silently rechunks. Update tests/callers as this API changes.
5. Keep errors at their owners: infeasible user-requested chunk counts are input
failures, just as unusable processing selections are. Cancellation and
operational collaborator errors remain operational. Use a focused typed
preparation error or existing selection-error wrapping without making every
preparation failure an input error. Preserve causes and phase context.
6. Test the assembled plan for normalized content/summary, feasible fixed chunks,
selected stage guidance and ordered profile deduplication. Include an empty
pipeline, disabled repair profiles and infeasible section count. Use real
normalizer/chunker; reuse their algorithm tests rather than duplicating them.
Acceptance: preparation returns the complete domain plan without an output
session or model call, and processing can consume it without repeating this work.
## Stage 4: Make processing consume the prepared invocation
**Completed.**
Work:
1. Factor shared CLI acquisition/local preparation out of `loadProcessInputs`
and `prepareProcess`. Retain the current main selection, bootstrap reporting,
runtime glossary source protection, native diagnostic classification and
runtime assembly. Factor the quiet destination check so both commands use it
before configuration/transcript acquisition.
2. Keep normal configuration and credential behavior: engine creation and native
inspection still perform their existing checks. Do not add a special local-only
credential bypass or force new credential/provider preparation checks where
the existing local path does not perform them.
3. Assemble the domain plan, then derive/check destinations with the existing
report-directory rules from `prepareProcess`. Return the prepared-invocation
value. Processing uses checking without the standalone temporary probe pass:
its real output preparation establishes write readiness.
4. Only after local preparation succeeds, allocate the processing run ID and
reporting session, build initial/failed report renderers, prepare outputs,
initialize reports, and optionally create debug artifacts. Preserve source,
normalized transcript, normalization-summary and effective-config debug
evidence, writing the already-computed values rather than recomputing them.
5. Change `runner.RunInput` to consume the prepared domain plan instead of
independently supplied configuration/transcript/specs. Update `executePipeline`
and internal tests directly. `Runner.Run` starts from its prepared sections,
preserves fixed initial metadata and the current per-stage mutation/commit
behavior, and never calls the chunker. Keep ownership invocation-local; do not
add a reusable/immutable-plan guarantee or redundant whole-plan deep copies.
6. Preserve role-client setup, proposal/validation/repair execution, cancellation,
partial success, ordered reporting and transcript encoding/publication. Ordinary
processing makes no smoke calls. Early normalization/chunking failure now occurs
before a reporting session and need not produce failed report files.
7. Adjust affected runner, preflight, CLI and report tests around this handoff.
Prove that chosen chunks reach execution and remain fixed as text evolves.
Preserve output initialization/publication failure tests; update expectations
that required artifacts for failures now deliberately preceding initialization.
Acceptance: `process` executes the shared plan, produces the existing transcript
and report/debug contracts on execution, and does not repeat stage resolution,
normalization or chunk planning. No temporary compatibility path remains.
## Stage 5: Share argument bindings and add the command routes
**Completed.**
Work:
1. Extract the current processing flags and transcript argument into reusable
typed binding builders. Use a shared invocation input for the existing
options; add the `Smoke` field and flag only to the preflight command binding.
Bind `--smoke` as a boolean with default true. `process` does not gain that flag.
2. Reuse all current process option parsers and explicit-override presence rules,
including runtime glossary ordering, profiles, collections, output/report/debug
settings and normalization/chunking controls. Preflight accepts the same
intended settings without triggering their processing lifecycle.
3. Register `preflight` with the shared bootstrap reporting invocation feature.
Register `commandkit.Alias("run", "process")` alongside the existing canonical
process declaration, rather than creating a second processing command.
Preserve native help, completion, reporting and usage-feature integration.
4. Implement standalone local-only orchestration through the shared preparation
helper, followed by Stage 2 probes. It must not generate a run ID for retained
artifacts, initialize reports, construct a disposable processing output
session, execute the runner, or emit corrected transcript JSON.
5. Route preparation errors through a shared CLI outcome adapter extracted from
`runProcess` where useful. Keep native load diagnostic distinctions, selection
and chunk-feasibility input failures at status 2, and cancellation/output
failures at status 1. Do not reintroduce blanket input classification by phase.
6. Test shared bindings with an overlay and runtime glossary, local-only success,
quiet without an output, `/dev/null`, help without acquisition, and one `run`
alias processing invocation. Test the alias against canonical behavior without
copying the whole process test suite. Default smoke execution is completed in
Stages 6–7; no intermediate stub should remain in the final implementation.
Acceptance: the routes and shared bindings represent one processing contract,
with a standalone local path that leaves final files and processing artifacts alone.
## Stage 6: Implement native structured-output verification
**Completed.**
Work:
1. Add a focused adapter in `internal/framework/llm` using the already captured
runtime engine. Call `Engine.SmokeTest` with
`SmokeTestRequest{Kind: SmokeTestStructuredOutput, ProfileID: id}`. Keep
`TransientRetries` nil (v0.25.0 diagnostic default: zero), and leave `Execution`,
direct credentials and prompt selection unset so native effective profile
settings/defaults apply. Do not apply per-stage retry/deadline values to one
shared profile check, add outer retries, or invent an aggregate timeout.
2. Retain the report and error together, including partial reports on cancellation.
Add a small pure outcome adapter with this positive-result predicate:
no error; nonnil report for the requested structured-output kind; supported;
applicability positively true; completed; native failure is none; and
`GenerationCompleted`, `ValidJSON` and `SchemaMatched` are each positively true.
Nil mandatory facts are inconclusive, not false or success.
3. Distinguish unsupported/inapplicable results, concluded negative results,
inconclusive/incomplete observations and successful results for diagnostics.
Native execution failures remain failures even if some positive facts exist.
Do not require HTTP status, reachability/authentication facts, expected-text
matching or other ancillary observations to establish structured generation.
Keep additional facts as native evidence; the diagnostic does not establish
provider enforcement or compatibility with every production prompt/schema.
4. Check the plan's distinct profiles sequentially in their established order.
Continue after an ordinary negative result/error to report the remaining
selected profiles, retaining all causes. Stop further calls on parent
cancellation/deadline and retain completed/partial results. No parallel
scheduler, backend deduplication or new capacity control is needed.
5. Add outcome-adapter tests using native report values for positive, nil-error
negative, unsupported/inapplicable, unknown facts, incomplete, execution-error
and canceled results. Cover a positive report with HTTP facts absent. Test
orchestration with a narrow fake smoke boundary for distinct-ID selection and
cancellation; use one real-engine controlled transport case to verify native
request wiring, without copying the private smoke prompt into production code.
Acceptance: success requires positive generation/schema evidence for each selected
profile. Native requests, credentials, retries/admission and observations remain
upstream-owned. The domain preflight package contains no provider types.
## Stage 7: Finish preflight reporting and provider orchestration
**Completed.**
Work:
1. After all shared local checks and destination probes succeed, call verification
by default. `--smoke=false` skips only verification. An empty profile list
succeeds without provider work and reports that there were no selected profiles.
Never dispatch smoke requests after a local failure.
2. Report local-preparation progress and each selected profile through CommandKit.
Emit a concise completion summary distinguishing local-only from local-plus-smoke
scope. For failures, identify the profile and unsupported/negative/inconclusive
result, preserving available native causes and partial observations. Do not
include transcript content, credentials or raw provider bodies in summaries.
3. Use CommandKit outcomes/reporters for quiet, progress and failure delivery.
Quiet requires the intended `--output` and suppresses optional summaries;
failures remain visible. No preflight JSON/YAML file, ordinary processing report,
debug run directory or new stable machine-report contract is introduced.
4. Retain existing ckprompt usage integration and context rather than computing
local token/cost totals. Native smoke usage is carried in each native report;
present that per-profile usage alongside its result, retaining native
known/completeness information and labeling it as smoke usage.
Do not synthesize execution events or imply the ordinary execution-observer
summary necessarily accounts for smoke calls. Unknown usage is not zero usage.
5. Cover default-on verification, explicit local-only mode, local failure preceding
provider calls, distinct models on one backend, omitted disabled repair roles,
and cancellation with partial diagnostics. Use controlled reports for outcome
combinations and an HTTP stub for a representative assembled command; never
call live providers. Check no final transcript/report/debug artifacts appear
and existing file contents survive both success and failure.
Acceptance: standalone preflight reports the checked scope truthfully and exits
0 only when that scope succeeds; unsuccessful provider verification exits 1.
`process`/`run` retain their existing execution behavior without smoke requests.
## Stage 8: Complete documentation and final validation
**Completed.**
Work:
1. Update the canonical owners with implemented behavior:
- `docs/cli.md`: `preflight`, default-on `--smoke`, local-only invocation,
shared arguments, `run` alias and outcomes.
- `docs/operations.md`: temporary probes, secrets/provider side effects,
non-destructive final-destination checks and the earlier preparation/report
boundary. Explain stdout/stream/report/debug distinctions without duplicating
the command reference.
- `docs/integrations/subprocess.md`: Narratio-style readiness invocation,
exit interpretation and the limits of a check before a separate later run.
- Internal pipeline, CLI/config and diagnostics docs: plan handoff, fixed chunks,
expressly named local preflight owner, provider adapter, and output lifecycle.
Update architecture's implementation description only if needed; preserve
ADR 0002's provider-independent local-readiness decision.
2. Add one small domain-neutral example under `examples/`, preferably extending
an existing project. Include local-only use and explain default live-smoke use;
link the canonical native diagnostic docs. Keep D&D recipe and Narratio adapter
changes outside this sprint. Do not duplicate upstream diagnostic manuals.
3. Run focused tests for touched packages as their wiring completes. On the final
implementation, run `go test ./...` and
`go build -o ./bin/audita ./cmd/audita` with the documented supported Go toolchain.
Validate affected examples/local links, Go formatting and `git diff --check`.
Reuse tests for unchanged algorithms; no performance study or live API gate.
4. Review final coverage for the specific risks: preserved final files; probes
attempted in quiet/nonquiet and local/default modes; failures during create,
close, removal or cancellation; disabled reports; stream targets never opened;
chunking failures before smoke/output initialization; processing report cleanup
and publication after the refactor; prepared guidance retained through execution.
Prefer narrow boundary tests over duplicating the full cross-product at CLI level.
5. Remove obsolete preparation code/test helpers and update roadmap status to
actual completion. Commit completed units under agent policy. Do not publish a
release or introduce new release gates as part of this feature sprint.
Acceptance: the final source build and offline suite pass, canonical documentation
matches delivered behavior, and no obsolete duplicated preparation path remains.
## Open Questions
None. Product decisions are settled in the feature roadmap; the design choices
above specify the implementation handoffs and native diagnostic success criteria.

View File

@@ -1,246 +0,0 @@
# Dedicated Preflight Command
Status: Implemented. The completed work is recorded in the
[implementation plan](implementation.md). See the [CLI contract](../cli.md#preflight)
and [operations guide](../operations.md#preflight) for current behavior.
## 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
```
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.
## Original Reviewed Baseline
The following describes the pre-implementation state reviewed at Audita commit
`8411a69`, rather than current code. 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. Implementation and offline validation are complete;
remaining review findings are tracked in [remediation](remediation.md).

View File

@@ -1,245 +0,0 @@
# Dedicated Preflight Implementation Review
Status: All findings remediated. Original review covered commit
`7874ea648b756fe83abb92854b8219e1c4f26aa5` against the eight stages of the
[implementation plan](implementation.md), the [feature roadmap](preflight-command.md),
and the preceding baseline `645931c`.
The follow-up integration audit reviewed `330044b`, which adds this review
document without changing application code. It examined each stage's interaction
with the existing configuration, reporting, output, and execution paths. At that
time R1–R3 remained open and R4 recorded the additional integration finding.
The findings and audit tables below describe those reviewed baselines; completion
entries record the subsequent remediation.
The shared preparation and execution boundaries are implemented. The findings
below concern diagnostic delivery and documentation accuracy. They do not require
new readiness gates, stronger filesystem guarantees, or changes to provider
success criteria. No implementation fixes were made during this review.
## R1 — Present actionable native smoke errors
**Priority:** P2. **Stage:** 7. **Status:** Complete.
**Completion:** Native smoke errors now appear beside their profile and safe
observations while the original cause remains attached. The missing-model CLI
regression passes in ordinary, quiet, and debug modes; preflight tests pass with
Go 1.27.4.
**Locations:** `internal/cli/preflight.go:38` and `:53`;
`internal/framework/llm/smoke.go:72`.
**Finding:** The LLM adapter correctly retains each native report and error,
including partial evidence and cancellation. However, `verificationLine` never
uses `ProfileVerification.Err`, and the CLI attaches the combined error only as
the CommandKit outcome's cause. CommandKit preserves that cause for programmatic
access; it does not automatically present it to the operator. A native error
without a report therefore loses its actionable explanation on stderr, including
in debug mode.
Reproduced with a selected profile that has an endpoint but no model. Local
inspection succeeds, then native smoke selection fails. Standalone preflight
exits 1 and displays only `Profile "selected": negative; smoke usage: unknown`.
The native `promptkit test structured_output --profile selected` command instead
explains that the execution model is required. No provider request is needed to
reproduce this case.
**Recommended change:** Include an appropriate native error explanation in the
per-profile failure details, alongside any available safe report observations.
Keep the original error attached for `errors.Is`/`errors.As` and retain partial
reports. Use the existing CommandKit explanation/detail path; do not dump whole
requests, credentials, transcript content, or raw provider bodies. Keep the
selected operational exit classification and native ownership of diagnostics.
**Acceptance:** A representative native request-preparation error identifies the
affected profile and explains the actionable defect on stderr, including in quiet
mode. Existing cancellation identity and partial-report behavior remain intact.
Add a focused CLI regression for the missing-model case without pinning the
complete upstream error wording.
## R2 — Identify the profile while its smoke check is running
**Priority:** P3. **Stage:** 7. **Status:** Complete.
**Completion:** A small adapter callback identifies each profile before dispatch
through CommandKit progress. Adapter ordering and CLI visibility regressions
cover progress, disabled progress, debug, and quiet modes. Focused CLI and LLM
tests pass with Go 1.27.4.
**Locations:** `internal/cli/preflight.go:36`;
`internal/framework/llm/smoke.go:64`.
**Finding:** The command emits one generic provider-verification progress message,
then waits for `VerifyStructuredOutput` to finish every selected profile. The
adapter has no progress notification. Per-profile result messages are produced
only after the full operation returns and use the informational reporting
category. Consequently, enabling `--progress` does not identify the profile
currently being checked, contrary to Stage 7's selected per-profile progress.
A controlled two-profile run confirmed that, while the second request was held
open, stderr contained only the local-readiness and generic structured-output
messages. This makes a slow check difficult to locate even when the operator
explicitly requests progress.
**Recommended change:** Add a small progress notification at the per-profile
dispatch boundary and route it through CommandKit's progress reporter. Keep
verification in the LLM adapter and preserve sequential order, ordinary-failure
continuation, cancellation, and collected results. A callback is sufficient; no
scheduler or reporting framework is needed. Preserve native visibility rules,
including quiet mode and `--progress=false`.
**Acceptance:** With progress enabled, the profile being checked is identified
before its smoke call returns. A controlled blocked-call test can establish this
without timing assertions or exact message snapshots. Existing result and usage
presentation continues to follow CommandKit's reporting modes.
## R3 — Reconcile the feature roadmap with completed implementation
**Priority:** P3. **Stage:** 8. **Status:** Complete.
**Completion:** The roadmap now records implementation, labels its original
baseline as historical, and links canonical current behavior and remaining
remediation. Affected links and whitespace checks passed.
**Locations:** `docs/roadmap/preflight-command.md:3`, `:28`, `:39`, and its
closing validation paragraph.
**Finding:** The implementation plan marks all stages complete, and the canonical
CLI, operations, subprocess, and internal documentation describes the delivered
feature. The feature roadmap still says implementation has not begun and that
the commands are unimplemented interfaces. Its heading "Current Baseline" also
introduces the former output-coupled preparation path and runner-owned chunking
without labeling those descriptions as historical. The closing paragraph still
describes an implementation-free documentation pass.
**Recommended change:** Record the actual implementation status and distinguish
the original reviewed baseline from the delivered architecture. Remove obsolete
claims that the interfaces are unimplemented or that this remains only a
documentation pass. Retain the agreed target and rationale while linking to the
canonical documentation for implemented behavior; no additional behavioral
contract is needed.
**Acceptance:** The roadmap and implementation plan agree about delivery status,
and historical baseline descriptions cannot be mistaken for current code.
## R4 — Integrate preflight with the existing usage-reporting feature
**Priority:** P2. **Stages:** 5–7. **Status:** Complete.
**Completion:** An invocation-local CommandKit diagnostic-report producer now
presents native per-profile smoke observations in ordinary mode and explicitly
qualifies execution-observer totals as excluding smoke calls. Quiet mode suppresses
the report; local-only runs emit no smoke report, and ordinary processing retains
its existing native usage path. No upstream API change, local aggregation, or
synthetic execution events were needed. Controlled CLI coverage includes ordinary,
requested, verbose, quiet, local-only, failed-verification, and processing usage.
CLI documentation now describes the delivered reporting scope. The full offline
suite, source build, touched-package race checks, and local links passed with
Go 1.27.4.
**Locations:** `internal/cli/app_wiring.go:121`,
`internal/cli/preflight.go:37` and `:47`; upstream ckprompt v0.12.0
`usage_report.go:24`.
**Finding:** The existing global `--show-tokens` feature installs an ordinary
PromptKit execution observer and renders its final summary. Native smoke calls
intentionally do not enter that observer. ckprompt recognizes its own
`promptkit test` route and adds a smoke-usage qualification, but it does not
recognize Audita's new standalone `preflight` route.
Audita presents actual per-profile smoke observations with `Reporter.Info`, which
is hidden in ordinary reporting mode. Consequently, `preflight --show-tokens`
can make a provider request and display only an empty observer summary: zero
prompts, zero tokens, USD 0, and complete terminal coverage. It does not explain
that this excludes the smoke calls. With `--verbose`, the actual smoke counts
appear alongside that unqualified zero summary. Preserving observations in the
adapter does not resolve this presentation conflict.
Reproduced with one controlled smoke request reporting 7 prompt tokens,
3 completion tokens, and 10 total tokens. The command exited 0. Without
`--verbose`, the explicitly requested usage report showed only zeros; with
`--verbose`, the profile line showed 10 total tokens while the subsequent
execution-observer summary still showed zero. Local-only preflight made no
requests, so its empty observer summary does not demonstrate this defect.
**Recommended change:** Integrate the standalone route with native usage
reporting so explicitly requested smoke usage is visible without requiring
verbose/debug mode, subject to quiet mode. Suppress the irrelevant empty
execution-observer summary for this route or clearly qualify its scope while
presenting the native per-profile observations. Prefer a focused upstream
ckprompt hook if its current public API cannot express that distinction. Keep
ordinary processing usage behavior intact. Do not synthesize execution events,
add local token/cost aggregation, or infer zero cost from absent observations.
**Acceptance:** A controlled `preflight --show-tokens` invocation exposes its
native smoke counts and does not imply that the observer's zero totals describe
those requests. Unknown/incomplete observations remain truthful. Quiet mode,
local-only preflight, and processing's existing usage report retain their
respective behavior. Add focused assembled-command coverage using controlled
responses; assert meaning and scope rather than the entire upstream rendering.
## Stage Review Summary
| Stage | Review result |
| --- | --- |
| 1 — Checked destinations | Implemented. Checking is separate from resource acquisition; existing path, collision, in-place, stream, staging, and publication behavior is retained. |
| 2 — Temporary probes | Implemented. Active regular targets receive sibling probes; close/removal failures and cancellation are retained. Stdout, streams, devices, and disabled reports are skipped. |
| 3 — Domain preparation | Implemented. The provider-independent plan resolves stages and glossary views, normalizes once, fixes chunks, and collects distinct profiles in first-use order. Infeasible requested chunk counts retain input classification. |
| 4 — Processing handoff | Implemented. Processing consumes the prepared plan and checked destinations, then initializes reports/debug evidence and runs the existing stage pipeline. The runner no longer chunks. |
| 5 — Shared bindings and routes | Implemented. Preflight shares processing inputs and acquisition; smoke is preflight-only, and `run` is a native alias. Quiet destination checks and existing error classifications are retained. |
| 6 — Provider verification | Implemented. Native structured-output checks use the captured engine without extra retries or deadlines. Success requires the selected positive facts; native errors and partial reports remain available. |
| 7 — CLI reporting | Scope, outcomes, native usage presence/completeness, quiet handling, and cancellation are implemented. R1 and R2 cover diagnostic-delivery gaps; R4 covers the conflict with the inherited usage-reporting feature. |
| 8 — Documentation and validation | Canonical documentation and examples reflect the implementation; the offline suite and build pass. R3 covers stale roadmap status. |
## Validation Performed
Using Go 1.27.4 with workspace discovery and module network access disabled:
- `go test ./...` passed.
- A source build of `./cmd/audita` passed; the executable was kept outside the
repository for controlled CLI probes.
- `go test -race` passed for `internal/cli`, `internal/framework/llm`,
`internal/framework/preflight`, `internal/framework/runner`, and
`internal/core/diagnostics`.
- Controlled CLI probes reproduced R1 and R2, exercised positive/negative native
diagnostics, and confirmed that local-only preflight against a FIFO with no
reader returns without opening or writing it.
- Changed production Go files are formatted; affected local Markdown links and
`git diff --check` passed.
Tests and probes used local fixtures and controlled HTTP responses, without live
inference or real credentials. No unintended new input caps, credential gates,
retry/deadline policies, plan authenticity/reusability guarantees, filesystem
durability guarantees, or correction-acceptance restrictions were found.
## Follow-up Integration Audit
All eight stages were checked against their existing collaborators:
| Stages | Integration evidence and result |
| --- | --- |
| 1–2 — Destination checks and probes | Checked paths retain the existing session's collision, canonicalization, stream, and publication rules. Probes are confined to standalone preflight; processing still acquires its real output resources. No additional integration finding. |
| 3 — Domain plan | Existing normalization/chunking algorithms and glossary-view reuse are preserved. Canonical conversion owns its segment/category data, so moving it earlier does not corrupt later source-debug evidence. No additional integration finding. |
| 4 — Processing handoff | A controlled multi-stage, two-chunk run retained runtime glossary guidance and both original source-debug documents. Failure of all four proposal operations still returned the normalized transcript with completed ordinary reports. No additional integration finding. |
| 5 — Bindings and routes | Shared acquisition retained overlays, ordered runtime inputs, bootstrap credentials, source protection, and input/operational error distinctions. The native `run` alias executed the processing path. The inherited usage feature needs R4. |
| 6 — Native smoke adapter | The same bootstrapped credentials reached native smoke and processing calls. Used profiles were checked in order; the disabled repair role was omitted. Local-only mode made no calls. No additional integration finding. |
| 7 — Reporting and orchestration | Actual CLI invocations reproduced R4's mismatch between native smoke observations, informational-message visibility, and the inherited execution-observer report. Existing R1 and R2 remain separate findings. |
| 8 — Documentation and examples | Canonical lifecycle descriptions agree with the checked handoffs. R3's stale roadmap status remains open. The usage-reporting fix should keep the canonical CLI/operations descriptions aligned. |
Validation reused the preceding full-suite, build, and race results after
confirming no Go source or dependency changes since that review. Focused CLI
tests for reporting modes, runtime-input failures, ordered profiles, resilient
processing, and preflight passed again with Go 1.27.4. Additional controlled CLI
probes exercised the interactions above and the `--show-tokens` reporting
combinations. No live inference or real credentials were used. This follow-up
changes only the remediation document.
## Final Remediation Validation
R1–R4 are complete as separate committed units. `go test ./...`, a source build
of `./cmd/audita`, and `go test -race ./internal/cli ./internal/framework/llm`
passed with Go 1.27.4 and module network access disabled. Affected Markdown
links, Go formatting, and whitespace checks passed. No live inference or real
credentials were used. Provider success criteria, budgets, output lifecycle,
and correction acceptance were preserved.