-
Notifications
You must be signed in to change notification settings - Fork 0
feat(automation): route trusted review-agent mentions #787
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
seonghobae
wants to merge
60
commits into
main
Choose a base branch
from
feat/review-agent-mention-router-main
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
Show all changes
60 commits
Select commit
Hold shift + click to select a range
a3f4c83
ci: materialize focused review-agent mention router
seonghobae 0cdc975
chore(automation): remove transient mention-router materializer
seonghobae e8adc56
test(automation): preserve trusted mention-router contracts
seonghobae 39afd62
test(automation): preserve organization mention sweep contracts
seonghobae 57a6b9b
test(automation): preserve least-privilege mention workflow contract
seonghobae 6c5038c
feat(automation): add trusted review-agent mention router
seonghobae fab2bf9
feat(automation): add bounded organization mention sweep
seonghobae 1867cc8
test(automation): pin mention-router runner and checkout source
seonghobae 8cd9be3
feat(automation): add trusted review-agent mention workflow
seonghobae 7e53010
ci(automation): enforce mention-router quality gates
seonghobae f6aaa6e
docs(automation): document review-agent mention routing
seonghobae 580909f
docs(changelog): record trusted mention-router slice
seonghobae b0d2d11
docs(automation): define mention-router activation gate
seonghobae b67b99e
test(automation): isolate CLI environment contract
seonghobae 95f5e54
test(automation): require path-based coverage measurement
seonghobae cf4400f
ci(automation): measure exact mention-router script paths
seonghobae 588ea68
test(agent-router): require per-agent durable dispatch idempotency
seonghobae ee1e33e
test(agent-router): require downstream exact-key idempotency
seonghobae cb08d05
test(agent-router): separate workflow trigger and pytest contracts
seonghobae 6008bac
test(agent-router): execute durable idempotency contracts
seonghobae d7c2335
fix(agent-router): deduplicate exact per-agent dispatches
seonghobae 109a5fa
fix(agent-router): accept empty workflow-run inventory
seonghobae 9e11bb3
test(agent-router): model durable run inventory reads
seonghobae 236fd71
fix(agent-router): grant durable workflow-run read access
seonghobae 78af2e0
test(agent-router): require durable dispatch wrappers
seonghobae f0522c4
feat(agent-router): add durable Noema dispatch wrapper
seonghobae 88b5960
feat(agent-router): add durable OpenCode dispatch wrapper
seonghobae d4caec6
feat(agent-router): route through durable dispatch wrappers
seonghobae 68877ff
test(agent-router): expect durable wrapper events
seonghobae ec201df
test(agent-router): cover wrapper event idempotency
seonghobae c1171d7
test(agent-router): reject unsupported Bash lookahead
seonghobae 316246c
fix(agent-router): use portable Bash base validation
seonghobae d69a767
ci(agent-router): track durable dispatch wrappers
seonghobae 7a5db21
test(agent-router): make central run ledger authoritative
seonghobae 75df0cd
ci(agent-router): execute receipt authority contract
seonghobae d3afa23
test(agent-router): make production paths receipt-independent
seonghobae f384e2e
fix(agent-router): remove local receipt authority
seonghobae 7689c3a
fix(agent-router): make sweep receipt-independent
seonghobae b86250d
test: prevent no-op sweep requests from exhausting budget
seonghobae 22e4c18
test: assert job permissions independently
seonghobae 1fd0119
test: accept wildcard quality-gate path coverage
seonghobae 9056842
fix: preserve sweep capacity for newly queued work
seonghobae 9427718
test: cover durable run-ledger failure boundaries
seonghobae ff02c87
docs: record durable dispatch ledger and permission boundary
seonghobae 678be8b
fix(automation): remove branch-selected mention sweep dispatch
seonghobae c1e28b2
test(automation): prohibit branch-selected mention sweep dispatch
seonghobae 9027938
docs(automation): document protected mention sweep trigger
seonghobae 8aa7101
fix(automation): preserve app-token fallback semantics
seonghobae e0f2457
test(ci): cover scheduler package import fallback
seonghobae 84bb106
test(automation): require payload-bound agent invocation keys
seonghobae ef456e3
ci: materialize payload-bound review-agent invocations
seonghobae af1b35c
ci: add bounded PR 787 payload-binding materializer
seonghobae b4105d9
ci(pr787): trigger payload-bound invocation repair
seonghobae b731c29
ci: trigger bounded PR 787 payload-binding repair
seonghobae 521ce30
ci(pr787): stage validated payload-binding repair
seonghobae eb73298
ci(pr787): run payload-bound repair v2
seonghobae 4427fe1
ci: retrigger verified PR 787 payload-binding repair
seonghobae 550a869
ci(pr787): build verified payload candidate
seonghobae 53c5dc6
ci(pr787): upload verified payload candidate
seonghobae 55152c6
ci(pr787): export verified reviewed files
seonghobae 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Trigger the exact-head payload-binding repair workflow after the quality gate identified the missing Noema base-branch identity field. |
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 |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: Agent Mention Noema Dispatch | ||
| run-name: >- | ||
| Agent Mention Noema ${{ github.event.client_payload.target_repository }}#${{ | ||
| github.event.client_payload.pr_number }} [cwl-agent-invocation:${{ | ||
| github.event.client_payload.agent_invocation_key }}] | ||
|
|
||
| on: | ||
| repository_dispatch: | ||
| types: [agent-mention-noema] | ||
|
|
||
| concurrency: | ||
| group: agent-mention-noema-${{ github.event.client_payload.agent_invocation_key || github.run_id }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| actions: read | ||
| contents: write | ||
|
|
||
| jobs: | ||
| validate-and-forward: | ||
| if: github.repository == 'ContextualWisdomLab/.github' | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REQUESTED_AGENT: "cwl-noema-review" | ||
| PAYLOAD_AGENT: ${{ github.event.client_payload.requested_agent || '' }} | ||
| INVOCATION_KEY: ${{ github.event.client_payload.agent_invocation_key || '' }} | ||
| TARGET_REPOSITORY: ${{ github.event.client_payload.target_repository || '' }} | ||
| PR_NUMBER: ${{ github.event.client_payload.pr_number || '' }} | ||
| PR_HEAD_SHA: ${{ github.event.client_payload.pr_head_sha || '' }} | ||
| REQUESTED_BY: ${{ github.event.client_payload.requested_by || '' }} | ||
| SOURCE_COMMENT_ID: ${{ github.event.client_payload.source_comment_id || '' }} | ||
| steps: | ||
| - name: Validate exact invocation and elect one durable leader | ||
| id: leader | ||
| run: | | ||
| set -euo pipefail | ||
| if [ "$PAYLOAD_AGENT" != "$REQUESTED_AGENT" ] || | ||
| ! [[ "$INVOCATION_KEY" =~ ^[0-9a-f]{64}$ ]] || | ||
| ! [[ "$TARGET_REPOSITORY" =~ ^ContextualWisdomLab/[A-Za-z0-9_.-]+$ ]] || | ||
| ! [[ "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]] || | ||
| ! [[ "$PR_HEAD_SHA" =~ ^[0-9a-f]{40}$ ]] || | ||
| ! [[ "$SOURCE_COMMENT_ID" =~ ^[1-9][0-9]*$ ]] || | ||
| ! [[ "$REQUESTED_BY" =~ ^[A-Za-z0-9-]+$ ]]; then | ||
| echo "::error::Rejected malformed or mismatched Noema agent invocation payload." | ||
| exit 1 | ||
| fi | ||
|
|
||
| marker="[cwl-agent-invocation:${INVOCATION_KEY}]" | ||
| leader_id="$( | ||
| gh api --paginate --slurp \ | ||
| "repos/${GITHUB_REPOSITORY}/actions/workflows/agent-mention-noema-dispatch.yml/runs?event=repository_dispatch&per_page=100" \ | ||
| | jq -r --arg marker "$marker" ' | ||
| [.[].workflow_runs[] | ||
| | select((.display_title // "") | contains($marker)) | ||
| | .id] | ||
| | min // empty | ||
| ' | ||
| )" | ||
| if [ -z "$leader_id" ]; then | ||
| echo "::error::Could not establish the durable Noema invocation leader." | ||
| exit 1 | ||
| fi | ||
| if [ "$leader_id" != "$GITHUB_RUN_ID" ]; then | ||
| echo "forward=false" >>"$GITHUB_OUTPUT" | ||
| echo "Duplicate exact-key invocation suppressed by durable workflow-run identity." | ||
| exit 0 | ||
| fi | ||
| echo "forward=true" >>"$GITHUB_OUTPUT" | ||
|
|
||
| - name: Forward once to the authoritative Noema workflow | ||
| if: steps.leader.outputs.forward == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| jq -n \ | ||
| --arg target_repository "$TARGET_REPOSITORY" \ | ||
| --argjson pr_number "$PR_NUMBER" \ | ||
| --arg pr_head_sha "$PR_HEAD_SHA" \ | ||
| --arg requested_agent "$REQUESTED_AGENT" \ | ||
| --arg agent_invocation_key "$INVOCATION_KEY" \ | ||
| --arg requested_by "$REQUESTED_BY" \ | ||
| --argjson source_comment_id "$SOURCE_COMMENT_ID" \ | ||
| '{ | ||
| event_type: "noema-review", | ||
| client_payload: { | ||
| target_repository: $target_repository, | ||
| pr_number: $pr_number, | ||
| pr_head_sha: $pr_head_sha, | ||
| requested_agent: $requested_agent, | ||
| agent_invocation_key: $agent_invocation_key, | ||
| requested_by: $requested_by, | ||
| source_comment_id: $source_comment_id | ||
| } | ||
| }' \ | ||
| | gh api "repos/${GITHUB_REPOSITORY}/dispatches" -X POST --input - | ||
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 |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| name: Agent Mention OpenCode Dispatch | ||
| run-name: >- | ||
| Agent Mention OpenCode ${{ github.event.client_payload.target_repository }}#${{ | ||
| github.event.client_payload.pr_number }} [cwl-agent-invocation:${{ | ||
| github.event.client_payload.agent_invocation_key }}] | ||
|
|
||
| on: | ||
| repository_dispatch: | ||
| types: [agent-mention-opencode] | ||
|
|
||
| concurrency: | ||
| group: agent-mention-opencode-${{ github.event.client_payload.agent_invocation_key || github.run_id }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| actions: read | ||
| contents: write | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
|
|
||
| jobs: | ||
| validate-and-forward: | ||
| if: github.repository == 'ContextualWisdomLab/.github' | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REQUESTED_AGENT: "opencode-agent" | ||
| PAYLOAD_AGENT: ${{ github.event.client_payload.requested_agent || '' }} | ||
| INVOCATION_KEY: ${{ github.event.client_payload.agent_invocation_key || '' }} | ||
| TARGET_REPOSITORY: ${{ github.event.client_payload.target_repository || '' }} | ||
| PR_NUMBER: ${{ github.event.client_payload.pr_number || '' }} | ||
| PR_HEAD_SHA: ${{ github.event.client_payload.pr_head_sha || '' }} | ||
| BASE_BRANCH: ${{ github.event.client_payload.base_branch || '' }} | ||
| REQUESTED_BY: ${{ github.event.client_payload.requested_by || '' }} | ||
| SOURCE_COMMENT_ID: ${{ github.event.client_payload.source_comment_id || '' }} | ||
| TRIGGER_REVIEWS: ${{ github.event.client_payload.trigger_reviews }} | ||
| REVIEW_DISPATCH_LIMIT: ${{ github.event.client_payload.review_dispatch_limit || '' }} | ||
| ENABLE_AUTO_MERGE: ${{ github.event.client_payload.enable_auto_merge }} | ||
| UPDATE_BRANCHES: ${{ github.event.client_payload.update_branches }} | ||
| MERGE_MODE: ${{ github.event.client_payload.merge_mode || '' }} | ||
| steps: | ||
| - name: Validate exact review-only invocation and elect one durable leader | ||
| id: leader | ||
| run: | | ||
| set -euo pipefail | ||
| if [ "$PAYLOAD_AGENT" != "$REQUESTED_AGENT" ] || | ||
| ! [[ "$INVOCATION_KEY" =~ ^[0-9a-f]{64}$ ]] || | ||
| ! [[ "$TARGET_REPOSITORY" =~ ^ContextualWisdomLab/[A-Za-z0-9_.-]+$ ]] || | ||
| ! [[ "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]] || | ||
| ! [[ "$PR_HEAD_SHA" =~ ^[0-9a-f]{40}$ ]] || | ||
| ! [[ "$BASE_BRANCH" =~ ^[A-Za-z0-9._/-]+$ ]] || | ||
| [[ "$BASE_BRANCH" == -* ]] || | ||
| ! [[ "$SOURCE_COMMENT_ID" =~ ^[1-9][0-9]*$ ]] || | ||
| ! [[ "$REQUESTED_BY" =~ ^[A-Za-z0-9-]+$ ]] || | ||
| [ "$TRIGGER_REVIEWS" != "true" ] || | ||
| [ "$REVIEW_DISPATCH_LIMIT" != "1" ] || | ||
| [ "$ENABLE_AUTO_MERGE" != "false" ] || | ||
| [ "$UPDATE_BRANCHES" != "false" ] || | ||
| [ "$MERGE_MODE" != "disabled" ]; then | ||
| echo "::error::Rejected malformed, mismatched, or mutation-capable OpenCode invocation payload." | ||
| exit 1 | ||
| fi | ||
|
|
||
| marker="[cwl-agent-invocation:${INVOCATION_KEY}]" | ||
| leader_id="$( | ||
| gh api --paginate --slurp \ | ||
| "repos/${GITHUB_REPOSITORY}/actions/workflows/agent-mention-opencode-dispatch.yml/runs?event=repository_dispatch&per_page=100" \ | ||
| | jq -r --arg marker "$marker" ' | ||
| [.[].workflow_runs[] | ||
| | select((.display_title // "") | contains($marker)) | ||
| | .id] | ||
| | min // empty | ||
| ' | ||
| )" | ||
| if [ -z "$leader_id" ]; then | ||
| echo "::error::Could not establish the durable OpenCode invocation leader." | ||
| exit 1 | ||
| fi | ||
| if [ "$leader_id" != "$GITHUB_RUN_ID" ]; then | ||
| echo "forward=false" >>"$GITHUB_OUTPUT" | ||
| echo "Duplicate exact-key invocation suppressed by durable workflow-run identity." | ||
| exit 0 | ||
| fi | ||
| echo "forward=true" >>"$GITHUB_OUTPUT" | ||
|
|
||
| - name: Forward once to the authoritative review-only scheduler | ||
| if: steps.leader.outputs.forward == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| jq -n \ | ||
| --arg target_repository "$TARGET_REPOSITORY" \ | ||
| --argjson pr_number "$PR_NUMBER" \ | ||
| --arg pr_head_sha "$PR_HEAD_SHA" \ | ||
| --arg base_branch "$BASE_BRANCH" \ | ||
| --arg requested_agent "$REQUESTED_AGENT" \ | ||
| --arg agent_invocation_key "$INVOCATION_KEY" \ | ||
| --arg requested_by "$REQUESTED_BY" \ | ||
| --argjson source_comment_id "$SOURCE_COMMENT_ID" \ | ||
| '{ | ||
| event_type: "merge-scheduler", | ||
| client_payload: { | ||
| target_repository: $target_repository, | ||
| pr_number: $pr_number, | ||
| pr_head_sha: $pr_head_sha, | ||
| base_branch: $base_branch, | ||
| trigger_reviews: true, | ||
| review_dispatch_limit: "1", | ||
| enable_auto_merge: false, | ||
| update_branches: false, | ||
| merge_mode: "disabled", | ||
| requested_agent: $requested_agent, | ||
| agent_invocation_key: $agent_invocation_key, | ||
| requested_by: $requested_by, | ||
| source_comment_id: $source_comment_id | ||
| } | ||
| }' \ | ||
| | gh api "repos/${GITHUB_REPOSITORY}/dispatches" -X POST --input - | ||
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 |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: Agent Mention Router Quality CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - ".github/workflows/agent-mention-router.yml" | ||
| - ".github/workflows/agent-mention-router-quality-ci.yml" | ||
| - ".github/workflows/agent-mention-noema-dispatch.yml" | ||
| - ".github/workflows/agent-mention-opencode-dispatch.yml" | ||
| - "scripts/ci/agent_mention_router.py" | ||
| - "scripts/ci/agent_mention_sweep.py" | ||
| - "tests/test_agent_mention_*.py" | ||
| - "requirements-opencode-review-ci-hashes.txt" | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - ".github/workflows/agent-mention-router.yml" | ||
| - ".github/workflows/agent-mention-router-quality-ci.yml" | ||
| - ".github/workflows/agent-mention-noema-dispatch.yml" | ||
| - ".github/workflows/agent-mention-opencode-dispatch.yml" | ||
| - "scripts/ci/agent_mention_router.py" | ||
| - "scripts/ci/agent_mention_sweep.py" | ||
| - "tests/test_agent_mention_*.py" | ||
| - "requirements-opencode-review-ci-hashes.txt" | ||
|
|
||
| concurrency: | ||
| group: agent-mention-router-quality-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | ||
|
|
||
| jobs: | ||
| quality: | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - name: Harden runner | ||
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | ||
| with: | ||
| egress-policy: audit | ||
| - name: Checkout exact head | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | ||
| persist-credentials: false | ||
| - name: Set up Python | ||
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | ||
| with: | ||
| python-version: "3.14" | ||
| cache: pip | ||
| cache-dependency-path: requirements-opencode-review-ci-hashes.txt | ||
| - name: Install exact hash-locked tooling | ||
| run: >- | ||
| python -m pip install --disable-pip-version-check --require-hashes | ||
| -r requirements-opencode-review-ci-hashes.txt | ||
| - name: Run complete focused branch coverage | ||
| shell: bash --noprofile --norc -e -o pipefail {0} | ||
| run: | | ||
| cat >"${RUNNER_TEMP}/agent-mention-coveragerc" <<'EOF' | ||
| [run] | ||
| branch = True | ||
| include = | ||
| scripts/ci/agent_mention_router.py | ||
| scripts/ci/agent_mention_sweep.py | ||
| [report] | ||
| fail_under = 100 | ||
| show_missing = True | ||
| EOF | ||
| export COVERAGE_RCFILE="${RUNNER_TEMP}/agent-mention-coveragerc" | ||
| python -m coverage erase | ||
| python -m coverage run -m pytest -q \ | ||
| tests/test_agent_mention_router.py \ | ||
| tests/test_agent_mention_sweep.py \ | ||
| tests/test_agent_mention_workflow_contract.py \ | ||
| tests/test_agent_mention_idempotency.py \ | ||
| tests/test_agent_mention_downstream_idempotency.py \ | ||
| tests/test_agent_mention_receipt_authority.py | ||
| python -m coverage report --fail-under=100 | ||
| python -m interrogate --fail-under=100 \ | ||
| scripts/ci/agent_mention_router.py \ | ||
| scripts/ci/agent_mention_sweep.py | ||
| python -m compileall -q \ | ||
| scripts/ci/agent_mention_router.py \ | ||
| scripts/ci/agent_mention_sweep.py \ | ||
| tests/test_agent_mention_router.py \ | ||
| tests/test_agent_mention_sweep.py \ | ||
| tests/test_agent_mention_workflow_contract.py \ | ||
| tests/test_agent_mention_idempotency.py \ | ||
| tests/test_agent_mention_downstream_idempotency.py \ | ||
| tests/test_agent_mention_receipt_authority.py | ||
| git diff --check |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.