FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

flatten: hoisted cycle names come from the merged components by reuvenharrison · Pull Request #1245 · oasdiff/oasdiff · GitHub

flatten: hoisted cycle names come from the merged components - #1245

Merged
reuvenharrison merged 5 commits into
mainfrom
flatten-stable-cycle-names
Sep 13, 2026
Merged

flatten: hoisted cycle names come from the merged components#1245
reuvenharrison merged 5 commits into
mainfrom
flatten-stable-cycle-names

Conversation

Copy link
Copy Markdown
Collaborator

Implements the principle from review: flatten must produce the same output standalone and inside diff.

The defect the counter had

AllOfMergedN was assigned in document walk order, so an unrelated recursive cycle added earlier in a revision shifted every later number. Base and revision are flattened independently, the components-table diff pairs by name, and oasdiff diff --flatten-allof reported a phantom modification of a logically unchanged cycle (measured: base's AllOfMerged1 = A∧B paired against revision's AllOfMerged1 = C∧D). breaking/changelog were unaffected (checkers compare usage sites by value), but any consumer of the structured diff — or of flattened output committed anywhere — saw names move for no reason.

The fix

The synthetic name is built from the component names the cycle merges, in input order: AllOfMerged_NodeA_NodeB. Nothing outside the allOf itself can move it, so the same logical cycle keeps its name across revisions and the phantom churn disappears (verified: the shifted-revision diff now reports only the genuine additions). The numeric AllOfMergedN remains as the fallback for hintless targets, and name collisions get a numeric suffix, both still in deterministic walk order.

Mechanically: flattenSchemas records a naming hint (the input set's component names) for the result it populates; MergeSpec carries hints across the write-back identity repair; nameAnchoredCycles prefers the hint.

Tests

  • Existing hoisting/mixed pins updated to the stable names (AllOfMerged_NodeA_NodeB, AllOfMerged_NodeA).
  • New Test_MergeSpec_HoistedNameIsStable: the same cycle gets the same name in the base document and in a revision with an unrelated earlier cycle — the exact churn scenario, pinned.

Full suite and lint pass. The docs in #1244 will be updated to describe the name scheme.

A position counter gave the same logical cycle different names in
different revisions: an unrelated cycle earlier in the walk shifted
the numbering, the components diff pairs by name, and a diff of two
flattened revisions reported a phantom modification of a schema that
did not change. The name is now built from the component names the
cycle merges (AllOfMerged_NodeA_NodeB), which no unrelated edit can
move, so flatten produces the same output standalone and inside diff.
The numeric form remains as the fallback for hintless targets and
collisions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDvUFsg5nu1NBWQffErGDw

codecov-commenter commented Sep 13, 2026
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.78788% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.25%. Comparing base (63632bf) to head (6b27d50).

Files with missing lines Patch % Lines
flatten/allof/merge_allof_spec.go 68.42% 6 Missing ⚠️
flatten/allof/merge_allof.go 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1245      +/-   ##
==========================================
- Coverage   92.27%   92.25%   -0.03%     
==========================================
  Files         345      345              
  Lines       14336    14357      +21     
==========================================
+ Hits        13229    13245      +16     
- Misses       1107     1112       +5     
Flag Coverage Δ
unittests 92.25% <78.78%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

reuvenharrison and others added 4 commits September 13, 2026 15:30
One letter separated it from componentNamer, which allocates names in
the components namespace; this function only derives the hint the
namer consumes, and its new name says so at every call site.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDvUFsg5nu1NBWQffErGDw
reuvenharrison merged commit 07dd331 into main Sep 13, 2026
11 checks passed
reuvenharrison deleted the flatten-stable-cycle-names branch September 13, 2026 12:50
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL