René's URL Explorer Experiment


Title: improvement(knowledge): rank inside the permitted set for organization search by waleedlatif1 · Pull Request #7996 · simstudioai/sim · GitHub

Open Graph Title: improvement(knowledge): rank inside the permitted set for organization search by waleedlatif1 · Pull Request #7996 · simstudioai/sim

X Title: improvement(knowledge): rank inside the permitted set for organization search by waleedlatif1 · Pull Request #7996 · simstudioai/sim

Description: Summary Organization search indexes grant most documents to one mailbox, channel, or file owner, so a typical member can read about 0.1% of the index. Both retrieval legs searched the whole index and checked access afterwards. The vector walk then post-filtered nearly every neighbour away, and common keyword terms ranked matches the member could never see. Resolve the permitted set once. retrieveKnowledgeSearch calls resolvePermittedDocuments before both legs for live user scopes (a user scope with an access provider and no explicit documentIds). It returns bounded (documents plus their connector) or unbounded. The set is resolved with the same candidate predicate both legs apply, so restricting a leg to it can only narrow. Vector. bounded ranks the permitted chunks exactly and skips the HNSW walk. unbounded runs the walk only, with no second tractability probe. Keyword. bounded reads the permitted chunks directly through embedding_keyword_search_document_idx, using an OFFSET 0 fenced subquery aliased as the table. Base, enabled, tsquery and tag checks are applied outside it. The existing visibility CTE still re-applies the candidate predicate. Probe SQL (user scopes). It counts the documents the caller's tokens reach inside the requested bases, up to the limit. It reads doc_acl_gin_idx (deleted_at IS NULL AND acl && tokens) inside an OFFSET 0 fence and applies the base check to the rows the index returns, so the planner cannot swap to a whole-base heap scan. The count is base-scoped because the baseline tokens (pub/ws/org) are shared by every tenant; a global count would saturate for nearly every caller. Only when the count is under the limit does it materialize those rows and apply the base, state and full candidate access conditions in memory. Over the limit, a saturated sentinel row reports unbounded. Resolved scopes keep the plain form. Members-mode access clause. The row-value IN (subquery) is now a correlated EXISTS, served by the observation PK (document_id, member_id). Semantics are identical: every compared column is NOT NULL, and the clause sits inside the connector EXISTS, so document.connector_id is non-null there. PostgreSQL no longer hashes every observation once per statement. Excluded sources and timeouts. Sources excluded by live authorization are dropped from the permitted set on refill; uploads with a null connector stay. An empty set short-circuits both legs. If the vector budget runs out during resolution, the result is unbounded and the vector leg is marked timed out; the keyword leg is not failed. Diagnostics. New stage permitted_documents and new metadata permittedDocuments / permittedDocumentCount. Evidence Server-side execution time on a restored copy of a large organization search index, measured with the same members and queries on main and on this branch: Typical member, keyword: common term: 1640 ms → 42 ms; rare term: 8 → 23 ms. Typical member, vector: Before: the HNSW walk found 0–16 of 1600 candidates after 0.7–3.4 s, then the tractability probe timed out at 600 ms. Now: permitted set 37 ms + exact ranking 17 ms + rerank 53 ms, with complete results. Replay recall went from 13–14 of 20 to 20 of 20. Member whose tokens reach several times the probe limit: hydration and rerank each 142–188 ms → ~1 ms, from the members-mode EXISTS; probe 2.0 s warm / 11.8 s cold → ~200 ms; rare keyword 319 → 2 ms. Unchanged: the unbounded common-term keyword path stays at ~2.3 s. A follow-up addresses it. Calibration: Exact vector ranking costs ~3 µs per permitted chunk: 7 ms at 1k documents, 513 ms at 100k. The HNSW walk only fills when a member can read roughly 20% or more of the index, so the bounded/unbounded split stays at the existing VECTOR_PROBE_DOCUMENT_LIMIT (100k documents). Keyword: the direct read and the text-index intersection cost about the same on common terms, but the planner misplanned the index form for real members (147–180 ms vs 23–42 ms). Bounded keyword therefore always uses the direct read. Type of Change Improvement (performance) Testing 11 new planner unit tests, plus a real-Postgres test: VECTOR_PROBE_DOCUMENT_LIMIT + 1 reachable documents in a sibling base must leave the target base bounded. The unit tests cover bounded exact ranking skips the walk; empty sets; no re-probe when unbounded; keyword confinement; excluded-source refill; saturation; budget exhaustion; resolved once before both legs. Each was confirmed to fail against a broken planner. 2965 knowledge unit tests pass; type-check, lint, check:api-validation and check:audits are clean. Real-Postgres knowledge ACL suite: 501/502. The one failure is a pre-existing organization-personal-tokens test that also fails on staging. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary Organization search indexes grant most documents to one mailbox, channel, or file owner, so a typical member can read about 0.1% of the index. Both retrieval legs searched the whole index a...

X Description: Summary Organization search indexes grant most documents to one mailbox, channel, or file owner, so a typical member can read about 0.1% of the index. Both retrieval legs searched the whole index a...

Opengraph URL: https://github.com/simstudioai/sim/pull/7996

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:5878f1a2-c4c1-1536-b3c6-2b4c8c4344b6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id95D8:73CE1:ED74AC:14535C0:6AFB5F14
html-safe-noncee8b2fb5629e03eda4be64aec14f2d22ea5da948088bb75454b1fd2c53f0fc53a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUQ4OjczQ0UxOkVENzRBQzoxNDUzNUMwOjZBRkI1RjE0IiwidmlzaXRvcl9pZCI6IjM1MTQ2ODA2NTE4OTIzNTA3NDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0917005c2d288a9a48cd28fccb53304e530403960f3c75643881291b765d1ecd
hovercard-subject-tagpull_request:4574667001
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/7996/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Organization search indexes grant most documents to one mailbox, channel, or file owner, so a typical member can read about 0.1% of the index. Both retrieval legs searched the whole index a...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ef97164c52cf59bd10558ddec9c4f482763988
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/7996/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F7996%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F7996%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/7996/files
Reloadhttps://github.com/simstudioai/sim/pull/7996/files
Reloadhttps://github.com/simstudioai/sim/pull/7996/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
improvement/search-permitted-set-plannerhttps://github.com/simstudioai/sim/tree/improvement/search-permitted-set-planner
Conversation 17 https://github.com/simstudioai/sim/pull/7996
Commits 2 https://github.com/simstudioai/sim/pull/7996/commits
Checks 34 https://github.com/simstudioai/sim/pull/7996/checks
Files changed https://github.com/simstudioai/sim/pull/7996/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7996/files
improvement(knowledge): rank inside the permitted set for organization search https://github.com/simstudioai/sim/pull/7996/files#top
Show all changes 2 commits https://github.com/simstudioai/sim/pull/7996/files
30af2a4 improvement(knowledge): rank inside the permitted set for organizatio… waleedlatif1 Sep 19, 2026 https://github.com/simstudioai/sim/pull/7996/commits/30af2a4fb5e21b81833c0d14bf486989da2f79a5
a63f19c fix(knowledge): count a caller's reach inside the requested bases waleedlatif1 Sep 19, 2026 https://github.com/simstudioai/sim/pull/7996/commits/a63f19c3e6a987350b2ba2f4006bd80dad88ebc4
Clear filters https://github.com/simstudioai/sim/pull/7996/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7996/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7996/files
kb-block-search.integration.ts https://github.com/simstudioai/sim/pull/7996/files#diff-5e1af68949d3acae280bad6cfa417e3f453a0f92c0fbfbf64fb1b9640cdd4b87
predicate.ts https://github.com/simstudioai/sim/pull/7996/files#diff-720ce8ebbff1c232b2a35c2b75ac2bb1983110156c6d866f4127172e619c4df3
diagnostics.ts https://github.com/simstudioai/sim/pull/7996/files#diff-454cb97c4d1f9ca41cc9ec69e41039731b15cf7250ff59d784f19495ea0caea6
queries.test.ts https://github.com/simstudioai/sim/pull/7996/files#diff-b5bc7cdb4cf5dd93b0dc5beb76436fb9e70fc036e89833eaf8d9defb8bc83c3b
queries.ts https://github.com/simstudioai/sim/pull/7996/files#diff-5f10054baeef2f06350b32a6520d8f841f86a2fc908435296dd8dcb097497ba9
apps/sim/lib/knowledge/__integration__/kb-block-search.integration.tshttps://github.com/simstudioai/sim/pull/7996/files#diff-5e1af68949d3acae280bad6cfa417e3f453a0f92c0fbfbf64fb1b9640cdd4b87
View file https://github.com/simstudioai/sim/blob/a63f19c3e6a987350b2ba2f4006bd80dad88ebc4/apps/sim/lib/knowledge/__integration__/kb-block-search.integration.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7996/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7996/files#diff-5e1af68949d3acae280bad6cfa417e3f453a0f92c0fbfbf64fb1b9640cdd4b87
https://github.com/simstudioai/sim/pull/7996/files#diff-5e1af68949d3acae280bad6cfa417e3f453a0f92c0fbfbf64fb1b9640cdd4b87
https://github.com/simstudioai/sim/pull/7996/files#diff-5e1af68949d3acae280bad6cfa417e3f453a0f92c0fbfbf64fb1b9640cdd4b87
apps/sim/lib/knowledge/access/predicate.tshttps://github.com/simstudioai/sim/pull/7996/files#diff-720ce8ebbff1c232b2a35c2b75ac2bb1983110156c6d866f4127172e619c4df3
View file https://github.com/simstudioai/sim/blob/a63f19c3e6a987350b2ba2f4006bd80dad88ebc4/apps/sim/lib/knowledge/access/predicate.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7996/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7996/files#diff-720ce8ebbff1c232b2a35c2b75ac2bb1983110156c6d866f4127172e619c4df3
https://github.com/simstudioai/sim/pull/7996/files#diff-720ce8ebbff1c232b2a35c2b75ac2bb1983110156c6d866f4127172e619c4df3
https://github.com/simstudioai/sim/pull/7996/files#diff-720ce8ebbff1c232b2a35c2b75ac2bb1983110156c6d866f4127172e619c4df3
https://github.com/simstudioai/sim/pull/7996/files#diff-720ce8ebbff1c232b2a35c2b75ac2bb1983110156c6d866f4127172e619c4df3
apps/sim/lib/knowledge/search/diagnostics.tshttps://github.com/simstudioai/sim/pull/7996/files#diff-454cb97c4d1f9ca41cc9ec69e41039731b15cf7250ff59d784f19495ea0caea6
View file https://github.com/simstudioai/sim/blob/a63f19c3e6a987350b2ba2f4006bd80dad88ebc4/apps/sim/lib/knowledge/search/diagnostics.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7996/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7996/files#diff-454cb97c4d1f9ca41cc9ec69e41039731b15cf7250ff59d784f19495ea0caea6
https://github.com/simstudioai/sim/pull/7996/files#diff-454cb97c4d1f9ca41cc9ec69e41039731b15cf7250ff59d784f19495ea0caea6
https://github.com/simstudioai/sim/pull/7996/files#diff-454cb97c4d1f9ca41cc9ec69e41039731b15cf7250ff59d784f19495ea0caea6
https://github.com/simstudioai/sim/pull/7996/files#diff-454cb97c4d1f9ca41cc9ec69e41039731b15cf7250ff59d784f19495ea0caea6
Please reload this pagehttps://github.com/simstudioai/sim/pull/7996/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7996/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.