From e11b15931d8d10085463450e527f83093e0fd71b Mon Sep 17 00:00:00 2001 From: Zahin Mohammad Date: Wed, 11 Nov 2026 14:00:34 -0500 Subject: [PATCH 1/2] fix(root): use unprotected roles for AI inference Ticket: INF-5300 --- .claude/agents/iyarc-prune.md | 4 ++-- .github/workflows/claude-pr.yml | 35 +++++++++---------------------- .github/workflows/iyarc-prune.yml | 19 ++++++++++------- scripts/iyarc-prune.js | 23 -------------------- 4 files changed, 23 insertions(+), 58 deletions(-) diff --git a/.claude/agents/iyarc-prune.md b/.claude/agents/iyarc-prune.md index 59c14fe95a..037505c428 100644 --- a/.claude/agents/iyarc-prune.md +++ b/.claude/agents/iyarc-prune.md @@ -23,8 +23,8 @@ over an unsafe or unverified bump. ## Environment notes - For a manual run of [the workflow](../../.github/workflows/iyarc-prune.yml#L29-L42), - select `master` in **Use workflow from**. The AWS login uses the - [workflow's branch identity](https://docs.github.com/en/actions/reference/security/oidc#filtering-for-a-specific-branch), + select `master` in **Use workflow from**. The AWS login uses the `ai-inference` + [environment identity](https://docs.github.com/en/actions/reference/security/oidc#filtering-for-a-specific-environment), not the checkout ref. Merge workflow changes before a live run; local agent invocations are unaffected. - This is a Lerna + Yarn (v1, `1.22.22`) workspaces monorepo with ~116 packages diff --git a/.github/workflows/claude-pr.yml b/.github/workflows/claude-pr.yml index ff9790cda3..9d98d1aadc 100644 --- a/.github/workflows/claude-pr.yml +++ b/.github/workflows/claude-pr.yml @@ -14,6 +14,7 @@ on: jobs: claude-pr: + environment: ai-inference if: | ( (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || @@ -27,34 +28,24 @@ jobs: timeout-minutes: 10 env: AWS_REGION: us-west-2 - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v6 - name: Configure AWS Credentials (OIDC) - uses: aws-actions/configure-aws-credentials@v6 + uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 with: - role-to-assume: arn:aws:iam::199765120567:role/${{ github.event.repository.name }}-iam-protected + role-to-assume: arn:aws:iam::199765120567:role/${{ github.event.repository.name }}-iam-unprotected aws-region: us-west-2 - name: Assume inference role - id: inference-role - run: | - CREDS="$(aws sts assume-role \ - --role-arn arn:aws:iam::168000258654:role/BedrockInferenceRole \ - --role-session-name claude-inference-session \ - --query 'Credentials' \ - --output json)" - - AWS_ACCESS_KEY_ID="$(echo "$CREDS" | jq -r '.AccessKeyId')" - AWS_SECRET_ACCESS_KEY="$(echo "$CREDS" | jq -r '.SecretAccessKey')" - AWS_SESSION_TOKEN="$(echo "$CREDS" | jq -r '.SessionToken')" - - echo "::add-mask::$AWS_SECRET_ACCESS_KEY" - { echo "aws-access-key-id=$AWS_ACCESS_KEY_ID"; echo "aws-secret-access-key=$AWS_SECRET_ACCESS_KEY"; echo "aws-session-token=$AWS_SESSION_TOKEN"; } >> "$GITHUB_OUTPUT" + uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 + with: + role-to-assume: arn:aws:iam::168000258654:role/BedrockInferenceRole + role-session-name: claude-inference-session + role-chaining: true + role-skip-session-tagging: true + aws-region: us-west-2 - name: Determine prompt to use id: determine-prompt @@ -86,9 +77,6 @@ jobs: env: ANTHROPIC_MODEL: arn:aws:bedrock:us-west-2:168000258654:inference-profile/global.anthropic.claude-sonnet-5-5 AWS_REGION: us-west-2 - AWS_ACCESS_KEY_ID: ${{ steps.inference-role.outputs.aws-access-key-id }} - AWS_SECRET_ACCESS_KEY: ${{ steps.inference-role.outputs.aws-secret-access-key }} - AWS_SESSION_TOKEN: ${{ steps.inference-role.outputs.aws-session-token }} MAX_THINKING_TOKENS: '0' with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -109,9 +97,6 @@ jobs: env: ANTHROPIC_MODEL: arn:aws:bedrock:us-west-2:168000258654:inference-profile/global.anthropic.claude-sonnet-5-5 AWS_REGION: us-west-2 - AWS_ACCESS_KEY_ID: ${{ steps.inference-role.outputs.aws-access-key-id }} - AWS_SECRET_ACCESS_KEY: ${{ steps.inference-role.outputs.aws-secret-access-key }} - AWS_SESSION_TOKEN: ${{ steps.inference-role.outputs.aws-session-token }} MAX_THINKING_TOKENS: '0' with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/iyarc-prune.yml b/.github/workflows/iyarc-prune.yml index 89ec168d17..51396e3915 100644 --- a/.github/workflows/iyarc-prune.yml +++ b/.github/workflows/iyarc-prune.yml @@ -18,6 +18,7 @@ concurrency: jobs: prune: + environment: ai-inference runs-on: ubuntu-latest timeout-minutes: 60 defaults: @@ -30,7 +31,7 @@ jobs: run: | set -euo pipefail if [ "$GITHUB_REF" != 'refs/heads/master' ]; then - echo '::error::Run iyarc-prune from master. The AWS role trusts the workflow ref, not the checkout ref. Merge workflow changes before dispatching them.' + echo '::error::Run iyarc-prune from master. Merge workflow changes before dispatching them.' exit 1 fi @@ -55,14 +56,19 @@ jobs: run: node scripts/iyarc-prune.js install-scanner - name: Authenticate workflow with AWS - uses: aws-actions/configure-aws-credentials@v6 + uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 with: - role-to-assume: arn:aws:iam::199765120567:role/${{ github.event.repository.name }}-iam-protected + role-to-assume: arn:aws:iam::199765120567:role/${{ github.event.repository.name }}-iam-unprotected aws-region: us-west-2 - name: Obtain credentials for the Bedrock model service - id: inference-role - run: node scripts/iyarc-prune.js assume-inference-role + uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 + with: + role-to-assume: arn:aws:iam::168000258654:role/BedrockInferenceRole + role-session-name: iyarc-prune-session + role-chaining: true + role-skip-session-tagging: true + aws-region: us-west-2 - name: Load iyarc-prune agent instructions id: agent @@ -82,9 +88,6 @@ jobs: # Bedrock: replaying a tool-call turn requires a leading thinking block; disable to avoid 400. MAX_THINKING_TOKENS: '0' AWS_REGION: us-west-2 - AWS_ACCESS_KEY_ID: ${{ steps.inference-role.outputs.aws-access-key-id }} - AWS_SECRET_ACCESS_KEY: ${{ steps.inference-role.outputs.aws-secret-access-key }} - AWS_SESSION_TOKEN: ${{ steps.inference-role.outputs.aws-session-token }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Load trusted workflow helper from the original checkout diff --git a/scripts/iyarc-prune.js b/scripts/iyarc-prune.js index dc66898a5f..aeed67ecaa 100644 --- a/scripts/iyarc-prune.js +++ b/scripts/iyarc-prune.js @@ -47,28 +47,6 @@ function installScanner() { fs.appendFileSync(env.GITHUB_PATH, `${directory}\n`); } -function assumeInferenceRole() { - const credentials = JSON.parse( - run('aws', [ - 'sts', - 'assume-role', - '--role-arn', - 'arn:aws:iam::168000258654:role/BedrockInferenceRole', - '--role-session-name', - 'iyarc-prune-session', - '--query', - 'Credentials', - '--output', - 'json', - ]) - ); - console.log(`::add-mask::${credentials.SecretAccessKey}`); - console.log(`::add-mask::${credentials.SessionToken}`); - setOutput('aws-access-key-id', credentials.AccessKeyId); - setOutput('aws-secret-access-key', credentials.SecretAccessKey); - setOutput('aws-session-token', credentials.SessionToken); -} - function loadInstructions() { const instructions = fs.readFileSync('.claude/agents/iyarc-prune.md', 'utf8'); const endOfFrontmatter = instructions.indexOf('\n---\n'); @@ -242,7 +220,6 @@ function reportPullRequest() { const operations = { 'install-scanner': installScanner, - 'assume-inference-role': assumeInferenceRole, 'load-instructions': loadInstructions, 'write-agent-summary': writeAgentSummary, 'require-successful-completion': requireSuccessfulCompletion, From 3970f99c918e9b1dcc3d3b30099f747af17df0e1 Mon Sep 17 00:00:00 2001 From: Zahin Mohammad Date: Wed, 11 Nov 2026 14:08:45 -0500 Subject: [PATCH 2/2] fix(root): identify BitGoJS inference sessions Ticket: INF-5300 --- .github/workflows/claude-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/claude-pr.yml b/.github/workflows/claude-pr.yml index 9d98d1aadc..e231fafcba 100644 --- a/.github/workflows/claude-pr.yml +++ b/.github/workflows/claude-pr.yml @@ -42,7 +42,7 @@ jobs: uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 with: role-to-assume: arn:aws:iam::168000258654:role/BedrockInferenceRole - role-session-name: claude-inference-session + role-session-name: bitgojs-claude-inference-session role-chaining: true role-skip-session-tagging: true aws-region: us-west-2