When a file has no trailing newline (for example one created by
text_editor write without a final newline), a line edit that inserts
past the last line was written straight after it, merging the two
lines: "alpha\nbeta" + {from: 3, content: "gamma\n"} became
"alpha\nbetagamma\n", while the tool reported 3 lines.
Terminate the unterminated last line before writing content appended
past end of file.
All three patch methods replaced the destination with a root-owned 0600
file, removing executable bits and preventing host users from editing
bind-mounted files. Preserve the existing mode and, when running as root,
UID/GID in one shared helper before atomic replacement. Read metadata once
and use os.replace directly; metadata errors leave the original intact.
Add regression coverage for each patch format, permission modes, root
ownership preservation and failed metadata updates. Document the existing-
file scope; ownership policy for new workspace files remains separate.
Validation: 48 focused editor tests passed, plus 15 metadata checks in the
root container. Live bind-mount checks confirmed host-owned files remain
writable and executable by the host user after all three patch methods.
Introduces patch_text editing for the Docker-local text_editor, sharing request validation and freshness-state logic with text_editor_remote while preserving legacy line-number edits. Adds anchored context patching, safer state handling after context edits, updated model guidance, live remote wrapper reuse, and focused regression coverage for chained patches and Python replacement cases.