Skip to content

Claude/fix mongodb duplicates x v56n#18

Merged
mtrunkat merged 2 commits into
claude/mongodb-query-index-check-sharding-patternsfrom
claude/fix-mongodb-duplicates-xV56n
May 19, 2026
Merged

Claude/fix mongodb duplicates x v56n#18
mtrunkat merged 2 commits into
claude/mongodb-query-index-check-sharding-patternsfrom
claude/fix-mongodb-duplicates-xV56n

Conversation

@mtrunkat
Copy link
Copy Markdown
Member

No description provided.

claude added 2 commits May 18, 2026 20:01
Re-runs of the workflow on the same PR were re-posting the same inline
review comments and summary, cluttering PRs with 3-5 near-identical
reviews per commit. The prompt now fetches existing github-actions[bot]
review comments before posting and skips findings whose (path, line)
already has a non-outdated comment with the same severity marker, and
skips the whole submission when a summary already exists for the head SHA.

https://claude.ai/code/session_01M5uzeS2vPDxt8nHJ5AxvRq
- Drop the same-HEAD_SHA early-exit. With the workflow-side concurrency
  group + 'edited' trigger removed, same-SHA re-runs are rare. The
  per-comment dedup already covers the common bad case, and the dropped
  branch matched on a summary-body prefix step 4 never actually
  guaranteed.
- Reference the comment template from step 4 instead of restating all
  four severity-emoji prefixes. Less drift if the template ever changes.
- Collapse the two skip-submission cases and inline the severity write
  instead of forwarding to 'step 5'. Steps now read self-contained.
- Trim hedge wording and forward references throughout.

https://claude.ai/code/session_01M5uzeS2vPDxt8nHJ5AxvRq
Copilot AI review requested due to automatic review settings May 19, 2026 08:48
@mtrunkat mtrunkat merged commit 7479cd4 into claude/mongodb-query-index-check-sharding-patterns May 19, 2026
3 checks passed
@mtrunkat mtrunkat deleted the claude/fix-mongodb-duplicates-xV56n branch May 19, 2026 08:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the MongoDB query/index review prompt to avoid reposting identical findings across workflow reruns by introducing a deduplication step before submitting review comments.

Changes:

  • Add a new “Deduplicate against previous runs” step that queries existing PR review comments and filters out duplicates by (path, line).
  • Renumber workflow steps and adjust submission gating to “only when at least one new finding remains”.
  • Clarify that $RESULT_PATH severity must reflect all findings (including deduped ones) to avoid “greening” a previously failing check.
Comments suppressed due to low confidence (1)

mongodb-query-index-check/prompts/review.md:113

  • The dedup filter only considers comments whose author is github-actions, but GitHub Actions comments commonly come from github-actions[bot] (see repo docs). If the login includes [bot], this check will miss prior findings and dedup won’t work; consider matching github-actions[bot] (or both variants).
2. Collect comments whose `author` is `github-actions`, whose containing thread is not `is_outdated`, and whose `body` starts with the template prefix defined in step 4 (any of the four severity emojis followed by ` **MongoDB index check`).
3. Drop any finding whose `(path, line)` matches a collected comment. Outdated threads don't count — line numbers shift across commits, so a fresh finding on a shifted line is a new finding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


A previous run on this PR may have already posted some of these findings. Filter duplicates before posting:

1. Call `mcp__github__pull_request_read` with `method: get_review_comments` and `pullNumber: $PR_NUMBER`. The response is a list of review threads; each has `is_outdated` and a `comments` array (every comment has `author`, `body`, `path`, `line`).
mtrunkat added a commit that referenced this pull request May 19, 2026
## What changed

Extensions to `prompts/review.md` for `mongodb-query-index-check`,
sourced from apify-core post-mortems and team feedback during review:

- **Sharded patterns.** Pattern #3 now bakes in the real
`ShardAwareCollection` constructor signature (`new
ShardAwareCollection<TSchema, TShardKeys>(collection, shardKeys[],
openTelemetry?)`) and tells Claude to grep the workspace for `new
ShardAwareCollection<` to find shard keys per collection.
Mechanism-first treatment of `readConcern: 'available'` so Claude can
reason about novel cases. `ShardAwareCollection` exposes
`approximateCountDocuments` (wrapped) — *not* `countDocuments`, so plain
`.countDocuments()` on a sharded raw collection IS flag-worthy.
- **Heavy-index hint** (🟡 medium). Flag queries on 40+-index collections
lacking `hint:`.
- **Missing projection** (🟡 medium). Closes apify-core#19762. Flags
reads without `projection` (wastes IO + BSON parse on multi-KB docs).
- **Prefer reusing existing indexes.** Rewritten "Suggested action": (1)
adjust the query, (2) extend an existing index, (3) only as last resort
propose a new one. Per the [Slack
thread](https://apify.slack.com/archives/C01VBUV81UZ/p1779168107624789?thread_ts=1779107433.941669)
— busy collections already have too many indexes and the goal is to
shrink that surface, not grow it.
- **Cross-run dedup** (already merged via #18) — Claude drops findings
at the same `(path, line)` as prior bot comments before posting.

## Tests

`pnpm run lint` / `type-check` / `test` — clean, 35/35. envsubst
allowlist unchanged.

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

4 participants