Repository navigation
fix(record): an edited copy keeps following upstream (#317 item 1) - #368
Merged
Merged
Conversation
willgosnold
marked this pull request as ready for review
October 26, 2026 16:56
This was referenced Oct 26, 2026
These fail on main: an edit to a copy's destination records as a replace, so the copy stops following upstream, and an edited rename of a file that a copy still builds from records as delete + add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An edit to the destination of a copy or move of an upstream file, while another output of that file is on disk, now records as a file edit on the destination's path whose base is the upstream file. The build applies it after the structural edits, so it builds that output alone, and sync merges upstream's changes to the source into it, reporting a conflict as for any file edit. It was a replace, which froze the copy. - assemble: a file edit on a path upstream doesn't have waits for the structural edits and edits the upstream file a copy or move stages there (editedUpstream); otherwise it is gone, as before. - sync: a destination file edit merges with that upstream file, found with the same structure pass at the pins, only when some file edit sits under a copy or move destination. - record: an edited rename whose source a copy still builds from is a move plus a file edit on the new path. An edit to the source is a file edit once every other output on disk is an edited destination. Re-editing the copy updates its file edit, and deleting it drops the edit and records a delete. A replace no longer deletes block entries; a destination file edit does once nothing reads them. - tests: the source-edit and vendor hook tests use inputs that don't touch upstream's line or a long change name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… comments (#317) The no-comments pass took out the comments this PR added or rewrote. `each` now says the rule in names (isDestination, others, nothingReadsEntries, editedDestination), and destinationSources takes an atPin callback in place of the upstream and its files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…edit (#317) A hand-written copy or move of a copy's destination after its file edit read upstream's text or refused as gone, where main's replace built the edit. Deleting the edited copy dropped the edit from the copy that reads it, and record wrote the edit into a change before the copy. A gone destination said upstream no longer has it, though upstream lost only its source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#317) A file edit on a copy's or move's destination applied after every structural edit, so a later copy or move of the destination read upstream's text or found nothing to move. It now applies in its place in the series, where the replace it supersedes applied: a later copy or move reads the edit, and the destination still has a base and follows upstream. applyStructure reports the upstream file under each such edit, and the build and sync both read it. record counts a destination edit as structural when it picks a change, so it never goes into a change before its copy, and deleting an edited copy that a later copy reads keeps the edit, as main does for a replace. A gone destination now says no earlier copy or move reaches it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…th the controlled message (#317) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
willgosnold
force-pushed
the
fix/317-edited-copy-follows-upstream
branch
from
October 26, 2026 18:14
be30149 to
8f02e9a
Compare
…te supersedes (#317) A hand-written replace or delete of an edited copy left the copy's file edit in place with nothing building from it. Sync still merged it, so an upstream change to the line it edits wrote conflict markers into an ours copy no output reads, and build, status and the commit hook refused. Main builds that case, since a replace never merges. applyStructure now names each destination file edit whose ours copy no staged path reads once every structural edit applies. Sync doesn't merge it, and the build skips its stale and conflict-marker checks, so the build writes the replacement or omits the path. An edit a later copy or move reads, even after its own delete, still merges. A superseded file edit on an upstream path keeps main's behavior. CHANGELOG and DESIGN say a deleted edited copy keeps its edit while a later copy or move reads it, and that a source edit is a replace only while an unedited output still builds from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recording an edit to a binary copy wrote `file <dest>`. Once upstream changed the source, sync reported a binary conflict, left the base behind and said "Nothing to do" on the next run, so status and build refused with no way out but hand-editing CHANGE.md. Main recorded a `replace` there, which kept building our bytes. When base, ours or upstream's file of a destination's file edit isn't text, sync now keeps ours as the replace did, moves the base to upstream's file, lists the edit in replacedUpstreamChanged and names it on stderr. That covers a binary edit, a mode-only edit of a binary copy and a text copy whose source upstream makes binary. A file edit on an upstream path keeps main's conflict (#374). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stination's problems (#317) A copy destination's missing-copy, stale and gone problems dropped the change name that main printed for a copy's replace. They now report as the change's file edit, and the missing-copy detail says which copy is gone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Owner
Author
|
Root countersign: independent verification PASS covering exact head 5be46d3 against main 598249d. Full lanes and a design review at 3505d53 and 8f02e9a, then focused verifiers at accb1da and 5be46d3, with all six CI checks green at this head. I corrected one test count in the description, and the head is unchanged. This authorizes an exact-head squash merge of 5be46d3 only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses item 1 of #317. The other items stay open.
Problem
Copy an upstream file and commit, so
recordwritescopy skills/a -> skills/b. Then editskills/b/SKILL.mdand commit.recordand the commit hook wrotereplace skills/b/SKILL.md, a frozen copy. From then onskills/bmissed every upstream change toskills/a. An upstream edit to the very line we changed was dropped with no conflict, andstatussaid no problems. The same rule recorded an edited rename of a file that a copy still builds from asdelete+add.Design
An edit to a copy's destination is now a
fileedit on the destination's path. Its base is upstream's version of the source file, and its ours copy is the edited file.fileedit on a path upstream doesn't have applies in its place in the series, among the structural edits (applyStructure), where thereplaceit supersedes applied. It edits the upstream file that an earliercopyormovestages at its path. The base must match that file, or the edit isstale. From there on its ours copy is that path's file. A latercopyormoveof the path reads the edit, as it read thereplaceon main, while the source and any other copies still build from upstream. A destination edit that no earlier copy or move of an upstream file reaches isgone, andstatussays so in those words. Once every structural edit applies, a destination edit whose ours copy no staged path reads builds nothing, as after a later hand-writtenreplaceordeleteof its path that nocopyormovereads first. The build doesn't check that edit forstaleor conflict markers, so neitherstatusnor the commit hook refuses it.syncmerges the edit with the new upstream source through the existinggit merge-filepath. A clean merge updates the copy. A conflict leaves markers in ours,syncreports it, andstatus,buildand the commit hook refuse until it is resolved, as for any file edit.syncfinds the source with the same structure pass the build uses (applyStructure'supstreamOf, over the pinned files). It reads the other upstreams' pinned files only when some file edit sits under a copy or move destination. It doesn't merge a destination edit that builds nothing, so that edit never gets conflict markers. When base, ours or the new upstream source isn't text,synccan't merge a destination edit. That covers a binary copy, a mode-only edit of one, and a text copy whose source upstream makes binary.syncthen keeps ours, as main'sreplacedid. It moves the base to upstream's file, lists the edit inreplacedUpstreamChangedand names it on stderr, with how to take upstream's file instead, which is to write it over the output and runrecord. So the copy keeps building our bytes andstatusis clean. Afileedit on an upstream path keeps main's binary conflict (A binary file edit that conflicts with upstream can't be recovered through sync #374).eachwrites the destination edit when another output of the same upstream file is still on disk. An edit to the source stays areplacewhile an unedited copy still builds from it. Once every other output on disk is an edited destination, in an earlier commit or the same one, the source edit is a plainfileedit. An edited rename whose source a copy still builds from ismoveplusfile <new path>. Editing the copy again updates its file edit. Deleting the copy takes the file edit out of its change and records adelete, as for areplace. When a latercopyormovereads the copy, the file edit stays so that output keeps it, and only thedeleteis recorded, as main does for areplace. Since the build applies a destination edit in series order,recordcounts it as a structural edit when it picks a change. It goes only into the change with thecopyormove, or a later one, andrecord <earlier change>refuses and names that change.DESIGN.md (build order, sync, record) and CHANGELOG.md say the same.
Alternatives
A new edit kind, such as
file <from> -> <to>. It would name the source in the change, sosyncwouldn't need the structure pass. It duplicates the file edit's copies, merge, conflict,showand intent code, and it names the source a second time, which can disagree with thecopyline. Rejected.Block entries keyed by output path. Entries cover paragraphs only and are keyed by upstream path, so they can't hold an arbitrary edit to one output. Rejected.
Applying every content edit after the structural edits. File edits would all key on output paths, but every recorded
moveplusfile <upstream path>from fix(record): record a renamed output as a move #314 would break, and so would the rule that any change can take a file edit. Rejected.A stored diff applied at build. A 3-way merge succeeds where a diff fails after upstream rewords nearby lines ("Changes store states, not diffs" in DESIGN.md). Rejected.
Giving
replacea base.replacemeans ours wins with no merge, for binaries and rewrites. Merging it would change every existing replace. Rejected.Applying destination edits after every structural edit. This PR's first version did that. A later hand-written
copyof the destination then built upstream's text, and amoverefused asgone, where main'sreplacebuilt the edit. Rejected for that regression.Merging a destination edit that builds nothing, and ignoring it only in the build.
syncwould report a conflict and write markers into a file no output reads. Rejected, as is merging it only when the merge is clean, which adds a second rule tosyncand still leaves the conflicting case behind.A third
Sourcekind that carries the source path, so the build and the hook could take the destination's mode from upstream. It touchesgithook.tsfor acore.fileMode=falsecorner. The destination's source stays{ kind: "ours" }, andclassifyOnereads the change's edit kind, as it already does to tellunaddfromunreplace.Recording a binary edit on a copy's destination as a
replace, as main did. It fixes a binary copy edited and recorded, but not a text copy whose source upstream later makes binary. That copy still reachessync's binary conflict, which never moves the base, sostatusstaysstaleandsyncsaysNothing to do. Fixing that needs thesyncrule above anyway, and the rule already covers the binary copy. Both build our bytes. Main'sreplaceof a copy's destination gets noreplacedUpstreamChangedentry, since upstream has no file at that path, so main froze the binary copy without a word, where thesyncrule reports it. Rejected for the second rule it adds.Reporting the kept edit as a conflict while moving its base. The summary would count a conflict with no markers to resolve and a clean
status. Rejected, as are rewriting the edit to areplaceduringsync(a new kind ofsyncwrite) and taking upstream's bytes when ours differs from base only in mode (a second binary rule that upstream paths don't have).Tradeoffs
synccan't merge as text doesn't follow upstream, as main'sreplacedidn't.syncsays so on stderr and inreplacedUpstreamChanged, which the patchbook-update skill already handles. A mode-only edit of a binary copy keeps our old bytes with our mode, rather than taking upstream's new bytes. To take upstream's file, write it over the output and runrecord.fileedit or block entries, the copy keeps that text as it was when you edited the copy. Upstream's later changes still merge in, but later changes to the source's own edit or entries don't reach the copy. Before this PR nothing reached it.syncmoves upstream's mode into both copies, so an upstream mode change still reaches the output. Undercore.fileMode=false, the hook doesn't stage that new mode for the destination the way it does for an output built straight from upstream.replaceon main and over afileedit on an upstream path. A hand-writtenreplaceof the destination in a later change builds the replacement, and adeleteremoves the output. Then nothing builds from the file edit, sosyncleaves it alone, and an upstream change to the line it edits doesn't stop the build, as on main.recordnever writes either while the file edit is there. If you later remove that hand-writtenreplaceordelete, the file edit isstaleuntil upstream next moves, becausesyncat an unchanged pin does nothing. The nextsyncmerges it correctly. Main has the same dead end for anyfileedit whose base is behind the pin, such as one merged in from a branch.replacebefore this PR stays areplace. Editing it again updates the replace.deleteplusadd, as it was with thereplace(Renaming or moving an edited copy freezes it again #373).changes/<name> file <path>, as a copy'sreplacedid on main, and a missing copy says which one:invalid changes/b-edit file skills/b/SKILL.md: its ours copy is missing. A file edit on an upstream path keeps main's wording,its base or ours copy is missing.Proof
All numbers are at the head, 5be46d3.
replaceordelete+add. The tenth edits only the source, which stays areplace, so it passes on both. Commit 88a38cd adds 5 more, which all fail on 3505d53. They cover a later hand-writtencopyandmoveof an edited copy, deleting an edited copy that a later copy reads,recordrefusing a destination edit into a change before its copy, and thegonewording. Commit 8f02e9a adds the sync test for a destination edit with a missing base copy. Commit f30f940 adds 3 more, which all fail on 8f02e9a. A hand-writtenreplaceand a hand-writtendeleteof an edited copy each build after upstream changes the line the copy's edit changed. Sync merges nothing into the superseded edit, andstatusis clean. The commit hook takes a hand-writtenreplaceover a copy whose superseded edit holds sync's conflict markers. f30f940 also adds a sync to the deleted-copy test, so an edit a later copy reads still merges. Commit accb1da adds 4 more. In 3 of them a binary copy has its bytes or its mode edited, or a text copy's source turns binary. Each fails on f30f940 with sync's1 conflicts. Copy, edit, record, a change to the source upstream and a sync then build our bytes, andstatusis clean. The text copy then takes upstream's file once it is written over the output and recorded. The fourth, a mode-only edit to a text copy, passes on both and is there for coverage. Commit 5be46d3 adds 4 more and changes 1. They cover a copy's missing base copy, missing ours copy, both missing, and a base that differs from its source, instatus,buildandstatus --json, and it changes thegonetest to the new wording. All 4 new ones and the changed one fail on accb1da, which didn't name the change. Theclassifyunits state the destination rule.bun run typecheckexits 0, andtest/units.test.tspasses 331 of 331.bun test test/e2e.test.ts -t "copy|move|replace|record|sync|track|binary|missing"passes 835 of 835.record, the commit hook,sync,statusandbuildagainst clean clones. 14 of its 55 expectations fail on 87e3dab, and none fail at 5be46d3. Its journeys cover the hook and directrecord, an overlapping upstream edit (conflict, refusal, resolution), a source edit after the copy edit, an edited rename, deleting the edited copy, and a copy already recorded as areplace.0 of ours merged cleanly, 0 conflicts. Against the accb1da run, the fourJ_missing_*status rows now pass and every other row is unchanged. The 10 failures are the known ones. The renamed copy fails twice (Renaming or moving an edited copy freezes it again #373). The 4 superseded sync rows still expect the conflict that round 4 removed, and main prints0 conflictstoo. The superseded upstream-path control fails four times, and main refuses the same way (A conflicted file edit that a later replace supersedes still blocks build and status #378).binaryandbinaryrecover. In both, sync now keeps our bytes andstatusexits 0. Inbinary,buildexits 0 too. Inbinaryrecover,last-sync.jsonlists the copy inreplacedUpstreamChanged. Their new expectation failures are round 1's expectations of a refusal and a binary conflict.binarymain, a binaryfileedit on an upstream path, is unchanged (A binary file edit that conflicts with upstream can't be recovered through sync #374).handcopyandhandmovecarry the edit.twicematches main, where the laterreplacebuilds.The drivers and transcripts are in the #317 owner folder of this run.
🤖 Generated with Claude Code