Skip to content

Support attributing MassApplyPatch operations to a dedicated bot account#52

Merged
mtfishman merged 2 commits into
mainfrom
mf/bot-auth-env
Apr 24, 2026
Merged

Support attributing MassApplyPatch operations to a dedicated bot account#52
mtfishman merged 2 commits into
mainfrom
mf/bot-auth-env

Conversation

@mtfishman
Copy link
Copy Markdown
Member

Summary

Adds a BotAuth(; token, user_name, user_email) struct and threads it through make_patch_pr via a new auth kwarg. The auth kwarg propagates to:

  • clone_repo — clones via HTTPS with the PAT embedded in the URL (so the push authenticates as the token's owner) and sets git config user.name / user.email in the cloned repo to the bot identity.
  • github_auth — uses the PAT for the GitHub API.

When auth === nothing (default), the existing behavior is preserved exactly: SSH clone via the user's local key, the user's global git config for commit identity, and gh auth token / ENV["GITHUB_AUTH"] for the API. No caller that omits auth is affected.

Intended use

Running MassApplyPatch under an automation account. A caller like ITensorOrgPatches can construct a BotAuth from a PAT stored in e.g. macOS Keychain and pass it in:

using MassApplyPatch: BotAuth, make_patch_pr

pat = readchomp(`security find-generic-password -s ITENSORORGPATCHES_PAT -a ITensorBot -w`)
auth = BotAuth(;
    token = pat,
    user_name = "ITensorBot",
    user_email = "278814285+ITensorBot@users.noreply.github.com",
)

for repo in repos
    make_patch_pr(:my_patch, repo; auth)
end

The PAT is only ever present in a short-lived tmpdir clone URL; nothing is stored on disk beyond the caller's own secret store.

Why kwargs instead of env vars

Earlier draft of this change used environment variables. Switched to kwargs so the API signature makes the bot-attribution contract explicit, and so callers can't accidentally leak credentials through process env into other tooling.

Compat

Pre-0.3 bump; call sites that omit auth continue to behave identically.

Add a `BotAuth(; token, user_name, user_email)` struct and thread it
through `make_patch_pr` via a new `auth` kwarg that also propagates to
`clone_repo` (HTTPS clone with the token, local git user.name/email
config) and `github_auth` (PAT for GitHub API calls).

When `auth === nothing` (default), the existing behavior is preserved:
SSH clone via the user's local key, the user's global git config for
commit identity, and `gh auth token` / `ENV["GITHUB_AUTH"]` for the API.

The intended use case is running MassApplyPatch under an automation
account. Callers like ITensorOrgPatches can construct a `BotAuth`
from a PAT stored in e.g. macOS Keychain and pass it in. The PAT is
only ever present in a short-lived tmpdir clone URL; nothing is
stored on disk beyond the caller's secret store.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.19%. Comparing base (8543c66) to head (5024fd7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/main.jl 0.00% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
- Coverage   24.63%   24.19%   -0.44%     
==========================================
  Files          13       13              
  Lines         609      620      +11     
==========================================
  Hits          150      150              
- Misses        459      470      +11     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtfishman mtfishman enabled auto-merge (squash) April 24, 2026 20:27
Mirrors the make_patch_pr signature so callers using the
argv-style entrypoint can also attribute operations to a bot account.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman merged commit a54cdad into main Apr 24, 2026
14 of 16 checks passed
@mtfishman mtfishman deleted the mf/bot-auth-env branch April 24, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant