September 4, 2026

Turning Incident Knowledge into Automated Tests

Bridging the gap

Executive Summary

Data engineering teams currently lose an estimated 10 hours per quarter re-investigating recurring data quality incidents. These incidents get documented in postmortems, but that knowledge rarely makes it back into the codebase as a preventive safeguard. This proposal outlines a solution that uses an LLM to automatically translate postmortem documentation into dbt tests, closing the gap between what a team learns from an incident and what it actually enforces in code.

🎯 The ROI

Reduces incident remediation time by 75% and increases test coverage from incidents by 3x.


1. The Problem: Where Knowledge Goes to Die

Here’s what typically happens after an incident today. Notice where the process quietly breaks down.

flowchart TD
    A[Data Quality Incident Occurs] --> B[Team Investigates & Applies Reactive Fix]
    B --> C[Postmortem Written]
    C --> D[Postmortem Archived in Wiki Page]
    D -.->|"KNOWLEDGE GAP"| E[No Test Created / No Enforcement]
    E --> F[Business Logic Lives Only in Human Memory]
    F -.-> A

    style D fill:#ff4d4f,stroke:#a8071a,stroke-width:2px,color:#fff
    style E fill:#ff4d4f,stroke:#a8071a,stroke-width:2px,color:#fff

Reactive fixes are prioritized over durable prevention. The postmortem — which actually contains the business logic needed to stop recurrence — gets filed away instead of being turned into enforced code. That’s an inefficient loop: the same class of incident can resurface months later, and the team re-investigates from scratch because nothing was ever encoded as a guardrail.


2. The Solution: An 8-Step Automated Workflow

The proposed “To-Be” process closes that loop by inserting an LLM-powered translation step between “we understand what went wrong” and “the system now prevents it from happening again.”

flowchart TD
    S1[1. Incident Occurs & Is Resolved] --> S2[2. Postmortem Written Using Structured Template]
    S2 --> S3[3. Postmortem Stored in Confluence / Notion]
    S3 --> S4[4. LLM Tool Ingests Postmortem + Latest dbt manifest.json / catalog.json]
    S4 --> S5[5. PII Scan & Anonymization Pre-Processing]
    S5 --> S6[6. LLM Generates dbt SQL Test + YAML Config]
    S6 --> S7[7. Human-in-the-Loop Review — Senior Engineer Approves / Modifies / Rejects]
    S7 --> S8[8. Test Merged & Runs on Every dbt Execution]

    style S7 fill:#1890ff,stroke:#0050b3,stroke-width:2px,color:#fff
    style S8 fill:#52c41a,stroke:#237804,stroke-width:2px,color:#fff

The two steps worth calling out: Step 5 (PII scanning) exists specifically to satisfy InfoSec before anything touches an external API, and Step 7 (human-in-the-loop review) is non-negotiable — no LLM-generated test is merged without explicit sign-off from a senior engineer.

Scope for v1:

  • âś… In scope: dbt projects with SQL-based tests, postmortems written in English, Confluence/Notion as the source system
  • ❌ Out of scope: non-dbt data projects, non-English postmortems, automatic PR creation (v1 generates the test; a human still opens the PR)

3. The Artifacts

📊 Tab 1: Stakeholder Matrix
StakeholderCategoryPower / InfluenceInterest LevelKey Concerns & ExpectationsEngagement Strategy
Data / Analytics EngineersPrimary Users (SMEs)MediumHigh”Will this add friction to my workflow? Will the LLM generate wrong tests I have to fix?”Manage Closely — involve them in early testing; integrate seamlessly into their existing IDE/PR workflow
Head of Data / Engineering ManagerProject SponsorHighMedium”What is the ROI? Will this reduce incident resolution time and improve velocity?”Keep Satisfied — monthly metrics on time saved and incidents prevented, framed around business value and LLM API costs
Data Quality / Governance LeadApproverHighHigh”Will this improve our Data Quality SLAs? Are we creating a sustainable, version-controlled safety net?”Manage Closely — align tool output with existing data quality frameworks; use them to champion the structured postmortem template
Downstream Data Consumers (BI Analysts, PMs)BeneficiariesLowHigh”I just want dashboards to stop breaking because of null timestamps or missing data.”Keep Informed — communicate reliability improvements; no build involvement, but they’re the ultimate beneficiaries
InfoSec / IT SecurityGatekeeperHighMedium”Are we sending proprietary schema details, table names, or sample data to an external LLM API?”Keep Satisfied — proactively address via an enterprise-grade, private LLM instance or anonymized schema metadata

Power/Interest Grid

quadrantChart
    title Stakeholder Power / Interest Grid
    x-axis Low Interest --> High Interest
    y-axis Low Power --> High Power
    quadrant-1 Manage Closely
    quadrant-2 Keep Satisfied
    quadrant-3 Monitor
    quadrant-4 Keep Informed
    Data Quality Lead: [0.85, 0.85]
    Engineering Manager: [0.55, 0.85]
    InfoSec: [0.45, 0.85]
    Data Engineers: [0.8, 0.55]
    Downstream Consumers: [0.85, 0.2]
  • High Power, High Interest — Manage Closely: Data Quality Lead, Engineering Manager. These are the decision-makers and champions — engage them weekly.
  • High Power, Low Interest — Keep Satisfied: InfoSec, Head of Data. They can block the project but don’t need the details — give them high-level summaries and compliance assurances.
  • Low Power, High Interest — Keep Informed: Downstream Data Consumers. They love the outcome but can’t build it — send release notes about “improved data reliability.”
  • Low Power, Low Interest — Monitor: External vendors or unrelated teams. Minimal effort required.
🔍 Tab 2: Gap Analysis & Risk Register

Gap Analysis

Gap CategoryDescriptionImpact
Process GapNo standardized, enforced step in the incident resolution workflow requires the creation of a preventive test.Postmortems remain passive documents; recurring incidents keep draining engineering resources.
Technology GapNo existing tooling bridges unstructured text (postmortem analysis) and structured code (dbt SQL/YAML tests).Engineers must manually translate business logic from text into code — time-consuming and easy to skip.
People / Knowledge GapEngineering bandwidth is prioritized for new features over “technical debt” like test writing; knowledge lives in the author’s head or a wiki, not in version control.High risk of knowledge loss if the original engineer leaves; data quality depends on human memory rather than automated guardrails.

Recommendations & Action Plan

Gap to CloseRecommended ActionOwnerPriority
Process GapUpdate the Incident Response SOP to make “Preventive Test Generation” a mandatory exit criterion for P1/P2 incidents.Data Engineering ManagerHigh
Technology GapBuild and deploy the LLM-based prototype that parses wiki pages and outputs dbt test files, piloted with 2–3 engineers.Data Platform TeamHigh
Knowledge GapImplement a standardized Postmortem Template with required fields: Root Cause, Affected dbt Model(s), Expected Data State.Data Quality LeadMedium
Risk MitigationEstablish a Human-in-the-Loop review step — no LLM-generated test merges without senior engineer approval.All Data EngineersHigh

Risk Register

RiskLikelihoodImpactMitigation
LLM hallucination generates incorrect test logicHighHighMandatory human review before merge (Step 7 in To-Be process)
LLM lacks current project contextMediumHighTool ingests the latest manifest.json and catalog.json on each run
Poor-quality postmortem inputMediumMediumEnforce a structured postmortem template with required fields
LLM API costs at scaleLowLowBatch processing; cache repeated patterns
PII leakageLowHighPre-processing step scans and hides PII before it’s sent to the LLM

Success Metrics

  • Adoption: 80% of P1/P2 postmortems result in a newly merged dbt test within 30 days of the incident.
  • Quality: 50% reduction in recurring incidents of the same root cause over 6 months.
  • Efficiency: Average time to create a preventive test drops from ~45 minutes (manual) to ~10 minutes (LLM-assisted + review).
đź’» Tab 3: User Stories & Real-World Validation

User Stories

US-1: As a data engineer, I want the tool to read my postmortem analysis and generate a dbt test automatically, so that I don’t have to manually write the test after fixing the incident.

  • Given a postmortem with a clearly described root cause and affected model
  • When the tool processes the postmortem
  • Then it generates a valid dbt SQL test file and corresponding YAML configuration
  • And the test passes dbt parse without syntax errors

US-2: As a data quality lead, I want to review and approve all LLM-generated tests before they are merged, so that I can prevent false positives from entering the test suite.

  • Given a generated test
  • When the engineer reviews it
  • Then they can approve, modify, or reject the test
  • And rejected tests are logged for LLM improvement feedback

Non-Functional Requirements

  • Performance: The LLM must ingest the postmortem and generate the test file in under 30 seconds.
  • Security/Compliance: Must use an enterprise LLM (e.g., Azure OpenAI) with zero data retention, or run a PII scanner before any text is sent to the API.
  • Usability: Generated YAML and SQL must be properly formatted and indented per standard dbt linting rules.

Real-World Validation

Incident: Orders with status = 'shipped' were missing the shipped_at timestamp, causing logistics confusion.

Generated Test: A custom SQL test flagging any order where status = 'shipped' but shipped_at IS NULL.

-- test: assert_shipped_orders_have_timestamp
SELECT order_id
FROM {{ ref('orders') }}
WHERE status = 'shipped'
  AND shipped_at IS NULL

Impact: This test now runs on every dbt execution, catching the issue before it reaches stakeholders.

Business Value & ROI

CategoryCurrent State (Baseline)Future State (Target)Estimated Impact
Time Savings~4–6 hours per recurring incident (re-investigation + fix)~1 hour (postmortem only, test auto-generated)~75% reduction in incident remediation time
Quality Improvement~30% of postmortems result in preventive tests (estimated)~90% of postmortems result in preventive tests3x increase in test coverage from incidents
Knowledge RetentionPostmortems archived, rarely revisitedKnowledge operationalized as codePermanent retention via version-controlled tests
Stakeholder ConfidenceRecurring incidents erode trustFewer recurring incidentsImproved data quality SLA compliance

4. Conclusion & Next Steps

This tool exists to help data and analytics engineers improve data quality by making it easier to implement prevention tests. It bridges the gap between knowledge that’s already been documented and the implementations or improvements that should follow from it. It isn’t meant to replace human judgment — it’s meant to make sure lessons learned from incidents actually turn into prevention, not just documentation.

As data teams mature, the focus shifts from reactive incident response to proactive quality assurance. Tools that operationalize incident knowledge are a step in that direction.


5. BA Reflection

  • Managing stakeholder expectations around AI hallucination is just as important as the technical implementation. InfoSec and the Data Quality Lead weren’t worried about whether the LLM could generate a test — they were worried about what happens when it generates a wrong one. Designing the Human-in-the-Loop step wasn’t a technical afterthought; it was the thing that got the project approved.
  • A gap analysis is only useful if it separates process, technology, and people. It would have been easy to frame this as “we need better tooling,” but the real blocker was partly organizational: engineering bandwidth is structurally prioritized toward features over test debt. No tool fixes that on its own — the SOP change had to be part of the recommendation.
  • The most convincing artifact wasn’t the diagram, it was the SQL. Talking about “closing the knowledge-to-code gap” is abstract. Showing the actual shipped_at IS NULL test generated from a real incident made the value concrete for engineers and tech leads in a way that no process map could.
Share