fix: add us-cpa tax year rules and package metadata

This commit is contained in:
Stefano Fiorini
2026-03-15 02:47:14 -05:00
parent d3fd874330
commit 6c02e0b7c6
9 changed files with 211 additions and 45 deletions
+14
View File
@@ -32,6 +32,13 @@ TOPIC_RULES = [
]
RISK_BY_CONFIDENCE = {
"high": "low",
"medium": "medium",
"low": "high",
}
def _normalize_question(question: str) -> str:
return question.strip().lower()
@@ -98,6 +105,7 @@ class QuestionEngine:
"authorities": authorities,
"conclusion": {"answer": answer, "summary": summary},
"confidence": rule["confidence"],
"riskLevel": RISK_BY_CONFIDENCE[rule["confidence"]],
"followUpQuestions": [],
"primaryLawRequired": False,
}
@@ -115,6 +123,7 @@ class QuestionEngine:
"summary": "This question needs primary-law analysis before a reliable answer can be given.",
},
"confidence": "low",
"riskLevel": "high",
"followUpQuestions": [
"What facts drive the section-level issue?",
"Is there an existing return position or drafted treatment to review?",
@@ -125,6 +134,9 @@ class QuestionEngine:
def render_analysis(analysis: dict[str, Any]) -> str:
lines = [analysis["conclusion"]["summary"]]
lines.append(
f"Confidence: {analysis['confidence']}. Risk: {analysis['riskLevel']}."
)
if analysis["factsUsed"]:
facts = ", ".join(f"{item['field']}={item['value']}" for item in analysis["factsUsed"])
lines.append(f"Facts used: {facts}.")
@@ -160,6 +172,8 @@ def render_memo(analysis: dict[str, Any]) -> str:
"",
"## Analysis",
analysis["conclusion"]["summary"],
f"Confidence: {analysis['confidence']}",
f"Risk level: {analysis['riskLevel']}",
"",
"## Conclusion",
analysis["conclusion"]["answer"],