Skip to content

fix(git): include untracked new files in diff snapshots (DEBUG #57) - #22

Merged
linkerlin merged 1 commit into
masterfrom
cursor/untracked-diff-snapshot-c2f2
Nov 2, 2026
Merged

linkerlin merged 1 commit into
masterfrom
cursor/untracked-diff-snapshot-c2f2

Conversation

@linkerlin

Copy link
Copy Markdown
Owner

Summary

失败现场和成功路径共用的 diff 快照以前只跑 git diff HEAD,宿主新建且未 git add 的文件(例如 notes.md)不会进入 episode。现在这份快照会把未跟踪新文件收成 diff --git 新文件块,两臂口径一致。

Failure and success snapshots share capture_diff_snapshot. It used to run only git diff HEAD, so an untracked new file such as notes.md was missing from the episode. The helper now appends those files as new-file hunks. Both arms stay on that one helper.

What changed

  • capture_diff_snapshot 仍先取 git diff HEAD(已跟踪文件的暂存与未暂存改动,含已经 git add 的新文件),再追加从未入库的未跟踪新文件。

  • 补充块跳过爆炸半径不计的路径(.venv、node_modules、__pycache__、.git、.env 等受保护文件)、运行态目录(memory/、.evolver/ 等,与 _is_runtime_state 同口径),以及文件头含 NUL 的二进制。读入量不超过快照剩余预算。

  • 失败侧 _failure_diff 与成功侧事件的 diff_snapshot 都走这个 helper。未改固化门、不写 Parent baseline、不调用 skip_validation、不开 val 密封。未动 DEBUG #61,也未重开未完成 run 的 tick 宿主契约。

  • DEBUG #57 标为已修。回归:未跟踪 notes.md 在 hypothesis_missing 的 episode 里可见,成功事件的 diff_snapshot 里同样可见;噪声与二进制不出现。

  • capture_diff_snapshot still starts with git diff HEAD (staged and unstaged edits to tracked paths, including a new file already git added), then appends never-added files.

  • The supplement skips blast-radius noise (.venv, node_modules, __pycache__, .git, protected files such as .env), runtime-state dirs (memory/, .evolver/, same heads as _is_runtime_state), and binaries whose first bytes contain NUL. Reads stay within the remaining snapshot budget.

  • _failure_diff and the success-path diff_snapshot both use this helper. No solidify-gate, Parent-baseline, skip_validation, or val-seal changes. DEBUG #61 and the unfinished-run tick host contract stay deferred.

  • DEBUG #57 is marked fixed. Regression: untracked notes.md is visible on hypothesis_missing and on the success event; noise and binaries are not.

How to test

  1. uv run pytest tests/test_git_ops.py tests/gep/test_solidify.py tests/gep/test_solidify_soft_continue_bugs.py tests/gep/test_solidify_fitness.py tests/gep/test_solidify_acceptance_hook.py tests/gep/test_solidify_soft_default.py tests/gep/test_no_git_no_commit.py tests/gep/test_sprint23_bandit_novelty.py tests/gep/test_sprint23_coverage_gaps.py tests/gep/test_policy_check.py -q
    Expected: 166 passed.
  2. uv run pytest tests/test_auto_trigger_and_evolution_e2e.py::TestAutoEvolutionRealReliableBeneficialE2E::test_two_round_closed_loop_rollback_then_beneficial_repair -q
    Expected: 1 passed.
  3. uv run ruff check src/evolver/gep/git_ops.py tests/test_git_ops.py tests/gep/test_solidify.py
    uv run ruff format --check src/evolver/gep/git_ops.py tests/test_git_ops.py tests/gep/test_solidify.py
    uv run mypy src/evolver/gep/git_ops.py
    Expected: ruff clean, mypy Success: no issues found in 1 source file.

Risk

Low. Recorded diff text can now include untracked new-file hunks, so the existing secret scan on this snapshot sees new source files, and later novelty comparisons can see their + lines. Tracked diffs stay first and are still truncated the same way. Noise trees are not appended. Accept/reject gates are unchanged.

Harness/evaluator governance

Upstream governance surface: gep/git_ops.capture_diff_snapshot (the diff scene stored by solidify failure and success events). Gate logic, Parent baseline writers, and val seal are untouched.
Downstream EvoX impact: N/A — no bridge or contract change. Recorded diff text may contain untracked new-file hunks.
Rollout-local scope: snapshot contents only; no proposal, shadow, or cohort change.
Promotion boundary: N/A — not a gate or default-policy promotion.
Evaluator mismatch sets: evidence (the stored diff). Observation, action, repair, verification, and belief sets are unchanged.
Non-regression evidence: untracked-file unit tests on the helper, hypothesis_missing episode, and success diff_snapshot; 166 related tests plus the two-round closed-loop e2e.
Fix-severity review: low
Owner approval: N/A
Security boundary: untracked source can now appear in the diff already scanned for secrets. .env and other protected paths stay out of the untracked supplement. No new network or host tool.
Rollback: revert this commit. Snapshots return to git diff HEAD only.
Live promotion: no
Autonomous evaluator self-editing: no

Self-check

  • Tests added or updated to cover the new behavior; gates pass locally: uv run pytest (relevant modules, 166 passed, plus 1 closed-loop e2e), uv run ruff check / ruff format --check on touched files, uv run mypy src/evolver/gep/git_ops.py.
  • No new runtime dependencies without a clear justification in "What changed".

Related

DEBUG #57

Open in Web Open in Cursor 

git diff HEAD omits files that were never added, so a notes.md created
in the worktree left both the failure episode and the success event
with an empty scene. Append those files as new-file hunks from the
shared snapshot helper, and keep dependency, runtime, and binary noise
out of that supplement.

Co-authored-by: Steper Lin <linker.lin@live.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@linkerlin
linkerlin merged commit 233bb5b into master Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants