diff --git a/docs/roadmap/failed-load-inspection.md b/docs/roadmap/failed-load-inspection.md index 551792e..7a8715f 100644 --- a/docs/roadmap/failed-load-inspection.md +++ b/docs/roadmap/failed-load-inspection.md @@ -1,7 +1,7 @@ # Inspect configuration independently of validation outcome -Status: proposed target; not implemented. Public API and earlier-checkpoint -choices remain open below. +Status: agreed target; public accessor and checkpoint approach settled; not +implemented. Baseline: commit `4a7ae66`, following the typed-value and inspection-view work. ## Purpose and user intent @@ -60,12 +60,24 @@ failure behavior. Scoping remains a reporting focus. The error's sources and the view's sources should refer consistently to the same load and evidence, using the existing sanitization rules. -The recommended API is an optional inspection accessor on LoadError, mirroring -Result's scope selection; see Open Decision 1. Ordinary semantic rejection must -not leave consumers with a reduced reporting interface. Callers handle the -non-nil error and retrieve inspection through their normal reporting adapter. -Keeping the current nil Result return is a compatibility choice, not a rule -that rejected configurations must be inaccessible. +Add an optional inspection accessor on LoadError, mirroring Result's scope +selection: + +```go +func (e *LoadError) InspectSubtree(path Path) (Inspection, bool) +``` + +The root Path requests whole-configuration inspection; other scopes follow the +existing rules. Reporting adapters can accept Result and LoadError through the +same inspection-acquisition interface. The Boolean concerns snapshot availability +and path validity, not validation success or presence of the selected scope. +A valid absent scope behaves as it does today. + +Ordinary semantic rejection must not leave consumers with a reduced reporting +interface. Callers handle the non-nil error and retrieve inspection through their +normal reporting adapter. Preserve existing load signatures and nil Result +returns on error as a compatibility choice, not a rule that rejected +configurations must be inaccessible. This addition concerns reporting data. It does not require typed execution access through an error, and does not establish a general prohibition on such access. @@ -86,18 +98,27 @@ secret lookup failures when the retained snapshot is available. Secret reference can still be reported by name without retaining credential contents. Validation success is not an admission condition for inspection. -Recommend using the candidate presented to the final validator as the inspection -snapshot for errors reported during that callback, including mutation errors. +Use the candidate presented to the final validator as the inspection snapshot +for errors reported during that callback, including mutation errors. Identify it as the pre-validation candidate; do not silently replace it with unrecorded callback mutations or invent origins for those mutations. The existing mutation diagnostic remains available alongside the snapshot. A callback failure must not automatically erase previously retained evidence. When processing stops earlier, keep diagnostics and available source evidence, -and expose any supported retained configuration checkpoint with its processing -stage and limitations. Do not label an earlier or incomplete snapshot as a fully -resolved configuration, or fabricate omitted values and history. The exact extent -of earlier-checkpoint support is Open Decision 2. Absence of an inspection view +and expose the latest coherent checkpoint already produced by the pipeline whose +values, history, and sensitivity can be reported faithfully. Identify its +processing stage and limitations using lightweight snapshot-stage information +alongside the acquired Inspection. This can include an earlier decoded candidate +when a later CLI assignment fails, or a resolver's entry candidate when resolution +fails. Availability follows the actual processing completed in that invocation. + +During implementation planning, inventory failure exits and specify availability +at each existing checkpoint. Earlier acquisition and parsing failures may have +diagnostics/source evidence alone. This approach reuses existing checkpoints; +it does not require snapshots after every phase or a new partial-decoding or +recovery framework. Do not label an earlier or incomplete snapshot as fully +resolved, or fabricate omitted values and history. Absence of an inspection view means there is no supported configuration snapshot for that failure, not that an invalid configuration is categorically uninspectable. @@ -155,52 +176,3 @@ Completion means a consumer can investigate rejected resolved settings through the ordinary inspection interface, see the stage and limits of any earlier snapshot, and continue to receive the original failure diagnostics. Detailed sequencing belongs in a subsequent implementation plan. - -## Open Decisions - -### 1. Where should callers acquire error inspection? - -**Recommendation:** add -`func (e *LoadError) InspectSubtree(path Path) (Inspection, bool)`, mirroring -Result.InspectSubtree. The root Path requests whole-configuration inspection; -other scopes use existing rules. This gives reporting adapters one shared -interface and preserves existing load signatures and nil-result behavior. -The Boolean concerns snapshot availability/path validity, not validation success -or presence of the selected scope. A valid absent scope behaves as it does today. - -**Alternative:** `LoadError.Inspection() (Inspection, bool)` returns a root view. -This is a natural discovery API and matches the original suggestion. Full parity -would also need scope selection on Inspection, or an additional error method; -that can be useful generally but adds more public surface than the mirrored -accessor. - -**Alternative:** return a non-nil Result alongside an error when configuration -has been resolved. This directly reuses existing result methods and can expose -typed values as well. It is idiomatic Go when documented, but changes ConfigKit's -current error-return contract and creates additional ownership and compatibility -questions. The requested reporting capability can be delivered independently of -that broader change. - -### 2. Which earlier configuration checkpoints should be exposed? - -**Recommendation:** guarantee inspection of the retained resolved candidate on -later failure, and expose earlier coherent checkpoints already produced by the -pipeline where their values, history, and sensitivity can be reported faithfully. -Use lightweight snapshot-stage information alongside the acquired Inspection to -identify that evidence. During implementation planning, inventory failure exits -and specify availability at each existing checkpoint. Earlier acquisition and -parsing failures may have diagnostics/source evidence alone. This provides useful -failure evidence without inventing a new partial-decoding or recovery framework. -Validator mutation retains the pre-validation candidate as described above. - -**Alternative:** initially expose only the resolved-candidate checkpoint, while -preserving diagnostics/source records on earlier failures. This is smaller and -simpler to document, and fulfills Narratio's final-validation example, but leaves -other already available configuration states inaccessible to reporting. It would -be a deliberate scope reduction requiring agreement, not a safety principle. - -**Alternative:** create snapshots after every processing phase, including partial -assembly and decoding, and optionally capture post-validator mutations. This can -provide richer debugging evidence, but requires additional rules for incomplete -values, missing provenance, sensitivity, and retained memory. Consider it only -where concrete operator needs justify that additional machinery.