← Back to Pull requests

Ci/dejadoc duplicate doctests #5216

Closed
unknown closed this pull request without merging on Oct 02, 2026 07:52 UTC
View on GitHub
unknown unknown commented on Sep 17, 2026 20:24 UTC
Author

Duplicated doctests slip in either through tiredness, a doc pasted from its neighbour and half-adapted, or an LLM regurgitating an existing doctest when writing a new one.

For instance, I nearly missed a duplicated doctest while reviewing #5198, where the LikeAny and ILikeAny struct docs repeated examples that the method doctests already run. Both copies compile and pass CI, rustdoc just runs the same test twice, so nothing else would flag them.

Since these kind of thing can be detected statically, I decided to write cargo-dejadoc, a well tested crate + GitHub Action.

It parses the code statically and canonicalizes every doctest rustdoc would run, reports clones, and ships as a GitHub Action that comments on the copies to remove, each linked to the copy that survives with a removal suggestion. The check, not requiring the code to actually build, is fairly fast, locally takes for diesel 0.4s.

In its default mode, which is how I propose to configure it, it reports only duplicates a pull request introduces (all existing duplicates in diesel have now been taken care of).

In fact, I ran a scan of current main and unexpectedly found 8 duplicated groups, 13 redundant copies out of 536 doctests.

The worst offenders are the doctests under jsonb_group_array call json_group_array instead, so the JSONB aggregate currently has no doctest coverage at all. I fixed these and the other mentioned cases in #5213, #5214, and #5215

In this PR, the `rust,dejadoc notation is to denote duplicated tests which we expect to appear as duplicates.

The workflow runs on pull_request_target rather than pull_request because fork PRs get a read-only token and the action review comments would not post, it checks out the pull request head with persist-credentials: false.

Diff: 233 lines (+174 / -59) across 2 files Reviewer: weiznich Review duration: 20848m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 233 lines diff across 2 files
0.42
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.326
Shallow Review Depth shallow_review_depth
0.289
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #5216"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 42.1% (MEDIUM) · Higher = larger blast radius
42.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 16.6% · Safe to merge
16.6%