[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D9CNA01WE5F4AV3B9WWB5F":3,"skill-same:01M7D9CNA01WE5F4AV3B9WWB5F":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":60,"commitSha":61,"skillDirectory":62,"forksCount":14,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":65,"ownerDescription":66,"updatedAt":67,"install":68,"resources":81},"01M7D9CNA01WE5F4AV3B9WWB5F","RAG Regression Testing",null,"Gate RAG pipelines in CI with versioned golden eval sets, per-metric thresholds, baseline drift detection, and a build that fails when retrieval or answer quality regresses.","GrupoANDevelopment-m\u002Falberto-ai","GrupoANDevelopment-m","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257455179?v=4","01M7D69X2N2KEVN0SJF6WGM6SH","Antônio  Ndombe","01M7D69X3P5JTT8H8S904N3888",0,"MIT","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Frag-regression-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: RAG Regression Testing\ndescription: Gate RAG pipelines in CI with versioned golden eval sets, per-metric thresholds, baseline drift detection, and a build that fails when retrieval or answer quality regresses.\nversion: 1.0.0\nauthor: thetestingacademy\nlicense: MIT\ntags: [rag, regression-testing, llm-evals, ci, golden-dataset, drift-detection, ragas, deepeval, baseline]\ntestingTypes: [regression, llm-evals, integration]\nframeworks: [ragas, deepeval, pytest]\nlanguages: [python]\ndomains: [ai, llm, api]\nagents: [claude-code, cursor, github-copilot, windsurf, codex, aider, continue, cline, zed, bolt, gemini-cli, amp]\n---\n\n# RAG Regression Testing Skill\n\nYou are an expert in shipping RAG systems without quality regressions. When the user asks you to add CI gates, detect drift, or stop a build from merging when answer quality drops, you build a versioned golden eval set, compare every run against a committed baseline, and fail the build on absolute-threshold breaches or relative drops. You treat prompts and retriever configs as versioned artifacts, because a prompt change is a behavior change.\n\n## Core Principles\n\n1. **A RAG pipeline regresses silently.** Code tests stay green while answer quality rots from a model update, a prompt tweak, a chunking change, or an index rebuild. Only an eval gate catches this.\n2. **The golden set is the regression contract.** Every metric is scored against a fixed, committed dataset. Changing the dataset is a deliberate, reviewed event - never an accident.\n3. **Gate on two conditions: absolute floor and relative drop.** Fail if any metric falls below its hard floor, *and* fail if it drops more than N points versus the committed baseline - even while still \"passing.\"\n4. **Baselines are committed artifacts.** Store `baseline_metrics.json` in the repo. A score is only meaningful as a delta against a known-good baseline.\n5. **Version the prompt and retriever, not just the code.** Tag each eval run with prompt and retriever versions so a regression can be traced to the exact change that caused it.\n6. **Pin everything that scores.** Judge model, judge temperature, embedding model, and `top_k`. An unpinned judge makes \"regression\" indistinguishable from judge noise.\n7. **Fail fast and loud in CI; allow an explicit baseline-update path.** The only way to move the baseline is a reviewed PR that regenerates and commits it.\n8. **Quarantine, do not delete, flaky golden samples.** Mark them, investigate, fix the data or the pipeline - never silently drop a hard question to make the gate pass.\n\n## Repository Layout\n\n```\nrag-evals\u002F\n  golden\u002F\n    dataset.v3.json            # versioned golden set; bump filename on change\n  baseline\u002F\n    baseline_metrics.json      # committed known-good scores\n  config\u002F\n    eval_config.py             # pinned models, thresholds, drift budget\n  run_eval.py                  # produces scores, writes report.json\n  gate.py                      # compares scores vs baseline + floors -> exit code\n  update_baseline.py           # regenerates baseline (run intentionally)\n.github\u002F\n  workflows\u002F\n    rag-regression.yml\n```\n\n## Pinned Evaluation Config\n\n```python\n# config\u002Feval_config.py\nfrom dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass EvalConfig:\n    # Everything that influences a score is pinned.\n    judge_model: str = \"gpt-4o-mini\"\n    judge_temperature: float = 0.0\n    embedding_model: str = \"text-embedding-3-small\"\n    top_k: int = 5\n\n    # Identifies the system under test for traceability.\n    prompt_version: str = \"answer-v4\"\n    retriever_version: str = \"hybrid-bm25+dense-v2\"\n\n    dataset_path: str = \"rag-evals\u002Fgolden\u002Fdataset.v3.json\"\n    baseline_path: str = \"rag-evals\u002Fbaseline\u002Fbaseline_metrics.json\"\n\n\n# Absolute floors: build fails if a metric drops below these, ever.\nHARD_FLOORS = {\n    \"faithfulness\": 0.88,\n    \"context_precision\": 0.78,\n    \"context_recall\": 0.78,\n    \"answer_relevancy\": 0.72,\n}\n\n# Drift budget: build fails if a metric drops more than this vs baseline,\n# even if still above the hard floor. Catches slow erosion.\nMAX_REGRESSION = {\n    \"faithfulness\": 0.03,\n    \"context_precision\": 0.05,\n    \"context_recall\": 0.05,\n    \"answer_relevancy\": 0.05,\n}\n\nCONFIG = EvalConfig()\n```\n\n## Running the Eval and Producing a Report\n\n```python\n# run_eval.py\nimport json\nfrom datasets import Dataset\nfrom ragas import evaluate\nfrom ragas.metrics import (\n    context_precision, context_recall, faithfulness, answer_relevancy,\n)\nfrom ragas.llms import LangchainLLMWrapper\nfrom langchain_openai import ChatOpenAI, OpenAIEmbeddings\n\nfrom config.eval_config import CONFIG\nfrom my_rag_app import rag_pipeline\n\n\ndef load_golden(path: str) -> list[dict]:\n    with open(path) as f:\n        return json.load(f)[\"samples\"]\n\n\ndef main() -> None:\n    golden = load_golden(CONFIG.dataset_path)\n    rows = {\"question\": [], \"answer\": [], \"contexts\": [], \"ground_truth\": []}\n    for s in golden:\n        out = rag_pipeline(s[\"question\"], top_k=CONFIG.top_k)\n        rows[\"question\"].append(s[\"question\"])\n        rows[\"answer\"].append(out[\"answer\"])\n        rows[\"contexts\"].append(out[\"contexts\"])\n        rows[\"ground_truth\"].append(s[\"ground_truth\"])\n\n    judge = LangchainLLMWrapper(\n        ChatOpenAI(model=CONFIG.judge_model, temperature=CONFIG.judge_temperature)\n    )\n    result = evaluate(\n        Dataset.from_dict(rows),\n        metrics=[context_precision, context_recall, faithfulness, answer_relevancy],\n        llm=judge,\n        embeddings=OpenAIEmbeddings(model=CONFIG.embedding_model),\n    )\n\n    df = result.to_pandas()\n    means = {\n        m: round(float(df[m].mean()), 4)\n        for m in [\"context_precision\", \"context_recall\", \"faithfulness\", \"answer_relevancy\"]\n    }\n    report = {\n        \"metrics\": means,\n        \"n_samples\": len(golden),\n        \"below_floor_counts\": {\n            m: int((df[m] \u003C 0.5).sum())  # count of egregious per-sample failures\n            for m in means\n        },\n        \"prompt_version\": CONFIG.prompt_version,\n        \"retriever_version\": CONFIG.retriever_version,\n        \"judge_model\": CONFIG.judge_model,\n    }\n    with open(\"report.json\", \"w\") as f:\n        json.dump(report, f, indent=2)\n    print(json.dumps(report, indent=2))\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## The Gate: Floors + Drift Detection\n\n```python\n# gate.py\nimport json\nimport sys\n\nfrom config.eval_config import CONFIG, HARD_FLOORS, MAX_REGRESSION\n\n\ndef load(path: str) -> dict:\n    with open(path) as f:\n        return json.load(f)\n\n\ndef main() -> int:\n    report = load(\"report.json\")\n    current = report[\"metrics\"]\n    baseline = load(CONFIG.baseline_path)[\"metrics\"]\n\n    failures: list[str] = []\n\n    for metric, score in current.items():\n        floor = HARD_FLOORS.get(metric)\n        if floor is not None and score \u003C floor:\n            failures.append(f\"[FLOOR]  {metric}={score:.3f} \u003C hard floor {floor:.2f}\")\n\n        base = baseline.get(metric)\n        budget = MAX_REGRESSION.get(metric)\n        if base is not None and budget is not None:\n            drop = base - score\n            if drop > budget:\n                failures.append(\n                    f\"[DRIFT]  {metric} dropped {drop:.3f} \"\n                    f\"(baseline {base:.3f} -> {score:.3f}, budget {budget:.2f})\"\n                )\n\n    if failures:\n        print(\"RAG REGRESSION DETECTED:\\n  \" + \"\\n  \".join(failures))\n        print(f\"\\nprompt={report['prompt_version']} retriever={report['retriever_version']}\")\n        return 1\n\n    print(\"RAG eval passed. No regression vs baseline.\")\n    for m, s in current.items():\n        print(f\"  {m}: {s:.3f} (baseline {baseline.get(m, float('nan')):.3f})\")\n    return 0\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n```\n\n## Updating the Baseline (Intentional Only)\n\n```python\n# update_baseline.py\n\"\"\"Run ONLY when a quality change is intended and reviewed.\nThe resulting baseline_metrics.json must be committed in the same PR.\"\"\"\nimport json\nimport shutil\n\nfrom config.eval_config import CONFIG\n\n# run_eval.py must have been run first to produce report.json\nwith open(\"report.json\") as f:\n    report = json.load(f)\n\nshutil.copy(CONFIG.baseline_path, CONFIG.baseline_path + \".bak\")\nwith open(CONFIG.baseline_path, \"w\") as f:\n    json.dump({\"metrics\": report[\"metrics\"],\n               \"prompt_version\": report[\"prompt_version\"],\n               \"retriever_version\": report[\"retriever_version\"]}, f, indent=2)\nprint(\"Baseline updated. Commit this file with a justification in the PR.\")\n```\n\n## CI Workflow (GitHub Actions)\n\n```yaml\n# .github\u002Fworkflows\u002Frag-regression.yml\nname: RAG Regression Gate\n\non:\n  pull_request:\n    paths:\n      - \"rag-evals\u002F**\"\n      - \"src\u002Fprompts\u002F**\"\n      - \"src\u002Fretriever\u002F**\"\n      - \"src\u002Frag\u002F**\"\n  workflow_dispatch:\n\nconcurrency:\n  group: rag-eval-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  rag-eval-gate:\n    runs-on: ubuntu-latest\n    timeout-minutes: 20\n    steps:\n      - uses: actions\u002Fcheckout@v4\n\n      - uses: actions\u002Fsetup-python@v5\n        with:\n          python-version: \"3.12\"\n\n      - name: Install deps\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt   # ragas, datasets, langchain-openai, etc.\n\n      - name: Run RAG evaluation\n        env:\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        run: python rag-evals\u002Frun_eval.py\n\n      - name: Gate on thresholds + drift\n        run: python rag-evals\u002Fgate.py   # non-zero exit fails the job\n\n      - name: Upload eval report\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: rag-eval-report\n          path: report.json\n\n      - name: Comment metrics on PR\n        if: always() && github.event_name == 'pull_request'\n        uses: actions\u002Fgithub-script@v7\n        with:\n          script: |\n            const fs = require('fs');\n            const r = JSON.parse(fs.readFileSync('report.json', 'utf8'));\n            const rows = Object.entries(r.metrics)\n              .map(([k, v]) => `| ${k} | ${v.toFixed(3)} |`).join('\\n');\n            const body = `### RAG Eval (\\`${r.prompt_version}\\` \u002F \\`${r.retriever_version}\\`)\\n`\n              + `| metric | score |\\n|---|---|\\n${rows}`;\n            await github.rest.issues.createComment({\n              owner: context.repo.owner, repo: context.repo.repo,\n              issue_number: context.issue.number, body,\n            });\n```\n\nThe gate runs on PRs that touch prompts, retriever, or the eval set. A merge is blocked until the gate passes - so the only way to ship a quality change is to also commit the new baseline.\n\n## Detecting Drift Over Time\n\nFor nightly scheduled runs against production traffic samples, append each run's metrics to a time series and alert on a moving-window drop:\n\n```python\n# drift_alert.py\nimport statistics\n\n\ndef detect_trend_drift(history: list[dict], metric: str, window: int = 7) -> str | None:\n    \"\"\"history: list of {date, metrics:{...}} newest last.\"\"\"\n    series = [h[\"metrics\"][metric] for h in history if metric in h[\"metrics\"]]\n    if len(series) \u003C window + 1:\n        return None\n    recent = statistics.mean(series[-3:])\n    baseline_window = statistics.mean(series[-(window + 1):-3])\n    drop = baseline_window - recent\n    if drop > 0.04:\n        return (f\"{metric} trending down: {baseline_window:.3f} -> {recent:.3f} \"\n                f\"over {window} days (drop {drop:.3f})\")\n    return None\n```\n\n## Best Practices\n\n1. **Commit the baseline; never compute it at runtime.** A regression is a delta from a known-good, reviewed file - not from yesterday's accidental score.\n2. **Gate on both a hard floor and a drift budget.** Floors catch cliffs; drift budgets catch slow erosion that stays \"green.\"\n3. **Version the golden dataset in the filename (`dataset.v3.json`).** Bumping the version is a reviewable, deliberate act.\n4. **Tag every report with prompt and retriever versions.** When the gate fails, you know exactly which artifact regressed.\n5. **Make baseline updates a separate, justified PR step.** Require a written reason in the PR description for any baseline move.\n6. **Scope the gate to RAG-relevant paths, and publish the report.** Use `paths:` to keep paid LLM-judge calls off unrelated PRs; upload `report.json` as an artifact and comment scores on the PR.\n7. **Run a nightly scheduled eval against fresh data for trend drift.** PR gates catch deliberate changes; scheduled runs catch upstream model drift.\n\n## Anti-Patterns to Avoid\n\n1. **No committed baseline.** Comparing against \"last run\" lets a slow daily 0.5% decline accumulate into a disaster, each step individually passing.\n2. **Floor-only gating.** A metric sliding from 0.95 to 0.89 (still above a 0.88 floor) is a real regression a drift budget would catch.\n3. **Editing the golden set in the same PR as a pipeline change.** You can no longer tell whether the score moved because the system changed or the test changed.\n4. **Unpinned judge or embedding model in CI.** Judge noise gets misread as regression, and the gate becomes flaky and ignored.\n5. **Deleting hard golden questions to make the build green.** That is removing the smoke detector because it keeps going off.\n6. **Silencing the gate (`continue-on-error: true`) to unblock a deadline.** A non-blocking quality gate is theater.\n\n## When to Trigger This Skill\n\nTrigger when the user asks to:\n- Add a CI gate or build check for RAG \u002F LLM answer quality\n- Detect quality drift or regression in a RAG pipeline over time\n- Set up a golden eval set with baselines and thresholds for CI\n- Fail a build when faithfulness, retrieval, or relevancy drops\n- Version prompts and retrievers for regression traceability\n- Wire Ragas\u002FDeepEval into GitHub Actions or another CI system\n\nFor the *definitions and scoring* of the underlying metrics (faithfulness, context precision\u002Frecall, answer relevancy), use the RAG Evaluation Metrics skill. This skill assumes those metrics exist and focuses on gating and drift over time.\n","# RAG Regression Testing Skill\n\nYou are an expert in shipping RAG systems without quality regressions. When the user asks you to add CI gates, detect drift, or stop a build from merging when answer quality drops, you build a versioned golden eval set, compare every run against a committed baseline, and fail the build on absolute-threshold breaches or relative drops. You treat prompts and retriever configs as versioned artifacts, because a prompt change is a behavior change.\n\n## Core Principles\n\n1. **A RAG pipeline regresses silently.** Code tests stay green while answer quality rots from a model update, a prompt tweak, a chunking change, or an index rebuild. Only an eval gate catches this.\n2. **The golden set is the regression contract.** Every metric is scored against a fixed, committed dataset. Changing the dataset is a deliberate, reviewed event - never an accident.\n3. **Gate on two conditions: absolute floor and relative drop.** Fail if any metric falls below its hard floor, *and* fail if it drops more than N points versus the committed baseline - even while still \"passing.\"\n4. **Baselines are committed artifacts.** Store `baseline_metrics.json` in the repo. A score is only meaningful as a delta against a known-good baseline.\n5. **Version the prompt and retriever, not just the code.** Tag each eval run with prompt and retriever versions so a regression can be traced to the exact change that caused it.\n6. **Pin everything that scores.** Judge model, judge temperature, embedding model, and `top_k`. An unpinned judge makes \"regression\" indistinguishable from judge noise.\n7. **Fail fast and loud in CI; allow an explicit baseline-update path.** The only way to move the baseline is a reviewed PR that regenerates and commits it.\n8. **Quarantine, do not delete, flaky golden samples.** Mark them, investigate, fix the data or the pipeline - never silently drop a hard question to make the gate pass.\n\n## Repository Layout\n\n```\nrag-evals\u002F\n  golden\u002F\n    dataset.v3.json            # versioned golden set; bump filename on change\n  baseline\u002F\n    baseline_metrics.json      # committed known-good scores\n  config\u002F\n    eval_config.py             # pinned models, thresholds, drift budget\n  run_eval.py                  # produces scores, writes report.json\n  gate.py                      # compares scores vs baseline + floors -> exit code\n  update_baseline.py           # regenerates baseline (run intentionally)\n.github\u002F\n  workflows\u002F\n    rag-regression.yml\n```\n\n## Pinned Evaluation Config\n\n```python\n# config\u002Feval_config.py\nfrom dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass EvalConfig:\n    # Everything that influences a score is pinned.\n    judge_model: str = \"gpt-4o-mini\"\n    judge_temperature: float = 0.0\n    embedding_model: str = \"text-embedding-3-small\"\n    top_k: int = 5\n\n    # Identifies the system under test for traceability.\n    prompt_version: str = \"answer-v4\"\n    retriever_version: str = \"hybrid-bm25+dense-v2\"\n\n    dataset_path: str = \"rag-evals\u002Fgolden\u002Fdataset.v3.json\"\n    baseline_path: str = \"rag-evals\u002Fbaseline\u002Fbaseline_metrics.json\"\n\n\n# Absolute floors: build fails if a metric drops below these, ever.\nHARD_FLOORS = {\n    \"faithfulness\": 0.88,\n    \"context_precision\": 0.78,\n    \"context_recall\": 0.78,\n    \"answer_relevancy\": 0.72,\n}\n\n# Drift budget: build fails if a metric drops more than this vs baseline,\n# even if still above the hard floor. Catches slow erosion.\nMAX_REGRESSION = {\n    \"faithfulness\": 0.03,\n    \"context_precision\": 0.05,\n    \"context_recall\": 0.05,\n    \"answer_relevancy\": 0.05,\n}\n\nCONFIG = EvalConfig()\n```\n\n## Running the Eval and Producing a Report\n\n```python\n# run_eval.py\nimport json\nfrom datasets import Dataset\nfrom ragas import evaluate\nfrom ragas.metrics import (\n    context_precision, context_recall, faithfulness, answer_relevancy,\n)\nfrom ragas.llms import LangchainLLMWrapper\nfrom langchain_openai import ChatOpenAI, OpenAIEmbeddings\n\nfrom config.eval_config import CONFIG\nfrom my_rag_app import rag_pipeline\n\n\ndef load_golden(path: str) -> list[dict]:\n    with open(path) as f:\n        return json.load(f)[\"samples\"]\n\n\ndef main() -> None:\n    golden = load_golden(CONFIG.dataset_path)\n    rows = {\"question\": [], \"answer\": [], \"contexts\": [], \"ground_truth\": []}\n    for s in golden:\n        out = rag_pipeline(s[\"question\"], top_k=CONFIG.top_k)\n        rows[\"question\"].append(s[\"question\"])\n        rows[\"answer\"].append(out[\"answer\"])\n        rows[\"contexts\"].append(out[\"contexts\"])\n        rows[\"ground_truth\"].append(s[\"ground_truth\"])\n\n    judge = LangchainLLMWrapper(\n        ChatOpenAI(model=CONFIG.judge_model, temperature=CONFIG.judge_temperature)\n    )\n    result = evaluate(\n        Dataset.from_dict(rows),\n        metrics=[context_precision, context_recall, faithfulness, answer_relevancy],\n        llm=judge,\n        embeddings=OpenAIEmbeddings(model=CONFIG.embedding_model),\n    )\n\n    df = result.to_pandas()\n    means = {\n        m: round(float(df[m].mean()), 4)\n        for m in [\"context_precision\", \"context_recall\", \"faithfulness\", \"answer_relevancy\"]\n    }\n    report = {\n        \"metrics\": means,\n        \"n_samples\": len(golden),\n        \"below_floor_counts\": {\n            m: int((df[m] \u003C 0.5).sum())  # count of egregious per-sample failures\n            for m in means\n        },\n        \"prompt_version\": CONFIG.prompt_version,\n        \"retriever_version\": CONFIG.retriever_version,\n        \"judge_model\": CONFIG.judge_model,\n    }\n    with open(\"report.json\", \"w\") as f:\n        json.dump(report, f, indent=2)\n    print(json.dumps(report, indent=2))\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## The Gate: Floors + Drift Detection\n\n```python\n# gate.py\nimport json\nimport sys\n\nfrom config.eval_config import CONFIG, HARD_FLOORS, MAX_REGRESSION\n\n\ndef load(path: str) -> dict:\n    with open(path) as f:\n        return json.load(f)\n\n\ndef main() -> int:\n    report = load(\"report.json\")\n    current = report[\"metrics\"]\n    baseline = load(CONFIG.baseline_path)[\"metrics\"]\n\n    failures: list[str] = []\n\n    for metric, score in current.items():\n        floor = HARD_FLOORS.get(metric)\n        if floor is not None and score \u003C floor:\n            failures.append(f\"[FLOOR]  {metric}={score:.3f} \u003C hard floor {floor:.2f}\")\n\n        base = baseline.get(metric)\n        budget = MAX_REGRESSION.get(metric)\n        if base is not None and budget is not None:\n            drop = base - score\n            if drop > budget:\n                failures.append(\n                    f\"[DRIFT]  {metric} dropped {drop:.3f} \"\n                    f\"(baseline {base:.3f} -> {score:.3f}, budget {budget:.2f})\"\n                )\n\n    if failures:\n        print(\"RAG REGRESSION DETECTED:\\n  \" + \"\\n  \".join(failures))\n        print(f\"\\nprompt={report['prompt_version']} retriever={report['retriever_version']}\")\n        return 1\n\n    print(\"RAG eval passed. No regression vs baseline.\")\n    for m, s in current.items():\n        print(f\"  {m}: {s:.3f} (baseline {baseline.get(m, float('nan')):.3f})\")\n    return 0\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n```\n\n## Updating the Baseline (Intentional Only)\n\n```python\n# update_baseline.py\n\"\"\"Run ONLY when a quality change is intended and reviewed.\nThe resulting baseline_metrics.json must be committed in the same PR.\"\"\"\nimport json\nimport shutil\n\nfrom config.eval_config import CONFIG\n\n# run_eval.py must have been run first to produce report.json\nwith open(\"report.json\") as f:\n    report = json.load(f)\n\nshutil.copy(CONFIG.baseline_path, CONFIG.baseline_path + \".bak\")\nwith open(CONFIG.baseline_path, \"w\") as f:\n    json.dump({\"metrics\": report[\"metrics\"],\n               \"prompt_version\": report[\"prompt_version\"],\n               \"retriever_version\": report[\"retriever_version\"]}, f, indent=2)\nprint(\"Baseline updated. Commit this file with a justification in the PR.\")\n```\n\n## CI Workflow (GitHub Actions)\n\n```yaml\n# .github\u002Fworkflows\u002Frag-regression.yml\nname: RAG Regression Gate\n\non:\n  pull_request:\n    paths:\n      - \"rag-evals\u002F**\"\n      - \"src\u002Fprompts\u002F**\"\n      - \"src\u002Fretriever\u002F**\"\n      - \"src\u002Frag\u002F**\"\n  workflow_dispatch:\n\nconcurrency:\n  group: rag-eval-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  rag-eval-gate:\n    runs-on: ubuntu-latest\n    timeout-minutes: 20\n    steps:\n      - uses: actions\u002Fcheckout@v4\n\n      - uses: actions\u002Fsetup-python@v5\n        with:\n          python-version: \"3.12\"\n\n      - name: Install deps\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt   # ragas, datasets, langchain-openai, etc.\n\n      - name: Run RAG evaluation\n        env:\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        run: python rag-evals\u002Frun_eval.py\n\n      - name: Gate on thresholds + drift\n        run: python rag-evals\u002Fgate.py   # non-zero exit fails the job\n\n      - name: Upload eval report\n        if: always()\n        uses: actions\u002Fupload-artifact@v4\n        with:\n          name: rag-eval-report\n          path: report.json\n\n      - name: Comment metrics on PR\n        if: always() && github.event_name == 'pull_request'\n        uses: actions\u002Fgithub-script@v7\n        with:\n          script: |\n            const fs = require('fs');\n            const r = JSON.parse(fs.readFileSync('report.json', 'utf8'));\n            const rows = Object.entries(r.metrics)\n              .map(([k, v]) => `| ${k} | ${v.toFixed(3)} |`).join('\\n');\n            const body = `### RAG Eval (\\`${r.prompt_version}\\` \u002F \\`${r.retriever_version}\\`)\\n`\n              + `| metric | score |\\n|---|---|\\n${rows}`;\n            await github.rest.issues.createComment({\n              owner: context.repo.owner, repo: context.repo.repo,\n              issue_number: context.issue.number, body,\n            });\n```\n\nThe gate runs on PRs that touch prompts, retriever, or the eval set. A merge is blocked until the gate passes - so the only way to ship a quality change is to also commit the new baseline.\n\n## Detecting Drift Over Time\n\nFor nightly scheduled runs against production traffic samples, append each run's metrics to a time series and alert on a moving-window drop:\n\n```python\n# drift_alert.py\nimport statistics\n\n\ndef detect_trend_drift(history: list[dict], metric: str, window: int = 7) -> str | None:\n    \"\"\"history: list of {date, metrics:{...}} newest last.\"\"\"\n    series = [h[\"metrics\"][metric] for h in history if metric in h[\"metrics\"]]\n    if len(series) \u003C window + 1:\n        return None\n    recent = statistics.mean(series[-3:])\n    baseline_window = statistics.mean(series[-(window + 1):-3])\n    drop = baseline_window - recent\n    if drop > 0.04:\n        return (f\"{metric} trending down: {baseline_window:.3f} -> {recent:.3f} \"\n                f\"over {window} days (drop {drop:.3f})\")\n    return None\n```\n\n## Best Practices\n\n1. **Commit the baseline; never compute it at runtime.** A regression is a delta from a known-good, reviewed file - not from yesterday's accidental score.\n2. **Gate on both a hard floor and a drift budget.** Floors catch cliffs; drift budgets catch slow erosion that stays \"green.\"\n3. **Version the golden dataset in the filename (`dataset.v3.json`).** Bumping the version is a reviewable, deliberate act.\n4. **Tag every report with prompt and retriever versions.** When the gate fails, you know exactly which artifact regressed.\n5. **Make baseline updates a separate, justified PR step.** Require a written reason in the PR description for any baseline move.\n6. **Scope the gate to RAG-relevant paths, and publish the report.** Use `paths:` to keep paid LLM-judge calls off unrelated PRs; upload `report.json` as an artifact and comment scores on the PR.\n7. **Run a nightly scheduled eval against fresh data for trend drift.** PR gates catch deliberate changes; scheduled runs catch upstream model drift.\n\n## Anti-Patterns to Avoid\n\n1. **No committed baseline.** Comparing against \"last run\" lets a slow daily 0.5% decline accumulate into a disaster, each step individually passing.\n2. **Floor-only gating.** A metric sliding from 0.95 to 0.89 (still above a 0.88 floor) is a real regression a drift budget would catch.\n3. **Editing the golden set in the same PR as a pipeline change.** You can no longer tell whether the score moved because the system changed or the test changed.\n4. **Unpinned judge or embedding model in CI.** Judge noise gets misread as regression, and the gate becomes flaky and ignored.\n5. **Deleting hard golden questions to make the build green.** That is removing the smoke detector because it keeps going off.\n6. **Silencing the gate (`continue-on-error: true`) to unblock a deadline.** A non-blocking quality gate is theater.\n\n## When to Trigger This Skill\n\nTrigger when the user asks to:\n- Add a CI gate or build check for RAG \u002F LLM answer quality\n- Detect quality drift or regression in a RAG pipeline over time\n- Set up a golden eval set with baselines and thresholds for CI\n- Fail a build when faithfulness, retrieval, or relevancy drops\n- Version prompts and retrievers for regression traceability\n- Wire Ragas\u002FDeepEval into GitHub Actions or another CI system\n\nFor the *definitions and scoring* of the underlying metrics (faithfulness, context precision\u002Frecall, answer relevancy), use the RAG Evaluation Metrics skill. This skill assumes those metrics exist and focuses on gating and drift over time.\n",{"name":5,"tags":24,"agents":34,"author":47,"domains":48,"license":15,"version":52,"languages":53,"frameworks":55,"description":7,"testingTypes":57},[25,26,27,28,29,30,31,32,33],"rag","regression-testing","llm-evals","ci","golden-dataset","drift-detection","ragas","deepeval","baseline",[35,36,37,38,39,40,41,42,43,44,45,46],"claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","gemini-cli","amp","thetestingacademy",[49,50,51],"ai","llm","api","1.0.0",[54],"python",[31,32,56],"pytest",[58,27,59],"regression","integration","main","eac438ea9216a7cb8a570cab803eb01eeafc6793","skills\u002Fqa\u002Frag-regression-testing","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m","https:\u002F\u002Fid-preview--d5bef06d-6c9e-4563-a3d4-a855b9d61610.lovable.app\u002F","Eu sou Antonio B. B. Ndombe \r\nEu sou um Pesquisador e desenvolvedor de sistema autonomia cognitivos, fundador de sistemas ODCs ( organismos digital conscientes)","2026-11-04 06:53:39",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":80},[70,73,76],{"tool":71,"command":72},"npx","npx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"RAG Regression Testing\"",{"tool":74,"command":75},"bunx","bunx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"RAG Regression Testing\"",{"tool":77,"command":78},"pnpm","pnpm dlx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"RAG Regression Testing\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Frag-regression-testing\u002FSKILL.md",true,[],[83,91,98,105,112,119],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7DASC6FSCJP49JZBSK0NY1Z","nemoclaw-user-reference","Describes the NemoClaw integration layer and blueprint architecture and how they orchestrate compatible agent sandboxes. Use when looking up architecture, agent integration, plugin structure, or blueprint design. Trigger keywords - nemoclaw architecture, nemoclaw agent architecture, nemoclaw plugin blueprint structure, nemoclaw vs openshell, which cli, nemoclaw cli, openshell cli, sandbox commands, nemoclaw cli commands, nemoclaw command reference, nemoclaw network policy, sandbox egress control operator approval, nemoclaw troubleshooting, nemoclaw debug sandbox issues.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-reference\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7DAS5S79VK33XFGVAM2TFWF","nemoclaw-user-overview","Explains how OpenClaw, OpenShell, and NemoClaw form the ecosystem, NemoClaw's position in the stack, what NemoClaw adds beyond the community sandbox, and when to prefer NemoClaw versus integrating OpenShell and OpenClaw directly. Use when users ask about the relationship between OpenClaw, OpenShell, and NemoClaw, or when to use NemoClaw versus OpenShell. Trigger keywords - nemoclaw ecosystem, openclaw openshell, nemoclaw vs openshell, sandboxed openclaw, how nemoclaw works, nemoclaw sandbox lifecycle blueprint, nemoclaw overview, openclaw always-on assistants, nvidia openshell, nvidia nemotron, nemoclaw release notes, nemoclaw changelog.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-overview\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7DAS0PQEMET5MNGZ1ABSZVS","nemoclaw-user-monitor-sandbox","Inspects sandbox health, traces agent behavior, and diagnoses problems. Use when monitoring a running sandbox, debugging agent issues, or checking sandbox logs. Trigger keywords - monitor nemoclaw sandbox, debug nemoclaw agent issues.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-monitor-sandbox\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M7DARQYGF7E9A69VH6S3CGN9","nemoclaw-user-manage-sandboxes","Explains operational tasks after the quickstart: listing sandboxes, status and health checks, logs, diagnostics, port forwards, multiple sandboxes, credential reset, rebuilds, network presets, upgrades, and uninstall. Trigger keywords - manage nemoclaw sandboxes, nemoclaw status, nemoclaw list, nemoclaw dashboard port, nemoclaw rebuild, nemoclaw upgrade sandboxes, nemoclaw uninstall, sandbox mutability, sandbox runtime configuration, sandbox rebuild, nemoclaw backup, nemoclaw restore, workspace backup, openshell sandbox download upload, nemoclaw messaging channels, nemoclaw telegram, nemoclaw discord, nemoclaw slack, nemoclaw wechat, nemoclaw whatsapp, openshell channel messaging, nemoclaw workspace files, soul.md, user.md, identity.md, agents.md, sandbox persistence.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-sandboxes\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":19},"01M7DARH8BRTG51TRCAB7YWDJ4","nemoclaw-user-manage-policy","Adds, removes, or modifies allowed endpoints in the sandbox policy. Use when customizing network policy, changing egress rules, or configuring sandbox endpoint access. Trigger keywords - customize nemoclaw network policy, sandbox egress policy configuration, nemoclaw integration policy examples, post-install policy setup, openshell approval workflow, policy preset, nemoclaw approve network requests, sandbox egress approval tui.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-policy\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":19},"01M7DARAT62M2VR37590VCZ5NS","nemoclaw-user-get-started","Installs NemoClaw, launches a sandbox, and runs the first agent prompt. Use when onboarding, installing, or launching a NemoClaw sandbox for the first time. Trigger keywords - nemoclaw quickstart, install nemoclaw openclaw sandbox, nemohermes quickstart, hermes agent nemoclaw, run hermes openshell sandbox, nemoclaw prerequisites, nemoclaw supported platforms, nemoclaw hardware software, nemoclaw windows wsl2 setup, nemoclaw install windows docker desktop.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-get-started\u002FSKILL.md",[],[]]