Skip to content

Add ci review --annotations to show findings on the pull request diff - #52

Merged
mohsen1 merged 3 commits into
prooflinedev:mainfrom
HookWoods:feat/ci-review-annotations
Nov 17, 2026
Merged

mohsen1 merged 3 commits into
prooflinedev:mainfrom
HookWoods:feat/ci-review-annotations

Conversation

@HookWoods

Copy link
Copy Markdown

Who this helps

Teams that run proofline ci review in GitHub Actions and want findings where they read code, on the diff.

Right now the way to get there is --sarif plus github/codeql-action/upload-sarif, and on a private repository that upload needs GitHub Advanced Security. A lot of teams in the 20 to 150 engineer range don't have it, so findings stay in the job log or behind the review link and the author has to go and look for them.

Workflow annotations work on every plan. With --annotations, each finding that is not resolved becomes one ::error (SERIOUS) or ::warning (WARNING) line, and GitHub pins it to the cited file and lines in the Files changed tab and lists it on the run summary.

- run: proofline ci review --annotations --fail-on serious

What changed

  • src/annotations.rs (new) walks the same findings as the SARIF export (the CODE assessment for this head, then each environment assessment) and writes one workflow command per finding.
  • src/sarif.rs exposes location(), a thin wrapper over the existing code_location(), so annotations and SARIF agree on where a finding goes.
  • src/outcome.rs gets a small resolved() helper, now used both by --fail-on and by annotations instead of comparing against "RESOLVED" in two places. Severities go through the existing Severity enum.
  • src/lib.rs adds the --annotations flag to ci review and calls the writer right after the review is read.
  • README.md gets a short paragraph next to the other CI notes.

Decisions

  • Escaping matters more than anything else here. Claims and impacts come from the reviewer and quote repository content. An unescaped newline would let a finding start its own command, such as ::add-mask:: or ::stop-commands::, or post a fake error. Values first go through text::terminal_safe, which already strips control characters for terminal output, then get the same escaping as @actions/core: % and newlines in the message, plus : and , in properties. The integration test feeds a claim that tries exactly this.
  • Location rules are shared with SARIF. A finding gets file=/line=/endLine= only when one of its evidence refs passes the checks SARIF already applies: a verified repository read at the review's head commit, with a valid path and line range. Other findings are annotated on the job with no location.
  • The flag is opt-in. The repository's own CI runs the tests with GITHUB_ACTIONS=true, and ci review already leaves behaviour changes to explicit flags (--fail-on fails nothing unless you pass it). Turning annotations on by default inside Actions would change the logs of existing jobs. If you want that later, it is a small follow-up with a --no-annotations switch.
  • Annotations go to stderr, so --json output stays one parseable document. The runner wires a step's stderr to the same OutputManager as stdout (ScriptHandler.cs), so the commands are still processed, and progress messages already use stderr through say().
  • Resolved findings are skipped, which matches how --fail-on treats CODE findings. A severity this CLI doesn't know yet becomes a ::notice, so a new server value still shows up instead of disappearing from the job.
  • Exit codes and the review document don't change. The flag only adds lines to stderr.

Verification

  • A unit test in src/annotations.rs covers the escaping table: \r\n, %, ::add-mask:: inside a value, and an ANSI escape sequence.
  • An integration test in tests/http.rs runs the binary against the axum mock server with three ENV findings: a SERIOUS one with a verified ref at the head, a WARNING one cited at another commit, and a RESOLVED one. Without the flag, no stderr line starts with ::. With it, stderr holds exactly two commands. The first is placed on src/app.rs lines 3 to 5 with the injection attempt escaped; the second has no location. stdout is still valid JSON and the exit code is unchanged.
  • cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings and cargo test --locked pass on Linux with the pinned 1.98.1 toolchain, and cargo deny check passes.

Not in this PR

  • A job summary table in $GITHUB_STEP_SUMMARY. GitHub shows at most 10 error and 10 warning annotations per step, so a long review gets cut off; a summary table could list the rest using the same walk.
  • Enabling annotations automatically when GITHUB_ACTIONS=true.

HookWoods and others added 3 commits November 8, 2026 16:08
`ci review --annotations` prints each finding that is not resolved as a
GitHub Actions workflow command on stderr, placed on the cited file and
lines when an evidence ref is verified at the review's head. Annotations
work on every GitHub plan, while uploading SARIF to code scanning needs
GitHub Advanced Security on private repositories.

Values are escaped like @actions/core does, so a claim cannot end its
command or start another one.

@mohsen1 mohsen1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codex

Resolved README changes and updated the identity regression fixture for the opt-in flag. Exact-head location checks and workflow-command escaping remain intact. Both required jobs passed.

@mohsen1
mohsen1 merged commit 2cc8716 into prooflinedev:main Nov 17, 2026
2 of 3 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