You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromqwed_tax.jurisdictions.us.reciprocity_guardimportReciprocityGuardguard=ReciprocityGuard()
# Any input — the solver is always satresult=guard.verify_reciprocity(
residence_state="NY",
work_state="NJ",
same_state=False,
)
print(result)
# → {"verified": True, ...} for EVERY input
Expected behavior
The guard should verify whether a state tax reciprocity agreement exists between the residence and work states, and whether the claimed withholding treatment is correct per that agreement.
If a reciprocity agreement exists and the claimed treatment matches → verified=True
If no reciprocity agreement exists → verified=False or UNVERIFIABLE
If the claimed treatment contradicts the agreement → verified=False
Actual behavior
ReciprocityGuard returns verified=True for every input. The Z3 solver is always sat because the three rules together form a tautology — there is no input that makes the constraint system unsat.
Additionally, line 64 contains a dead code bug:
# reciprocity_guard.py line 64ifsame_state==Trueorresidence==work:
same_state is a Z3 BoolRef (line ~40-50). In Python, same_state == True constructs a Z3 expression (BoolRef), which is always truthy in an if statement. So the condition effectively reduces to just residence == work — the same_state check is dead code.
Root cause
reciprocity_guard.py lines 57-75:
ifresult==sat:
ifsame_state==Trueorresidence==work:
# Same state — no reciprocity neededreturn {"verified": True, "message": "...same state..."}
else:
# Different states — check reciprocityreturn {"verified": True, "message": "...reciprocity verified..."}
else:
return {"verified": False, "message": "Logic Error: No model found."}
The problem:
same_state == True is a Z3 expression, not a Python bool — always truthy in if
Both branches of the if/else return verified=True — there is no verified=False path except the unreachable "Logic Error" branch
The solver is always sat because the constraints don't actually test for reciprocity agreement existence — they just model the relationship between states
Why this is a bug
The guard provides no real verification gate — every input passes
An AI agent claiming "no withholding needed in NJ for NY resident" gets verified=True regardless of whether a reciprocity agreement actually exists
The dead == True check means same_state parameter is ignored — caller's claim about same-state status is never evaluated
Severity
LOW — because State is enum-constrained upstream (only 8 states in models.py), the practical attack surface is limited. But the guard is structurally non-functional — it's a pass-through masquerading as a verifier.
Fix direction
Fix the dead Z3 comparison: Replace same_state == True with is_true(same_state) from z3 (proper Z3 bool evaluation), or restructure to not pass same_state as a Z3 variable
Add reciprocity agreement data: The guard needs a table of actual reciprocity agreements (e.g., NY-NJ has reciprocity, NY-PA does not) to verify against — currently it models the relationship but not the agreement
Description
QWED Version
0.1.0Python Version
3.11.9
Which engine is affected?
ReciprocityGuard (US state tax withholding)
Input that caused the bug
Expected behavior
The guard should verify whether a state tax reciprocity agreement exists between the residence and work states, and whether the claimed withholding treatment is correct per that agreement.
verified=Trueverified=FalseorUNVERIFIABLEverified=FalseActual behavior
ReciprocityGuardreturnsverified=Truefor every input. The Z3 solver is alwayssatbecause the three rules together form a tautology — there is no input that makes the constraint systemunsat.Additionally, line 64 contains a dead code bug:
same_stateis a Z3BoolRef(line ~40-50). In Python,same_state == Trueconstructs a Z3 expression (BoolRef), which is always truthy in anifstatement. So the condition effectively reduces to justresidence == work— thesame_statecheck is dead code.Root cause
reciprocity_guard.pylines 57-75:The problem:
same_state == Trueis a Z3 expression, not a Python bool — always truthy inifif/elsereturnverified=True— there is noverified=Falsepath except the unreachable "Logic Error" branchsatbecause the constraints don't actually test for reciprocity agreement existence — they just model the relationship between statesWhy this is a bug
verified=Trueregardless of whether a reciprocity agreement actually exists== Truecheck meanssame_stateparameter is ignored — caller's claim about same-state status is never evaluatedSeverity
LOW — because
Stateis enum-constrained upstream (only 8 states inmodels.py), the practical attack surface is limited. But the guard is structurally non-functional — it's a pass-through masquerading as a verifier.Fix direction
same_state == Truewithis_true(same_state)fromz3(proper Z3 bool evaluation), or restructure to not passsame_stateas a Z3 variableverified=False(intersects with [Bug]: Unknown, unsupported, or partially modeled tax rules are treated as verified #16 — unknown rules treated as verified)verified=Falsewhen no reciprocity exists: Theelsebranch should not default toverified=TrueSuggested regression tests
Related issues