跳转到内容
FDE 现场笔记

第 16 周:沿着一个请求 ID 找到故障

现场练习 16 / 20让别人接得住返回学习地图

现场练习 16 / 设备维修工单。所有组织、数据与业务情节均为模拟材料。

HTTP 成功不等于任务成功

标题“HTTP 成功不等于任务成功”

一个请求可能顺利返回“资料不足”,这在任务层是正确拒绝。也可能返回 200 却引用错误型号,这仍是错误。

实验:给一次运行串起编号

标题“实验:给一次运行串起编号”

为请求记录请求 ID、阶段、耗时、结果类别、数据版本和操作 ID。授权拒绝、检索为空、依赖超时与提交成功应该能区分。

在日志中故意删除一个阶段,检查还能否定位最早偏离点。不要把完整手册、用户输入、密钥或批准凭证全部写入普通日志。

分别统计请求错误、任务结果和评测质量。没有线上用户时,业务采用只能标为未知,不能从日志数量推算价值。

工单说“等待批准”,能填哪一个日期?

标题“工单说“等待批准”,能填哪一个日期?”

设备维修助手被问到“WO-1002 现在是什么状态?电工是哪天批准的?”第一个问题查工单快照,第二个要找一条已发生的批准事件。即使两者出现在同一张单里,也需要分别交出字段依据。这里的“现在”只指你下载的样例版本。

从 Work Order RAG 固定版本的上游原件 保存 work_orders.json,再下载本站历史核对脚本,二者放在一个目录,用 Python 3 运行:

终端窗口
python3 check-history.py work_orders.json history-review.json

脚本核对原件字节摘要,把本单状态和每条历史的原文位置写入新报告。它按日期找最新记录,保留同一天的全部条目。打开 history-review.json,先自己写下两个问题的答案,再用以下三行检查证据:

要填的项 跟着指针读原件 能填入交接单的值
WO-1002 的快照状态 /1/status In Progress。这里只读到这个版本的状态。
WO-1002 的批准日期 查看 /1/history 的五条条目。最新的 /1/history/4 记的是等待电工批准 approvalDate: null,说明“所列历史未给批准日期”。2024-02-07 是等待记录的日期。
WO-1001 哪天换泵、哪天关单 /0/history/4 与 /0/history/5 同在最新日期集合 两项均为 2024-01-20。只能写到日;若要算换泵到关单相隔几小时,仍缺两项时刻。

报告中的 /1/history/4 表示原数组的第 2 张单、第 5 条历史,依次从 0 开始计数。核对练习先匹配工单编号,再对照位置。请交一条对 WO-1002 的答复,分别给出快照状态、最近有记录的动作、批准日期和原文位置。把答案中的 2024-02-07 换成“批准于这一天”,让同伴指出所引动作哪里支撑不了这句话。

这个开源示例的导入实现会把状态和历史组装成检索材料。本练习只读固定教学快照,取数与判断可离线复算。接到真实工单时,应另查经过授权的审批事件或关联单据,再决定能否补上日期。

接手人能看到调用结果,又不会拿到原始预览号吗?

标题“接手人能看到调用结果,又不会拿到原始预览号吗?”

在起步包解压后的四文件目录运行 node demo.mjs。留意正常查询打印了整条合成手册,预览中的 id 也会出现在批准结果的 operationId。要向同伴说明查询为何没有资料、两次确认是否指向同一操作,通常用不到这些原值。

将本地观测脚本保存到原版 lab.mjs 旁,用 Node.js 22+ 执行。脚本核对起步包业务源码的摘要,调用其中的查询与确认函数;不需要账号或网络。

终端窗口
node observe-workorder.mjs capture trace-first
node observe-workorder.mjs review trace-first/observed.jsonl
node observe-workorder.mjs review-copy trace-first/missing-line.jsonl

capture 同时保存原件摘要 observed.sha256。把这份摘要另存到交接记录;review 先对照捕获时的摘要,再判断每条结果。改写原件中的状态或别名会停止。若摘要本身也被替换,这项本地核对无法证明来源。故意删行的教学副本用 review-copy 检查结构,保留原件。

observed.jsonl 记录五次实际函数调用的开始和返回。先有五条开始记录,再陆续返回;按 requestId 配对。包装器只输出固定类别,原操作号在本次运行内映射成 OP1,不会输出手册正文、操作者、工单号或有效期。这个别名只在当前文件中有意义。脚本看得到函数边界;函数内部的授权阶段、HTTP 状态和耗时均未采集。

请求 在完整文件中应能核对的结果
R1 / R2 / R3 查询 依次为 found、denied、unavailable。后两项分别是拒绝访问和没有适用资料。
R4 首次确认 / R5 重放 两项均为 closed OP1。两个请求号对应同一个实验操作。

用缺行副本交接一次。 missing-line.jsonl 是从本次实测原件移去 R4 返回行的教学副本。向同伴交出 R4、R5 的逐项判断:R4 缺 returned,记 unknown;R5 仍有 closed OP1。缺行的复核退出码为 2,完整为 0,字段违规等输入错误为 1。再运行第一条 review 核对保留的原件,说明补到了哪一行。若原件查不到,就保留未知,别用 R5 替 R4 填结论或重做确认。再次采集请换新目录名。这里只示范合成材料的字段取舍,真实日志的访问与分享仍需单独审查。OWASP 日志数据取舍

三条人工轨迹,先看终点与阶段

标题“三条人工轨迹,先看终点与阶段”

以下 JSONL 是作者编写的日志结构设计,不是起步包自带日志、真实遥测或线上用户记录。阶段名是拟新增的观测点,不是可调用 API:现有 query、confirmClose 内部自行授权,authorize 没有导出,原包也没有 logger。这里 query 指授权后的资料查询阶段,不表示已经实现先调用独立授权 API 的编排。

{"recordType":"design-example","requestId":"SYNTHETIC-REQ-A","dataVersion":null,"events":[{"stage":"authorization","result":"denied","durationMs":null}],"actual":null}
{"recordType":"design-example","requestId":"SYNTHETIC-REQ-B","dataVersion":null,"events":[{"stage":"authorization","result":"allowed","durationMs":null},{"stage":"query","result":"unavailable","durationMs":null}],"actual":null}
{"recordType":"design-example","requestId":"SYNTHETIC-REQ-C","dataVersion":null,"events":[{"stage":"confirmation-authorization","result":"allowed","durationMs":null},{"stage":"confirmation","result":"closed","operationId":"SYNTHETIC-OP-EXAMPLE-C","durationMs":null}],"actual":null}
  • A 对应跨车间查询等授权拒绝。拟设计控制流应停止,不进入受保护资料查询,因此没有后续查询阶段;仅看不到日志事件,仍不能独自证明这一控制要求已被遵守。
  • B 可对照 tech-a 查询同车间 T-102:资源访问允许,但无可见适用手册,业务结果是 unavailable。这与 A 的拒绝不同,也不等于系统宕机。
  • C 表示有权 actor 对有效预览完成确认后的设计终点;同一请求下的事件用 requestId 关联,成功结果再用 operationId 关联业务操作。此处操作号是明显合成占位,不是真实批准凭证。

每条的 actual、未知的数据版本和耗时都保留 null;不能把未知耗时写成 0,也不能把示例当作已运行的日志系统或真实业务采用证据。

最小字段为什么保留,哪些不能直接公开

标题“最小字段为什么保留,哪些不能直接公开”
字段 用途 公开与记录边界
requestId 串起同一次请求的阶段 真实编号应经授权、去标识后分享,不用会话令牌充当编号
stage 指出授权、资料查询或确认等观测点 可公开设计名称,不自动公开真实系统内部结构
result 区分 denied、unavailable、closed 等结果 不复制异常栈或受限正文;真实结果也需核对分享权限
durationMs 分析一个已测阶段的耗时 未测为 null,注明单位,不从缺事件推算耗时
dataVersion 将结果关联到使用的材料版本 本例未知为 null;真实资源标识、版本关系需授权脱敏
operationId 将确认结果关联到业务操作 本例只用合成号;原实验与 preview.id 同值,真实记录须另行审查和脱敏,不能照搬预览凭证

坏日志与最小改写

标题“坏日志与最小改写”

下面两条均为人工示意。第一条故意使用合成令牌和正文占位展示不应记录的内容,不要把真实令牌或手册填进示例;第二条只保留定位问题所需的字段:

{"requestId":"SYNTHETIC-REQ-B","stage":"query","result":"unavailable","token":"SYNTHETIC_TOKEN_NOT_REAL","manualText":"合成受限正文占位"}
{"requestId":"SYNTHETIC-REQ-B","stage":"query","result":"unavailable","durationMs":null}

若把 B 的 query 事件删掉,只能说查询阶段没有可用记录,可能漏记、中断或未发生;不能断言它已经执行,更不能直接宣布根因。若 C 缺少确认事件,也不能从“没日志”推出“未提交”。应结合实际控制流、相邻事件与可核对操作状态继续调查,证据不足时保留未知,不据缺记录盲目再写一次。

The pump still reports pressure. Why did its temperature alert fire?

标题“The pump still reports pressure. Why did its temperature alert fire?”

A planner sees a temperature alert for pump P-01 while the pressure feed looks healthy. To decide what to investigate, replay the same readings twice. The device check accepts any reading from P-01. The temperature check accepts only a temperature reading from P-01.

IBM’s example permits an unspecified data item for a DeviceType and requires a named item for other resource types. It shows a two-hour silence threshold and a three-hour cooldown, including a case where pressure keeps arriving. The original lab requires Maximo access. IBM scope rule · IBM example timelines

Local replay. Save the block as pump_gap.py in an empty directory. It uses synthetic arrivals on one UTC day, in minutes after 12:00. At each listed check it includes arrivals at that minute first. A scope emits an alert at a gap of 120 minutes or longer, then waits at least 180 minutes before another. These timing rules apply to this exercise. It needs only Python 3.7 or later.

import argparse
import csv
import sys
args = argparse.ArgumentParser()
args.add_argument("--add-temperature", action="store_true")
replay = args.parse_args()
arrivals = {
"pressure": [0, 5, 60, 120, 150, 180, 240, 300],
"temperature": [0, 5],
}
if replay.add_temperature:
arrivals["temperature"].append(124) # 14:04, before the first alert
def clock(minute):
return f"{12 + minute // 60:02d}:{minute % 60:02d}"
rows = csv.writer(sys.stdout, lineterminator="\n")
rows.writerow(["pump", "scope", "check_utc", "last_reading_utc", "gap_min",
"next_alert_allowed_utc", "result"])
for scope in ("device", "temperature"):
readings = (arrivals["pressure"] + arrivals["temperature"]
if scope == "device" else arrivals["temperature"])
next_allowed = None
for check in (124, 125, 150, 243, 244, 305):
last = max(t for t in readings if t <= check)
gap = check - last
if gap < 120:
result = "fresh"
elif next_allowed is not None and check < next_allowed:
result = "cooldown"
else:
result = "alert"
next_allowed = check + 180
rows.writerow(["P-01", scope, clock(check), clock(last), gap,
clock(next_allowed) if next_allowed is not None else "", result])

Run both commands. Each starts with an empty alert history. The CSV files retain the scope, check time, last matching arrival, silence duration, cooldown deadline and decision. A blank deadline means that scope has never alerted.

终端窗口
python3 pump_gap.py > baseline.csv
python3 pump_gap.py --add-temperature > extra-reading.csv

In baseline.csv, compare the two 14:05 rows. The device last reported at 14:00, only five minutes earlier. Temperature last arrived at 12:05. Its gap grows from 119 minutes at 14:04 to 120 at 14:05: first alert. At 14:30 the temperature gap is 145 minutes, still in cooldown. At 17:05 the cooldown expires and the temperature alert repeats. The device scope stays fresh at every listed check.

In extra-reading.csv, find the 14:04 temperature arrival you added. The 14:05 gap is now one minute. Find the next temperature alert at 16:04 and explain why 17:05 now shows cooldown. This second run tests a reading received before any alert.

Handoff. Save the two 14:05 rows from one run and identify which file they came from. Write one sentence naming the pump, the silent scope (if any) and the next check. For example, compare the temperature channel at the source with its gateway feed while pressure is still current. Equipment failure, a real Maximo alert, and service-request or work-order status all remain unknown.

A temperature reading arrived after the alert. What goes in the handoff?

标题“A temperature reading arrived after the alert. What goes in the handoff?”

At 15:00 the planner receives a CSV with a P-01 temperature sample measured at 14:04. The 14:05 operator could not see it. Keep the original baseline.csv. The earlier --add-temperature exercise makes the reading available at 14:04 and therefore answers a different question.

Save the late-reading replay beside that CSV (Python source). From that directory run the two cases with Python 3.7+. Only the metric changes.

python3 recheck-pump-alert.py baseline.csv late-temperature.json
python3 recheck-pump-alert.py baseline.csv late-pressure.json --metric pressure

Compare the histories for the same alert_key. Both preserve the temperature alert as New at 14:05 and after the 15:00 upload. At 15:05 the replay rechecks the interval. The temperature sample fills the gap, so that branch becomes Resolved. The pressure sample belongs to another metric, so the temperature alert stays New. Include the original row, its file digest, both sample and receipt times, and the recheck decision in your handoff. If you start from extra-reading.csv, there is no 14:05 temperature alert to revise.

IBM’s example distinguishes uploading a historical CSV from running the backtrack pipeline. This local exercise uses one UTC day and a two-hour gap. The status history describes the simulated alert; pump condition and work-order status remain unknown. IBM’s backtrack timeline

三条完整模拟请求轨迹、一份字段字典和一张诊断顺序表。需要的字段应回答具体问题,而不是为了仪表盘好看。

让同伴仅凭运行记录判断一次故障在哪个阶段。如果只能看见“error”,补结果类别与关联标识;如果日志能泄露资料,先缩减记录内容。


← 上一周 · 学习地图 · 下一周 →