brevio-core

Catches the mistakes coding agents repeat before they merge: a pull-request gate with no model call and no API key.

View the Project on GitHub Brevio-Ventures/brevio-core

R4.3: N+1 query prevention

Short answer: Batch queries with IN / joins instead of per-row loop queries. One query per row turns a page of 100 rows into 101 round trips.

Group: Database and migrations. Status: stable. Generated from the rule definitions; do not edit by hand.

Playground: https://brevio.pro/tools/agent-guard-playground?rule=R4.3

What it catches

N+1 query prevention: batch queries with IN / joins instead of per-row loop queries.

Why

One query per row turns a page of 100 rows into 101 round trips.

A bad example

for (const u of users) await db.orders.where({ userId: u.id });

A good example

await db.orders.where({ userId: { in: users.map((u) => u.id) } });

How it is checked

How to silence it

A person can silence one finding with brevio-core: ignore R4.3 -- reason on the line or the line above. Without the reason it does not count. An agent cannot silence it: the agent hook and the MCP tools never honour the comment, and a pull request that adds one is reported until a reviewer allows it. Fixing the code is still the better answer.

To change what the rule flags, edit its definition in dev_rules.py or code_rules/__init__.py. That is a code change and is reviewed like one.