tdfs4ds.impact_report¶
tdfs4ds.impact_report
¶
Impact report: the output of tdfs4ds.impact.impact_of as a shareable file.
Pure functions: no database, no language model. render_impact_report returns the text (html, md or csv); write_impact_report is the only I/O.
The model is the dict returned by impact_of. Newer optional keys are read when present and ignored when missing: features, feature_edges, severity_counts, schema_version and agent (used, ledger, footprint, narrative, consumer_answers, skipped_reason), efficiency (EXPLAIN comparison), measure (measured comparison on volatile tables) and dependents (the reading by dependent object, with an explanation per affected feature). The agent block is shown only when agent.used is true, and its wording is labelled as unverified.
REVIEW_NOTE_SHORT
module-attribute
¶
REVIEW_NOTE_SHORT = 'These checks are not exhaustive and can report false positives: have an expert review the findings. They support experts, they do not replace them.'
_SEVERITY_ORDER
module-attribute
¶
_COLORS
module-attribute
¶
_COLORS = {'breaks': '#b3261e', 'values_change': '#b26a00', 'may_change': '#7a5c00', 'unaffected': '#2e7d32', 'not_verifiable': '#6b6b6b', 'depends': '#37474f'}
_EFF_COLORS
module-attribute
¶
_EFF_COLORS = {'faster': '#2e7d32', 'same': '#37474f', 'slower': '#b3261e', 'not_comparable': '#6b6b6b'}
_AGENT_NOTE
module-attribute
¶
_AGENT_NOTE = 'Written by the assistant, unverified wording: check every claim against the evidence above. ' + REVIEW_NOTE_SHORT
_CSV_COLUMNS
module-attribute
¶
_CSV_COLUMNS = ['edited_feature', 'edited_process_id', 'affected_object', 'affected_kind', 'affected_feature', 'severity', 'reason', 'consequence', 'evidence', 'explanation', 'type_note', 'cost_reference', 'agent_opinion', 'agent_confidence', 'agent_reason']
_REVIEW_HEADERS
module-attribute
¶
_REVIEW_HEADERS = ['Object', 'Why undecided', 'Code', 'Agent opinion', 'Confidence', 'Agrees with code', 'Reason', 'Evidence']
_REVIEW_NOTE
module-attribute
¶
_REVIEW_NOTE = "Agent opinions, for expert review. The agent reads the findings the code could not decide, or only in part; its opinion sits beside the code's finding and never replaces it."
_PARSE_NOTE
module-attribute
¶
_PARSE_NOTE = 'The parser cannot follow these SQL constructs: have an expert review the objects below; the findings about them may be incomplete.'
_REFERENCE_NOTE
module-attribute
¶
_REFERENCE_NOTE = 'Logged durations cover the whole run of the process (ingestion included): a reference, not the time of the SELECT alone.'
_LEDGER_HEADERS
module-attribute
¶
_CSS
module-attribute
¶
_CSS = '\n.tdimp{--navy:#00233C;--orange:#FF5F00;--ink:#2c3e50;--muted:#5A6B7B;--line:#E3E8EE;--panel:#fff;\n font:15px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;color:var(--ink);\n max-width:1080px;margin:0 auto;padding:8px 4px 60px;background:#f5f7fa}\n.tdimp *{box-sizing:border-box}\n.tdimp h1{margin:.2em 0 .1em;font-size:26px;color:#fff;letter-spacing:-.02em;word-break:break-word}\n.tdimp h2{margin:0 0 6px;font-size:19px;color:var(--navy)}\n.tdimp h3{margin:14px 0 6px;font-size:14px;color:var(--navy)}\n.tdimp p.muted{color:var(--muted);font-size:13.5px;margin:.2em 0 10px}\n.tdimp code{background:#eef1f5;border-radius:5px;padding:1px 6px;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12.5px;color:#c0392b;word-break:break-word}\n.tdimp header.hero{background:linear-gradient(135deg,#00233C,#004069);border-radius:16px;padding:24px 28px;margin-bottom:20px}\n.tdimp .kicker{letter-spacing:.16em;text-transform:uppercase;font-size:11.5px;color:var(--orange);font-weight:700}\n.tdimp .hero-sub{color:#bcd0e0;font-size:14px;margin-top:8px}\n.tdimp .kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:12px;margin:0 0 18px}\n.tdimp .kpi{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:13px 15px}\n.tdimp .kpi-label{font-size:11.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}\n.tdimp .kpi-value{font-size:24px;font-weight:800;margin-top:4px;color:var(--navy)}\n.tdimp section.card{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px 20px;margin:16px 0}\n.tdimp section.ai{border-left:4px solid var(--orange)}\n.tdimp .scroll{overflow-x:auto}\n.tdimp table{width:100%;border-collapse:collapse;font-size:13.5px}\n.tdimp th,.tdimp td{text-align:left;vertical-align:top;padding:7px 9px;border-bottom:1px solid var(--line)}\n.tdimp th{font-size:11.5px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);background:#f8fafc}\n.tdimp td.sev{font-weight:700}\n.tdimp ul,.tdimp ol{margin:6px 0 0 20px;padding:0}\n.tdimp li{margin:4px 0}\n'
html_note
¶
The long note as an escaped, self-styled HTML block (works in light and dark pages).
_s
¶
Text for any value: None is empty, lists are joined, dicts are dumped as JSON.
_severity_counts
¶
severity_counts when given; otherwise derived from the verdict counts (may_change is 0).
_explanations
¶
{(OBJECT, FEATURE): explanation} from the reading by dependent.
_reference
¶
The process's logged runs (efficiency.reference) and the measured seconds beside them
(measure.reference): {row, text, measured, note}, empty when nothing is logged or measured.
_reader_rows
¶
One row per (edited feature, affected object, affected feature). Without features, one row per downstream verdict (the object-level view).
_owner_groups
¶
Objects that may disfunction, grouped by owner. Owner = the reader's owner, else its kind. The fix is the reader's own fix when given, else a generic pointer to the steps.
_review_rows
¶
One row per review: object, why undecided, code verdict, opinion, confidence, agreement, reason, evidence.
_answer_cell
¶
A consumer answer in one table cell: lines joined with ' / ', bold and code kept.
_agent_view
¶
The assistant block as plain rows (no JSON, forward slashes): ledger, footprint, narrative bullets.
render_impact_report
¶
The impact model as 'html' (self-contained, scoped CSS, no script), 'md' or 'csv'.
Every value is escaped for its format. Optional keys that are missing are skipped, never raised on.
write_impact_report
¶
Render and write the report; returns the absolute path. Without path the file goes under tdfs4ds.IMPACT_REPORT_DIR when set, else a temporary directory.