Skip to content

OpenConceptLab/ocl_issues#3074 | A reference to a concept added after the release says why it resolved to nothing and how to fix it - #1073

Merged
snyaggarwal merged 8 commits into
masterfrom
ocl_issues-3074-unresolved-reason
Nov 29, 2026
Merged

snyaggarwal merged 8 commits into
masterfrom
ocl_issues-3074-unresolved-reason

Conversation

@snyaggarwal

@snyaggarwal snyaggarwal commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

API part of items 1 and 3 of OpenConceptLab/ocl_issues#3074 (epic OpenConceptLab/ocl_issues#2942), following #1017. The TBv3 part is OpenConceptLab/oclweb3#116.

The everyday case now says why and what to do

An unversioned reference to a concept added after its source's latest release used to read "…, but it resolved to no concepts or mappings in /orgs/O/sources/S/v1/". It now reads:

The reference is saved in collection Foo, but its concept is not in /orgs/O/sources/S/v1/, the release the collection uses, because it was added after that release. To include it, create a new release of /orgs/O/sources/S/ and rebuild the expansion, or refer to a version of /orgs/O/sources/S/ that has it

For a mapping it says "its mapping". repo_versions names the release, and reason is not_in_release. added, resolved: false and the other keys are unchanged.

When it's used (CollectionReference.get_release_added_after), all of these must hold:

  • The reference names one concept or mapping by code, with no filter or value set.
  • Its system names no version, so the collection resolves it through the source's latest release.
  • The expansion evaluated it in that release, and nowhere else. A version lock on an older release keeps the old message, since a new release wouldn't fix that by itself.
  • The source's HEAD has the code, or the resource version it names, as evaluating the reference in HEAD would find it.
  • The requester can view the release and HEAD's content, so it reveals nothing new to anyone else. Anyone else gets the old message, as before.

Otherwise the reference keeps the message it had: the found-nothing, parameters-excluded or resource-version messages from #1017.

The same message on both kinds of expansion

  • The everyday case: the message is chosen when the response is built, from the reference and its source, so both kinds give it. That covers the usual auto-generated expansion and one someone created.
  • A resource version that no version has (resolution toggle on): a created expansion marked it resource_version_not_held when it re-evaluated it. An auto-generated one doesn't re-evaluate, so it marked it found_nothing and said "resolved to nothing in …". It now gets the same reason from the reference's saved members, so both kinds say "no version of … has resource version …". Only the response reason changes: the expansion's unresolved_repo_versions are untouched.

Blank collection name (older point from the ticket)

The success message for an expression that names a source version, like /orgs/O/sources/S/v1/concepts/c1/, read "The reference is successfully added to collection " with the name blank. It now names the collection.

A reason code per reference

Each unresolved item now has a stable reason next to repo_versions and message. Clients such as TBv3 read the code to show a short label; message stays as a fallback for API clients.

reason When
not_in_release its concept or mapping was added after the release the collection uses
filtered_by_parameters the expansion's parameters exclude everything it resolved to
concept_version_not_found no version (or not the version it names) has the resource version it names
filter_not_applied its filter names a property or op OCL can't apply
repository_not_found a value set it names can't be found, or its requester can't view it
valueset_not_expanded a value set it names has no default expansion
not_found anything else that resolved to nothing

Wording

Tests

  • Integration, both kinds of expansion (a created one and autoexpand-HEAD):
    • a concept and a mapping added after the release get the new message;
    • a pinned resource version that no version has gets "no version of … has".
  • Integration:
    • a reference naming that release keeps "resolved to nothing in v1";
    • the two private-source tests now expect the new message for members and staff, while a requester who can't view the source still gets the old one;
    • the two version-pinned success messages now carry the collection name;
    • every internal reason, plus an unknown one, maps to its reason code, and the full-item assertions include reason.
  • Model:
    • an auto-generated expansion marks a pinned version that no version holds resource_version_not_held with the toggle on, and found_nothing with it off;
    • get_release_added_after returns the release for a code and a resource version HEAD holds. It returns None for an unknown code, a named version, a filter, and a source with no release.

Focused pylint on the 5 changed files exits 0. The local stack is down, so the Django tests run in CI only.

🤖 Generated with Claude Code

… the release says why it resolved to nothing and how to fix it, on both kinds of expansion

@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 1 (Expansion Health epic, reviewed with #1069–#1072 and OpenConceptLab/oclweb3#116): approve with nits

The new "added after the release" message is narrowly scoped, and it falls back to the existing messages in every case it doesn't cover. Its view checks keep what it reveals to what the requester can already see.

Checked, no issue

  • get_release_added_after guards:
    • it needs a code, with no filter, value set or named repo version;
    • the latest release must be released, not HEAD, and viewable;
    • the expansion must have evaluated the reference in that release only, so a lock on an older release keeps the old message;
    • HEAD's content must be viewable and hold the code or the pinned resource version.
  • No false "added after":
    • REFERENCE_EXCLUDED_BY_PARAMETERS is skipped before the call;
    • for REFERENCE_VERSION_NOT_HELD with the toggle on, HEAD doesn't hold the version either, so it returns None;
    • with the toggle on, a resource version only HEAD holds resolves to HEAD (pick_repo_version_with_resource_version), so it never reaches this message.
  • Auto-generated branch: the not-re-evaluating branch now marks resource_version_not_held from saved members, with the toggle on only. It only sets unresolved_reason, so unresolved_repo_versions and #1069's merge are unaffected.
  • Success message fix:
    • an expression pinned to a repo version has the version at index 5, so it always fell through to UNKNOWN_REFERENCE_ADDED_TO_COLLECTION_FMT.format('');
    • now it passes the collection name;
    • the two updated integration tests cover it.
  • Open core: nothing commercial in the messages, constants or tests.
  • TBv3: OpenConceptLab/oclweb3#116 shows the API's message as given, and wraps it at phone width.

Nits

  1. Merge conflict with #1069 in core/collections/tests/tests.py. Both add tests right after test_add_references_marks_pinned_reference_no_version_holds (~L4420). It's textual only: keep both blocks.
  2. Queries per unresolved reference: for each unresolved reference, the response builds:
    • release.has_view_access;
    • _get_resolved_system_versions;
    • release.head, a query each time, not cached;
    • head.can_view_all_content;
    • an exists().
      A bulk PUT of many references to one source, all added after its release, repeats the first four for the same release. A per-release cache in the view (keyed like system_version_cache) would leave one exists() per reference.
  3. Wording is Jon's call. "its concept is not in …, the release the collection resolves through" reads fine. The message names two URLs, so at phone width it leans on OpenConceptLab/oclweb3#116's wrapping.

CI: Pylint passes; Tests is still running.

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Round 1 nit 2 is fixed in 6ced918:

  • The fix: get_unresolved_items now passes a release_head_cache. For each release, the view check, the HEAD lookup and HEAD's can_view_all_content now run once, not once per reference.
  • Not cached: _get_resolved_system_versions.
    • For a concept or mapping version reference, its result depends on the reference.
    • For the others it already runs in memory, from the expansion's cached recorded versions.
    • So the per-reference work left is that call and the exists().
  • Test: test_release_added_after_checks_a_release_s_access_and_head_once.

Nit 1, the textual conflict with #1069 in core/collections/tests/tests.py, still applies to whichever of the two merges second. Keep both blocks.

@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. Every earlier point is met and CI is green. The message wording waits on Jon's call; that doesn't block the merge, and changing it later is a one-constant edit (REFERENCE_ADDED_AFTER_RELEASE_FMT, core/collections/constants.py:27).

Earlier points (all met at 6ced918)

  • Nit 1, textual conflict with oclapi2#1069 in core/collections/tests/tests.py: answered (keep both blocks). The branch merges cleanly with master now.
  • Nit 2, queries per unresolved reference: met. get_unresolved_items (core/collections/views.py:578) passes a release_head_cache, so the release's view check, HEAD lookup and can_view_all_content run once per release (_get_viewable_release_head, core/collections/models.py:1627). Leaving _get_resolved_system_versions uncached is fine for the reason given. Covered by test_release_added_after_checks_a_release_s_access_and_head_once.
  • Nit 3, wording: waits on Jon's call.

Checked at head, no defect

  • get_release_added_after falls back to the old messages for every case it doesn't cover (filter, value set, named version, an older release lock, HEAD without the code, a requester who can't view the release or HEAD).
  • REFERENCE_EXCLUDED_BY_PARAMETERS is skipped before the call, so no false "added after".
  • The auto-generated branch (core/collections/models.py:2191) sets only unresolved_reason; unresolved_repo_versions is untouched.
  • Success message for a reference that names a version: the integration tests now expect the collection's name.

One question, not a defect in the diff. The message tells the owner to create a new release. Please confirm on staging, with a reference that came back with this message, that after the new release exists the reference then resolves (that the default expansion re-evaluates it against the new release), or whether the owner must also re-run the expansion or re-add the reference. If it needs a step, the message should say so, and that is worth a line in the ticket either way.

Optional

  • core/collections/models.py:2191: with a collection whose auto-generated expansion didn't evaluate the version the reference names (evaluation skipped), "no version holds resource version" could be reported for a version that exists. The skipped case is narrow; a comment on the condition is enough.

CI. Tests and Pylint pass on 6ced918.

…ansion needs a rebuild after the new release, as nothing re-evaluates it
@snyaggarwal

Copy link
Copy Markdown
Contributor Author

Thanks. Replying to round 1. Changes are in dc26623.

Your question: does the reference resolve once the new release exists? No, not by itself. I checked it in the code rather than on staging:

  • Creating or releasing a source version only marks health (Expansion.mark_health_not_current_for_repository). Nothing re-evaluates a collection's references or moves an expansion off the release it locked to, which matches the rule that publishing a release doesn't move a lock.
  • So after the new release, the default expansion stays on the old one until it's rebuilt. TBv3 then offers the rebuild (ocl_issues#3009).

So the message needed the step. REFERENCE_ADDED_AFTER_RELEASE_FMT now ends: "To include it, create a new release of {source} and rebuild the expansion, or pin the reference to a version that holds it". The integration test expects the new text. The exact words are still Jon's call.

Optional, taken: the condition at core/collections/models.py:2191 now has a comment saying that, when the expansion never evaluated the version the reference names, holding nothing can mean only that.

Pylint passes on the changed files. The local stack is down, so CI runs the Django tests on the new head.

@paynejd

paynejd commented Nov 26, 2026

Copy link
Copy Markdown
Member

Review lead (Claude, for Jon), round 2, head dc26623.

Both round-1 points are answered:

  • The question (does the reference resolve once the new release exists?): answered from the code. Creating a release only marks health; nothing re-evaluates the references or moves the expansion off the release it locked to. So the expansion needs a rebuild, and the message now says so. That matches the rule that a new release doesn't move a lock.
  • Optional: the comment on the condition at core/collections/models.py:2191 is in.

Pylint and Tests pass. The PR stays on hold for Jon's call on the expansions design, which includes this message's wording ("pin the reference" among it). Nothing else is open.

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

Copy link
Copy Markdown
Contributor Author

@paynejd a reminder: this PR is ready in code (CI green, master merged at d4bd113) and is waiting only on your decisions:

  1. Reference outcomes: keep today's per-reference sentences, or move to short labels per reference with counts first (the redesign proposed on ocl_online#549). The labels need API reason codes per reference first.
  2. This message's wording: "…create a new release of {source} and rebuild the expansion, or pin the reference to a version that holds it". Is "pin" OK, or should it say something else, such as "name a version"?

It merges once you decide. Ticket: OpenConceptLab/ocl_issues#3074.

snyaggarwal and others added 2 commits November 29, 2026 13:00
…ble reason code, and drop 'pin' and 'hold' from its messages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' instead of 'resolves through'

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

paynejd commented Nov 29, 2026

Copy link
Copy Markdown
Member

Review lead (Claude, for Jon), round 3, head ff7976c.

Verdict: ready to approve once Tests pass (Pylint passes; Tests were still running). Both settled answers on OpenConceptLab/ocl_online#549 are carried out.

  1. A reason code per reference: met (eeb6ccf). Each unresolved item in the add response now has a stable reason: not_in_release, not_found, filtered_by_parameters, concept_version_not_found, filter_not_applied, repository_not_found or valueset_not_expanded. repo_versions gives the version it looked in, and message stays as the fallback for API clients. The integration tests check the codes.
  2. No "pin" or "hold": met (eeb6ccf, ff7976c). The message now ends "or refer to a version of {source} that has it", "resolves through" became "uses", and the two "holds" messages say "has".

Optional, for a later change. The rules page has a class "In a newer release" with no code yet. When an expansion is locked to an older release and the concept is in the newer one, get_release_added_after returns nothing (the evaluated version isn't the latest release), so the reference gets not_found. That is accurate, since OCL evaluated it there and found nothing, but a newer_release code would let TBv3 show the more specific class.

OpenConceptLab/oclweb3#116 reads these codes, so this should merge before it.

@snyaggarwal
snyaggarwal merged commit 02f3ad9 into master Nov 29, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_issues-3074-unresolved-reason branch November 29, 2026 08:51
paynejd added a commit that referenced this pull request Dec 1, 2026
Brings in #1085, #1086,
#1082 and #1073. The two
conflicts were adjacent additions (master's EXPANSION_FHIR_RULES_TOGGLE and
evaluation import next to this branch's REFERENCE_SEARCH_OPTIONS_TOGGLE);
both are kept. No change to this branch's own code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWUTom6BGgjQy6oehZ
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