Skip to content

Add Flow.model(context_type=, strict=False) subset/omnibus context#236

Merged
timkpaine merged 2 commits into
nk/auto_deps_auto_callable_modelfrom
tkp/flow-model-strict-context
Jun 10, 2026
Merged

Add Flow.model(context_type=, strict=False) subset/omnibus context#236
timkpaine merged 2 commits into
nk/auto_deps_auto_callable_modelfrom
tkp/flow-model-strict-context

Conversation

@timkpaine

Copy link
Copy Markdown
Member

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.

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>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Test Results

    1 files  ±0      1 suites  ±0   2m 51s ⏱️ -1s
1 170 tests +6  1 168 ✅ +6  2 💤 ±0  0 ❌ ±0 
1 176 runs  +6  1 174 ✅ +6  2 💤 ±0  0 ❌ ±0 

Results for commit 75b5781. ± Comparison against base commit 51396bc.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.58824% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.02%. Comparing base (51396bc) to head (75b5781).

Files with missing lines Patch % Lines
ccflow/tests/test_flow_model_strict_context.py 94.23% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timkpaine timkpaine merged commit cda9559 into nk/auto_deps_auto_callable_model Jun 10, 2026
20 checks passed
@timkpaine timkpaine deleted the tkp/flow-model-strict-context branch June 10, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant