Repository navigation
OpenConceptLab/ocl_online#703 | A release's search matches its own mapped codes - #1010
Conversation
Codex review, pass 1 (codex-cli 0.169.0, commit bc1a10f)Verdict: findings: 3 P1, 3 P2.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "bc1a10f5c07b3219256e92031d47f4beb0c501e7",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "core/concepts/management/commands/concept_release_map_codes.py",
"line": 72,
"claim": "The backfill skips existing documents whose top-level mapped codes need correction.",
"scenario": "A concept mapped to X in v1 was dropped from HEAD before deployment. Its existing document has empty HEAD codes. The new builder puts X in the top-level fields and emits no release entry because v1 is the only release holding the row. The backfill skips the document, so searching v1 for X still misses the concept.",
"action": "Backfill documents whose top-level mapped-code fields need correction even when the release entries are empty. Add an upgrade test that starts with the old document fields.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P1",
"tag": null,
"file": "core/concepts/management/commands/concept_release_map_codes.py",
"line": 49,
"claim": "The backfill writes to the default concepts index when the operator selects a different index.",
"scenario": "Running the command with `--index concepts-next --source <url>` installs the mapping on `concepts-next`, but the update actions still write to `concepts`. The selected index remains unfilled. If the live index lacks the field, those writes can dynamically map it as an object and prevent the required nested mapping from being installed in place.",
"action": "Use the selected index for every backfill write and missing-document fallback, or reject `--index` with `--source` until that combination is supported.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.3",
"severity": "P1",
"tag": null,
"file": "core/concepts/search.py",
"line": 325,
"claim": "Release-scoped `$match` leaves mapped-code filters unscoped in vector and filter-only requests.",
"scenario": "A semantic match against v1 filters on `target_repo`. An unchanged concept whose mapping to that target was added in HEAD can still be returned by kNN because the rewrite applies only to the lexical query. Elasticsearch combines those result sets with OR. A filter-only row also bypasses the rewrite because it has no `wrapped_clauses`. [Elasticsearch kNN search](https://www.elastic.co/guide/en/elasticsearch/reference/8.15/knn-search.html)",
"action": "Apply release-aware mapping filters to every `$match` retrieval path. Add coverage for a semantic match and a filter-only row against a release that lacks the HEAD mapping.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.4",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 912,
"claim": "Fuzzy concept search ignores release overrides when the release is selected through `source_version`.",
"scenario": "A request to `/concepts/` uses `fuzzy=true`, a name query, a `source_version` URL for v1, and a `target_repo` filter. The name matches an unchanged concept whose mapping to that target was added in HEAD. The version filter selects v1, but `map_codes_release` returns `None` because the route has no `source` parameter, so the concept incorrectly passes the mapped-code filter.",
"action": "Scope the mapped-code filter using each resolved source version in the fuzzy query. Keep the source, owner, and version criteria together with that version's mapping clause.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.5",
"severity": "P2",
"tag": null,
"file": "core/concepts/search.py",
"line": 50,
"claim": "Truncating the two facet branches before merging can omit the most frequent target repo.",
"scenario": "A target repo has five mappings in each branch. Each branch also has 100 different target repos with six mappings apiece. Both branch aggregations discard the shared target, so the response omits the target with the highest combined count of ten and can return 200 buckets despite the existing 100-bucket cap.",
"action": "Combine bucket counts before ranking and applying `FACET_SIZE`. Add a test where a bucket outside both branch cutoffs ranks first overall.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.6",
"severity": "P2",
"tag": null,
"file": "core/concepts/documents.py",
"line": 105,
"claim": "Duplicating mapping snapshots per release can make previously valid concept documents fail to index.",
"scenario": "An unchanged concept has 100 mappings with target source URLs across 100 releases. HEAD changes one mapping. The builder copies the same 100 historical mapping objects into each release entry, creating over 10,000 nested objects in one document. Elasticsearch rejects the write at its default limit, leaving the concept unindexed or stale. [Elasticsearch mapping limits](https://www.elastic.co/guide/en/elasticsearch/reference/8.15/mapping-settings-limit.html)",
"action": "Share identical mapping snapshots across release IDs and handle histories with many distinct snapshots within the index limit. Test that a concept with a large release history remains searchable.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Pass 1 responses (fixed in 4aa28e5)
|
Codex review, pass 2 (codex-cli 0.169.0, commit 4aa28e5)Verdict: findings: 3 P1, 3 P2. Pass 1: F1.1 resolved, F1.2 resolved, F1.3 resolved, F1.4 unresolved, F1.5 unresolved, F1.6 unresolved.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "4aa28e52f9a1a8411e458a0fe40cf32b975a854e",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "resolved"
},
{
"id": "F1.2",
"status": "resolved"
},
{
"id": "F1.3",
"status": "resolved"
},
{
"id": "F1.4",
"status": "unresolved"
},
{
"id": "F1.5",
"status": "unresolved"
},
{
"id": "F1.6",
"status": "unresolved"
}
],
"findings": [
{
"id": "F2.1",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 589,
"claim": "Global fuzzy search can reveal mappings from a private source version.",
"scenario": "A public source has a private v1. A concept shared by v1 and HEAD is public, and only v1 maps it to a particular target repository. An anonymous fuzzy search can select v1 through `source_version` and match the concept with a `target_repo` filter. Version resolution checks existence, and the Elasticsearch visibility filter checks the public concept document. The direct v1 endpoint would deny access.",
"action": "Check view access to each resolved source version before using it in search or facets. Add a regression test with a private version of a public source.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.2",
"severity": "P1",
"tag": null,
"file": "core/concepts/documents.py",
"line": 100,
"claim": "Unversioned global search starts matching dropped concepts by their historical mapped codes.",
"scenario": "In the existing fixture, v3 drops B and its mapping to X03, and B's v2 row keeps `is_latest_version=True`. The new builder puts X03 in that row's top-level fields. Global `/concepts/?q=X03` filters on `is_latest_version` without requiring HEAD membership, so it now returns B. The base branch indexed that row with HEAD's empty mapped-code fields.",
"action": "Keep HEAD mapped-code behavior for documents eligible for unversioned global search. Store the older release's codes in its override and extend the dropped-concept test to cover global search.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.3",
"severity": "P1",
"tag": null,
"file": "core/concepts/search.py",
"line": 409,
"claim": "Lexical `$match` with `bestMatch=true` discards matches found only through a release override.",
"scenario": "A v1 `$match` request with `bestMatch=true` and `limit=10` searches for `other_map_codes=X05`. The concept matches only the nested release field. The request highlights the top-level fields, so the hit has no highlight. The view classifies it as `low` and drops it from the response. The new test ends at the Elasticsearch hit and misses this response filtering. [Elasticsearch nested highlighting](https://www.elastic.co/guide/en/elasticsearch/reference/8.15/nested.html#nested-fields-interaction)",
"action": "Use the matched release clause or its nested highlight to classify release mapped-code hits. Test the `$match` response with `bestMatch=true`.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.4",
"severity": "P2",
"tag": null,
"file": "core/concepts/documents.py",
"line": 106,
"claim": "Recreating a source version can reuse the deleted version's mapped-code override.",
"scenario": "A shared concept's document has a v1 override for X after HEAD drops X. An editor deletes v1 and recreates it from HEAD without changing the concept. The release indexing job only appends the version label and updates the latest-release flag on existing documents. The old override still matches the reused label, so searching the new v1 for X returns the concept.",
"action": "Key overrides by an immutable source-version ID or refresh them when an existing document gains release membership. Test deletion and recreation through the release indexing path.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.5",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 622,
"claim": "Facets for a fuzzy search in one source version count historical mappings from other sources.",
"scenario": "A fuzzy search selects source A's v1 through `source_version`. The hits query uses that resolved source, but the facet query builds a regular search without the source-version constraint and applies the bare `v1` override. A matching concept in source B can contribute a target repository present only in B's v1, even though B is outside the requested results.",
"action": "Build facets from the same authorized source-version scope as the hits. Test with two sources that share a version label.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.6",
"severity": "P2",
"tag": null,
"file": "core/integration_tests/tests_release_map_codes.py",
"line": 176,
"claim": "The vector regression test never checks whether Elasticsearch returns the right candidates.",
"scenario": "If the v1 kNN filter accidentally selects v2's override, the serialized filter still contains `release_map_codes` and the test passes. The filter-only integration test issues no kNN query, so it cannot catch a vector candidate admitted by the wrong version's mapping.",
"action": "Execute a semantic search on the CI Elasticsearch version with candidates reachable only through kNN. Assert that v1 admits a candidate with its mapping and excludes a candidate whose mapping was added in HEAD.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Pass 2 responses (fixed in 9dbc134)
|
Measurements: index size and reindex time (OpenConceptLab/ocl_online#703 acceptance criterion 3)LOINC on production (read-only queries):
Local benchmark (a throwaway test,
Extrapolated to LOINC
|
Codex review, pass 3 (codex-cli 0.169.0, commit 9dbc134)Verdict: findings: 4 P1, 1 P2. Earlier: F1.1 resolved, F1.2 resolved, F1.3 resolved, F1.4 unresolved, F1.5 unresolved, F1.6 unresolved, F2.1 resolved, F2.2 resolved, F2.3 resolved, F2.4 regressed, F2.5 resolved, F2.6 unresolved.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "9dbc13496d46f6500410cf78f340acc493faaf71",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "resolved"
},
{
"id": "F1.2",
"status": "resolved"
},
{
"id": "F1.3",
"status": "resolved"
},
{
"id": "F1.4",
"status": "unresolved"
},
{
"id": "F1.5",
"status": "unresolved"
},
{
"id": "F1.6",
"status": "unresolved"
},
{
"id": "F2.1",
"status": "resolved"
},
{
"id": "F2.2",
"status": "resolved"
},
{
"id": "F2.3",
"status": "resolved"
},
{
"id": "F2.4",
"status": "regressed"
},
{
"id": "F2.5",
"status": "resolved"
},
{
"id": "F2.6",
"status": "unresolved"
}
],
"findings": [
{
"id": "F3.1",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 586,
"claim": "The latest-release concept search can expose mappings from a private release.",
"scenario": "A public HEAD shares a public concept with its newest release, which is private and has a mapping absent from HEAD. The list view looks up the literal version label `latest`, finds no parent, and skips the permission check. The search then resolves `latest` to the private release and uses its mapping to match the concept or count its target repository in facets.",
"action": "Resolve `latest` before checking permissions and use the same authorized source version for hits and facets. Add an anonymous search and facet test for a private release of a public source.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F3.2",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 912,
"claim": "A source-scoped fuzzy search can apply release mapping filters to a different source's concepts.",
"scenario": "Sources A and B both have a v1. A's v1 is public and B's v1 is private. A fuzzy search under A's v1 can select B's v1 through `source_version`. The query checks access to A but selects B's public concept documents and applies the bare `v1` mapping override, exposing mappings that exist only in B's private release.",
"action": "Bind the fuzzy hits query and its mapping rewrite to the exact authorized source version. Add a regression test with two sources that share a release label.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F3.3",
"severity": "P1",
"tag": null,
"file": "core/common/es.py",
"line": 17,
"claim": "Replaying a release indexing job removes valid mapping overrides.",
"scenario": "Release v1 maps an unchanged concept to X. HEAD later drops X, and the mapped-code update correctly saves a v1 override. If the original release indexing job is delayed or rerun, the append script deletes that override even though v1 is already present on the document. A v1 search then falls back to HEAD and misses X until another reindex.",
"action": "Identify overrides by immutable source-version ID or recompute the release's mapping fields during the append. Test that replaying the append after a HEAD-only mapping change preserves the release's search results.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F3.4",
"severity": "P1",
"tag": null,
"file": "core/concepts/documents.py",
"line": 98,
"claim": "Collection search loses mapped-code matches for concept rows shared by older source releases.",
"scenario": "A collection expansion holds a concept row shared by source releases v1 and v2. Only v1 maps the concept to X, and the concept was edited in v3. The base indexes X on the shared older row, so the collection finds it. After reindexing this change, X exists only in the v1 override and collection search reads the top-level v2 fields, so the same search misses it.",
"action": "Preserve existing mapped-code search behavior for collection members while applying exact mapping snapshots to source-release searches. Add a collection search regression test using a pinned historical concept row.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F3.5",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1072,
"claim": "Ordinary release search loses requested highlights when mapped-code matches move into an override.",
"scenario": "An older concept row was shared by v1 and v2, and only v1 mapped it to X. On the base, a v1 search for X with `includeSearchMeta=true` can highlight the mapped code in the top-level field. The new search still finds the concept through its v1 override, but the list query requests only top-level highlights, so the response loses the mapped-code highlight.",
"action": "When release list search requests highlights, collect nested mapped-code highlights and return them under the same response keys. Add an API test for a release-only mapped-code highlight.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Pass 3 responses (fixed in dbf017e)
That was the last Codex defects pass. Next come a simplification review, then a Codex check of the commits after 9dbc134. |
Simplification review (fresh Claude subagent, commit dbf017e), applied in 48648ce
|
Codex check of commits 9dbc134..48648ce (codex-cli 0.169.0)Verdict: findings: 2 P1, 1 P2.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "48648cea774a28c8d8faf412d0192d6ed6264295",
"verdict": "findings",
"prior": [
{
"id": "F3.1",
"status": "resolved"
},
{
"id": "F3.2",
"status": "regressed"
},
{
"id": "F3.3",
"status": "resolved"
},
{
"id": "F3.4",
"status": "regressed"
}
],
"findings": [
{
"id": "FC.1",
"severity": "P1",
"tag": null,
"file": "core/concepts/documents.py",
"line": 96,
"claim": "Public collection search can reveal mappings from a private source release.",
"scenario": "A public collection pins a concept row from public v2. Private v1 shares that row and is the only release that maps it to code X. HEAD has since edited the concept. At 9dbc1349, collection search read v2's top-level codes and did not match X. The new union puts X in the top-level fields, so an anonymous search for X returns the concept even though the caller cannot view v1.",
"action": "Keep private-release codes out of fields searched by all collection readers. Use those codes only after checking access to the release, and add an anonymous collection search test for a row shared by public and private releases.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.2",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 919,
"claim": "Fuzzy search ignores release mappings even when the request explicitly selects one public release.",
"scenario": "A concept matches the fuzzy text query and maps to a target repository in public v1. HEAD drops the mapping without editing the concept. A request to the v1 concept list with `fuzzy=true`, `source_version` pointing to that same v1, and a `target_repo` filter returned the concept at 9dbc1349. The current query still selects v1 but applies the mapping filter to HEAD's fields, so the concept disappears.",
"action": "Apply the mapped-code rewrite using the authorized source versions that actually constrain the fuzzy query. Test an explicitly selected public release and retain coverage for requests whose URL and selected source differ.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.3",
"severity": "P2",
"tag": null,
"file": "core/concepts/search.py",
"line": 205,
"claim": "$match drops release mapping filters when `target_repo` resolves to both an organization source and a user source.",
"scenario": "An organization and a user share a name and both publish public releases with the same source mnemonic and version. A structured `target_repo` with no `owner_type` is accepted and searches both releases. At 9dbc1349, the rewrite matched each release's own mappings. The new lookup finds two IDs and skips the rewrite, so a concept whose mapping exists in its release but was dropped from HEAD no longer matches.",
"action": "Pass the authorized release IDs from target resolution into the search and apply each ID within its repository's query. Add a test with both owner types.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Responses to the check of 9dbc134..48648ce (fixed in 27d7b26)
One more Codex check of the commits after 48648ce follows. |
Codex check of commit 27d7b26 (codex-cli 0.169.0)Verdict: findings: 2 P1, 1 P2.
Responses (fixed in 5cb2495)
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "27d7b2632dfca3066507b7592627c61bcec7cf44",
"verdict": "findings",
"prior": [
{
"id": "FC.1",
"status": "unresolved"
},
{
"id": "FC.2",
"status": "resolved"
},
{
"id": "FC.3",
"status": "unresolved"
},
{
"id": "F3.2",
"status": "resolved"
}
],
"findings": [
{
"id": "FC.4",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 931,
"claim": "Fuzzy search results and mapped-code facets use different release scopes.",
"scenario": "With IncludeFacets enabled, the new fuzzy search test's v1 request returns concept A using its v1 mappings. The targetRepoMapType facet omits NARROWER-THAN, which is present on A in v1, because get_facets still searches HEAD for that request.",
"action": "Apply the fuzzy search's resolved release to both the facet query and the mapped-code aggregations. Extend the integration test to assert the v1 map-type bucket.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.5",
"severity": "P1",
"tag": null,
"file": "core/concepts/documents.py",
"line": 100,
"claim": "Changing a release's visibility leaves its shared documents' mapped-code fields stale.",
"scenario": "A public collection contains a historical concept row shared by two releases. The row is indexed while the only release with a particular mapping is private. Making that release public leaves collection search unable to find the concept by that code. The source update does not rebuild mapped-code fields for release members. In the reverse direction, a newly private release's code remains searchable.",
"action": "Rebuild the mapped-code fields of the release's member documents when its visibility changes. Cover both transitions through the source-version update API.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.6",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 605,
"claim": "A collection version can authorize a mapped-code lookup against an unrelated source release ID.",
"scenario": "The reference resolver can return a public collection version for source_version. If a source has the same owner, mnemonic, and version label, its concept rows pass the fuzzy filter. When a shared row also has an entry for a private source release whose numeric ID matches the collection version's ID, the filter evaluates the private release's mappings after checking access only to the collection.",
"action": "Require the resolved object to be a Source before using its ID for the rewrite. Add a regression test with overlapping collection and source version IDs.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Codex check of commit 5cb2495 (codex-cli 0.169.0)Verdict: findings: 4 P2, no P1.
Responses (0793a72)
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "5cb2495a209da9953703d5ed29d0be7f031a006e",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "FC.7",
"severity": "P2",
"tag": null,
"file": "core/sources/models.py",
"line": 761,
"claim": "The mapped-code refresh can run before the release access change commits.",
"scenario": "A caller makes v1 private inside a transaction. An indexing worker runs the queued task before commit, reads v1 as public, and finishes without removing v1's codes. No refresh runs after commit, so public collection searches can still match those codes.",
"action": "Publish the refresh through transaction.on_commit. Test that it is queued only after the access change commits.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.8",
"severity": "P2",
"tag": null,
"file": "core/sources/models.py",
"line": 761,
"claim": "Overlapping access refreshes can overwrite current mapped codes with a stale result.",
"scenario": "An owner briefly makes v1 public and then makes it private again. One worker computes mapped codes while v1 is public. A second worker writes the corrected fields after v1 goes private. If the first worker writes last, public collection searches can match v1-only codes even after both tasks succeed.",
"action": "Serialize mapped-code refreshes for overlapping concept rows from database read through Elasticsearch write, or reject writes computed from an older revision.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.9",
"severity": "P2",
"tag": null,
"file": "core/sources/models.py",
"line": 761,
"claim": "Retrying an access update cannot recover chunks that failed to queue.",
"scenario": "An owner makes a release private. The database save commits and the broker accepts the first chunk, but publishing the second chunk fails after retries. The request errors. Repeating it sees that the release is already private and queues nothing, leaving the second chunk's old codes searchable.",
"action": "Persist the refresh work with the access change and make unpublished or failed chunks retryable independently of the access update.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.10",
"severity": "P2",
"tag": null,
"file": "core/integration_tests/tests_release_map_codes.py",
"line": 369,
"claim": "The remaining fuzzy-search test would pass if the removed rewrite were restored.",
"scenario": "The test selects v1 in the URL path and omits the source_version query parameter. The removed rewrite activated only with one resolved source_version. Restoring it would leave this test green while an explicit source_version=v1 fuzzy request would again match A through v1's mapped codes.",
"action": "Add the explicit source_version request to the test and assert that the target-repository filter returns only B.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Codex check of commit 0793a72 (codex-cli 0.169.0)Verdict: clean, no findings. findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "0793a72b8d7cc81234c1af00ed119ec17999cbcd",
"verdict": "clean",
"prior": [],
"findings": []
} |
snyaggarwal
left a comment
There was a problem hiding this comment.
I found two mapped-code gaps on this head. The direct $match SAME-AS input misses the indexed field, and collection-only rows can gain codes from mappings that HEAD dropped.
Merge blocker: GitHub reports conflicts with master. I reproduced them against 44010f59 in the concept document/model, importer model/tests, and source model. Now that #985 is on master, replaying the release-search commits on top of it would make it easier to preserve the final seeding changes and verify the intended diff.
I ran focused checks against the query-rewrite and mapping-selection code. Django and Elasticsearch integration tests were unavailable from this session.
|
|
||
| wrapped_clauses = [ | ||
| Q("bool", must=[Q(filter_query), clause]) | ||
| Q("bool", must=[Q(filter_query), scoped(clause, highlight=True)]) |
There was a problem hiding this comment.
[P2] Route direct SAME-AS inputs through the release lookup. Both priority lists build the $match clause against same_as_mapped_codes, while the index and release rewriter use same_as_map_codes. The rewriter leaves the existing misspelled clause untouched, so a row whose only matching input is a SAME-AS code from the selected release still returns no hit. The new test covers other_map_codes only. Keep the existing input key if callers use it, translate it to the indexed field when building the clause, and test a SAME-AS code present in v1 and dropped in v2.
There was a problem hiding this comment.
Fixed in f98d947. Both priority lists now build the clause on same_as_map_codes, the indexed field, so the release rewriter scopes it like other_map_codes. An input row's same_as_mapped_codes is still read, as the same input, unless the row also sends same_as_map_codes. The Mapper already sends same_as_map_codes, which this list never read.
test_match_reads_the_releases_same_as_codes sends X01 (SAME-AS in v1, dropped in v2) under both keys: v1 finds A; v2 and HEAD find nothing; HEAD finds B by X03. It failed before the fix: v1 returned every row, since no clause read the input.
One effect beyond releases: SAME-AS codes now count in every $match, HEAD included, at boost 0.1 (the boost already listed). Before this, a SAME-AS input never matched anything anywhere.
| def get_fields(self, concept): | ||
| releases = self.releases.get(concept.id, []) | ||
| if concept.is_versioned_object or concept.is_latest_version or not releases: | ||
| codes = to_mapped_codes(concept.get_unidirectional_mappings().values(*MAPPING_VALUES)) |
There was a problem hiding this comment.
[P2] Exclude dropped HEAD mappings for collection-only rows. This adds top-level codes for older rows that have no source-release membership. get_unidirectional_mappings() applies is_active=True only to the versioned object and the latest row, so this new path also indexes inactive HEAD mappings for old rows. The new test at tests_release_map_codes.py:246 demonstrates the mismatch: v2 dropped A's X01 and X05, yet the collection-only row is expected to get both. That makes collection search match codes absent from HEAD, contrary to the stated fallback. Please filter this branch to active HEAD mappings and test with both a retained and a dropped mapping.
There was a problem hiding this comment.
Fixed in 4a2b177. A row no release holds now takes HEAD's active mappings only (get_unidirectional_mappings().filter(is_active=True)), the same rule HEAD's own rows follow.
test_a_row_no_source_version_holds_reads_heads_active_mappings replaces the test you pointed at. v3 edits A with M7 (SAME-AS X07) and M8 (NARROWER-THAN X08); v4 edits A again, keeping M7 and dropping M8. A's v3 row, with its source versions cleared, now gets (['X07'], []). Before the fix it got (['X07', 'X01'], ['X08', 'X05']): M8, plus M1 and M5, which v2 dropped.
…pped codes A concept unchanged since a release keeps one row, shared by HEAD and the release, and so one search document, whose mapped codes are HEAD's. Searching the release by a mapped code found HEAD's codes: those HEAD added, and not those it dropped. - The concept document gets release_map_codes: one entry per release whose own active mappings (as Concept.get_version_mappings reads them) give other codes than the document's. Documents without a difference carry none, so HEAD and a latest release equal to HEAD index as before. - ReleaseMapCodes loads the releases' codes for a chunk of rows in two queries; full indexing and the partial mapped-codes updates both use it. - A search in a release (a version or latest) rewrites each clause on a mapped-code field to read the release's entry where the document has one, else its own fields: the search box, the target repo filter, and $match against a release URL. Documents without an entry match and score as before. HEAD's queries are unchanged. - The targetRepo and targetRepoMapType facets in a release count the release's own codes. - concept_release_map_codes adds the field's mapping to an existing concepts index (no reindex), and with --source fills it on the documents of that source's releases that need an entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…mapped codes From the final review of #985 (FE.5, FE.6 and the rest of FD.4). MappedCodes now decides all of a document's mapped-code fields, and replaces Concept.get_indexed_mappings: - a row HEAD holds, or that no source version holds (a version only a collection holds), takes HEAD's mappings, as it did before #985. Such a row lost its mapped codes on reindex (FE.6). - any other row takes the codes of the latest release that holds it, not the union of every release's (FE.5). A concept dropped from HEAD keeps its latest row, which no longer follows HEAD (FD.4). - each other release whose codes differ gets its release_map_codes entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…doc, scope $match filters, group entries - F1.1: the backfill rewrites the mapped codes of every row the source's releases hold. Documents indexed before this carry HEAD's codes, and a row HEAD doesn't hold now takes its latest release's, with or without entries. - F1.2: --source with --index is refused; the updates go to the concepts index. - F1.3: $match in a release scopes its filters, so the kNN filters and a filter-only row read the release's codes too, not only the lexical clauses. - F1.4: a fuzzy concept search in one source_version reads that version's codes. - F1.5: the release facets keep FACET_SIZE buckets after merging. - F1.6: releases with the same codes share one entry, whose version lists them, so a long release history doesn't repeat the same codes per release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
… codes, $match highlights entries, new releases drop stale entries - F2.2: the versioned object and the latest version keep HEAD's codes as their own, since global search reads the latest version. A concept dropped from HEAD keeps its latest row's codes in entries, so its releases still find it. - F2.3: $match in a release puts each lexical mapped-code clause's entry match in named inner hits, highlighted; CustomESSearch.get_highlight adds them to the hit's highlight under the field's own name, so bestMatch keeps the hit. - F2.4: appending a new release's name to its members' docs also takes that name out of their entries. A release has HEAD's codes when made, so an entry naming it was left by a deleted release of the same name. - F2.1, F2.5: a fuzzy search's source_version no longer selects the release whose codes it reads (back to F1.4 as accepted). - F2.6: the kNN filter test checks the filter names v1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…e id, viewable releases only, union kept for collection search - F3.3 (and F2.4 at its root): entries name their releases by source version id, not name. A release made again under a deleted one's name has a new id, so no entry is stale, and the append script is back as it was: running a release's indexing again no longer drops its entries. - F3.1: a search in a release (a version or latest) reads the release's codes only if the user can view it; otherwise each document's own, as before. - F3.2: a fuzzy search no longer rewrites its mapped-code filters: it isn't scoped to the URL's source version. - F3.4: a row only releases hold keeps the codes of every release that holds it as its own, as the base branch does, for collection searches; each release whose codes differ reads its own entry. - $match resolves its release's id from the repo params, if exactly one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…Codes and command, one test fewer - S1: a row's own code key is computed once, not once per release. - S2: MappedCodes doesn't guard an empty id list; the queries return nothing. - S4: the command reads the expected mapping inline. - S5: test_partial_updates_carry_the_entries goes; the command test covers partial updates that carry entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…only in entries, fuzzy search in one viewable version - FC.1: a row only releases hold takes its own fields from the public releases that hold it. A private release's codes are only in its entry, which a search reads only for a user who can view that release. - FC.2: a fuzzy concept search that selects one source version with source_version, which the user can view, reads that version's codes by its id. The id names that version alone, so a URL naming another source's version of the same name changes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…e rebuilds its rows' codes; fuzzy search back to each doc's own codes - FC.5: when a release's public_access changes, the rows only releases hold (whose own fields take the public releases' codes) get their mapped codes rebuilt on the indexing queue, 5,000 ids a task. - FC.4, FC.6: the fuzzy search rewrite for one source_version (FC.2) is removed. Fuzzy search reads each document's own codes, as it did before this PR (F1.4, accepted). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…ebuild on commit; fuzzy test selects v1 too - FC.7: the mapped-code rebuild after a release's access change is queued once the change commits, so the tasks read the new access. - FC.10: the fuzzy search test also selects v1 with source_version and still gets only B. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9
…D's active mappings get_unidirectional_mappings filters is_active only for the versioned object and the latest version, so an older row that only a collection holds took the mappings HEAD had dropped too. Its own fields now take HEAD's active mappings, as HEAD's rows do. The test keeps one mapping and drops another. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
…e_as_map_codes, so a release reads its own $match built its SAME-AS clause on same_as_mapped_codes, which no document has, so the clause matched nothing and the release rewrite skipped it. The clause now reads same_as_map_codes, the indexed field, which the Mapper already sends; same_as_mapped_codes is still read as the same input. In a release, the clause reads that release's codes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
0793a72 to
f98d947
Compare
snyaggarwal
left a comment
There was a problem hiding this comment.
Verdict: request changes. One P2 remains in the rollout path. The backfill skips existing collection-only documents affected by the new indexing rule.
The two earlier code findings are fixed. Both SAME-AS input keys reach the release-scoped indexed field, and documents prepared for collection-only rows now exclude inactive mappings. GitHub reports that the branch merges cleanly with master.
Focused checks passed for both fixes and confirmed the backfill omission. I did not run the Django or Elasticsearch integration suites.
| @staticmethod | ||
| def backfill(source): | ||
| """Rewrites the mapped codes of the docs of every row `source`'s releases hold. Returns how many.""" | ||
| concept_ids = sorted(set(Concept.sources.through.objects.filter( |
There was a problem hiding this comment.
[P2] Backfill the collection-only rows that now read active HEAD codes. This query can only return members of source releases. An existing older concept row held by a collection alone can have empty mapped-code fields under the old indexing rule. The new MappedCodes branch would give that row its active HEAD codes, but running the documented --source backfill leaves the old fields in place. Include collection-held rows without release membership in the backfill, and extend the backfill test to assert that an already indexed collection-only row gains the retained code without regaining the dropped one.
There was a problem hiding this comment.
Fixed in ff19577. --source now also rewrites every older row of the source: every row except the versioned object and the latest version, whether or not a release holds it. That covers a row only a collection holds, and any older version nothing holds. Both read HEAD's active codes under the new rule and had none before. That's simpler than checking collections: the older rows a release holds were already in the backfill.
test_the_command_fills_a_collection_only_row sets up A's v3 row with no source version holding it, alongside M7 (kept in HEAD), M8 (dropped in v4) and M1/M5 (dropped in v2). It indexes the row as it was before this PR, with no codes, runs the command, and checks the doc reads (['X07'], []). Before the fix the doc stayed ([], []).
Cost: finding LOINC's older rows on production is one sequential scan of concepts; the planner estimates about 851k of them. Many are release rows the backfill already rewrote (814,844 for LOINC). I didn't count how many no release holds, because that would take another full scan on production.
…s and mappings are written together A release is seeded in two writes, its concepts, then its mappings. A concept's search doc rebuilt between them saw the release hold the concept with no mappings, so it got an entry with no codes for that release, and the release's indexing, an append, kept it: a search in the release missed that concept's codes until another rebuild. The two writes are now one transaction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
…r rows too, so a collection-only row gets HEAD's active codes --source rewrote only the rows the source's releases hold. An older row no release holds, such as a version only a collection holds, was indexed with no mapped codes before, and now takes HEAD's active ones, so the backfill rewrites every older row of the source as well. The test indexes such a row as before and checks it gains the code HEAD kept, not those HEAD dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
Codex review, pass 4 (codex-cli 0.169.0, commit f98d947)New round after the rebase onto master and the fixes for the review at 0793a72. Previously accepted findings (F1.4/FC.2, F1.5, F1.6, F2.6, F3.5, FC.3, FC.8, FC.9) are unchanged. Verdict: findings (3 P1, 1 P2 as Codex rated them)
Responses
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "f98d9474",
"verdict": "findings",
"prior": [
{
"id": "F1.4",
"status": "unresolved"
},
{
"id": "FC.2",
"status": "unresolved"
},
{
"id": "F1.5",
"status": "unresolved"
},
{
"id": "F1.6",
"status": "unresolved"
},
{
"id": "F2.6",
"status": "unresolved"
},
{
"id": "F3.5",
"status": "unresolved"
},
{
"id": "FC.3",
"status": "unresolved"
},
{
"id": "FC.8",
"status": "unresolved"
},
{
"id": "FC.9",
"status": "unresolved"
}
],
"findings": [
{
"id": "F4.1",
"severity": "P1",
"tag": null,
"file": "core/concepts/documents.py",
"line": 107,
"claim": "A concept indexed during source seeding can keep an empty mapped-code override after the release finishes seeding.",
"scenario": "HEAD concept A has an active mapping to X01. The async seed writes A's release membership before writing the release's mapping memberships. If an indexing worker rebuilds A in that interval, MappedCodes writes an empty override for the release. The subsequent source-version append preserves that override, so the completed release's search for X01 misses A until another rebuild.",
"action": "Recompute release mapped codes after both membership writes and add an integration test that indexes a concept between them, then runs the normal release indexing path.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F4.2",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 586,
"claim": "The mapped-code rewrite changes results on the `/latest/` alias when HEAD changes after the newest release.",
"scenario": "Release v2 contains A and its mapping to X01. A stays unchanged while HEAD replaces the mapping with X02. Before the PR, `/latest/concepts/?q=X02` finds A through the shared document's HEAD codes. The rewrite scopes that request to v2 and removes A from the results. The alias tests use HEAD and newest-release fixtures with identical mapped codes.",
"action": "Preserve the alias's existing mapped-code behavior while scoping named version URLs. Test a HEAD-only mapping edit after the newest release.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F4.3",
"severity": "P1",
"tag": null,
"file": "core/concepts/search.py",
"line": 147,
"claim": "The SAME-AS fix changes `$match` candidates for an explicit HEAD target.",
"scenario": "The Mapper submits `{ \"id\": \"A\", \"same_as_map_codes\": \"X03\" }` against HEAD, where X03 is a SAME-AS code for B. The base matches A by ID. The new priority list adds a live OR clause for X03, so B appears too. The new HEAD assertions encode the changed behavior.",
"action": "Apply the corrected SAME-AS clause and alias handling to version-scoped matching while preserving HEAD's existing candidate set. Add a HEAD regression test with both an ID and a mapped code.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F4.4",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 592,
"claim": "The release lookup and the Elasticsearch query can select different repositories when their names differ only in case.",
"scenario": "An organization has public sources `LOINC` and `loinc`, each with a `v1`. A search on `/sources/LOINC/v1/concepts/?q=X01` resolves the exact-cased release for its override, but the normalized Elasticsearch source filter also admits documents from `loinc/v1`. Those documents have no entry for `LOINC/v1`, so a matching code in their own fields can appear in the other release's results.",
"action": "Constrain the rewritten search to the exact owner and source used to resolve the release ID, using the existing exact-case index fields. Cover two public sources whose names differ only in case.",
"lines_delta": null,
"confidence": "high"
}
]
} |
|
Rebased onto master (fb7c8e6). Replaying the nine release-search commits gave no conflicts, and their diff against master matches this PR's diff at 0793a72 apart from hunk offsets, so #985's final seeding changes (a59f88f) stay as they landed. The PR now merges cleanly. Since then:
Each has a reply on its thread, and pass 4 is in the comment above. Pylint is 10.00, and the full suite passed on f98d947 (3,463 + 663 OK). The run on ff19577 is in progress. |
…HEAD's mappings refreshes the older rows no release holds An older row no release holds, such as a version only a collection holds, reads HEAD's codes. A mapping edit through the API reindexes every row of the concept, but an import refreshed only the versioned object and the latest row, both for the mappings it imports and for those a seeding import drops. So the older row kept codes HEAD no longer has. Both paths now refresh those rows too (Concept.get_unreleased_older_ids). Rows a release holds keep their release's codes, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
snyaggarwal
left a comment
There was a problem hiding this comment.
Verdict: request changes. The backfill fix now includes older collection-only rows and deduplicates rows shared with releases. The atomic seeding change also closes the gap between writing a release's concept and mapping memberships. One P2 remains because those collection-only documents can become stale again on a later seed.
I checked the backfill and mapping-drop selectors against this head. Pylint passed. The CI test job was still running when I posted this review.
| if concept.is_versioned_object or concept.is_latest_version or not releases: | ||
| # HEAD's active mappings: for an older row, get_unidirectional_mappings keeps those HEAD dropped | ||
| codes = to_mapped_codes( | ||
| concept.get_unidirectional_mappings().filter(is_active=True).values(*MAPPING_VALUES)) |
There was a problem hiding this comment.
[P2] Refresh collection-only rows when HEAD drops a mapping. After backfill, the older row in test_the_command_fills_a_collection_only_row has X07 in its top-level fields. If the next seed keeps A unchanged and drops M7, the mapping-drop refresh selects A's versioned object and latest row only. The older collection row keeps X07, so collection search can still match a code absent from HEAD after the indexing jobs finish. Include older rows with no source-release membership in the mapped-code refresh for affected concepts. Extend the regression test through a second seed that drops M7 and verify the existing indexed row loses X07 without another manual backfill.
There was a problem hiding this comment.
14561fb fixed the drop path (Source.index_dropped_children now also refreshes Concept.get_unreleased_older_ids). Its test only checked that the row was selected, so b83d400 extends test_the_command_fills_a_collection_only_row the way you asked. After the backfill gives the row X07, a second seed (v5) keeps A and drops M7. The test replays that seed's mapped-code refreshes as its indexing jobs would, without another backfill, and checks the doc now reads ([], []). With core/sources/models.py as it was at ff19577, the same test fails with (['X07'], []).
Codex review, pass 5 (codex-cli 0.169.0, commit ff19577)Verdict: findings. F4.1 is resolved. F4.2, F4.3 and F4.4 remain as answered in pass 4. New findings: 2 P1 and 2 P2, as Codex rated them.
Responses
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "ff19577f",
"verdict": "findings",
"prior": [
{
"id": "F4.1",
"status": "resolved"
},
{
"id": "F4.2",
"status": "unresolved"
},
{
"id": "F4.3",
"status": "unresolved"
},
{
"id": "F4.4",
"status": "unresolved"
},
{
"id": "F1.4",
"status": "unresolved"
},
{
"id": "FC.2",
"status": "unresolved"
},
{
"id": "F1.5",
"status": "unresolved"
},
{
"id": "F1.6",
"status": "unresolved"
},
{
"id": "F2.6",
"status": "unresolved"
},
{
"id": "F3.5",
"status": "unresolved"
},
{
"id": "FC.3",
"status": "unresolved"
},
{
"id": "FC.8",
"status": "unresolved"
},
{
"id": "FC.9",
"status": "unresolved"
}
],
"findings": [
{
"id": "F5.1",
"severity": "P1",
"tag": null,
"file": "core/sources/models.py",
"line": 314,
"claim": "An isolated import can leave obsolete HEAD mapping codes searchable on a concept version held only by a collection.",
"scenario": "The backfill gives a pinned older row code X07 from an active HEAD mapping. The next isolated import keeps the concept and drops that mapping. The drop job updates the versioned object and latest row, so the pinned row keeps X07 and collection search still returns it after indexing finishes.",
"action": "Include older rows with no release membership in mapped-code refreshes for affected concepts. Cover an import that drops a mapping after a collection-only row has been indexed.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F5.2",
"severity": "P1",
"tag": null,
"file": "core/collections/models.py",
"line": 831,
"claim": "A collection reference that filters concepts within a specific source release still searches the shared document's mapped codes.",
"scenario": "An editor pins an intensional reference to v1 and filters it with q=X01. The unchanged concept A maps to X01 in v1, and HEAD later drops that mapping. The reference correctly limits candidates to v1's concept rows, but the Elasticsearch query reads the shared document's top-level fields and omits A from the expansion.",
"action": "Pass the resolved, viewable source version into the reference's concept filter and apply the release query rewrite. Test a mapped-code filter against a pinned release after HEAD drops the mapping.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F5.3",
"severity": "P2",
"tag": null,
"file": "core/mappings/views.py",
"line": 357,
"claim": "Deleting a mapping version can leave its code searchable in a release.",
"scenario": "Release v1 has an indexed override for X01 because HEAD dropped that code. An admin soft-deletes the mapping version held by v1. The release's mapping list excludes the inactive mapping, but the delete only saves the mapping row and never refreshes the concept document. Searching v1 for X01 still finds the concept.",
"action": "After a mapping-version deletion commits, refresh mapped-code fields for the affected concept rows in releases that held the mapping. Add a regression test through the delete endpoint.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F5.4",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 586,
"claim": "A release published during a `/latest/` request can make that request use two different releases.",
"scenario": "A search builds its membership filter while v1 is latest. Before `map_codes_release` resolves the alias again, v2 becomes latest. If only v2 maps shared concept A and new concept B to X02, the search can return just A by applying v2's mapped codes to v1's members. The correct result is empty for v1 and A plus B for v2.",
"action": "Resolve `/latest/` once per request and reuse the same source version for permissions, membership filters, mapped-code clauses, and facets.",
"lines_delta": null,
"confidence": "high"
}
]
} |
snyaggarwal
left a comment
There was a problem hiding this comment.
Verdict: approve. I reviewed the full discussion, including the pass 5 findings and responses. The outstanding collection-only refresh issue is fixed. The normal import and seeding-drop paths both refresh older rows with no source-release membership, and the regression test checks that both paths select the affected row. The shared selector excludes older rows held by a release so they retain their release-specific codes.
I found no new merge blocker in this revision. I left a non-blocking inline suggestion to make the backfill help match its current scope. Focused selector checks passed. CI was still in progress on this head when I posted, and I did not run the integration suites locally.
| help="A source's URL, such as /orgs/Regenstrief/sources/LOINC/, whose release docs to rewrite. " | ||
| "Repeatable; not with --index.") |
There was a problem hiding this comment.
Non-blocking suggestion. The option help still says it only rewrites release docs. Include the older rows so operators can see the scope before running the backfill.
| help="A source's URL, such as /orgs/Regenstrief/sources/LOINC/, whose release docs to rewrite. " | |
| "Repeatable; not with --index.") | |
| help="Rewrite mapped codes for release members and older concept rows of this source. " | |
| "Use the source URL, for example /orgs/Regenstrief/sources/LOINC/. " | |
| "Repeatable. Do not combine with --index.") |
…ps M7 through to the collection-only row's doc After the backfill gives the collection-only row X07, the next seed keeps A and drops M7. The test now runs that seed's mapped-code refreshes and checks the doc loses X07 with no second backfill. The import test keeps the HEAD-only import path, and one fixture helper builds an edited A. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
… read each doc's own codes, as its hits do A fuzzy search in a release matches each doc's own codes, but its facets came from the release's codes, so they could offer a map type no hit has. A fuzzy request now isn't scoped to the release at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
… rows it also rewrites Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUwCLvLBDodjZbS2Yn
|
After your approval at 14561fb I pushed three commits:
Pass 6 and the final check of these commits are in the comments below. |
Codex review, pass 6 (codex-cli 0.169.0, commit 14561fb)Verdict: findings. F5.1 is resolved. F5.2, F5.3 and F5.4 remain as answered in pass 5. New: 2 P1, as Codex rated them. This was the third and last pass of this round.
Responses
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "14561fb4",
"verdict": "findings",
"prior": [
{
"id": "F5.1",
"status": "resolved"
},
{
"id": "F5.2",
"status": "unresolved"
},
{
"id": "F5.3",
"status": "unresolved"
},
{
"id": "F5.4",
"status": "unresolved"
},
{
"id": "F4.1",
"status": "resolved"
},
{
"id": "F4.2",
"status": "unresolved"
},
{
"id": "F4.3",
"status": "unresolved"
},
{
"id": "F4.4",
"status": "unresolved"
},
{
"id": "F1.4",
"status": "unresolved"
},
{
"id": "FC.2",
"status": "unresolved"
},
{
"id": "F1.5",
"status": "unresolved"
},
{
"id": "F1.6",
"status": "unresolved"
},
{
"id": "F2.6",
"status": "unresolved"
},
{
"id": "F3.5",
"status": "unresolved"
},
{
"id": "FC.3",
"status": "unresolved"
},
{
"id": "FC.8",
"status": "unresolved"
},
{
"id": "FC.9",
"status": "unresolved"
}
],
"findings": [
{
"id": "F6.1",
"severity": "P1",
"tag": null,
"file": "core/common/tasks.py",
"line": 457,
"claim": "Publishing a release can leave it unable to find mappings linked to an older concept version.",
"scenario": "Edit concept A, then add a HEAD mapping to X01 using the first version of A as `from_concept_url`. Let indexing finish before publishing v1. The release holds A's newer row and the mapping. The release's mapping lookup follows A's versioned object ID and returns X01, but the newer row's existing document has no X01 because HEAD's lookup excludes the older row. Publication only appends release membership, so v1 search still misses A until the document is rebuilt.",
"action": "Refresh mapped codes for release members whose release mappings differ from their existing document fields during publication. Add a regression test that indexes the concept before publishing and searches the release after the normal indexing job.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F6.2",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 630,
"claim": "A fuzzy release search can advertise a mapped-code facet that produces no results.",
"scenario": "In the release fixture, search v1 with `fuzzy=true`, `q=name`, `source_version` pointing to v1, `target_repo` set to ICD-10, and `IncludeFacets: true`. The results contain only B because fuzzy search reads the document's own codes. The facets use v1's overrides and advertise `NARROWER-THAN` from A. Adding `target_repo_map_type=NARROWER-THAN` returns no fuzzy hits.",
"action": "Build the mapped-code facets for fuzzy requests from the same query and document fields as the fuzzy hits. Test the results and facets together in one response.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Codex check of commits 14561fb..0952f28 (codex-cli 0.169.0, commit 0952f28)Verdict: findings (1 P1, as Codex rated it)
Response: not changed; it predates this PR. On master, findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "0952f284",
"verdict": "findings",
"prior": [
{
"id": "F6.2",
"status": "regressed"
}
],
"findings": [
{
"id": "FC.10",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 586,
"claim": "Fuzzy facets can count concepts that the fuzzy hit query cannot match. The new guard removes release scoping from the regular query used to select documents for facets, so that query can now match a code added after the release.",
"scenario": "In the LOINC fixture, B belongs to v1 but gains the mapped code X03 in v2. Request v1 concepts with `q=X03&fuzzy=true` and `IncludeFacets: true`. The fuzzy hit query searches names and synonyms and returns no concepts. The facet query now matches B through its HEAD code X03 and reports a SAME-AS bucket that was empty before this change.",
"action": "Use the fuzzy hit criteria to select documents for fuzzy facets, preserving the requested release filter and the document-level mapped-code aggregations. Add a test for a query that matches only a mapped code.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…earch and cascade-scope branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTbiSiJ56vAgWwb9D
…MappedCodes' fields, and runs are time-boxed Review changes after merging master (#1010 moved concept mapped codes into MappedCodes): - The latest-flags update sends everything MappedCodes.get_fields gives a row, release_map_codes included, built once per batch. get_latest_flags_fields takes the batch. A version only a private release holds then keeps that release's codes in release_map_codes once an import supersedes it. - A run indexes for at most 5 minutes, then queues the next run behind the indexing tasks queued meanwhile, so the window no longer holds an indexing slot throughout. - A run renews its lock only while the lock still holds its token, and stops once it doesn't. - A window shorter than the 10 minutes between beat runs pauses the job and logs an error, as a value that doesn't parse does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWWFiC4BMWhVDdX48K
OpenConceptLab/ocl_online#703. Builds on #985, now on master; this branch was rebased onto master on Nov 20.
What this does
A concept search in a release now matches that release's own mapped codes. Since #985, a release's concept page, concept list and mappings tab show the release's own mappings; search did not.
Why search differed. A concept unchanged since a release keeps one row, shared by HEAD and the release, so one search document serves both. That document's mapped codes were HEAD's. Searching a release by a mapped code found codes HEAD had added since, and missed codes HEAD had dropped. With seeding imports (#985), a new release can drop many mappings at once, so this gap gets much wider.
Index side. The concept document gets one new nested field,
release_map_codes. It holds one entry per distinct set of codes, with that set'ssame_as_map_codes,other_map_codesandmapped_codes, and asource_version_idlist naming every release that has it. The entries use ids, not names: a release made again under a deleted one's name gets a new id, so its documents can't pick up a stale entry. Only releases whose own active mappings give other codes than the document's own fields appear. A document whose releases all match carries no entries.MappedCodesloads the release codes for a chunk of rows in two queries. Full indexing (prepare, 100 docs a chunk) and the partial mapped-code updates (Concept.get_mapped_codes_actions) both use it, so every path that refreshes mapped codes refreshes the entries too.One rule for a document's own codes.
MappedCodesreplacesConcept.get_indexed_mappings. The rule also covers three items from #985's final review (FE.5, FE.6 and the rest of FD.4):Concept.get_unreleased_older_ids), as a mapping edit through the API already did.public_accesschanges, those rows' codes are rebuilt on the indexing queue (Source.index_release_rows_mapped_codes_async).Query side. In a release the user can view (
/<version>/concepts/or/latest/concepts/),ConceptDocument.scope_map_codes_to_releaserewrites each clause on a mapped-code field after the query is built. The clause matches the document's entry for that release where there is one, and the document's own fields otherwise. That covers:targetRepofilter;$matchagainst a release URL: its filters, including those the kNN queries use, and its lexical clauses. The lexical clauses highlight an entry's matching field through named inner hits, whichCustomESSearch.get_highlightfolds into the hit's highlight. Without that,bestMatchwould drop the hit.$matchSAME-AS input.$matchbuilt its SAME-AS clause onsame_as_mapped_codes, which no document has, so that input never matched and the release rewrite skipped it. The clause now readssame_as_map_codes, the indexed field, which the Mapper already sends.same_as_mapped_codesis still read as the same input. This applies in HEAD as well: a SAME-AS input now counts toward$matchscores (boost 0.1, as listed).Facets.
targetRepoandtargetRepoMapTypein a release count the release's own codes.What stays the same.
$matchSAME-AS fix above is the one change HEAD sees.)Deploying
python manage.py concept_release_map_codes. It adds the field's mapping to the live concepts index and checks it. Nothing is reindexed.python manage.py concept_release_map_codes --source <source URL>rewrites the mapped codes of every row that source's releases hold, and of every older row of the source. On master, every document holds HEAD's codes, rows only older releases hold included, so each source with releases needs this once. An older row no release holds, such as a version only a collection holds, had no mapped codes on master and now gets HEAD's active ones.conceptson production (the planner estimates about 851k older LOINC rows; many are release rows already counted below).Measurements
LOINC numbers come from production (read-only) and a local benchmark; details are in the measurements comment.
Testing
core/integration_tests/tests_release_map_codes.py. A seeded v1 → v2 where concepts A and B don't change, and their mappings do. A's mappings are dropped in v2; B gains one.ReleaseMapCodesTest, no ES:$matchname the release;--sourcewith--indexis refused.ReleaseMapCodesSearchTest, ES. HEAD, v1, v2 andlatest, each:targetRepofilter the same way;$matchagainst v1 and v2, by a NARROWER-THAN code and by a SAME-AS code (under both input keys), a filter-only$match, and the highlight of a hit matched through an entry;test_older_concept_version_indexes_its_releases_mappingsasserts the document fields now thatget_indexed_mappingsis gone.test_mapped_codes_actions_update_just_the_mapped_codesexpects the new field.TEST_ES=off --exclude-tag es --parallel=4: 3,465 tests, OK;--tag es --parallel=1: 665 tests, OK.pylint -j0 core/gives 10.00 with no messages.Not in this PR
latest, so a private latest release's membership still filters the results. This predates the PR; its mapped codes are no longer read (F3.1).$matchreads the entries'.from_conceptis an older concept version isn't in HEAD's codes, as on master (Codex F6.1).🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qVSZwPgUucRdN8D9U9