Add Flow.model(context_type=, strict=False) subset/omnibus context#236
Merged
timkpaine merged 2 commits intoJun 10, 2026
Merged
Conversation
By default a declared `context_type` may now be an "omnibus" superset: every `FromContext[...]` parameter must exist on the context with a compatible type, but the context may carry extra fields the model does not consume. This matches the otherwise-permissive bag-of-types design and lets multiple models share one broad context. - `_validate_declared_context_type(..., strict=False)` keeps the missing-field and type-compatibility checks but only enforces the "every required context field is a FromContext param" bijection when `strict=True`. - Runtime: `_validate_declared_context_values` validates the consumed fields individually when the declared context has unconsumed required fields (subset mode); otherwise it constructs the whole declared context so its cross-field validators still run. No config/serialization change needed. - Thread `strict` through `flow_model` and document it on `Flow.model`. Updates the existing extra-required-field test to reflect the new default (allowed by default, rejected under strict=True) and adds focused tests for subset execution, strict rejection/acceptance, and the shared missing/type checks that apply in both modes. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## nk/auto_deps_auto_callable_model #236 +/- ##
=================================================================
Coverage 93.01% 93.02%
=================================================================
Files 160 161 +1
Lines 17835 17897 +62
Branches 1153 1157 +4
=================================================================
+ Hits 16589 16648 +59
- Misses 1020 1023 +3
Partials 226 226 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
By default a declared
context_typemay now be an "omnibus" superset: everyFromContext[...]parameter must exist on the context with a compatible type, but the context may carry extra fields the model does not consume. This matches the otherwise-permissive bag-of-types design and lets multiple models share one broad context._validate_declared_context_type(..., strict=False)keeps the missing-field and type-compatibility checks but only enforces the "every required context field is a FromContext param" bijection whenstrict=True._validate_declared_context_valuesvalidates the consumed fields individually when the declared context has unconsumed required fields (subset mode); otherwise it constructs the whole declared context so its cross-field validators still run. No config/serialization change needed.strictthroughflow_modeland document it onFlow.model.Updates the existing extra-required-field test to reflect the new default (allowed by default, rejected under strict=True) and adds focused tests for subset execution, strict rejection/acceptance, and the shared missing/type checks that apply in both modes.