Skip to content

OpenConceptLab/ocl_online#862 | Comparing expansions or collection versions tells apart members that share an ID - #1121

Merged
snyaggarwal merged 3 commits into
masterfrom
issues-862-compare-same-id
Dec 4, 2026
Merged

snyaggarwal merged 3 commits into
masterfrom
issues-862-compare-same-id

Conversation

@snyaggarwal

@snyaggarwal snyaggarwal commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Ticket: OpenConceptLab/ocl_online#862

Why

Two sources in a collection can have a concept or mapping with the same ID. Comparing two expansions, or two versions of a collection, treated them as one, so it could say "No change" when a code was dropped.

As the ticket found, the comparison used the ID alone.

What

Members of expansions and collection versions are now compared by source and ID. Comparing two versions of a source is unchanged.

  • An ID that one source uses is listed as before.
  • An ID that several sources share, on either side, is listed by its address, such as /orgs/CIEL/sources/CIEL/concepts/1873/. In $changelog, its entry keeps id and gains source and version_url, the address of the revision it describes. A changed or retired one also has prev_version_url. In $compare, the address is in the mnemonic list.
  • A changed mapping is listed under its own concept, not under another source's concept with the same ID.
  • The Markdown changelog shows the owner and source next to a shared ID, and links to the compared revision inside the compared collection: <expansion or version>/concepts/1/22/?uri=<source>. Someone who can view the collection can open it, even when the source is private.
  • Comparisons of collection versions that were already saved are made again when next asked for, since they compared by ID alone. No migration is needed.

On staging's data (read only, old and new code side by side)

Collection Before Now
jamlung/Demo-Collection 17 concepts, then 24 18, then 25
jamlung/demo 1 removed, 8 changed 5 removed, 4 changed
BITRI/BEMRS 4,571 concepts, then 4,405 4,574, then 4,408

The new concept and mapping counts match the number of different members in the database.

To look at in review

  • Clients that use the keys of $changelog, or the mnemonic list of $compare, as IDs get an address for a shared ID.
  • TBv3 needs OpenConceptLab/ocl_online#862 | Comparison shows the source of an ID that several sources share, and opens the right member oclweb3#125 to show the source and to open the right member. The two can be deployed in either order.
  • version_url and prev_version_url are addresses in the member's own source. To open a revision with the collection's access, ask the compared version for it, as the Markdown links do.
  • Not changed: one expansion can hold two versions of the same concept from one source. The comparison still counts those as one. BITRI/BEMRS has 12 in its older expansion.

Tests

  • New tests, for expansions and collection versions: an ID shared by two sources that one source drops, changes or retires, or that each side takes from a different source. Also IDs with special characters, the compared revisions' addresses, mappings, Markdown links opened by a reader who can't view the source, saved comparisons, and a source deleted after its comparison was saved.
  • Run locally after the review fixes: common, repos, sources, collections, and the source and collection integration tests (1,763 tests). The only failure is test_get_concepts_search_options_without_q_select_the_whole_version, which also failed locally on master and comes and goes. Pylint is clean.
  • The staging check loaded the changed compare code in memory, before the special-character and review fixes. The comparison and its links were tried in a browser with OpenConceptLab/ocl_online#862 | Comparison shows the source of an ID that several sources share, and opens the right member oclweb3#125, on local data. The Markdown links were tried only in tests.

🤖 Generated with Claude Code

…rsions tells apart members that share an ID

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. The comparison now distinguishes shared IDs in its results. Please fix the two link paths below before merging so readers can open the right member and revision.

I ran 107 focused Django tests, including the existing expansion detail test for duplicate IDs. All passed. Pylint scored 10/10 on the four changed files.

Comment thread core/common/checksums.py Resolved
Comment thread core/sources/changelog_markdown.py Resolved
… addresses of the compared revisions, and Markdown links to them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review verdict: Changes requested. I reviewed 4963d344 together with OpenConceptLab/oclweb3#125 at 31facefa. The JSON now identifies both revisions when they exist. Three issues remain when readers follow the links.

  1. [P2] Route View and Markdown links to an actual revision page. View uses the source API revision path as a TermBrowser URL, for example /orgs/O/sources/B/concepts/1/22/. The exact repository routes stop at the resource ID. I checked this with the app’s React Router matcher, and the revision URL falls through to the 404 page. The same path is produced by Markdown when WEB_URL points at TermBrowser v3. Please add a route and loading behavior for the exact revision, and test that the generated link reaches it. Link builder · Repository routes.

  2. [P2] Preserve access granted by the collection. The new View and Compare targets are source endpoints. With an authenticated reader of a public collection whose member comes from a private source, the changelog returned 200 and the direct revision request returned 403. A request for the same revision through the expansion, with the member version in the path and the source in uri, returned 200. Please keep the exact revision links within the selected collection or expansion so they honor the same access as the changelog. Source revision permissions · Expansion member lookup.

  3. [P2] Suppress Compare when a new retired member has no predecessor. With A/1 in both expansions and retired B/1 first appearing in the newer expansion, the API reports B/1 as changed_retired, with version_url and no prev_version_url. TermBrowser still displays Compare and falls back to the bare ID for both sides. The older link returned HTTP 200 for A/1 in a local API test. For a source-qualified row, only offer Compare when both revisions exist. Compare button and fallback.

I ran 97 API tests, 361 frontend tests, and local checks for the routes and API responses above. Pylint and ESLint passed on the changed files.

…red revision stay inside the compared collection

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

You're right on all three. They're fixed in 401304d and OpenConceptLab/oclweb3@3aa8603.

  1. Links reach the revision. TBv3 now has routes for an exact version of a concept or mapping, and opens it in the existing split view. A test follows the generated View link to its revision. Edit, Retire and adding mappings are hidden on an exact version, so an old one can't be saved over the latest.
  2. Access stays with the collection. View, Compare and Markdown links now ask the compared expansion or version, as you suggested: <expansion>/concepts/1/22/?uri=<source>. An API test opens each Markdown link as a reader of a public collection whose sources are private: 200 there, 403 at the source.
  3. Compare needs both revisions. For a shared ID it's hidden unless both version_url and prev_version_url exist. View then opens the revision that exists.

I also opened the links in a browser on local data, as a reader who can't view the source: View for newer, older and removed concepts and a mapping, and Compare. All showed the right revision. The Markdown links were tried only in tests.

Tests: 1,763 API tests ran, with one failure, test_get_concepts_search_options_without_q_select_the_whole_version, which is unrelated and comes and goes. All 371 frontend tests pass. Pylint and ESLint are clean.

Both PR descriptions are updated. Ready for another look.

(Written by Claude for Sunny)

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review verdict: Changes requested. I reviewed 401304df with OpenConceptLab/oclweb3#125 at 3aa8603. The revision routes now match, collection-only access works through the expansion, and a shared retired member without a predecessor no longer offers Compare. I verified two remaining cases.

  1. [P2] Build links in the order returned by the changelog. The UI lets the newer expansion sit on the left. The API reorders the pair by creation time, but the link builders still use the picker order. With the newer expansion selected first, View for a changed shared ID requested the newer revision from the older expansion and returned 404. The same request against meta.version2.uri returned 200. Use meta.version1.uri and meta.version2.uri for View and Compare. TermBrowser base URLs · API ordering.

  2. [P2] Preserve the exact concept ID through the View route. The new split-view path passes through React Router’s pathname decoding and parseRepoPath, then ConceptHome applies both encodeURIComponent and encodeURI to the concept ID. I traced the shared IDs a b and a%20b through this path. Both requested concepts/a%2520b/b2/. The API returned the UUID for the literal a%20b member, or 404 when that member was absent. Keep one round of path encoding from the original ID and cover the final HTTP request for both IDs. This also affects Markdown links opened in TermBrowser v3. Route parser · Detail request.

Verification included 103 focused API tests, 371 frontend tests, and two local API checks reproducing the cases above. Pylint and ESLint passed on the changed files.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Both points from the last review are fixed in OpenConceptLab/oclweb3#125, commit a4ad78b. No change was needed in this PR.

# Point Fix
1 Links in the order the changelog returned View and Compare are built from meta.version1.uri and meta.version2.uri. This also covers IDs that aren't shared, and source versions.
2 The exact concept ID through View The ID is read from the browser's own address, which the router hasn't decoded, and encoded once for the request. Mappings had the same code, so they have the same fix.

On point 2:

  • The double encoding was there before this PR, so any ID with a space failed in a collection's split view. That is fixed too.
  • The router also changed a%2520b to a%20b in the address bar, so a reload would have opened the wrong concept. The repository page and its list now keep the address as it is.
  • View also encodes the ID where only one source uses it.

Tests: npm test has 383 passing, and ESLint is clean. The new tests follow a View link to the final request path for a b, a%20b, 100%, a+b and a@b, directly and after the router rewrites the address.

Tried in a browser on local data, as a reader who can't view the source, with the newer expansion picked first:

  • View opened a b and a%20b each at its own revision. a%20b was still right after a reload.
  • Compare on a%20b showed the older revision on the left and the newer on the right.
  • Not tried in a browser: a mapping.

(Written by Claude for Sunny)

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. I re-reviewed 401304df with OpenConceptLab/oclweb3#125 at a4ad78b. The two findings from the previous round are fixed. Selecting the newer expansion first now produces links to the correct old and new revisions, and View requests distinct revisions for a b and a%20b.

[P2] Keep the stored concept ID when opening a regular collection row. The new detail helper assumes it receives a stored ID. An ordinary row click still puts the decoded item.id into the route and into the detail request. I reproduced this with a concept created using ID a:b. The API stores a%3Ab, while the expansion list returns id: "a:b". The new request goes to concepts/a%3Ab/ and returns 404. The previous request went to concepts/a%253Ab/ and returned 200 for the same concept. Carry the stored member ID from the list result’s resource URL into the panel, then encode it once. Please cover an ordinary row click as well as a changelog link. Row selection · Detail request · Expansion lookup.

All 17 focused API tests and 383 frontend tests passed. ESLint passed on the changed frontend files. Three additional local checks verified the two fixes and reproduced the collection-list regression.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

The P2 from the last review is fixed in OpenConceptLab/oclweb3#125, commit 78af931. No change was needed in this PR.

Fix: a row click now takes the stored ID from the row's own url (.../concepts/a%3Ab/), not the decoded id. That ID goes into the route and the panel, and it's encoded once for the request. The split view and the seed check use it too, and mappings get the same fix.

Tests: npm test has 388 passing, and ESLint is clean. New tests cover an ordinary row click for a:b, a b and a%20b through to the final request path, plus the changelog links from before.

Tried in a browser on local data:

  • In a collection's list, clicking a:b requested concepts/a%253Ab/ and got 200. a b and a%20b each opened their own concept, and a%20b was still right after a reload.
  • In a source's list, a:b opened as well.
  • Not tried in a browser: mappings, and global search.

Side effect: for a:b the address bar now shows concepts/a%253Ab. An old link to concepts/a%3Ab still opens from a source but not from a collection.

(Written by Claude for Sunny)

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. I re-reviewed oclapi2 401304df and OpenConceptLab/oclweb3#125 at 78af931. The last blocker is fixed. The collection list now uses the stored code, so clicking a:b opens the expected concept, and two rows with the same display ID can still open distinct stored codes.

The previous cases also passed. View and Compare follow the API’s older and newer sides even when the picker order is reversed. Changelog links resolve the expected revision through the expansion for a reader without direct source access, and Compare is hidden for a shared row without an older revision.

All 17 focused API tests and 388 frontend tests passed, along with changed-file ESLint and a local check that confirmed the returned UUIDs. I found no remaining blockers for the pair.

@snyaggarwal
snyaggarwal merged commit 9d8bf39 into master Dec 4, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the issues-862-compare-same-id branch December 4, 2026 11:37
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