{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.13.0"
    },
    "blog_metadata": {
      "topic": "Fabric Medallion Governance Is Maturing: What the New Warehouse Guidance Means for Data Leaders",
      "slug": "fabric-medallion-governance-is-maturing-what-the-new-warehou",
      "generated_by": "LinkedIn Post Generator + Azure OpenAI",
      "generated_at": "2026-11-11T21:09:53.426Z"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Fabric Medallion Governance Is Maturing: What the New Warehouse Guidance Means for Data Leaders\n",
        "\n",
        "This notebook turns the blog post into a hands-on validation workbook. It focuses on the core claim that Bronze, Silver, and Gold should be treated as governance control boundaries, not just engineering stages, and provides executable Python examples to test naming, promotion, readiness, KPI, and contract patterns."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "%pip install pandas matplotlib seaborn networkx"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "import networkx as nx\n",
        "from pprint import pprint\n",
        "\n",
        "sns.set_theme(style='whitegrid')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Governance framing\n",
        "\n",
        "The blog argues that Fabric's medallion pattern creates operating-model pressure: once the platform standardizes Bronze, Silver, and Gold, leaders need explicit ownership, access, separation of duties, and audit evidence. In practice, Gold should sit downstream of both quality gates and governance controls, not just downstream of transformation."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "layers = pd.DataFrame([\n",
        "    {\"layer\": \"bronze\", \"purpose\": \"preservation and intake\", \"primary_control\": \"source fidelity\", \"consumer_access\": \"restricted\"},\n",
        "    {\"layer\": \"silver\", \"purpose\": \"transformation and conformance\", \"primary_control\": \"quality and standardization\", \"consumer_access\": \"role-based\"},\n",
        "    {\"layer\": \"gold\", \"purpose\": \"publication and decision support\", \"primary_control\": \"curation and governed consumption\", \"consumer_access\": \"approved consumer classes\"},\n",
        "])\n",
        "\n",
        "print(layers)\n",
        "\n",
        "G = nx.DiGraph()\n",
        "G.add_edges_from([\n",
        "    (\"Source Systems\", \"Bronze / Raw Lakehouse\"),\n",
        "    (\"Bronze / Raw Lakehouse\", \"Silver / Conformed Lakehouse\"),\n",
        "    (\"Silver / Conformed Lakehouse\", \"Gold / Curated Warehouse\"),\n",
        "    (\"Gold / Curated Warehouse\", \"Semantic Model / BI\"),\n",
        "    (\"Silver / Conformed Lakehouse\", \"Data Quality Rules\"),\n",
        "    (\"Data Quality Rules\", \"Gold / Curated Warehouse\"),\n",
        "    (\"Gold / Curated Warehouse\", \"Governance Controls\"),\n",
        "    (\"Governance Controls\", \"RLS / CLS / Auditing\"),\n",
        "])\n",
        "\n",
        "plt.figure(figsize=(12, 6))\n",
        "pos = nx.spring_layout(G, seed=42, k=1.2)\n",
        "nx.draw(G, pos, with_labels=True, node_size=3500, node_color=\"#D9EAF7\", font_size=9, arrows=True)\n",
        "plt.title(\"Fabric Medallion Flow with Quality and Governance Gates\")\n",
        "plt.axis(\"off\")\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 1: Validate medallion layer naming and ownership conventions\n",
        "\n",
        "This example checks whether warehouse objects carry a clear layer signal in their names and whether each object has an assigned owner. It demonstrates the blog's point that if naming and ownership are optional, governance is already leaking."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Validate medallion layer naming and ownership conventions\n",
        "warehouses = [\n",
        "    {\"name\": \"wh_gold_sales\", \"layer\": \"gold\", \"owner\": \"data-platform\"},\n",
        "    {\"name\": \"wh_silver_ops\", \"layer\": \"silver\", \"owner\": \"data-eng\"},\n",
        "    {\"name\": \"sales_curated\", \"layer\": \"gold\", \"owner\": \"\"},\n",
        "]\n",
        "\n",
        "def validate(items):\n",
        "    issues = []\n",
        "    for w in items:\n",
        "        expected_prefix = f\"wh_{w['layer']}_\"\n",
        "        if not w[\"name\"].startswith(expected_prefix):\n",
        "            issues.append(f\"{w['name']}: expected prefix {expected_prefix}\")\n",
        "        if not w[\"owner\"]:\n",
        "            issues.append(f\"{w['name']}: missing owner\")\n",
        "    return issues\n",
        "\n",
        "issues = validate(warehouses)\n",
        "print(\"Validation issues:\")\n",
        "for issue in issues:\n",
        "    print(\"-\", issue)\n",
        "\n",
        "pd.DataFrame(warehouses)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 2: Enforce a simple promotion rule from Silver to Gold\n",
        "\n",
        "The original post used PowerShell to show that promotion should depend on controls being complete, not just on usefulness. Here the same logic is implemented in Python so it can run directly in this notebook."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Enforce a simple promotion rule from silver to gold warehouse\n",
        "\n",
        "datasets = [\n",
        "    {\"Name\": \"customer_360\", \"QualityScore\": 92, \"HasOwner\": True, \"HasSLA\": True},\n",
        "    {\"Name\": \"orders_daily\", \"QualityScore\": 74, \"HasOwner\": True, \"HasSLA\": False},\n",
        "]\n",
        "\n",
        "results = []\n",
        "for d in datasets:\n",
        "    approved = (d[\"QualityScore\"] >= 85) and d[\"HasOwner\"] and d[\"HasSLA\"]\n",
        "    decision = \"promote to gold warehouse\" if approved else \"hold in silver until controls are complete\"\n",
        "    results.append({**d, \"Approved\": approved, \"Decision\": decision})\n",
        "    print(f\"{d['Name']}: {decision}\")\n",
        "\n",
        "pd.DataFrame(results)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 3: Visualize the Silver-to-Gold quality gate sequence\n",
        "\n",
        "This sequence view reinforces the idea that Gold publication should happen only after conformance outputs pass quality checks. It converts the blog's sequence diagram into a simple Python visualization."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "steps = [\n",
        "    \"Data Engineer\\nPublish conformed tables\",\n",
        "    \"Silver Lakehouse\\nStore conformed data\",\n",
        "    \"Data Quality Gate\\nRun schema + quality checks\",\n",
        "    \"Gold Warehouse\\nApprove curated load\",\n",
        "    \"BI Consumer\\nServe governed dimensions/facts\",\n",
        "]\n",
        "\n",
        "fig, ax = plt.subplots(figsize=(14, 2.8))\n",
        "ax.set_xlim(0, len(steps))\n",
        "ax.set_ylim(0, 1)\n",
        "ax.axis(\"off\")\n",
        "\n",
        "for i, step in enumerate(steps):\n",
        "    ax.text(i + 0.5, 0.5, step, ha=\"center\", va=\"center\",\n",
        "            bbox=dict(boxstyle=\"round,pad=0.4\", facecolor=\"#EAF2F8\", edgecolor=\"#5D6D7E\"))\n",
        "    if i < len(steps) - 1:\n",
        "        ax.annotate(\"\", xy=(i + 1.0, 0.5), xytext=(i + 0.75, 0.5),\n",
        "                    arrowprops=dict(arrowstyle=\"->\", lw=2, color=\"#34495E\"))\n",
        "\n",
        "plt.title(\"Silver to Gold Promotion Sequence\")\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 4: Score tables for warehouse readiness based on governance signals\n",
        "\n",
        "This example shifts the discussion from technical queryability to publication readiness. It scores assets using governance-oriented signals such as primary keys, test coverage, and PII tagging."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Score tables for warehouse readiness based on governance signals\n",
        "tables = [\n",
        "    {\"table\": \"dim_customer\", \"pk\": True, \"tests\": 12, \"pii_tagged\": True},\n",
        "    {\"table\": \"fact_sales\", \"pk\": False, \"tests\": 8, \"pii_tagged\": True},\n",
        "    {\"table\": \"stg_orders\", \"pk\": False, \"tests\": 2, \"pii_tagged\": False},\n",
        "]\n",
        "\n",
        "def readiness_score(t):\n",
        "    score = 0\n",
        "    score += 40 if t[\"pk\"] else 0\n",
        "    score += min(t[\"tests\"] * 5, 40)\n",
        "    score += 20 if t[\"pii_tagged\"] else 0\n",
        "    return score\n",
        "\n",
        "scored = []\n",
        "for t in tables:\n",
        "    score = readiness_score(t)\n",
        "    tier = \"warehouse-ready\" if score >= 80 else \"needs-hardening\"\n",
        "    scored.append({**t, \"score\": score, \"tier\": tier})\n",
        "    print(f\"{t['table']}: {score} -> {tier}\")\n",
        "\n",
        "score_df = pd.DataFrame(scored)\n",
        "display(score_df)\n",
        "\n",
        "plt.figure(figsize=(8, 4))\n",
        "ax = sns.barplot(data=score_df, x=\"table\", y=\"score\", hue=\"tier\", dodge=False)\n",
        "ax.axhline(80, ls=\"--\", color=\"red\", label=\"Gold minimum bar\")\n",
        "plt.title(\"Warehouse Readiness Scores\")\n",
        "plt.ylim(0, 100)\n",
        "plt.legend()\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 5: Tag sensitive columns before exposing them through warehouse models\n",
        "\n",
        "The blog emphasizes that Gold publication should be controlled and auditable. A simple way to validate that mindset is to classify columns before they are exposed to broader consumer groups."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Tag sensitive columns before exposing them through warehouse models\n",
        "columns = [\n",
        "    {\"Table\": \"dim_customer\", \"Column\": \"customer_id\", \"Sensitivity\": \"Confidential\"},\n",
        "    {\"Table\": \"dim_customer\", \"Column\": \"email\", \"Sensitivity\": \"HighlyConfidential\"},\n",
        "    {\"Table\": \"fact_sales\", \"Column\": \"net_amount\", \"Sensitivity\": \"General\"},\n",
        "]\n",
        "\n",
        "labels = []\n",
        "for c in columns:\n",
        "    label = f\"{c['Table']}.{c['Column']} => {c['Sensitivity']}\"\n",
        "    labels.append(label)\n",
        "    print(label)\n",
        "\n",
        "col_df = pd.DataFrame(columns)\n",
        "display(col_df)\n",
        "\n",
        "plt.figure(figsize=(7, 4))\n",
        "sns.countplot(data=col_df, y=\"Sensitivity\", order=col_df[\"Sensitivity\"].value_counts().index)\n",
        "plt.title(\"Sensitivity Labels Applied Before Publication\")\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 6: Generate a simple governance KPI summary for leadership reporting\n",
        "\n",
        "This example turns governance expectations into measurable platform metrics. Instead of tracking intentions, it reports certification, security, and ownership coverage across assets."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Generate a simple governance KPI summary for leadership reporting\n",
        "assets = [\n",
        "    {\"name\": \"gold_sales\", \"certified\": True, \"rls\": True, \"owner\": True},\n",
        "    {\"name\": \"gold_finance\", \"certified\": True, \"rls\": False, \"owner\": True},\n",
        "    {\"name\": \"silver_ops\", \"certified\": False, \"rls\": False, \"owner\": False},\n",
        "]\n",
        "\n",
        "total = len(assets)\n",
        "certified = sum(a[\"certified\"] for a in assets)\n",
        "secured = sum(a[\"rls\"] for a in assets)\n",
        "owned = sum(a[\"owner\"] for a in assets)\n",
        "\n",
        "summary = {\n",
        "    \"total_assets\": total,\n",
        "    \"certified_pct\": certified / total,\n",
        "    \"secured_pct\": secured / total,\n",
        "    \"owned_pct\": owned / total,\n",
        "}\n",
        "\n",
        "print({\"total_assets\": total, \"certified_pct\": certified / total})\n",
        "print({\"secured_pct\": secured / total, \"owned_pct\": owned / total})\n",
        "\n",
        "summary_df = pd.DataFrame([summary])\n",
        "display(summary_df)\n",
        "\n",
        "plot_df = pd.DataFrame({\n",
        "    \"metric\": [\"certified_pct\", \"secured_pct\", \"owned_pct\"],\n",
        "    \"value\": [summary[\"certified_pct\"], summary[\"secured_pct\"], summary[\"owned_pct\"]],\n",
        "})\n",
        "\n",
        "plt.figure(figsize=(7, 4))\n",
        "ax = sns.barplot(data=plot_df, x=\"metric\", y=\"value\", palette=\"Blues_d\")\n",
        "ax.set_ylim(0, 1)\n",
        "plt.title(\"Governance KPI Coverage\")\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Example 7: Build a lightweight data contract for curated warehouse tables\n",
        "\n",
        "The post argues that Gold should be treated as a contract, not a convenience layer. This example validates the presence of basic contract fields such as grain, owner, SLA, and column definitions."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "# Build a lightweight data contract for curated warehouse tables\n",
        "contract = {\n",
        "    \"table\": \"dim_customer\",\n",
        "    \"grain\": \"one row per customer\",\n",
        "    \"owner\": \"domain-sales\",\n",
        "    \"sla_hours\": 4,\n",
        "    \"columns\": [\n",
        "        {\"name\": \"customer_id\", \"type\": \"string\", \"nullable\": False},\n",
        "        {\"name\": \"customer_name\", \"type\": \"string\", \"nullable\": False},\n",
        "        {\"name\": \"region\", \"type\": \"string\", \"nullable\": True},\n",
        "    ],\n",
        "}\n",
        "\n",
        "required = {\"table\", \"grain\", \"owner\", \"sla_hours\", \"columns\"}\n",
        "missing = required - contract.keys()\n",
        "print(\"contract_valid=\", len(missing) == 0)\n",
        "print(\"column_count=\", len(contract[\"columns\"]))\n",
        "print(\"missing_fields=\", missing)\n",
        "\n",
        "pprint(contract)\n",
        "pd.DataFrame(contract[\"columns\"])"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Practical leadership checklist\n",
        "\n",
        "Use the examples above to validate whether your Fabric implementation behaves like a governed operating model:\n",
        "\n",
        "- Bronze has restricted access and named intake stewardship.\n",
        "- Silver has explicit transformation accountability and quality gates.\n",
        "- Gold requires owner, SLA, certification, and publication controls.\n",
        "- Promotion decisions are conditional on evidence, not convenience.\n",
        "- KPI reporting tracks exceptions and coverage, not just architecture completion."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Next Steps\n",
        "\n",
        "This notebook translated the blog's argument into executable checks and lightweight governance artifacts. The main takeaway is that medallion maturity is proven when each layer changes permissions, responsibilities, and evidence requirements.\n",
        "\n",
        "Suggested next steps:\n",
        "- Define a one-page control charter for Bronze, Silver, and Gold.\n",
        "- Add owner, SLA, and certification checks to promotion workflows.\n",
        "- Set a minimum readiness score for Gold publication.\n",
        "- Track exception metrics such as undocumented owners, broad Bronze access, and uncertified Gold assets.\n",
        "- Turn Gold datasets into explicit contracts with grain, columns, intended use, and service expectations."
      ]
    }
  ]
}