Repository navigation
fix(rag): apply channel scope before retrieval limit - #27
Merged
Merged
Conversation
Co-authored-by: OpenAI Codex <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apply the existing channel restriction inside Chroma before selecting the top-k results, so globally higher-ranked messages from other channels cannot crowd out useful context. Keep the payload safeguard and preserve unscoped retrieval and current document visibility.
Part of #3
Closes #25
Verification used a cleared environment,
MISE_NO_ENV=1, frozen dependencies after installation, andUV_PYTHON=3.13. No real Slack or model tokens or.envfiles were read or changed.mise run installpassed with Python 3.13. The initial automatic Python 3.14 selection lacked a compatible ONNX wheel; rerunning with the configured Python version succeeded.mise run test-backendpassed, including five new local Chroma regressions. Before the implementation, the fixture produced four failures and one pass; API and Slack paths both forwarded empty context.mise run test-frontendpassed its existing placeholder command (No frontend tests yet).mise run test-runtimepassed with local listener permission. The first sandboxed attempt could not bind loopback listeners.mise run dev-backendstarted successfully on 127.0.0.1:18025, returned HTTP 200 for health and the fixture ask request, then stopped cleanly.git diff --checkpassed. No schema changes or migrations.The RAG fixture uses fixed embeddings and temporary local Chroma storage. Two COTHER messages rank ahead globally; the CTARGET query still returns both CTARGET messages. A missing channel returns no results without falling back to global retrieval. Chroma telemetry is disabled in the tests.
The HTTP capture used temporary SQLite/Chroma storage, mocked Slack authentication, blocked Slack API calls and a mock runtime. The answer below is a fixture response, not model-generated proof.
{"answer":"Fixture only - context forwarded to the mock runtime.","sources":[{"channel_id":"CTARGET","source":"slack"},{"channel_id":"CTARGET","source":"slack"}],"confidence":"low"}The captured payload forwarded to the mock runtime was
{"request_id":"fixture-api-proof","conversation_id":"request:fixture-api-proof","question":"How do I connect?","context":"From slack:\nTarget channel first\n\nFrom slack:\nTarget channel second","sources":[{"channel_id":"CTARGET","source":"slack"},{"channel_id":"CTARGET","source":"slack"}]}No dashboard UI changed, so no screenshot was needed. No Slack posts, DMs, Socket Mode connections or live model calls were made. Live Slack delivery is unverified by design. Shared documents and uploads without channel metadata retain their existing visibility; this slice does not introduce a sharing policy or an authorisation boundary. The separate empty-collection indexing bug discovered during fixture setup is tracked in #26.
GitHub CI passed lint-and-test and all three image builds at 16da4d4. CodeQL and Socket Security pull request checks also passed; the Socket Security project report was skipped.