Skip to content

Refuse a policy that forbids what it requires (closes #322) - #387

Merged
patelankeet2 merged 3 commits into
mainfrom
feat/322-policy-contradictions
Nov 2, 2026
Merged

patelankeet2 merged 3 commits into
mainfrom
feat/322-policy-contradictions

Conversation

@shubhamkataria2005

@shubhamkataria2005 shubhamkataria2005 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #322 (US-30). My one task from #354.

What it does

A prohibition says traffic must be DENIED. A requirement says it must be PERMITTED. Two such rules over overlapping traffic on the same device and filter cannot both be satisfied — whichever way the network is configured, one of them reports a violation, and fixing it creates the other.

Before this the policy loaded cleanly and the scan ran. load_policy() now refuses it:

PolicyError: this policy contradicts itself, so no configuration could
satisfy it: rule 3 ('The LAN must not reach the finance server') forbids
what rule 7 ('Accounts must reach the finance server') requires on rtr-us5
filter acl_in: both describe src 10.10.10.64/26, dst 10.20.0.5/32,
dst ports 443

Against the acceptance criteria:

criterion
Pure logic over the policy file; no Batfish, no config ✅ no Batfish, Docker or Ollama; analysis/policy_conflicts.py imports only ipaddress and re
Reports the contradicting pair with both rule numbers and the overlap ✅ and the overlap is the intersection, not either rule restated
A contradiction blocks the scan ✅ raised from load_policy(), the gate every entry point goes through
#240's problem D ✅

The design decision I want reviewed hardest

Three answers, not two. Batfish header specifiers are a language — dstIps can read 0.0.0.0/0 \ (218.8.104.58, 10.20.0.5), ipProtocols can read !tcp. This module parses a deliberate subset and refuses to guess at the rest:

answer effect
overlap policy refused
no overlap loads
undecidable loads, and is reported on Policy.undecidable

The third is the whole safety argument. An undecidable pair is printed by the pipeline as warning:, never dropped, because treating "we could not compare these" as "these are fine" is F-4 arriving through the policy file.

The shipped docs/examples/policy.example.json proves it is not theoretical: its set difference makes one pair it could not compare, and that pair is reported rather than given a clean bill of health it has not earned. (Corrected 2 November, @patelankeet2's review: this said two pairs. Since the field-by-field fix in 8a190a3, the negated-protocol pair, rule 2 vs rule 4, is proved disjoint by dstIps before its protocol matters, so it is no longer reported. test_the_example_does_not_warn_about_a_pair_a_parsed_field_proves_disjoint pins that.)

An unmodelled query field makes a pair undecidable rather than being skipped, and that direction is deliberate: skipping a field would widen both header spaces and could invent an overlap that is not there, refusing a policy that is perfectly consistent. That is the failure I would most want someone to check me on.

What is deliberately not a contradiction

Two prohibitions over the same traffic are consistent — denying twice is denying — and so are two requirements. Rules on different devices or filters never collide. A rule's queries are a union, because policy_compliance fails the rule if any one fails.

The port case is the one worth seeing, because it is the real shape in the example file: 0-442,444-65535 against 443 is not an overlap, and a cruder check that noticed "both mention ports" would refuse a correct policy.

Mutation-tested rather than assumed

Each of the five mutations that matter fails the new tests:

undecidable collapses to "no overlap"      9 failed, 18 passed
unmodelled query fields ignored            2 failed, 25 passed
node/filter scope check dropped            2 failed, 25 passed
two prohibitions counted as a conflict     8 failed, 19 passed
overlap detail dropped from the message    1 failed, 26 passed

tests/test_suite_hygiene.py also earned its keep here — six of my first-draft tests asserted nothing and it named all six. They assert the positive property now.

Scope

policy_compliance only, because kind is its key and it is the only section whose rules can disagree about the same traffic this way. contradictions() takes entries and knows nothing about which section produced them, so another section gaining that shape is a call, not a rewrite.

Touches none of the three things #354 told me to stay out of: no web/, no analysis/checks/access_control.py, no tools/.

Verified

1848 passed, 42 skipped. ruff check . reports 8 errors, all pre-existing in docs/document-builds/ and identical on main — I left them alone, but they are in the folder rescued by #311 and someone may want them in a separate PR.

US-30. A `prohibition` says traffic must be DENIED; a `requirement` says it
must be PERMITTED. Two such rules over overlapping traffic on the same device
and filter cannot both be satisfied -- whichever way the network is
configured, one reports a violation, and fixing it creates the other.

Before this, that policy loaded cleanly and the scan ran. The user got a real
finding, fixed it, and got the opposite finding. Nothing said the rules were
at fault.

`load_policy()` now refuses it, naming both rules and the intersection:

    PolicyError: this policy contradicts itself, so no configuration could
    satisfy it: rule 3 ('The LAN must not reach the finance server') forbids
    what rule 7 ('Accounts must reach the finance server') requires on
    rtr-us5 filter acl_in: both describe src 10.10.10.64/26,
    dst 10.20.0.5/32, dst ports 443

The overlap is in the message because US-30 asks for it: naming only the pair
leaves the user diffing two header specifiers by eye.

Pure logic over the policy file. No Batfish, no Docker, no config.

PROVEN, NOT PRESUMED -- AND THE THIRD ANSWER

Batfish header specifiers are a language, not a list: `dstIps` can read
`0.0.0.0/0 \ (218.8.104.58, 10.20.0.5)` and `ipProtocols` can read `!tcp`.
analysis/policy_conflicts.py parses a deliberate subset and refuses to guess
at the rest, so every comparison has three answers:

    overlap        proven to share traffic      -> policy refused
    no overlap     proven disjoint              -> loads
    undecidable    outside the parsed subset    -> loads, and is REPORTED

The third one is the point. Undecidable pairs come out on
`Policy.undecidable` and the pipeline prints them as `warning:`, never drops
them. Treating "we could not compare these" as "these are fine" would be F-4
arriving through the policy file.

An unmodelled query field makes a pair undecidable rather than being skipped.
That direction is deliberate: skipping a field widens both header spaces and
could invent an overlap, refusing a policy that is consistent.

The shipped docs/examples/policy.example.json demonstrates it -- it uses both
set difference and a negated protocol, so it loads and reports two pairs it
could not compare, rather than a clean bill of health it has not earned.

MUTATION-TESTED RATHER THAN ASSUMED

Each of the five mutations that matter fails the new tests:

    undecidable collapses to "no overlap"        9 failed
    unmodelled query fields ignored              2 failed
    node/filter scope check dropped              2 failed
    two prohibitions counted as a conflict       8 failed
    overlap detail dropped from the message      1 failed

Scoped to `policy_compliance`, because `kind` is its key and it is the only
section whose rules can disagree about the same traffic this way.
`contradictions()` takes entries and knows nothing about the section, so
another section gaining that shape is a call, not a rewrite.

1848 passed, 42 skipped. ruff clean (the 8 pre-existing errors in
docs/document-builds/ are unchanged and also present on main).
@shubhamkataria2005

Copy link
Copy Markdown
Collaborator Author

@ARSH871-bot @SamikaPerera — gentle nudge, no rush. This closes #322, which was my one task from #354. It is clean against current main with CI green.

The thing most worth a reviewer's time is the third answer ("undecidable"). #324 now depends on it too: the corrected "never fires" definition I posted there today reuses policy_conflicts.overlap() from this PR.

@ARSH871-bot ARSH871-bot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed ab9a784 in a detached worktree, and on scratch merges onto main dc93ccb (which now has #389) and onto #390. Everything below I re-ran; none of it is taken from the description.

What holds up

  • A proven contradiction is refused everywhere I tried. With your example file, python -m analysis.pipeline tests/fixtures/rtr-us5-secure --policy contra.json prints "Policy not loaded, so nothing was analysed." and then your message word for word. /api/policy returns 400 with the same text and stages nothing. Policy( is only built inside load_policy, so "the gate every entry point goes through" is true.
  • The before is real. On main the same file loads, and rtr-us5-secure reports PC-003 and PC-007.
  • No false refusals in the subset you parse. Adjacent /24s, 0-442 vs 443, different devices, different filters, udp vs tcp, two prohibitions and two requirements all load. I thought icmp-forbidden vs dstPorts-443-required was a false refusal, but Batfish's searchFilters(deny, dstIps=10.20.0.5, dstPorts=443) returned ICMP (type=8, code=0), so a ports-only space really does include ICMP and you're right to refuse it.
  • Numbers: 1848 passed / 42 skipped without Batfish, as you said. ruff shows the same 8 as main. Four of your five mutation counts reproduce exactly. "Undecidable collapses" gave me 5 or 10 depending on where it collapses, not 9, but it's caught either way.

Changes requested

  1. Protocol tokens are guessed — analysis/policy_conflicts.py:133-146. Anything not negated is taken as a protocol name. So "6", "tcp,udp" and ["tcp, udp"] never meet tcp/udp, and the pair loads as consistent with no warning. Batfish reads all three as real protocols: ipProtocols=["6"] returned a TCP (SYN) flow, and pybatfish splits "tcp,udp" into ['tcp','udp']. Repro:

    prohibition {"srcIps":"10.10.10.0/24","dstIps":"10.20.0.5","ipProtocols":["6"]}
    requirement {"srcIps":"10.10.10.64/26","dstIps":"10.20.0.0/16","ipProtocols":["tcp"],"dstPorts":"443"}
    

    This loads with undecidable == []. Swap "6" for "tcp" and it's refused. Scanned, PC-003 fires on the "6" rule with a TCP flow. That's "no contradiction" standing in for "didn't understand the token", which is the exact case your third answer exists for (overlap() says "Never guesses", line 226). Please split items on commas, map numbers or treat them as undecidable, and make anything outside a known name list undecidable.

  2. Filter scope is compared as raw strings — :242-243 and :268-269. ACL_IN vs acl_in is "different filter: cannot collide", silently. Batfish resolves ACL_IN, acl_in (trailing space), /acl_in/ and @in(GigabitEthernet0/0) all to acl_in on rtr-us5, while nonexistent raises. Repro: your example with the requirement's filter set to "ACL_IN" loads clean, and the scan reports both PC-003 and PC-007. Suggest comparing strip().casefold(). If two filters match only after normalising, or either uses specifier syntax (/ @ ( ,), report the pair as undecidable rather than skipping it. docs/policy-rules.md:374 ("never collide") needs the same qualifier. Node is fine as it is: a mis-cased node never runs.

  3. "Never dropped" holds on the CLI only — docs/policy-rules.md:396-397 and the PR body. /api/policy returns only renamed (web/main.py:2022). Uploading docs/examples/policy.example.json gives 200 with no mention of either pair, and python -m analysis.change_impact … policy.json doesn't print them either. So on the dashboard an undecidable pair is dropped silently. I know #354 kept you out of web/, so please change the wording to say the CLI prints them and the dashboard doesn't yet, and we'll open an issue for the UI. Also, deleting print(f"warning: {note}") at analysis/pipeline.py:886 fails no test. Please add one that runs pipeline.main() on the example policy and asserts two warning: lines.

Should-fix

  1. One unparseable field hides a disjoint parsed one — _parse(), :149-166. On the shipped example, rule 2 vs rule 4 says "could not be compared: ipProtocols=['!tcp']", but their dstIps are 10.20.0.5 and 218.8.104.58, which is provably disjoint on a field you do parse. So one of the two warnings the PR cites is wrong. Please compare field by field and return False as soon as any parsed field is disjoint. That can't invent an overlap, which is the direction you were worried about, because a conjunct only shrinks a space. If our own example produces a false warning, people will learn to skip the warnings.

Nits

  • overlap({"dstPorts":"1-100,50-200"},{"dstPorts":"60-70"}) gives dst ports 60-70,60-70.
  • The "Last, because…" ordering in load_policy isn't pinned. Moving the call above _assign_missing_numbers passes every test, and the message would then say "an unnumbered rule … an unnumbered rule". One test with no number fields would cover it.
  • tests/test_policy_contradictions.py:214 is relative to the current directory and fails when run from tests/. test_policy_example_is_valid.py anchors on Path(__file__).
  • The _COMPLEX comment mentions /, but the regex doesn't include it.
  • dstPorts: true is accepted as port 1.

Cross-PR: merges cleanly onto main dc93ccb and with #390. Without Batfish: main 1849/49, plus #387 1878/49, plus #390 1895/49. With Batfish: main 1885/13, plus #387 1914/13. No semantic overlap with #390. #389 loads through the same gate, so it refuses contradictions too.

Requesting changes for 1–3. Items 1 and 2 are your design's own rule applied to two places it missed, and both fixes are small.

…nings

Every item from @ARSH871-bot's review of ab9a784, each reproduced first.

1. Protocol tokens were guessed. Anything not negated was taken as a name,
   so "6", "tcp,udp" and ["tcp, udp"] never met tcp/udp and a real
   contradiction loaded as consistent. Batfish reads "6" as TCP. Protocols
   now come from a closed list -- tcp, udp, icmp by name or number -- with
   comma lists split the way pybatfish splits them. Anything else is
   undecidable, never a new protocol.

2. Filter scope compared raw strings, so ACL_IN vs acl_in was "different
   filter: cannot collide". Batfish resolves ACL_IN, "acl_in ", /acl_in/ and
   @in(...) to the same ACL. Filters that match only after strip/casefold,
   or that are specifiers (/ @ ( ,), now make the pair undecidable rather
   than skipped. Node is still compared exactly: a mis-cased node never runs.

3. "Never dropped" held on the CLI only. docs/policy-rules.md now says the
   pipeline and change_impact CLIs print each pair and the dashboard does
   not yet, pointing at #404. change_impact's CLI now prints them too, and
   two tests run both CLIs on the shipped example and count the warnings --
   deleting the pipeline's print used to fail nothing.

4. One unparseable field hid a disjoint parsed one. Comparison is now field
   by field: a query is a conjunction, so one provably disjoint field makes
   the pair disjoint whatever the others say. That cannot invent an overlap.
   The shipped example drops from two warnings to one; rule 2 vs rule 4 was
   false (10.20.0.5 vs 218.8.104.58).

Nits: overlapping port ranges are described once; a bool is not a port; the
"last, because" ordering in load_policy is pinned by a test with no numbers;
the example path is anchored on __file__; the _COMPLEX comment no longer
mentions "/".

Mutation-tested: unknown protocol accepted, commas not split, raw filter
compare, specifiers skipped, giving up at the first unparsed field, the
pipeline print removed, the check moved before numbering, and a bool port
each fail the tests. The "first unparsed field" mutant initially SURVIVED --
both disjoint-beats-unparsed tests put the disjoint field first in field
order -- so a test with the unparsed field first now pins it.

1932 passed, 13 skipped with Batfish running. ruff clean.
@shubhamkataria2005

Copy link
Copy Markdown
Collaborator Author

@ARSH871-bot — all of it is addressed in 8a190a3. I reproduced each item before fixing it, and under M-2 rule 1 your review is void now, so this needs a fresh look.

# your finding now
1 "6", "tcp,udp", ["tcp, udp"] load as consistent refused. Closed list (tcp/udp/icmp, plus 6/17/1), comma lists split like pybatfish does; anything else, e.g. "banana", is undecidable
2 ACL_IN vs acl_in skipped as "cannot collide" undecidable, and so are acl_in , /acl_in/ and @in(GigabitEthernet0/0). acl_out vs acl_in is still skipped. Node compared exactly, as you said
3 "never dropped" is CLI-only docs say exactly that and point to #404, which I opened for the dashboard. change_impact's CLI prints them too now, and two tests run both CLIs on the example and count the warning: lines
4 one unparsed field hides a disjoint one field by field now. The example drops from two warnings to one; rule 2 vs rule 4 was the false one

All five nits are done: ports described once, dstPorts: true is undecidable, the ordering is pinned by a test with no number fields, the example path is anchored on __file__, and the _COMPLEX comment is fixed.

One thing your review caught that I should have caught myself. When I mutation-tested fix 4, the "give up at the first unparsed field" mutant survived. Both of my disjoint-beats-unparsed tests put the disjoint field before the unparsed one in field order, so the early return never mattered. There's now a test with an unparsed srcIps ahead of a disjoint dstIps, and the mutant fails.

On your icmp note: thank you for checking that against Batfish before calling it a false refusal. A ports-only space does include ICMP, so it stays refused.

1932 passed, 13 skipped with Batfish running, merged with current main (dc93ccb). ruff clean.

@SamikaPerera SamikaPerera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I went through the diff with Claude Code and checked Arsh's four findings against 8a190a3 one by one: protocol tokens are a closed list (analysis/policy_conflicts.py:136-154); ACL spelling and specifier syntax come out undecidable, not guessed (:66-91 and :307-314); "never dropped" is documented as CLI-only with #404 opened (docs/policy-rules.md:413); and the comparison is field by field (:275-286). Each has a named test. I had tests/test_policy_contradictions.py run: 45 passed. The shipped example now gives one undecidable pair instead of two, and the pair that went is the one Arsh called false. undecidable is kept as a separate list from contradictions and printed as warning: lines, so an undecidable pair never reads as "no contradictions found" (F-4).

What I did not check: the intersection maths in _nets_meet (:202) and _ranges_meet (:216), where no finding was raised and I haven't mutation-tested them. I also skimmed the 104 documentation lines without verifying every sentence.

Questions, not blockers. Why two regexes for "too complex to parse" (_COMPLEX at :69, _FILTER_SPECIFIER at :293)? Were _nets_meet and _ranges_meet mutation-tested? Does an absent field (ANY) always make a pair more likely to be reported, not less?

shubhamkataria2005 added a commit that referenced this pull request Oct 29, 2026
…r own regex

Answers two of Samika's questions on #387. Mutation-testing _nets_meet and
_ranges_meet killed 13 of 14 mutants; the survivor was removing the address
de-duplication, which the port side already had a test for. Now 14 of 14.

Kept off #387's branch so its approval is not voided for a test-only change.
@shubhamkataria2005

shubhamkataria2005 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

@SamikaPerera — thanks for the review, and sorry these sat for three days. Answers, with what I ran:

1. Why two regexes? They guard two different grammars. In an address field, / is a CIDR and , separates a list, and _networks() parses both. In a filter name, /acl_in/ is a regex and a,b is a list of filters. So one pattern can't serve both: _COMPLEX would let /acl_in/ through as a plain name, and _FILTER_SPECIFIER would refuse every CIDR. That reason wasn't written next to the code, so it is now (see below).

2. Were _nets_meet and _ranges_meet mutation-tested? They hadn't been, so I tested them now. 14 mutants against tests/test_policy_contradictions.py:

KILLED    nets: overlaps -> equality           KILLED    ports: <= -> < (single port lost)
KILLED    nets: pick the LESS specific         KILLED    ports: max/min swapped
KILLED    nets: always pick x                  KILLED    ports: lo from first range only
SURVIVED  nets: drop de-duplication            KILLED    ports: hi from first range only
KILLED    nets: never meet                     KILLED    ports: drop de-duplication
KILLED    nets: always meet                    KILLED    ports: never meet
KILLED    ANY: absent field is disjoint        KILLED    ANY: both absent is disjoint

The survivor only changes wording: 10.20.0.5 against 10.20.0.0/24,10.0.0.0/8 would print the address twice. It's the address version of Arsh's port nit, which already had a test. I added the matching test and it kills the mutant, so it's 14 of 14 now.

3. Does an absent field (ANY) always make a pair more likely to be reported, never less? Yes. In _field_meet (:229-234), an absent field on either side returns "meets" before any comparison runs, so absence can never make a pair disjoint. The two ANY mutants above flip exactly that, and both are killed. That matches Batfish, where an absent header field means any value. Arsh's ICMP check showed the consequence: a ports-only space includes ICMP.

Where the change went. The new test and the comment are on #426's branch (7518ab1), not this one. Under M-2 rule 1, pushing here would void your approval for a test-only change. #426 is stacked on this PR, so they reach main right after it.

On GitHub this still shows "changes requested". That's Arsh's review of ab9a784, which is void under M-2 because 8a190a3 came after it, and your approval is of 8a190a3. So under our rules this is ready to merge, and #406 next (approved by Ankeet). @ARSH871-bot, if you'd like to look at 8a190a3 yourself first, I'll wait for you.

@shubhamkataria2005

Copy link
Copy Markdown
Collaborator Author

@patelankeet2, I've added you as a reviewer on my open PRs so you can see what's coming in policy and change impact. No pressure to approve all of them. If you only read some, this is the order they land in:

  1. Refuse a policy that forbids what it requires (closes #322) #387 (this one): refuses a policy that forbids what it requires. Samika has approved it. Everything below builds on it.
  2. Change impact reports what it did not look at (closes #403, most of #402) #406, which you approved. Once Refuse a policy that forbids what it requires (closes #322) #387 lands I'll merge main into it; the one conflict and its tested fix are written up there.
  3. Check two policies against each other, not just each against itself (closes #419) #426, Tell me when an edit makes my policy weaker (closes #418) #427, Show which interfaces and subnets no policy rule talks about (closes #421) #429, stacked on Refuse a policy that forbids what it requires (closes #322) #387: two policies against each other, a policy getting weaker between versions, and which interfaces no rule covers. Give a proposed change a size, beside its findings (closes #420) #428, stacked on Change impact reports what it did not look at (closes #403, most of #402) #406, gives a change a size.
  4. Do not pass a policy rule whose filter is applied to no interface (closes #430) #432: policy_compliance used to give a green tick when a rule's filter was applied to no interface. Measured: telnet was delivered while PC-000 said no issues.
  5. Research: how our policy check compares with formal verification (closes #423) #431, Research: our policy format compared with industry formats (closes #424) #433, Research: our severity rules compared with CVSS (closes #425) #434: the three research docs (formal methods, policy formats, CVSS). Docs only.

Nothing here touches ai/.

@patelankeet2 patelankeet2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with real testing, not just the diff. Verified against current main (b69d591), not the state this was last reviewed against.

git merge origin/main (local only)              clean, auto-merged pipeline.py
pytest tests/test_policy_contradictions.py tests/test_change_against_policy.py -q
                                                  59 passed
pytest tests/ -q                                 1946 passed, 13 skipped
ruff check --select E4,E7,E9,F ...               clean

Mutation-tested independently (not reusing the table in this PR's own description -- reproduced it myself, on the two guards that matter most):

  • Removed the raise PolicyError(...) in policy.py::_check_contradictions -- 9 failed, same count your own table reports for this mutation.
  • Removed the if reasons: return None, ... collapse in policy_conflicts.py::overlap(), so an undecidable field would silently fall through to "no contradiction" -- 15 failed. This is the single most safety-relevant line in the module (an undecidable pair reported as clean is F-4 through the policy file, exactly what the module docstring warns about), and it's the most heavily guarded line in the test file. Good.

Both reverted after confirming the failures and the reasons behind them.

Live-reproduced the shipped example, and found one thing worth a correction.

p = policy.load_policy_file('docs/examples/policy.example.json')
len(p.undecidable)  # -> 1, not 2

The PR description says the example "uses both set difference and a negated protocol, so it loads and reports two pairs it could not compare." Measured, it reports one. Traced why: rule 2's negated-protocol query (ipProtocols: ["!tcp"]) is compared against rule 4 only on 10.20.0.5 vs 218.8.104.58 -- different single hosts -- so dstIps alone proves the pair disjoint before the unparseable protocol field ever gets a chance to matter. That's the "field by field" design working exactly as documented: one provably-disjoint field short-circuits the rest, so the negation's undecidability is masked by the IP mismatch rather than skipped incorrectly.

Confirmed the mechanism itself is sound and deliberately tested (test_the_example_does_not_warn_about_a_pair_a_parsed_field_proves_disjoint exists for exactly this), and confirmed in isolation that a negated protocol with matching IPs does come back undecidable as expected:

policy_conflicts.overlap(
    {'srcIps': '10.10.10.0/24', 'dstIps': '218.8.104.58', 'ipProtocols': ['!tcp']},
    {'srcIps': '10.10.10.0/24', 'dstIps': '218.8.104.58', 'ipProtocols': ['udp'], 'dstPorts': '53'},
)
# -> (None, "ipProtocols=['!tcp'] ('!tcp' is not a protocol this check recognises ...)")

So this isn't a code defect -- the logic is correct and the masking is the safe direction (a disjoint field is never wrongly overridden by an unparseable one). It's a one-count overclaim in the PR's own description: the shipped example proves the set-difference path is undecidable, but doesn't actually exercise the negated-protocol path as undecidable, because another field resolves that particular pairing first. Worth fixing the sentence (or editing the example so the negated-protocol rule shares a host with rule 4, if you want the file to demonstrate both), not blocking.

Checked the edges #324/#406 will depend on: _same_scope's three-way answer (True/False/None) is compared node-exact and filter-fuzzy as documented, and Policy.undecidable defaults to [] so every existing caller that builds a Policy() without the new kwarg is unaffected -- confirmed by the full suite staying green with no call-site changes needed anywhere else.

No em-dashes, no AI-tool mentions.

Approving. The one correction above is cosmetic, not a blocker -- the design (three answers, never two; field-by-field short-circuit; undecidable carried forward rather than dropped) is right, and it's now independently verified rather than only self-tested.

@patelankeet2
patelankeet2 merged commit 93e6307 into main Nov 2, 2026
2 checks passed
@patelankeet2
patelankeet2 deleted the feat/322-policy-contradictions branch November 2, 2026 01:35
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.

US-30 — Tell me if my own policy contradicts itself

4 participants