failure-flywheel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: failure-flywheel
Skill: failure-flywheel
Turn recurring failures into rules. Capture by code, count deterministically, draft a stub for a human to approve — never auto-promote.
将重复出现的失败转化为 rules。按 code 捕获失败、确定性地计数,并为人工审批起草 stub——绝不自动 promote。
WHAT
是什么
Purpose và context
目的与上下文
- Purpose: biến lỗi lặp lại của agent thành guardrail: ghi lỗi bằng code, đếm tất định theo taxonomy, khi một lớp lỗi vượt ngưỡng thì dựng STUB đề xuất rule/skill vào luồng propose→gate.
- Trigger (when to use):
- A task failed in a way that could recur (invented an API, broke a test, ignored a rule, over-built). Record it so it is counted, not forgotten.
- Periodically (end of session, or every N failures): to see which failure class recurs most.
--report - When a class crosses the recurrence threshold: to seed a candidate rule, then run
--draft <category>to finish it./propose - User nói "log this failure", "record the mistake", "why does this keep happening", "turn failures into rules", "failure taxonomy", "what keeps breaking", hoặc .
/failure-flywheel
- Non-goals: Do NOT use to auto-write rules. This skill seeds the gate; a human always approves. Không tự chưng cất nội dung rule (10% cần phán đoán thuộc về người + ).
/propose
- 目的: 将 Agent 的重复失败转化为 guardrail:按 code 记录失败,按 taxonomy 确定性地计数;当某个失败类别超过阈值时,在 propose→gate 流程中生成 rule/skill 候选 STUB。
- 触发条件(何时使用):
- 任务以可能重复的方式失败(虚构了 API、破坏了测试、无视了 rule、过度构建)。记录该失败,使其被计数而不是被遗忘。
- 定期(会话结束时,或每 N 次失败后):运行 查看最常重复的失败类别。
--report - 当某个类别越过重复阈值时:运行 播种候选 rule,然后运行
--draft <category>完成它。/propose - 用户说出“log this failure”“record the mistake”“why does this keep happening”“turn failures into rules”“failure taxonomy”“what keeps breaking”,或 。
/failure-flywheel
- 非目标: 不要用于自动编写 rules。此 skill 只为 gate 播种;始终由人工审批。不自动提炼 rule 内容(10% 需要人的判断,并配合 )。
/propose
Mental model
思维模型
failure → record(category) → failures.jsonl → --report (group · COUNT · leaderboard) → lớp ≥ recurrence_threshold → --draft stub → /propose → cổng người duyệtfailure → record(category) → failures.jsonl → --report (group · COUNT · leaderboard) → 类别 ≥ recurrence_threshold → --draft stub → /propose → 人工 gateInput và output contract
输入与输出约定
| Field | Required? | Ý nghĩa | |
|---|---|---|---|
| In | | có (record) | lớp taxonomy gần nhất; category lạ vẫn ghi, bị gắn cờ ở report |
| In | | không | chi tiết thêm |
| In | | không (draft) | ISO only, mặc định 2026-06-29; sai định dạng → exit 2 |
| In | | có | ngưỡng + taxonomy (adapter, |
| Out | dòng trong failures.jsonl | có (record) | lịch sử local, gitignored |
| Out | leaderboard | có (report) | đếm theo lớp, first/last seen, lớp nào |
| Out | | chỉ khi đủ ngưỡng | STUB (OKF frontmatter + |
| 字段 | 必需? | 含义 | |
|---|---|---|---|
| 输入 | | 是(record) | 最接近的 taxonomy 类别;即使 category 未知也仍会记录,并在 report 中标记 |
| 输入 | | 否 | 补充详情 |
| 输入 | | 否(draft) | 仅限 ISO,默认 2026-06-29;格式错误 → exit 2 |
| 输入 | | 是 | 阈值 + taxonomy(adapter, |
| 输出 | failures.jsonl 中的一行 | 是(record) | 本地历史,gitignored |
| 输出 | leaderboard | 是(report) | 按类别计数、首次/最近出现时间,以及哪些类别为 |
| 输出 | | 仅在达到阈值时 | STUB(OKF frontmatter + |
Rules và capabilities
规则与能力
- RULE-01 (MUST): Capture is fail-open — recording a failure must never break the session.
- RULE-02 (MUST): Never auto-promote. seeds
--draft; a human approves./propose - RULE-03 (MUST): The draft filename date is fixed (, default 2026-06-29, ISO
--dateonly — not theYYYY-MM-DDwiki filename convention) for determinism; real use can stamp today. A malformedDDMMYYnow exits 2 with a clear error instead of silently falling back to the default (fixed 2026-07-20 after that exact silent-fallback shipped a wrong-dated draft file).--date - RULE-04 (MUST): Do not hard-code the threshold or taxonomy anywhere but the config — that is the adapter.
- Capabilities: ghi append lịch sử lỗi local; đọc config ngưỡng/taxonomy; ghi một file draft stub vào wiki draft. Không mạng, không sửa rule/skill thật.
- RULE-01 (MUST):捕获必须采用 fail-open——记录失败绝不能中断 session。
- RULE-02 (MUST):绝不自动 promote。只为
--draft播种;必须由人工审批。/propose - RULE-03 (MUST):draft 文件名中的日期由 确定(默认 2026-06-29,仅限 ISO
--date——不采用YYYY-MM-DDwiki 文件名约定),以确保确定性;实际使用时可以标记当天。格式错误的DDMMYY现在会 exit 2 并给出清晰错误,而不是静默回退到默认值。该静默回退曾生成日期错误的 draft 文件;现已修复(2026-07-20)。--date - RULE-04 (MUST):除 config(adapter)外,不得在任何位置硬编码 threshold 或 taxonomy。
- 能力:追加写入本地失败历史;读取 config 中的 threshold/taxonomy;向 wiki draft 写入一个 draft stub。不联网,不修改真实的 rule/skill。
Failure boundaries
失败边界
- Ghi lỗi hỏng → fail-open (session không vỡ), không chặn.
- lớp chưa đủ ngưỡng → không viết stub (blocked hẹp, báo đếm hiện tại).
--draft - sai định dạng → failed exit 2, thông báo rõ.
--date - Config còn → stub chỉ có human-TODO, không rule tự viết (partial có chủ đích).
verified: false
- 记录失败时发生错误 → fail-open(session 不会崩溃),不阻塞。
- 对未达到阈值的类别 → 不写入 stub(仅阻断此项操作),并报告当前计数。
--draft - 格式错误 → failed exit 2,并给出明确消息。
--date - Config 仍为 → stub 只包含 human-TODO,不自动编写 rule(有意保持 partial)。
verified: false
HOW
如何执行
Main workflow
主流程
| Step | Type | Inputs | Action | Outputs/exit | Failure/next |
|---|---|---|---|---|---|
| W01 | effect | failure vừa xảy ra | | dòng jsonl | category lạ → vẫn ghi + cờ ở report |
| W02 | deterministic | failures.jsonl + config | | lớp đánh dấu | không lớp nào đủ → dừng |
| W03 | effect | lớp đủ ngưỡng | | file draft stub | chưa đủ ngưỡng / |
| W04 | judgment | stub | STOP chờ người; người chạy | proposal đầy đủ | người từ chối → giữ stub |
Chi tiết từng bước (nguồn chân lý cho W01–W04):
| 步骤 | 类型 | 输入 | 操作 | 输出/退出码 | 失败/下一步 |
|---|---|---|---|---|---|
| W01 | effect | 刚发生的失败 | 在最接近的 taxonomy 类别下运行 | jsonl 行 | category 未知 → 仍记录,并在 report 中标记 |
| W02 | deterministic | failures.jsonl + config | 运行 | 类别 ≥ 阈值时标记为 | 无类别达到阈值 → 停止 |
| W03 | effect | 达到阈值的类别 | 运行 | draft stub 文件 | 未达到阈值 / |
| W04 | judgment | stub | STOP,等待人工;由人运行 | 完整 proposal | 人拒绝 → 保留 stub |
各步骤详情(W01–W04 的事实来源):
The flywheel (Hamel: create -> label -> fix -> repeat)
飞轮(Hamel: create -> label -> fix -> repeat)
The slow human step is "notice the same mistake keeps happening and turn it into a rule." This makes the mechanical 90% deterministic (capture + taxonomy + count + scaffold) and refuses to fake the 10% that needs judgement (what the rule actually is).
缓慢的人工步骤是“发现同一个错误反复发生,并将其转化为 rule”。这样,90% 的机械工作(捕获 + taxonomy + 计数 + scaffold)都是确定性的,同时不会假装替代那 10% 需要判断的工作(rule 究竟是什么)。
Commands
命令
bash
undefinedbash
undefined1. CAPTURE — append one failure (BY CODE; failures.jsonl is gitignored local history)
1. CAPTURE — append one failure (BY CODE; failures.jsonl is gitignored local history)
python3 harness/scripts/failure-flywheel.py record <category> "<summary>" [--detail "..."]
python3 harness/scripts/failure-flywheel.py record <category> "<summary>" [--detail "..."]
2. REPORT — deterministic taxonomy: group by category, COUNT, leaderboard (most-frequent
2. REPORT — deterministic taxonomy: group by category, COUNT, leaderboard (most-frequent
first) + first/last seen + which classes are eligible to draft
first) + first/last seen + which classes are eligible to draft
python3 harness/scripts/failure-flywheel.py --report
python3 harness/scripts/failure-flywheel.py --report
3. DRAFT — only if <category> recurs >= recurrence_threshold: scaffold a STUB proposal at
3. DRAFT — only if <category> recurs >= recurrence_threshold: scaffold a STUB proposal at
llmwiki/wiki/sources/draft/DDMMYY-failure-<category>.md and STOP for human approval
llmwiki/wiki/sources/draft/DDMMYY-failure-<category>.md and STOP for human approval
python3 harness/scripts/failure-flywheel.py --draft <category> [--date YYYY-MM-DD]
undefinedpython3 harness/scripts/failure-flywheel.py --draft <category> [--date YYYY-MM-DD]
undefinedSteps
步骤
- On a failure, it under the closest taxonomy category (see the config). Capture never blocks — an unlisted category is still recorded and flagged in
record.--report - Run to read the leaderboard. A class marked
--reporthas recurred >= the threshold.DRAFT - For an eligible class, . It writes a valid draft STUB (OKF frontmatter +
--draft <category>, deliberately no## Originso it passes the R7 gate as a seed) containing a templated "TODO: distill rule from these N failures" + the failure list.## Plan - The stub STOPS for you. Run to turn it into a complete, gated rule/skill. FailureFlywheel never auto-promotes — the gate stays human.
/propose
- 发生失败时,在最接近的 taxonomy 类别下运行 。捕获绝不能阻塞——未列出的 category 仍会被记录,并在
record中标记。--report - 运行 读取 leaderboard。标记为
--report的类别表示其重复次数已 ≥ 阈值。DRAFT - 对于符合条件的类别,运行 。它会写入一个有效的 draft STUB(OKF frontmatter +
--draft <category>,有意不含## Origin,从而以种子的形式通过 R7 gate),其中包含模板化的## Plan及失败列表。TODO: distill rule from these N failures - stub 在此 STOP,等待你接手。运行 ,将其转化为完整且带 gate 的 rule/skill。FailureFlywheel 绝不自动 promote——始终由人工把守 gate。
/propose
Gói thành chỉ dẫn cho lần sau (user 23/09/2026)
打包为下次使用的指引(用户 23/09/2026)
Lớp lỗi chạm (mặc định 3 — tức quá 2 lần) thì TỰ gói ngay thành một thẻ chỉ dẫn:
recurrence_thresholdrecord()bash
harness/metrics/guardrails/failure-<lớp>.md # máy gói, có INDEX.md; được commit để phiên/máy khác cùng học
python3 harness/scripts/flywheel.py --kind failure --guardrails # gói lại toàn bộ lớp đã đủ ngưỡngThẻ chỉ CHƯNG CẤT từ chính các dòng đã ghi (triệu chứng + cách sửa đã dùng + số lần + lần gần nhất) — không bịa luật mới. Hook in 5 thẻ mới nhất ở đầu MỖI phiên (mục ), nên lần kế tiếp agent đọc được trước khi làm việc cùng loại. Thẻ mang trạng thái : nó là chỉ dẫn đọc-để-nhớ, KHÔNG cắn được ở CI. Muốn thành luật/skill chính thức thì vẫn rồi — cổng người giữ nguyên (RULE-02).
session_start🧯 [đã học]đã học, CHƯA duyệt--draft/propose当失败类别达到 (默认 3——即超过 2 次)时, 会立即自动打包成一张指引卡:
recurrence_thresholdrecord()bash
harness/metrics/guardrails/failure-<lớp>.md # máy gói, có INDEX.md; được commit để phiên/máy khác cùng học
python3 harness/scripts/flywheel.py --kind failure --guardrails # gói lại toàn bộ lớp đã đủ ngưỡng卡片仅摘录已记录的行本身(症状 + 已使用的修复方法 + 次数 + 最近一次),不会臆造新 rule。 hook 会在每个会话开头注入最近 5 张卡片( 章节),因此 Agent 下次在处理同类工作前即可读到。卡片状态为“已学习,尚未审批”:它是供阅读与记忆的指引,不会在 CI 中强制阻断。若要成为正式 rule/skill,仍需先运行 ,再运行 ——保持人工 gate(RULE-02)。
session_start🧯 [已学习]--draft/proposeThe adapter boundary (build-now-adapt-later)
Adapter 边界(build-now-adapt-later)
Everything above is deterministic and built now. The ONE quarantined unknown is (): the recurrence threshold and taxonomy are best-guesses, and the "distill failures -> rule" model is absent. While it is unset, inserts a human-TODO stub instead of an auto-written rule. Finalize later by editing only that one file — calibrate the threshold, name a distill model, flip .
harness/failure-flywheel.config.yamlverified: false--draftverified: true上述所有内容都是确定性的,且已现在构建完成。唯一处于隔离状态的未知项是 ():重复阈值和 taxonomy 均为最佳猜测,且“从 failures 提炼 rule”的模型尚不存在。在其配置完成前, 会插入 human-TODO stub,而不是自动编写 rule。后续只需编辑这一个文件即可最终确定——校准阈值、指定 distill model,并翻转为 。
harness/failure-flywheel.config.yamlverified: false--draftverified: trueBranches
分支
| ID | Kind | Guard | Hành vi | Skip / failure | Rejoin |
|---|---|---|---|---|---|
| B01 | conditional_required | lớp lỗi ≥ | W03 | dưới ngưỡng → skip, chỉ report | W04 |
| B02 | capability_optional | config | stub có rule tự chưng cất thay vì human-TODO | chưa verified → human-TODO stub (mặc định hiện tại) | W04 |
| ID | 类型 | 守卫 | 行为 | 跳过/失败 | 汇合点 |
|---|---|---|---|---|---|
| B01 | conditional_required | 失败类别 ≥ | W03 | 低于阈值 → 跳过,仅执行 report | W04 |
| B02 | capability_optional | config | stub 包含自动提炼的 rule,而非 human-TODO | 尚未 verified → human-TODO stub(当前默认) | W04 |
Validation và stopping
验证与停止条件
Đếm và ngưỡng do quyết (tất định). Stub hợp lệ = OKF frontmatter + , cố ý không để qua cổng R7 như hạt giống. Luôn dừng ở W04 — không bao giờ tự promote.
failure-flywheel.py## Origin## Plan计数和阈值由 决定(确定性)。有效 stub = OKF frontmatter + ,有意不含 ,从而以种子的形式通过 R7 gate。始终在 W04 停止——绝不自动 promote。
failure-flywheel.py## Origin## PlanExamples
示例
- Positive: agent bịa API lần thứ N (vượt ngưỡng) → →
python3 harness/scripts/failure-flywheel.py record invented-api "called nonexistent fetchAll()"hiện--reportđánh dấuinvented-api→DRAFTviết--draft invented-apivà dừng chờllmwiki/wiki/sources/draft/DDMMYY-failure-invented-api.md./propose - Boundary/failure: → exit 2 kèm lỗi rõ ràng, không viết file ngày sai.
--draft invented-api --date 19/09/2026
- 正向示例: Agent 第 N 次虚构 API(超过阈值)→ →
python3 harness/scripts/failure-flywheel.py record invented-api "called nonexistent fetchAll()"将--report标记为invented-api→DRAFT写入--draft invented-api,然后停止并等待llmwiki/wiki/sources/draft/DDMMYY-failure-invented-api.md。/propose - 边界/失败: → exit 2 并给出明确错误,不会写入日期错误的文件。
--draft invented-api --date 19/09/2026
Related
相关内容
- — same by-code, gitignored-JSONL, fail-open capture pattern.
harness/scripts/code-logger.py - — the gate this feeds.
llmwiki/skills/dev-loop/propose.md - — the quarantine pattern the config follows.
llmwiki/skills/dev-loop/build-now-adapt-later.md
- ——相同的按 code 分类、gitignored-JSONL、fail-open 捕获模式。
harness/scripts/code-logger.py - ——本流程接入的 gate。
llmwiki/skills/dev-loop/propose.md - ——config 所遵循的 quarantine 模式。
llmwiki/skills/dev-loop/build-now-adapt-later.md