Skip to content

improvement(search): consolidate knowledge search around live Sim Search and document-decided workspace retrieval - #8314

Merged
waleedlatif1 merged 1 commit into
stagingfrom
chore/consolidate-knowledge-search
Sep 26, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
chore/consolidate-knowledge-search

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Organization Sim Search is live-only. The indexed org-search implementation stays in the repo but is dormant: it lives entirely in lib/sim-search/indexed/ (and app/**/indexed/ for its UI) behind one gate, isIndexedOrgSearchEnabled(), and every indexed use case refuses on its own while dormant
  • Workspace knowledge base search (Knowledge block, v1/v2, MCP, Sim tools) decides access on the document for every principal. A search that names a search-index knowledge base keeps working the same way while indexed search is dormant. The per-row ACL machinery (access plan, reach/permitted sets, on-row walk, embedding_keyword_search, per-source walks) now only runs for search-index bases while indexed search is on. Signed-in workspace searches run fewer statements; live source proof stays lazy; actorless legs keep their prior (unbudgeted) behavior
  • Splits shared retrieval into candidates.ts, tag-filters.ts, and vector-leg.ts
  • Removes the knowledge-async-projection, knowledge-projection-fill, and knowledge-tin-keyword flags and their code paths
  • Less background DB work: no per-source HNSW builds nothing read, no per-write projector requests; the projector sweep releases every mark with nothing to project (search-index marks too while dormant) and only starts a pass for content writes; processing recovery skips dormant search-index documents; member-sync reclaims use their partial index
  • Removes unreachable code (knowledge/table VFS mutations, member-connectors and GitHub installation routes/contracts/hooks, bulk document delete, and other unused helpers)
  • Follow-up (separate PR after this deploys): a migration scoping the projection mark and ACL-mirroring triggers to search-index knowledge bases

Type of Change

  • Improvement

Testing

Type-check, lint, check:audits, unit suites, and the knowledge/sim-search integration suites against real Postgres. New integration coverage: workspace document-decided access (incl. a gated GitHub-installation source and a positive principal), member-sync reclaim scoping, processing recovery while dormant, projection work detection and mark release in both gate states.

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)

@waleedlatif1
waleedlatif1 requested a review from a team as a code owner September 26, 2026 01:33
@vercel

vercel Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 26, 2026 2:34am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Consolidates knowledge search around indexed and live implementations.

The PR appears safe to merge; ordinary reply links appearing in recent-source shortcuts is a non-blocking issue.

Summary

The PR consolidates knowledge retrieval around document-level access, leaves indexed organization search gated, reduces projection and sync work, and adds private organization search history and source-navigation shortcuts.

  • The subsequent changes also refactor retrieval helpers, revise search and chat controls, and add history storage and API routes.

Reviews (3) · Last reviewed commit: "improvement(search): consolidate knowled..."

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 212 files

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread apps/sim/lib/sim-search/indexed/retrieval/vector.ts
Comment thread scripts/check-indexed-org-search-boundary.ts Outdated
Comment thread apps/sim/scripts/dormant-org-search/cli.ts Outdated
Comment thread apps/sim/lib/sim-search/indexed/retrieval/legs.ts
Comment thread apps/sim/lib/knowledge/projection/run.ts Outdated
Comment thread apps/sim/scripts/dormant-org-search/disable-tin-projection.ts Outdated
Comment thread apps/sim/scripts/dormant-org-search/delete-search-index-documents.ts Outdated
Comment thread apps/sim/lib/knowledge/__integration__/search-latency.integration.ts Outdated
Comment thread apps/sim/lib/knowledge/connectors/sync-engine.ts
Comment thread scripts/check-indexed-org-search-boundary.ts Outdated
@waleedlatif1
waleedlatif1 force-pushed the chore/consolidate-knowledge-search branch from e3d9a30 to a50312d Compare September 26, 2026 01:59
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/lib/knowledge/documents/service.ts Outdated
Comment thread apps/sim/lib/knowledge/projection/run.ts Outdated
Comment thread apps/sim/app/api/v1/knowledge/search/route.test.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 193 files

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread apps/sim/lib/knowledge/application/sim-search.ts
Comment thread apps/sim/lib/knowledge/search/tag-filters.ts
Comment thread apps/sim/lib/knowledge/search/tag-filters.ts
Comment thread apps/sim/lib/knowledge/documents/service.ts Outdated
Comment thread apps/sim/lib/knowledge/projection/enqueue.ts Outdated
Comment thread apps/sim/lib/knowledge/search/vector-leg.ts
Comment thread packages/db/knowledge-projection.ts
…rch and document-decided workspace retrieval

- Move indexed organization search under lib/sim-search/indexed, dormant behind the single isIndexedOrgSearchEnabled() gate, with a check:indexed-org-search-boundary audit keeping callers on its public entry
- Decide workspace knowledge base search on the document for every principal, so workspace retrieval never waits on the projector
- Remove the knowledge-async-projection, knowledge-projection-fill and knowledge-tin-keyword flags and their code paths
- Trim the projector to a single periodic sweep that releases workspace marks before deciding whether a pass is owed
- Remove per-source vector index builds
- Scope member sync and processing recovery to the indexed search path
- Remove dead code left behind by the consolidation
- Add an ops runbook and scripts for recovering and maintaining a dormant search index
@waleedlatif1
waleedlatif1 force-pushed the chore/consolidate-knowledge-search branch from a50312d to 884cdd9 Compare September 26, 2026 02:33
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 193 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit be4461b into staging Sep 26, 2026
23 of 24 checks passed
@waleedlatif1
waleedlatif1 deleted the chore/consolidate-knowledge-search branch September 26, 2026 02:39
waleedlatif1 added a commit that referenced this pull request Sep 26, 2026
…indexes (#8333)

- Since #8314, workspace knowledge search ranks on `embedding`/`document`. The only live reader of `embedding_keyword_search` and `embedding_keyword_tin` is dormant indexed search, and only for bases that are search indexes. Yet every chunk write still upserted a keyword row, ran a Tin `DELETE` on insert, and every document insert fanned an ACL/connector sync out to the projections
- Script migration `0025_scope_keyword_projections`, all `CREATE OR REPLACE` in one transaction with the 0024 lock-timeout retry:
  - `sync_embedding_keyword_search` takes the shared membership lock and writes keyword rows only for `is_search_index` bases. On an update that moves a chunk out of a search index, it deletes the chunk's row
  - A new flip trigger backfills a base's keyword rows when it becomes a search index and deletes them when it stops being one, under the exclusive membership lock. It is separate from the Tin flip trigger, which only exists where Tin is installed. Its upsert skips unchanged rows
  - The Tin chunk trigger skips its `DELETE` on insert, since a new chunk can't have a Tin row
  - `projection_source_acl_sync` becomes `AFTER UPDATE OF connector_id, acl ... WHEN` the value actually changed. A new document has no chunks yet (FK), so the insert arm never matched anything
- The projector's keyword page writes only for search-index bases, keyed on the base flag
- Fresh installs, `db:push`, and late Tin adoption end with the same trigger definitions: 0019 installs the final guarded, key-share-locked Tin triggers, and 0025 re-runs after 0016. A `db:push` re-run of the legacy 0016 backfill may refill keyword rows for non-search bases; they're unread and left in place like the existing ones
- Both adoption backfills read their chunks `FOR KEY SHARE`, so a chunk delete racing an adoption is waited out instead of failing it
- Rollback floor: v0.9.1 and earlier ranked workspace keyword search through `embedding_keyword_search`. Once 0025 has run, don't roll back below v0.9.2, and self-hosters should upgrade through v0.9.2 or later
- Existing keyword rows for non-search bases are left in place (unread) and removed separately

This branch was successfully deployed

1 active deployment
Preview — 884cdd90 Deployed Sep 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant