forked from fullsend-ai/fullsend
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(#247): cap review verdict at comment-only for governance docs #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fullsend-ai-coder
wants to merge
2
commits into
main
Choose a base branch
from
agent/247-governance-doc-comment-only
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,10 @@ | |
| # Runs on the GitHub Actions runner AFTER the sandbox is destroyed. | ||
| # CWD is runDir. | ||
| # | ||
| # This script is the sole enforcement point for protected-path checks: | ||
| # if the PR touches sensitive paths, an "approve" action is downgraded | ||
| # to "comment" so only a human can grant approval. | ||
| # This script is the sole enforcement point for protected-path and | ||
| # governance-document checks: if the PR touches sensitive paths or | ||
| # consists solely of governance documents, an "approve" action is | ||
| # downgraded to "comment" so only a human can grant approval. | ||
| # | ||
| # Required environment variables: | ||
| # REVIEW_TOKEN — token with pull-requests:write on the target repo | ||
|
|
@@ -90,6 +91,11 @@ REVIEW_PROTECTED_PATHS=( | |
| "skills/" | ||
| ) | ||
|
|
||
| # Temp files used by downgrade paths below; cleaned up on exit. | ||
| MODIFIED_RESULT="" | ||
| GOV_RESULT="" | ||
| trap 'rm -f "${MODIFIED_RESULT}" "${GOV_RESULT}"' EXIT | ||
|
|
||
| DOWNGRADED=false | ||
| if [ "${ACTION}" = "approve" ]; then | ||
| PR_FILES=$(gh pr view "${PR_NUMBER}" --repo "${REPO_FULL_NAME}" --json files --jq '.files[].path') | ||
|
|
@@ -126,13 +132,61 @@ if [ "${ACTION}" = "approve" ]; then | |
|
|
||
| # Rewrite the result file with downgraded action and appended notice. | ||
| MODIFIED_RESULT=$(mktemp) | ||
| trap 'rm -f "${MODIFIED_RESULT}"' EXIT | ||
| jq --arg notice "${PROTECTED_NOTICE}" \ | ||
| '.action = "comment" | .body = (.body + $notice)' \ | ||
| "${RESULT_FILE}" > "${MODIFIED_RESULT}" | ||
| RESULT_FILE="${MODIFIED_RESULT}" | ||
| DOWNGRADED=true | ||
| fi | ||
|
|
||
| # ------------------------------------------------------------------------- | ||
| # Governance-document check: if ALL changed files are governance docs, | ||
| # downgrade "approve" to "comment" (defense-in-depth, mirrors the | ||
| # protected-path downgrade above). | ||
| # Governance document patterns (kept in sync with pr-review SKILL.md): | ||
| # ------------------------------------------------------------------------- | ||
| if [ "${DOWNGRADED}" = "false" ]; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] edge-case Governance check is skipped when protected-path already fired (DOWNGRADED=false guard). Both paths produce the same result (comment action with DOWNGRADED=true), so enforcement is correct. User sees only the protected-path explanation. |
||
| GOVERNANCE_DOC_PATTERNS=( | ||
| "MAINTAINERS.md" | ||
| "GOVERNANCE.md" | ||
| "CODE_OF_CONDUCT.md" | ||
| "SECURITY.md" | ||
| ) | ||
|
|
||
| ALL_GOVERNANCE=true | ||
| while IFS= read -r file; do | ||
| [ -z "${file}" ] && continue | ||
| BASENAME=$(basename "${file}") | ||
| IS_GOV=false | ||
| for pattern in "${GOVERNANCE_DOC_PATTERNS[@]}"; do | ||
| if [ "${BASENAME}" = "${pattern}" ]; then | ||
| IS_GOV=true | ||
| break | ||
| fi | ||
| done | ||
| if [ "${IS_GOV}" = "false" ]; then | ||
| ALL_GOVERNANCE=false | ||
| break | ||
| fi | ||
| done <<< "${PR_FILES}" | ||
|
|
||
| if [ "${ALL_GOVERNANCE}" = "true" ]; then | ||
| echo "All changed files are governance documents — downgrading approve to comment" | ||
|
|
||
| GOV_NOTICE=$'\n\n---\n\n' | ||
| GOV_NOTICE+=$'> **Governance documents detected** — all changed files in this PR are\n' | ||
| GOV_NOTICE+=$'> governance or process documents. The review agent cannot approve PRs that\n' | ||
| GOV_NOTICE+=$'> consist solely of governance documents.\n' | ||
| GOV_NOTICE+=$'> A human reviewer must approve this PR.\n' | ||
|
|
||
| GOV_RESULT=$(mktemp) | ||
| jq --arg notice "${GOV_NOTICE}" \ | ||
| '.action = "comment" | .body = (.body + $notice)' \ | ||
| "${RESULT_FILE}" > "${GOV_RESULT}" | ||
| RESULT_FILE="${GOV_RESULT}" | ||
| DOWNGRADED=true | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low] edge-case
The is_all_governance() test helper returns true for empty input (vacuous truth). In production this is guarded by PR_FILES non-empty check. Adding a documenting test case would make the edge case explicit.
Suggested fix: Add: run_gov_test "empty-input-vacuous-true" "" "true" with a comment noting the upstream guard.