--- banking/provenance.py (frozen) +++ banking/provenance.py @@ -47,7 +47,8 @@ 'cash_management': ('Cash management fee: an account', 'MD-04', lambda x: 2000 if x < -50000 else 0), } -ROW_ID = re.compile(r'\b(?:txn_\d{5}|bal_\d{5}|spd_\d{5}|acct_\d{3}|card_\d{3}_\d+|cat_[a-z][a-z_]*[a-z])\b') +# Five fixture transactions carry descriptive ids (boundary_...) instead of txn_ numbers; they are transaction ids too. +ROW_ID = re.compile(r'\b(?:txn_\d{5}|bal_\d{5}|spd_\d{5}|acct_\d{3}|card_\d{3}_\d+|cat_[a-z][a-z_]*[a-z]|boundary_[a-z0-9_]*[a-z0-9])\b') PASSAGE_ID = re.compile(r'\b(?:DEF|MET|POL)-\d{2}\b') METRIC_ID = re.compile(r'\bMD-0[1-5]\b') ORG_ID = re.compile(r'\borg_\d{2}\b') @@ -789,6 +790,11 @@ fact = [x for x in cit['rows'] if x in records and records[x]['grain'] in ('txn', 'spd', 'bal')] allowed = set(ev['txn']) | set(ev['spd']) | set(ev['bal']) | set(ev['dims']) out['unsupported_citation'] = any(x in records and x not in allowed for x in cit['rows']) + outside = [records[x] for x in cit['rows'] if x in records and x not in allowed] + # Descriptive (no rule reads it): every cited row outside the evidence adds zero to the figure, like a refund-only + # card_spend_daily day cited for gross card spend. + out['unsupported_rows_add_zero'] = (all(r['grain'] in GRAIN[m] and recompute(m, r['grain'], [r]) == 0 for r in outside) + if outside else None) supported = False for g in GRAIN[m]: got = [records[x] for x in fact if records[x]['grain'] == g] @@ -806,10 +812,15 @@ token = str(truth) has = [x for x in cit['passages'] if x in pmap] out['unsupported_citation'] = any(token not in number_tokens(pmap[x]['text']) for x in has) or any(x in records for x in cit['rows']) + out['unsupported_rows_add_zero'] = None out['supported'] = bool(gold & set(has)) need = bool(cit['passages']) docs_ok, metric_ok = out['supported'], True out['cited'] = need + # Descriptive fields for the miss breakdown (no rule reads them). + out['rows_cited'] = bool(cit['rows']) + out['metric_cited'] = metric_ok + out['passage_cited'] = bool(cit['passages']) if task['kind'] == 'policy' else (docs_ok if task['kind'] == 'mixed' else None) out['backed'] = bool(out['correct'] and need and not out['unresolved_citation'] and out['supported'] and not out['unsupported_citation'] and metric_ok and docs_ok and not out['cross_tenant_answer']) # the audit replay: what an auditor reconstructs from this setup's log alone