Repository navigation
fix(snapshot): 终态快照不声称进程存活,未知写 null(#116 D-07 裁决 B) - #117
Merged
Merged
Conversation
契约先行:§27 新增 REV-35(判活/退出码三态 + 同进程退出码交接 + 旧快照按未知显示)。 §6 通知字段表加 process-alive / process-alive-known / exit-code-known; §8 详情显示加「未知不是已退出」。实现与验收证据随后落。
判活/退出码从二态改成三态(CONTRACT §27 / REV-35): - processAlive 只在**观测到退出**时写 false(退出事件,或探活证明进程组消失), 没观测到写 null;processAliveKnown 仅在有观测证据时为 true。 D4(watch 命中、进程仍在跑)修前写 false,现在写 null + known:false。 - exitCode 同理:数字 = 观测到,null = 没拿到,exitCodeKnown 区分二者, 绝不把「没拿到」读成「退出码 0」。 - 退役代的退出回调不再把退出码丢掉(同进程 /reload):合并写回已持久化快照 (只碰 exitCode/exitCodeKnown,不动 status/finishedAt),收养代结算时读取。 跨进程收养拿不到 → null + false,不假装。 - 通知字段表加 process-alive / process-alive-known / exit-code-known; TUI 详情、hold / print-wait 结果行、完成卡片统一走 snapshotLiveness / formatExitStatus:unknown 绝不渲染成 exited,null 绝不渲染成 exit 0。 - 旧快照(无这两个字段)一律按「未知」显示,不迁移、不推断。 验收 1-5 见 tests/l-snapshot-honesty.test.ts;旧断言按新契约更新(d-storage、 g-revive 的 Linux 用例)。typecheck exit 0;npm test 红集合与 origin/main 基线逐条相同。
独立复核(fresh-context reviewer)的 12 条 findings 逐条处置(docs/reports/snapshot-honesty.md §5): - F2(major):killed 结算现在用一个独立的观测值 `"killed"` —— 退出事件看到了,但结论是 killKind,spawn 层对信号死亡报的 `1` 是它自己的兜底、不是子进程的判决,所以不记退出码。 修前同一次 timeout kill 会按「退出事件/ killTree 谁先到」记 `1` 或 `null`(不稳定)。 - F1/F8:契约写明「确定的数字」的两个来源(观测到的退出码 / 启动失败的判决 1), `hasObservedExitCode()` 采纳 `exitCodeKnown`(字段从 write-only 变成可读)。 - F3/F7:`finalize` 不再丢掉对象上已有的数字;退役代交接同时更新同一实例持有的当前对象。 - F4:`sweepLiveness` 对无 pid 的快照不再声称 `gone`。 - F5:结果行对缺失的退出码也说 `exit unknown`(两个调用方都只渲染终态行)。 - F6:`async_wait` 行保持冻结形状(有数字才有键),三态只在快照里。 - F9:新增 tests/d-reload.test.ts 用例 —— 真 init()/onFinalize/renderer,钉住生产通知与完成卡片。 - F10/F11/F12:payload 镜像、契约与报告措辞、死代码与重复收窄。 顺带把「first mutation rollback 用 git checkout 冲掉未提交修复」这件事记进报告,避免下一个人踩。 验证:typecheck exit 0;全量 508 条 / 479 pass / 16 fail,红集合与 origin/main 基线逐条相同; 变异 ①(finalize 无条件 false)→ 2 红,变异 ②(null 当 false 渲染)→ 4 红。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #116
裁决 B 的落地
终态快照不声称进程存活;未知写
null。 契约修订见docs/CONTRACT.md§27(REV-35)+ §6 通知字段表 +§8 详情显示;证据见
docs/reports/snapshot-honesty.md。processAlivefalse= 退出被观测到;null= 没观测到(显式写进 JSON,不是缺字段)processAliveKnowntrue仅当上面那个值是观测的结论,不是默认值exitCodenull= 没拿到(绝不等于exit 0)exitCodeKnowntrue仅当exitCode是确定的数字finalize()多了observed: "exit" | "killed" | "gone" | "unknown",21 个调用点逐个分类:只有真看到退出(退出事件 / 探活证明进程组消失 /
killTree()确认)才写false+known: true。finalize恒写false):D4(watch 命中、进程仍在跑)修前processAlive: false,修后null+known: false;对照组(真退出)仍是false+known: true+ 真退出码。(只碰
exitCode/exitCodeKnown,不动status/finishedAt),收养代结算时读取;跨进程收养拿不到→
null+false,不假装。两个用例都在tests/l-snapshot-honesty.test.ts。snapshotLiveness/formatExitStatus/exitSuffix):通知字段表新增process-alive/process-alive-known/exit-code-known,TUI 详情行、hold /pi -p结果行、完成卡片都走它 ——
unknown绝不渲染成exited,null绝不渲染成exit 0。processAlive: false而没有processAliveKnown不推断为「已退出」(0.5.3 那个
false是默认值),不迁移、不崩。验证
npm run typecheck→ exit 0。npm test(macOS,这台机器有 16 条既存红):508 条 / 479 pass / 16 fail / 13 skipped;红集合与
origin/main@56fff93的基线逐条diff为空(16 条全是 mac 既存红,与本次改动无关)。CI(ubuntu)为准 —— 三处 Linux-only 断言按新契约改写(
exitCode由undefined变null/观测值,并把「探活 watcher 与退役代退出回调的竞态」写成不变式而不是钉死数字)。
tests/l-snapshot-honesty.test.ts(验收 1–5 + 对照组)与tests/d-reload.test.ts一条走真
init()/onFinalize/renderer 的生产链路用例。finalize回到无条件false→ 2 红;② 把null当false渲染 → 4 红。已知边界(接受,写进契约)
exitCode: null(少一条证据,绝不写出与事实相反的
false)。killed行不带退出码(结论是killKind;spawn 层对信号死亡报的1是它自己的兜底,不是子进程判决)。