# FDE 项目实战：维修工单实验步骤、运行结果与展示清单

> 从起步包运行 FDE 项目，按方法与结果找到准确测试和排查入口，区分资料与批准状态；提供独立英文 quick start、材料核验和 .mjs 文件运行步骤，并保留验证边界。

原文：https://cs-wude-fde-learning.pages.dev/projects/
维护者：[wude](https://cs-wude-fde-learning.pages.dev/about/)
内容更新：2026-11-05

## LAB–01：先解决一个很小的问题

一位维修人员输入设备型号和工单编号，系统找出其有权查看的有效手册。资料不足时不猜测，危险操作不自动执行。这是本站贯穿练习的**虚构场景**，设备与工单均为合成数据。

先不做聊天界面。先保证同一个输入、同一版数据和同一个身份，能得到可解释的结果。

## 手里的维修数据适合做哪个实验？

先看你能拿出什么输入。只有一段报修描述，可以先练分流；已经拿到助手填好的工单，就要连同报修原话一起核对。下面三个入口都用公开的合成数据。在装有 Node.js 22 或更新版本的电脑上，选一行，从该行的材料开始即可。

| 手里的输入 | 先做哪件事 | 第一份结果 |
| --- | --- | --- |
| 报修人发来的短文，还没选队列 | [按原单 ID 给十二张单分流](https://cs-wude-fde-learning.pages.dev/course/week-10-evaluation-contract/#repair-intake-scoring) | 保存逐单预测和评分报告，能指出哪三张被规则送错队列。 |
| 报修原文和已经填好的字段 | [对照原句检查五个字段](https://cs-wude-fde-learning.pages.dev/course/week-10-evaluation-contract/#%E6%8A%A5%E4%BF%AE%E5%8E%9F%E6%96%87%E8%BD%AC%E6%88%90-json-%E5%90%8E%E6%80%8E%E6%A0%B7%E6%A3%80%E6%9F%A5%E6%AF%8F%E4%B8%AA%E5%AD%97%E6%AE%B5) | 保存字段报告，能区分已否认的异常、缺失的读数和抄自别单的值。 |
| 工单号、测试身份和一本有版本的手册 | [下载起步包并运行](https://cs-wude-fde-learning.pages.dev/projects/#%E4%B8%8B%E8%BD%BD%E5%B9%B6%E8%BF%90%E8%A1%8C) | 运行 `node demo.mjs`，对照同一张单在两种身份下返回的手册版本或拒绝结果。 |

**跟一张单做选择。** 打开[同批来单](https://cs-wude-fde-learning.pages.dev/downloads/repair-intake/tickets.json)，找到 R05。它提到手册中的“漏油”，同时说“我只需要那页资料，现场没有异常”。同一段话可以回答两种不同的问题。

- 想知道“这张单送给谁”，把来单、[分流脚本](https://cs-wude-fde-learning.pages.dev/downloads/repair-intake/triage.mjs)和[参考队列](https://cs-wude-fde-learning.pages.dev/downloads/repair-intake/reference.json)存到同一空目录。先运行 `node triage.mjs example tickets.json predictions.json`，再运行 `node triage.mjs score tickets.json reference.json predictions.json routing-report.json`。打开报告的 `mistakes`，找到 R05，比较规则预测的“设备报修”和原文支持的“资料请求”。
- 想知道“助手填写的现场异常是否有依据”，把来单、[候选字段](https://cs-wude-fde-learning.pages.dev/downloads/field-review/candidate.json)和[字段复核脚本](https://cs-wude-fde-learning.pages.dev/downloads/field-review/review.mjs)存到另一空目录。运行 `node review.mjs tickets.json candidate.json field-report.json`。示范候选有错，脚本写出报告后以状态码 1 退出。打开 `reviews` 中 R05 的 `siteAbnormal`，找出为什么 `true` 应改为 `false`，并圈出能支持纠正的原句。

如果你能改对 R05 的队列，再检查那条错误的现场异常是否也随之纠正。两次检查各读自己的候选文件，各留一份报告。读完分支课程，用浏览器返回这里，或在项目目录中选择“手里的维修数据适合做哪个实验？”，可以沿同一张工单走另一条路径。

## English project brief: maintenance work-order lab

This small learning project uses synthetic equipment, work orders, manuals, and workshop identities. A technician needs to find a manual that matches the equipment, date, and access rules. The starter is a deterministic business core for practicing FDE delivery decisions. It is not a complete AI application or a predictive maintenance platform, and it never connects to real equipment or work-order systems.

Use Node.js 22 or newer. [Download the starter ZIP](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab.zip) or inspect the [readable README](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/README.md) and source files: [business core](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/lab.mjs), [behavior tests](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/lab.test.mjs), and [demo](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/demo.mjs). Extract it and open a terminal in the directory containing `README.md`, `lab.mjs`, `lab.test.mjs`, and `demo.mjs`. No dependency installation, service account, or model API key is needed for this starter. Run:

```bash
node --version
node --test lab.test.mjs
node demo.mjs
```

The tutorial, README, and demonstration labels are in Chinese; inspect these output fields alongside the Chinese instructions below:

- The allowed query returns `status: 'found'`, with manual `MAN-01` at `version: 2`.
- A cross-workshop query and an ordinary technician's write-preview request return `status: 'denied'`.
- After approval, closure returns `status: 'closed'` and `revision: 2`. Repeating confirmation of that same successful preview returns the same `operationId`, with the revision still `2`.

The starter has no LLM integration, RAG retrieval, MCP transport, HTTP service, graphical interface, persistent storage, or production authentication. Fixed sessions are teaching fixtures. Build and test extensions separately; do not present planned features as implemented. Save actual commands, versions, test results, and failure examples in your [delivery portfolio](https://cs-wude-fde-learning.pages.dev/portfolio/). Passing these exercises does not establish production readiness, job qualification, or measured business benefits.

For lesson snippets, see [save and run one .mjs file](https://cs-wude-fde-learning.pages.dev/projects/#run-lesson-file). Keep each original lesson block in a separate file.

<h3 id="english-quick-start" lang="en" tabindex="-1">English quick start: verify and run locally</h3>

This is a local exercise with synthetic work orders and manuals. It needs Node.js 22 or newer, with no package installation, service account, or model API key. The README, demo labels and most lessons are in Chinese. This quick start gives the complete file-verification and saved-file steps in English.

For a separate Python exercise in English, [check whether the reported error covers a repair costing 5,000](https://cs-wude-fde-learning.pages.dev/course/week-10-evaluation-contract/#work-order-cost-error). You can read the saved evaluation without installing the model. The surrounding Week 10 lesson is in Chinese.

If pressure keeps arriving but temperature goes quiet, [replay both pump alert scopes and save a handoff](https://cs-wude-fde-learning.pages.dev/course/week-16-task-observability/#pump-reading-gaps). This English exercise runs offline with Python.

For repair scheduling, [check whether a repair fits inside one maintenance window](https://cs-wude-fde-learning.pages.dev/course/week-13-read-only-mcp/#fit-repair-window). The English exercise uses a public shift calendar and saves the eligible window IDs for a planner.

#### 1. Save the seven matching materials

Download the [original four-file ZIP](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab.zip), the [material manifest](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab-manifest.json), and the [standalone offline verifier](https://cs-wude-fde-learning.pages.dev/downloads/verify-lab-materials.mjs). To inspect the files first, [preview the manifest](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab-manifest.json) or [read the verifier source](https://cs-wude-fde-learning.pages.dev/downloads/verify-lab-materials.mjs). Record the download times and keep the original filenames. Extract the ZIP into a new directory, then place the original downloaded ZIP, manifest, and verifier beside the four extracted files:

```text
one-directory/
  README.md
  lab.mjs
  lab.test.mjs
  demo.mjs
  workorder-lab.zip
  workorder-lab-manifest.json
  verify-lab-materials.mjs
```

Do not replace the original ZIP with a newly compressed archive. Save the linked files themselves, not an HTML page or Markdown fences. Existing personal exercises may stay in this directory: the verifier ignores additional files and does not delete or overwrite them. It checks only the four fixed basenames and the original ZIP against the selected manifest; it requires the strict v1 manifest schema and the four fixed basenames, accepts regular files, rejects stable symbolic links, and limits the manifest to 8 KiB, each source file to 1 MiB, and the ZIP to 4 MiB. Do not edit or synchronize materials while it is reading them.

#### 2. Verify bytes offline

Open a terminal in that directory. First confirm that `node --version` reports Node.js 22 or newer, then run:

```text
node --version
node verify-lab-materials.mjs
```

Only a valid manifest and matching bytes for all four files **and the ZIP itself** produce these six lines and exit code 0:

```text
PASS README.md
PASS lab.mjs
PASS lab.test.mjs
PASS demo.mjs
PASS workorder-lab.zip
PASS selected-manifest-bytes
```

A difference fails with exit code 1 and a fixed diagnostic, for example `FAIL file-mismatch lab.mjs`, `FAIL archive-mismatch workorder-lab.zip`, `FAIL missing workorder-lab.zip`, or `FAIL manifest-schema`. Keep the original files, selected manifest, download times, and failure output. These latest links can change, and separate requests or caches can temporarily deliver mismatched publication materials. Obtain a matching set in another new directory; do not overwrite your work, edit expected hashes, regenerate the manifest to fit changed files, or bypass a failure. The verifier does not fetch updates or repair inputs.

Byte equality is relative to the saved manifest. The same-site manifest and verifier are not a signature or an independent trust anchor; a match does not prove source authenticity, code safety, business-test success, independent handoff, or deployment readiness. This path has been executed on the maintainer's local Node.js environment, not verified on Windows, PowerShell, or CMD machines. Platform file checks do not guarantee protection against malicious concurrent replacement.

#### 3. Save one read-only exercise as a new module

In a text editor, create an unused `lesson-check.mjs` in the same directory and save it as UTF-8. If that name already exists, choose another unused `.mjs` name and change the run command to match. Never overwrite `lab.mjs`, the original files, or a previous exercise. Check the actual extension: it must not be `.mjs.txt`.

Copy only the complete JavaScript below. Do not copy the Markdown fences, language labels, terminal prompts such as `$` or `PS>`, or any Bash heredoc wrapper. Run it from the system terminal, not the Node interactive REPL. Each original lesson block belongs in a separate new file; combining blocks can duplicate imports or constants. Keep the original block's identities, dates, and assertions when converting other lessons.

```javascript
import assert from 'node:assert/strict';
import { createLab, fixtures } from './lab.mjs';
const lab = createLab();
const result = lab.query('tech-a', 'T-101');
assert.deepEqual(result, { status: 'found', sources: [fixtures.manuals[0]] });
assert.equal(result.sources.length, 1);
assert.equal(result.sources[0].id, 'MAN-01');
assert.equal(result.sources[0].version, 2);
assert.deepEqual(lab.query('tech-b', 'T-101'), { status: 'denied' });
console.log('query found MAN-01 v2');
console.log('cross-workshop denied');
```

Run the file with this separate command, substituting your filename if you chose a different one:

```text
node lesson-check.mjs
```

The exact ASCII output is:

```text
query found MAN-01 v2
cross-workshop denied
```

These assertions check one allowed query and one complete cross-workshop rejection. They do not run all sixteen business tests or the other lessons. The new exercise file is not added to the original four-file ZIP. The starter still has no LLM, RAG retrieval, MCP transport, HTTP service, real authentication, or persistent production workflow; these commands do not establish any of those capabilities or measured business benefits. When you can reproduce both outcomes, [save your first contribution record](https://cs-wude-fde-learning.pages.dev/portfolio/#first-contribution-record) and keep the supplied test separate from your own changes.

<h3 id="assetops-suite-choice" lang="en" tabindex="-1">Which AssetOpsBench profile contains my work-order scenarios?</h3>

Before you set up an agent, pick the scenario IDs you want to practice. Suppose your handoff asks for work-order suite entry `wosr:10` and failure-mode entry `fmea:9001`. IBM’s Mini profile lists both. Lite has ten WOSR entries to Mini’s nine, yet they share **no WOSR IDs**. Switching to Lite would drop your chosen work-order entry.

1. Save IBM’s pinned [mini.yaml](https://raw.githubusercontent.com/IBM/AssetOpsBench/e844f6468c6c68b328022e7ca8e31da140842cc7/benchmarks/scenario_suite/mini.yaml) and [lite.yaml](https://raw.githubusercontent.com/IBM/AssetOpsBench/e844f6468c6c68b328022e7ca8e31da140842cc7/benchmarks/scenario_suite/lite.yaml) in a new folder. Keep their raw bytes. Add the [offline profile checker](https://cs-wude-fde-learning.pages.dev/downloads/assetops-suite-choice.py) ([read the Python source](https://cs-wude-fde-learning.pages.dev/downloads/assetops-suite-choice.py)). It uses Python 3.9+ and its standard library.
2. Run these commands from that folder. The first checks the handoff. The second asks for a different work-order ID while keeping the failure-mode entry.

```text
python3 assetops-suite-choice.py choice.json wosr:10 fmea:9001
python3 assetops-suite-choice.py mixed.json wosr:11 fmea:9001
```

3. In `choice.json`, check `targets` and the original IDs under `group_differences`. The FMEA IDs unique to Mini are 9001, 9003 and 9027. In `mixed.json`, Lite contains 11 in WOSR and Mini contains 9001 in FMEA, so **neither single profile covers both**. Give your partner the report and say which target would be left out. To check your own IDs, change the pairs and use a fresh output filename. An ID absent from both lists stays unlisted.

These files select scenarios at IBM revision `e844f646`. To run one later, obtain the matching scenario directory with its question and input manifest. Evaluation also requires its ground truth. This check reads two lists offline. It creates no trajectories or model scores. [IBM’s suite and execution guide](https://github.com/IBM/AssetOpsBench/blob/e844f6468c6c68b328022e7ca8e31da140842cc7/benchmarks/scenario_suite/README.md) · [IBM repository license, Apache 2.0](https://github.com/IBM/AssetOpsBench/blob/e844f6468c6c68b328022e7ca8e31da140842cc7/LICENSE)

## 下载并运行

这个起点面向已经会基本编程、能使用终端的读者。“从零做项目”指从一个新实验开始，不包含编程零基础课程。第一轮目标是把查询、拒绝和批准三种行为运行并解释清楚，之后再选择是否扩展 AI 功能。

1. [下载维修工单实验起步包 ZIP](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab.zip)，解压到自己的练习目录。
2. 打开终端，进入同时包含 `README.md`、`lab.mjs`、`lab.test.mjs` 和 `demo.mjs` 的目录。解压工具可能额外套一层同名目录，以这四个文件实际所在位置为准。
3. 运行 `node --version`，确认使用 Node.js 22 或更新版本，再执行测试和演示：

```bash
node --version
node --test lab.test.mjs
node demo.mjs
```

不需要安装依赖、注册服务或填写 API Key。你也可以直接查看 [本站可读 README](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/README.md)、[业务核心 lab.mjs](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/lab.mjs)、[行为测试 lab.test.mjs](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/lab.test.mjs)和[演示 demo.mjs](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/demo.mjs)，这四份可读文件与 ZIP 都从同一实验源码生成，可对照下载文件核查实现；网页入口用于阅读，运行时仍请解压完整起步包。第一轮不需要启动整个 Astro 学习网站。

需要与发布方选定基准比较下载材料时，按[第 8 周的清单与离线校验步骤](https://cs-wude-fde-learning.pages.dev/course/week-08-repeatable-deployment/#verify-materials)另存侧车文件；原 ZIP 仍只有四件，字节校验与实际运行分别记录。

### 运行成功后，具体看哪些输出？

当前 `lab.test.mjs` 有 16 个行为用例。先确认测试汇总全部通过，再按下面的字段核对 `node demo.mjs` 输出；终端的排版会随 Node.js 版本不同而变化。

| 演示标签 | 应当看到什么 | 说明了哪条规则 |
| --- | --- | --- |
| 正常查询 | `status: 'found'`；来源包含 `id: 'MAN-01'`、`version: 2` | 取得当前任务适用的手册，并保留资料身份 |
| 跨车间拒绝 | `status: 'denied'` | B 车间用户不能读取 A 车间工单 |
| 普通角色无法预览写入 | `status: 'denied'` | 能查询不代表有权关闭工单 |
| 批准前 | `state: 'open'`、`revision: 1` | 生成预览没有提前修改业务状态 |
| 批准后 | `status: 'closed'`、`revision: 2` | 经批准后才执行这一次关闭 |
| 重复确认 | 与上一次相同的 `operationId`，`revision` 仍为 `2` | 同一成功预览重试，不再修改一次版本 |

预览 ID、操作 ID 和过期时间在不同运行中会变化，不要照抄固定值判断成功。演示输出里的 `denied` 是故意展示的正确拒绝；是否正常应结合输入身份和对应断言判断。

如果原工单已经关闭，接手时只拿到了工单副本和原预览 ID，可以继续做[三实例核对练习](https://cs-wude-fde-learning.pages.dev/projects/#state-only-rebuild)。

### 第一次运行遇到问题

| 现象 | 先检查什么 |
| --- | --- |
| 找不到 `node` 命令 | Node.js 是否已安装，当前终端能否执行 `node --version`；安装后重新打开终端再核对 |
| 找不到 `demo.mjs` 或 `lab.test.mjs` | 当前目录是否确实含有起步包的四个文件，避免停在外层解压目录 |
| 测试失败，但还没改过代码 | 保存 Node.js 版本和完整失败输出，在新目录解压原始起步包对照；不要用截图代替报错文字 |
| 演示没有网页或聊天窗口 | 当前交付是终端实验。HTTP 接口、界面、模型和 MCP 传输层都需要另行实现 |

运行后先保存命令、版本和结果。下面的范围表用于区分起步包已实现的行为与后续扩展任务。

| 已实现 | 故意没有实现 |
| --- | --- |
| 工单与手册的规则匹配 | LLM 回答和向量检索 |
| 可信测试会话、角色与车间隔离 | 生产登录系统、完整租户系统 |
| 缺失、过期、冲突与越权处理 | 真实设备操作或维修决策 |
| 写操作预览、身份与参数绑定、有效期 | MCP 传输层与真实业务集成 |
| 批准后关闭模拟工单、重复请求去重 | 数据库持久化、跨进程并发与生产审计 |

它是确定性业务核心的实验，不是可直接上线的维修平台，也不是已经完成的 MCP Server。

## 看到这个结果，下一步查哪里？

先记下**哪个方法**返回了什么，不只抄一个 `denied`。下表链接到现有课程的具体证据入口；状态本身不能替代输入、身份、版本和原操作记录。它不是新错误处理 API。

| 方法与结果 | 已知与不能推断 | 现有证据入口 | 具体下一步 |
| --- | --- | --- | --- |
| `query / found` | 找到唯一可见适用来源；不证明回答忠实、维修完成或可以关单 | [成功响应与展示字段](https://cs-wude-fde-learning.pages.dev/course/week-07-frontline-task-permissions/#%E6%9F%A5%E8%AF%A2%E6%88%90%E5%8A%9F%E5%90%8E%E4%B9%9F%E8%A6%81%E6%98%8E%E7%A1%AE%E5%B1%95%E7%A4%BA%E5%93%AA%E4%BA%9B%E5%AD%97%E6%AE%B5) | 核对来源 ID、版本和展示合同，再单独判断原问题是否有依据 |
| `query / denied` | 身份、工单或车间授权未通过；不能定位唯一原因或据此判断资源存在性 | [未知身份、未知工单与跨车间完整响应](https://cs-wude-fde-learning.pages.dev/course/week-07-frontline-task-permissions/#%E4%B8%8D%E5%8F%AA%E6%A3%80%E6%9F%A5%E7%8A%B6%E6%80%81%E6%96%AD%E8%A8%80%E5%AE%8C%E6%95%B4%E5%93%8D%E5%BA%94) | 对照允许的测试身份和范围复现；不要靠枚举 ID 或自报角色排查 |
| `query / unavailable` | 没有可见且适用的资料；不等于程序崩溃，也不能据此说所有资料都不存在 | [无可见手册的完整响应](https://cs-wude-fde-learning.pages.dev/course/week-07-frontline-task-permissions/#%E4%B8%8D%E5%8F%AA%E6%A3%80%E6%9F%A5%E7%8A%B6%E6%80%81%E6%96%AD%E8%A8%80%E5%AE%8C%E6%95%B4%E5%93%8D%E5%BA%94) | 核对型号、日期与可见规则；按[故障证据分类](https://cs-wude-fde-learning.pages.dev/course/week-11-retrieval-baseline/#%E7%94%A8%E8%AF%81%E6%8D%AE%E5%86%B3%E5%AE%9A%E6%95%85%E9%9A%9C%E5%9C%A8%E5%93%AA%E4%B8%80%E5%B1%82)区分缺失和误过滤，必要时交有权资料负责人复核 |
| `query / conflict` | 多条资料同时适用；不能擅选第一条或最高版本 | [无资料与版本冲突的可运行片段](https://cs-wude-fde-learning.pages.dev/course/week-05-deterministic-vertical-slice/#%E7%9B%B4%E6%8E%A5%E5%A4%8D%E7%8E%B0%E6%97%A0%E8%B5%84%E6%96%99%E4%B8%8E%E7%89%88%E6%9C%AC%E5%86%B2%E7%AA%81) | 保留冲突来源身份和适用条件，复核版本治理；不要随意删资料掩盖冲突 |
| `previewClose / denied` | 未通过写权限或资源范围检查；能读不等于能创建写预览 | [写授权与预览状态](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#%E6%8C%89%E5%AE%9E%E9%99%85%E6%A3%80%E6%9F%A5%E9%A1%BA%E5%BA%8F%E8%AF%BB%E7%8A%B6%E6%80%81%E8%BD%AC%E7%A7%BB) | 核对可信身份及该动作的写权限，不把查询成功或界面按钮当作批准 |
| `confirmClose / denied` | 预览未知、重新授权失败或具体 actor 不符；不能推断工单存在性 | [确认时的授权与 actor 检查](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#%E6%8C%89%E5%AE%9E%E9%99%85%E6%A3%80%E6%9F%A5%E9%A1%BA%E5%BA%8F%E8%AF%BB%E7%8A%B6%E6%80%81%E8%BD%AC%E7%A7%BB) | 核对已保存的原预览上下文与操作者；同角色换人也不能拿原预览确认 |
| `previewClose / needs_approval` | 创建了预览，尚未关闭工单 | [预览与业务状态只读核对](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#%E7%94%A8%E4%B8%A4%E4%B8%AA%E7%8B%AC%E7%AB%8B%E5%AE%9E%E4%BE%8B%E6%A0%B8%E5%AF%B9%E8%BE%B9%E7%95%8C) | 核对显示、原绑定、业务条件和具体批准；不要把预览返回当作执行成功 |
| `previewClose / already_closed` | 这是重新预览非 open 工单的结果，不是 `confirmClose` 的返回枚举 | [成功后重新预览](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#%E7%94%A8%E4%B8%A4%E4%B8%AA%E7%8B%AC%E7%AB%8B%E5%AE%9E%E4%BE%8B%E6%A0%B8%E5%AF%B9%E8%BE%B9%E7%95%8C) | 先核当前状态与原操作记录，不把它当成一次新关闭 |
| `confirmClose / closed` | 可能是首次关闭，也可能返回同一成功预览的原结果 | [成功操作重放](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#%E7%94%A8%E4%B8%A4%E4%B8%AA%E7%8B%AC%E7%AB%8B%E5%AE%9E%E4%BE%8B%E6%A0%B8%E5%AF%B9%E8%BE%B9%E7%95%8C) | 对照原 operationId 和 revision，确认是否重放；不据重复返回再记一次写入 |
| `confirmClose / expired` | 没有该预览成功记录且已到期限；成功重放的检查在期限之前 | [未执行预览的精确到期](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#%E7%94%A8%E4%B8%A4%E4%B8%AA%E7%8B%AC%E7%AB%8B%E5%AE%9E%E4%BE%8B%E6%A0%B8%E5%AF%B9%E8%BE%B9%E7%95%8C) | 核对原期限及当前授权、状态和意图，再判断是否具备新预览条件；不要盲重试旧确认 |
| `confirmClose / stale` | 尚无成功记录、未过期，但工单版本或状态已变 | [竞争预览与检查顺序](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#%E7%94%A8%E4%B8%A4%E4%B8%AA%E7%8B%AC%E7%AB%8B%E5%AE%9E%E4%BE%8B%E6%A0%B8%E5%AF%B9%E8%BE%B9%E7%95%8C) | 读取获授权的当前状态，重新核对操作；不能靠旧预览反复确认越过版本变化 |
| 页面参数门 / `input-rejected` | 第 13 周作者本地门拒绝参数，不是核心枚举或 MCP 协议错误 | [非法参数零业务调用](https://cs-wude-fde-learning.pages.dev/course/week-13-read-only-mcp/#%E5%8F%82%E6%95%B0%E4%B8%8D%E5%90%88%E7%BA%A6%E6%97%B6%E4%B8%9A%E5%8A%A1%E6%9F%A5%E8%AF%A2%E6%9C%89%E6%B2%A1%E6%9C%89%E8%A2%AB%E8%B0%83%E7%94%A8) | 查必填、类型与额外字段合同，核对核心调用数；不能删除自报身份字段后悄悄继续 |
| 调用方记录 / `pending-verification` | 第 17 周的教学记录，不是核心枚举、真实网络错误或执行失败结论 | [忽略返回后核对原操作](https://cs-wude-fde-learning.pages.dev/course/week-17-safe-degradation/#%E4%B8%BB%E5%8A%A8%E4%B8%A2%E5%BC%83%E8%BF%94%E5%9B%9E%E5%80%BC%E5%85%88%E6%A0%B8%E5%AF%B9%E8%80%8C%E4%B8%8D%E6%98%AF%E5%8F%A6%E5%86%99%E4%B8%80%E6%AC%A1) | 先读获授权的当前状态并关联已保存的原操作证据；当前 closed 本身也不能证明是哪次操作，禁止盲目另写一次 |

确认检查的实际顺序是：预览存在 → 重新授权与具体 actor → 已成功操作重放 → 期限 → 版本或状态。不能统一解释成“过期总是 expired”或“一律重试、新建预览”。接手者可沿用[第 18 周的三项交接任务](https://cs-wude-fde-learning.pages.dev/course/week-18-operations-handoff/#%E7%94%A8%E4%B8%89%E9%A1%B9%E4%BB%BB%E5%8A%A1%E6%A0%B8%E5%AF%B9%E6%8E%A5%E6%89%8B%E7%BB%93%E6%9E%9C)，分别保存实际结果、是否求助和停止条件。

### 填实走查：T-102 的 unavailable 需要修吗？

固定原始合成夹具，`T-102` 在 A 车间、型号 `MX-2`、任务日期 `2026-10-08`；`tech-a` 可访问工单，但对应 `MAN-02` v1 只允许 `lead`。这不是“换成主管就修好了”的建议。

| 核对点 | 夹具与完整断言说明 | 判读与下一步 |
| --- | --- | --- |
| `query('tech-a', 'T-102')` | 完整结果为 `{ status: 'unavailable', sources: [] }` | 本例是预期可见性边界，不必购买 Key、重装 Node 或提高调用者权限 |
| 同一测试中的 `lead-a` 对照 | `restricted manuals do not appear in technician output` 同时核对主管夹具返回 `found`；对应资料为 MAN-02 v1 | 只说明固定夹具的角色可见性不同，不建议切换身份绕过规则；`found` 也不证明实际维修或关单成立 |
| 若你扩展后的预期不同 | 需有任务、型号、日期、访问政策和资料适用依据 | 保留原拒绝与无资料记录，让有权负责人核对合同，不能用更高权限或删断言掩盖差异 |

在解压后的四文件目录，仅运行下面这条**精确选中一个既有测试**的命令；完整测试名与首尾锚点均保留，双引号包住 pattern：

```text
node --test --test-name-pattern="^restricted manuals do not appear in technician output$" lab.test.mjs
```

这条命令只用于上述一项核对，不代表 16 个业务测试全跑；其余未选中或跳过的项目按实际输出记录，不能算通过。需要完整业务回归时，另行运行完整测试。本指南的新增命令只在维护者本机 Node.js 实跑，未验证 Windows 实机或真人独立接手；原课程中的协议、RAG 与生产限制仍然适用。

## 终端不支持 `<<` 时，保存为文件运行

课程中的 `node --input-type=module <<'JS'` 和末尾独立的 `JS` 是 Bash / zsh 的包装，不是 JavaScript，也不是 PowerShell / CMD 的通用语法。可改用编辑器保存 `.mjs` 文件，再让 Node.js 执行文件；本例不需要 `package.json`、安装依赖、账户或 API Key，也不需要安装 WSL、修改执行策略或用 `Invoke-Expression` 执行文本。

1. 确认 Node.js 22+ 可用，解压起步包，找到同时包含 `README.md`、`lab.mjs`、`lab.test.mjs`、`demo.mjs` 的目录。
2. 用文本编辑器在同一目录新建一个未占用的 `lesson-check.mjs`，保存编码选 UTF-8。若同名文件已存在，另取未占用的 `.mjs` 文件名，并同步修改下面的启动命令；不要覆盖 `lab.mjs`、其他起步文件或已有练习。
3. 只复制下面完整的 JavaScript 内容，不复制 Markdown 围栏与语言标签，不加入 `$`、`PS>` 等终端提示符。核对实际扩展名是 `.mjs`，不是 `.mjs.txt`。

```javascript
import assert from 'node:assert/strict';
import { createLab, fixtures } from './lab.mjs';
const lab = createLab();
const result = lab.query('tech-a', 'T-101');
assert.deepEqual(result, { status: 'found', sources: [fixtures.manuals[0]] });
assert.equal(result.sources.length, 1);
assert.equal(result.sources[0].id, 'MAN-01');
assert.equal(result.sources[0].version, 2);
assert.deepEqual(lab.query('tech-b', 'T-101'), { status: 'denied' });
console.log('query found MAN-01 v2');
console.log('cross-workshop denied');
```

4. 在系统终端进入这个目录，执行下面的独立命令，不是在 Node 交互式 REPL 中输入。若你改了文件名，这里也要改成同一个名字：

```text
node lesson-check.mjs
```

断言通过时，本例的精确 ASCII 输出为：

```text
query found MAN-01 v2
cross-workshop denied
```

转换其他课程时，**一个原代码块保存为一个新文件**：仅复制 `node --input-type=module <<'JS'` 首行与末尾独立 `JS` 之间的 JavaScript，保留该块原有身份、日期、数据构造与断言。不要把同页多个代码块拼在一起，否则可能出现重复 `import` 或 `const`；也不要用本例替换原课程实验。运行各文件时，仍使用它们原先要求的四文件目录和材料。

`lesson-check.mjs` 是读者自行保存的练习，不是 ZIP 新增文件；公开起步包仍只有原四个文件。本例仅验证两条本地只读查询，没有启动 HTTP、MCP 或 RAG。保存文件并执行的路径已在维护者本机 Node.js 核对；Windows、PowerShell、CMD 实机运行仍未验证，不能把本机结果写成全平台或全部课程已通过。

## 工单还是 closed，原来的批准能找回来吗？

接手人拿到了 T-101 关闭后的完整工单和当时的预览 ID。要核对那次关闭，两个实例即使读到相同的工单，能拿出的回执也可能不同。下载[起步包](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab.zip)，按上面的文件运行方法，在解压后的四文件目录另存 `check-replay.mjs`，执行 `node check-replay.mjs`。若文件名已占用，另取新名。整个练习在同一个 Node.js 进程内运行。

```javascript
import assert from 'node:assert/strict';
import { createLab, fixtures } from './lab.mjs';

const actor = 'lead-a';
const ticketId = 'T-101';
const originalFixtures = structuredClone(fixtures);
const openRow = originalFixtures.tickets.find(row => row.id === ticketId);
const original = createLab();
const { status, preview } = original.previewClose(actor, ticketId);
assert.equal(status, 'needs_approval');
const receipt = original.confirmClose(actor, preview.id);
assert.deepEqual(receipt, { status: 'closed', operationId: preview.id, ticketId, revision: 2 });
const savedRow = original.readStatus(actor, ticketId);
assert.deepEqual(savedRow, { ...openRow, state: 'closed', revision: 2 });
console.log('原预览 ID', preview.id);

function checkReplay(label, lab, expectedRow, expectedReply) {
  const before = lab.readStatus(actor, ticketId);
  assert.deepEqual(before, expectedRow);
  const reply = lab.confirmClose(actor, preview.id);
  assert.deepEqual(reply, expectedReply);
  assert.deepEqual(lab.readStatus(actor, ticketId), before);
  console.log(label, before.state, before.revision, JSON.stringify(reply));
}

checkReplay('A 原实例', original, savedRow, receipt);
checkReplay('B 默认新实例', createLab(), openRow, { status: 'denied' });
const copiedTickets = structuredClone(fixtures.tickets).map(row =>
  row.id === ticketId ? structuredClone(savedRow) : row
);
const stateOnly = createLab({ tickets: copiedTickets });
checkReplay('C 复制工单的新实例', stateOnly, savedRow, { status: 'denied' });
assert.deepEqual(original.confirmClose(actor, preview.id), receipt);
assert.deepEqual(original.readStatus(actor, ticketId), savedRow);
assert.deepEqual(fixtures, originalFixtures);
```

保存本次预览 ID、Node.js 版本和终端输出，再用自己的结果填三行。用 A 的 `operationId` 核对原预览 ID，用修订号核对重放后工单有没有再变。

| 实例 | 本次状态、修订号、旧 ID 返回值 | 据此能做的下一步 |
| --- | --- | --- |
| A 原实例 | ____ | 将重放的完整回执与首次关闭回执比对 |
| B 默认新实例 | ____ | 核对它读到的是否仍是初始工单 |
| C 复制工单的新实例 | ____ | 把它与 A 的工单逐字段比较，再单独比较回执 |

A 和 C 都能读到 `closed`、修订号 2。A 能重放原回执，C 却与仍是 `open`、修订号 1 的 B 一样返回 `denied`。在[公开包的 lab.mjs](https://cs-wude-fde-learning.pages.dev/downloads/workorder-lab/lab.mjs)中查看 `createLab` 和 `confirmClose`。每个实例都有独立的预览表和操作表。C 只收到业务行，无法从它核实批准人、原预览和这次关闭的关联。到这里应停止重试，将原回执列为待补证据。若原实例仍在但调用方丢了返回值，接着做[第 17 周的同实例核对](https://cs-wude-fde-learning.pages.dev/course/week-17-safe-degradation/#%E4%B8%BB%E5%8A%A8%E4%B8%A2%E5%BC%83%E8%BF%94%E5%9B%9E%E5%80%BC%E5%85%88%E6%A0%B8%E5%AF%B9%E8%80%8C%E4%B8%8D%E6%98%AF%E5%8F%A6%E5%86%99%E4%B8%80%E6%AC%A1)。真实进程重启或数据库备份恢复需要单独验证。

## 第一轮：改坏它，再修好

1. 运行测试，读一遍每个用例的输入与断言。
2. 复制一条适用手册，制造两个有效版本同时命中的冲突。
3. 确认程序返回 `conflict`，没有擅自挑一条。
4. 改工单车间，确认其他车间的用户拿不到资料。
5. 给写操作预览后修改工单版本，确认旧批准不能继续执行。

把失败前后的测试输出与一次提交放进学习记录。不要只留下“所有测试通过”的截图。

## 第二轮：选一个扩展方向

### A · 数据入口

把内存夹具换成 CSV 或数据库。你要补的是校验、隔离、幂等键和重放记录，不是换一个存储产品名称。[对应第 6 周](https://cs-wude-fde-learning.pages.dev/course/week-06-reliable-data-ingestion/)。

### B · 有出处的手册回答

加入带权限和版本的文档检索，再接入模型。先固定测试问题，分别测来源是否正确与回答是否忠实。维修建议只用于模拟实验，不替代设备厂商要求或合格人员判断。[对应第 9–12 周](https://cs-wude-fde-learning.pages.dev/course/week-09-governed-rag-corpus/)。

### C · 受控的工单工具

把查询封装成只读 MCP 工具，再为关闭模拟工单加入逐次批准。服务器必须自己核对身份、资源、参数、版本和批准状态，不能信任模型自报角色。[对应第 13–15 周](https://cs-wude-fde-learning.pages.dev/course/week-13-read-only-mcp/)。

如果你生成了两份维修草稿，它们可能同时用到同一批备件。先[按料号合并两单需求，算出缺口再交给审核人](https://cs-wude-fde-learning.pages.dev/course/week-14-approved-write-action/#draft-parts-availability)。

## 交付时交什么

一个别人能运行的仓库、一份列出输入与预期的测试、一张说清数据流和信任边界的图、一段包含失败路径的演示，以及一份限制说明。

可以按这个顺序整理第一个可展示版本：

1. 用[范围单](https://cs-wude-fde-learning.pages.dev/course/week-04-discovery-brief/)说明模拟使用者、手册查询任务和不做事项，明确没有真实客户效果数据。
2. 在 README 放运行命令、Node.js 版本与上面的预期输出；记录自己新增或修改的用例及提交，区分本站起步代码与个人贡献。
3. 演示一条 `found` 和一条 `denied`，再说明批准前后与重复确认的状态。让观看者能从输出回到具体测试。
4. 如果扩展 RAG 或工具接入，分别增加检索/回答评测和权限/批准测试，把结果与原确定性基线并列保存。扩展计划不能写成已完成功能。

不需要声称“企业级”。先写明你确实验证了什么，尚未验证什么。用 [交付档案](https://cs-wude-fde-learning.pages.dev/portfolio/)组织材料。

## 参考

实验关注的评测思想可对照 [OpenAI 评测指南](https://developers.openai.com/api/docs/guides/evaluation-best-practices)，协议接入请阅读 [MCP 架构文档](https://modelcontextprotocol.io/docs/learn/architecture)。实现中的工单规则是教学设计，不是上述文档规定的标准。

需要学习完整 LLM 应用项目的文档组织方式时，可以参考 [LLM Zoomcamp 项目说明](https://github.com/DataTalksClub/llm-zoomcamp/blob/main/project.md)，重点核对问题、运行配置、输入输出和评测入口；该课程的项目范围与本站确定性起步包不同。
