Repository navigation
Final review fixes for #985: FE.2 and match_algorithms off HEAD - #1014
Conversation
… resolve matches a mapping by code only within that URL's source, so an import never updates or retires another source's mapping (FE.2) MappingImporter.get_queryset and the seeding preflight's MappingMatcher now also require the mapping's from_source_url to be the line's from source when the from concept URL doesn't resolve, with or without from_concept_code. The same source's mapping still matches, so re-importing an id-less line that names its from code updates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav
…e sets match_algorithms on the new version only; HEAD keeps its own and its vectors aren't resynced apply_version_metadata_to_head skips match_algorithms, which stays in ISOLATED_METADATA_FIELDS so the line still sets and checks it on the version, as POST .../versions/ leaves HEAD's alone. Nothing else it copies can change HEAD's semantic flag, so the HEAD vector sync that went with it is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav
…tched as mappings are saved: by link to the source it resolves to, else by the stored URL (FE.2 review, pass 1) A mapping saved from a canonical from URL is linked to the source the URL resolves to and stores that source's own URL, so a text match on the line's URL missed it: a re-import failed uniqueness and a DELETE found nothing. A linked mapping now matches when it's linked to the source the line's URL resolves to, and an unlinked one when its stored from source URL is the line's, in MappingImporter and MappingMatcher alike. That also stops a stale stored URL from matching a mapping linked to another source. Each update variant in the cross-source test now starts from S1's mapping alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav
Codex review, pass 1 (codex-cli 0.169.0, commit 320d944)Verdict: findings (1 P1, 3 P2).
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "320d944f",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "core/importers/models.py",
"line": 929,
"claim": "Re-importing an id-less mapping through a registered canonical URL can fail uniqueness even when the source is the same.",
"scenario": "Import S1/X through S1's registered canonical URL while X is absent. The save resolves S1 and stores its relative OCL URI. Resending the same line with from_concept_code set to X compares the canonical URL against the stored relative URI, misses the existing mapping, and attempts a create that fails uniqueness. DELETE reports not found, and MappingMatcher also counts the existing mapping as omitted.",
"action": "Use the same source resolution as mapping persistence in MappingImporter and MappingMatcher. Add a regression test that reimports and deletes a mapping through its registered canonical URL.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P2",
"tag": null,
"file": "core/importers/models.py",
"line": 493,
"claim": "A stored URL can still match a mapping linked to a different source.",
"scenario": "A mapping created before its canonical URL was registered retains that URL after Source.update_mappings links it to S1. If the registry later points the URL to S2, the mapping stays linked to S1. An id-less DELETE for S2/X through that URL still matches the stored string and retires S1's mapping. MappingMatcher also accepts that row.",
"action": "When a mapping has a from_source link, compare it with the source the incoming URL resolves to. Use the stored URL as the fallback for mappings without a source link.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.3",
"severity": "P2",
"tag": null,
"file": "core/importers/tests.py",
"line": 1450,
"claim": "The parallel DELETE test checks the worker result and misses the outcome returned by the parallel import.",
"scenario": "A parallel DELETE for S2/X with only S1/X mapped now returns not_found from its worker. BulkImportParallelRunner.json_result omits that bucket, so the caller sees one processed line with no outcome. The test passes because it reads the worker report directly.",
"action": "Include not_found in the parallel result and assert it through the runner using the worker's actual result.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.4",
"severity": "P2",
"tag": null,
"file": "core/importers/tests.py",
"line": 1462,
"claim": "The cross-source update test skips the required starting state for a line carrying from_concept_code.",
"scenario": "For each incoming source, the no-code line creates that source's mapping before the test sends the explicit-code line. An update path that correctly selects S2's mapping when it exists but falls back to S1 when S2 has no mapping would pass this test.",
"action": "Run the update variants from independent fixtures containing only S1's mapping. Assert that each variant creates S2's mapping and leaves S1's mapping untouched.",
"lines_delta": null,
"confidence": "high"
}
]
}Review by Claude Code, with Codex. |
… criteria helper, inside pylint's local-variable limit for MappingImporter.get_queryset Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav
Reply to Codex pass 1
Tests: |
…mpared by identity when both sides have one, else by the URLs a mapping stores for it (FE.2 review, pass 2) The line's from source URL is resolved versionless, so an explicit HEAD path names its source. A mapping's source is its from source link, else its from concept's source; when the line's URL resolves to a source and the mapping has one, the two must be the same. Otherwise the mapping's stored from source URL must be one the URL is stored as, which includes the resolution URL a version-qualified canonical URL is stored under. A mapping linked to a source since retired is found again by its URL, as before this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav
Codex review, pass 2 (codex-cli 0.169.0, commit 1fdb827)Verdict: findings (3 P2, no P0 or P1). Prior: F1.1, F1.2 and F1.4 resolved; F1.3 unresolved (accepted in the pass 1 reply).
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "1fdb8274",
"verdict": "findings",
"prior": [
{"id": "F1.1", "status": "resolved"},
{"id": "F1.2", "status": "resolved"},
{"id": "F1.3", "status": "unresolved"},
{"id": "F1.4", "status": "resolved"}
],
"findings": [
{
"id": "F2.1",
"severity": "P2",
"tag": null,
"file": "core/importers/models.py",
"line": 971,
"claim": "An explicit HEAD segment makes an id-less import miss a mapping linked to the same source.",
"scenario": "Save S1/X → T/Y using `/orgs/O/sources/S1/concepts/X/` while X is absent. Re-import it using `/orgs/O/sources/S1/HEAD/concepts/X/`. The resolver looks for a source URI ending in `/HEAD/`, but S1's HEAD row stores the versionless URI. The fallback excludes the existing mapping because it has a source link. The update fails uniqueness, DELETE reports not found, and MappingMatcher treats the mapping as omitted.",
"action": "Resolve a relative OCL source path to its versionless HEAD identity in both lookups. Add a regression test that updates and deletes the same mapping through an explicit HEAD path.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.2",
"severity": "P2",
"tag": null,
"file": "core/importers/models.py",
"line": 986,
"claim": "An unregistered, version-qualified canonical URL cannot find the mapping created by the same import line.",
"scenario": "Import an id-less mapping from `https://external.example/CodeSystem/S|2024/concepts/X/`. Persistence removes the `|2024/` suffix and stores `https://external.example/CodeSystem/S` without a source link. Resending the same line compares the saved URL against `https://external.example/CodeSystem/S|2024/`. The update fails uniqueness, DELETE reports not found, and MappingMatcher misses the existing row.",
"action": "Use the same normalized URL that persistence stores for unresolved sources in both lookups. Add a test that re-imports the identical version-qualified line.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.3",
"severity": "P2",
"tag": null,
"file": "core/importers/models.py",
"line": 488,
"claim": "The URL fallback can still match another source's mapping when only the from-concept link was backfilled.",
"scenario": "Save a mapping through an unregistered canonical URL. Register the URL to an existing S1, then add X to S1. `Concept.update_mappings` links the mapping to S1/X while leaving `from_source_id` null. If the registry later points that URL to S2, which has no X, an id-less DELETE through the URL still retires S1's mapping. MappingMatcher accepts the same row.",
"action": "Use the linked concept's parent as the source identity when the source link is absent. Apply the URL fallback only when neither link identifies a source, and test the concept-only backfill case.",
"lines_delta": null,
"confidence": "high"
}
]
}Review by Claude Code, with Codex. |
Reply to Codex pass 2All three are small and local, so they're fixed in 42aa7a4 with one rule, in
Tests: No P0 or P1 is open, so the defect passes stop here. A simplification review and a Codex check of 1fdb827..HEAD follow. |
Simplification review (Claude subagent, commit 42aa7a4)Two proposed cuts, both low confidence. Neither is applied, so no commit follows from this step.
simplify.json{"reviewer":"claude subagent","perspective":"simplify","mode":"full","commit":"42aa7a40","verdict":"findings","prior":[],"findings":[{"id":"S1","severity":null,"tag":"dup-test","file":"core/importers/tests.py","line":224,"claim":"test_mapping_line_without_id_still_matches_its_own_sources_mapping_by_code runs the same update, update-with-code, DELETE sequence on the same fixture as the canonical-URL test (only the from URL differs). The 'finds_its_mapping_through_other_forms' test also covers re-import of S1's own mapping. The plain-URL same-source update/delete is exercised three times over inline and parallel.","action":"Delete this test; the canonical-URL test (F1.1) and the other-forms test keep the same-source match covered, and the plain same-source path is hit by the 'forms' retired/head cases. Alternatively keep it and drop the DELETE leg.","lines_delta":-15,"confidence":"low","severity_note":null,"scenario":null},{"id":"S2","severity":null,"tag":"dup-test","file":"core/importers/tests.py","line":313,"claim":"The two S1 positive cases in test_seeding_preflight_matches_a_code_only_within_the_from_urls_source (line('S1') and line('S1', from_concept_code='X') both kept) repeat MappingMatcher(...).kept assertions already made in the canonical-URL test and the other-forms test; only the S2/S3 'set()' case is unique to this test.","action":"Trim the loop to the S2/S3 negative case alone and let the other tests carry the positive matcher assertions.","lines_delta":-4,"confidence":"low","scenario":null}]}
Next: a Codex check of 1fdb827..42aa7a4, the commit after the last Codex pass. |
…ce matching: its versionless lookup misreads some canonical URLs and its URL fallback matches mappings linked elsewhere This reverts commit 42aa7a4, which answered pass 2's three P2 findings. The final Codex check found it broke more than it fixed: stripping a version segment can resolve a canonical URL to another source, and the fallback for a URL that resolves to no source matched mappings linked to another source. The tree returns to 1fdb827, which pass 2 found free of P0 and P1 defects; F2.1 to F2.3 are accepted as P2 edge cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav
Codex check of commits 1fdb827..42aa7a4 (codex-cli 0.169.0, commit 42aa7a4)Verdict: findings (2 P1, 1 P2), all introduced by 42aa7a4, the answer to pass 2.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "42aa7a40",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "FC.1",
"severity": "P1",
"tag": null,
"file": "core/importers/models.py",
"line": 975,
"claim": "Stripping a slash-delimited version before resolving a canonical URL can change which source the URL names.",
"scenario": "S1 is registered as `https://terms.example.org/sources/S/2024/` and S2 as `https://terms.example.org/sources/S/`. An ID-less DELETE for S1's `X` has no matching concept URI. The new lookup strips `2024/`, resolves S2, and retires S2's mapping if its code, map type, and target match. The previous lookup resolved the full canonical URL to S1.",
"action": "Preserve literal canonical URLs during resolution and restrict slash-version stripping to relative OCL source paths. Test that the two registered URLs select their own mappings.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.2",
"severity": "P1",
"tag": null,
"file": "core/importers/models.py",
"line": 976,
"claim": "An extras-only re-import through an explicit HEAD path clears the mapping's link to its active source.",
"scenario": "A mapping links to S1 through `from_source` and has no linked concept for code `X`. An ID-less update using `/orgs/demo/sources/S1/HEAD/concepts/X/` finds the mapping because the lookup strips `/HEAD/`. The save resolves the original path, finds no source row at that URI, and persists a null `from_source_id`. The mapping then disappears from S1's per-source distribution. The new explicit HEAD test checks the update count and extras but omits the source link.",
"action": "Use the same source-path normalization for matching and saving, and assert that the explicit HEAD re-import preserves `from_source_id`.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.3",
"severity": "P2",
"tag": null,
"file": "core/importers/models.py",
"line": 991,
"claim": "An unresolved source URL can match a mapping whose link identifies a different source.",
"scenario": "An older clone links its mapping to Local but still stores Origin's URL in `from_source_url`. Origin is later deleted, leaving the clone and its Local link intact. An ID-less DELETE naming Origin's code and the clone's matching target now retires the Local mapping because the lookup falls back to the stale URL. The previous lookup excluded rows with a populated `from_source_id` in this case.",
"action": "When the line's source cannot be resolved, verify that the URL belongs to a linked mapping's source, including retired sources. Use stored URL matching alone for mappings with no source or concept link.",
"lines_delta": null,
"confidence": "high"
}
]
}Review by Claude Code, with Codex. |
Reply to the Codex checkReverted in 78eedaa, which undoes 42aa7a4 in full. The PR's tree is now identical to 1fdb827 (
The review loop ends here: no P0 or P1 is open at 78eedaa. |
* OpenConceptLab/ocl_online#655 | Isolated source versions: a seeding import replaces HEAD content, metadata and hierarchy, and versions record seeded_from * OpenConceptLab/ocl_online#655 | Seeding imports refuse a large drop unless allowed, report what they drop, check content targets, link the hierarchy only on commit and take version defaults from HEAD * OpenConceptLab/ocl_online#655 | Source migrations renumbered after 0048_source_verification * OpenConceptLab/ocl_online#655 | Seeding imports check the drop, hierarchy root and line metadata before any content, link concepts with assigned ids and versioned parent URLs, and report archive drops * OpenConceptLab/ocl_online#655 | Seeding preflight matches idless mappings, refuses delete lines and reads archive lines whole; dropped codes leave HEAD's comparisons and concept mappings; archive summaries round-trip * OpenConceptLab/ocl_online#655 | Seeding preflight matches idless mappings as the importer does; dropped ids aren't reused, restores refresh HEAD caches, releases keep their own mappings, and parent version URLs resolve exactly * OpenConceptLab/ocl_online#655 | Seeding needs update_if_exists and matches from codes as the importer does; release concept lists and older concept versions use the release's own mappings; latest-as-HEAD reads HEAD * Final review fixes for #985: FE.2 and match_algorithms off HEAD (#1014) * OpenConceptLab/ocl_online#655 | A mapping line whose from URL doesn't resolve matches a mapping by code only within that URL's source, so an import never updates or retires another source's mapping (FE.2) MappingImporter.get_queryset and the seeding preflight's MappingMatcher now also require the mapping's from_source_url to be the line's from source when the from concept URL doesn't resolve, with or without from_concept_code. The same source's mapping still matches, so re-importing an id-less line that names its from code updates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav * OpenConceptLab/ocl_online#655 | A seeding import's Source Version line sets match_algorithms on the new version only; HEAD keeps its own and its vectors aren't resynced apply_version_metadata_to_head skips match_algorithms, which stays in ISOLATED_METADATA_FIELDS so the line still sets and checks it on the version, as POST .../versions/ leaves HEAD's alone. Nothing else it copies can change HEAD's semantic flag, so the HEAD vector sync that went with it is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav * OpenConceptLab/ocl_online#655 | An unresolved from URL's source is matched as mappings are saved: by link to the source it resolves to, else by the stored URL (FE.2 review, pass 1) A mapping saved from a canonical from URL is linked to the source the URL resolves to and stores that source's own URL, so a text match on the line's URL missed it: a re-import failed uniqueness and a DELETE found nothing. A linked mapping now matches when it's linked to the source the line's URL resolves to, and an unlinked one when its stored from source URL is the line's, in MappingImporter and MappingMatcher alike. That also stops a stale stored URL from matching a mapping linked to another source. Each update variant in the cross-source test now starts from S1's mapping alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav * OpenConceptLab/ocl_online#655 | The from source lookup moves into its criteria helper, inside pylint's local-variable limit for MappingImporter.get_queryset Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav * OpenConceptLab/ocl_online#655 | An unresolved from URL's source is compared by identity when both sides have one, else by the URLs a mapping stores for it (FE.2 review, pass 2) The line's from source URL is resolved versionless, so an explicit HEAD path names its source. A mapping's source is its from source link, else its from concept's source; when the line's URL resolves to a source and the mapping has one, the two must be the same. Otherwise the mapping's stored from source URL must be one the URL is stored as, which includes the resolution URL a version-qualified canonical URL is stored under. A mapping linked to a source since retired is found again by its URL, as before this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav * OpenConceptLab/ocl_online#655 | Revert the pass 2 change to from source matching: its versionless lookup misreads some canonical URLs and its URL fallback matches mappings linked elsewhere This reverts commit 42aa7a4, which answered pass 2's three P2 findings. The final Codex check found it broke more than it fixed: stripping a version segment can resolve a canonical URL to another source, and the fallback for a URL that resolves to no source matched mappings linked to another source. The tree returns to 1fdb827, which pass 2 found free of P0 and P1 defects; F2.1 to F2.3 are accepted as P2 edge cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Jonathan Payne <paynejd@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The two items under "Fix before merge" in the final review of #985, as a PR into
ocl_online#655for @snyaggarwal to merge into #985. Nothing from "Ship and ticket" is touched.1. FE.2: a from URL that doesn't resolve matches by code only within its own source (617e3ea, b9449f1, 1fdb827)
When a mapping line's
from_concept_urldoesn't resolve to a concept,MappingImporter.get_querysetmatched an existing mapping by map type, from code and target, from any source. An ordinary import could then update (and rewire to its own from source) or retire (__action: DELETE) another source's mapping that shares the code.MappingImporter.get_querysetnow also requires the mapping to be from the from URL's source, with or withoutfrom_concept_code. A mapping linked to a from source matches when that's the source the URL's source part resolves to, resolved as a mapping's save resolves it. A mapping with no link matches when its storedfrom_source_urlis that URL (versionless). So a line naming a source by its canonical URL still finds that source's mapping (review pass 1). This also closes the cross-source match that master already had for lines withoutfrom_concept_code.MappingMatcher(the seeding preflight's simulation of the importer) applies the same rule, so the drop count still predicts what the importer does.from_concept_codeupdates the same source's mapping instead of failing uniqueness.2.
match_algorithmsstays off HEAD (320d944)A seeding import's Source Version line that sets
match_algorithmsnow sets it on the new version only. HEAD keeps its own, as it does after POST.../versions/.Source.apply_version_metadata_to_headskipsmatch_algorithms. It stays inISOLATED_METADATA_FIELDS, so the line still sets it on the version and it is still validated.Tests
BulkImportInlineTest, each run inline and through one parallel part (bulk_import_parts_inline, as a worker runs it), against a mapping source holding S1/X -> T/Y, with S2 existing without X and S3 not existing:test_mapping_line_without_id_never_updates_another_sources_mapping_by_code: lines from S2/X and S3/X, with and withoutfrom_concept_code, each starting from S1's mapping alone, create their own mapping, and the S1 mapping is unchanged.test_mapping_delete_line_without_id_never_retires_another_sources_mapping_by_code: the same lines with__action: DELETEreport not found, and the S1 mapping stays active.test_mapping_line_without_id_still_matches_its_own_sources_mapping_by_code: S1/X lines with and without the code update the S1 mapping, and a DELETE retires it.test_seeding_preflight_matches_a_code_only_within_the_from_urls_source:MappingMatcherkeeps the S1 mapping for S1 lines and nothing for S2 and S3 lines.test_mapping_line_without_id_through_a_canonical_url_matches_the_source_it_resolves_to: lines naming S1 by its registered canonical URL update and retire S1's mapping, and the matcher keeps it.test_mapping_delete_line_without_id_never_retires_a_mapping_linked_to_another_source: a mapping linked to S1 that still stores a URL now registered to S2 isn't retired by an S2 line.test_seeding_line_match_algorithms_reach_headis nowtest_seeding_line_match_algorithms_stay_off_head: in both directions (lexical HEAD with a semantic line, and the reverse), HEAD'smatch_algorithmsis unchanged, the version has the line's value, and HEAD's vector sync isn't started.test_semantic_change_on_head_syncs_its_vectorsis removed, since that sync no longer exists.core.importers,core.sources,core.integration_tests.tests_sourcesandtests_mappings, run as CI runs them: 825 tests without Elasticsearch (--parallel=4) and 39 taggedes, all passing on the final tree. Pylintcore/is clean.The Codex review is in the comments: two defect passes, a simplification review and a final check. 42aa7a4 (an answer to pass 2's P2s) was reverted in 78eedaa after the final check, so the final tree is 1fdb827's. Accepted and not fixed: F1.3 (the parallel runner's combined result has no
not_foundbucket, as on master) and F2.1 to F2.3 (P2 edge cases in how unusual from URL spellings are saved).🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qWhAoApU55xQW8puav