Phase 4 Wave 3: DI-resolved validator path + ISettingsCollection exposure (VAL-01 DI path, API-02)#35
Open
guy-lud wants to merge 5 commits into
Open
Phase 4 Wave 3: DI-resolved validator path + ISettingsCollection exposure (VAL-01 DI path, API-02)#35guy-lud wants to merge 5 commits into
guy-lud wants to merge 5 commits into
Conversation
Register the built ISettingsCollection as a DI singleton and add an AddSimpleSettings(out ISettingsCollection, Action?) overload that surfaces the same instance while preserving the IServiceCollection fluent chain.
Add a deferred, opt-in ISettingsValidationRunner resolved via IServiceProvider.ValidateSimpleSettings(). It resolves DI-registered ISettingValidation<T> from a fresh scope (so scoped-dependency validators work), dispatches through the ISettingsValidator cast (the default-interface bridge, no reflection), and aggregates via the shared SettingsValidationException.ThrowIfAny so the thrown contract is identical to the core populate path. A throwing validator surfaces value-free as SettingsValidatorInvocationException (type-only, no bound value, no inner).
- ValidateSimpleSettings surfaces a caller-facing error when AddSimpleSettings was not called (internal runner type no longer leaks into the message). - Trim runner comments to one line each; drop internal planning-ID reference. - Harden tests: deferral test is now an invocation-counter timing probe (0 runs at build, 1 on the explicit call); scope test asserts the scoped validator actually executed; redaction test pins that the secret is bound; add no-op (no DI validators) and misuse coverage.
…tate Record the VAL-01 DI path + API-02 execution: 04-04-SUMMARY.md, the gsd-code-reviewer 04-04-REVIEW.md, STATE.md (all 5 Phase 4 plans landed; verify+secure pending), and patch the plan's superseded reflective-dispatch text to the shipped default-interface-bridge dispatch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4 Wave 3 (plan 04-04) — VAL-01 DI path + API-02
Completes the code for Phase 4 (Collection & Validation Binding). Waves 1–2 (#33) landed collection binding + the core validation engine; this wave adds the DI-integration surface.
API-02 — expose
ISettingsCollection(D-15)AddSimpleSettingsnow registers the builtISettingsCollectionas a DI singleton (GetRequiredService<ISettingsCollection>()), serving the same instances the container resolves per interface.AddSimpleSettings(out ISettingsCollection settings, Action<ISettingsBuilderOptions>? = null)overload surfaces the built collection while preserving theIServiceCollectionfluent chain. Theoutvalue and the DI singleton are the same instance.VAL-01 — DI-resolved validator path (D-11)
IServiceProvider.ValidateSimpleSettings()runs DI-registeredISettingValidation<T>in a deferred, post-BuildServiceProvider()step (the container isn't built duringAddSimpleSettings).IServiceScopeFactory.CreateScope()), so validators with scoped dependencies resolve undervalidateScopes: true.ISettingValidation<T>default-interface bridge (((ISettingsValidator)v).Validate(...)) — no reflection.SettingsValidatorInvocationException(type, type)(no bound value, no chained inner); errors aggregate through the sharedSettingsValidationException.ThrowIfAny, so the thrown contract is identical to the core populate path.ISettingsValidationRunner) is internal; onlyValidateSimpleSettings()is public. GenericHost stays Abstractions-only (no new dependency).Notes
[SettingsSection(ValidatorType=…)],[SettingsProperty(ValidatorType=…)]) remain the core path and run automatically during binding; the DI path is additive. DI validators run only on the explicitValidateSimpleSettings()call — an opt-in caveat documented in the XML-doc and carried to DOC-01 (README, Phase 5).Tests & review
.planning/phases/04-collection-validation-binding/04-04-{SUMMARY,REVIEW}.md.Requirements: VAL-01 (DI path), API-02. Closes the code for Phase 4; phase verify + security gate to follow.