From ab445439ccc140714a83e4397462f17f07c3e008 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sat, 28 Nov 2026 15:43:27 +0000 Subject: [PATCH] Record preflight review findings --- docs/roadmap/remediation.md | 131 ++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 docs/roadmap/remediation.md diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md new file mode 100644 index 00000000..ab7a0006 --- /dev/null +++ b/docs/roadmap/remediation.md @@ -0,0 +1,131 @@ +# Pipeline Preflight Review Remediation + +## Scope And Overall Assessment + +Reviewed implementation commit `c08e5ab` against all eleven stages of +[Implementation Plan](implementation.md) and the accepted +[Preflight Feature Roadmap](preflight.md). + +The intended architecture is in place. Run and explicit preflight share local +selection and construction; prepared adapters own source parsing; domain owners +validate references; `internal/preflight` discovers selected targets and +interprets native smoke evidence. The CLI owns destination probes, requested +capture, and native readiness reporting. Offline pipeline validation remains +offline. Preflight neither executes the substantive pipeline nor initializes +an accepted-result cache store. + +Two follow-ups are warranted: consistent error propagation at the smoke observer +boundary, and narrow documentation corrections. No unintended strengthening of +permissions policy, provider capability requirements, retry budgets, or readiness +guarantees was found. Keep the accepted scope unchanged while remediating. + +## Finding 1: Preserve Smoke Observer Errors Independently Of Readiness + +**Priority:** P2 — error handling and separation of responsibilities. + +**Affected owners:** +[smoke orchestration](../../internal/preflight/smoke.go), particularly +`RunSmokeChecksObserved` lines 43–48, and the assessment/finalization handoff in +[the preflight command](../../internal/cli/pipeline_preflight.go). +Related plan stages: 4, 6, and 7. + +The observer's error is returned only when the diagnostic itself succeeded and +another diagnostic remains. Consequently: + +- A failing observer on the final successful diagnostic is silently discarded: + the helper returns a nil error. +- If a diagnostic and its observer both fail, the helper returns only the + diagnostic error, losing the observer error at this boundary. + +An offline review test with one successful structured smoke request and an +observer returning a sentinel error reproduced the first case: one observation +was returned with `err == nil`. A final observer returning cancellation has the +same error-loss problem. + +The current CLI's sticky recorder normally recovers capture failures during +`Finalize`; the existing capture tests confirm that those failures still yield +an unsuccessful command. This is not a claim that current CLI capture failures +silently succeed. The problem is that the generic smoke helper depends on a +particular caller's recorder behavior and discards an explicit callback error to +influence the caller's readiness calculation. That makes the error contract +surprising and couples orchestration to presentation/disposition. + +### Required Change + +- Retain errors returned by the observer consistently, including on the final + check and alongside a diagnostic failure. Ordinary wrapping or `errors.Join` + is sufficient; preserve `errors.Is`/`errors.As` identity. +- Keep the native diagnostic verdict on its observation distinct from errors + recording that observation. Retain the collected observations when returning + an error, and stop additional diagnostics when recording fails. +- Let the CLI determine assessment completion from performed diagnostic results + and whether required checks remain, separately from capture/command failure. + A completed positive assessment may still report `ready: true` with nonzero + command status when capture fails, as already agreed. An interrupted sequence + with required checks remaining must not claim readiness. +- Remove the need to suppress callback errors based on their position in the + sequence. No new retry loop, error hierarchy, persisted state, or public report + variant is needed. + +### Verification + +Add focused tests for a final observer failure and simultaneous diagnostic and +observer failures, checking original error identities. Retain the existing +early-capture-stop, cancellation/capture, and positive-assessment/failed-capture +tests. Verify that additional paid checks do not start after an observer +failure and that report delivery/finalization are not repeated. + +## Finding 2: Correct Two Remaining Documentation Boundaries + +**Priority:** P3 — documentation accuracy and clarity. +Related plan stages: 9 and 10. + +1. [Run State Internals](../internal/state.md), lines 131–133, still says that + the run path alone calls `debug.Start`. Explicit preflight now calls the same + allocation lifecycle through `startRunDebug`, as the preceding paragraph + correctly states. Describe both invocation owners and keep shared loaders + storage-free. +2. [Operations](../operations.md), lines 147–187, inserts the new top-level + `Preflight Lifecycle` section before the existing `Acceptance And Fallback` + subsection. This makes substantive run acceptance, semantic continuation, and + permissive artifact fallback appear to be part of preflight. Move the + preflight section after that run subsection, or otherwise restore the run + subsection's correct parent. Preserve the explicit distinction that producer + fallback does not change preflight's smoke verdict. + +### Verification + +Review the resulting heading hierarchy and capture-owner wording against the +implemented command. Check affected links and `git diff --check`; no prose +snapshot tests or additional upstream-library documentation are needed. + +## Stage-By-Stage Review Evidence + +| Plan stage | Review result | +| --- | --- | +| 1 — Shared invocation preparation | Both commands use the same flags, loading, reference selection, resolution, materialization, construction, input reads, and session selection. Run retains its execution/publication owner. Existing selection/regression tests pass. | +| 2 — Source and reference checks | `PreparedPipeline.ParseSource` is shared with the runner; document validation and cancellation remain adapter/framework-owned. The runner builds its index once. Constructors retain domain reference checks; a full configured D&D preflight accepts generated dependencies without fabricated artifacts. | +| 3 — Target discovery | Explicit initial-prompt declarations separate independently selected requests from correction dependencies. Native inspection selects profiles; exact identities deduplicate profile/backend scopes, retaining bindings. Endpoint-only profiles and selected validators are covered. | +| 4 — Native smoke orchestration | Access checks and structured generation are deduplicated, native overrides/retries are forwarded, and actual facts determine verdicts. Unsupported/inapplicable capabilities add no failed check or warning. Finding 1 concerns observer error propagation. | +| 5 — Destination probes | Standard-library temporary probes are cleaned up; output failure and cache warnings have different dispositions. Auto/refresh leave accepted entries unchanged; bypass/deterministic work avoids cache access. No permission convergence was added. | +| 6 — Command and report | Both native command spellings work. Text/JSON/YAML and unsuccessful assessments use CommandKit reporting; quiet/verbose and presentation failures retain native behavior. Assessment disposition needs the narrow adjustment described in Finding 1. | +| 7 — Capture and causes | Requested capture starts before selection/engine work, updates `latest`, and finalizes before reporting. Existing tests retain cancellation and sticky capture causes, including a positive assessment with failed capture. Finding 1 removes the lower helper's reliance on that sticky mechanism. | +| 8 — Assembled verification | Existing real-kit/local-provider tests pass. An additional temporary offline test exercised the unabridged maintained D&D pipeline, its ordinary transcript/reference inputs, generated handoffs, and selected target discovery; it passed with one shared-profile model call and no substantive execution. | +| 9 — Public documentation | Command/report and subprocess workflows are documented, including fixture scope and process-status handling. Finding 2 corrects the Operations hierarchy. | +| 10 — Internals and architecture | Native ownership, shared parsing, online versus offline boundaries, and smoke usage separation are documented. Finding 2 corrects the stale run-only capture sentence. No unrelated architecture restriction was introduced. | +| 11 — Final verification | Tests, vet, build, both help routes, and offline validation succeed. The two findings above should be addressed before treating documentation and error-boundary cleanup as complete. | + +## Checks Run During Review + +- `go test ./...` +- `go test -count=1 ./internal/cli ./internal/preflight ./internal/framework/pipeline` +- `go test -race ./internal/preflight ./internal/cli -run 'TestPreflight|TestSmoke' -count=1` +- `go vet ./...` +- Built `./cmd/notarius` to a temporary path outside the repository. +- Exercised `help pipeline preflight`, `preflight --help`, and offline + `pipeline validate dnd-session --config examples/dnd-complete/config.yml`. +- Temporary Go-overlay tests exercised the full D&D preflight and the terminal + observer-error case without modifying application or permanent test files. + +No live provider calls, real credentials, extraction artifacts, or accepted cache +entries were needed for this review.