Repository navigation
OpenConceptLab/ocl_online#736 | Fuzzy concept search keeps to the URL's repository version; a reference's cascade walks only source versions its creator can view - #1024
Conversation
…ository version in the URL, as plain search does A fuzzy search that names no source_version targets now applies the URL's owner, source and version filters. The block that builds them moves unchanged out of __get_search_results into __apply_scope_filters, which both searches call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC
…version it names only if the reference's creator can view it A version the creator can't view is walked as if it didn't exist, so the reference adds only the concept, as for a label that doesn't resolve; omit_if_exists_in already works this way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC
…em or value set version it walks too; a search scope naming no version matches nothing The cascade check now covers every repo version a cascade walks, not only one named by label. A search scoped to a version that doesn't resolve (latest with no release) now returns no results, rather than an Elasticsearch error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC
Codex review, pass 1 (codex-cli 0.169.0, commit 78d8bbc)Verdict: findings (4 P1, 1 P2). The full findings and the evidence are on the tracking ticket. Responses:
|
… requester on /user/ routes A collection's owner URL and the release `latest` resolves to now use the requester on the /user/ shortcut, as the owner filter already did, so searches there keep to the requester's own repositories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC
Codex review, pass 2 (codex-cli 0.169.0, commit 0024aca)Verdict: findings (2 P1, 4 P2). It marks F1.2 and F1.4 resolved; F1.1, F1.3 and F1.5 stand as answered in pass 1 (covered by #1023, or present in plain search already). Responses:
|
…cut keeps to the collection's members; search stats with no hits answer an empty list - A search under /user/collections/<c>/ no longer adds the requester as the concepts' owner: a collection's members come from any owner's source, as on the /users/<u>/collections/<c>/ route. - Search stats (searchStatsOnly) with no hits return [] instead of failing on a null max score. - The signed-out reference test now names the cascade version too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcjfVFHsP2kYdP9tH
Codex review, pass 3 (codex-cli 0.169.0, commit c9e891c)Verdict: findings (3 P1, 1 P2). It marks F2.2 resolved and F2.1 unresolved only because fuzzy search on collection concept lists still fails (F3.1 below); the
Pylint is clean and the full suite passes locally on 695c24c (3453 tests, plus 653 Elasticsearch tests). |
Codex check of commits c9e891c..695c24c (codex-cli 0.169.0)Verdict: findings (2 P1). F3.3 and F3.4 resolved. Codex marks F3.2 regressed because the
Neither is narrowed here: the shortcut now matches the explicit route, and both gaps are noted on the tracking ticket. Simplification review (claude subagent, 695c24c)Two low-confidence items, both declined:
No commits after 695c24c. |
…ce version it walks as the walk finds it, among the versions that hold the concept The label check looked the version up under the source's current name, while the walk looks it up among the source versions that hold the concept. When those differ (after a source is renamed, its releases keep the old name), the check found nothing and let the walk through. It now resolves the label the way the walk does and checks every version it finds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcjfVFHsP2kYdP9tH
Adversarial review (claude subagent, on 695c24c)A fresh reviewer looked for other paths that reach the same data while skipping this PR's checks.
|
…urce version it walks once and hands the checked version to the walk The check and the walk each resolved the cascade's version label. The check now resolves it once, as the walk did (among the source versions that hold the concept, exactly one), checks it, and passes that version to the walk, or None, which adds only the concept as an unknown label does. One lookup per concept instead of the walk's two, and nothing changes between the check and the walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcjfVFHsP2kYdP9tH
Codex check of commits 695c24c..9e1826c (codex-cli 0.169.0)Verdict: findings (1 P1, 1 P2), both about the cascade check from the adversarial fix. One change answers both, in 91628a7:
Pylint is clean and the full suite passes locally on 91628a7 (3454 tests, plus 653 Elasticsearch tests). |
snyaggarwal
left a comment
There was a problem hiding this comment.
Reviewed at 91628a7, after your Codex passes, the adversarial pass and the final clean check. The cascade check and the fuzzy-search scope hold on the paths I traced:
- A fuzzy search without
source_versiontargets keeps to the URL's repository version. - The cascade check finds a label's version the way the walk does, and hands the walk the version it checked.
latestwith no release answers an empty list.
I haven't run the tests.
Before merge (inline): one case in FuzzySearchScopeTest fails once #1023 is also merged, because #1023 answers 404 for a missing source. The two PRs merge without text conflicts, so only CI would catch it.
Agreed to leave for later: fuzzy search on a collection's concept list answering 500 (your pass 3, F3.1).
Nits (inline): HEAD URLs belong with the behaviour change; the How section's method name and "moves unchanged" are out of date; and one inline comment is easy to misread.
| for user in [None, self.outsider, self.member]: | ||
| self.assertEqual(self.search(public_release_url, user), (200, []), user) | ||
| self.assertEqual(self.search(self.public_source.uri + 'latest/', user), (200, []), user) | ||
| self.assertEqual(self.search('/users/outsider/sources/NoSuchSource/v9/', user), (200, []), user) |
There was a problem hiding this comment.
Before merge: this case fails once #1023 is merged. #1023's check_source_version_access answers 404 for a source or version that doesn't exist, and its test_a_missing_source_or_version_is_not_found asserts that. So this request gets (404, None) there.
The two PRs merge without text conflicts (git merge-tree of ae48cfa and 91628a7 is clean), so only CI on whichever merges second would show it. #1023 covers the missing-source case, so dropping it here keeps this test green whichever PR merges first:
| self.assertEqual(self.search('/users/outsider/sources/NoSuchSource/v9/', user), (200, []), user) |
There was a problem hiding this comment.
Dropped as you suggested, in f03ca38. A missing source or version is now left to #1023's test_a_missing_source_or_version_is_not_found.
Checked on trial merges with #1023:
- f03ca38 with its then head ae48cfa:
tests_cross_repo_accessandtests_access_controlpass (210 tests). With this line put back, that merge fails at it with(404, None) != (200, []), so it was the only case. - The new head 396efe3 (master merged in, up to OpenConceptLab/ocl_online#703 | A release's search matches its own mapped codes #1010) with its current head 0b217d7:
tests_cross_repo_access,tests_access_controlandtests_release_map_codespass (242 tests).
| self.__get_source_versions_es_criterion(source_versions) | ||
| ) | ||
| else: | ||
| results = self.__apply_scope_filters(results) |
There was a problem hiding this comment.
Nit (PR body). Without source_version targets, this now applies the URL scope on HEAD URLs too: owner, source and source_version=HEAD under /orgs/O/sources/S/concepts/. Before, the fuzzy path had no repository filter, so a fuzzy search there matched every source's latest revisions. The body lists HEAD URLs under "Unchanged", but they belong with the behaviour change. No client sends fuzzy=true, so the impact is small.
There was a problem hiding this comment.
Agreed. HEAD URLs are now under the behaviour change in the PR body: a fuzzy search on /orgs/O/sources/S/concepts/ keeps to S's HEAD, where it used to match every source's latest revisions.
| if is_members_view: | ||
| kwargs_filters['ownerType'] = 'Organization' | ||
| kwargs_filters['owner'] = self.get_members_view_org_mnemonics() or ['UNKNOWN-ORG-DUMMY'] | ||
| elif self.user_is_self and is_authenticated and 'collection' not in self.kwargs: # members have any owner |
There was a problem hiding this comment.
Nit. Two lines up, "members" means the requester's orgs (is_members_view). Here it means the collection's member concepts. Spelling it out keeps the next reader from undoing the condition:
| elif self.user_is_self and is_authenticated and 'collection' not in self.kwargs: # members have any owner | |
| elif self.user_is_self and is_authenticated and 'collection' not in self.kwargs: | |
| # a collection's concepts can come from any owner's source, so only other routes filter by owner |
|
|
||
| return Concept.objects.filter(id__in=concept_ids), Mapping.objects.filter(id__in=mapping_ids) | ||
|
|
||
| def _get_viewable_cascade_version(self, concept, repo_version, viewable_by_version): |
There was a problem hiding this comment.
Nit (PR body). The How section calls this CollectionReference._can_view_cascade_version. It also says the URL-scope block moves unchanged out of __get_search_results, but __apply_scope_filters gains the match_none branch and the 'collection' not in self.kwargs condition. Both are listed under "From the review passes", so only the How section is out of date.
There was a problem hiding this comment.
Fixed in the PR body: the How section names _get_viewable_cascade_version and says what __apply_scope_filters gains on the move (the match_none branch and the 'collection' not in self.kwargs condition).
…d cascade-scope branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTbiSiJ56vAgWwb9D
…ing source to the version-access tests; clearer owner-filter comment A missing source or version is the version-access check's case (#1023 answers 404 and tests it), so this test no longer asserts an answer for one and passes whichever PR merges first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTbiSiJ56vAgWwb9D
…earch and cascade-scope branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTbiSiJ56vAgWwb9D
Codex check of commits 91628a7..396efe3 (codex-cli 0.169.0)The commits after Sunny's review: 3a31969 (master merged in, with #1022 and #1017), f03ca38 (his two suggestions) and 396efe3 (master merged in again, with #1010). Two checks, each asked only what those commits broke. Verdict: no defect in this PR's own changes, and none from how they combine with #1022, #1017 or #1010.
Tests on 396efe3: |
snyaggarwal
left a comment
There was a problem hiding this comment.
Approving at 396efe3. f03ca38 makes both inline changes: the missing-source line is gone, so FuzzySearchScopeTest passes whether #1023 merges first or second, and the owner-filter comment now says which members it means. The PR body lists HEAD URLs under the behaviour change and names _get_viewable_cascade_version. Both master merges are conflict-free.
CI is green at 396efe3. It merges cleanly with master, which now has #1007, and with #1023 (36f75b3). Your trial merge ran with #1023 at 0b217d7. #1023's later commit changes only reads with no owner named, which no test here uses. Still, whichever of the two merges second should take master and pass CI first. I haven't run the tests locally.
…1007) into ocl_online-718-query-collection-version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
Part of OpenConceptLab/ocl_online#736 (items 1 and 2).
What changes
Fuzzy concept search keeps to the repository version in the URL. A
?fuzzy=truesearch that names nosource_versiontargets now applies the same URL scope as the plain search: owner, source and version (or the requester's orgs on a members view). Until now it applied no repository filter, so it could return concepts from outside the repository version the URL names.A collection reference's cascade walks a source version it names only if the reference's creator can view it. When
cascade.source_versionnames a version by label, that version gets the same check as the reference's system version (can_view_all_contentfor the reference's creator). A version the creator can't view is walked as if it didn't exist, so the reference adds only the concept, as it already does for a label that doesn't resolve.omit_if_exists_inalready treats a repository its creator can't view this way.From the review passes:
latestwith no release) returns no results, where plain search used to fail with an Elasticsearch error./user/routes, the scope reads the owner from the requester (url_username), as the owner filter already did. Search on/user/collections/<c>/concepts/andlatest/under/user/sources/<s>/works again.Behaviour change to check
/orgs/O/sources/S/concepts/?fuzzy=true: they now keep to source S's HEAD, where they used to match the latest revisions of every source. No OCL client sendsfuzzy=true(oclmap, oclweb3, oclweb2, ocl-cli checked).source_versiontargets, and the global/concepts/?fuzzy=true.How
BaseAPIView.__apply_scope_filters: the URL-scope block moves out of__get_search_results, and both searches call it. It gains two changes from the review passes: a scope value that doesn't resolve matches nothing (match_none), and the/user/owner filter skips collection routes, since a collection's concepts can come from any owner's source.CollectionReference._get_viewable_cascade_version: called from_apply_cascadefor each concept. It resolves asource_versionlabel once, among the source versions that hold the concept (as the walk does), checks that version, and hands the walk the checked version, or None. Each version's check is cached while one reference is evaluated.Tests
core/integration_tests/tests_cross_repo_access.py:FuzzySearchScopeTest(es): signed out, outsider and member. It covers a public release URL,latest/(with and without a release), and HEAD. A URL naming a source or version that doesn't exist is left to the version-access tests: OpenConceptLab/ocl_online#717 OpenConceptLab/ocl_online#718 | Reads under a source version get that version's access check #1023 answers it 404. The release's own URL keeps answering 401/403 to non-members and 200 to members.CascadeSourceVersionAccessTest: an outsider, a member and staff add references through the references API.These tests fail on master and pass here. At 91628a7 the full suite passed (3,453 tests in the parallel run, 653 tagged
es). After master was merged in (up to #1010),tests_cross_repo_accessandtests_release_map_codespass (55 tests) and pylint is clean. A trial merge of 396efe3 with #1023's head 0b217d7 passestests_cross_repo_access,tests_access_controlandtests_release_map_codes(242 tests), so the two PRs can merge in either order.🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC