Skip to content

OpenConceptLab/ocl_online#736 | A reference whose system URL names a version is evaluated in that version - #1066

Merged
snyaggarwal merged 3 commits into
masterfrom
ocl_online-736-system-url-version
Nov 25, 2026
Merged

snyaggarwal merged 3 commits into
masterfrom
ocl_online-736-system-url-version

Conversation

@snyaggarwal

@snyaggarwal snyaggarwal commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Ticket: OpenConceptLab/ocl_online#736 (finding F2.2 of the #1028 review, and the mismatch F1.3 left for later) · Epic: OpenConceptLab/ocl_issues#2942

A reference whose system URL names a repository version (/orgs/O/sources/S/v1/, /orgs/O/sources/S/v1, or url|v1) with an empty version field is now treated as naming that version. Before, only the version field counted:

  • Evaluation: an expansion that had already evaluated another version of the source (its lock) evaluated the reference there, not in the version it names. So a reference naming v1 got v2's members, and a missing v1 evaluated nothing.
  • Recording: the version went into evaluated_source_versions, as if it were a lock, rather than explicit_source_versions. So a later unversioned reference to the same source could take it as its lock, and TBv3 called it movable (found in the OpenConceptLab/ocl_issues#3009 | Say why new releases are offered, and compare before rebuilding oclweb3#114 review).
  • system-version: the parameter overrode a version the system URL names, though it only applies to a system with no version.

The change (core/collections/models.py)

  • names_repo_version reads the system as the resolver does:

    • a version field;
    • a version after |;
    • or the fifth segment of a relative URL's path, without its query string (/orgs|users/<owner>/<repo type>/<repo>/<version>/), except HEAD. No repository's URL has a HEAD segment, so such a system never resolves, and get_evaluated_repo_version_urls already excluded it.

    This is the reading get_evaluated_repo_version_urls already used since OpenConceptLab/ocl_online#736 | Unresolved-reference details list only repository versions the requester can view #1028, moved into the property so both share it. Read by position:

    • /orgs/O/sources/S/v1 without the trailing slash counts;
    • these don't count: a HEAD URL of an owner named sources (/orgs/sources/sources/S/), a canonical URL whose path merely looks versioned, and a concept-version URL used as a system (/orgs/O/sources/S/concepts/c1/123/). The resolver reads that last one as the source's HEAD.

    The old check counted url|v1 and the trailing-slash form, as this one does. Its is_versioned_uri part got the other four wrong.

  • is_versionless_expression is now not names_repo_version and not resource_version. It decides:

    • whether add_references reuses a recorded evaluated version;
    • which list the version is recorded in;
    • what get_source_versions_resolved_by returns for the reference (resolved_repo_versions);
    • whether health's consistency check counts it as unversioned.
  • can_compute_against_other_system_version uses names_repo_version too, so system-version doesn't override a version the system URL names, as it already didn't for a version field.

  • version_lists (rebuild_expansion_version_lists) already counted the trailing-slash and url|v1 forms as explicit through names_repo_version. Now every form counts, and is_explicit reads not is_versionless_expression alone, which agrees with what add_references records.

  • A resource-versioned reference (system, code and resource_version) whose system names a version without a trailing slash (/S/v1) is now pinned to that version, as the trailing-slash form already was. It no longer resolves to a version that holds its resource version.

No toggle: this is a correctness fix, and the docs (OpenConceptLab/ocl-docs#83, rule 1) already say a reference that names a version, by version or by URL, uses that version. Existing expansions keep what master recorded until they're rebuilt, or until rebuild_expansion_version_lists --apply runs. Adding references doesn't remove a version master recorded as evaluated, so later references, and version create's lock, still read it until then.

Tests

  • CollectionReferenceTest.test_names_repo_version_reads_the_system_as_the_resolver_does covers each form:

    • relative URLs, with or without the trailing slash, with a query string, user-owned, with |v1;
    • /HEAD/, and an owner named sources;
    • canonical URLs with and without |v1, and a canonical URL whose path merely looks versioned.

    It checks is_versionless_expression alongside.

  • test_can_compute_against_other_system_version adds the system-URL forms.

  • ExpansionTest.test_add_references_evaluates_a_reference_in_the_version_its_system_names, with and without the trailing slash: with the expansion locked to v2, adding a reference whose system names v1 evaluates it in v1, records v1 as explicit and keeps v2 as the lock. get_source_versions_resolved_by returns v1.

  • ExpansionTest.test_system_version_parameter_does_not_override_a_version_the_system_names: a rebuild with system-version=S|v2 keeps the reference on v1.

  • ExpansionTest.test_a_later_unversioned_reference_takes_the_latest_release_not_a_version_another_reference_names: after a reference naming v1, an unversioned one resolves to the latest release v2, not to v1 as a lock.

  • ExpansionTest.test_a_named_version_its_creator_cannot_view_adds_nothing_as_a_missing_one_does: with the expansion locked to public v1, a reference naming a private v2 adds nothing, as one naming a missing v3 does. On master, it added v1's members.

  • CollectionReferenceTest.test_resolve_system_version_keeps_a_repo_version_its_system_names_without_a_trailing_slash: a resource-versioned reference whose system is /S/v2 resolves to v2, with or without the slash.

  • All of these fail on master.

  • OpenConceptLab/ocl_online#769 | A retired version named by its relative URL still resolves #1065's test_rebuild_resolves_a_reference_whose_system_names_a_retired_version_by_its_url now expects v1 in explicit_source_versions. That's what this PR changes.

  • Run locally in a one-off container:

    • core.collections, core.integration_tests.tests_collections and core.common.tests (951 tests): the only failure was that OpenConceptLab/ocl_online#769 | A retired version named by its relative URL still resolves #1065 test, before its update, and that test now passes;
    • then SourceTest, core.fhir.tests_resolve, core.url_registry.tests_resolution and the updated test (189 tests): all pass;
    • after round 2's fixes, core.collections, core.integration_tests.tests_collections and core.common.tests (954 tests): all pass.
  • pylint on the changed files exits 0.

Sibling PRs

🤖 Generated with Claude Code

…version is evaluated in that version and recorded as explicit
@snyaggarwal
snyaggarwal requested a review from paynejd November 25, 2026 02:56
@snyaggarwal snyaggarwal self-assigned this Nov 25, 2026
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Review, round 1: approve with nits. An independent review of 51130c3, reading the code only.

Checked and fine

  • Matches the resolver: the positional reading matches how the resolver reads a system. It splits at |, strips the query, then runs to_parent_uri.

  • Every caller moves toward the docs' rule 1:

    • add_references and get_ref_results;
    • lock resolution, including cascade;
    • system-version matching, here and in version_lists;
    • health's consistency check;
    • views, reference_conversions and get_evaluated_repo_version_urls, which is a pure move;
    • FHIR $expand and $validate-code, which prefer explicit pins.

    Exclude references take the same path. Value-set-only references are unchanged. The expression parser puts a version in the version field, so only structured references are affected.

  • Access: this closes the content-level oracle in OpenConceptLab/ocl_online#736. A private named version is now evaluated in that version and adds nothing, as a missing one does. Master added the lock's members. No new list-level difference appears: it matches the existing version-field form.

  • Parser edge cases all match the resolver:

    • /references/, /expansions/ and /concepts/;
    • a concept URL as the system;
    • url| with an empty version;
    • a relative URL with |v;
    • a query string, empty input and None;
    • doubled slashes;
    • canonical URLs with :;
    • encoded characters.
  • Tests and rules: the new tests fail on master, no existing test relied on the old behaviour, and nothing is commercial.

Nits

  1. The HEAD exclusion: /S/HEAD/ is excluded, but the resolver treats it as a named version that matches nothing. A version field of HEAD does count. This only affects references that never resolve, such as dry_run_expansions sampling and the order in keep_member_repos. Drop the exclusion, or say it's deliberate.
  2. Unmentioned change for resource-versioned references: a resource-versioned reference whose system has no trailing slash (/S/v1) used to resolve by resource version, because the old check needed the slash. It's now pinned to v1, which is right under rule 1, but it's untested and not in the description.
  3. The description overstates two things:
    • version_lists counted only the trailing-slash form as explicit;
    • adding references doesn't remove a stale v1 that master recorded as evaluated, so later references and version create lock still read it. Only a rebuild or rebuild_expansion_version_lists corrects it.
  4. Test gaps:
    • a later unversioned reference doesn't take the URL-named version as its lock;
    • a private named version adds nothing, as a missing one does;
    • nit 2.
  5. Follow-up, not this PR: generate_references and __get_repo_and_resource_version still read not self.version. So a cascade-and-transform reference whose system names v1 generates references at the latest release. This predates the PR.

…ce, a private named version and a resource-versioned system without a slash; the HEAD rule is documented
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Round 1 nits, in feaba95:

  1. HEAD: kept, and now documented in the docstring and the description. No repository's URL has a HEAD segment, so such a system never resolves. get_evaluated_repo_version_urls already excluded it, and keeping it means the move into the property changes nothing there.

  2. A resource-versioned reference whose system has no trailing slash: it's now in the description. A new test checks that /S/v2 and /S/v2/ both resolve to v2, and that neither resolves by resource version. It fails on master for the no-slash form.

  3. Description: version_lists counted only the trailing-slash form before. Existing expansions keep what master recorded until a rebuild or rebuild_expansion_version_lists --apply, and until then adding references and version create's lock still read it.

  4. Tests:

    • a later unversioned reference resolves to the latest release, not to the URL-named v1 as a lock. On master, v1 was recorded as evaluated;
    • a reference naming a private v2 adds nothing, as one naming a missing v3 does, while the expansion is locked to public v1. On master, it added v1's members.

    I didn't add separate tests for exclude references and the lock parameter. They go through the same is_versionless_expression branch these tests cover.

  5. generate_references and __get_repo_and_resource_version still read not self.version. I've left that as a follow-up on OpenConceptLab/ocl_online#736, since it predates this PR.

Checks: core.collections and core.integration_tests.tests_collections pass (721 tests), and pylint on the changed files exits 0. One earlier run had two transient errors that didn't reproduce on their own or in a rerun of the same set. Another session's tests most likely hit the shared local test database at the same time.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Review, round 2: approve with nits. An independent review of feaba95. It found no correctness problems in the production change or in round 1's additions.

Checked and fine

  • Docstring: two lines, accurate, and in the resolver's order. It drops the query, then runs to_parent_uri, and reads a URL with : as canonical.
  • Test helper: changing _resource_version_reference to dict unpacking changes nothing for existing callers.
  • New tests: each one fails on master for the reason its name gives, and none depends on a toggle:
    • the lock reuse;
    • the later unversioned reference;
    • the private version, which depends on the creator view check, with missing v3 as the control;
    • the resource-versioned system without a slash;
    • system-version.
  • Callers: these are all consistent:
    • health;
    • version_lists;
    • get_source_versions_resolved_by;
    • lock reuse and recording in add_references;
    • get_unresolved_items;
    • the move into the property.
  • Real reference shapes: the old-style parser puts the version in the version field, so those references are unaffected. Value-set-only references are unchanged.
  • Description: every claim holds except nit 2. References are qualified, nothing is commercial, and each commit is one line.

Nits

  1. Dead clause: version_lists.is_explicit reads not reference.is_versionless_expression or reference.names_repo_version. Its second clause can no longer change the result.
  2. Description: master also counted url|v1, and its is_versioned_uri check wrongly counted two shapes besides the owner named sources. Those are canonical URLs whose path looks versioned, and a concept-version URL used as a system (/S/concepts/c1/123/). The concept-version URL now reads as unversioned, as the resolver reads it. That's untested and not described.
  3. Test comment: "a version named in system is named, as a version field is" reads as circular.

…versionless_expression alone, and a concept-version URL as a system is tested as unversioned
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Round 2 nits, in cf83e2c:

  1. version_lists.is_explicit is now not reference.is_versionless_expression, without the clause that could no longer change the result.
  2. The description now says what master counted, url|v1 and the trailing-slash form, and lists the four shapes its is_versioned_uri check got wrong. The names-version table adds a concept-version URL as a system (/orgs/O/sources/S/concepts/c1/123/, unversioned, as the resolver reads it) and a concept URL under v1 (versioned).
  3. The test comment now reads "a version its system URL names is explicit, as a version field is".

Checks: core.collections, core.integration_tests.tests_collections and core.common.tests pass (954 tests), and pylint on the three changed files exits 0. An earlier run hit errors from another session's tests on the same local test database; this run was alone.

The loop stops here: approve with nits, nits fixed.

@snyaggarwal
snyaggarwal marked this pull request as ready for review November 25, 2026 04:20
@snyaggarwal
snyaggarwal merged commit 783f6b1 into master Nov 25, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-736-system-url-version branch November 25, 2026 12:16
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