Skip to content

fix(patch): anchor V4A Begin/End Patch markers to full lines - #76394

Merged
teknium1 merged 1 commit into
mainfrom
salvage/v4a-marker-anchor-74458
Aug 1, 2026
Merged

fix(patch): anchor V4A Begin/End Patch markers to full lines#76394
teknium1 merged 1 commit into
mainfrom
salvage/v4a-marker-anchor-74458

Conversation

@teknium1

@teknium1 teknium1 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

V4A patches no longer suffer silent data loss when the patch content mentions the boundary markers. parse_v4a_patch scanned for *** Begin Patch / *** End Patch with unanchored substring tests, so a content line like +*** End Patch (e.g. docs describing the V4A format, or nested patch text) was treated as the real boundary.

Salvage of #74458 by @spfcraze (authorship preserved via cherry-pick), clean onto current main.

Root cause: file-operation headers (*** Update File: etc.) already used anchored regexes, but the Begin/End markers used '*** End Patch' in line substring matching. A +/-/space-prefixed content line containing that string matched, truncating or discarding operations.

Changes

  • tools/patch_parser.py: boundary scan now matches ^\*\*\*\s*Begin\s+Patch\s*$ / ^\*\*\*\s*End\s+Patch\s*$ (whole line, column 0). The no-space ***Begin Patch form is preserved.
  • tests/tools/test_patch_parser.py: new TestBoundaryMarkersInContent — 3 regression tests.

Validation

Live before/after against the real parse_v4a_patch:

Scenario Before (main) After
+*** End Patch inside Add content ['doc line one'] — 2 lines silently dropped, reports success all 3 content lines preserved
+*** Begin Patch mid-content 0 operations, no error (silent no-op) 1 operation, content intact
***Begin Patch no-space markers accepted still accepted (no regression)

scripts/run_tests.sh tests/tools/test_patch_parser.py — 26/26 pass.

Closes #74458.

Infographic

V4A patch markers anchored to full lines

The boundary scan in parse_v4a_patch used substring matching, so a
content line mentioning "*** End Patch" (docs about the patch format,
nested patch text) truncated the patch, and "*** Begin Patch" in
content reset the start boundary — silently dropping already-parsed
operations while reporting success. Match only whole-line markers at
column 0, preserving the no-space "***Begin Patch" tolerance.
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on f792c9d

ℹ️ Info

Desktop E2E visual evidence · View test artifacts · View job

3 visual diffs.

inline evidence upload failed.

Failed to upload diff-1508682a2ae8-boot-ready-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-1508682a2ae8-boot-ready-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso)

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) labels Aug 1, 2026
@teknium1
teknium1 merged commit 8c17272 into main Aug 1, 2026
40 checks passed
@teknium1
teknium1 deleted the salvage/v4a-marker-anchor-74458 branch August 1, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants