Skip to content

Floor and pin files merge structurally (git merge driver dragon-floor) - #183

Merged
thejackshelton merged 3 commits into
masterfrom
floor-merge-driver
Oct 5, 2026
Merged

thejackshelton merged 3 commits into
masterfrom
floor-merge-driver

Conversation

@thejackshelton

Copy link
Copy Markdown
Contributor

What changed: floor and pin files now merge structurally, so two PRs that both raise a floor no longer conflict. #136, #140 and #142 bounced on this today.

  • The driver: scripts/floor-merge.ts, merge=dragon-floor. It is a git merge driver that does a three-way merge of the JSON.
    • Counts: for a count both sides changed, it takes the larger.
    • Lists: two lists both sides extended become their union. Unordered floors, which DRAGON_FLOOR_WRITE writes sorted, come out sorted. Ordered lists keep each side's order: each side's additions stay together after the item they followed.
    • Keys: a key either side added is kept.
    • Pins are exact: glyph-clearance-pins.json pins are compared exactly by pixel-reference.test.ts. So a pin that both sides changed differently is a conflict, never a max.
  • What it refuses. It refuses, and leaves git's ordinary text conflict with markers, on any of these:
    • a removed name or key;
    • a type change;
    • a repeated name;
    • two orders that cannot both hold;
    • a string both sides changed differently;
    • JSON it cannot parse;
    • a result in a shape floorRegressions cannot judge.
  • It never lowers. Every floor result is checked with floorRegressions (the landing driver's own floors check) against both sides, and is refused if it would fall below either. That also catches a side that lowered a count.
  • Output format. The output is written as the files' writers write them (JSON.stringify(v, null, 2); pins one compact line per case), byte for byte. Merging a file with itself gives the file back.
  • Registration.
    • .gitattributes gets packages/*/test/*-floor.json and packages/*/test/glyph-clearance-pins.json with merge=dragon-floor. That is exactly the set the landing driver's floors check judges (isFloorFile).
    • pnpm setup:git registers the driver next to dragon-generated.
    • The landing driver sets both merge drivers in the repository's shared config at start (MERGE_DRIVERS), so its worktree merges the same way.
  • Script guard. The script's main guard compares realpaths. On macOS /tmp is a symlink, and a guard that missed would exit 0 and leave git with ours unmerged. A first draft did exactly that, and a by-hand test caught it.

Outside the spec:

  • scripts/land.ts sets the merge drivers.
  • packages/parity/test/regen.test.ts: its .gitattributes policy test read every non-comment line as a dragon-generated line. It now skips the dragon-floor lines. Its intent (the generated lines equal the regen outputs, sorted) is kept, and the floor lines are checked in the new test file.

For the lane contract (the PM applies it; lanes do not write docs/goals). Under "Scope", after the floor-files bullet, add: "Floor and pin files merge structurally (merge=dragon-floor, run pnpm setup:git once per clone): a catch-up merge takes the larger count and the union of names. If it still leaves a conflict, a name was removed, two orders disagree or a pin was changed on both sides, so resolve it by hand, never lower a floor, and give a written reason."

What passed:

  • pnpm typecheck passed.
  • vitest run packages/parity/test/floor-merge.test.ts packages/parity/test/regen.test.ts packages/parity/test/land.test.ts passed: 139 tests, 2 of them skipped (regen's opt-in full-chain check).
  • New, in floor-merge.test.ts:
    • Typical shapes: sorted and ordered name lists, p1-floor {order, counts}, css-escapes counts, and pins (different cases merged, one pin changed twice refused).
    • Every refusal: each case listed under "What it refuses" above.
    • Never lowers: 2000 seeded random pairs of raises as DRAGON_FLOOR_WRITE makes them. Every merged result is no lower than the base and either side by floorRegressions, and a lowering side is refused.
    • Real git: two branches raising the same floor merge with no conflict, where the text merge conflicts. A removal is left as a conflict with markers.
    • Registration: pnpm setup:git sets exactly MERGE_DRIVERS, the marked files are exactly isFloorFile's, and every real floor and pin file formats back byte for byte.

🤖 Generated with Claude Code

…loor-merge.ts, merge=dragon-floor) takes the larger count and the union of names, refusing anything else; pnpm setup:git and the landing driver register it
@thejackshelton
thejackshelton merged commit 5e2e253 into master Oct 5, 2026
5 checks passed
@thejackshelton
thejackshelton deleted the floor-merge-driver branch October 5, 2026 17:00
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.

1 participant