Repository navigation
Reviewer: answer replies to its findings without a mention; look up bucket and key settings instead of asking - #342
Merged
Conversation
…ok up bucket and key settings instead of asking A person's reply in a thread CoderHelm started was dropped unless it mentioned CoderHelm, and every drop was silent. Thread replies on a person's PR now go to the reviewer with or without a mention: it checks the thread is its own, acknowledges the answer, records the finding as answered, resolves the thread when the answer settles it, and re-runs the formal review when that finding was holding the merge. Each version of a reply's words is handled once. Every drop logs its reason. The reviewer can now read an S3 bucket's encryption, bucket policy and policy status, and a KMS key's description and key policy, through the team's read-only role, and names the missing permission when refused. The role templates and the update stack add those five read-only actions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The reviewer asked a question on a person's pull request ("Is the source bucket encrypted with a customer-managed KMS key? ... a quick
aws s3api get-bucket-encryptionwould settle it"). The author answered in that thread and nothing happened.Why the reply was ignored.
handle_review_commentsent a thread reply to the reviewer only whenparse_reviewer_askfound@coderhelmor/coderhelmin the comment, and returnedOkwith no log line otherwise. The only other path for a reply, the pushback judgment inreview_lessons, counts onlycreatedevents and only queues a lesson; it never answers. Edits also went throughask_added_by_edit, which returns early for anything but an edit that adds an ask. Every one of these exits was silent, so the gateway logs showed nothing after "GitHub webhook received". Separately, the "is it CoderHelm" checks matched any login containingcoderhelm, so a person whose login contains that word was treated as the app.This PR does two things:
Changes
Gateway (
routes/github_webhook.rs,routes/review_lessons.rs)route_review_commentis a pure function that decides what to do with apull_request_review_commentand gives a reason for every ignore. A reply in a thread (in_reply_to_id) on a person's PR goes to the worker as triggerthread_reply, withthread_root_idandmentioned, whether or not it mentions CoderHelm. A new top-level inline comment still needs the mention. On CoderHelm's own PRs nothing changes: thread replies there belong to the fix loop.typeplus the app login (is_coderhelm_user), no longer by any login that contains the word.thread#<comment id>#<fingerprint of the reply's words>. Mentions, quoted lines, punctuation and spacing are left out of the fingerprint. A duplicate delivery gets the same key. So does an edit that only adds a mention to a reply that was already answered, which is exactly the edit in this case. An edit that adds the answer gets a new key and is handled once. An edit that changes nothing in the words is ignored. This is the comment id plus a fingerprint rather than the comment id plusupdated_at, becauseupdated_atalso changes on a mention-only edit and would answer twice.issue_comment: a person's comment that quotes text (GitHub's "Quote reply") on a PR CoderHelm reviewed goes to the worker asquote_reply. Every early return now logs its reason.review_lessons: an edited thread reply whose words changed now counts as pushback, so it feeds the lesson judgment. The two "not judged" exits now log their reason.reviewed_by_coderhelmis exposed for the quote path.Worker
passes/review_thread_reply.rs. It finds what the reply answers before the job is claimed: the CoderHelm thread whose first comment is the reply's root, or, for a quote, CoderHelm's thread, review or comment that contains the quoted text. A reply in someone else's thread that doesn't address CoderHelm is skipped with a log and leaves no claim, so a later edit that adds a mention is still handled. The module also builds the prompt (the finding, the thread so far, the answer), resolves the thread through GraphQLresolveReviewThread, and records the outcome underREVIEWANSWER#…(answered or settled, resolved, who, when).review_pr.rs: the answer goes through the existing reply pipeline, which brings the same tools and the verdict reconciliation. When the answer settles a finding and the standing verdict is REQUEST_CHANGES, the formal review runs first. A thread CoderHelm resolved after a person's answer now counts as settled for re-reviews, so the concern isn't raised again.review_agent.rs: the reply-conclusion check also returnssettles_finding.clients/github.rs:BotReviewThread.root_id(the first comment'sdatabaseId).ops_tools.rs: new toolsaws_bucket_settingsandaws_kms_key, available whenever an AWS account is connected. The prompt tells the reviewer to look these facts up first and to quote the missing permission when a lookup is refused. Lookups are recorded and cited like other lookups (T1, T2, …), and when every read in a lookup is refused, the lookup fails.Common
live/aws_settings.rs: input checks for buckets (name,s3://or ARN) and keys (id, alias or ARN). The reads areGetBucketEncryption,GetBucketPolicy,GetBucketPolicyStatus,DescribeKeyandGetKeyPolicy. A call made in the wrong region is retried in the region S3 names. Each read can come back as a value, absent, denied or failed. A denial is written up from the last permission check of the role: "the CoderHelmLogReader role is missings3:GetEncryptionConfiguration… Update on the AWS page", or "the role allows it, so the resource's own policy refused it".log_reader.rs: new abilitysettings("Bucket and key settings"), described in plain words, metadata only.messages.rs:thread_root_idandmentionedonReviewMessage. Both are skipped when empty, so the gateway-to-worker contract bytes don't change. Both tool registries list the two new tools as reads.Infra
coderhelm-log-reader.yamlandcoderhelm-log-reader-update.yamleach get aReadBucketAndKeySettingsstatement withs3:GetEncryptionConfiguration,s3:GetBucketPolicy,s3:GetBucketPolicyStatus,kms:DescribeKeyandkms:GetKeyPolicy. Neither template grants object reads,ListBucket, or encrypt or decrypt. Adding the actions changes the permissions id, so the release gets a newCoderHelmLogReaderUpdate-<id>stack and teams see "Update needed" on the AWS page until they apply it.Verification
gateway/src/routes/testdata/): a reply without a mention is routed as a thread reply; a reply with a mention keeps its ask; an edited reply that adds the answer gets its own key; edits that only fix punctuation, or arrive without the old text, are ignored; a mention-only edit gets the key of the version already answered; replies from a bot and from CoderHelm are ignored, and a person whose login contains "coderhelm" is not; a duplicate delivery gets the same job key; deleted and empty comments are ignored with a reason.cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo test --workspace(common 1216, gateway 593, worker 767; all pass, after rebasing on main).infra:npm test(77 pass),cfn-linton both role templates (clean).