Skip to content

fix(edit): enforced seen-line guard on write tags - #15676

Open
roboomp wants to merge 1 commit into
mainfrom
farm/76f5c83a/fix-write-tag-seen-line-guard
Open

roboomp wants to merge 1 commit into
mainfrom
farm/76f5c83a/fix-write-tag-seen-line-guard

Conversation

@roboomp

@roboomp roboomp commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Repro

A write of alpha\nbeta\ngamma returns [seen-probe.txt#B6C1]; without reading, PUT 2.=2: with +BETA against that tag used to apply and change beta to BETA instead of revealing line 2. Run cd packages/coding-agent && bun test test/write-hashline-header.test.ts: the new contract case fails against the unfixed addon.

Cause

maybeWriteSnapshotHeader in packages/coding-agent/src/tools/write-content.ts records the write tag with an empty seen-line set; assert_seen_lines in crates/pi-edit/src/modes/hashline/patcher.rs returned early for that set, conflating no lines seen with no provenance known.

Fix

  • Treat Some(empty) as nothing seen in assert_seen_lines, preserving the None early return and the inline reveal/retry path.
  • Update packages/coding-agent/test/write-hashline-header.test.ts to assert rejection, unchanged file, and success after the reveal; retain an unanchored append through a local:// write tag.
  • Update the permission-denied fallback write-to-edit test to retry after the anchor reveal; document the user-visible guard in the coding-agent changelog.

Verification

bun test test/sdk-file-write-fallback-extension.test.ts test/write-hashline-header.test.ts passed (13/13) with the rebuilt native addon; the four affected edit suites passed (20/20), and a manual write-tag edit returned never displayed with 2:beta revealed and the file unchanged. The contract test failed against the old addon (1 failure). Skipped pre-publish gates (bun run fix, bun check, bun run test) because the same check and full-suite commands fail on a clean origin/main archive: bun check fails compiling zstd-sys in the shared Rust cache with Operation not permitted; bun run test fails at packages/utils/test/dirs-xdg.test.ts:82 with EACCES creating /srv/agent-home/.omp-dirs-xdg-*. The worktree exhibits the same failures; the diff-related write-to-edit test failure from the first gate run was corrected and its focused suite passed.

Fixes #15666

Treat empty write provenance as no displayed lines so anchored edits reveal content before applying.

Updated the write-to-edit contract test and kept unanchored appends working.

Fixes #15666
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T04:30:19.814830Z a9b2b1d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

edit: anchored edits against a write tag skip the seen-line guard (empty seen set disables it)

1 participant