Repository navigation
Conversation
…on's version parameters, and loops refused Under FHIR's rules (the per-evaluation switch: on for FHIR's evaluations, OCL's toggle for API users), an imported value set's default expansion is read as it is only when nothing the expansion brings would change it: its version parameters (system-version, force-, check-system-version, default-valueset-version) and the evaluation's own content leave every version it used, however deep, as it was; nothing it couldn't resolve now resolves; it used one version of each source; and the expansions it read form no loop. Otherwise its references are evaluated again, from its own locks, in an expansion that isn't kept. A failed check or a parameter naming no version met there is recorded on the importing expansion, marked with the value set it came through. A value set whose evaluation leads back to one being evaluated, or to itself, adds nothing and is recorded as a loop (health: value_set_loop); adding a reference whose import leads back to the version it's added to is refused. A value set reached by two routes is not a loop. With the switch off, nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…ong each import, nested reuse, loops on saved results, private imports) - The loop walk and an import's evaluation take the parameters that reach each import along its route: the importer's, as they resolve in the import's namespace (by the repository's OCL path where its URL registry would name another), ahead of the import's own. - What an import read in turn counts as changed when a version parameter names a repository it used: its default expansion now may not be what the importer read. - An expansion that reuses saved results still refuses a loop. - A default-valueset-version naming no version records its parameter, and is carried through an import like the others; a failed check counts only when it is the importer's check for that repository. - What came through an import is named only to a reader who can view that value set. - The evaluation's own content is asked for a release's HEAD canonical URL too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
… other value sets is evaluated again, routes kept, walks that end) - An expansion records which value sets it read, not what they held then, so under FHIR's rules one that read any is never read as it is: it's evaluated again from what they hold now. - The evaluation's own content is asked for the URLs the import's references and parameters name. - What came through imports keeps its whole route (via_path); a reader sees it only when they can view every value set on it. - An importer's entry naming no repository in its namespace doesn't reach the import; entries met again around a loop aren't added twice. - The add-time walk stops at a version on its route; the loop walk's memo is its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…s, legacy links, carried imports' diagnostics, loop memo) - What came through imports records the exact value set versions on its route (via_versions); a reader sees it only when they can view each, and never the ids themselves. - system-version and check-system-version are asked of every source version an import recorded: one built before OCL told named and chosen versions apart recorded both as named. - What a carried value set built under the same parameters found is recorded through its importer too. - The loop walk's memo keeps the versions each cached branch leads to, and loops when one is on the route; the add-time walk keeps only results no loop cut short. - An inherited entry naming a version that doesn't exist still names its repository (versionless fallback); a diagnostic's key includes the importing reference's namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…he, a helper and a test that added nothing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
… from the references, own rules only, each route walked once) - Which source versions an import chose is told from its references (those naming no version), not from how its expansion recorded them: a version every reference names keeps its stored members under system-version. - A diagnostic counts as the importer's only when its rule for that repository is the entry, not only the same text. - Imports of one version under one set of parameters are read once, whatever route reaches them, and the add-time walk visits each once even past a loop elsewhere; the import list is cached apart from the method that reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…alk reuses a result only while what cut it short is on the route) A version that couldn't reach the target is reused only while the versions on the route that cut its walk short are on the route again, so a route reaching it under other parameters is walked; the walk loops plainly, one frame a level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…import evaluated again carries what reading it by version needs Rebased onto the versions-kept-apart branch (#1090). An import evaluated again outside a request (EvaluatedImport) now carries what reading it by version reads: its parameters, how it was built, whether it keeps versions apart, the versions it recorded and its memberships, read before its rollback. ImportedValueSet reads memberships through one helper that answers for both a stored expansion and such an import. Tests: an intersection and an exclusion ask an import by version, as versions kept apart read it; a carried import's marker covers its memberships too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…layed references read imports under the parameters, readers by what they read - An import's references, evaluated again at another version to read it by version, read their own imports as the import's evaluation under the expansion's version parameters would (ValueSetImports.inner), not their stored expansions. - Readers of an import are kept by what they read and how (the expansion, and the imports it was read under), so one version read as built for one reference and evaluated again for another is read as each needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…s own route, so a replayed import's loop back to it is one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…he rules now name code systems, by repository and canonical URL Rebased onto fhir-452-b-apart a1d6351, where a version rule applies by the repository it names and by its canonical URL (VersionRules.keys_of, Rules.find). What an import used, recorded as unresolved, or reports through its importer is looked up the same way (ValueSetImports.keys_of). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
… as an evaluation rules them; one that kept versions apart read as it is - Whether the version parameters change what an import used is asked of each of its references to a code system, as an evaluation of them would ask (VersionRules.rule_for and keys_of, by the reference's own URL and namespace), not worked out again from the versions its expansion recorded. - An import whose default expansion kept versions apart may be read as it is though it used two versions of one source: its memberships say which version selected each member. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…an import's reference is checked against the one version it used A version parameter that applies to one of an import's references leaves it as it was only when the stored expansion used exactly one version of that reference's code system and that version is the one the rule gives (and one check-system-version names). With none or several (versions kept apart, or a reference served from another repository), which it used can't be told, so the import is evaluated again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…one, and an import's own force-system-version means it's evaluated again - The versions an import's expansion used are told apart by version, so one recorded both as named and as chosen is one, and a parameter that leaves it as it was doesn't rebuild the import. - When the import's own expansion carries force-system-version, which may have taken a reference to another code system, a version parameter that applies to one of its references means it's evaluated again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
…-version counts only for the references it applies to Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn
paynejd
force-pushed
the
fhir-452-b-imports
branch
from
November 30, 2026 01:08
431959d to
c53c67f
Compare
paynejd
changed the base branch from
fhir-452-b-versions
to
fhir-452-b-apart
November 30, 2026 01:08
…ort reads is the evaluation's to give ValueSetImports reads an imported version's default expansion through ExpansionEvaluation.default_expansion: its stored one, as before, unless a subclass has one of its own for a version of content of its own, as a request that carries a value set reached only through a stored import builds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTifnareNUwCKwKcm
… hook (c3831b4) The FHIR workspace no longer needs it: a stored value set evaluated again over content a request carries is refused there instead of built over it. This returns the branch to c53c67f's tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTifnareNUwCKwKcm
…r-452-b-apart) into imports Brings in #1090's new head, which carries #1087's and #1086's: a request-time evaluation evaluates only expansions built under it, for its caller (what references find is what the caller can view) unless opened for none, a version the caller can't view is answered as one not found, and a statement runs as it is while the evaluation has no deadline. Conflicts, in core/collections: - evaluation.py: ExpansionEvaluation keeps both sides' state (the caller, its own expansions and what it may view; what it built and the imports it evaluated). at_request_time's description keeps both halves, the no-seconds sentence included. within_deadline is #1086's, which lets a statement through with no deadline, as this branch's did. - models.py, build_at_request_time: both sides kept: refused for a version the evaluation may not build; locks_of's locks and the parameters it was built under recorded; the expansion registered as its own. Adapted to the new interface: this branch opens an evaluation at request time outside a request too, so that nothing a stored expansion's import evaluates again is kept (ValueSetImports.evaluate). An opening answers its caller unless opened with for_caller False, which #1086 now offers, so that path opens with for_caller False: the import is evaluated as its references' creators view it, as the stored build is, rather than as an anonymous caller (which refused a private import). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWddiMQHvvG5BYWRfh
paynejd
added a commit
that referenced
this pull request
Nov 30, 2026
…for no caller views as each reference's creator at_request_time takes for_caller (True by default). Opened with False, only so that nothing it evaluates is kept, as an expansion built outside a request may (an import evaluated again, in the stacked #1091), it answers no caller: each reference finds what its creator can view, as outside a request, nothing is hidden, and build_at_request_time builds what the references reached. answers_caller says which; viewer, viewer_id, hides and can_build follow it. The rollback, side-effect guard, deadline and own-expansion check are as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWddiMQHvvG5BYWRfh
…release the caller can't view still applies A request-time build from another expansion's locks keeps them as they are: one on a release the caller can't view is still the release its reference is evaluated in, answered as not found, never a newer one the caller can view. The lock stays recorded, so what replays the build's references later keeps it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWddiMQHvvG5BYWRfh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7 # Conflicts: # core/collections/models.py
…mport keeps the version it used A failed version check recorded through an imported value set is the imported expansion's own entry, so it keeps the id of the version that evaluation used (#1087). The route's ids join that id among the ones OCL records for its own checks and leaves out of what readers are given, in one place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVWYYmWDsL1uzvh9q7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVC3osEQxNxh6dcRnV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qV2gzsF5GhF5BwTJ6x
paynejd
added a commit
that referenced
this pull request
Nov 30, 2026
…es), which the FHIR series builds on fhir-452-b-codes ends the queue of OCL API PRs, so the FHIR series sits on all of them: #1085, #1086, #1089, #1088, #1087, #1090, #1091, #1092 and #1093, and the core changes that need them together. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qV2gzsF5GhF5BwTJ6x
snyaggarwal
pushed a commit
that referenced
this pull request
Dec 1, 2026
…t time, under a resolution the caller supplies, with code references in one query (#1086) * OpenConceptLab/ocl_online#452 | An expansion evaluates under an ExpansionEvaluation the caller may supply An ExpansionEvaluation says how one expansion is evaluated: which rules it follows (fhir_rules: OCL's new EXPANSION_FHIR_RULES_TOGGLE decides for API requests, read only when asked; a caller can set them) and how what its references and system-version entries name resolves. Its resolve() is the one entry point for both, ahead of the shared resolver, so a caller with content of its own can answer for a canonical first, even with the URL registry on. The version is passed apart from the URL. add_references and seed_children take an optional evaluation and set it on each reference while they evaluate it. Callers that pass none are unchanged: each reference resolves under its own default, which calls the resolver exactly as before. Nothing reads fhir_rules yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | An expansion can be evaluated at request time, rolled back, with side effects refused and a deadline ExpansionEvaluation.at_request_time(seconds) opens an evaluation for one request: a transaction rolled back when it closes; side effects refused while it's open (Celery tasks and cache writes raise in tests and are skipped in production with an error logged; a search index write raises in both; an on_commit hook is refused at close, the rollback dropping it); and one deadline for all it runs. Each statement gets SET LOCAL statement_timeout from the time left, add_references checks it before each reference, and running out raises EvaluationTooCostly once rolled back. Under it, add_references and seed_children index nothing and write nothing back to the references or to health, and Expansion.build_at_request_time builds a new expansion of a collection version at once. The guard lives in core/side_effects.py: the task classes check it before they queue (a once task before it takes its lock), the cache backend is django_redis's with its writes checked (core.common.cache.RedisCache), and the search client's transport refuses writes (RefusingTransport). With no evaluation open they behave as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | An expansion evaluates its code references to one source version in one query A reference to one concept by its code, with nothing else to apply (no concept version, cascade, transform or value set), is now evaluated with the others like it: add_references resolves each as before, then finds all their codes with one query per source version (CodeReferenceBatch), applies the expansion's parameters once to what they found, adds it once, and writes back and records each reference's result as it did one at a time. Each finds what it found on its own: in a version, the concept with that code, the newest if the version holds two; in HEAD, the concept itself; only in versions its creator can view. add_references also reads its owner's resolution namespace once rather than once per reference (a toggle read each). A request-time build of 10 or 40 code references now runs the same number of queries; one at a time it ran about six more per reference. Tests build each case both ways (batched and one at a time) and compare members, mappings, recorded versions, unresolved entries, each reference's reason, what's written back and what's indexed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | A request-time evaluation checks the 32-bit link sequences it advances A rollback gives back none of the ids a request-time evaluation used, so each request advances the sequences of the link tables it writes for good. LINK_SEQUENCE_TABLES lists the ones with 32-bit ids (concept and mapping source links, parent links, expansion members, reference results and an expansion's recorded versions), and link_sequence_usage() reads how much of each range is used. at_request_time() refuses to open (EvaluationUnavailable) once one reaches 90%, leaving the rest to OCL's own writes. A test checks that every table with 32-bit ids a request-time build inserts into is on the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Lint: a cache write test passes the method itself Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Review pass 1: exclusions batched, order kept, the guard tightened - Code references excluded are evaluated together too, one query per source version. - A run of code references is applied before any other reference, which may read the expansion being built (a value set reference to its own collection), so every reference sees what it saw one at a time. - Members a request-time evaluation removes no longer mark the stored collection's last_child_removal_at, which held its row until the rollback. - Bulk indexing and the indexing signal tasks check the guard in the calling thread, before their worker threads (which don't see it) start. - An on_commit hook is refused when it's registered, savepoints included, not only at close. - The deadline covers the sequence check, and an evaluation that finishes past it is too costly. - A relative url|version is split for the evaluation's resolve too, unless the resolver reads it as canonical. - The test runner's no-op cache refuses writes at request time, as the deployed cache does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Review pass 2: search reads within the deadline, one search per version, nested guards - Search index reads during a request-time evaluation get only the time its deadline leaves, with no retries, and a search ends on the index's side too (its timeout); out of time, or timed out, is too costly. - A code batch is told every code the expansion's code references name, so each source version is searched once, however other references split them into runs. - Expansion parameters that read members (exclude-system, date) apply reference by reference, as before, since an earlier reference's concepts can change what a later one adds. - The sequence check runs inside the evaluation, within its deadline. - A nested evaluation restores the outer one's on_commit guard when it closes. - Fix: the bulk index guard named its document with __name__, which an instance doesn't have, on every bulk index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Code batches index exactly as one reference at a time did - What batched code exclusions removed is queued for indexing as a list: a set isn't JSON, so a build that indexes outside tests failed (found by crew fhir-b-versions' review). - With a parameter that reads members (exclude-system, date), what's indexed is re-read once added, as one reference at a time did, so the same members are indexed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Review pass 3: savepoint rollbacks, nested deadlines, read routes, indexing re-read - A savepoint's rollback or release, and a statement in a failed transaction, run without the deadline's SET LOCAL, so an error caught in a savepoint leaves the evaluation usable. - A nested evaluation ends by the outer one's deadline, for statements and search reads alike. - A search request is a read by its endpoint (the first segment starting with _), so a document whose id looks like a read's endpoint is still a write. - With a parameter that reads members, what's indexed is the parameters' own query re-read once added, as one reference at a time did (a text filter's matches stay as matched). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Simplification review: fewer read routes, one forwarding test less - The search transport takes for reads only the endpoints OCL sends (_search, _count, _msearch, _mget and a scroll); any other request is a write. - A test that seed_children forwards its evaluation goes: the request-time tests go through it. - Import order and a long line (lint). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Final check: _all searches, composed queries, a test stub's model - A search of every index (_all) is a search: _all names indexes, it isn't an endpoint. - The deadline wrapper passes a composed query (psycopg2.sql) through; only a string can be a savepoint's rollback. - The equivalence test's text filter stand-in answers with the model it was given (mappings too). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWrEkUwedkj6bUPC61 * OpenConceptLab/ocl_online#452 | Review: request-time evaluation builds only its own expansions, for its caller - At request time an evaluation evaluates only expansions built under it (build_at_request_time). A stored one is refused before anything is read or written: its rows would stay locked, and its members cleared, until the rollback. - A request-time evaluation answers its caller (ExpansionEvaluation(caller=...), anonymous unless given). What each reference finds is what the caller can view, not what its creator can (CollectionReference.viewer), and resolve() answers a version the caller can't view as one not found. build_at_request_time refuses a collection version the caller can't view. Without an evaluation nothing changes. - Equivalence tests for the incremental add (PUT .../references/, is_adding_all=False), with the collection's code and cascade exclusions evaluated again. - Code references: each version is searched for the codes of references naming its repository, not every source's. A stored build reads each creator once, not once per reference. - The sequence check: a sequence never used counts as none used, one this role can't read as unknown (no evaluation opens). Bigint ids on these tables would be the lasting fix. - SET LOCAL statement_timeout only once the time left has dropped STATEMENT_TIMEOUT_MARGIN (0.25 s) below the one last set, or a shorter evaluation opens inside; a savepoint's rollback has it set again. - The search index signal processor skips quietly while side effects are refused: no task and no error per row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXjDrGi7Trb7ERK92a * OpenConceptLab/ocl_online#452 | Review check: a version the caller can't view is hidden where it's recorded, not resolved away - resolve() no longer answers a version the caller can't view as unresolved. That also hid which repository a reference names, so a public release named in system-version no longer applied to it when the source's newer release was private. At request time, the expansion now answers such a version as one not found where it's recorded: a system-version entry, a reference's own versions and its value sets (ExpansionEvaluation.hides). - The viewer checks go through ExpansionEvaluation.can_view, which an evaluation with content of its own can extend to let its own versions through. - The statement timeout is trusted as last set only when every execute wrapper that runs before the evaluation's is an evaluation's: another (FHIR's search timeout) may set a longer one before each statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXjDrGi7Trb7ERK92a * OpenConceptLab/ocl_online#452 | Review check 2: visibility read once per version, a shorter timeout set around it kept - ExpansionEvaluation.can_view reads whether a version may reach the caller once per version and viewer, not per reference: an anonymous build of thousands of code references to a public release was two queries per reference. - The statement timeout set is the time left or the one already in effect, whichever is shorter (set_config from pg_settings, in one statement): an enclosing search with less time left keeps its own. - build_at_request_time asks the evaluation whether the collection version may be built (can_view), so an evaluation with content of its own can build its own value sets; a test shows such an evaluation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXjDrGi7Trb7ERK92a * OpenConceptLab/ocl_online#452 | Review check 3: what the caller may view read again each opening; the build asks has_view_access - The evaluation's visibility answers are read again each time it opens: access can change between two requests. - build_at_request_time asks ExpansionEvaluation.can_build, by default has_view_access as the API's views ask, which an evaluation with content of its own extends for its own value sets. - The timeout tests start from a known timeout, and one checks a shorter timeout in effect when it opens is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXjDrGi7Trb7ERK92a * OpenConceptLab/ocl_online#452 | Review check 4: a test of an old two-owner collection the build refuses, as the API does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXjDrGi7Trb7ERK92a * OpenConceptLab/ocl_online#452 | A statement runs as it is while the evaluation has no deadline within_deadline sets no timeout and cancels nothing while the evaluation's deadline is None, as it did before the deadline's rewrite: an evaluation opened within none, with no time of its own, has none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWddiMQHvvG5BYWRfh * OpenConceptLab/ocl_online#452 | An evaluation opened at request time for no caller views as each reference's creator at_request_time takes for_caller (True by default). Opened with False, only so that nothing it evaluates is kept, as an expansion built outside a request may (an import evaluated again, in the stacked #1091), it answers no caller: each reference finds what its creator can view, as outside a request, nothing is hidden, and build_at_request_time builds what the references reached. answers_caller says which; viewer, viewer_id, hides and can_build follow it. The rollback, side-effect guard, deadline and own-expansion check are as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWddiMQHvvG5BYWRfh --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…o fhir-452-b-imports Takes #1090's new head, which brings in master through #1087. Merged cleanly; 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
…o fhir-452-b-imports Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX3xher9sfoCLLKrTC
…torage, after fhir-452-b-apart) into fhir-452-b-imports So the migration graph stays linear: sources/0053-0054 and collections/0079-0080 come before what follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…its migrations bound their lock waits) into fhir-452-b-imports Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
…lock waits bounded before the first DDL, both ways) into fhir-452-b-imports Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWapJWFsFc1Xjopf9k
This was referenced Dec 1, 2026
…nto fhir-452-b-imports Takes #1103's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. The one conflict is the constants import in core/collections/models.py, where both sides add names: all 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_01AaZ4qVQviVc1p6MQwqUUed
paynejd
added a commit
that referenced
this pull request
Dec 2, 2026
…nto fhir-452-b-codes Takes #1091's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. The one conflict is an import line in core/collections/models.py, next to one this branch changed: this branch's is 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_01AaZ4qVQviVc1p6MQwqUUed
paynejd
marked this pull request as ready for review
December 4, 2026 11:46
paynejd
added a commit
that referenced
this pull request
Dec 4, 2026
…nto fhir-452-b-codes Takes #1091's new head. The one conflict is an import line in core/collections/models.py, next to one this branch changed: this branch's is kept. This branch already held everything else, so its tree doesn't change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
paynejd
added a commit
that referenced
this pull request
Dec 4, 2026
…nto fhir-452-b-codes Takes #1091's new head: #1090 now has the test stand-in's fix this branch had (f990fd0), and an imported value set whose expansion recorded no versions is read by those its references resolve to, or evaluated again. 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_01AaZ4qVQviVc1p6MQwqUUed
paynejd
added a commit
that referenced
this pull request
Dec 4, 2026
…nto fhir-452-b-codes Takes #1091's new head. Merged cleanly; 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_01AaZ4qVQviVc1p6MQwqUUed
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated Dec 1: this branch now merges
fhir-452-c-storage(#1103: the storage of code system supplements and reserved code spaces, four additive migrations), which merges right after #1090, so the migration graph stays linear. Its base moved to that branch; this PR's own diff is unchanged.Stacked on #1103, which comes after #1087 and #1090: merge those first. When they're on master, this branch merges master and its base becomes master. The diff against its base is what to review, and it doesn't change with that.
Part of OpenConceptLab/ocl_online#452 (phase B, PR 6: imported value sets under the expansion's rules, and value set loops refused).
What it does
Two changes to how an expansion reads the value sets its references import, behind the per-evaluation switch #1086 added (
ExpansionEvaluation.fhir_rules). FHIR's request-time evaluations will turn it on. For API requests theEXPANSION_FHIR_RULES_TOGGLEtoggle decides, and it isn't set anywhere, so nothing changes for API users until it is.Version parameters reach imported value sets
Today a value set reference reads the imported version's stored default expansion, built under that expansion's own parameters. With the switch on (
core/collections/imports.py):force-system-versiongives another version, or thatcheck-system-versiondoesn't name, or, for a source its references name without a version, one thatsystem-version(elsecheck-system-version) gives another version. Which sources those are comes from the references themselves, since older expansions recorded every version as named;ExpansionEvaluation.has_own, false by default; FHIR's request-time workspace answers it for the resources a request carries);Expansion.build_at_request_time, which can now start from another expansion's locks). The importing expansion's version parameters come first, ahead of the import's own, so for a source both name, the importer's counts. Entries resolve as they would in the importer's namespace: one that another owner's URL registry would read as another repository is passed by that repository's OCL path, and one that names no repository there doesn't reach the import. The import's own locks hold for what the parameters don't name. Inside a request-time evaluation that expansion lives as long as the evaluation. Otherwise (an API build with the toggle on) it is built in a nested request-time evaluation with no deadline of its own (at_request_time()now takes no seconds), and rolled back once its members are read.default-valueset-versionmisses now record theirparameter, asreference.systementries do). The entry is marked with the value set it came through (via), the route (via_path) and the value set versions on it (via_versions). A reader sees what it says only when they can view each of those versions. Otherwise they see only its type and the value set. They never see the version ids.A value set that leads back to itself is refused
reference.valuesetwith reasonvalueset_loop, and expansion health counts it asvalue_set_loop, apart fromunresolved_references. A value set reached by two routes is not a loop. Versions are what's identified, so a collection importing an earlier release of itself loops only if that release leads back.Collection.add_references): "The reference is not saved in collection …: value set … leads back to this collection version, directly or through others". This sits behind the switch too, read through the toggle; FHIR ValueSet writes use the same path, so they follow the toggle as well. A reference that reaches an existing loop elsewhere is saved, and adds nothing when evaluated. The add-references response gives it reasonvalueset_loop.With the switch off
Nothing above runs: no import is evaluated again, nothing new is recorded, no reference is refused. Builds ask the switch only for a reference that names a value set. Every behaviour has a test with the switch on and off, and the toggle's path for API requests is tested both ways.
Production (read-only, Nov 29)
system-versiontogether with a value set reference, and none setsforce-orcheck-system-version, so with the toggle on, imports would be evaluated again only where they read other value sets or used two versions of one source.With versions kept apart (#1090)
This PR is built on #1090 and reads imports the way it does:
ImportedValueSetreads memberships through one helper that answers for a stored expansion and for such an import.ValueSetImports.inner), not their stored expansions.VersionRules.rule_forandkeys_ofrule them (by repository and canonical URL).Before the toggle goes on for API users
Tests
core/collections/tests/tests_imports.py: reading or evaluating an import under each version parameter, locks, legacy links, routes and their visibility, the evaluation's own content, loops (mutual, self, through an exclusion, two routes, own releases, a chain of imports whose parameters pin a version), the add-time refusal, and the add-references response.core/collections/tests/tests_version_rules.py: adefault-valueset-versionmiss now records itsparameter.--parallel=4plus the ES-tagged run) on c53c67f: pylint 10.00; 4,354 + 803 tests OK; coverage 97%. c3831b4 added adefault_expansionhook for the FHIR workspace and 31d87ad reverts it, so the head's tree is c53c67f's.Review
Three Codex defect passes (9, 7 and 7 findings; every P0 and P1 fixed), a simplification review (4 of 7 cuts applied) and checks of the later commits. The integration with #1090 had its own checks (each P1 fixed, with a test that fails without the fix). Accepted with reasons, all P2: a lock-toggle-off edge for unreleased locks, concurrent adds forming a loop across two collections (evaluation still refuses it), and a diagnostic key after URL registries are switched on between builds (a full rebuild clears it).
Follow-up: #1090's new head merged in (eb764d7), which brings #1086's review answers here for the first time. A stored expansion's import evaluated again opens its rolled-back evaluation with #1086's
for_caller=False, so the import is evaluated as its references' creators view it, as the stored build is, not as an anonymous caller (a test fails without it). A request-time build from another expansion's locks keeps them as they are and recorded, so a lock on a release the caller can't view still applies, answered as not found (6384831, a test). Not done here: removing those versions from what the build records, which would also drop them from the locks its references are replayed under; FHIR leaves out what its caller isn't shown when it answers. Codex checks: one P1 answered as for #1090, one P2 accepted (legacy collections with two owners), and the last check clean.Follow-up: #1087's new head merged in through #1090 (3f2206f). A failed version check recorded through an import keeps the id of the version that evaluation used, and the ids OCL records for its own checks (that id and
via_versions) are left out of what readers are given in one place (4b78320; a test fails without it). Full suite: 4,384 + 803 tests OK, coverage 97%, pylint 10.00. Codex check of the follow-up: nothing in this PR.Follow-up: #1090's answer to B's visibility review merged in (d85ea10 through c745f4e): one rule for where a member of an imported value set built without FHIR's rules goes when no version it recorded holds it (HEAD when HEAD holds it, else live releases, else drafts or retired releases, else HEAD). At request time, an import's versions the caller can't view are left out. Full suite on e74654d: 4,388 + 803 tests OK, coverage 97%, pylint 10.00. c745f4e adds only #1090's test change, and #1091's import and member-version tests pass with it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qTSj4R6AHvrLWEVgWn