Sema code review and GitHub pull requests: how is analysis bounded on very large diffs?
26.5K reputation · 17 Jan 2022, 23:27 UTC
Integration boundary
We are evaluating the Sema code-review tool connected to GitHub, where automated review comments are posted directly onto pull requests. The boundary in question is between Sema's analysis engine and the GitHub pull-request API.
Goal
Understand what happens when a pull request exceeds a practical size — many changed files, a very large diff, or long analysis time. The goal is to know whether analysis is bounded (by file count, diff size, or a time limit) and, if so, how the delivered review comments are truncated or ordered once a limit is reached.
Constraints and uncertainty
Public documentation does not appear to state a versioned contract for these limits, so behavior may be product- and version-specific. We also want to avoid assuming behavior from unrelated tools with similar names (semaphore libraries, Semgrep). Assume a current Sema release and a standard GitHub App installation; exact permission scopes and limits should be confirmed against the vendor's current documentation.
Questions
- Does Sema impose a documented cap on pull-request size or analysis duration, and what is the observable outcome when it is hit?
- When results are truncated, is there a defined ordering (e.g., by severity or file) for which comments are kept?
- Is a sandbox test on an oversized pull request the recommended way to verify this, or is a documented limit available?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 18 Jan 2022, 04:58 UTC
To build on the discussion of resource caps, it is important to distinguish between full-scan analysis and incremental analysis. Most modern static analysis engines attempt to bound the problem by evaluating only the modified Abstract Syntax Tree (AST) nodes and their immediate dependencies rather than the entire codebase.
When a pull request is exceptionally large, this incremental approach can still hit boundaries in two specific ways:
- Dependency Bloat: If a large diff modifies a core utility file used globally, the "incremental" scope may expand to include nearly the entire project, triggering the timeouts or memory caps mentioned previously.
- Cross-File False Negatives: If the tool enforces a strict file-count limit to stay within GitHub API rate limits, it may skip analyzing the relationship between a modified caller and a modified callee in different files.
To verify this behavior, check your tool's configuration for parameters like max-files or timeout, and inspect the CI logs for "truncated" or "skipped" warnings when testing with synthetic oversized PRs.