Binding the tenant scope with `let _ =` drops the guard at once, so the digest reads every tenant's rows
Tier 1 easy rust · cross-file · authored, execution-grounded case
Ground-truth defects
The diff adds tenant scoping to build_digest with `let _ = ctx.enter(tenant);`. In Rust `let _ = expr` is not a binding — it discards the value immediately, so the guard's Drop runs at the end of that statement and the tenant is no longer current on the very next line. (`let _scope = ...` would hold it for the body.) The same form also suppresses the `#[must_use]` on `enter`, so the one warning that would have caught it never fires. The unchanged store.rs then decides what an unscoped read means, and it is documented there: an unscoped caller is the maintenance context, so visible_rows returns a FULL TABLE rather than nothing. Every tenant's rows land in every tenant's digest — a cross-tenant data leak that compiles clean, raises nothing, and looks in the diff exactly like the scoping it is missing.
The change under review
diff
@@ -1,7 +1,11 @@ use crate::context::TenantCtx; use crate::store::Store; -/// Build the digest for whichever tenant the caller has entered. -pub fn build_digest(ctx: &TenantCtx, store: &Store) -> Vec<String> { +/// Build the digest for `tenant`. +/// +/// The nightly worker calls this outside any request, so there is no tenant entered yet and the +/// digest has to enter one itself. +pub fn build_digest(ctx: &TenantCtx, store: &Store, tenant: u64) -> Vec<String> { + let _ = ctx.enter(tenant); store.visible_rows(ctx).into_iter().map(|row| row.body).collect() }
Leaderboard for this case
easy · 9 of 9 bots fully caught it (100% solve rate) · 100% avg coverage.
| # | Bot | Result | Caught | Coverage | Findings | False alarms |
|---|---|---|---|---|---|---|
| 1 | Claude Code (Opus 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 2 | Cubic | solved | 1/1 | 100.0% | 1 | 0 |
| 3 | cursor | solved | 1/1 | 100.0% | 1 | 0 |
| 4 | Drape (Deep Review) | solved | 1/1 | 100.0% | 1 | 0 |
| 5 | Drape (Review) | solved | 1/1 | 100.0% | 1 | 0 |
| 6 | greptile | solved | 1/1 | 100.0% | 1 | 0 |
| 7 | Mjolnir (Opus 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 8 | Mjolnir (Sonnet 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 9 | qodo | solved | 1/1 | 100.0% | 1 | 0 |
Bot results
Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
`let _ =` drops the TenantScope guard right away, and its Drop impl (`self.ctx.current.replace(self.previous)`) puts back whatever tenant was current before. So `visible_rows` never runs under `tenant`: it runs under the caller's tenant, or unscoped (the maintenance context) for the nightly worker. The headline's 'silently override' framing gets the mechanism slightly wrong, but the comment points at the dropped guard, and the claimed failure is real and comes from this change: the explicit `tenant` doesn't reliably apply, and callers get rows from the wrong tenant. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
`let _ = ctx.enter(tenant);` drops the `TenantScope` guard straight away, because the `_` pattern never binds the value. That also silences the `#[must_use]` warning. The previous tenant comes back before `visible_rows` runs. When the nightly worker calls this, nothing was entered before, so the context is unscoped and `Store::visible_rows` treats it as the maintenance context and does a full-table read. Every tenant's digest would then contain every other tenant's rows, which is a cross-tenant data leak. Bind the guard to a named variable such as `let _scope = ctx.enter(tenant);` so it stays alive through the read.
The signature now takes both a context and an explicit `tenant`. If a caller already has a different tenant entered, this function quietly switches to `tenant`, and in the current code it switches straight back because the guard is dropped. Callers can no longer tell which tenant actually applies. Consider checking `ctx.current()` for a conflict, or documenting that the explicit `tenant` takes precedence.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (2)
<!-- cubic:v=a0ef1079-8660-4ba2-8e91-9001c6953810 -->
<!-- cubic:review-run=b199f22a-bf09-50e4-80fc-6a029c544978 -->
<!-- metadata:{"confidence":10} -->
P1: The `_` pattern drops the `TenantScope` immediately, so `visible_rows` runs unscoped and includes every tenant's rows. Bind the guard to a named variable so it stays alive through the read.
<details>
<summary>Prompt for AI agents</summary>
```text
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At digest.rs, line 9:
<comment>The `_` pattern drops the `TenantScope` immediately, so `visible_rows` runs unscoped and includes every tenant's rows. Bind the guard to a named variable so it stays alive through the read.</comment>
<file context>
@@ -1,7 +1,11 @@
+/// The nightly worker calls this outside any request, so there is no tenant entered yet and the
+/// digest has to enter one itself.
+pub fn build_digest(ctx: &TenantCtx, store: &Store, tenant: u64) -> Vec<String> {
+ let _ = ctx.enter(tenant);
store.visible_rows(ctx).into_iter().map(|row| row.body).collect()
}
</file context>
```
</details>
```suggestion
let _scope = ctx.enter(tenant);
```
<!-- cubic:review-summary:start -->
**1 issue found** across 1 file
<!-- cubic:review-summary:end -->
<details>
<summary>Prompt for AI agents (unresolved issues)</summary>
```text
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="digest.rs">
<violation number="1" location="digest.rs:9">
P1: The `_` pattern drops the `TenantScope` immediately, so `visible_rows` runs unscoped and includes every tenant's rows. Bind the guard to a named variable so it stays alive through the read.</violation>
</file>
```
</details>
<sub>Reply with feedback, questions, or to request a fix.<br /><br />[View guided diff](https://www.cubic.dev/pr/drape-io/crbench-cubic-2026-09/pull/113?utm_source=github&utm_medium=review_footer) | [Turn on auto-fix](https://www.cubic.dev/action/auto-fix/pr/drape-io/crbench-cubic-2026-09/113?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F113) | [Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/113/ai_pr_review_github_delivery_72e5d67d12493443700014e68c11aba23ec2e5a19d1392f28829695bedd7f87b?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F113)</sub>
<!-- cubic:review-post:ai_pr_review_github_delivery_72e5d67d12493443700014e68c11aba23ec2e5a19d1392f28829695bedd7f87b:edadef8b7190fae3e6d51e97cd2f8c7c157b7cea:b199f22a-bf09-50e4-80fc-6a029c544978 -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (2)
### Tenant guard dropped before digest read
**High Severity**
<!-- DESCRIPTION START -->
`enter` returns a `TenantScope` that keeps the tenant current only while that guard lives. Binding it with `let _ =` drops the guard immediately, so `visible_rows` runs unscoped and returns every tenant's rows instead of just the requested tenant.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 3680342e-0a7a-4eb2-ae10-bb5e53ec7401 -->
<!-- LOCATIONS START
digest.rs#L8-L10
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVlN2E4Mjc0LTVmNzAtNGExNi05OThmLTg0YjkyYjQ4NDNhMiIsImVuY3J5cHRpb25LZXkiOiJ4SWkweEw1aHNDdnNmSkVDUVNhejl5NVNMaXA5bE5XU0xkMzVSbVhibUdVIiwiYnJhbmNoIjoicHItY2VkNDBhOTY3YyIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVlN2E4Mjc0LTVmNzAtNGExNi05OThmLTg0YjkyYjQ4NDNhMiIsImVuY3J5cHRpb25LZXkiOiJ4SWkweEw1aHNDdnNmSkVDUVNhejl5NVNMaXA5bE5XU0xkMzVSbVhibUdVIiwiYnJhbmNoIjoicHItY2VkNDBhOTY3YyIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjExMywiY29tbWl0U2hhIjoiMDFhZjk3NTE5ZDJjYjc5ZmMwYTc5ODA5Mzk1YWEyMGI3MWU4NGUxMyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 01af97519d2cb79fc0a79809395aa20b71e84e13. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTpkNzIwOTQxMi0yMjJjLTRkNDQtOWZjNC0zZWRhNzFhZGM5MTQiLCJlbmNyeXB0aW9uS2V5IjoialhGamZ5aGgwdzVsTklqaDk1eDBaSm9tVkNXRFk3dFN5bXZIZVFIVENCbyIsImJyYW5jaCI6InByLWNlZDQwYTk2N2MiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 01af97519d2cb79fc0a79809395aa20b71e84e13. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
raw comments (1)
**Digest includes every tenant's rows**
`let _ =` drops the guard from `ctx.enter` immediately, so no tenant is current when `visible_rows` runs; from the nightly worker that's a full-table read. Bind the guard to a named variable, e.g. `let _scope = ctx.enter(tenant);`.
```
digest.rs:8 pub fn build_digest(ctx: &TenantCtx, store: &Store, tenant: u64) -> Vec<String> {
digest.rs:9 let _ = ctx.enter(tenant);
context.rs:38 impl Drop for TenantScope<'_> {
context.rs:39 fn drop(&mut self) {
context.rs:40 self.ctx.current.replace(self.previous);
context.rs:41 }
store.rs:24 match ctx.current() {
store.rs:25 Some(tenant) => self.rows.iter().filter(|r| r.tenant == tenant).cloned().collect(),
store.rs:26 None => self.rows.clone(),
context.rs:26 #[must_use = "the tenant is only current while the returned guard is alive"]
```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
raw comments (1)
**Tenant scope dropped immediately; digest leaks all tenants**
`let _ = ctx.enter(tenant);` drops the guard at once, so the tenant is restored to None before `visible_rows` runs. The unscoped read is a full-table read, so the digest contains every tenant's rows. Bind the guard: `let _scope = ctx.enter(tenant);` so it lives until the function returns.
```
digest.rs:9 let _ = ctx.enter(tenant);
```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (2)
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> <a href="#"><img alt="security" src="https://greptile-static-assets.s3.amazonaws.com/badges/Security.svg?v=2" align="top"></a> **Digest includes other tenants**
`let _ = ctx.enter(tenant)` drops the returned `TenantScope` before `visible_rows` runs. For the unscoped nightly worker described here, that restores `None`, so the digest returns every tenant's row bodies instead of only the requested tenant's. Keep the guard alive with `let _scope = ctx.enter(tenant);` until the read finishes.
**How this was verified:** `TenantScope::drop` restores the previous tenant, and `visible_rows` returns all rows when that tenant is `None`.
```suggestion
let _scope = ctx.enter(tenant);
```
<!-- greptile_summary -->
<h2><a href="https://app.greptile.com/api/retrigger?id=76825572"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a>Confidence Score: 3/5</h2>
**[Medium risk]** Nightly digest now manages tenant context directly\.
Do not merge until the digest keeps its tenant guard alive through the read.
<h2>Findings</h2>
1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"> <img alt="Security" src="https://greptile-static-assets.s3.amazonaws.com/badges/Security.svg?v=2" align="top"> **Digest includes other tenants** <a href="https://github.com/drape-io/crbench-greptile-2026-09/pull/113#discussion_r4214133048">▶</a>
<h3>Summary</h3>
`build_digest` now accepts a tenant and tries to enter it for the nightly worker.
- The returned guard is dropped before the read.
- Keep the guard alive so the digest only includes the requested tenant's rows.
<details open><summary>Diagram</summary>
```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Nightly worker: no tenant entered"] --> B["build_digest enters requested tenant"]
B --> C["Discarded guard restores no tenant"]
C --> D["visible_rows returns all rows"]
D --> E["Digest contains every tenant's data"]
```
</details>
<!-- greptile_confidence_score:3 -->
<sub>Reviews (1) · Last reviewed commit: ["Enter the tenant inside the nightly dige..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/fd916c0e9a7b9eb41fa29e31aa3fde4129caf869) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_expert&utm_medium=github&utm_campaign=code_reviews&utm_content=drape-io/crbench-greptile-2026-09)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
`enter` returns a TenantScope whose Drop restores the previous tenant (context.rs:38-41). `let _ =` drops the guard right away, so `visible_rows` sees `None` and does a full-table read across all tenants (store.rs). [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
[P0] Tenant scope guard is dropped immediately, so the digest reads every tenant's rows
`let _ = ctx.enter(tenant);` drops the `TenantScope` guard right away, because `_` doesn't bind anything. Dropping the guard restores the previous tenant before `visible_rows` runs. The nightly worker calls this with no tenant entered, so the context is unscoped again by the time of the read. `Store::visible_rows` treats an unscoped context as the maintenance context and returns the full table. As a result, each tenant's digest contains every tenant's row bodies, which leaks data across tenants. The `let _ =` also silences the `#[must_use]` warning on `enter` that would have caught this. The guard needs to be bound to a named variable such as `_scope` so it stays alive through the read.
[P0] `let _ =` drops the tenant guard right away, so the digest reads every tenant's rows
`ctx.enter(tenant)` returns a `TenantScope` guard, and the tenant only stays current while that guard is alive. Binding it with `let _ =` doesn't keep it: Rust drops it at the end of that statement, and the `#[must_use]` warning is silenced too. When the guard drops it restores the previous context. For the nightly worker, which this change targets, the previous context is unscoped (`None`). So `store.visible_rows(ctx)` runs in the maintenance context, and `store.rs` says that is a full-table read across all tenants. Each tenant's digest would then include every other tenant's rows, which leaks data between tenants. The guard needs a named binding such as `_scope` so it lives until the read is done.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
`let _ =` drops the TenantScope right away, and its Drop impl (context.rs) restores `previous` (None in the worker). So visible_rows sees None and returns self.rows.clone(), which is every tenant's rows: a cross-tenant leak. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
[P0] Tenant guard dropped immediately, digest leaks all tenants' rows
`let _ = ctx.enter(tenant);` drops the returned `TenantScope` guard at the end of that statement, because `let _` does not bind the value. The tenant is therefore restored to its previous state (`None` in the nightly worker) before `store.visible_rows(ctx)` runs. `visible_rows` treats an unscoped context as a full-table maintenance read, so `build_digest(ctx, store, tenant)` returns every tenant's rows instead of only `tenant`'s. This is a cross-tenant data leak. It happens in the exact case the new code targets, a nightly worker calling it outside any request. Bind the guard to a named variable, e.g. `let _scope = ...`, so it lives until the end of the function. The `#[must_use]` on `enter` does not fire for `let _ =`.
[P0] Tenant guard dropped immediately, digest reads all tenants' rows
`let _ = ctx.enter(tenant);` drops the returned `TenantScope` on the spot, because `_` doesn't bind the value. The previous tenant is restored before `store.visible_rows(ctx)` runs, and the `#[must_use]` warning is suppressed. In the nightly worker path, which the new doc comment says runs with no tenant entered, `ctx.current()` is `None`. `visible_rows` treats that as the maintenance context and returns every tenant's rows. The digest for `tenant` then contains other tenants' data, which is a cross-tenant data leak. Bind the guard to a named variable such as `_scope` so it lives until the end of the function.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (3)
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
1\. Nightly digests leak other tenants' rows <code>🐞 Bug</code> <code>⛨ Security</code>
<pre>
<b><i>build_digest</i></b> discards the guard returned by <b><i>ctx.enter(tenant)</i></b>, which immediately restores the
previous tenant before <b><i>visible_rows</i></b> runs. When the nightly worker starts without an entered
tenant, <b><i>visible_rows</i></b> performs a full-table read and the digest includes rows belonging to other
tenants.
</pre>
<details>
<summary><strong>Agent Prompt</strong></summary>
```
## Issue description
The tenant guard is dropped before the digest reads rows, leaving the nightly worker in the unscoped maintenance context.
## Fix Focus Areas
- digest.rs[8-10]
## Recommended Fix
Bind the guard to a named local variable so it remains alive through the `visible_rows` call.
```
<code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
</details>
[Dismiss ↗](https://app.qodo.ai/findings/c10d6820-1fc5-415a-bd88-989d047f8794?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/c10d6820-1fc5-415a-bd88-989d047f8794)
<h3>Code Review by Qodo</h3>
<code>🐞 Bugs (1)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<br/>
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
<details>
<summary> 1. Nightly digests leak other tenants' rows <code>🐞 Bug</code> <code>⛨ Security</code></summary>
<br/>
> <details open>
><summary>Description</summary>
><br/>
>
><pre>
><b><i>build_digest</i></b> discards the guard returned by <b><i>ctx.enter(tenant)</i></b>, which immediately restores the
>previous tenant before <b><i>visible_rows</i></b> runs. When the nightly worker starts without an entered
>tenant, <b><i>visible_rows</i></b> performs a full-table read and the digest includes rows belonging to other
>tenants.
></pre>
></details>
> <details>
><summary>Code</summary>
><br/>
>
><code>[digest.rs[9]](https://github.com/drape-io/crbench-qodo-2026-09/pull/113/files#diff-a8a30b93bea1d91b027ea4e6a62bf4bf3e82f18e772d0e2942d71edcbea6a535R9-R9)</code>
>
>```diff
>+ let _ = ctx.enter(tenant);
>```
></details>
> <details>
><summary>Evidence</summary>
><br/>
>
><pre>
><b><i>enter</i></b> returns a scope guard, whose <b><i>Drop</i></b> restores the previous tenant. The store returns all rows
>when no tenant is current, and the new digest code discards that guard before calling the store.
></pre>
>
> <code>[digest.rs\[8-10\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/eb4c7a51ac9fb6fc0f947769d061f46154344b34/digest.rs/#L8-L10)</code>
> <code>[context.rs\[23-27\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/eb4c7a51ac9fb6fc0f947769d061f46154344b34/context.rs/#L23-L27)</code>
> <code>[context.rs\[36-40\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/eb4c7a51ac9fb6fc0f947769d061f46154344b34/context.rs/#L36-L40)</code>
> <code>[store.rs\[20-28\]](https://github.com/drape-io/crbench-qodo-2026-09/blob/eb4c7a51ac9fb6fc0f947769d061f46154344b34/store.rs/#L20-L28)</code>
></details>
> <details>
><summary>Agent prompt</summary>
><br/>
>
>```
>The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
>
>## Issue description
>The tenant guard is dropped before the digest reads rows, leaving the nightly worker in the unscoped maintenance context.
>
>## Fix Focus Areas
>- digest.rs[8-10]
>
>## Recommended Fix
>Bind the guard to a named local variable so it remains alive through the `visible_rows` call.
>```
> <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
></details>
[Dismiss ↗](https://app.qodo.ai/findings/c10d6820-1fc5-415a-bd88-989d047f8794?action=dismiss&origin=git) | [View ↗](https://app.qodo.ai/findings/c10d6820-1fc5-415a-bd88-989d047f8794)
<hr/>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-context:start -->
<details><summary><strong>Context sources</strong></summary>
<div>Review mode: <code>Auto: ⚖️ Balanced</code>: Changes tenant context behavior in a nightly data-generation path.</div>
<!-- qodo-context:end -->
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:start -->
<details>
<summary><strong>Tip of the day</strong></summary>
<br/>
<pre>💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link</pre>
<a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:end -->
<!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/eb4c7a51ac9fb6fc0f947769d061f46154344b34 -->
<a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>
<h3>PR Summary by Qodo</h3>
Scope nightly digests to the requested tenant
<code>🐞 Bug fix</code> <code>🕐 Less than 10 minutes</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<details>
<summary>AI Description</summary>
<dl>
<dd>
<br/>
><pre>
>• Enter the requested tenant before reading rows for a nightly digest.
>• Prevent unscoped worker reads from including other tenants’ data.
></pre>
</dd>
</dl>
</details>
<details>
<summary>Diagram</summary>
<dl>
<dd>
<br/>
```mermaid
graph TD
Worker["Nightly worker"] --> Digest["Digest builder"] --> Scope["Tenant scope"] --> Store["Row store"] --> Result["Tenant digest"]
```
</dd>
</dl>
</details>
<details>
<summary>High-Level Assessment</summary>
<dl>
<dd>
<br/>
>Entering the tenant inside the digest is appropriate because the worker has no request scope. The existing guard confines the store read and restores the previous context; moving scoping to callers or changing the store API would broaden this focused fix.
</dd>
</dl>
</details>
<details>
<summary> Files changed (1) <code> +6 / -2 </code> </summary>
<dl>
<dd>
<br/>
<details>
<summary>Bug fix (1) <code> +6 / -2 </code></summary>
<dl>
<dd>
<details>
<summary>digest.rs<code>Enter the requested tenant while building a digest</code> <code>+6/-2</code></summary>
<br/>
>Enter the requested tenant while building a digest
>
><pre>
>• Adds a tenant argument and enters its scope before reading visible rows. This prevents an unscoped nightly invocation from reading rows across all tenants.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/113/files#diff-a8a30b93bea1d91b027ea4e6a62bf4bf3e82f18e772d0e2942d71edcbea6a535'>digest.rs</a>
</details>
</dd>
</dl>
</details>
</dd>
</dl>
</details>