Skip to content

Fix: context-free filters cover all contexts under strict#7

Merged
oojacoboo merged 2 commits into
masterfrom
feature/strict-context-free-coverage
Apr 16, 2026
Merged

Fix: context-free filters cover all contexts under strict#7
oojacoboo merged 2 commits into
masterfrom
feature/strict-context-free-coverage

Conversation

@oojacoboo

Copy link
Copy Markdown
Contributor

Summary

Fixes an inconsistency between how context-free filters are handled during query composition vs the strict coverage check.

A filter with no `context:` array is documented as "applies to all contexts" — and that's exactly how matching strategies treat it. But the strict coverage check was treating context-free filters as contributing no coverage. That meant adding a base `company_id = X` filter (a very common pattern) silently made strict mode deny all real contexts.

Now context-free filters cover all contexts for the strict check too. "Applies to all" and "covers all" align.

Behavior changes

  • `strict: true` + any context-free filter = no denial ever (context-free covers everything)
  • `strict: true` + only contextual filters = denies active contexts not listed (strict works as designed)
  • To use strict meaningfully, declare `context:` on every filter

Tests

  • New: `testStrictContextFreeFilterCoversAllContexts` — proves the new semantic
  • Updated: `testStrictUncoveredContextDenied` — uses `StrictNoContextFreeEntity` (contextual-only) to actually test denial
  • Updated: `testStrictAmbientContext*` — switched to `StrictNoContextFreeEntity` so ambient-skip logic is actually exercised
  • README updated with a "Context-free filters" note explaining the interaction

All 49 tests pass.

Context-free filters already apply to all contexts during query
composition, but the strict coverage check treated them as covering
nothing. That was inconsistent: "applies to all" and "covers all"
should align.

Now a context-free filter short-circuits the coverage check — strict
only denies when every filter declares a context and some active
non-ambient context isn't listed.

For strict mode to be meaningful, every filter should declare a
`context:` array.
Adds explicit test that a context-free filter placed first under
FirstMatch short-circuits all subsequent filters. This has been
the behavior since FirstMatch was introduced — the test makes
it a regression guard against silent drift.
@oojacoboo
oojacoboo merged commit 6d4a1c0 into master Apr 16, 2026
3 checks passed
@oojacoboo
oojacoboo deleted the feature/strict-context-free-coverage branch April 16, 2026 21:05
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