Skip to content

OpenConceptLab/ocl_online#769 | A retired version named by its relative URL still resolves - #1065

Merged
snyaggarwal merged 2 commits into
masterfrom
ocl_online-769-retired-relative-version
Nov 25, 2026
Merged

snyaggarwal merged 2 commits into
masterfrom
ocl_online-769-retired-relative-version

Conversation

@snyaggarwal

@snyaggarwal snyaggarwal commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Ticket: OpenConceptLab/ocl_online#769 · Epic: OpenConceptLab/ocl_issues#2942

A repository version named by its relative URL (/orgs/O/sources/S/v1/) now resolves after it's retired, as url|v1 and a reference's version field already do. Retiring a release no longer moves a lock or empties a reference on the next rebuild.

The cause

resolve_reference_expression matched a relative URL to a row by uri, filtered is_active=True, retired=False. For a version URL, that row is the version itself, so a retired version didn't match. The canonical path finds the repository and then reads its version through ReferenceResolution.version(), which has no retired filter.

The change

  • core/common/models.py: a relative URL that names a version, by its position (/orgs/O/sources/S/v1/, five segments), is matched with is_active=True only. Position rather than is_versioned_uri, which reads /orgs/sources/sources/S/ (an owner named like a resource) as a version URL. A deactivated version still doesn't resolve. A repository's own URL keeps the retired=False filter, and canonical URLs are unchanged.
  • Both paths in the ticket go through this resolver, so both are fixed:
    • system-version entries (resolve_system_version_entries): a rebuild keeps the pin, and the entry no longer lands in unresolved_repo_versions;
    • a reference whose system is a version URL (resolve_expression_system_version): the reference keeps its members on a rebuild.
  • Every other caller gets the retired version too, where it used to get nothing:
    • $resolveReference, as it already did for url|version;
    • FHIR by OCL path (/orgs/O/CodeSystem/S/v1/), matching FHIR's rule that a retired release is served when named, while the repository has a live release (has_release). A retired HEAD still isn't served by path;
    • valuesets named by a relative version URL, and health's pinned versions;
    • mapping and import source links, for a concept URL under a retired version (they now link to HEAD instead of to no source).

Tests

  • SourceTest.test_resolve_reference_expression_relative_url_of_a_retired_version: a retired version resolves by relative URL, with or without the trailing slash, and as url|v1. A deactivated version doesn't resolve, and a repository's URL still resolves to HEAD when its only release is retired.
  • ExpansionTest.test_rebuild_keeps_a_retired_version_system_version_names_by_its_url: retire v1, then rebuild with system-version as /orgs/O/sources/S/v1/ and as url|v1. v1 stays the lock and nothing is unresolved.
  • ExpansionTest.test_rebuild_resolves_a_reference_whose_system_names_a_retired_version_by_its_url: the reference keeps its member from v1, and v1 stays recorded.
  • SourceTest.test_resolve_reference_expression_relative_url_of_a_retired_head_of_an_owner_named_like_a_resource: an owner named sources with a retired HEAD still doesn't resolve by path.
  • FhirResolveCases.test_a_retired_release_named_by_its_ocl_path_is_served_beside_a_live_one: FHIR serves retired v1 by its path, in both path forms and as |v1, and the repository's own path still serves live v2.
  • The resolver, rebuild and FHIR tests fail on master. The owner-named test passes on master and fails on beccb33: it guards the positional rule.
  • Run locally in a one-off container: ExpansionTest, CollectionReferenceTest, SourceTest, core.url_registry.tests_resolution, core.fhir and core.integration_tests.tests_collections, 1216 tests in all.
    • The only errors are 9 *_not_test_mode tests that need Redis, which the local run blocks. They fail the same way without this change.
  • pylint on the changed files exits 0.

Notes

  • A reference whose system is a version URL but has no version field is recorded in evaluated_source_versions, not explicit_* (is_versionless_expression). That's unchanged here, and the test doesn't depend on which list it is.
  • OpenConceptLab/ocl_issues#3009 | Say why new releases are offered, and compare before rebuilding oclweb3#114 stops promising that a retired version a reference names survives a rebuild (2c50cef), and only treats a system-version version URL as pinned while that version isn't retired. Both can be relaxed once this is deployed.

Sibling PRs

🤖 Generated with Claude Code

…ve URL still resolves, in system-version and in a reference's system
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Review, round 1: approve with nits. An independent review of beccb33 against master.

Checked and fine

  • The fix. A relative version URL matches its own row with is_active=True only. ReferenceResolution.version(row, None) then returns that row, the same answer url|v1 gives. HEAD URLs keep retired=False, and a HEAD with no version named still goes to get_latest_released_version(), which skips retired releases. Canonical URLs are untouched.
  • Every caller of resolve_reference_expression. Each one now gets the retired version, or HEAD when it passes version=HEAD, where it used to get nothing. That's the intended behaviour or better:
    • system-version entries and conflicts;
    • a reference's system;
    • reference_conversions, version_lists and health's pinned versions;
    • valuesets named by a relative version URL;
    • mapping and import source links;
    • lexical variants, map project targets, concept search, and $resolveReference.
  • FHIR. A relative path does reach it, through to_ocl_path. Serving a retired release named by its path matches FHIR's rule that a retired release is served when named. A repository whose only release is retired stays hidden, and a retired HEAD still isn't served, because HEAD keeps retired=False.
  • URL shapes. With and without the trailing slash, user-owned repositories, concept and expansion URLs, collection versions, /HEAD/ (matches no row either way), and encoded versions.
  • Tests. All three fail without the fix. No existing test's expectation changes.

Nits

  1. A HEAD URL can read as a version URL. is_versioned_uri goes through drop_version, which looks at the segment four from the end. For an owner named sources, collections, concepts or mappings (the namespace pattern allows them), /orgs/sources/sources/S/ counts as versioned, so a retired HEAD of that owner would resolve. Decide by position instead: a repository version path has five segments.
  2. The description lists only some of what changes. FHIR by OCL path, mapping and import source links, valuesets named by relative URL, and health's pinned versions also change. Name them, and add one FHIR test of a retired release named by its path.
  3. core/sources/tests/tests.py: assertIsNotNone(inactive.id) exists only to use a variable. Don't assign the variable.
  4. core/collections/tests/tests.py: the reference test accepts v1 in either list. Assert evaluated_source_versions == [v1], the list it actually lands in, so a change in which list is used gets caught.

Info, no action: a retired repository (its HEAD) with a live v1 resolves /S/v1/ but not /S/|v1. That was already true before this PR, and the ticket is about retired versions.

… position, so an owner named like a resource keeps its HEAD rule, and FHIR serves a retired release by its path
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Round 1 nits are fixed in 2edfba4.

  1. Version URLs by position: a relative URL names a version when it has five segments (/orgs/O/sources/S/v1/). It no longer goes through is_versioned_uri, so an owner named sources with a retired HEAD still doesn't resolve by path. The new test for this fails on beccb33.
  2. Description and FHIR test: the description now lists every caller that changes. A FHIR test serves retired v1 by /orgs/HL7/sources/aging/v1/, by /orgs/HL7/CodeSystem/aging/v1/ and by |v1, and the repository's own path still serves live v2. It fails on master.
  3. Unused variable: the inactive version isn't assigned any more, and the assertion that only used it is gone.
  4. Which list: the reference test asserts evaluated_source_versions == [v1] and nothing in explicit_*.

Checks: the five resolver and rebuild tests and core.fhir.tests_resolve pass (50 tests), and pylint on the four changed files exits 0.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Review, round 2: approve with nits. An independent review of 2edfba4 against master. All four round 1 nits are fixed.

Checked and fine

  • The positional check. The query still needs an exact uri match on a repository row, and a version segment can't contain /, so a five-segment input can only ever match a version row. These all behave as on master:
    • /S/HEAD/, /S/versions/ and /S/summary/ match no row before or after;
    • query strings are stripped first;
    • concept, mapping, reference and expansion paths are cut back by to_parent_uri;
    • FHIR paths become /sources/ paths first;
    • user-owned repositories, collections and encoded versions count correctly.
      The URL registry only handles canonical URLs, so this line runs the same with the toggle on or off.
  • Tests.
    • Each rebuild test fails on master, and the url|v1 subtest is a control.
    • The FHIR test fails on master in both subclasses.
    • The owner-named test guards the positional rule.
    • Every assertion compares at most one row, so row order can't matter.
  • Description claims about mapping and import links, health's pinned versions, valuesets, deactivated versions and a retired HEAD all match the code.
  • Repo rules. The comment is two lines with no ticket number, lines are at most 120 characters, references are fully qualified, commits are one line, and nothing is commercial.

Nits (description only)

  1. FHIR serves a retired release named by its path only while the repository has a live release (has_release). Say so.
  2. "Each new test fails without the change it covers" isn't true of the owner-named test, which passes on master and fails on beccb33. Say that it guards the positional rule.

Info, out of scope: an owner named concepts, mappings, references or expansions already breaks to_parent_uri. That predates this PR.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Round 2 nits are fixed in the description: the FHIR bullet now says a retired release is served by its path only while the repository has a live release, and the Tests section says the owner-named test passes on master and fails on beccb33, so it guards the positional rule. No code changed, so the head is still 2edfba4. The loop stops here: approve with nits, nits fixed.

@snyaggarwal
snyaggarwal merged commit d852b81 into master Nov 25, 2026
1 of 2 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-769-retired-relative-version branch November 25, 2026 01:56
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