Skip to content

【规格】818 写侧缺值处置:三列必填拦下补齐(9 卡执行件) #853

Closed

Description

@FeatherHunter

Part of #765(818 的执行规格单;定案正文为首见 #818 ## 定案)

Problem Statement

用户在私家大厨里记一道菜时,经常有填不出的格子:盐写“适量”没有克数、装盘那一步没有分钟数、这次做完不想打分。用户要的是:要么当时就被清楚地拦下并知道缺什么、问谁要、怎么补(已填的不丢、不存半条怪数据),要么一次补齐就顺利入库。实际情况是老库三列都是非空约束,缺值写入直接失败,而 9 张场景卡(录入 6、修改 1、历史 1、派生 1)都要经过这三列,四张纵向票被一起挡住。

Solution

三列一律按必填执行:用量数字、步骤时长数字、评分 0-5 数字,缺一即响亮失败并指引补齐,不落半条脏数据。用户补齐后重试一次通过。查询与统计保持原样(平均分直算、用量与时长直显),页面把这三项标为必补。远期放开可空另立 schema 票,届时评分改回选填。

User Stories

  1. As a home cook adding a dish from a photo, I want to be told exactly which ingredient lacks a numeric amount, so that I can supply it and complete the entry.
  2. As a home cook writing “适量” for salt, I want the assistant to ask me for an estimated grams figure while keeping my “适量” wording, so that the record stays truthful instead of inventing a number.
  3. As a home cook importing a recipe from a markdown file, I want missing amounts or step durations collected in one go, so that I don't fix them one by one across retries.
  4. As a home cook importing from JSON, I want a failed import to list every missing field and let me retry after filling them, so that nothing is silently dropped.
  5. As a home cook using a fill-in form, I want unfilled required items marked in red with the confirm button disabled, so that I know what blocks saving before I try.
  6. As a home cook editing an ingredient amount, I want the change to require a real number, so that the shopping list math stays correct.
  7. As a home cook adding a new ingredient to an existing recipe, I want the same numeric-amount rule as during entry, so that rules don't change between pages.
  8. As a home cook recording a cook, I want to be asked for a 0-5 score when I skip it, so that the record is complete and averages stay meaningful.
  9. As a home cook doing a quick record (“刚做完,很不错”), I want the one-question score prompt plus my one-line feedback, so that quick entry stays quick but complete.
  10. As a home cook backfilling yesterday's cook, I want the same score rule with a date I choose, so that补录 behaves like a normal record.
  11. As a home cook viewing a dish's average score, I want the average computed straight from real scores, so that I can trust it.
  12. As a home cook viewing the cooking timeline, I want every entry to show its real score and feedback, so that history reads truthfully.
  13. As a home cook deriving a new dish from a mother recipe, I want inherited ingredients and steps to carry their numbers over, so that the new dish is complete on creation.
  14. As a home cook editing a derived difference, I want emptied numbers flagged as must-fill, so that I can't accidentally save a broken dish.
  15. As a home cook generating a shopping list, I want amounts summed from real numbers, so that the totals are usable.
  16. As a home cook opening the cooking mode, I want each step to show a real duration, so that waiting-type steps can be planned around.
  17. As an AI assistant executing these cards, I want one uniform missing-value behavior across all 9 cards, so that I don't memorize per-card exceptions.
  18. As an AI assistant hitting a missing value, I want the failure to name the field and how to fix it, so that I can ask the user precisely and retry.
  19. As a maintainer reviewing longitudinal tickets, I want the per-ticket rulings findable in each ticket body, so that 录入域:端到端搬迁(6 卡,写侧) #773/修改域:端到端搬迁(4 卡,写侧) #774/历史域:端到端搬迁(4 卡;记录做菜=写、查看历史/查看统计=读) #775 each stand alone.
  20. As an acceptance reviewer, I want negative cases (one missing column each) to fail loudly with no partial rows, so that data corruption is impossible by construction.
  21. As a home cook who truly has no rating to give, I want to be asked once rather than blocked silently, with the knowledge that a future update will allow skipping scores entirely.

Implementation Decisions

  • 按列独立审查、结论收敛为同一个“必填”:用量数字必填、步骤时长数字必填、评分 0-5 必填;审查过程是分列的,结果是一致的;改 schema 只出图不做。
  • 缺值在取数层写入入口统一拦下(单个定义地,别处引用不重写):先校验后落盘,单条写入不产生半条行;批量采集的整批原子性(先验后写或同事务)由各纵向票在实现时保证,本规格只定单条语义。
  • 对外契约:缺用量数字、缺时长数字、缺评分 → 取数失败类错误(消息含缺哪个字段、找用户补什么),命令出口以取数失败档非零退出;成功保持零退出与回执不变。
  • “适量”语义:数字用量与文字用量分离,AI 向用户要一个估计数并原样保留文字(如少许约 5g),不编造、不存 0(0 已有“废弃标注”含义,不得复用)。
  • 评分语义:0 分是合法评分,未评分当前不可存储且与 0 分不可区分,因此缺评分必须补;卡面“选填”暂按“必填”执行,HELP 内容资产本次不动,文字差随远期 schema 票改回。
  • 查询与统计零改动:平均分直算、无剔除逻辑;用量显示数字加文字;时长显示分钟数。
  • 页面:录入与修改表单把三项标为必补(缺失时确认置灰);记录做菜缺评分走失败回执加重试。
  • 关联步骤、维度表写入、导入事务边界不在本规格内,沿用既有对账口径(本期不开)。
  • 不改老库、不改老件、不碰真库;验证一律走副本库,真库只读对照。
  • 与数据库层全局缺口裁定(重名唯一约束、外键)正交,互不干扰。

Testing Decisions

  • 好测试只测外部行为(命令、退出码、写后读回),不测内部实现。
  • 缝只取一个最高缝:CLI 唯一出口(参数加 JSON 加退出码),覆盖 9 卡路径(单条操作、批量内嵌数组、历史记录);取数层写入入口直调作为辅助定位缝,不单独设新缝。
  • 先例:既有命令级闭环测试(加菜到查看、反例非零退出)与取数级统计闭环测试;本规格的反例沿同一写法:三列各一例缺值,均须非零退出且读回无新增。
  • 副本老库实测为准:缺值被拦下、带值可写;正例写后读回关键字段。

Out of Scope

  • 把三列改成可空并迁移老库(远期 schema 票,另立;本图只做技能侧)。
  • HELP 卡面“选填”文字改回(随远期 schema 票;本次行为以本规格为准)。
  • 维度表写入、导入事务边界、批量进度与中断恢复。
  • 反馈禁占位词、补录日期等历史域既有校验(保持不变)。
  • 步骤内容修改与重排、食材关联步骤落点(各纵向票内定)。
  • 体检、批量改、备份等数据管理卡。

Further Notes

进度:100%

下一步:本票已关(执行完毕,15 条 CLI 判据全绿);「rating 传空串走成 exit 2」的缺陷已在本票内修掉,证据件见 docs/skills/skill-chef/t853-写侧缺值验收.md。

Activity

  1. added
    ready-for-agent
    on Sep 21, 2026
  2. FeatherHunter commented on Sep 22, 2026

    @FeatherHunter
    OwnerAuthor

    解决评论:执行完毕,判据全绿

    交付物(提交 9706382c):验收器械 docs/skills/skill-chef/t853-验收.mjs(213 行)+ 执行与验收记录 docs/skills/skill-chef/t853-写侧缺值验收.md(85 行)+ 源码修复 packages/skill-chef/src/history/run-record.ts。

    一行真跑

    node tooling/run-locked.mjs --ticket 853 -- node docs/skills/skill-chef/t853-验收.mjs
    

    缝只取一个最高缝:CLI 唯一出口(参数 + JSON + 退出码),照本票 ## Testing Decisions 的字面要求。反例在副本库上跑(真库全程只读:跑前跑后字节 294912/294912、mtime 与 sha256 逐次一致),写后按行数判「有没有留下半条脏数据」。

    读数

    • 9 卡 × 三列逐格可证:15 条判据全绿。三列各一例缺值(本票要求的那三条)都是 exit 4 + 消息点名 quantity/duration_minutes/rating + 读回无新增:
      • 缺用量:op=add 内嵌食材只给「适量」文字 ⇒ 4;JSON 导入空串 ⇒ 4;改用量给「适量」⇒ 4;单味追加只给名 ⇒ 4。
      • 缺时长:op=add 内嵌步骤不给时长 ⇒ 4;导入给 null ⇒ 4;单步追加不给时长 ⇒ 4。
      • 缺评分:不传 rating ⇒ 4;空串 ⇒ 4。
    • 正例补齐即入库:op=add 数字+文字两样都给 ⇒ 0;记做菜给 4 分 ⇒ 0;改用量 6 克并同时改文字 ⇒ 0;给 0 分 ⇒ 0(0 是合法评分)。读回「盐」的 quantity=6 unit=克 quantity_text=少许约6g——数字是用户给的估计数、文字是用户原话,两者都在。
    • 派生卡:母本整份复制,不接内嵌行;完整母本派生 ⇒ 0 且四张表齐增(不误伤正路)。
    • 回归:包内 node --test packages/skill-chef/test/*.test.mjs 133 过 0 败;pnpm gen:check 6/6 绿(生成物零漂移)。

    本轮修掉的缺陷

    chef.history.record 的 rating 传空串 ⇒ exit 2「缺槽位」,而同一个场景整个不传 ⇒ exit 4 点名 rating——同一件事两个定义地,且空串那条不符合本票对外契约(缺评分属取数失败档)。根因是顶层 runHistoryRecord 把空串喂给了只认数字的口径校验,而数据层 recordHistory 本来就认空串为缺值。改法:两处把空串/纯空白按「没给」归一。

    变异自证(改坏必须变红、改回必须变绿):

    变异态(去掉归一)  exit=9  R6:期望 4 实得 0 红 | 行数变化 recipe_history  ← 真落了一条没评分的脏数据
    还原态              exit=0  判据汇总:绿 15 / 红 0
    

    本票范围外(照票面不动)

    • 三列的可空性(NULL ≠ 0,让「未评分」与「0 分」可区分):## Out of Scope 第一条,随远期 schema 票。
    • HELP 卡面「评分(选填)」文字(src/help/sceneData.ts:122):818 定案明令本次不改,本票照此执行。但请维护者看一眼:卡面写「选填」而实际行为必填,这是用户侧能感觉到的文案与行为不一致;改它要动生成物与其生成器,属产品决策,本票不擅自改。
    • 页面侧三条(录入/修改表单三项标为必补、记录做菜缺评分走失败回执加重试)早已交付:src/add/pages.ts:404-423 的失败回执(renderErrorReceipt 四段+建议下一步)与 docs/skills/skill-chef/t774-run-update.mjs:611-616 的缺值探针(已声明「改食材无补丁 exit 2/加步骤缺时长 exit 4/关联步骤 exit 2,无半条」)。

    遗留(有读数,未开票)

    1. recordHistory 里「非数字串」那一支现在是死路:CLI 唯一入口 runHistoryRecord 在顶层就拦下了。本轮已把它并进「缺评分」一档(少一个定义地),但不可达的那行仍留着。属清理,不属本票。
    2. 退出码 3 在本包被 CHEF_HISTORY_CORRUPT/CHEF_RECIPE_CORRUPT/CHEF_DB_UNREADABLE 复用,而 src/cli/cmd_read.ts:3 头注写的是「3 key」——既有偏离,与本票正交。

    两条都指得出读数、但都不是本票的验收面,按开票三问先记文档不占票;谁要认领就回写这里。

  3. FeatherHunter commented on Sep 22, 2026

    @FeatherHunter
    OwnerAuthor

    执行完毕,判据全绿(15/15),证据见上一条解决评论与 docs/skills/skill-chef/t853-写侧缺值验收.md。

  4. added 3 commits that reference this issue on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions