Plan inspection of rejected configurations
This commit is contained in:
206
docs/roadmap/failed-load-inspection.md
Normal file
206
docs/roadmap/failed-load-inspection.md
Normal file
@@ -0,0 +1,206 @@
|
||||
# Inspect configuration independently of validation outcome
|
||||
|
||||
Status: proposed target; not implemented. Public API and earlier-checkpoint
|
||||
choices remain open below.
|
||||
Baseline: commit `4a7ae66`, following the typed-value and inspection-view work.
|
||||
|
||||
## Purpose and user intent
|
||||
|
||||
Operators need to inspect invalid configurations at least as easily as valid
|
||||
ones. A failed load must report its error; failure is not a reason to withhold
|
||||
configuration evidence that ConfigKit has already produced.
|
||||
|
||||
Narratio's motivating workflow is `config validate`, followed by `config show`
|
||||
or `config explain` for the same selected inputs. For example, an unsupported
|
||||
`storage.backend` value should be inspectable together with the import, overlay,
|
||||
or override that contributed it. The application's CommandKit/ckconfig adapter
|
||||
should use ConfigKit's native reporting interface rather than reload the input
|
||||
with validation disabled or reconstruct provenance itself.
|
||||
|
||||
Success or failure describes the outcome of processing and validation.
|
||||
Inspection describes the available configuration evidence. These are separate
|
||||
facts; access to a report does not imply that configuration passed validation.
|
||||
|
||||
## Current baseline
|
||||
|
||||
[LoadError](../../diagnostic.go) exposes diagnostics and sanitized source records.
|
||||
Both loading entry points currently return a nil Result on error. A successful
|
||||
[Result](../../lifecycle.go) provides current typed values and a separately frozen
|
||||
[Inspection](../../inspection_view.go) view with effective rendering, history,
|
||||
explanations, metadata, source contexts, and comparison.
|
||||
|
||||
Internally, history and the resolved document are retained before secret lookup
|
||||
and final validation. However, sensitivity, source records, resource contexts,
|
||||
and secret-reference reporting are finalized on the success path in
|
||||
[load_result.go](../../internal/engine/load_result.go). Error construction drops
|
||||
that inspection state. Simply attaching the unfinished state to LoadError would
|
||||
not provide existing redaction and reporting behavior.
|
||||
|
||||
The final validator is expected to be read-only. Its existing mutation audit can
|
||||
reject value, sensitivity, or resolved-secret changes. A retained snapshot from
|
||||
before that callback remains useful even if the callback violates its contract.
|
||||
|
||||
## Target end state
|
||||
|
||||
### One inspection experience
|
||||
|
||||
An invalid resolved configuration supports the same reporting operations and
|
||||
public Inspection type as a valid one:
|
||||
|
||||
- Whole-configuration and selected-subtree effective output with existing redaction.
|
||||
- Native-path explanations, rendered explanations, effective presence/origins,
|
||||
chronological history, and historical-path enumeration.
|
||||
- Original source IDs, source catalogs, locations, and passive resource contexts.
|
||||
- Existing structural comparison and paired redaction at matching scopes,
|
||||
including comparisons between accepted and rejected configuration snapshots.
|
||||
|
||||
Preserve canonical reporting scopes, explicit query path intent, absent/null
|
||||
behavior, ancestor evidence, sequence-atomic differences, and ordinary writer
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
### Evidence from the failing invocation
|
||||
|
||||
A view is backed by retained evidence from that invocation. Reading it does not
|
||||
reload sources, rerun callbacks, repeat secret lookup, or consult changed inputs.
|
||||
The evidence is frozen independently of caller-owned objects and subsequent
|
||||
loads. Existing detached-record and passive resource-context ownership applies;
|
||||
resource contents themselves are still read only when the application requests
|
||||
access, under the existing resource contract.
|
||||
|
||||
When source assembly, typed decoding, overrides, and recorded resolution have
|
||||
produced the resolved snapshot, preserve it on later reported failure. This
|
||||
includes semantic validation errors, final registered-identity failures, and
|
||||
secret lookup failures when the retained snapshot is available. Secret references
|
||||
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.
|
||||
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
|
||||
means there is no supported configuration snapshot for that failure, not that an
|
||||
invalid configuration is categorically uninspectable.
|
||||
|
||||
Snapshot stage identifies completed processing, not a second success flag or a
|
||||
new validation policy. Where a view is available, the same reporting semantics
|
||||
apply to the evidence it actually contains. A failed load remains an error;
|
||||
inspection does not turn it into a successful load or continue startup for the
|
||||
application.
|
||||
|
||||
### Existing safety and lifecycle behavior
|
||||
|
||||
Reuse current sensitivity classification and historical/paired redaction for
|
||||
both successful and failed loads. Credential contents remain outside inspection,
|
||||
and application-authored messages retain their existing responsibility boundary.
|
||||
No additional confidentiality or isolation guarantee is introduced.
|
||||
|
||||
Keep the existing processing order, callback contracts, error classifications,
|
||||
composition rules, and resource cleanup. Error inspection does not require a
|
||||
second validation pass or a special load mode. A snapshot unavailable because of
|
||||
an existing history/resource limit does not authorize bypassing that limit.
|
||||
Snapshot retention should reuse already produced evidence where possible rather
|
||||
than duplicate complete trees or introduce a global cache.
|
||||
|
||||
## Changes needed from the baseline
|
||||
|
||||
The engine needs a shared inspection-finalization boundary used by success and
|
||||
eligible error returns. It must complete classification and source/context
|
||||
reporting before exposing a view, preserve the candidate represented by its
|
||||
history, and carry that evidence through engine and root LoadError wrappers.
|
||||
The ordinary result-publication path should reuse that owner.
|
||||
|
||||
The public facade needs error inspection acquisition, scope selection, and a
|
||||
clear account of snapshot availability/stage. Existing consumers of LoadError
|
||||
and Result should continue to work. Downstream adapters can then share reporting
|
||||
logic across outcomes; Narratio and ckconfig integration changes remain owned by
|
||||
those projects rather than implemented inside ConfigKit.
|
||||
|
||||
Current architecture and configuration documentation must distinguish error
|
||||
status from inspectability. Revise wording about failure and inspection where it
|
||||
currently assumes only successful loads have reports, including comparison
|
||||
eligibility. Record the architectural decision in an ADR, with references to the
|
||||
existing lifecycle and inspection decisions. Keep implemented-behavior claims
|
||||
unchanged until implementation lands; this pass creates no ADR or policy changes.
|
||||
|
||||
Behavioral coverage should establish same-invocation values and provenance after
|
||||
semantic rejection, defaults/layers/CLI/resolution agreement, earlier-failure
|
||||
availability, validator-mutation snapshot identity, and sensitive current and
|
||||
historical output. Include typed secrets, final identity failure, accepted versus
|
||||
rejected snapshot comparison, scoped reports, and independent loads. A maintained
|
||||
consumer example should demonstrate rendering and explanation after an error
|
||||
without a second load. Reuse existing mechanisms and tests where they already
|
||||
protect unchanged behavior; avoid private-call-count or performance thresholds.
|
||||
|
||||
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.
|
||||
Reference in New Issue
Block a user