Repository navigation
fix: bind Noema App slug to review identity #1483
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
Changes from 4 commits
3bcdf8b
255280d
851e782
cc74dcf
8dd4334
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| "opencode-agent[bot]", | ||
| "opencode-agent", | ||
| } | ||
| GITHUB_APP_BOT_RE = re.compile(r"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\[bot\]$") | ||
| MAX_DIFF_CHARS = 60000 | ||
| MAX_CONTEXT_FILES = 12 | ||
| MAX_FILE_CONTEXT_CHARS = 4000 | ||
|
|
@@ -190,6 +191,16 @@ def existing_noema_review(pr: dict[str, Any], actor: str) -> bool: | |
|
|
||
| def current_actor() -> str: | ||
| """Return the verified user or GitHub App bot login for the active token.""" | ||
| action_actor = os.environ.get("NOEMA_REVIEW_ACTOR", "").strip() | ||
| installation_id = os.environ.get("NOEMA_REVIEW_INSTALLATION_ID", "").strip() | ||
| if action_actor or installation_id: | ||
| if ( | ||
| os.environ.get("NOEMA_REVIEW_TOKEN_SOURCE") != "noema-review-github-app" | ||
| or not GITHUB_APP_BOT_RE.fullmatch(action_actor) | ||
| or not installation_id.isdigit() | ||
| ): | ||
| raise RuntimeError("Noema GitHub App identity binding is invalid") | ||
| return action_actor | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Comment on lines
+194
to
+203
Contributor
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. |
||
| for args, suffix in ( | ||
| (["gh", "api", "user", "--jq", ".login"], ""), | ||
| (["gh", "api", "/installation", "--jq", ".app_slug"], "[bot]"), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ | |
| MAX_TRANSIENT_BACKOFF_MULTIPLIER = 4 | ||
| NOEMA_REVIEW_AUTHOR = "cwl-noema-review[bot]" | ||
| NOEMA_REVIEW_MARKER = "<!-- noema-review-gate " | ||
| NOEMA_MARKER_HEAD_RE = re.compile(r"<!-- noema-review-gate head_sha=([0-9a-fA-F]{40}) decision=[a-z_]+ -->") | ||
| NOEMA_BODY_HEAD_RE = re.compile(r"Head SHA:\s*`([0-9a-fA-F]{40})`") | ||
| TERMINAL_NOEMA_STATES = {"APPROVED", "CHANGES_REQUESTED", "COMMENTED"} | ||
|
|
||
|
|
||
|
|
@@ -103,6 +105,13 @@ def noema_review_state(reviews: list[dict[str, Any]], head_sha: str) -> str | No | |
| continue | ||
| if NOEMA_REVIEW_MARKER not in str(review.get("body") or ""): | ||
| continue | ||
| body = str(review.get("body") or "") | ||
| marker_heads = NOEMA_MARKER_HEAD_RE.findall(body) | ||
| body_heads = NOEMA_BODY_HEAD_RE.findall(body) | ||
| if len(marker_heads) != 1 or len(body_heads) != 1: | ||
| continue | ||
|
Comment on lines
+109
to
+112
Contributor
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. 🟡 Valid reviews become unrecoverable When model text repeats Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| if marker_heads[0].lower() != head_sha.lower() or body_heads[0].lower() != head_sha.lower(): | ||
| continue | ||
|
Comment on lines
+111
to
+114
Contributor
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. 🟡 Rejected reviews block every redispatch A malformed or duplicate head binding makes Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| state = str(review.get("state") or "").upper() | ||
| if state in TERMINAL_NOEMA_STATES: | ||
| return state | ||
|
Comment on lines
+108
to
117
Contributor
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. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.