Repository navigation
seam guard: fork-seams.json is a gate file; a seam file may get lost upstream lines back (#968) - #1034
Conversation
…upstream lines back (#968) - .github/fork-pr-queue.json: the gate rule lists .github/fork-seams.json, so a change to the upstream-seam list needs the merge-path and state lenses (and the code lens with other files), as docs/fork/updates.md says ("reviewed like any gate change"). - fork-seam-check.cjs: a pull request that lowers a seam file's "lost" entry in its own list (neither count raised) may put those upstream lines back: one added line per "gone" lowered, one lost line of main's file per "lines" lowered beyond those. The run from upstream holds the lowered entry exact, so a fork line in place of upstream's is still refused there. With "lost" left as main's, the refusal says to lower it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: code · reviewer: lens agent (Claude) · read at: 6d877ba 🤖 Generated with Claude Code |
|
lens: state · reviewer: lens agent (Claude) · read at: 6d877ba 🤖 Generated with Claude Code |
|
lens: merge-path · reviewer: lens agent (Opus 5.5) · read at: 6d877ba Other attacks tried, none got through:
verdict: not safe to merge 🤖 Generated with Claude Code |
…out (#968) A lowered "lost" `gone` now allows lines back only when `lines` drops at least as much: a line put back where upstream has it is in order again, so it lowers both. One put back out of order (upstream `lock(); work(); unlock();` as `lock(); unlock(); work();`) lowers `gone` alone and is refused, with a hint to put it where upstream has it. The refusal for a line moved or re-indented back now says to lower the entry, and refusals name updating the branch when main's "lost" entry changed since the merge-base. Each doc comment sits above its own function; the docs say what the gate rule does exactly. New tests: the out-of-place case, the counted-only rule, the stale-branch hints, the moved-back hint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-ups from the #965 reviews: the issue body plus its one comment (the merge-path lens on #979).
What changed, per item
1. The merge gate rated
.github/fork-seams.jsonas a normal file. It is critical now..github/fork-pr-queue.json: thegaterule lists.github/fork-seams.json.codelens was enough.review_judge.test.py:NOT_GATEkeeps only.github/fork-ci-tests.txt. The seam list is in the critical-paths list, and the newtest_a_seam_list_change_needs_the_gate_lenses_and_with_code_the_code_lenscovers it. Red: 3 failures ('normal' != 'critical').head_check.test.py: the real-config testtest_an_app_change_that_adds_a_seam_needs_the_gate_lenses_and_the_code_lenspasses only with merge-path, state and code. Red:0 != 1 … the path rules decide: normal, lenses code.Comment, point 1: the doc and the rule file disagreed. Fixed by item 1. The doc now names what enforces it: the "Adding a seam line" step 1 in
docs/fork/updates.mdpoints to the gate rule.2. A seam file's changed upstream lines can be changed back.
fork-seam-check.cjsadds a newrestorableLost. On a pull request it applies to a seam file whoselostentry the pull request's own list lowers, with neither count raised, and only among the entries its run counts from upstream (listEditedCounts):goneit lowers allows one added line, the line put back.linesit lowers beyond those allows one lost line of main's file, a line moved or re-indented back. A line put back in place lowers both counts.findLostNotUpstream) holds the lowered entry exactly. So a fork line added in place of upstream's line lowers nothing there and is refused.--no-upstream) passes a real restore and the fork-checks run refuses a swap.lostis left as main's, a put-back line is still refused as before, and the refusal now says:(if it puts back an upstream line counted in "lost", lower that entry in this change's .github/fork-seams.json).fork-seam-check.test.cjs, "a pull request that lowers a seam file's "lost" entry may put those upstream lines back":p.ts: adds \b(x);`and1 upstream line deleted, moved or re-indented by this change`, the exact refusal the issue describes.docs/fork/updates.mdsays this next to "may not move a seam line".3. Generic seam lines: dropped (see Left).
4. Note for #817 step 2: recorded. The note was not in #817's body or comments, and not in #965's body. Added one comment on #817: #817 (comment)
Comment, point 2: binding an announcement to its pull request: dropped (see Left).
Left
parseConfig,findSeamBreaches,findSpareSeamLines,findListedNotFork,lowerListand fork-follow's lowering commit. fork-follow already refuses the case, and the docs say so.docs/fork/updates.mdalready tells reviewers that "any pull request may spend an announced line".General vs project
restorableLostallowance and its hint infork-seam-check.cjs, and its test.gaterule entry in.github/fork-pr-queue.json, the real-config tests inreview_judge.test.pyandhead_check.test.py, the twodocs/fork/updates.mdparagraphs, and the Contract fields for a linked child's secret requests and 'unknown'; a secret ends a wait (seam PR, #808) #817 note.State
The three cases are judged the same, because the allowance is a pure function of main's list, the pull request's own list (and the merge-base's, through
listEditedCounts) and the trees. It writes nothing and keeps no state between runs.lostnot lowered, or the reverse) is refused, as before. The first case's refusal now names the fix. A lowered entry whose lines are not back is refused by the count from upstream.lost): no entry to lower means no allowance, so it is judged exactly as before.--from-upstreamruns never use the allowance.Seam lines
None. No upstream file changes, and
.github/fork-seams.jsonis unchanged.Verification
node --test .github/scripts/fork-seam-check.test.cjs: 118 pass, 0 fail.python3 fork-ci/actions/pr-queue/review_judge.test.py: 57 run. TheForkConfigclass passes. 2 fail on this machine and on clean main alike: the local Python reads Unicode 16.0, and the vectors pin 15.0.python3 fork-ci/actions/head-check/head_check.test.py:ForkConfigRulespasses (9). The same 11 failures and 16 errors happen on clean main on this macOS machine: case-insensitive names, non-UTF-8 file names and rlimit child processes, inPathRules*,MergedConfigandHostileConfig.vp run check:changed: all pass (format, lint, knip, typecheck 43 packages, tests).node .github/scripts/fork-seam-check.cjs --no-upstream origin/main HEAD: passes.Round 1 (lens findings at 6d877ba, fixed at 410cbe6; branch updated from main first)
lock(); work(); unlock();, main droppedunlock();, and a PR withlock(); unlock(); work();pluslost{"lines": 1, "gone": 0}passed all three runsrestorableLost: a loweredgoneallows lines back only whenlinesdrops at least as much. Ifgonedrops more, the file gets no allowance and is markedmisplaced. The refusal then says: put each upstream line back where upstream has it, in order, which lowers both--no-upstreamrun, and the in-place restore passes all three runs. Red: with the old checker the out-of-place head passes (actual: 0, expected: 1)restorableLost's doc comment sat betweenpromotedFiles' comment and its functiondocs/fork/updates.mdsaid the code lens is added "when it changes other files"gatepath matches". A seam list plusci.ymlstays merge-path and statelostleft as main's got no "lower the entry" hintfindLostLinesadds(if it moves or re-indents back an upstream line counted in "lost", lower that entry …)when main's entry countslinesand the own entry allows none. A sharedlostHintbuilds both put-back hintslostentry changed since the branch's merge-base, the refusals pointed the wrong way and never said to update the branchfindLostNotUpstream) add(this branch's merge-base has another "lost" entry for it than main: update the branch from main, whose list changed since)for those filesaddsrefusal carries the hint), and own entry lowered from main's (the count refusal carries the hint)for (const file of counted)widened to all seam files, the branch addingforkZ();passes (actual: 0, expected: 1)Why the count is the root fix and a positional diff against upstream is not needed. The
linescount is the positional measure: it counts the upstream lines that are not kept in order, and the run from upstream holds the own entry to the head exactly. Each line a pull request adds or moves can bring at most one more upstream line back into order. The PR run limits the moved lines to thelinesdrop beyondgone. So if every loweredgoneis a line put back, thelinesdrop reachesgoneonly when every put-back line lands in order. A line put out of place leaves the drop at least one short, and the file gets no allowance. Diffing against upstream positionally in the PR run would add nothing over that, and the--no-upstreamrun cannot do it at all. Required checks are strict, so the merge-base is main when the PR merges.Round 1 runs (Linux, at 410cbe6):
node --test .github/scripts/fork-seam-check.test.cjs122 pass, 0 fail.python3 -I -B review_judge.test.py57 OK.python3 -I -B head_check.test.py270 OK (1 skipped).vp run check:changed: format, lint, knip, typecheck (43 packages), test and node --test all pass.Fixes #968
🤖 Generated with Claude Code