From the Meeting to the Notebook: How We Built CERC's Semantic Layer
← Back to Articles

From the Meeting to the Notebook: How We Built CERC's Semantic Layer

TL;DR — Two teams. Same table. Same question. Two different numbers — and both wrong. This happened every week at CERC, across 5 financial domains with billions of transactions per day. The solution wasn’t another dashboard: it was an end-to-end pipeline with +10 AI agents — from recording the meeting with whoever understands the data all the way to a production-ready Databricks notebook, going through domain thesis, business wishes, and semantic clusters. And the next domain is already shipping in 2–3 weeks.


Table of Contents

  1. The Problem That Never Showed Up in Dashboards
  2. Why Diamond and Not Standard Gold?
  3. The Answer: An Agent-Driven Framework
  4. The 3 Major Building Blocks
  5. Architecture & Contracts: Understanding the Invariant
  6. Strategic Patterns That Underpin the Framework
  7. The Agent Ecosystem in Detail
  8. The Final Artifact: What Odin Delivers
  9. The Role of Hooks and Guardrails
  10. Static Spark Analysis — Performance as a First-Class Concern
  11. The Result: 3 Months of Work, 5 Domains, Dozens of Tables
  12. What We Learned About Agent Automation
  13. What Comes Next
  14. For Those Who Want to Replicate This

1. The Problem That Never Showed Up in Dashboards

Two people. Same table. Same question: how many active units do we have today?

Each one gives a different number. Nobody is lying — both ran the “right” query, just with a different filter, in a different time window. And the worst part: neither number was correct.

This wasn’t an isolated case. It happened every week, across any of CERC’s financial domains — with billions of transactions per day running behind each one. Each domain with its own rules, its own flows, and — consequently — its own queries.

The problem wasn’t a lack of data. The problem was that the same data was being consumed in incompatible ways at the same time.

Not because the data was dirty, but because nobody had defined the correct semantics of the question. What is an active unit? Depends on who you ask. What is a consolidated position? Depends on when.

💸 Duplicated processing
   Team A runs query with filter X
   Team B runs the same query with filter X+Y
   Result: two numbers, two processing jobs, zero consensus

📊 Analytical divergence
   "How many active units do we have?"
   Depends: did you consider companies less than 1 year old? Yes? No?
   Done: you and I now have answers that will never match

The problem wasn’t technical. It was that information doesn’t arrive linearly. A business meeting has:

  • A domain expert who knows the rule in prose (non-linear narrative)
  • An analyst who pulls 3 different queries from that conversation
  • An engineer who doesn’t know which of the 3 is the “right” one
  • A system that needs ONE definition, not 3 interpretations

Nobody can linearize that conversation with a diagram. We needed agents that could transform domain conversation into executable specification. Not with empty prompts — with a domain thesis that works as a semantic bridge between what the business says and what the code understands.

The solution was to create an official analytical layer — what everyone calls Gold, and what we decided to call Diamond. But behind every Diamond there is always a thesis.


2. Why Diamond and Not Standard Gold?

In our data lake, the architecture follows the classic layered pattern:

flowchart LR
  BR["BRONZE (raw)"] --> SI["SILVER (clean)"]
  SI -.->|each team its own way| GO["Gold ad hoc (grey zone, pre-Diamond)"]
  SI ==>|explicit contract| DI["DIAMOND (official)"]

    style BR fill:#78350f,stroke:#f59e0b,color:#fff
    style SI fill:#374151,stroke:#9ca3af,color:#fff
    style GO fill:#7f1d1d,stroke:#ef4444,color:#fff,stroke-dasharray: 5 5
    style DI fill:#1e3a5f,stroke:#3b82f6,color:#fff

The distinction matters. Before Diamond, there existed the grey zone above: Gold tables created ad hoc by different teams, with no consistent naming, no documented grain. Each team defined its own “Gold” — and nobody knew where the other one ended. All came from Silver and at every processing run a different view told a different story.

Diamond is different. It is the official layer: semantic, deliberate, with an explicit quality contract — created precisely to fill the space the grey zone left open.

The problem was: how do you build this at scale, for 5 domains with high regulatory complexity, without turning it into a 2-year project?


What surprised us: the answer wasn’t “another dashboard” or “better documentation” or “more manual validation.” It was automating the transformation of conversation into thesis into code — with agents that understand natural language and a domain thesis as a semantic bridge.


3. The Answer: An Agent-Driven Framework

To keep this from taking years, we built a framework with 3 sequential blocks — each delivering a concrete artifact that feeds the next.

The framework runs entirely in GitHub Copilot Agents inside VS Code, with agents, hooks, skills, and instructions that take you from .vtt recordings to production-ready Databricks Notebooks. The entry point is always the Black Belt — a hub agent that classifies the engineer’s request and delegates to the right specialist agent.

The 3 blocks are:


4. The 3 Major Building Blocks

The general map, before diving into each block:

flowchart LR
    subgraph B1["4.1 — From Recording to Thesis"]
        direction LR
        b1a[".vtt"] --> b1b["domain thesis"]
    end
    subgraph B2["4.2 — From Thesis to Wishes"]
        direction LR
        b2a["raw wishes"] --> b2b["semantic cluster"]
    end
    subgraph B3["4.3 — From Wish to Artifact"]
        direction LR
        b3a["table_spec.yaml"] --> b3b["notebook.py"]
    end
    B1 --> B2 --> B3

    style B1 fill:#14532d,stroke:#22c55e,color:#bbf7d0
    style B2 fill:#2e1065,stroke:#a78bfa,color:#ddd6fe
    style B3 fill:#1e3a5f,stroke:#3b82f6,color:#bfdbfe

4.1 Block 1 — From Recording to Thesis

4.1.1 “VTT Bronze”

The starting point is the .vtt file — the raw transcript generated by Microsoft Teams. It looks like this:

WEBVTT

00:02:09.561 --> 00:02:13.996
<v Person1>You can have two teams wanting the same
information, running the same query,</v>

00:02:10.054 --> 00:02:13.996
<v Person2>Right</v>

00:02:15.154 --> 00:02:17.682
<v Person1>at two different moments,
spending twice on the processing.</v>

Impossible to use directly. The agent needs something linearized, organized, with the noise removed.

4.1.2 “VTT Silver”

The _parsed.md is what cleans and removes impurities from the text. Stop words, affirmations, sighs — none of that matters to the context. Only what is actually said. Short phrases or ones lasting only a few seconds don’t help.

A Python script deterministically strips linguistic noise that adds no value to the process.

It looks like this:

WEBVTT

00:02:09.561 --> 00:02:17.682
<v Person1>You can have two teams wanting the same
information, running the same query at two different moments,
spending twice on the processing.</v>

4.1.3 “VTT Gold”

The _parsed_summary.md is what feeds the rest of the pipeline. A real output example:

## How team X currently uses data from domain Y

The team performs 3–4 manual joins every time they need a
consolidated view: event history + supplementary records + consents.

**Main pain**: every analysis starts from scratch. There is no "magic"
table that delivers the final view ready to use.

**Implicit wish**: table with granularity by the main entity,
containing incoming flow, outgoing flow, requesting participant and settlement status.

4.1.4 Pipeline

The first pipeline transforms this into 3 layers:

.vtt (bronze)
  └── _parsed.md (silver)
        consolidated speech groups
        stopwords removed
        "uh-huh", "yeah", "right" eliminated
        └── _parsed_summary.md (gold)
              business insights extracted
              decisions captured
              pains identified
              implicit and explicit wishes flagged

For the 5 domains we worked on, we had dozens of meetings. Each an hour long. Revisiting them constantly would be impossible. The VTT pipeline solves this: we process once, and the summary layer becomes the source of truth for subsequent steps (with review by everyone who attended the meeting to avoid hallucinations).

Agents involved in this step:

flowchart LR
    VTT(["📼 .vtt"])
    ORCH["vtt-orchestrator"]
    SPEC["vtt-spec-transcript"]
    OUT(["📄 _parsed_summary.md"])

    VTT --> ORCH
    ORCH --> SPEC
    SPEC --> OUT

    style VTT fill:#166534,stroke:#22c55e,color:#fff
    style ORCH fill:#166534,stroke:#22c55e,color:#fff
    style SPEC fill:#166534,stroke:#22c55e,color:#fff
    style OUT fill:#166534,stroke:#22c55e,color:#fff

The vtt-orchestrator detects the type of meeting (technical deep-dive? business discovery? hands-on with data?) and routes to the right agent. The vtt-spec-transcript processes and extracts the structured summary.


4.2 Block 2 — From Thesis to Wishes

With the _parsed_summary.md in hand, the next problem is: how do you organize dozens of meetings from multiple domains so that Odin (the agent that generates the tables) can actually work with it?

Each meeting tells a piece of the story. One team is focused on consent flows. Another wants the relationship between market participants. A third wants to track settlement. All talking about the same product, but from completely different angles.

The underlying problem is always the same: information doesn’t arrive linearly. The solution was to create a thesis per domain — a document that linearizes all that dispersed knowledge into a coherent narrative.

docs/knowledge_base/cerc_systems/{domain}/wiki/thesis/
├── 01_intro.md
├── 02_glossary.md
├── 03_background.md
├── 04_participants.md
├── 05_business_rules.md
├── 06_legal_and_regulatory.md
├── 07_flow.md
├── 08_billing.md
├── 09_consumers.md
├── 10_risks_and_limitations.md
├── appendix_01_open_questions.md
├── appendix_02_pains.md
└── appendix_03_operational_queries.md

What Goes into Each Thesis Chapter

The thesis has 13 chapters — each answering a specific question:

ChapterCentral QuestionContentWho Validates
01_intro.mdWhat is this domain?Name, abbreviation, purpose, main stakeholders, historical contextPO, Domain Lead
02_glossary.mdWhat does each term mean?Dictionary of 50–200 technical and business terms specific to the domain (e.g. “consent”, “settlement”, “entity”, etc.)Technical expert + PO
03_background.mdWhy does this domain exist?History, evolution, regulations that created the need, macro context (market, competition, technology)Domain Lead
04_participants.mdWho is who?Persona mapping: role, responsibility, information used, pain feltDomain Lead + Operations
05_business_rules.mdHow does it work?50–300 structured business rules (conditions, logic, exceptions, cited directly from meetings)PO + PHD Agent
06_legal_and_regulatory.mdWhat laws/regulations apply?Compliance requirements, SLAs, processing windows, data retention, auditingLegal + Operations
07_flow.mdWhat is the sequence?Temporal diagram: events, states, transitions, dependencies between steps (e.g. arrival order, precedence)Technical expert
08_billing.mdWho pays and how?Billing models, margin, processing costs, volume drivers (e.g. per transaction? per entity? per month?)Finance + PO
09_consumers.mdWho uses it and why?Mapping of data consumers: which team, which query pattern, which specific pain we resolveClient teams
10_risks_and_limitations.mdWhat can break?Known limits, operational risks, documented edge cases, scale limitsEngineering + PO
appendix_01_open_questions.mdWhat don’t we know?Open questions, hypotheses to validate, knowledge gaps not yet resolvedPHD Agent
appendix_02_pains.mdWhat are the pains?Structured pain list: processing overhead (duplication), data quality, latency, costs, compliance riskCompiled from meetings
appendix_03_operational_queries.mdWhat queries exist today?Real SQL query examples that teams run manually, with context for why they existOperations

Each chapter is written in markdown with concrete examples (not generic templates). The PHD agent writes using meetings as source; the PHD Supervisor validates that the thesis makes sense; domain teams review for accuracy.

The thesis is called a thesis for a reason: it can be wrong and it can be refuted.

This comes from academic rigor. In a doctoral program, you write a thesis. The committee examines it. They refute it. You defend it or acknowledge the error. Here it’s the same thing.

Refutation is a friend. Finding the error in the thesis costs 1 hour. Finding it in production costs weeks.

Real example: in one of the domains, we wrote that an event arrived at a certain time (thesis). Validation with the teams showed the time was wrong (refutation). The thesis was updated. This cycle of hypothesis → validation → refinement is explicit in the process. Without the documented thesis, that error would have been discovered 6 months later in production code, causing massive rework. With the thesis, it was caught and corrected on the spot.

Nobody needs to go back to a 2-hour meeting to find out “oh, actually the time is different.” It’s there. It’s been refuted. It’s documented why it was refuted. Next.


The Thesis as a Permanent Foundation

Here is the uncomfortable truth: the Databricks notebook has a lifecycle tied to the source systems. When a SILVER table’s schema changes, when a business rule is revised, when a new field appears — the code follows that cadence.

The thesis also evolves — but at a different pace. It captures the why of the domain’s existence — its rules, its participants, its flows — and that reasoning tends to be more stable than any specific implementation. When the system changes, the notebook changes with it; when the business premise changes, the thesis is revised — and the notebook follows the thesis, not the other way around.

When an engineer joins the team, they don’t need to attend 20 meetings. They read the thesis in 3–4 hours and are up to speed. Nobody at the company had done curation like this before — documenting every piece of how the system works, validated by all areas. That is rare. That is valuable.

The central asset — the most powerful artifact of this process is not the Databricks notebook. It is the thesis. It concentrates product knowledge that normally lives in the heads of 3–4 people who attended the right meetings. It is versioned, coexists with code (each business rule has a corresponding chapter in the thesis), and it is refutable — it can be wrong, it can be improved. And in the age of agents, it is worth even more: it is the thesis that gives context to the agent. Without a thesis, the agent can generate artifacts — but cannot reason about the why behind each rule.


The PHD agent (who writes theses, after all, is a doctor) builds and maintains these chapters. The PHD Supervisor reviews across 17 dimensions and reports quality findings without editing directly — a clear separation of responsibilities.

In parallel, the djinn extracts the wishes.

A wish is the minimum unit of business desire. It is what a person expressed, explicitly or implicitly, that they needed a table for.

A simplified wish example (no internal data):

wish_id: "0001"
title: Consolidated Event Table for Domain X
description: >
  A "magic" table that consolidates an event view oriented to the domain's primary grain.
origin: explicit
ambition: incremental
tipo: table
grain_hint: >
  1 row = 1 entity with a reconciled event, tracked on 1 reference date
cadence_hint: daily
warehouse_hint: fact_transactional
consumers:
  - analytics_team
  - operations_team
  - product_team
business_function: entity_lifecycle
need: |-
  Create a Diamond table with granularity by primary entity, containing:
   - Received event (composite key from relevant business fields)
   - Type of relationship between participants
   - Consolidated lifecycle status
   - Temporal traceability
expected_value: |-
  - Eliminate 3–4 manual joins repeated per analysis
  - Allow group by and simple filtering without redoing complex logic
evidence: >
  Discovery meeting with consuming team — _parsed_summary.md

In the first run on a specific domain/system, 150 wishes were detected. That was too many. Lots of duplicates, lots of variations on the same problem.

And here it became a critical inflection point in the framework — for two reasons worth separating: what happens when you over-automate, and how to resolve the wish surplus without losing rigor.


The Mistake We Didn’t Make Twice: Full Automation

The temptation was clear: throw the 150 wishes at the agent and ask it to generate the tables.

We tried. It failed miserably.

The reasons were multiple:

  • The thesis, as rich as it was, had unvalidated hypotheses
  • The Unity Catalog had data that contradicted what the meetings said
  • Many wishes were in fact the same need, expressed by different teams in different vocabularies
  • The agent couldn’t discern which PKs made sense without human confirmation

The lesson was: the right agent for a non-deterministic task is not a substitute for human judgment. It is an amplifier of it.

We changed the approach:

❌ Before: 150 wishes → agent → 150 tables (automatic, catastrophic)

✅ After: 150 wishes → human curation → 65 wishes → deterministic script → N tables → human-in-the-loop → decision

Step 1: Human Curation (150 → 65 wishes)

The 150 raw wishes had a critical problem: 5 teams, same question, 5 different vocabularies, 5 interpretations.

Real example:

  • Team A: “Consolidated event table by date”
  • Team B: “Flow view by entity”
  • Team C: “Participant history”
  • All wanted the same thing, but nobody knew it.

This required heavy human curation:

  • Read each wish in context (meeting, domain, persona)
  • Identify semantic duplicates (same thing, different vocabularies)
  • Eliminate ambiguity (what does “consolidated” mean to you? And to them?)
  • Consolidate into a single clear definition

Result: 150 → 65 consolidated wishes. Each with a univocal definition, no duplicates, no interpretation conflicts.

Step 2: Deterministic Clustering (65 → N tables)

With the 65 clean wishes, the next step was grouping into logical tables. This is where the script comes in.

We tried letting the agent do it. It didn’t work:

  • Agent can’t guarantee reproducibility (run it twice, get two different results)
  • Can’t control semantic threshold (which similarity score becomes a cluster?)
  • Can’t explain why it grouped X with Y

The solution: a deterministic cluster builder (script + explicit rules).

The script:

  1. Vectorizes each wish using semantic embeddings
  2. Calculates pairwise distance with an explicit threshold (e.g. 0.35 in cosine space)
  3. Groups into clusters using a hierarchical algorithm
  4. Output: N consolidated clusters, each a candidate for 1 table

Result: 65 wishes → ~8–15 cluster candidates (otherwise we’d have 65 tables — absurd).

Step 3: Final Human-in-the-Loop (clusters → approved tables)

The script generated the clusters, but critical human decisions remain:

  • Grain tradeoff: do you want 1 wide table (many columns, fine grain) or 3 narrow tables (coarse grain, more power)?
  • Volume vs complexity: merging 3 clusters saves compute, but complicates queries?
  • Consumer fit: which configuration best serves the consuming teams?

Example:

Cluster A: 4 wishes about events
Cluster B: 3 wishes about participants
Cluster C: 2 wishes about flow

Option 1: Keep 3 tables (fine grain, each team sees only their columns)
Option 2: Merge into 1 wide table (cross grain, more power, more complexity)

Decision: depends on the architecture you want in Diamond.
→ Human-in-the-loop decides which path.
# Simplified example of the internal cluster builder
from sentence_transformers import SentenceTransformer
import numpy as np
from sklearn.cluster import AgglomerativeClustering

def build_clusters(wishes: list[dict], weights: dict) -> list[list[str]]:
    """
    Clusters wishes using semantic embeddings with per-field weights.

    Weights empirically calibrated for the Diamond domain:
    - title: 0.3      (naming can diverge significantly between teams)
    - need: 0.4       (the actual need is the strongest signal)
    - grain_hint: 0.3 (different grain = different table, non-negotiable)
    """
    model = SentenceTransformer("sentence-transformers/paraphrase-multilingual-mpnet-base-v2")

    embeddings = []
    for wish in wishes:
        combined = (
            weights["title"] * model.encode(wish["title"]) +
            weights["need"] * model.encode(wish["need"]) +
            weights["grain_hint"] * model.encode(wish.get("grain_hint", ""))
        )
        embeddings.append(combined / np.linalg.norm(combined))

    clustering = AgglomerativeClustering(
        n_clusters=None,
        distance_threshold=0.35,  # calibrated for financial domain
        metric="cosine",
        linkage="complete"
    )
    labels = clustering.fit_predict(np.array(embeddings))

    clusters = {}
    for wish, label in zip(wishes, labels):
        clusters.setdefault(label, []).append(wish["wish_id"])

    return list(clusters.values())

The script is deterministic. Given the same input, it always produces the same output. The agent then receives the clusters and reviews them — it doesn’t decide the clusters, it interprets them.

This distinction is fundamental to what we call “agentic engineering”: knowing where the agent adds value (semantic interpretation, artifact generation, reasoning about business rules) and where a deterministic script is more reliable (clustering, schema validation, DDL generation).


4.3 Block 3 — From Wish to Databricks Artifact

With the wishes clustered and reviewed, Odin steps in.

Odin is the most complex agent in the pipeline. It:

  1. Reads the wishes from a cluster and proposes an intermediate table_spec.yaml
  2. Analyzes grain, sources, joins, business rules, and PKs
  3. Generates the config.yaml with the table metadata and Databricks workflow configuration
  4. Generates the notebook.py with the full PySpark transformation
  5. Runs the coverage validation — are all wishes in the cluster answered?

Odin is equipped with various skills: from Databricks SQL queries to validate data, to a static PySpark notebook analyzer to enforce best practices before each generation.

It is like the great builder and sage of the entire framework. Without the previous steps, Odin cannot sustain itself — it doesn’t have enough context to create artifacts that make sense.

4.4 Full Flowchart

The complete flow looks like this:

flowchart TD
    A(["📼 .vtt"])

    subgraph VTT_PIPELINE["Stage 1 — VTT"]
        V1["vtt-orchestrator"] --> V2(["_parsed_summary.md"])
    end

    subgraph KNOWLEDGE_PIPELINE["Stage 2 — Knowledge"]
        K1["phd"] --> K2(["updated thesis"])
        K3["djinn"] --> K4(["wish_NNNN.yaml"])
        K4 --> K5["spoiler-batch"]
        K5 --> K6(["wish with resolved SQL"])
    end

    subgraph ODIN_PIPELINE["Stage 3 — Diamond"]
        O1["🧠 Odin"] --> O2(["table_spec.yaml"])
        O1 --> O3(["config.yaml"])
        O1 --> O4(["notebook.py"])
    end

    CONF(["Confluence / Xray / PDFs"])
    A --> V1
    V2 --> K1
    V2 --> K3
    CONF --> K1
    K2 --> O1
    K6 --> O1

    style A fill:#166534,stroke:#22c55e,color:#fff
    style V1 fill:#166534,stroke:#22c55e,color:#fff
    style V2 fill:#166534,stroke:#22c55e,color:#fff
    style K1 fill:#5b21b6,stroke:#a78bfa,color:#fff
    style K2 fill:#5b21b6,stroke:#a78bfa,color:#fff
    style K3 fill:#1e40af,stroke:#3b82f6,color:#fff
    style K4 fill:#1e40af,stroke:#3b82f6,color:#fff
    style K5 fill:#1e40af,stroke:#3b82f6,color:#fff
    style K6 fill:#1e40af,stroke:#3b82f6,color:#fff
    style O1 fill:#92400e,stroke:#f59e0b,color:#fff
    style O2 fill:#92400e,stroke:#f59e0b,color:#fff
    style O3 fill:#92400e,stroke:#f59e0b,color:#fff
    style O4 fill:#92400e,stroke:#f59e0b,color:#fff
    style CONF fill:#374151,stroke:#9ca3af,color:#fff
    style VTT_PIPELINE fill:#14532d,stroke:#22c55e,color:#bbf7d0
    style KNOWLEDGE_PIPELINE fill:#2e1065,stroke:#a78bfa,color:#ddd6fe
    style ODIN_PIPELINE fill:#1e3a5f,stroke:#3b82f6,color:#bfdbfe

5. Architecture & Contracts: Understanding the Invariant

Before looking at each agent in detail, it is important to understand why this framework works — and what makes it impossible to replicate without the two levers that follow.

5.1 The Core Principle: Human-in-the-Loop

The semantic layer needs robust context to function. That context doesn’t come from tables — it comes from people.

AI agents are excellent at consolidating dispersed information (meetings, PDFs, Confluence, data warehouse investigations) into structured knowledge. But they cannot validate semantics independently, because:

  1. Business rules change — what was true in January may be false in March without warning
  2. Definitions are ambiguous — “active” can mean 5 different things depending on the domain
  3. Data in Databricks Unity Catalog frequently contradicts what people say — nobody is lying, but there is divergence between the map (UC) and the territory (operational reality)

Therefore, agents amplify human judgment, they don’t replace it. Without human-in-the-loop at each critical stage, you generate garbage faster.

The design reflects this explicitly:

✅ Stage 1 — VTT (recordings to summaries): 95% deterministic, 5% validation
✅ Stage 2 — Knowledge (evidence to thesis + wishes): 60% agent, 40% human
✅ Stage 3 — Diamond (wishes to tables): 70% agent, 30% PK + coverage validation

This proportion varies because each stage has different reliability. Stage 1 is linguistic, practically deterministic. Stage 2 is where the most errors occur — thesis hypotheses that don’t match real UC data.

5.2 Input/Output Contracts

Each stage is independent, with a clear contract:

StageInputOutputTimeHuman EffortSuccess Rate
1 — VTTRaw .vtt (recordings)Structured _parsed_summary.md2–4h / 1h of recordingMinimal (1 engineer validates)~95% (failures = bad audio)
2 — Knowledge_parsed_summary.md + evidenceDomain thesis + 20–100 wishes3–5 daysHigh (2–3 people writing thesis, 1–2 iterations)~70% first time (3–4 cycles to convergence)
3 — Diamond50–80 clustered wishestable_spec.yaml + config.yaml + notebook.py4–6h / tableMedium (PK validation, wish coverage, performance)~85% first time (blockers = wrong sources, incomplete business rules)

What “success” means at each stage:

  • Stage 1: Summary is readable, main topics capture the meeting, no hallucinations
  • Stage 2: Thesis reflected in UC, wishes are not duplicated, hypotheses are not contradicted by real data
  • Stage 3: PKs validate without error, 100% of wishes are answered in the table, performance < 5min at volume

5.3 Real Success Rates and Rework

These numbers come from 5 domains completed:

Stage 1 — VTT:

  • Success rate: ~95%
  • Rework: ~10% of summaries (incomplete, redo 1–2x)
  • Failure cause: bad audio, multiple languages, extreme background noise

Stage 2 — Knowledge:

  • First-time success rate: ~70%
  • Rework: ~3–4 cycles to convergence (thesis is refined iteratively)
  • Failure cause: thesis hypothesis contradicted by real UC data, ambiguous definitions that only the operations team can resolve
  • Real example: the thesis said event X always arrived before event Y. Data showed inversion in 2% of cases — thesis was updated

Stage 3 — Diamond:

  • First-time success rate: ~65%
  • Rework: ~4–5 cycles (join bugs, incorrect PK, uncaptured business rule)
  • Failure cause: source table doesn’t exist, wish’s business rule is not documented in the thesis, performance not validated before merge, incorrect join validation, omission of relevant information
  • Debug time: ~8h / table to resolve PK or logic blockers

Conversely, without human-in-the-loop:

  • Error rate climbs to ~40–50% (tables nobody uses because they didn’t answer the right question)
  • Debug time rises to 8–16h / table (you discover the error in production)

6. Strategic Patterns That Underpin the Framework

One last layer before the agents: the structural decisions that sustain the quality and traceability of the entire system.

These were not accidental decisions. Each one solves a specific problem that appeared when the framework started to scale.

Strategic PatternWhy?Strategic Benefit
Two-artifact contract per table (config + notebook)Separating the technical contract from the implementation avoids confusion between intent, metadata, and executable logic.Architectural clarity: each piece of information has its right place and maintenance becomes more predictable.
Single owner of transformation per tableLogic spread across different files and flows creates responsibility ambiguity.Technical accountability: when something diverges, there is a single point to correct and audit.
Grain-first with explicit artifact type decision (fact, dimension, OBT, MV)The largest source of analytical inconsistency is implicit or poorly-defined granularity.Stable semantic contract: everyone understands what a row represents, without subjective interpretation.
SCD as contextual decision (not automatic default)Not every dimension needs full history; applying SCD2 everywhere increases cost and complexity without real gain.Balance between governance and efficiency: history when necessary, simplicity when sufficient.
End-to-end traceability (wish → spec → implementation → thesis/rules)Without explicit demand origin, production accumulates technical debt that is hard to justify.Strong governance: every production artifact proves why it exists and which business decision it serves.
Hardblock guardrails (hooks + CI)At scale, manual review cannot prevent structural drift with consistency.Systematic quality: critical problems are blocked before reaching the productive catalog.
Canonical runtime with deterministic destination derivationHardcoding environment, catalog, and path generates silent drift between executions.Operational reproducibility: the same contract behaves consistently across any environment.
DataFrame as standard, SQL as justified exceptionAn opaque or overly declarative pipeline makes reviewing and evolving rules difficult.Readability and maintainability: engineering and business can review the transformation with confidence.
Explicit ownership + human-in-the-loopPremises change over time; automation without human validation propagates errors rapidly.Real accountability: critical decisions pass through conscious validation before going to production.

How These Patterns Fit Together

  • Artifact contract + single owner + hardblocks ensure reliable execution at scale.
  • Grain-first + contextual SCD + traceability ensure reliable semantics for consumption.
  • Deterministic runtime + human-in-the-loop ensure safe evolution without losing governance.

Strategic Result

These patterns transform the framework from a table generator into an official semantic layer: the difference between a table that’s hard to trust and a data asset with a contract, an owner, and a decision trail.

7. The Agent Ecosystem in Detail

The final design has 12 agents with clearly delimited responsibilities. Before the relationship diagram, a summary of who does what:

AgentGroupRole in One Sentence
💎🥋 Black BeltHubClassifies the engineer’s request and delegates to the right agent
djinnDiamondExtracts wishes (business desires) from theses and meetings
spoiler-batchDiamondResolves the SQL for each wish with evidence from Xray
OdinDiamondGenerates table_spec.yaml, config.yaml, and notebook.py
vtt-orchestratorVTTDetects the meeting type and routes to the right agent
vtt-spec-transcriptVTTProcesses the .vtt and extracts the _parsed_summary.md
phdKnowledgeWrites and maintains the domain thesis chapters
phd_supervisorKnowledgeReviews the thesis across 17 dimensions, without editing directly
xrayXrayInvestigates the Unity Catalog: real grain, volume, PII
business-rulesXrayExtracts business rules from what Xray found
🌙 MoonshotChallengerQuestions overly timid modeling decisions
🧒 ELI5ChallengerExplains any thesis concept in simple language

The diagram below shows how they connect:

flowchart LR
    BB(["💎 Black Belt"])

    subgraph DIAMOND["Diamond"]
        DJ["djinn"]
        SB["spoiler-batch"]
        OD["Odin"]
    end

    subgraph VTT["VTT"]
        VO["vtt-orchestrator"]
        VS["vtt-spec-transcript"]
    end

    subgraph KNOWLEDGE["Knowledge"]
        PHD["phd"]
        PHDS["phd_supervisor"]
    end

    subgraph XRAY["Xray"]
        XR["xray"]
        BR["business-rules"]
    end

    MS["🌙 moonshot"]
    E5["🧒 eli5"]

    BB -->|extracts wishes| DJ
    BB -->|fills pending spoilers| SB
    BB -->|generates Diamond table| OD
    BB -->|transcribes| VO
    BB -->|writes thesis| PHD
    BB -->|investigates UC| XR
    BB -->|challenged by| MS
    BB -->|explains domain| E5

    DJ -->|UC offline - pending| SB
    XR -->|xray read by| SB
    BB -->|table_spec + config + notebook| OD
    VO -->|transcribes| VS
    PHD -->|supervised by| PHDS
    XR -->|extracts rules| BR

    classDef dmnd fill:#1e40af,stroke:#3b82f6,color:#fff
    classDef vttCls fill:#166534,stroke:#22c55e,color:#fff
    classDef knowledgeCls fill:#5b21b6,stroke:#a78bfa,color:#fff
    classDef xrayCls fill:#92400e,stroke:#f59e0b,color:#fff
    classDef moonCls fill:#78350f,stroke:#fbbf24,color:#fff
    classDef hub fill:#1d4ed8,stroke:#60a5fa,color:#fff,stroke-width:3px

    class BB hub
    class OD,DJ,SB dmnd
    class VO,VS vttCls
    class PHD,PHDS knowledgeCls
    class XR,BR xrayCls
    class MS,E5 moonCls

    style DIAMOND fill:#1e3a5f,stroke:#3b82f6,color:#bfdbfe
    style VTT fill:#14532d,stroke:#22c55e,color:#bbf7d0
    style KNOWLEDGE fill:#2e1065,stroke:#a78bfa,color:#ddd6fe
    style XRAY fill:#451a03,stroke:#f59e0b,color:#fef3c7

The Black Belt — The Single Entry Point

The Black Belt is the only agent the engineer calls directly. It classifies the intent and delegates:

@Diamond Black Belt, I need a new vintage table for domain X
                    ↓
        Classifies as: "new table"
                    ↓
        💎🥋🤖 using agent Odin

The Black Belt does not edit files directly. All writing goes through the specialist agent. This ensures each agent has a clear scope and that there is no “uncontrolled creativity” from a single agent with too much power.

The Moonshot — The Strategic Challenger

One of the most interesting agents is Moonshot. It is invoked when the Black Belt detects that the team may be thinking too small.

Real example: we were modeling a bidirectional flow fact as a single table, with a direction field. Moonshot was invoked and pointed out: with a mandatory WHERE direction = 'receiving' filter in every analysis, the team will make more mistakes, not fewer. It proposed splitting into two specialized tables by flow direction.

We split into two. It was the right call.

In the main scope of one of the domains, the consolidated result landed in tables like:

databricks/notebooks/{domain}/
├── tb_fct_main_entity/
├── tb_fct_inbound_flow/       ← came from the split Moonshot proposed
├── tb_fct_outbound_flow/      ← same
├── tb_obt_consolidated_view/
├── tb_obt_consents/
└── tb_dim_contract/

The set varies by domain and evolution stage. New products generate new table patterns within the same structure.

The Xray — Investigation in Unity Catalog

Before generating any table, Xray investigates the Unity Catalog: which tables exist in the SILVER layer? What is the real grain? How many rows? Which columns have PII?

This feeds the wishes with concrete SQL — the sql_spoiler field of each wish — so that Odin doesn’t have to infer joins from scratch. It starts from real evidence.

The ELI5 — Democratizing the Thesis

One of the most-used agents day to day: ELI5 (Explain Like I’m 5). It goes into the domain thesis and explains any concept in plain language.

💬 Engineer: what is [domain concept]?
🧒 ELI5: When you register an entity of this type, the rules that apply are...

The thesis became a living onboarding resource. Every new engineer on the team can get up to speed on the domain in hours, not weeks.

The CERC Council — Validation by Personas

An experiment that emerged at the end of the project: the CERC Council. The idea is to create personas based on VTTs from meetings with different teams.

# personas generated from meeting VTTs
personas = {
    "executive": {"role": "Executive", "focus": "ROI and cost efficiency"},
    "analyst": {"role": "Data Analyst", "context": vtt_analytics_team},
    "operations": {"role": "Operations Analyst", "context": vtt_operations_team},
    "engineer": {"role": "Data Engineer", "context": vtt_engineering_team}
}

Each persona evaluates the candidate table and “discusses” with the others. The result is a multi-perspective coverage report — essentially the equivalent of running a review with real stakeholders, but asynchronously and at any time.


8. The Final Artifact: What Odin Delivers

We’ve seen that Odin closes Block 3 by generating production-ready Databricks artifacts. In practice, for each table, it delivers 3 files:

1. config.yaml — The Table Contract

table:
  system: {domain}
  catalog: diamond
  schema: {domain}
  name: tb_fct_{main_entity}
  type: fct
  warehouse_hint: fact_transactional
  merge_keys:
    - ReferenceDate
    - PrimaryKey1
    - PrimaryKey2
    - PrimaryKey3
  description: >
    Daily fact of the main entity at the grain defined by the composite PK.
    Consolidates values, lifecycle stage, and business relationships.
  ownership:
    consumers:
      - analytics_team
      - operations_team
      - product_team

workflow:
  name: dmnd-{domain}-tb-fct-{entity}
  compute:
    schedule_cron_expression: 0 10 8 * * ?
    spark_version: <runtime_version>
    runtime_engine: PHOTON
    node_type_id: <node_profile>
    fixed_workers: <n_workers>
    spark_conf:
      spark.sql.adaptive.enabled: "true"
      spark.sql.adaptive.skewJoin.enabled: "true"
output_schema:
  - name: ReferenceDate
    type: DATE
    is_primary_key: true
    nullable: false
    description: "Table reference date."
    tags: ["PK"]
  - name: InvoiceKey
    type: STRING
    is_primary_key: true
    nullable: false
    description: "Unique 44-digit NF-e access key. PK (part 1/3) and merge key. Join with parent NF-e header table."
    tags: ["PK"]
  - name: IssuerCNPJ
    type: STRING
    is_primary_key: false
    nullable: true
    description: "CNPJ of the NF-e issuer. Use for seller matching and creditor identification."
  - name: RecipientCNPJ
    type: STRING
    is_primary_key: false
    nullable: true
    description: "CNPJ of the NF-e recipient (debtor). Use for customer identification and credit risk analysis."

This file is the contract. It feeds the workflow builder that creates the Databricks job, and is validated by an executable schema before any deploy.

2. notebook.py — The Transformation

# Databricks notebook source
# fmt: off

# COMMAND ----------
# MAGIC %md
# MAGIC # Diamond — tb_fct_{main_entity}
# MAGIC Daily fact of the domain's main entity.
# MAGIC Grain: ReferenceDate + PrimaryKey1 + PrimaryKey2 + ...

# COMMAND ----------

from diamond.runtime_functions import get_context, load_output_schema, execute_write

output_schema = load_output_schema(DEFAULT_CONFIG_PATH)

# COMMAND ----------
# MAGIC %md ## Sources

df_events = spark.table(
    cfg,
    "SILVER.{domain}.{main_events_table}"
)
df_supplementary = spark.table(
    cfg,
    "SILVER.{domain}.{supplementary_table}"
)

# COMMAND ----------
# MAGIC %md ## Business Rule BR-001
# MAGIC Applies flow direction filter as defined in the thesis
# MAGIC Reference: thesis/05_business_rules.md § ENTITY_LIFECYCLE

df_filtered = (
    df_events
    .filter(col("direction") == "MAIN_FLOW")
    .filter(col("ReferenceDate").isNotNull())
)

# COMMAND ----------
# MAGIC %md ## Enrichment

df_enriched = (
    df_filtered
    .join(
        df_supplementary.select("PrimaryKey1", "PrimaryKey2", "status"),
        on=["PrimaryKey1", "PrimaryKey2"],
        how="left"
    )
)

# COMMAND ----------
# MAGIC %md ## Write

execute_write(cfg, df_enriched, output_schema)

3. The Coverage Report

Odin also runs a coverage check after generating the notebook: are all wishes in the cluster answered by the table’s output_schema?

📊 Coverage Report — tb_fct_{entity}

Covered wishes (7/9):
  ✅ wish_0001: consolidated view by main entity
  ✅ wish_0007: type of relationship between participants
  ✅ wish_0012: requesting participant of the event
  ✅ wish_0013: equivalent status in the outbound flow
  ✅ wish_0022: settlement status
  ✅ wish_0024: constitution traceability
  ✅ wish_0026: relationship between the two participant types

Uncovered wishes (2/9):
  ⚠️ wish_0042: drill-down by additional dimension → amendment candidate
  ⚠️ wish_0046: renegotiation history → requires separate dim table

KPI answerability:
  Today (without amendment): 78%
  With amendment: 89%
  Moonshot (new dim): 95%

9. The Role of Hooks and Guardrails

The 3 files Odin generates don’t go to production without passing through a quality gate first. One of the most valuable learnings was that agents without guardrails drift. Not out of malice, but because the solution space is too large.

flowchart LR
  OD["Odin generates notebook.py"] --> H["Hooks (.github/hooks/diamond.py)"]
  H -->|passes| M["Merge released"]
  H -->|exit code 2| B["Blocked - Odin cannot proceed"]

    style OD fill:#92400e,stroke:#f59e0b,color:#fff
    style H fill:#374151,stroke:#9ca3af,color:#fff
    style M fill:#166534,stroke:#22c55e,color:#fff
    style B fill:#7f1d1d,stroke:#ef4444,color:#fff

The Notebook Contract: Freedom with Standards

The config.yaml we saw earlier is the data contract — grain, PKs, merge keys, metadata. But there is a second contract, just as important: the writing contract of notebook.py. Every Diamond table, in any domain, follows the same cell backbone — title and grain in Markdown, source reads, business rules referencing the thesis, enrichment, final write.

This is intentional. The engineer has full freedom to solve the business problem in whatever way makes sense; what is non-negotiable is how it is written:

The contract guarantees (fixed)The engineer decides (free)
Cell structureTitle, Sources, Business rules, Enrichment, Write — always in this order—
Source readsAlways via sources.read_SILVER(cfg, ...)Which SILVER tables to use, which joins to make
Thesis referenceEvery business rule cites the thesis chapter (thesis/05_business_rules.md § ...)Which business rule applies, and why
Join qualityAlways qualified (df_a["field"]), never ambiguousThe join logic itself
Final writeAlways via execute_write(cfg, df, output_schema)The transformation that gets there

The practical result: an engineer who has never seen domain X can open the notebook for domain Y and navigate in exactly the same way — same skeleton, same function vocabulary, same reasoning order. And this contract doesn’t depend on discipline or manual review: the hooks are what guarantee it’s never violated.

The Hooks’ Automatic Validation

The framework has a hook system that runs automatically. Among the most relevant validations:

.github/hooks/diamond.py
  ├── join ambiguity validation
  ├── config ↔ notebook coherence validation
  ├── minimum SQL/PySpark practice validation
  └── critical violation blocking before merge

Any violation returns exit code 2 and blocks the agent. Odin cannot proceed without passing all checks.

This was a costly lesson: in the initial version, Odin sometimes generated JOINs without table qualification (the infamous ambiguous col("field")). This caused silent bugs. The check_join_ambiguity() hook emerged from exactly that episode.

# BAD: ambiguous after join — which table has "field"?
df_joined = df_a.join(df_b, "key").select(col("field"))

# GOOD: qualified — unambiguous
df_joined = df_a.join(df_b, "key").select(df_a["field"])

The rule is now automatic. The agent cannot commit code with an ambiguous join.


10. Static Spark Analysis — Performance as a First-Class Concern

Guardrails ensure correctness. But correctness is not the same as efficiency — and that’s where the framework’s second quality system comes in. One of the most useful features is static notebook analysis. It analyzes notebook.py without executing anything and produces a performance risk report.

The motivation is personal: Spark is complex. It is easy to write a notebook that works correctly but burns 10x more compute than it needs to.

🔍 Static Analysis — tb_fct_{entity}/notebook.py

Risk 1/7 — [MEDIUM-5] Missing broadcast join
  AS-IS: df_main.join(df_supplementary, on=["PrimaryKey1", "PrimaryKey2"])
  UC Metrics: small table (~18MB estimated)
  → Broadcast reduces shuffle from O(n*m) to O(n).

  TO-BE:
  ```diff
  - df_main.join(df_supplementary, ...)
  + df_main.join(broadcast(df_supplementary), ...)
  ```

Risk 2/7 — [LOW-3] Unnecessary repartition before write
  AS-IS: df.repartition(200).write(...)
  → Default parallelism > 200 → repartition reduces parallelism with no gain.

  TO-BE: Remove repartition or use coalesce().

Each recommendation comes with:

  • The risk classified on a 1–7 scale
  • The AS-IS with evidence from the current code
  • The TO-BE with an exact diff
  • The Unity Catalog metric that justifies the recommendation

The rule is strict: no recommendation about join strategy or broadcast is made without real UC metrics. If there are no metrics, the report is blocked until the engineer confirms.


11. The Result: 3 Months of Work, 5 Domains, Dozens of Tables

Guardrails and performance analysis ensure the quality of each individual table. But what was the aggregate result after 3 months of this process running across 5 domains?

The scope was 5 business systems with high regulatory complexity — CERC’s core financial domains.

The numbers:

MetricBefore DiamondWith Diamond
Domains with an official analytical layer05
Standardized analytical tables~dozens (ad hoc)Dozens (formal contract)
Teams needing to reconcile queriesevery quartersharp drop with one standard source per domain
Estimated manual time10+ months3 months with agents
Time to next domain (e.g. depository)—2–3 weeks

The biggest saving is not time — it is quality. The SILVER layer had hundreds of tables from different systems. Diamond covers the analytical needs of 80–90% of use cases with dozens of tables under a clear contract.


12. What We Learned About Agent Automation

The numbers above came with lessons about where agent automation really works — and where it doesn’t.

1. Scripts Are Still Superior for Deterministic Tasks

Clustering wishes with ML is more reliable than letting the agent cluster semantically. The agent adds value where there is interpretation; the script adds value where there is reproducible computation.

2. Human-in-the-Loop Is Non-Negotiable in Semantic Modeling

No model substitutes validation with the business. The thesis can be wrong. The Unity Catalog can show something that contradicts what the meeting indicated. Without human validation, the Diamond layer would be just another layer of assumptions.

3. The Agent Needs Guardrails Before It Is Useful

The first version of Odin had no hooks. It generated technically valid code but with quality problems that only surfaced later. The hooks transformed the experience: the agent knows what it cannot do, and focuses on what adds value.

4. Separating Responsibilities Between Agents Reduces Hallucination

An agent that knows everything and does everything is more prone to invention. The Black Belt classifies but does not execute. Odin executes but does not decide grain without evidence. PHD writes theses but does not validate. This separation is intentional and crucial.

5. The Thesis Is the Most Valuable Asset

In the end, the most powerful artifact is not the notebook. It is the thesis. It concentrates product knowledge that normally lives in the heads of 3–4 people who attended the right meetings. With the versioned thesis, any engineer who joins the team can get up to speed in hours.


13. What Comes Next

Domain Agents: The Natural Next Step

Every organization will want an agent that understands their product. The question is not if, but when — and what will separate a useful agent from a generic bot is the quality of the context it carries.

What gives context to an agent? The thesis.

CERC has something most organizations don’t: linearized theses by domain — documents that capture the invariants of each system, validated by people who understand the business, versioned in the repository.

Each thesis can become the constitution of a specific agent. A Credit agent that knows the Credit flows. A Depository agent that understands the Depository rules. Not a generic bot with vague instructions — an agent that read the domain thesis and understands why each rule exists.

The material is already ready:

  • Linearized — glossary, concepts, rules, validation. Structure the agent can use.
  • Versioned — when a rule changes, the thesis changes. The agent stays updated.
  • Human-validated — not speculation. Every chapter was reviewed by domain teams.
  • Accessible — not in lost meetings or in the heads of 3 people. It’s written down.

With domain-specific agents, this asset becomes exponentially more valuable.

The thesis is the foundation. The agent is what you build on top of it.


Framework’s Next Evolutions

Institutionalization — when presenting the results to leadership, the final conversation was about transforming this material into a corporate asset. The thesis should not live only in the Diamond repository. It should feed the Architecture CoE, become the onboarding reference, be consumed by any agent that needs to understand a CERC product.

CI/CD for the thesis — when a rule changes in SILVER, which Diamond table is impacted? Today that is manual. The next version of the framework will have automatic impact traceability.

Coverage metrics — today we measure coverage per wish. The next iteration measures coverage per type of business question: vintage analysis, market monitoring, billing. This will allow prioritizing the next amendments with data.


14. For Those Who Want to Replicate This

The entire framework runs in GitHub Copilot Agents inside VS Code, leveraging the stack already adopted by the team (repository, Databricks, and catalog). The agents are .agent.md files with structured instructions. The skills are SKILL.md files that agents invoke.

Where to start: the biggest initial blocker is not technical — it is choosing the right domain for the first thesis. The ideal profile: a domain where recordings already exist, a specialist available to validate, and at least 2–3 teams complaining about analytical divergence. With that starting point, the first thesis is ready in 1–2 weeks. The first notebook follows in a few days.

The folder structure the engineer needs to create for a new domain:

docs/knowledge_base/cerc_systems/{domain}/
├── BRONZE/
│   └── meetings/
│       └── {date}_{meeting_name}.vtt
└── wiki/
    └── thesis/
        ├── 01_intro.md
        ├── 02_glossary.md
        └── ...

docs/knowledge_base/datalake/wiki/diamond/{domain}/
├── system_tables.json     ← SILVER source tables
├── system_tables.yaml     ← generated automatically
└── wishes/
    └── wish_NNNN.yaml     ← generated by djinn

And then: @Diamond Black Belt, and the process begins.


Conclusion

Building the Diamond layer was not a data project. It was a project in applied epistemology.

The original problem was not technical — it was that the knowledge of how CERC’s financial products work was dispersed across meetings, heads, and poorly documented queries. The solution was not just creating tables. It was creating a process that captures, organizes, and preserves that knowledge in a way that agents can use to build high-quality technical artifacts.

The framework VTT → Thesis → Wishes → Clusters → Diamond is reusable, documented, and already in use for new domains.

Those two people from the beginning — same table, same question, two different numbers — today have the same answer. Because there is a thesis that defines what the question means. And the thesis isn’t in anyone’s head: it’s in the repository, versioned, ready to be read by any engineer — or agent — that needs to understand the domain.

What we used to do by hand now has a process. And the process runs with agents.


This post was written by: André Tayer, Davi Campos, Guilherme Oliveira, José Roling, Robson Sampaio, and Marcel Duarte.