TaxPreFlight
TheTaxPreFlight class runs all applicable guards against a transaction intent dictionary. It checks worker classification, economic nexus, trader set-offs, capital gains, corporate loans, startup valuations, international remittances, and expense/TDS compliance in a single call.
Intent fields reference
Theaudit_transaction method inspects the following fields. Only include the fields relevant to your transaction — guards are skipped when their required fields are absent.
| Field | Type | Used by |
|---|---|---|
worker_type | str | ClassificationGuard |
worker_facts | dict | ClassificationGuard |
state | str | NexusGuard |
sales_data | dict (amount, transactions) | NexusGuard |
tax_decision | str | NexusGuard |
loss_head | str | SpeculationGuard |
loss_amount | float | SpeculationGuard |
offset_head | str | SpeculationGuard |
asset_type | str | CapitalGainsGuard |
dates | dict (buy, sell) | CapitalGainsGuard |
claimed_rate | str | CapitalGainsGuard |
lender_type | str | RelatedPartyGuard |
borrower_role | str | RelatedPartyGuard |
interest_rate | float | RelatedPartyGuard |
market_rate | float | RelatedPartyGuard |
investment_round | str | ValuationGuard (when "convertible_note") |
investment_amount | str | ValuationGuard |
cap_price | str | ValuationGuard |
discount | str | ValuationGuard |
next_round_price | str | ValuationGuard |
remittance_amount_usd | float | RemittanceGuard |
purpose | str | RemittanceGuard |
fy_usage | float | RemittanceGuard |
expense_category | str | InputCreditGuard |
amount | float | InputCreditGuard, TDSGuard |
tax_paid | float | InputCreditGuard |
service_type | str | TDSGuard |
ytd_payment | float | TDSGuard |
Capital gains date validation
Theaudit_transaction method validates that both buy and sell dates are present when asset_type and dates are provided in the intent. If either is missing, the transaction is blocked:
TDS advisories
When a TDS deduction is required, it appears in theadvisories field (the transaction is not blocked, but you are informed):
TaxVerifier
TheTaxVerifier class provides jurisdiction-scoped access to guards. Initialize with "US" or "INDIA" to load the appropriate guard set.
| Jurisdiction | Available methods |
|---|---|
US | verify_us_payroll(entry) — runs PayrollGuard gross-to-net check |
INDIA | verify_india_crypto(losses, gains) — runs CryptoTaxGuard set-off check |
INDIA | verify_india_deposit(**kwargs) — runs DepositRateGuard FD rate check |
The US verifier also includes a
TaxPreFlight instance accessible via us_verifier.preflight for intent-based auditing.QWEDTaxMiddleware (Gusto interceptor)
TheQWEDTaxMiddleware intercepts AI-generated payroll payloads before they reach execution APIs like Gusto. It validates the payload schema using Pydantic models and then runs deterministic gross-to-net verification.
Response format
- Verified
- Blocked (hallucination)
- Blocked (invalid payload)
VERIFIED or BLOCKED.Whether the payload is safe to forward to the execution API.
Risk code when blocked:
TAX_LOGIC_HALLUCINATION, INVALID_PAYLOAD, or VERIFIER_ERROR.Human-readable explanation of why the payload was blocked.
The validated payload (JSON-serialized) when execution is permitted.
Standalone guard usage
You can also use specific guards individually found inqwed_tax.jurisdictions and qwed_tax.guards.