Skip to content

OpenConceptLab/ocl_online#773 | resolved-repo-updates lists only versions a rebuild would move - #1072

Merged
snyaggarwal merged 6 commits into
masterfrom
ocl_online-773-resolved-repo-updates
Nov 26, 2026
Merged

snyaggarwal merged 6 commits into
masterfrom
ocl_online-773-resolved-repo-updates

Conversation

@snyaggarwal

Copy link
Copy Markdown
Contributor

Fixes OpenConceptLab/ocl_online#773.

What changed
…/expansions/<id>/resolved-repo-updates/ (Expansion.get_resolved_repo_version_diff_with_latest_updates) now leaves out recorded repo versions that a rebuild keeps. The response shape is unchanged ({recorded_url: resolves_to_now_url}), so current clients keep working. The new get_repo_version_ids_a_rebuild_keeps follows what add_references does on a rebuild (force_reevaluate + is_adding_all):

  • explicit_source_versions: kept, because a reference names the version (this includes a reference that names HEAD). The exception is a repository that a reference reaches through a concept or mapping version with no repo version (resource_version set, version empty). A rebuild resolves that one again, so it's still listed.
  • explicit_collection_versions: kept, because a value set named with its version stays.
  • evaluated_source_versions: moves, except for versions the expansion's system-version parameter resolves to (url|version, url|HEAD, or a version URL). A bare repository URL in system-version resolves again, so it still moves.
  • evaluated_collection_versions: moves, except for an expansion built with lock (built_with, from OpenConceptLab/ocl_issues#3009 | Expansions show built_with #1060). Its active value-set locks are the kept_valueset_locks a rebuild keeps.

A version recorded in both an explicit and an evaluated relation is still listed, since the evaluated reference moves it.

Why
The endpoint reported every recorded version whose repository now resolves elsewhere. It never looked at what pins the version, so TBv3 offered "updates available" and a rebuild then changed nothing. OpenConceptLab/oclweb3#114 filters some of these cases in the web app. This fixes it for every client, and for expansions with no built_with.

Reading of the ticket's "HEAD-pointed unreleased version" case
I read it as HEAD named explicitly: by a reference (…/HEAD/…) or by system-version (url|HEAD). A rebuild keeps both, and both are tested. A HEAD recorded only by a versionless reference is still listed once a release exists, because a rebuild does move it to that release.

Tests

  • New tests in ExpansionTest:
    • a reference-named version is left out;
    • a concept-version reference's repository is still listed;
    • system-version url|v1 is left out while a bare URL still moves;
    • a lock-built value-set lock is left out (a latest-built one is listed);
    • HEAD named by a reference and by system-version|HEAD is left out (listed once the parameter is gone).
  • The existing diff tests (test_get_resolved_repo_version_diff_with_latest_updates, and CollectionVersionExpansionResolvedRepoUpdatesViewTest.test_get_200_with_updates) recorded the version as explicit. They now record it as evaluated, the case a rebuild moves. test_get_resolved_repo_version_diff_skips_duplicate_url (explicit and evaluated together) is unchanged and still expects the entry.

Focused pylint on the changed files passes (exit 0). The local Docker stack is down, so the tests haven't run locally. This relies on CI's Tests job.

🤖 Generated with Claude Code

@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.

Review: request changes

This is better than master, and it never hides a version in the common cases. The endpoint still lists some versions a rebuild keeps, which is the ticket's symptom.

1. Should-fix: a reference whose system names a version is still listed.

  • Failure: CollectionReference(system=v1.uri, code='c1') with an empty version is is_versionless_expression, so the rebuild records v1 in evaluated_source_versions and keeps it. #1065's test_rebuild_resolves_a_reference_whose_system_names_a_retired_version_by_its_url asserts exactly that. A canonical url|v1 system behaves the same way.
  • This PR treats evaluated source versions as moving unless system-version names them, so it reports v1 → v2.
  • Fix: also keep the evaluated versions that names_repo_version versionless references resolve to. Skip that where a system-version entry for that repository overrides them.

2. Should-fix (here or a follow-up): resource-versioned references with resource-version repo resolution on.

  • Failure: the rebuild re-picks the newest release that holds the concept version (find_repo_version_with_resource_version), not the repository's latest. test_rebuild_keeps_resource_version_held_by_older_release keeps v1, but this endpoint lists v1 → v2.
  • With that toggle off, the listing is right.
  • Fix: when the toggle is on, compute the pick with get_repo_versions_holding_resource_versions and pick_repo_version_with_resource_version, and keep the version when the pick equals it.

3. Should-fix: self.parameters can be None.

  • The field is null=True, and self.parameters.get(...) raises AttributeError. This GET never read parameters before, so such a row now returns a 500.
  • Fix: use get(self.parameters, ExpansionParameters.INCLUDE_SYSTEM).

Nits

  • The re-resolved-repo query:
    • It includes references whose system is itself versioned, which a rebuild keeps.
    • .distinct('system') ignores namespace.
    • Better: iterate distinct (system, namespace) pairs and filter on not names_repo_version.
  • With EXPANSION_LOCKED_REPO_VERSION off, a value set named /…/collections/C/v1 (no trailing slash) or …/|v1 is classified as evaluated, but still resolves to v1 on a rebuild. It is listed unless the expansion is lock-built. Impact is low.
  • The get_repo_version_ids_a_rebuild_keeps docstring is garbled ("those references name (unless through … re-resolved)").
  • OpenConceptLab/oclweb3#114: the response shape is unchanged, so nothing breaks. Its system_version and lock pinned branches become dead once this ships, which is worth a note on that PR.

Checked, no issue:

  • The relations are cleared before re-evaluation.
  • Lock-built value-set locks are kept, including with the toggle off, because use_any_lock uses bool(built_with).
  • system-version resolution matches the rebuild's resolution and namespace. A bare URL still moves.
  • HEAD named by a reference or by url|HEAD is kept.
  • The modified existing tests and the new tests should pass as written.
  • There's no N+1 query.

…rsioned systems, resource-version picks, no parameters
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Fixed in 798e13e. get_repo_version_ids_a_rebuild_keeps now keeps exactly what a rebuild records again:

  1. A reference's system naming a version: an evaluated version a versionless reference's versioned system resolves to is kept, unless system-version decides that repository. Covered by test_resolved_repo_updates_leave_out_a_version_a_reference_s_system_names.
  2. Resource-versioned references: with resource-version repo resolution on, the release pick_repo_version_with_resource_version picks from the holders is kept. The pick uses the rebuild's evaluated versions as locks. With the toggle off, the version still moves. Covered by test_resolved_repo_updates_leave_out_the_release_holding_a_concept_version.
  3. parameters = None: now read with get(self.parameters, …). Covered by test_resolved_repo_updates_with_no_parameters.

Other changes in the same commit:

  • Explicit versions: kept only when a reference still names them, so a version left by a deleted reference is listed. The tests now create the naming reference.
  • Value sets: one named with a version, in any URL form, is kept in either relation.
  • Queries: references are read as distinct (system, version, namespace, valueset) tuples, with the namespace taken from each reference. Concept and mapping version references are loaded in full only for the holder pick.
  • Docstring: rewritten.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

I merged master (41aa19c) to pick up #1066 (783f6b1). That change records a reference whose system names a version as explicit, and evaluates it in that version. So finding 1 is now covered by the explicit rule: a non-versionless reference's resolved version is kept. In 6408d63 I removed my separate versioned-system branch, which #1066 made dead. test_resolved_repo_updates_leave_out_a_version_a_reference_s_system_names now records v1 as explicit, which is what a rebuild records.

@snyaggarwal
snyaggarwal marked this pull request as ready for review November 25, 2026 12:27
@snyaggarwal
snyaggarwal requested a review from paynejd November 25, 2026 12:27

@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.

Review round 2 (Expansion Health epic, reviewed with #1069–#1071, #1073 and OpenConceptLab/oclweb3#114): approve with nits

Round 1's three should-fix items are fixed (798e13e, 6408d63 after merging #1066):

  1. A versioned system: since #1066, a rebuild records it as explicit, and it's kept by the explicit rule.
  2. Resource-version picks: with the resolution toggle on, the pick uses get_repo_versions_holding_resource_versions and pick_repo_version_with_resource_version, with the rebuild's evaluated versions as locks.
  3. parameters = None: now read with get(...).

Checked, no issue

  • Resource-versioned references: they aren't is_versionless_expression, so add_references records them as explicit. Adding the pick to kept['explicit_source_versions'] is the right relation.
    • They can't compute against system-version (can_compute_against_other_system_version excludes resource_version), so the pick never conflicts with a system-version pin.
  • system-version pins: only versionless references compute against them, so keeping those pins only in evaluated_source_versions matches what a rebuild records.
  • Lock-built value-set locks:
    • a rebuild keeps them only when built_with == lock (kept_valueset_locks);
    • for anything else, evaluated_collection_versions is cleared before valueset_locks is read, so those move. This matches.
  • Response shape: unchanged, so nothing breaks outright. But OpenConceptLab/oclweb3#114's client-side pinned: 'reference' rule now hides real updates. That's posted as a should-fix on #114, and it means this PR should deploy before #114 (see below).

Nits

  1. Cost on a GET.
    • references.exclude(no_resource_version) loads every resource-versioned reference as a full model instance, even with the resolution toggle off. With the toggle off, nothing uses them beyond resolve(), which is cached by system anyway.
    • Collections built from concept versions can have tens of thousands of these, and TBv3 calls this endpoint for each expansion row it opens.
    • Fix: skip that queryset when is_resource_version_repo_resolution_on() is false, and use .only(...) with the fields the pick needs when it's on.
  2. Lock-built locks are kept even when no reference uses them any more. A deleted value-set reference's lock is hidden. That's the opposite of explicit source versions, which are listed once no reference names them. Neither case is an update a rebuild would offer, so the impact is low. It's only a consistency point.

Deploy order: deploy this before OpenConceptLab/oclweb3#114, and only together with #114's fix. After this PR, a version listed only in explicit_* is one a rebuild moves:

  • a resource-versioned reference with the resolution toggle off;
  • with the toggle on, a recorded pick that differs from today's pick;
  • a version no reference names any more.

#114 still labels those "pinned by a reference" and hides their Rebuild.

CI: Pylint passes; Tests is still running.

…s are loaded only for the release pick, and then with only the fields it reads
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Round 2 nit 1 is fixed in 951d189.

What changed in get_repo_version_ids_a_rebuild_keeps:

  • Resolution toggle off: concept and mapping version references are no longer loaded as full instances. They're read as distinct (system, version, namespace, valueset) rows, together with the other references.
  • Toggle on: they're loaded with .only(...), limited to the fields the release pick reads.

Why not skip them entirely when the toggle is off: with the toggle off, a concept version reference whose system names a version still keeps that version as explicit. Skipping the references would list that version as an update. Reading them as rows keeps the same result as before. test_resolved_repo_updates_leave_out_a_version_a_concept_version_reference_s_system_names covers it with the toggle both off and on.

Nit 2 (lock-built locks with no reference left) is unchanged.

@paynejd paynejd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review lead (Claude, for Jon), round 1

Verdict: COMMENT (head 951d189). Nothing blocks the merge; the points below are nits, plus a deploy-order note.

Reviewed against OpenConceptLab/ocl_online#773. The four listed cases are covered and tested: an explicitly named version, a system-version lock, a lock-built value-set lock, and HEAD named by a reference or by system-version.

Earlier points

  • Round 1 should-fix 1, a versioned system: met. After merging master at 41aa19c (#1066) a rebuild records it as explicit, and the explicit rule keeps it. I checked the merge with git show --remerge-diff 41aa19c3: it is empty, so master's side was taken as is, and 6408d63 then removed the branch that #1066 made dead.
  • Round 1 should-fix 2, resource-version picks with the resolution toggle on: met, using get_repo_versions_holding_resource_versions and pick_repo_version_with_resource_version.
  • Round 1 should-fix 3, parameters of None: met (get(self.parameters, ...), test_resolved_repo_updates_with_no_parameters).
  • Round 1 nits (distinct (system, version, namespace, valueset) tuples, value sets named in any URL form, docstring): met.
  • Round 2 nit 1, loading every resource-versioned reference in full on a GET: met in 951d189. They are read as distinct tuples, and loaded with .only(...) only when the toggle is on.
  • Round 2 nit 2, lock-built value-set locks kept when no reference uses them: accepted, low impact.
  • Deploy order with OpenConceptLab/oclweb3#114: met on that side. #114 at 5db310d dropped its client-side "named by a reference" rule and lists what this endpoint returns, so this deploys before #114 or with it.

New (all nits)

  1. A value set named once by version and once by its bare URL, in the same collection, hides the bare reference's update. The explicit one adds its version id to both relations (models.py ~L2609), and the bare reference's evaluated record of the same version is then treated as kept. The source case is handled (a version recorded as both is still listed); the value-set case isn't.
  2. The destination in the response for a concept-version reference comes from resolve_reference_expression(repo_url), the repository's latest. A rebuild moves it to the release that contains the concept version, which can be older. The entry is right to be listed, but the target URL can differ from what the rebuild picks. The pick is already computed, so reporting it would match.
  3. A version left behind by a deleted reference is listed, and the test at ~L4086 expects it. A rebuild drops that repository instead of moving it, which reads against the ticket's "only versions a rebuild would move". The behaviour is the same as master and Sunny chose it on purpose, so I'd leave it unless Jon prefers otherwise.

CI: Pylint and Tests pass.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Thanks. Replying to round 1. I've left the three nits as they are for now, since none blocks the merge:

  1. A value set named once by version and once bare: a narrow case. It needs both forms in one collection.
  2. The destination for a concept-version reference: right that it shows the repository's latest rather than the release a rebuild picks. Reporting the pick means carrying each old version's pick out of get_repo_version_ids_a_rebuild_keeps, which is worth its own small change if Jon wants the target exact.
  3. A version left by a deleted reference: kept listed on purpose, as you noted.

Happy to pick up 1 or 2 if Jon prefers them in this PR.

@paynejd

paynejd commented Nov 26, 2026

Copy link
Copy Markdown
Member

Ready to approve. Review lead (Claude, for Jon), round 2, head 951d189.

Every earlier point is met, and Pylint and Tests pass. I agree none of the three round-1 nits blocks:

  1. A value set named once by version and once bare: a narrow case, fine to leave.
  2. The destination shown for a concept-version reference: the entry is right to be listed; only the target can differ from the release a rebuild picks. Fine as its own change if Jon wants the target exact.
  3. A version left by a deleted reference: listed on purpose.

The head still merges cleanly with master (bc3bd00). Deploy order is unchanged: this before OpenConceptLab/oclweb3#114, or with it.

@snyaggarwal
snyaggarwal merged commit 7d813fc into master Nov 26, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-773-resolved-repo-updates branch November 26, 2026 02:13
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