🪢 Langfuse 图解教程Langfuse Visual Guide 第六部分 · 数据集与实验Part 6 · Datasets & Experiments 34 / 55
第六部分 · 数据集与实验Part 6 · Datasets & Experiments

数据集与数据项Datasets & items

🧭 读前Before you start
先读 第3课 的三大支柱,本课讲数据集与数据项的结构。
Read Lesson 3 on the three pillars; this lesson covers the structure of datasets and items.

评估需要「考题」。你想知道改了 prompt、换了模型之后应用变好还是变差——就得有一套固定的测试用例反复地考它。这套测试用例,就是数据集(dataset);其中每一道题,就是一个数据项(dataset item):一份输入 + 一份期望输出。 这一课讲数据集和数据项的数据模型,重点是两个让人眼前一亮的设计:数据项可以从真实的生产 trace「提拔」成测试用例(线上遇到的难题,直接变成回归测试题),以及数据项是版本化的——改一次题留一版历史,于是「上次实验用的到底是哪版题」永远查得到。

📋 生活类比
数据集像一套标准试卷。每道题(item)有题干(input)和参考答案(expectedOutput)。出题有两种来路:你可以现编一道,也可以把线上真实遇到的、应用答砸了的难题(一条 trace)原样收录进卷子——「生产事故」就这样变成了「回归考题」。 最讲究的是改题规则:当你修订一道题,系统不会抹掉旧版,而是给旧版盖一个「有效截止」的戳、再另起一张新版。于是这道题的每一版都留着,「三月那次考试用的是哪一版题干」永远翻得出来——这对「实验要可复现」是命根子。

数据集 = 一组测试用例,题可以从生产「捡」

数据模型很直观:一个 Dataset 装着一组 DatasetItem。Dataset 有名字、描述,还能挂 inputSchema / expectedOutputSchema 给题目定个格式规范。每个 DatasetItem 的核心是三样:input(题干)、expectedOutput(参考答案)、metadata(旁注)。但真正巧妙的是另外两个字段:sourceTraceId 和 sourceObservationId——它们记着「这道题是从哪条真实 trace 来的」。

数据集装一组测试用例,题可现编也可从生产捡 Dataset(一套试卷)name · 描述 · input/expectedOutput Schema DatasetItem A(现编)input + expectedOutput手动出的题 DatasetItem Binput + expectedOutputmetadata 旁注 DatasetItem C(从生产捡)sourceTraceId → 某条真实 trace线上难题变回归题 一条生产 trace(第 13 课) 提拔 「生产即测试源」:把线上真实答砸的 case 一键收录成考题,让回归测试紧贴真实分布
题从哪来:schema.prisma:685 的 DatasetItem 有 input/expectedOutput/metadata,外加 sourceTraceId/sourceObservationId——后两者让你把一条真实 trace(第 13 课)提拔成测试用例。Dataset(:661)还能用 inputSchema/expectedOutputSchema 约束题目格式。
示例:一个数据集和它的数据项 dataset · name=support-qa · 4 items input expectedOutput metadata 退款政策是什么?30 天内可全额退款{tag: billing} ← 已被某次 run 引用 如何重置密码?设置→安全→重置{tag: account} 支持哪些语言?中/英/日/德{tag: product} 发票在哪下载?账户→账单→发票{tag: billing} 每个 item = 一道「题 + 参考答案」;run 拿 input 跑应用,再和 expectedOutput 比
数据集 = 一组「题 + 参考答案」(字段取自 domain/dataset-items.ts;值为示例):每个 item 有 input(喂给应用的输入)、expectedOutput(参考答案)、metadata。一次 run 就是拿这些 input 跑一遍当前应用,把产出和 expectedOutput 比、评分(第 35 课)。于是「改一版好不好」有了固定考卷,可复现、可对比。
题干 + 答案input / expectedOutput
一个 item 的本体:input 喂给应用的输入、expectedOutput 你期望它给出的参考答案。评估时就拿应用的真实输出和 expectedOutput 对照(或交给第 29–31 课的评判)。metadata 放标签、难度等旁注。
从生产捡sourceTraceId / sourceObservationId
这是数据集最有生命力的来源:在 trace 详情里看到一个应用答砸的真实案例,一键收录成 item,sourceTraceId 记下出处。于是你的测试集紧贴真实流量分布,而不是凭空想象的玩具题。
状态DatasetStatus
item 有 ACTIVE / ARCHIVED 两态:归档不删除、只是退出测试集,历史与关联仍在。数据集本身也能挂 schema(inputSchema/expectedOutputSchema)给新题定规矩。

一个建好的数据集能干三件大事——它是 Part 6 后两课的地基:

回归测试

改 prompt / 换模型后,把整套题重跑一遍,对照分数有没有掉——防止「修了一个 bug,带崩三个 case」。

实验对比

同一套题,用不同配置各跑一次(第 35–36 课的 run),把多次结果并排比,挑出最优组合。

few-shot 示例库

数据项的 input/expectedOutput 也能当作 prompt 里的示例(第 37 课),让模型照着标准答案的样子答。

版本化:改一次题,关旧版、开新版

数据项最精巧的设计是版本化。看主键就懂了:@@id([id, projectId, validFrom])——同一道题(同 id)可以有多行,靠 validFrom 区分版本。每行还有一个 validTo:为空(null)的那行就是当前生效版。改题时,系统在一个事务里做两步——给旧版盖上 validTo(关闭它的有效区间)、再插入一行新版。这正是数据库里经典的「缓慢变化维 / 双时态」手法。(该版本化实现由 LANGFUSE_DATASET_SERVICE_WRITE_TO/READ_FROM_VERSIONED_IMPLEMENTATION 开关控制,executeWithDatasetServiceStrategy 据此在 STATEFUL 与 VERSIONED 间切换。)

同一道题 id 的版本时间轴(validFrom → validTo) 时间 版本 1(旧)validFrom=t1 · validTo=t2 版本 2(旧)validFrom=t2 · validTo=t3 版本 3(当前)validFrom=t3 · validTo=null t1 t2 关旧·开新 t3 关旧·开新 3 月的 run 钉住 validFrom=t2
双时态版本:当前版 = validTo IS NULL 的那行。改题在事务里「关旧版(盖 validTo)+ 插新版(新 validFrom)」。一次 dataset run 钉住某个 validFrom,所以它永远看到「当时那版题」——这正是第 30 课 eval 用 datasetItemValidFrom 的原因。源码:dataset-items.ts:418-470。
packages/shared/src/server/repositories/dataset-items.ts:418-470VERSIONED 写入
// 在一个事务里:先关旧版,再插新版(缓慢变化维 Type 2)
await prisma.$transaction(async (tx) => {
  // 0. 找到当前生效版(validTo 为空的那行)
  const current = await tx.datasetItem.findFirst({
    where: { id: itemId, projectId, validTo: null }, orderBy: { validFrom: "desc" } });
  const newValidFrom = new Date(Math.max(Date.now(), baseTs + 1));

  // 1. 给旧版盖上 validTo —— 关闭它的有效区间
  if (current) await tx.datasetItem.update({ where: {…current.validFrom}, data: { validTo: newValidFrom } });

  // 2. 插入新版 —— validFrom = 刚才那个时刻,validTo 默认 null(成为新的当前版)
  await tx.datasetItem.create({ data: { ...itemData, validFrom: newValidFrom } });
});

为什么大费周章不直接「原地改」?因为实验必须可复现。你三月跑了一次实验、打了分;六月改了几道题再跑一次。如果题是「原地改」的,那三月那次的分就失去了语境——你不知道它当时考的是哪版题,两次实验根本没法公平比较。版本化把每道题的每一版都钉在时间轴上,于是「三月的 run 用的是 t2 版、六月的 run 用的是 t3 版」清清楚楚,历史结论永远可解释。

id(逻辑题)validFromvalidTo是否当前内容
item-42t1t2否(历史)题干 v1
item-42t2t3否(历史)题干 v2
item-42t3null是 ✓题干 v3(当前)

三行同一个 id、不同 validFrom,靠 validTo 是否为空区分「当前 vs 历史」。查「现在这道题长啥样」就 WHERE validTo IS NULL;查「t2 那次实验用的是啥」就找 validFrom ≤ t2 < validTo 的那行——一张表同时回答「现在」和「任意历史时刻」两个问题,这就是双时态的威力。

同一个 id 三版,靠 validTo 是否为空分「当前 vs 历史」 时间 → 题干 v1(历史) 题干 v2(历史) 题干 v3 · validTo=null ✓ 当前 t1 t2 t3 现在 查「现在」:WHERE validTo IS NULL → v3 查「t2 时刻」:validFrom ≤ t2 < validTo → v2(历史可复现)
🎯 设计取舍
为什么数据项要版本化,而不是简单地原地更新? 一句话:为了让历史实验永远可解释、可复现。评估的全部价值在于「比较」——这次比上次好还是差。但如果测试题本身会被悄悄改掉,那「上次」的分数就成了无根之木:你不知道它当时考的是什么,自然没法和「这次」公平对比。版本化用 validFrom/validTo 给每道题的每一版钉上时间区间,让每次 run 都能钉死它当时用的那一版(第 30 课 eval 取数据时正是带着 datasetItemValidFrom 精确回放)。这是「不可变历史 + 可移动当前指针」的经典思路,和第 37 课的 prompt 版本、git 的 commit 是同一种工程信念:真相一旦记录就不抹改,要变就追加新版本。

为什么要让数据项能从真实 trace「提拔」? 因为最好的测试题就藏在生产事故里。凭空想象的测试用例往往覆盖不到真实用户那些刁钻的、长尾的输入;而线上每一次应用答砸的 trace,都是一道现成的、带着真实分布的好题。sourceTraceId 让「发现问题 → 收录成回归题 → 下次改进后验证」形成闭环——观测平台不只让你看见问题,还顺手把问题变成防止它复发的「疫苗」。
🎯 本课要点
  • 数据集 = 一组测试用例:Dataset 装一组 DatasetItem,每个 item = input(题干)+ expectedOutput(参考答案)+ metadata。它是评估的「考卷」,配合第 28–32 课的 score 用。
  • 题可从生产「提拔」:sourceTraceId/sourceObservationId 让你把一条真实 trace(第 13 课)一键收录成测试用例——回归集紧贴真实流量分布,而非凭空臆造。
  • 数据项是版本化的:主键 (id, projectId, validFrom) 让同一道题多版本共存;当前版 = validTo IS NULL。改题在事务里「关旧版(盖 validTo)+ 插新版」——缓慢变化维 / 双时态。
  • 版本化是为了可复现:一次 run 钉住某个 validFrom,永远看到「当时那版题」(第 30 课 eval 用 datasetItemValidFrom 精确回放)。历史实验因此永远可解释、可公平对比。
  • 不可变历史 + 可移动指针:和第 37 课 prompt 版本、git commit 同一种信念——真相记录后不抹改,变更追加新版本。

🧪 自测 · 想一想为什么这么设计

1. Langfuse 的数据项(DatasetItem)有 sourceTraceId / sourceObservationId 字段。它们让数据集获得了什么独特能力?
  1. 把数据项存进 ClickHouse
  2. 给数据项加密
  3. 把真实生产 trace「提拔」成测试用例:在线上发现应用答砸的难题,一键收录成回归题,让测试集紧贴真实流量分布而非凭空臆造
  4. 让数据项自动评分
看答案与解析 点击展开
答案:C。sourceTraceId/sourceObservationId 记下「这道题从哪条真实 trace 来」。凭空想象的测试用例覆盖不到真实长尾输入,而线上每次答砸的 trace 都是现成好题。于是「发现问题→收录成回归题→改进后验证」闭环——观测平台顺手把生产问题变成防复发的疫苗。
2. DatasetItem 的主键是 (id, projectId, validFrom),每行还有一个 validTo。当你修订一道题时,系统怎么做?
  1. 只改 updatedAt 时间戳
  2. 在一个事务里:给旧版盖上 validTo(关闭其有效区间),再插入一行新版(新 validFrom、validTo 为空成为当前版)——缓慢变化维 / 双时态,不抹改历史
  3. 删除旧行再建新行
  4. 原地更新那一行
看答案与解析 点击展开
答案:B。dataset-items.ts 的 VERSIONED 写入:事务里先找当前版(validTo IS NULL),给它盖 validTo=newValidFrom 关闭区间,再 create 一行新版 validFrom=newValidFrom(validTo 默认 null)。于是同一道题多版本共存、当前版 = validTo 为空那行。这是经典的不可变历史 + 可移动当前指针。
3. 为什么数据项要这样版本化,而不是简单地原地更新?
  1. 为了加快查询
  2. 为了实验可复现:一次 run 钉住某个 validFrom,永远看到「当时那版题」;否则历史实验的分数会失去语境,两次实验无法公平对比(第30课 eval 正是用 datasetItemValidFrom 精确回放)
  3. 为了节省存储
  4. 为了支持并发写
看答案与解析 点击展开
答案:B。评估的价值在比较。若题被原地改,「上次」的分就失去语境——不知道当时考的是什么,没法和「这次」公平比。版本化给每道题每版钉上时间区间,让每次 run 钉死它用的那版(第30课 eval 带 datasetItemValidFrom 精确回放)。这和第37课 prompt 版本、git commit 同一种「真相记录后不抹改」的信念。
💭 发散思考(没有标准答案,动手或动脑想想)
  • 数据集把「生产 trace」和「测试用例」用 sourceTraceId 连了起来,又用版本化保证实验可复现。设想你在维护一个客服机器人:你会怎么用这两个机制构建一套「持续改进」的回归测试流程?哪些线上 case 值得提拔成数据集?什么时候该给一道题升新版而不是新建一道题?

Evaluation needs "exam questions". To know whether your app got better or worse after you changed a prompt or swapped a model, you need a fixed set of test cases to quiz it on repeatedly. That set is a dataset; each question in it is a dataset item: one input + one expected output. This lesson covers the data model of datasets and items, focusing on two delightful designs: an item can be "promoted" from a real production trace into a test case (a hard case you hit in production becomes a regression test), and items are versioned—editing a question keeps a version of history, so "which version of the question did last experiment use" is always answerable.

📋 Analogy
A dataset is like a standard exam paper. Each question (item) has a prompt (input) and a reference answer (expectedOutput). Questions come two ways: you can write one, or you can capture verbatim a real, botched case from production (a trace) into the paper—a "production incident" thus becomes a "regression question". The most careful part is the edit rule: when you revise a question, the system does not erase the old version—it stamps the old one with a "valid-until" and starts a new version. So every version of the question is kept, and "which version of the prompt did the March exam use" is always retrievable—lifeblood for "experiments must be reproducible".

A dataset = a set of test cases, and questions can be "picked" from production

The data model is intuitive: a Dataset holds a set of DatasetItems. A Dataset has a name, a description, and can attach inputSchema / expectedOutputSchema to give questions a format spec. Each DatasetItem's core is three things: input (the prompt), expectedOutput (the reference answer), metadata (side notes). But the truly clever fields are two others: sourceTraceId and sourceObservationId—they record "which real trace this question came from".

a dataset holds test cases; questions authored or picked from production Dataset (an exam paper)name · description · input/expectedOutput Schema DatasetItem A (authored)input + expectedOutputhand-written question DatasetItem Binput + expectedOutputmetadata side notes DatasetItem C (from production)sourceTraceId → a real traceproduction hard case → regression q a production trace (Lesson 13) promote "production as test source": capture a real botched case into a question, keeping regression tests close to the real distribution
Where questions come from: schema.prisma:685's DatasetItem has input/expectedOutput/metadata, plus sourceTraceId/sourceObservationId—the latter let you promote a real trace (Lesson 13) into a test case. A Dataset (:661) can also constrain question format via inputSchema/expectedOutputSchema.
Example: a dataset and its items dataset · name=support-qa · 4 items input expectedOutput metadata what is the refund policy?full refund within 30 days{tag: billing} ← referenced by a run how to reset password?Settings → Security → Reset{tag: account} which languages?zh/en/ja/de{tag: product} where to download invoices?Account → Billing → Invoices{tag: billing} each item = a question + reference answer; a run feeds input to the app, then compares to expectedOutput
A dataset = a set of "question + reference answer" (fields from domain/dataset-items.ts; values illustrative): each item has input (fed to the app), expectedOutput (the reference), and metadata. A run feeds these inputs through the current app and compares the output to expectedOutput, scoring it (Lesson 35). So "is this revision better" gets a fixed exam — reproducible and comparable.
prompt + answerinput / expectedOutput
An item's body: input is fed to the app, expectedOutput is the reference answer you expect. Evaluation compares the app's real output against expectedOutput (or hands it to Lessons 29–31's judges). metadata holds tags, difficulty, and other notes.
from productionsourceTraceId / sourceObservationId
The dataset's most vital source: spotting a real botched case in a trace detail, you capture it in one click as an item, with sourceTraceId recording its origin. So your test set hugs the real traffic distribution, not imagined toy questions.
statusDatasetStatus
An item is ACTIVE / ARCHIVED: archiving doesn't delete—it just retires the item from the test set, keeping history and links. The dataset itself can attach a schema (inputSchema/expectedOutputSchema) to set rules for new questions.

A built dataset can do three big things—it's the foundation for the next two lessons of Part 6:

regression testing

After changing a prompt / swapping a model, re-run the whole set and check whether scores dropped—preventing "fix one bug, break three cases".

experiment comparison

The same set, run once per config (Lessons 35–36's runs), with multiple results placed side by side to pick the best combination.

few-shot example bank

An item's input/expectedOutput can also serve as examples in a prompt (Lesson 37), letting the model answer in the shape of the reference answers.

Versioning: edit a question by closing the old version, opening a new

An item's most refined design is versioning. The primary key says it all: @@id([id, projectId, validFrom])—the same question (same id) can have multiple rows, distinguished by validFrom. Each row also has a validTo: the row where it's null is the currently active version. On edit, the system does two steps in a transaction—stamp the old version with validTo (close its validity interval), then insert a new version row. This is the database's classic "slowly-changing dimension / bitemporal" technique. (The versioned implementation is gated by LANGFUSE_DATASET_SERVICE_WRITE_TO/READ_FROM_VERSIONED_IMPLEMENTATION; executeWithDatasetServiceStrategy switches between STATEFUL and VERSIONED accordingly.)

version timeline of one question id (validFrom → validTo) time version 1 (old)validFrom=t1 · validTo=t2 version 2 (old)validFrom=t2 · validTo=t3 version 3 (current)validFrom=t3 · validTo=null t1 t2 close+open t3 close+open March's run pins validFrom=t2
Bitemporal versions: the current version = the row with validTo IS NULL. An edit, in a transaction, "closes the old version (stamps validTo) + inserts a new version (new validFrom)". A dataset run pins a validFrom, so it always sees "that version of the question"—exactly why Lesson 30's eval uses datasetItemValidFrom. Source: dataset-items.ts:418-470.
packages/shared/src/server/repositories/dataset-items.ts:418-470VERSIONED write
// in one transaction: close the old version, then insert the new (SCD Type 2)
await prisma.$transaction(async (tx) => {
  // 0. find the current version (the row with validTo null)
  const current = await tx.datasetItem.findFirst({
    where: { id: itemId, projectId, validTo: null }, orderBy: { validFrom: "desc" } });
  const newValidFrom = new Date(Math.max(Date.now(), baseTs + 1));

  // 1. stamp the old version with validTo — close its validity interval
  if (current) await tx.datasetItem.update({ where: {…current.validFrom}, data: { validTo: newValidFrom } });

  // 2. insert the new version — validFrom = that moment, validTo defaults null (the new current)
  await tx.datasetItem.create({ data: { ...itemData, validFrom: newValidFrom } });
});

Why go to all this trouble instead of editing in place? Because experiments must be reproducible. You ran an experiment in March and got scores; in June you tweaked a few questions and ran again. If questions were "edited in place", March's scores would lose their context—you wouldn't know which version they tested, and the two experiments couldn't be compared fairly. Versioning pins every version of every question on a timeline, so "March's run used version t2, June's used t3" is crystal clear, and historical conclusions stay forever explainable.

id (logical question)validFromvalidTocurrent?content
item-42t1t2no (history)prompt v1
item-42t2t3no (history)prompt v2
item-42t3nullyes ✓prompt v3 (current)

Three rows with the same id, different validFrom, distinguished as "current vs history" by whether validTo is null. To ask "what does this question look like now", WHERE validTo IS NULL; to ask "what did the t2 experiment use", find the row where validFrom ≤ t2 < validTo—one table answers both "now" and "any historical moment", the power of bitemporal.

same id, three versions; current vs history by whether validTo is null time → question v1 (history) question v2 (history) question v3 · validTo=null ✓ current t1 t2 t3 now ask "now": WHERE validTo IS NULL → v3 ask "at t2": validFrom ≤ t2 < validTo → v2 (reproducible history)
🎯 Design trade-off
Why version dataset items rather than simply update in place? In a phrase: to keep historical experiments forever explainable and reproducible. The whole value of evaluation is "comparison"—is this better or worse than last time. But if the test questions are silently edited, "last time"'s score becomes rootless: you don't know what it tested, and can't fairly compare with "this time". Versioning uses validFrom/validTo to pin a time interval on every version of every question, letting each run pin the version it used (Lesson 30's eval replays exactly via datasetItemValidFrom). It's the classic "immutable history + a movable current pointer", the same belief as Lesson 37's prompt versions and git commits: once truth is recorded it's not erased; to change, append a new version.

Why let items be "promoted" from real traces? Because the best test questions hide in production incidents. Imagined test cases rarely cover the tricky, long-tail inputs real users throw; whereas every botched production trace is a ready-made, real-distribution question. sourceTraceId closes the loop "find a problem → capture it as a regression question → verify after improving"—an observability platform not only lets you see problems but turns them into "vaccines" against recurrence.
🎯 Key points
  • A dataset = a set of test cases: a Dataset holds DatasetItems, each = input (prompt) + expectedOutput (reference answer) + metadata. It's the "exam paper" for evaluation, used with Lessons 28–32's scores.
  • Questions can be "promoted" from production: sourceTraceId/sourceObservationId let you capture a real trace (Lesson 13) into a test case in one click—the regression set hugs the real traffic distribution, not made-up cases.
  • Items are versioned: the key (id, projectId, validFrom) lets many versions of one question coexist; the current = validTo IS NULL. An edit, in a transaction, "closes the old (stamps validTo) + inserts the new"—slowly-changing dimension / bitemporal.
  • Versioning is for reproducibility: a run pins a validFrom, always seeing "that version" (Lesson 30's eval replays via datasetItemValidFrom). Historical experiments stay explainable and fairly comparable.
  • Immutable history + a movable pointer: the same belief as Lesson 37's prompt versions and git commits—record truth without erasing it; append a new version to change.

🧪 Self-test - think about the design

1. Langfuse's DatasetItem has sourceTraceId / sourceObservationId fields. What unique capability do they give datasets?
  1. storing items in ClickHouse
  2. encrypting items
  3. promoting a real production trace into a test case: spot a botched hard case in production, capture it as a regression question in one click, keeping the test set close to the real traffic distribution rather than imagined
  4. auto-scoring dataset items
Show answer & explanation click to expand
Answer: C. sourceTraceId/sourceObservationId record which real trace a question came from. Imagined test cases miss real long-tail inputs, while every botched production trace is a ready-made question. This closes the loop 'find a problem → capture as regression question → verify after improving'—the platform turns production problems into vaccines against recurrence.
2. A DatasetItem's primary key is (id, projectId, validFrom), and each row has a validTo. When you revise a question, what does the system do?
  1. only changes the updatedAt timestamp
  2. in a transaction: stamp the old version with validTo (close its validity interval), then insert a new version row (new validFrom, validTo null becoming current)—slowly-changing dimension / bitemporal, not erasing history
  3. deletes the old row then creates a new one
  4. updates that row in place
Show answer & explanation click to expand
Answer: B. dataset-items.ts VERSIONED write: in a transaction, find the current version (validTo IS NULL), stamp it with validTo=newValidFrom to close its interval, then create a new row with validFrom=newValidFrom (validTo defaults null). So many versions of one question coexist, the current being the validTo-null row. Classic immutable history + a movable current pointer.
3. Why version dataset items this way rather than simply updating in place?
  1. to speed up queries
  2. for reproducibility: a run pins a validFrom and always sees 'that version of the question'; otherwise historical scores lose their context and two experiments can't be fairly compared (Lesson 30's eval replays exactly via datasetItemValidFrom)
  3. to save storage
  4. to support concurrent writes
Show answer & explanation click to expand
Answer: B. Evaluation's value is comparison. If a question is edited in place, 'last time'\'s score loses context—you don't know what it tested, can't fairly compare with 'this time'. Versioning pins a time interval on every version, letting each run pin the version it used (Lesson 30's eval replays via datasetItemValidFrom). Same 'record truth without erasing' belief as Lesson 37's prompt versions and git commits.
💭 Open questions (no single right answer - just think or try)
  • Datasets link 'production traces' and 'test cases' via sourceTraceId, and use versioning to keep experiments reproducible. Imagine maintaining a customer-service bot: how would you use these two mechanisms to build a 'continuous improvement' regression-test flow? Which production cases are worth promoting into a dataset? When should you version-up a question rather than create a new one?