Skip to content

feat(review): bounded read-only GitHub bot-review collector - #1218

Merged
hyperpolymath merged 9 commits into
feat/review-observation-admission-20261123from
feat/review-github-collector-20261123
Nov 23, 2026
Merged

hyperpolymath merged 9 commits into
feat/review-observation-admission-20261123from
feat/review-github-collector-20261123

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Stack relationship and scope

Base: feat/review-observation-admission-20261123 (draft #1216), not main. This branch depends on Hypatia.ReviewObservation.admit/2; do not merge it independently before the base is integrated. Tracked by #1217.

Implements the first read-only GitHub collector for external-review observations. It does not trigger paid review, alter branch settings, persist receipts, dispatch any bot or authorise merges.

Contract

  • Hypatia.ReviewGithubCollector.collect/3 fetches PR head, paginated inline review comments and review submissions, then re-reads the head; moving head/failed page/partial pagination => error, never "clean."
  • The production backend uses gh api --method GET without shell evaluation. Tests inject a pure API stub (no token needed).
  • Root inline findings are admitted only when GitHub API numeric bot IDs and logins match verified Codex/CodeRabbit identities, and a known machine finding marker identifies scope. Markdown/text is not executed or promoted.
  • Submitted reviews have unknown finding summary, including APPROVED; no code-review approval becomes a Hypatia merge approval. No comments is not evidence of safety.
  • mix hypatia.review_collect --repo OWNER/REPO --pr NUMBER prints a bounded inspection summary (no raw bot text or JSON receipts).
  • Include regression tests in existing Elixir CI; update README's exact code/task counts.
  • Design note defines boundaries and remaining blind spots.

Explicit limitations

Only the GitHub REST bot review-comment/review-submission surfaces are covered. CodeRabbit/Codex issue-comment summaries and quotas require versioned source-specific adapters; pre-commit.ci results need a GitHub check-run adapter. Source bot account identity comes from GitHub API metadata, not a cryptographic claim signature. Existing ReviewObservation output remains unverified/unqualified and is not proof or evidence for learning. No store or I-JSON/JCS canonical output is written here. All unknown/failed cases remain non-authorising.

Verification and merging

New branch contents have been compared to parent: six files (two new Elixir modules, one test file, one document, README and CI), no pre-existing code paths rewritten. Tests/format/CI have not yet been verified for this branch. Verify CI, then run a read-only live pilot at a pinned PR head and check API event ID parity before promoting. Keep this a draft and preserve the independent security/CI blockers. Do not merge until parent #1216 accepted and integration checks pass.

@gitnotebooks

gitnotebooks Bot commented Nov 23, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 30ea7895-63e3-46ba-8747-945dadb5b72f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copy link
Copy Markdown
Owner Author

Verified integration evidence for collector branch d60920c9f50a1ab26c2857c57c74d3578e9862af, workflow Tests (E2E / Integration / Stress / Bench) run 45098332749: the Integration Tests job 137443337283 completed success. Its Run Elixir integration tests step executed mix test --include integration, with runner log 3751 tests, 0 failures, 3 skipped (246 excluded). Thus the new Hypatia.ReviewGithubCollectorTest source participated in the full ExUnit suite (not a decorative test file).

Scope limits: this is a mocked-API collector regression run, not an authenticated live GitHub collector pilot. The stacked PR base is not main; the separate CI (including mix format --check-formatted) workflow is not triggered on this PR target. Some other runs/jobs may still be executing. The parent PR #1216 remains draft and security-red due #1219; no branch is merge-cleared on this evidence alone.

@sonarqubecloud

Copy link
Copy Markdown

Copy link
Copy Markdown
Owner Author

Additional semantic boundary to enforce before parity scoring: an admitted inline finding comment represents a successfully posted source event, not proof the entire external review run completed. The v0 adapter supplies status=completed to the shared observation type for these posted events; therefore assessment=reported_findings is only an external finding assertion on the named commit. It MUST NOT be interpreted as provider_run_status=completed, total review coverage, a completed code/security scan, or a valid negative denominator. The future provider-run adapter must supply its own separate run-status and scope/coverage fields, bound to the API's exact review attempt and SHA; avoid treating one inline comment as an entire reviewer result. No code or policy bypass is authorised by this clarification.

@hyperpolymath
hyperpolymath marked this pull request as ready for review November 23, 2026 06:36
@hyperpolymath hyperpolymath assigned Copilot and unassigned Copilot Nov 23, 2026
@hyperpolymath
hyperpolymath merged commit 8ba73d3 into feat/review-observation-admission-20261123 Nov 23, 2026
56 of 57 checks passed
@hyperpolymath
hyperpolymath deleted the feat/review-github-collector-20261123 branch November 23, 2026 06:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-23T06:42:51.970763Z 4d0e9b1 Draft marked ready
🔒 Security Review ✅ Completed 2026-11-23T06:39:51.040529Z 4d0e9b1 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d0e9b1139

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +121 to +122
head = get_in(pr, ["head", "sha"])
actual_repo = get_in(pr, ["base", "repo", "full_name"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return an error for malformed nested PR objects

When GitHub returns a top-level object whose head or base.repo field has an unexpected non-map shape, these get_in/2 calls raise FunctionClauseError or ArgumentError instead of satisfying collect/3's {:error, term()} contract. This bypasses the collector's documented fail-closed handling for unexpected API shapes and crashes callers such as the Mix task; validate each nested value as a map before traversing it.

Useful? React with 👍 / 👎.

Comment on lines +276 to +278
case System.cmd(
"gh",
["api", "--hostname", "github.com", "--method", "GET", path],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bound the gh subprocess runtime

When gh api stalls during network or credential access, System.cmd/3 waits indefinitely, so the page budget cannot make this collector bounded and the Mix task hangs instead of returning its documented unavailable result. The gh api flag list provides no request-timeout option, so run the child under an explicit deadline and terminate it when that deadline expires.

Useful? React with 👍 / 👎.

# stderr; the failure branch discards it without echoing secrets.
stderr_to_stdout: true
) do
{body, 0} when byte_size(body) <= @max_response_bytes ->

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Enforce the response limit while reading output

When an API page is larger than @max_response_bytes, System.cmd/3 has already captured the entire stdout value before this guard runs, so the advertised 4 MB limit only prevents decoding and does not bound memory use. A page containing many large review bodies or diff hunks can therefore allocate well beyond the intended cap; stream into a bounded collector and terminate the child as soon as the limit is exceeded.

Useful? React with 👍 / 👎.

env: [{"GH_PROMPT_DISABLED", "1"}],
# Capture error text rather than relaying it into the caller's
# stderr; the failure branch discards it without echoing secrets.
stderr_to_stdout: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep gh diagnostics out of the JSON stream

When the caller has GH_DEBUG enabled, GitHub CLI emits verbose diagnostics on standard error as documented in gh help environment, but stderr_to_stdout: true merges those diagnostics into the successful JSON response and makes Jason.decode/1 return :invalid_github_api_json for every request. Update-notifier or telemetry messages can corrupt the response for the same reason; capture or suppress stderr separately instead of combining it with stdout.

Useful? React with 👍 / 👎.

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