fix(edit): show candidate lines with similarity scores on oldText match failure#97038
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 6:00 PM ET / 22:00 UTC. Summary PR surface: Source +144, Tests +100. Total +244 across 2 files. Reproducibility: yes. source-level: current main's getNotFoundError emits only the generic mismatch text, and edit execution routes through applyEditsToNormalizedContent. I did not run a live edit command in this read-only review. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land one maintainer-selected bounded edit-diff diagnostic with redacted real terminal proof, then close or rebase the sibling candidate PRs against that canonical output. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main's getNotFoundError emits only the generic mismatch text, and edit execution routes through applyEditsToNormalizedContent. I did not run a live edit command in this read-only review. Is this the best way to solve the issue? Mostly yes: the shared edit-diff helper is the right layer because execution and preview share it, and the patch keeps matching semantics unchanged. The remaining questions are the canonical output shape and visible real behavior proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e80e8a2b6730. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +144, Tests +100. Total +244 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review Fixed P2: replaced .sort() with .toSorted() for candidate ranking. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
1 similar comment
|
@clawsweeper re-review |
When edit tool cannot find oldText, include up to 3 near-match candidate lines with similarity scores and line numbers. Caps input size (MAX_LINES 3000, MAX_LINE_LEN 200) to avoid unbounded CPU on large files. Reuses existing levenshteinDistance helper. Closes openclaw#97032
Fixes lint violation: unicorn(no-array-sort)
651751a to
59b8f92
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Land-ready maintainer proof for exact head
|
|
Merged via squash.
|
…ch failure (openclaw#97038) * fix(edit): show candidate lines on oldText match failure When edit tool cannot find oldText, include up to 3 near-match candidate lines with similarity scores and line numbers. Caps input size (MAX_LINES 3000, MAX_LINE_LEN 200) to avoid unbounded CPU on large files. Reuses existing levenshteinDistance helper. Closes openclaw#97032 * fix(edit): use toSorted instead of sort for candidate ranking Fixes lint violation: unicorn(no-array-sort) * fix(edit): keep candidate truncation branch-compatible --------- Co-authored-by: Vincent Koc <[email protected]>
…ch failure (openclaw#97038) * fix(edit): show candidate lines on oldText match failure When edit tool cannot find oldText, include up to 3 near-match candidate lines with similarity scores and line numbers. Caps input size (MAX_LINES 3000, MAX_LINE_LEN 200) to avoid unbounded CPU on large files. Reuses existing levenshteinDistance helper. Closes openclaw#97032 * fix(edit): use toSorted instead of sort for candidate ranking Fixes lint violation: unicorn(no-array-sort) * fix(edit): keep candidate truncation branch-compatible --------- Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
When the
edittool cannot findoldTextexactly, its failure only reports the expected and observed text. Agents cannot see the closest candidate lines, so small typos, indentation drift, or escaping differences lead to repeated blind retries.Why This Change Was Made
The failure path now performs a bounded similarity scan and reports the three strongest candidate lines with scores. The scan is capped at 128 Ki UTF-16 code units and 1,000 lines, candidate display is capped at 120 characters, and unrelated matches below 45% are omitted. The successful edit path is unchanged.
User Impact
Edit failures become actionable without dumping large files or adding work to successful edits. Diagnostics identify likely typo, indentation, and escaping mismatches while keeping output and computation bounded.
Evidence
node scripts/run-vitest.mjs src/agents/sessions/tools/edit-diff.test.ts src/agents/sessions/tools/edit.test.ts— 9 diagnostic tests and 23 existing edit-tool tests passed.59b8f921f6d57ed186ed46a2b33b2e95d0601b3d.tbx_01kwwh3bersv6jy68szp13b21a(Actions run 28820306743); exact-head CI is tracked in Actions run 28824931017.Closes #97032