Skip to content

feat: ask for merge risk in the run and keep it in the artifact and the review comment - #179

Merged
ivanmilevtues merged 6 commits into
mainfrom
feat/merge-risk-in-run
Nov 29, 2026
Merged

ivanmilevtues merged 6 commits into
mainfrom
feat/merge-risk-in-run

Conversation

@Svilen-Stefanov

@Svilen-Stefanov Svilen-Stefanov commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Ask for merge risk in the run, and keep the answer where the web platform reads it, so the webview never calls the service.

What

  • scripts/remote_features.py makes a third request beside the review guide and architecture, POST /v1/merge-risk, with the same bearer (OIDC plus license, or the run's token), asked for once and shared by all three. It sends no analysis: {version: 1, repo, pr, files: [{filename, additions, deletions, patch}]}, xz.
  • The file list is the pull request's, as GitHub lists it (GET /pulls/{n}/files, 100 a page, at most 3,000 files, a very large file without its patch). It is read after the head is checked: if the pull request moved on to a newer head during the run, nothing is sent, since the newer run answers for that head.
  • closed_features_source: false keeps merge risk's patches on the runner (the review guide's request still carries the changed files; this input never governed it). Merge risk then sends each file's path, additions and deletions with patch: null, so the diff's size and the areas its paths fall in still count. It reads the setting through source_allowed, the same check collect_source uses. README (the merge-risk paragraph, the source paragraph and the inputs table) and the input's description say so.
  • Withheld patches are said, not silent. Without patches licensing cannot run the mention and dependency checks; its answer says so in facts.patches (all, some, none), the run logs ::notice::merge-risk read none of the patches (...), and the comment line carries patches, so the web platform shows it instead of reading the silence as clean.
  • Patches go cheaply on a huge diff. Merge risk compresses at xz preset 1 (about 60 MB/s) rather than the guide's 9e (about 3 MB/s), since nothing keeps its request. A file list over ten times the compressed limit drops its patches before compressing; one under it that still does not fit drops them after. The guide's and architecture's requests are unchanged.
  • It is submitted before the analysis is collected and does not depend on it or on the guide; a failure prints one ::notice:: and writes nothing. When getting credentials fails, nothing is sent and merge risk logs its own ::notice::merge-risk failed: getting credentials failed: ... beside the guide's.
  • The answer is written to closed/merge_risk.json in the review artifact (with repo, pr, headSha) before the upload step.
  • The same step hands the review comment one hidden line as its merge_risk_line output, and build-review-comment.sh prints it before the existing machine-readable line: <!-- codeboarding:merge_risk {json} --> with the head sha, sensitive, critical area names, up to 20 dependency names, srcLines, sourceFiles, and each reason's level, code and params. The JSON escapes <, >, - and = so nothing in it can end the comment or match the status line's key=value reader. The existing marker stays the last line. The line and the stored JSON are both built before either is written, so an answer the line cannot carry leaves neither behind.
  • README and the review_guide_url input description mention the third request.

Asking for the guide when the service cannot call the run's provider moved to https://app.codeboarding.org/CodeBoarding/CodeBoarding-action/pull/180, which waits on licensing #70.

Related

Tests

tests/test_remote_features.py: the request body, the stored file and the step output, isolation in both directions (merge risk failing or skipped leaves the guide and architecture alone; missing analysis inputs leave merge risk alone), dropping patches over the limit, reading every page of the file list, skipping a head that moved on, and the hidden line's escaping and round trip. New with the review: source turned off sends no patches (false and False) and on sends them; a credentials failure logs both notices and sends nothing; an answer the line cannot carry writes neither file nor line; merge risk compresses at preset 1 while the guide stays at 9e; a 44 MB diff goes out without patches, compressed once, well under five seconds. tests/test_review_comment.py: the line's position, and no line without one. Full suite: 374 tests OK (9 skipped). Black clean; no shell changed since the last review.

Size, product code without tests: +184 / -29, 155 net.

Nothing visible changes in the comment: the line is an HTML comment.

Not tagged or released.

🤖 Generated with Claude Code

…ment

A third request beside the review guide and architecture, POST
/v1/merge-risk, sends the files changed between the merge base and the
head with their patches. They come from git in the checkout, not the
compare API, which stops at 300 files; the checkout is one commit deep, so
the merge base is fetched by sha with the run's token passed through the
environment. A patch over 300 KB is left out, and the patches go when the
request would be over the service's limit.

The answer is written to closed/merge_risk.json in the review artifact
with the head and base it describes, and summed up in one hidden line of
the review comment, <!-- codeboarding:merge_risk {json} -->, for the web
platform's dashboard. The JSON escapes <, >, - and = so nothing in it can
end the comment or match the status line's reader.

It runs from the start, whatever happens to the analysis inputs or the
guide, and a failure is one notice that writes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codeboarding-review

codeboarding-review Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

CodeBoarding review

Status: 1 changed component

See the full change in CodeBoarding.

graph LR
    n_Action_Workflow_and_Analysis_Execution["Action Workflow and Analysis Execution"]
    n_Remote_Review_and_Problem_Ledger["Remote Review and Problem Ledger"]
    n_Remote_Review_and_Problem_Ledger -- "validates credentials and requests tokens throu…" --> n_Action_Workflow_and_Analysis_Execution
    classDef added fill:#1f883d,stroke:#0b5d23,color:#ffffff;
    classDef modified fill:#bf8700,stroke:#7d4e00,color:#ffffff;
    classDef deleted fill:#cf222e,stroke:#82071e,color:#ffffff,stroke-dasharray:5 3;
    class n_Remote_Review_and_Problem_Ledger modified;
    linkStyle 0 stroke:#0b5d23,stroke-width:2px;
Loading

download artifacts · run 45927324207

Svilen-Stefanov and others added 2 commits November 26, 2026 22:56
The file list now comes from GitHub's pull request files, page by page, instead of fetching the
merge base by sha and parsing `git diff` in the checkout; a run whose head moved on during it
sends nothing, since a newer run answers for that head. The bearer is asked for once and shared,
so the lock around it goes, and the comment's hidden line is built in remote_features.py and
handed to the comment step as an output, so merge_risk_marker.py goes too. The line no longer
carries tests and dirs, which nothing reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ew findings

- closed_features_source: false now reaches merge risk: it sends each changed file's path,
  additions and deletions with patch null, read through the same source_allowed check that
  collect_source uses. README and the input description say so.
- A credentials failure logs its own merge-risk notice beside the guide's; before, merge risk was
  never submitted and said nothing.
- The comment line and the stored JSON are both built before either is written, so an answer the
  line cannot carry leaves neither behind.
- Merge risk compresses at xz preset 1 instead of 9e, and a file list over ten times the compressed
  limit drops its patches before compressing. The guide's and architecture's requests are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Svilen-Stefanov Svilen-Stefanov changed the title Ask for merge risk in the run; keep it in the artifact and the comment feat: ask for merge risk in the run and keep it in the artifact and the review comment Nov 27, 2026
Svilen-Stefanov and others added 3 commits November 27, 2026 02:31
With source off or a diff too large, the request goes without patches and licensing's mention and
dependency checks cannot run. The answer now says so (`facts.patches`), the run logs a notice, and
the comment line carries `patches` for the web platform. The README says the input does not keep
code from the review guide's request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Escaping `-` would turn a negative number into invalid JSON; escaping `>` already keeps `-->` out.
The line is now left out, with a notice, when it would take more than 8,000 characters of a comment
GitHub caps at 65,536; the artifact still carries the result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ivanmilevtues
ivanmilevtues marked this pull request as ready for review November 29, 2026 03:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T03:54:51.857765Z 9c9564e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ivanmilevtues
ivanmilevtues merged commit 59bc90d into main Nov 29, 2026
5 checks passed
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.

2 participants