Skip to content

[split-1066] U6 - fix(write-to-file): run the diff cleanup when handleError rejects #1937

Description

@easonLiangWorldedtech

Unit U6 of the PR #1066 split (5/6).

Split plan: #703
PR: #1932
Content source of record: tag pr1066-source = 46d1d218701f0ce2d675b1b315489bacb6b0f77d (easonLiangWorldedtech/Zoo-Code).

Unit contract

The execute() cleanup invariant: a finally around handleError so the diff cleanup runs even when handleError rejects, the writeApproved flag, and the consecutive-mistake-counter order.

Why this unit exists on its own

Single provider group + single gate scope (the execute() error path).

Boundary

Files and budget

  • src/core/tools/WriteToFileTool.ts +45/-11 — content subset of source
  • src/core/tools/__tests__/writeToFileTool.spec.ts +379/-4 — content subset of source
  • budget: 439 a+d / 2 files — SOFT-OVERSHOOT (rationale: single provider group + single gate scope; under the 1000 hard cap)
  • mutation gate: 34 changed executable lines — under the 500 cap; valid mutants for the whole PR are 116 / 400, so no directive was added by this unit.

Verification (must pass by once, binary)

  • zdt split verify --contract U6.json --worktree <wt> --head 9b93a6f882a4 — PASS (every changed file is a content subset of the source of record, or an explicitly sanctioned allowNew file).
  • Tests: 259 passed / 5 skipped, exit 0 (narrowest relevant suites: Task.spec.ts, writeToFileTool.spec.ts, writeToFileTool-partial-state-cleanup.spec.ts, removeClineFromStack-delegation.spec.ts, presentAssistantMessage-custom-tool.spec.ts).
  • Changed-line coverage: 14 covered / 0 uncovered — PASS.
  • ESLint --prune-suppressions --max-warnings=0: clean on every touched file; suppression counts unchanged.
  • No .changeset file, no CHANGELOG edit (AGENTS.md).

Deviations recorded

  • Owns the test reports a filesystem error only once across the streaming and execute phases, originally attributed to U5 (see U5).

Reproduce

git fetch https://github.com/easonLiangWorldedtech/Zoo-Code p1066/u6-execute-error-path-cleanup
node zdt.mjs split verify --contract U6.json --worktree <wt> --head 9b93a6f882a4
node zdt.mjs split measure --worktree <wt> --base e3c10401f760 --head 9b93a6f882a4
pnpm --dir src exec eslint --prune-suppressions --max-warnings=0 <touched file>

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions