🧩 fix: Support DocumentDB Prompt Group Lookup#13232
Conversation
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR updates getPromptGroup’s aggregation to use a DocumentDB-compatible $lookup shape while preserving tenant isolation semantics, and adds regression tests to prevent reintroducing the unsupported lookup form.
Changes:
- Replaced
$lookupusinglet/pipelinewith alocalField/foreignFieldjoin for DocumentDB compatibility. - Preserved tenant safety by nulling
productionPromptwhen a non-system tenant joins a prompt from another tenant. - Added Jest coverage for tenant match/mismatch, system tenant behavior, missing groups, string
_idcasting, and the emitted$lookupshape.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/data-schemas/src/methods/prompt.ts | Switched getPromptGroup aggregation to DocumentDB-compatible $lookup and added post-join tenant guard. |
| packages/data-schemas/src/methods/prompt.getPromptGroup.spec.ts | Added regression tests for tenancy behavior and to assert $lookup does not use let/pipeline. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
GitNexus: 🚀 deployedThe |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
GitNexus: 🚀 deployedThe |
* fix: support DocumentDB prompt group lookup * test: address prompt group review feedback * test: prove prompt group indexed lookup
* fix: support DocumentDB prompt group lookup * test: address prompt group review feedback * test: prove prompt group indexed lookup
Summary
I split the prompt-group DocumentDB compatibility fix into its own PR and kept it scoped to
getPromptGrouplookup behavior.$lookupform that usedletandpipelinewith a simplelocalField/foreignFieldlookup that is compatible with DocumentDB-style lookup support.productionPromptafter the join when a non-system tenant context sees a joined prompt from a different tenant._id, and the emitted lookup shape._idexecution paths, including_id_for the joined prompt andtotalDocsExamined <= 1for that lookup.Change Type
Testing
npx jest --runTestsByPath src/methods/prompt.spec.ts src/methods/prompt.getPromptGroup.spec.ts --runInBand --coverage=falsenpx tsc --noEmit -p packages/data-schemas/tsconfig.jsonnpm run build:data-schemasgit diff --checkTest Configuration:
mongodb-memory-server.getPromptGroupdoes not emit$lookup.letor$lookup.pipeline._idplan and the production prompt lookup uses the_id_index withtotalDocsExamined <= 1.Checklist