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
Tighten /diagnose-issue: input parity in Step 6, verify reporter's claims in Step 1 (#897)
* /diagnose-issue: require full TAXSIM input mapping when using direct Simulation
Lesson from re-examining taxsim #882: forgetting to pass
tax_unit_childcare_expenses in a direct Simulation situation
zeroed the federal CDCC, which shifted tax_liability_if_not_itemizing
by ~$300 and made it look like Microsim and Simulation produced
different answers. They actually agreed — I was comparing apples to
oranges because the inputs weren't identical.
Step 6 now mandates a TAXSIM-to-PE variable cross-walk before running
a direct Simulation, with a table of the easy-to-miss mappings
(childcare → tax_unit_childcare_expenses, proptax → real_estate_taxes,
mortgage → deductible_mortgage_interest, rentpaid → rent).
Debugging checklist updated to match.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* /diagnose-issue Step 1: treat reporter's claims as hypothesis, verify against output.txt
If the reporter cites a specific PE value, confirm it appears in the
bundle's output.txt before building a diagnosis around it. Reporters
sometimes paste values from a different case; without this check
you can construct a wrong narrative around a wrong number.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .claude/commands/diagnose-issue.md
+46-10Lines changed: 46 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,8 @@ Only if all three checks say "still relevant, fresh problem" do you go to Step 1
99
99
- Read the description carefully for diagnostic hints
100
100
- Note any specific numbers mentioned (PE vs TaxAct values)
101
101
102
+
Treat the issue body as a *hypothesis*, not as fact. If the reporter cites a specific PE value, confirm it appears in the bundled `output.txt` before building a diagnosis around it. Reporters sometimes mix up cases. If the cited value isn't there, work from what `output.txt` actually shows.
103
+
102
104
### Step 2: Verify the Input Parameters
103
105
**CRITICAL**: Before deep-diving into code, verify the TAXSIM input parameters are correct!
104
106
@@ -166,27 +168,61 @@ for path in sorted(glob.glob('/tmp/taxsim_$ISSUE/*.pdf')):
166
168
**If the reporter's claim and the PDF differ, the PDF is correct.** Numeric claims in issue bodies are sometimes paraphrased or based on a stale PE run.
167
169
168
170
### Step 6: Deep Dive if Needed
169
-
If the basic test shows incorrect values:
171
+
172
+
If the basic test shows incorrect values, drop into a direct `Simulation` to inspect individual variables.
173
+
174
+
**WARNING — input parity is critical.** If you write a `Simulation` situation that omits one of the TAXSIM inputs, the simulation will compute different intermediates than the emulator and you'll mis-attribute a real bug to a "framework difference." (Real example: omitting `tax_unit_childcare_expenses` zeroed out the federal CDCC in direct `Simulation`, which changed `tax_liability_if_not_itemizing` by ~$300 and made me think Microsim vs Simulation diverged when they actually agreed.)
175
+
176
+
**Mandatory TAXSIM-input → PE-variable cross-walk before running:**
177
+
178
+
| TAXSIM input | PE-US variable | Entity |
179
+
|---|---|---|
180
+
|`pwages`, `swages`|`employment_income`| person |
181
+
|`intrec`|`taxable_interest_income`| person |
182
+
|`pensions`|`taxable_pension_income`| person |
183
+
|`gssi`|`social_security`| person |
184
+
|`proptax`|`real_estate_taxes`| person |
185
+
|`mortgage`|`deductible_mortgage_interest`| person |
186
+
|`rentpaid`|`rent`| person |
187
+
|`childcare`|`tax_unit_childcare_expenses`|**tax_unit** ← easy to miss |
188
+
|`dividends`|`qualified_dividend_income`| person |
189
+
|`stcg`|`short_term_capital_gains`| person |
190
+
|`ltcg`|`long_term_capital_gains`| person |
191
+
192
+
Always look at the bundle's `txpydata.csv` and map **every non-zero column** before writing the situation. The canonical mapping is in `policyengine_taxsim/config/variable_mappings.yaml` if a column isn't in the table above.
170
193
171
194
```python
172
-
# Test with Simulation directly
173
195
from policyengine_us import Simulation
174
196
197
+
# Example — map EVERY non-zero TAXSIM input from txpydata.csv
**Verify input parity before drawing conclusions**: after building the situation, run the emulator (`policyengine_taxsim/cli.py policyengine ...`) on the same row and check that key intermediates (`adjusted_gross_income`, `cdcc`, `ctc`, federal `income_tax`) match. If they don't, you're missing a TAXSIM input mapping — fix that before going further.
225
+
190
226
### Step 7: Research Legal Documentation
191
227
192
228
When PE and TaxAct disagree on a specific credit, deduction, or line item, **fetch the primary sources** — don't rely on web-search summaries. Search summaries are routinely wrong or stale (e.g., a search may claim "State X does not offer credit Y" when the statute clearly establishes it). Use search only to *find* the right primary-source URL, then fetch the document.
@@ -336,7 +372,7 @@ When an issue doesn't reproduce as expected:
336
372
-[ ]**Filing status inference?** (`mstat=1 + depx≥1` → HoH, not single)
337
373
-[ ]**Ages set correctly?** (Many provisions are age-gated)
338
374
-[ ]**Income assigned to right person?** (Joint filers: check both)
339
-
-[ ]**Test with Simulation directly?**(Bypasses taxsim mapping)
375
+
-[ ]**Test with Simulation directly?**When you do, **map every non-zero TAXSIM input** (especially `tax_unit_childcare_expenses` from `childcare`, `real_estate_taxes` from `proptax`, `deductible_mortgage_interest` from `mortgage`) — missing inputs will make Simulation diverge from the emulator and you'll mis-attribute the gap to a framework difference. See Step 6.
340
376
-[ ]**Check existing tests in policyengine-us?** (May show expected behavior)
341
377
-[ ]**PDFs extracted and analyzed?** (Reporter's expected values may be wrong!)
342
378
-[ ]**Compared current PE vs TaxAct?** Every PE value queried directly (no inference from gaps between variables).
Add Step 6 input-parity warning to /diagnose-issue skill: when running direct Simulation, map every non-zero TAXSIM input from txpydata.csv before drawing conclusions. Includes the TAXSIM-to-PE variable cross-walk.
0 commit comments