Checkpoint ignore-semantics and restore-journaling follow-ups (#1410 threads wM68EMCO / wM68EMCv / wM68EMB_)

未關閉
#2,706 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 3 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
22/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
git, typescript
領域
backend

研究方向

Start with the checkpoint journaling in src/core/checkpoints/index.ts (the ignore skip near line 399, the early return near 404-408, and the restoreFile delete branch near 571-580), then isPathIgnored near line 625. Also read src/services/checkpoints/ShadowCheckpointService.ts (commit staging near 256-264) and preStepRestoreTarget in src/core/checkpoints/rollback.ts. The issue is a plan to be written before any code, with no PR allowed yet, so a newcomer should first help settle the design rather than patch.

由索引模型根據 Issue 內容生成。

描述

Tracking-issue draft: checkpoint metadata honesty (#1410 threads wM68EMCO, wM68EMCv, wM68EMB_) | draft for lead review; lead opens it

Title: Checkpoint ignore-semantics and restore-journaling follow-ups (#1410 threads wM68EMCO / wM68EMCv / wM68EMB_)

Two units in one issue, same family: the rollback metadata a checkpoint reports is not always the state the code acted on. Premises below were verified line by line against head bb9fe5fc528e124cd79442553ee4a3aecb06741d (sha1-40, the head published before today).

Unit A: ignore-semantics (threads wM68EMCO and wM68EMCv, one helper, one commit).

  • Premise 1: journaling skips an ignored write at src/core/checkpoints/index.ts:399 (continue) and returns early when every write in the step is excluded at 404-408, while the commit itself is stage-all based (src/services/checkpoints/ShadowCheckpointService.ts:256-264 uses git.add([".", "--ignore-errors"])). A path already tracked in the shadow repo and ignored only later is therefore committed while the journal skips it: isPathIgnored asks check-ignore with --no-index (625), which reports the rule and not the index membership.
  • Premise 2: isPathIgnored returns false for every git failure (catch at 627-630). In restoreFile the delete branch only refuses when the path is confirmed ignored (571-572) and otherwise removes the file (575-580), so a transient git error reads as not ignored and a live, never-tracked file is deleted unrecoverably.
  • Fix shape: decide tracked-ness from the index or tree before applying an ignore rule; add a throwing judgement used only inside the delete branch so unknown is not confused with confirmed-not-ignored; keep the permissive false for the write-side skip at index.ts:399. Tests: tracked-then-later-ignored; git failure during restore of an untracked file.
  • Cost: about ten executable lines plus two tests; rides the split track because this branches gate operand (781) already exceeds 500.

Unit B: restore journaling (thread wM68EMB_, major, heavy lift, registered here, not yet executed).

  • Premise: appendChanges has exactly one production call site, src/core/checkpoints/index.ts:448 (checkpoint save). Saves and restores are journaled, restores are not, so a save A, restore B-to-A, save C, restore C-to-previous sequence resolves the undone state from preStepRestoreTarget (src/core/checkpoints/rollback.ts:100, used at 167 and 220) which still points at the state the last restore undid.
  • Fix shape, two candidate designs to choose between in the unit: journal one entry per restore, or record the restored target explicitly and have preStepRestoreTarget consume that. Sequential-state test required, not a single-restore test.
  • Cost: new executable lines plus a sequencing test; queued next to the save-metadata unit already recorded under #1991.

Neither unit may open a PR until this issue carries the plan; both cite #1410 threads by id.

LEAD NOTE (issue owner): premise line citations carry frame bb9fe5fc528e124cd79442553ee4a3aecb06741d and were re-checked valid at current published head 17f224ef1900d9ae5226317824d7d06373f6de97 - the files cited (src/core/checkpoints/index.ts, src/services/checkpoints/ShadowCheckpointService.ts, src/core/checkpoints/rollback.ts) are byte-identical between the two heads (batch 11 touched only Task.ts, Task.spec.ts and the service spec). Neither unit opens a PR until this issue carries its plan (planned-and-issued).

主要語言
TypeScript
星號
2k
分支
301
平均合併
3 天 14 小時
30 天內合併 PR
103

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Zoo-Code-Org/Zoo-Code 的其他 Issue

查看 Zoo-Code-Org/Zoo-Code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。