Skip to content

Final review fixes for #985: FE.2 and match_algorithms off HEAD - #1014

Merged
snyaggarwal merged 6 commits into
ocl_online#655from
ocl_online-655-final-fixes
Nov 20, 2026
Merged

snyaggarwal merged 6 commits into
ocl_online#655from
ocl_online-655-final-fixes

Conversation

@paynejd

@paynejd paynejd commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

The two items under "Fix before merge" in the final review of #985, as a PR into ocl_online#655 for @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_url doesn't resolve to a concept, MappingImporter.get_queryset matched 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_queryset now also requires the mapping to be from the from URL's source, with or without from_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 stored from_source_url is 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 without from_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.
  • Kept from f027af0: re-importing an id-less line that carries from_concept_code updates the same source's mapping instead of failing uniqueness.
  • A from URL that resolves still matches by concept, as before.

2. match_algorithms stays off HEAD (320d944)

A seeding import's Source Version line that sets match_algorithms now sets it on the new version only. HEAD keeps its own, as it does after POST .../versions/.

  • Source.apply_version_metadata_to_head skips match_algorithms. It stays in ISOLATED_METADATA_FIELDS, so the line still sets it on the version and it is still validated.
  • The HEAD vector-sync branch there is removed: nothing else that function copies to HEAD can change HEAD's semantic flag.

Tests

  • New in 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 without from_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: DELETE report 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: MappingMatcher keeps 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_head is now test_seeding_line_match_algorithms_stay_off_head: in both directions (lexical HEAD with a semantic line, and the reverse), HEAD's match_algorithms is unchanged, the version has the line's value, and HEAD's vector sync isn't started. test_semantic_change_on_head_syncs_its_vectors is removed, since that sync no longer exists.
  • With the base model files mounted (A/B on 9c75a44), every new and changed test fails except two regression guards that pass on both: the same-source test and the canonical-URL test. The canonical-URL test fails on 320d944, the first version of this fix.
  • core.importers, core.sources, core.integration_tests.tests_sources and tests_mappings, run as CI runs them: 825 tests without Elasticsearch (--parallel=4) and 39 tagged es, all passing on the final tree. Pylint core/ 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_found bucket, 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

paynejd and others added 3 commits November 19, 2026 14:14
… 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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit 320d944)

Verdict: findings (1 P1, 3 P2).

  • F1.1 [P1] core/importers/models.py:929: a mapping saved from a from URL that is a source's registered canonical URL is linked to that source and stores the source's own URL. Matching on the line's URL text then misses it: re-importing the same id-less line fails uniqueness, a DELETE reports not found, and the seeding preflight counts the mapping as dropped.
  • F1.2 [P2] core/importers/models.py:493: a mapping linked to S1 that still carries a URL later registered to S2 matches an S2 line on that stored URL, so an id-less DELETE for S2/X through that URL can retire S1's mapping.
  • F1.3 [P2] core/importers/tests.py:1450: the parallel DELETE test reads the worker part's report; the parallel runner's combined result has no not_found bucket.
  • F1.4 [P2] core/importers/tests.py:1462: in the cross-source update test, the line naming from_concept_code runs after the no-code line has already created S2's mapping, so it never starts from S1's mapping alone.
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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Reply to Codex pass 1

  • F1.1 [P1]: fixed in b9449f1 (1fdb827 only moves the lookup for pylint). When the from URL doesn't resolve to a concept, a mapping now matches as it was saved: one linked to a from source matches if that's the source the line's from source URL resolves to (resolved as Mapping.populate_fields_from_relations resolves it), and one with no link matches if its stored from_source_url is the line's. Same rule in MappingImporter.get_same_from_source_criteria and MappingMatcher.is_same_from_source. Test: test_mapping_line_without_id_through_a_canonical_url_matches_the_source_it_resolves_to, which fails on 320d944 (uniqueness failure and not found).
  • F1.2 [P2]: fixed by the same rule. Test: test_mapping_delete_line_without_id_never_retires_a_mapping_linked_to_another_source, which fails on 320d944.
  • F1.3 [P2]: accepted. The parallel runner's combined result has no not_found bucket on master as well. That's a reporting gap, separate from which mapping a line matches, and outside this PR. The worker part's result, which the test reads, is what decides the update or delete.
  • F1.4 [P2]: fixed in b9449f1. Each update variant now starts from a fresh fixture holding only S1's mapping, and must create its own.

Tests: core.importers, core.sources, core.integration_tests.tests_sources and tests_mappings pass on b9449f1 (825 without Elasticsearch, 39 tagged es), and pylint core/ is clean on 1fdb827.

…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

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

  • F2.1 [P2] core/importers/models.py:971: a from URL with an explicit /HEAD/ segment resolves to no source, and the URL fallback skips linked mappings, so re-importing S1/X that way fails uniqueness and a DELETE reports not found.
  • F2.2 [P2] core/importers/models.py:986: a version-qualified URL that resolves to no source (…/S|2024/concepts/X/) is stored without its |2024, so the same line re-imported doesn't find the mapping it created.
  • F2.3 [P2] core/importers/models.py:488: a mapping linked only by its from concept (its from source link left empty) is compared by stored URL, so after that URL is registered to another source, a line through it can still match it.
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.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Reply to Codex pass 2

All three are small and local, so they're fixed in 42aa7a4 with one rule, in MappingImporter.get_same_from_source_criteria and MappingMatcher.is_same_from_source alike. When a line's from URL doesn't resolve to a concept, its from source URL is resolved versionless. A mapping's source is its from source link, else its from concept's source. When both sides have a source, they must be the same; otherwise the mapping's stored from source URL must be one of the forms the line's URL is stored as.

  • F2.1 [P2]: fixed. The versionless lookup resolves …/S1/HEAD/ to S1.
  • F2.2 [P2]: fixed. The stored forms include the resolution URL, which drops |2024.
  • F2.3 [P2]: fixed. A mapping linked only by its from concept is compared by that concept's source.
  • The same rule also covers a mapping whose linked source has since been retired: the URL resolves to no source, so the mapping is found by its stored URL, as before this PR. Without that, its re-import failed uniqueness.

Tests: test_mapping_line_without_id_finds_its_mapping_through_other_forms_of_its_source_url (HEAD path, version-qualified URL, retired source), plus a from-concept-only link variant in test_mapping_delete_line_without_id_never_retires_a_mapping_linked_to_another_source. Each runs inline and through a parallel part, and each subtest fails on 1fdb827. The touched modules pass on 42aa7a4 (826 without Elasticsearch, 39 tagged es), and pylint core/ is clean.

No P0 or P1 is open, so the defect passes stop here. A simplification review and a Codex check of 1fdb827..HEAD follow.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Simplification review (Claude subagent, commit 42aa7a4)

Two proposed cuts, both low confidence. Neither is applied, so no commit follows from this step.

  • S1 (dup-test): delete test_mapping_line_without_id_still_matches_its_own_sources_mapping_by_code. Declined: it's the same-source check the fix requires, and the only one on the main path, a plain relative URL whose source resolves and is linked. The canonical-URL and other-forms tests reach the match by different routes.
  • S2 (dup-test): keep only the S2/S3 case in test_seeding_preflight_matches_a_code_only_within_the_from_urls_source. Declined: its two S1 cases are the only matcher checks on that same plain-URL path, with and without the from code.
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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

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.

  • FC.1 [P1] core/importers/models.py:975: stripping a slash-delimited version before resolving can change which source a canonical URL names (a URL registered as …/sources/S/2024/ resolves as …/sources/S/).
  • FC.2 [P1] core/importers/models.py:976: a re-import through an explicit /HEAD/ path now matches the linked mapping, but the save doesn't resolve that path and clears the mapping's from source link.
  • FC.3 [P2] core/importers/models.py:991: when the line's source URL resolves to nothing, the fallback to the stored URL matches a mapping linked to another source that still carries a stale URL.
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.

@paynejd

paynejd commented Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Reply to the Codex check

Reverted in 78eedaa, which undoes 42aa7a4 in full. The PR's tree is now identical to 1fdb827 (git diff 1fdb8274 78eedaa8 is empty), which pass 2 found free of P0 and P1 defects. On that tree, core.importers, core.sources, core.integration_tests.tests_sources and tests_mappings pass (825 without Elasticsearch, 39 tagged es), and pylint core/ is clean.

  • FC.1, FC.2, FC.3: resolved by the revert. Each came from 42aa7a4's versionless lookup or its fallback for a URL that resolves to no source.
  • Pass 2's F2.1 to F2.3 [P2]: accepted, not fixed. Matching these exactly means changing how a mapping's from source is resolved on save, which is outside FE.2.
    • F2.1 (an explicit /HEAD/ path) and F2.2 (a version-qualified URL that resolves to no source): the line fails visibly, with a uniqueness error on update or not found on DELETE, instead of updating its own mapping. Nothing else changes.
    • F2.3: a line can still match a mapping linked to S1 only through its from concept, when the URL that mapping stored was later registered to S2. That takes a concept-only backfill followed by a registry repoint. Before this PR, any source's mapping matched by code here.
  • Also accepted: a re-import of a mapping whose linked from source has since been retired fails uniqueness instead of updating it. Before this PR it matched by code alone. It fails visibly and changes nothing.

The review loop ends here: no P0 or P1 is open at 78eedaa.

@snyaggarwal
snyaggarwal merged commit a59f88f into ocl_online#655 Nov 20, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-655-final-fixes branch November 20, 2026 02:17
snyaggarwal added a commit that referenced this pull request Nov 20, 2026
* 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>
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