From 8aa552070dc8e7cf4884b307888097abd262574d Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Mon, 30 Nov 2026 17:17:03 +0000 Subject: [PATCH] Remove completed preflight planning documents --- docs/release.md | 4 + docs/roadmap/implementation.md | 365 --------------------------------- docs/roadmap/preflight.md | 193 ----------------- docs/roadmap/remediation.md | 110 ---------- 4 files changed, 4 insertions(+), 668 deletions(-) delete mode 100644 docs/roadmap/implementation.md delete mode 100644 docs/roadmap/preflight.md delete mode 100644 docs/roadmap/remediation.md diff --git a/docs/release.md b/docs/release.md index 2d78c55..3441ab8 100644 --- a/docs/release.md +++ b/docs/release.md @@ -42,6 +42,10 @@ history, including failed-attempt diagnostics and original Notarius bundles. Operators can retain that material by setting `workspace.cleanup_after_publish` to `false`. +Also document the replacement of `session validate` with `preflight SESSION`, +which prepares or reuses inputs before checking readiness. See the +[preflight command](cli.md#preflight). + Retire completed roadmaps as appropriate, preserve pending work, and review the candidate through the ordinary development workflow. Commit the candidate and push it to `origin/main`, then publish from the clean `main` checkout: diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md deleted file mode 100644 index af03c2e..0000000 --- a/docs/roadmap/implementation.md +++ /dev/null @@ -1,365 +0,0 @@ -# Standalone Session Preflight Implementation Plan - -Status: Complete. - -## Scope And Working Instructions - -Implement the target in [Standalone Session Preflight](preflight.md). That -roadmap owns product scope and policy choices; this document owns the ordered -implementation work. The baseline is commit `07e6fae`, including the session -probe locking fix in `826369c`. - -The audience is a Luna coding agent implementing one stage per prompt, in order, -within one end-to-end sprint. Intermediate stages may leave callers or tests -temporarily incomplete. Complete the final integrated behavior rather than -adding transitional APIs or duplicate implementations to keep every stage green. -Update each stage's status when its work is complete and record actual checks. -Commit completed units with plain English messages under the agent policy. - -Start with [Development](../development.md) and read the applicable -[Agent](../policy/agents.md), [Architecture](../policy/architecture.md), -[Testing](../policy/testing.md), and -[Documentation](../policy/documentation.md) policies. Follow `AGENTS.md` for -code discovery. Each stage below identifies its focused starting points; expand -reading when a concrete dependency requires it. - -Planning authorizes documentation only. Implementation begins in subsequent -prompts. No dependency upgrade, release, tag, push, or CI monitoring is part of -this sprint. - -## Implementation Decisions - -- Register top-level `preflight SESSION` and remove `session validate`. Reuse - `run`'s configuration/session selectors, including `--previous-session-id`, - through existing acquisition helpers. Keep native CommandKit reporting and - ConfigKit error semantics. Stage ranges, force, and artifact filters are - outside this command's initial surface. -- Standalone selection covers enabled capabilities and the existing prompt - prerequisite closure, including reusable outputs. Automatic selection stays - based on projected execution. Share downstream checking and request setup. -- Execute a prepare-only bounded plan with ordinary resume and invalidation, - followed by standalone checks inside the same locked invocation. Use one - acquisition and one authoritative prepared manifest. Preparation success is - durable even when later readiness fails. -- Extract a small private locked-lifecycle wrapper and the existing selected - stage loop. The normal runner and standalone workflow supply their operation - bodies to that wrapper. This is reuse of two concrete workflows, not a stage - engine, plugin system, or collection of lifecycle hooks. -- Report coarse check groups: configuration, preparation, workspace/storage, - prompt requirements, Audita, Notarius, and publication locks as applicable. - Use `succeeded`, `failed`, and `blocked` check outcomes; omit inapplicable - groups or explain their non-applicability informationally. Keep preparation's - ordinary `completed`, `reused`, `failed`, or `not_attempted` outcome separate. - Findings retain existing severity and useful target context. A group can - succeed with warnings, including incomplete Scriptorium discovery. -- Use actual preparation/resume evidence for stable inputs, audio, and required - or optional previous-session inputs. Keep the existing configured-storage and - remote-lock inspections where preparation does not supply that evidence. - Required failures or blocked required checks prevent readiness success; - optional omissions and observed publication locks retain their current - non-fatal treatment. -- Continue independent standalone checks after ordinary failures while context - remains active. Prepared-input probes require successful persisted preparation. - Cancellation stops new work. Use ordinary errors and native classifications; - readiness creates neither a manifest stage nor a reusable success record. -- Use existing invocation-scoped probe helpers under `runs/` for both workflows. - Probe outputs remain disposable diagnostics. Leave canonical products, - latest processing-attempt views, and authorized cleanup semantics unchanged. - -## Stage 1: Factor Native Check Operations And Preserve Findings - -Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/preflight ./internal/adapters/audita ./internal/adapters/notarius` and `git diff --check`. - -Read `internal/preflight/{types,check,downstream}.go`, their tests, and -[Preflight Internals](../internal/preflight.md). Inspect the Audita and Notarius -adapter preflight contracts and focused tests where needed. - -1. Factor the Audita operation out of `CheckDownstream` into a small named - checker alongside existing Scriptorium `Check` and `CheckNotarius` operations. - Keep adapter invocation and native result interpretation in their current - owners. The application will sequence these operations and record group - outcomes without reinterpreting private downstream reports. -2. Preserve Scriptorium binding/variable checks, prerequisite context, warning - severity, and partial findings. Preserve Audita provider-smoke behavior and - Notarius inspection completeness, selected pipeline, required lanes, native - failure causes, warnings, and synthetic-input descriptions. -3. Preserve errors with wrapping/joining and honor cancellation. Successful - checks need not manufacture findings for every successful upstream detail; - the application can record a successful group from a successful operation. -4. Remove the old combined wrapper once its callers migrate in Stage 2; avoid - leaving two maintained implementations of the same checks. - -Verification: adapt existing `internal/preflight` tests for success, warnings, -failure findings, partial results, and cancellation. Use existing adapter -contract tests rather than repeating subprocess parsing at this layer. - -Done when each downstream check has one explicit callable owner and existing -severity/error behavior is preserved. - -## Stage 2: Share Downstream Request Construction And Execution - -Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/app ./internal/preflight` and `git diff --check`. - -Read `internal/app/{runner_preflight,preflight_targets}.go`, -`internal/stage/{polish_context,extract_preflight}.go`, and -`internal/app/{runner_preflight,runner_downstream,notarius_preflight,preflight_targets}_test.go`. - -1. Introduce a narrow application helper for downstream readiness, taking - explicit targets, the current invocation environment/paths/manifest, probe - identity, and the existing transcript/force controls. Return group outcomes, - contextual findings, and an error. Keep the report data small and local to - this feature; no generic check registry or dependency graph is needed. -2. Lazily construct only targeted adapters through invocation dependencies and - retain them in the invocation environment for later production reuse. Build - Audita requests through `stage.BuildPolishRequest` and Notarius requests - through `stage.BuildNotariusReadiness`. Verify Notarius reference snapshots - after the native call, including failure paths. Surface request-construction - or adapter-initialization failures as the affected group's failure. -3. Use `artifacts.SessionInvocationProbeDir` with the invocation's run identity - and existing output/log/debug subpaths. Pass the same configuration, - credentials, overlays, timeouts, reference selections, and applicable cache - controls as production. Standalone requests use ordinary non-forced controls; - automatic forced extraction keeps its current refresh behavior. -4. Sequence the three independent tool checks directly. Preserve collected - findings when another tool fails; stop starting checks on cancellation. - Prepared-evidence failure blocks only probes that require that evidence. - A failed checker still prevents automatic processing from starting. -5. Migrate `inspectInvocationRequirements` to the shared helper. Keep its work - projection, empty-target shortcut, `executionDownstreamTargets`, - `currentTranscriptUsableForNotarius`, and warning/progress presentation. - Keep standalone target selection as a distinct function, renaming the - validation-named selector to describe enabled capabilities when callers move. - -Verification: retain automatic checks-after-prepare, reused-work suppression, -artifact prerequisite closure, forced refresh, synthetic/current input choice, -and invocation-owned adapter reuse tests. Add only missing coverage for -independent tool failures and request-building failures; use fakes at adapters. - -Done when automatic preflight uses the shared path and standalone orchestration -can call it without rebuilding requests or acquiring a second lock. - -## Stage 3: Extract The Runner's Locked Invocation Lifecycle - -Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/app` and `git diff --check`. - -Read `internal/app/{runner,runner_runtime,runner_stage_execution,runner_finalization,runner_composition,runner_dependencies}.go`, -[Workspace Internals](../internal/workspace.md), and runner cancellation, -terminal-failure, partial-result, bounded-prerequisite, and cleanup-reuse tests. - -1. Extract the existing lifecycle shell from `executePlanWithDependencies` into - a private helper accepting one operation body. Preserve prerequisite checks, - unsupported-manifest handling before layout changes, layout creation, - context-aware session locking, locked initialization, restore protection, - terminal persistence, partial summaries, and lock-release error propagation. -2. Extract the selected-stage loop, including stage-result bookkeeping and its - automatic preflight boundary, into one private operation. The normal runner - uses the shared lifecycle with that operation and keeps its public executor - contract unchanged. -3. Allow the standalone body to execute that same loop with a prepare-only - bounded plan, inspect the outcome, and check readiness before returning to - shared finalization. A prepare-only selection does not trigger automatic - downstream checks, so standalone invokes them once through its own selection. -4. Hold the same lock continuously from locked manifest initialization through - preparation, readiness request construction, native calls, report reading, - reference verification, and terminal persistence. Finalize before releasing - it. Do not call another public command, reacquire the lock, or reload config. -5. Retain lazy run-directory creation, ordinary stage invalidation, and existing - cancellation-detached terminal persistence. Keep all operation errors intact - when persistence or release also fails. - -Verification: run the existing runner lifecycle, failure, bounded-run, -cancellation, and cleanup tests as the refactor becomes integrated. Preserve -their behavioral assertions rather than locking tests to new helper ordering. - -Done when normal execution retains its behavior and a second concrete operation -can share the full lifecycle without copying stage transitions or finalization. - -## Stage 4: Implement The Standalone Prepare-And-Check Operation - -Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/app ./internal/preflight`, focused readiness tests after the final reporting adjustment, and `git diff --check`. - -Read `internal/app/{session_inspection_command,operator_inspection,operator_findings,configuration_acquisition,command_dependencies}.go`, -[Preparation](../internal/stage-prepare.md), and existing session preflight tests. - -1. Add the application operation behind standalone preflight. Acquire the domain - configuration once with `newConfigurationAcquisition`, apply the existing - previous-session assertion, validate through the ordinary path, and close the - acquisition on every exit. Pass that same configuration and reporter to the - shared locked lifecycle with `BuildBoundedPlan("prepare", "prepare")` and - normal non-forced options. -2. Adapt command-owned adapter/storage factories into the invocation's existing - dependency seams. Reuse an already composed object store where available; - construct configured storage through the ordinary factory when needed for - lock inspection. Avoid global test hooks and duplicate configuration loads. -3. Run or reuse prepare through the shared stage loop. Derive preparation - outcome from its stage result and durable save outcome, not merely a prior - succeeded manifest record. Required writes must succeed before prepared-input - probes run. A failed replacement must not probe old preparation as current. -4. Map successful preparation/resume evidence to input/audio/previous-input - readiness findings. Preserve optional missing previous artifacts as optional. - Remove redundant validation-only live-input/download setup; keep inspection - helpers used by status, planning, or other commands. Use existing remote-lock - inspection without simulating uploads or requiring future outputs to exist. -5. Select all enabled downstream capabilities and prompt prerequisites regardless - of output reuse. Call the shared downstream helper once. After successful - preparation, use the existing pure work projection for the normal transcript - producer range and `currentTranscriptUsableForNotarius` to determine whether - upstream work would rerun. This suitability assessment does not narrow the - standalone target set or persist projection decisions. Permit a real input - only when that assessment and existing trimmed-artifact resolution support - it; otherwise use the synthetic fallback. This covers semantic changes to - transcript stages even when their older files and success records remain. - Do not run transcript producers to obtain a probe input. -6. On preparation failure, report prepared-input checks as blocked. Continue - configuration-based Scriptorium requirements inspection and available remote - lock inspection when practical and uncanceled. If acquisition, locked - initialization, or cancellation prevents a usable operation, return the - available failure/partial assessment and do not manufacture successes. -7. Build the standalone report as ordinary application data: `campaign`, - `session_id`, optional `session_source`/`run_id`, `preparation` (outcome and - reason), `ready`, `checks` (group, outcome, message), and `findings` with - existing severity/context. Keep its data shape common to all output formats. - Finalize `ready` after acquisition-close, persistence, and release errors are - known. Native report delivery failure retains CommandKit's own failed outcome. -8. Readiness failure leaves persisted preparation succeeded and retains normal - session terminal-failure reporting. It does not fail a processing stage or - independently invalidate its evidence. Only ordinary prepare transitions can - stale descendants. Stop before processing, publishing, notify, or cleanup. - -Verification: add focused application behavior tests for fresh preparation, -reused preparation with repeated checks, provider failure after prepare success, -and a preparation failure with blocked probes and independent findings. Use real -temporary input/workspace files and fake providers/storage. Verify substantive -state and error causes; exact incidental diagnostic wording is not contractual. - -Done when the operation works without prior prepare, has meaningful partial -results, and uses production preparation and readiness owners throughout. - -## Stage 5: Replace The CLI Command And Integrate Native Reporting - -Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/app ./internal/preflight ./internal/artifacts ./internal/stage`, focused native reporting and discovery tests, and `git diff --check`. - -Read `internal/app/{commands,session_inspection_command,execution_command,command_reporting,command_outcome}.go`, -the command boundary tests, and the existing session validation command tests. - -1. Register top-level `preflight SESSION` using native CommandKit declarations - and shared configuration flags. Include the existing overlay, campaign, - campaign-file, party-file, session-file, and previous-session selectors. - Help must state that preparation writes state/downloads inputs and checks may - contact providers. Keep help/completion discovery free of configuration loads. -2. Emit one final report through `Reporter().Report` and return - `reportOperationOutcome`, preserving joined causes and native classifications. - Use native text, YAML, JSON, automatic format selection, and visibility; - preparation/check progress belongs on stderr. Retain substantive failed or - blocked findings in reports under quiet/terse settings. -3. Remove `session validate` registration, its command-only types, and obsolete - orchestration. Reuse the shared inspection spec for other commands where - appropriate. Remove validation-only probe helpers if no caller remains; - retain helpers with other live users. Add no compatibility alias. -4. Migrate command callers and relevant tests to `preflight`, retaining native - malformed-config versus operational-failure coverage. Leave `config`, - `session plan`, `session status`, and artifact inspection semantics unchanged. - -Verification: exercise a representative successful and failed CLI workflow, -JSON/YAML report decoding, text/auto reporting, quiet failure visibility, -selection mapping, config failure, and removal/discovery of commands. Reuse -existing native boundary coverage instead of testing every upstream formatting -combination or reproducing CommandKit's test suite. - -Done when the new command is discoverable, the old command is absent, and native -reporting accurately presents preparation and readiness outcomes. - -## Stage 6: Protect Resume, Probe Locking, And Cleanup Interactions - -Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/app -count=1`, race-enabled focused readiness, lifecycle, and cleanup tests, and `git diff --check`. - -Read `internal/app/{session_preflight,session_validation_lock,notarius_preflight,preflight_targets,runner_downstream,cleanup_orchestration}_test.go` -and the application tests added in earlier stages. - -1. Replace obsolete no-workspace/no-manifest-mutation validation assertions with - the selected prepare-and-check behavior. Preserve tests for native findings, - optional sources, disabled prerequisites, cancellation, and error causes. -2. Verify a changed stable input triggers normal prepare invalidation, while a - probe failure alone retains successful preparation and previously current - processing authority. Verify a later ordinary run reuses preparation and - still performs applicable automatic preflight before processing. -3. Verify standalone checks include reusable enabled targets while automatic - checks omit reused targets. Keep production request parity, prerequisite - closure, and stale-transcript fallback covered at their narrowest owners. -4. Migrate the `826369c` lock regression tests to the new workflow. With each - provider probe held at a test-controlled boundary, verify the shared lock - excludes concurrent cleanup until all probe work has finished. Verify lock - waiting honors cancellation and no provider starts before acquisition. Cover - preparation-to-probe continuity through the shared lifecycle; avoid sleeps - that guess when a race has occurred. -5. Verify authorized subsequent cleanup removes finished run-local probe - evidence while durable prepared inputs remain reusable. Repeated preflight - can recreate probe space. Preflight itself does not perform cleanup or rotate - processing-stage diagnostic views. -6. Cover representative preparation-save, terminal-save, cancellation, and - release failures through existing injectable boundaries. Confirm partial - results never claim overall readiness or preparation reuse without adequate - evidence. Reuse existing lifecycle tests when they already cover a risk. - -Verification: run focused application tests and their race-enabled variants. -All default tests remain offline and credential-independent; external calls use -fakes and filesystem behavior uses `t.TempDir()`. - -Done when the changed workflow retains recovery and cleanup safety without -duplicating the suite or introducing stricter readiness rules. - -## Stage 7: Update Canonical Documentation And Verify The Sprint - -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), -[Preflight Internals](../internal/preflight.md), -[Workspace Internals](../internal/workspace.md), -[Audita Integration](../integrations/audita.md), and the architecture policy. - -1. Update CLI command inventory, examples, and public report-field reference for - `preflight`. Update operations to replace the separate prepare/validate - sequence with preflight and explain mutable preparation, full-capability - checking, provider calls, diagnostic lifetime, and successful-prepare reuse - after readiness failure. Keep automatic preflight's different selection clear. -2. Replace live troubleshooting commands and obsolete validation descriptions. - Explain synthetic-input limits and actionable failures without implying a - successful preflight guarantees later processing or publication success. -3. Update internal ownership/lifecycle descriptions and architecture policy's - standalone-validation paragraph to match implemented prepare-and-check - behavior. State the policy affirmatively and concisely. Preserve existing - ownership boundaries and the canonical pipeline stage set. -4. Update affected integration summaries, links/anchors, and roadmap baseline - links when the old CLI section is removed. Keep upstream feature definitions - linked to canonical upstream documentation. Keep versioned release-note - preparation for the documented release workflow; retain the command-removal - migration reminder in the feature roadmap for that follow-up. -5. Remove unused validation orchestration, imports, fixtures, and helpers left - by the migration. Review the cumulative diff against the feature roadmap: - no new config resolver, health framework, stage, success cache, subprocess - internals validator, or additional readiness restrictions should remain. -6. Run the normal completion checks with the maintained Go toolchain: - - ```sh - GOTOOLCHAIN=go1.27.4 go test ./... - GOTOOLCHAIN=go1.27.4 go test -race ./... - GOTOOLCHAIN=go1.27.4 go vet ./... - GOTOOLCHAIN=go1.27.4 go build ./... - GOTOOLCHAIN=go1.27.4 go test ./internal/doccheck - git diff --check - ``` - - Format changed Go code and fix relevant failures. Review staged changes, - update plan statuses with verification results, and commit the completed - work. Do not publish a release or wait for CI as part of completion. - -Done when all seven stages satisfy the feature roadmap, normal verification -passes, current documentation describes implemented behavior, and the worktree -is clean after commits. - -## Open Questions - -None. The feature's scope and behavior are decided. Internal names and file -placement may follow the simplest idiomatic organization within the owners -identified above; those choices do not alter the selected operator contract. diff --git a/docs/roadmap/preflight.md b/docs/roadmap/preflight.md deleted file mode 100644 index 7add576..0000000 --- a/docs/roadmap/preflight.md +++ /dev/null @@ -1,193 +0,0 @@ -# Standalone Session Preflight - -Status: Implemented. The next release notes must identify the migration from -`session validate` to `preflight`. - -## Goal - -Provide `narratio preflight SESSION` as the operator's prepare-and-check workflow -before starting a long pipeline run. It resolves Narratio configuration, prepares -or reuses real session inputs, checks Narratio's readiness, and invokes the -applicable downstream readiness checks. It replaces `session validate`. - -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. - -## Baseline Before Implementation - -- `session validate` already checks configuration, stable inputs, local or remote - audio availability, previous-session requirements, and publication locks. It - runs Audita and Notarius readiness checks and Scriptorium requirements - inspection against enabled definitions and their prerequisites. -- Validation requires existing prepared inputs for Audita and Notarius. It does - not execute preparation or update the manifest, although downstream probes can - write diagnostic files and contact providers. -- Automatic preflight runs after selected preparation completes or is reused. - It uses the ordinary work projection to check downstream work expected to - execute. Fully reused work does not require another downstream check. -- `internal/preflight` supplies shared checkers. The application layer currently - has separate validation and execution orchestration, including duplicated - prepared-manifest acquisition and downstream request setup. - -The current contracts are now described in [preflight internals](../internal/preflight.md), -[preparation](../internal/stage-prepare.md), and the -[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 - -### Command And Selection - -```sh -narratio preflight SESSION -narratio preflight SESSION --config ./pipeline.yml --session-file ./session.yml -narratio preflight SESSION --format json -``` - -Use the same configuration and session acquisition conventions as `run`, -including applicable campaign, party, overlay, and previous-session selectors. -Use CommandKit's native reporting and visibility controls. - -The command checks the configured session's enabled pipeline capabilities, -including the existing prerequisite closure for prompt requirements, regardless -of whether their processing outputs are reusable. Automatic preflight continues -to check only projected execution targets. These are two target-selection -policies, not two implementations of readiness checks. - -Remove `session validate` from the command tree and update its callers and -documentation. Native `config` validation and inspection retain their existing, -narrower purposes. The initial command does not need additional stage-range or -artifact-filtering options to deliver the agreed workflow. - -### Preparation And State - -Acquire configuration through the ordinary ConfigKit integration, then use the -normal invocation lifecycle and session lock to execute or reuse `prepare`. -Reuse its semantic checks, input projections, downloads, manifest persistence, -and dependent invalidation rather than implementing a preflight-specific -preparation path. - -Preflight is consequently not read-only. It can create a session workspace, -download audio and previous-session inputs, write prepared documents, and update -preparation state. Changed inputs can stale downstream records through the -existing rules. These effects must be explicit in help and operator guidance. - -Check downstream readiness against the resulting prepared inputs. Use existing -request builders and adapters so configuration selections, credentials, -references, and applicable execution settings agree with production invocation. -Audita retains its synthetic-transcript probe; Notarius uses a suitable verified -transcript when available and its existing synthetic fallback otherwise. A stale -transcript left by earlier work must not be presented as current input. - -The command stops after checking. It does not execute processing, publish, -notify, or the pipeline cleanup stage. A readiness failure after successful -preparation leaves that preparation available for reuse. The check itself does -not mark processing stages successful, invalidate otherwise valid products, or -create a persisted preflight stage whose success bypasses future checks. - -### Check Ownership And Coverage - -| Owner | Responsibility | -| --- | --- | -| ConfigKit integration | Resolve and validate configuration through the existing acquisition path; preserve native error semantics. | -| Narratio | Check its input, workspace, dependency, previous-session, and publication prerequisites using existing domain and adapter machinery. | -| Audita | Run native preflight with the prepared glossary inputs and existing provider smoke checks. | -| Notarius | Run native inspection and preflight with the selected pipeline, prepared reference bindings, and existing execution controls. | -| Scriptorium integration | Retain requirements inspection and Narratio's binding/source checks for enabled trim and analysis definitions and their prerequisites. | - -Carry forward the current validation checks and obtain preparation-related -evidence from actual preparation where that avoids duplicate work. Check -workspace access and dependency availability through ordinary setup or supported -adapter operations; identify any remaining concrete gaps during implementation -planning. This scope does not require inventing health protocols for every tool, -simulating a publish transaction, or making Narratio validate subprocess-owned -configuration itself. - -Preserve the existing distinction between errors and warnings. For example, -missing required prompt bindings and failed inspection are errors; conditional -or incomplete Scriptorium discovery and optional-source concerns retain their -existing warning treatment. Publication locks retain the current reporting -semantics. Merely moving a check into preflight does not make it stricter. - -### Reporting And Failure Behavior - -Return one final readiness report through CommandKit's native text, YAML, JSON, -and automatic format selection. Include session identity, preparation outcome, -overall readiness, and actionable findings. Distinguish checks that succeeded, -failed, or could not run because a prerequisite failed; retain warnings and -relevant limitations such as use of a synthetic transcript. - -Use ordinary stderr diagnostics and progress for preparation and checks. Report -substantive failures regardless of verbosity, preserve underlying error causes, -and use the existing ConfigKit/CommandKit outcome classification rather than -introducing a preflight-specific exit-code system. - -Continue independent checks where practical, while stopping dependent work when -its prerequisites fail and honoring cancellation. A required check that fails -or cannot run prevents an overall successful readiness result. This does not -reclassify an otherwise successful inspection's advisory findings as failures. -Configuration acquisition failure may prevent a session-level assessment. - -Successful preflight reports what was checked at that time. It does not guarantee -future provider availability, publication success, or processing quality with a -real transcript. Automatic preflight still runs before applicable processing. - -## Integration And Documentation - -Shared checking belongs in `internal/preflight`, acquisition and lifecycle in -`internal/app`, and native invocation in adapters. Production request builders -and prepared-input verification serve both readiness workflows. The resulting -implementation has one preparation/lifecycle owner and one implementation of -each readiness check, with distinct full-session and projected target selection. -Helpers still used by status, planning, or other commands remain available. - -Probe material uses existing invocation-scoped workspace and diagnostic -conventions. The shared session lock covers preparation through native probe -execution, report consumption, reference verification, and finalization. -Following the [cleanup lifecycle](../operations.md#cleanup), probe evidence under -`runs/` is disposable at the next authorized cleanup. Prepared inputs remain -durable and reusable; readiness does not promote probe outputs into canonical -products or authorize session cleanup. - -Current CLI, operations, troubleshooting, integration, internal, and architecture -documentation describes the implemented command when it lands. The standard -operator workflow uses preflight in place of the separate prepare/validate -sequence and explains state changes, provider calls, check coverage, and -diagnostic lifetime. The next release notes identify the migration from -`session validate` to `preflight`. - -The ordered work and completion checks are in the -[implementation plan](implementation.md). - -## Verification - -Extend existing behavioral tests in `internal/app`, `internal/preflight`, and -the affected adapters. Use real temporary workspaces and fakes at external -boundaries; ordinary tests remain offline and credential-independent. - -- A fresh session prepares inputs, checks enabled downstream targets, and stops - without processing or publishing. A repeated preflight reuses valid prepared - inputs while still performing readiness checks. -- Changed inputs follow ordinary prepare invalidation. A downstream readiness - failure preserves successfully prepared inputs and does not independently - invalidate completed processing results. -- Standalone and automatic checks use the same prepared references and execution - configuration. Standalone checks include reusable enabled work; automatic - checks retain projected-work selection. Existing prerequisite closure and - warning behavior remain covered. -- Preparation failure blocks checks requiring those inputs. Independent findings - remain reportable where possible; native check failures and cancellation cannot - produce an overall success. -- Native output formats and visibility controls carry the readiness report and - failures correctly. Cancellation, persistence failures, and resource release - use existing lifecycle behavior. - -Revise tests asserting that `session validate` never creates state or changes -the manifest: that is intentionally replaced by ordinary preparation behavior. -Retain applicable checks for native error handling, findings, and adapter -contracts rather than duplicating them under a new command name. Run focused -tests during implementation and the repository's normal completion checks, -including documentation links, before declaring the work complete. diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md deleted file mode 100644 index c250e9d..0000000 --- a/docs/roadmap/remediation.md +++ /dev/null @@ -1,110 +0,0 @@ -# Preflight Algorithmic Audit - -Reviewed baseline: `b2877c1`. - -Scope: the seven stages of [the implementation plan](implementation.md), with -attention to algorithmic cost in their shared collaborators. The findings below -are optimization opportunities for consideration, not demonstrated operational -failures or release blockers. The audit made no application changes; completion -notes below record subsequent remediation. Both findings are now complete. - -The selected prepare/resume machinery, pure transcript-work projection, -enabled-versus-projected target selection, and independent native checks remain -the accepted design. This audit does not propose changing those decisions or -adding caches, parallelism, limits, or new readiness requirements. - -## Stage Coverage - -| Stage | Assessment | -| --- | --- | -| 1: Native checks | Requirement matching uses map lookups and linear scans. Notarius lane membership is linear in available plus required lanes. Finding 1 concerns inherited error aggregation in the shared checker. | -| 2: Shared downstream execution | The tool sequence has fixed length; findings accumulate through amortized slice appends. Target construction is linear in selected bindings and variables, apart from existing deterministic dependency ordering. | -| 3: Locked lifecycle | Stage count is fixed. Finding 2 concerns output-inventory construction inherited by the new standalone caller. | -| 4: Standalone orchestration | Check-group processing and report construction are linear in findings. Preparation and pure projection were expressly selected and are not reconsidered. Finding 2 applies to its discarded lifecycle result. | -| 5: CLI and reporting | No additional suboptimal algorithm identified in the new command wiring. Native library formatting remains upstream-owned. | -| 6: Recovery and cleanup coverage | No additional algorithmic issue identified in the changed test code; existing lifecycle safety remains applicable to both proposed optimizations. | -| 7: Documentation and verification | No additional algorithmic issue identified. Documentation should change only if a later refactor changes observable behavior. | - -## 1. Flatten Notarius Failure Aggregation - -Status: Complete. Priority: P3. - -Completion: `CheckNotarius` now collects adapter and failed-check errors and -joins them once. Diagnostic rendering is linear in total message length rather -than repeatedly copying nested prefixes. Added coverage for multiple failed -checks, preserved warning severity, and typed adapter causes. Verified with -Go 1.27.4: `go test ./internal/preflight ./internal/adapters/notarius` and -`git diff --check`. - -Evidence: [CheckNotarius](../../internal/preflight/downstream.go), especially -lines 55–62 and 87–89. The loop assigns -`err = errors.Join(err, nextFailure)` for each failed native check. This code -predates the sprint; Stage 1 retains it and Stage 2 uses it through the shared -downstream path. The planning documents specify preservation of findings and -error causes, not this aggregation algorithm. - -Let `F` be the number of failed checks. Building the nested error tree takes -linear work, but rendering it is different: Go 1.27.4's `joinError.Error` -recursively renders each child and copies its text into the parent's buffer. -A left-nested tree therefore copies prefixes of lengths proportional to -`1, 2, ..., F`. For bounded-length failure messages, one rendering takes -`Theta(F²)` time and cumulative allocated bytes, with `Theta(F)` nesting depth. -The checker renders this error both for its aggregate finding and its wrapped -return error. No benchmark is needed to establish the copying pattern. - -Potential refactor: append the original adapter error and individual failed-check -errors to an error slice, then call `errors.Join(failures...)` once before the -existing completeness/lane decision. A flat join renders in time linear in the -total diagnostic text, with `O(F)` auxiliary references. Keep warning severity, -native failure precedence, findings, and `errors.Is`/`errors.As` causes intact. -The Scriptorium checker already uses slice accumulation followed by one join. - -Verification for a future fix: use a synthetic assessment containing multiple -failed checks plus an adapter error. Assert all failures and the adapter cause -survive, and existing warning-only and incomplete-assessment behavior is -unchanged. Avoid timing thresholds or a new diagnostic-count limit. - -## 2. Avoid Building A Discarded Run-Artifact Inventory - -Status: Complete. Priority: P3. - -Completion: shared finalization now returns a lightweight invocation result with -terminal manifest evidence. Only normal pipeline execution builds the full run -summary and artifact inventory; standalone preflight does not traverse or sort -that inventory. Terminal persistence and durable-evidence recovery remain under -the session lock, and normal summary completion includes lock-release failures. -Updated lifecycle tests and internal documentation. Verified with Go 1.27.4: -`go test ./...`, `go test -race ./...`, `go vet ./...`, `go build ./...`, focused -application/preflight/documentation tests, and `git diff --check`. - -Evidence: [standalone lifecycle caller](../../internal/app/session_readiness.go), -lines 79–90, and [finalization](../../internal/app/runner_finalization.go), -lines 45–107. `finalizeInvocation` always constructs `AvailableArtifacts` through -`durableRunArtifacts`. Standalone preflight uses the returned summary only to -distinguish a nil result on an early failure; it never consumes the inventory. - -Let `A` be the number of stored analyze-artifact records, `S` the number of -speaker records, and `K` the number of aggregate output records visited. -Ignoring bounded stage count and identifier lengths, this unused work costs -`O(A log A + S log S + K)` time and `O(A + S + K)` additional space for sorting, -deduplication, and materialized report entries. It runs even when preflight -checks only a small current configuration and the ledger contains many older -artifact records. It also extends the time spent holding the session lock. - -Potential refactor: separate shared terminal persistence/resource handling from -run-specific inventory assembly, allowing standalone preflight to receive a -lightweight lifecycle result. Keep normal `run` summaries and partial durable -artifact evidence unchanged. Removing this unused projection eliminates that -additional traversal/sort/allocation; it does not make the whole command -constant-time, because manifest I/O, selected preparation, and readiness checks -still have their own costs. - -Stage 3 deliberately selects shared locking, finalization, and preservation of -normal runner partial summaries. This opportunity preserves those decisions; -the plan does not require standalone readiness to build an inventory absent -from its report. Prefer a small separation of responsibilities over a generic -reporting or lifecycle-hook framework. - -Verification for a future fix: retain ordinary run/partial-summary tests and -standalone failure, cancellation, and lock-release tests. Confirm standalone -reports are unchanged and terminal persistence still completes while locked.