Skip to content

skills(nightly): audit bot PAT scopes via script - #294

Merged
max-sixty merged 1 commit into
mainfrom
pat-scope-check
Apr 16, 2026
Merged

max-sixty merged 1 commit into
mainfrom
pat-scope-check

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Catches the case where a required classic OAuth scope is added upstream (most recently gist in #291) but adopter repos still have older PATs that will silently fail the first time an affected skill runs.

New: plugins/tend-ci-runner/scripts/pat-scope-audit.sh parses the bot PAT's X-OAuth-Scopes response header, compares granted vs required, and prints STATUS=ok|missing|fine-grained plus CSV lists on stdout. No GitHub writes — detection only.

Wired into nightly: Step 1 of the nightly skill runs the script and acts on STATUS — closes a prior tracking issue when scopes are now complete, opens/updates one (deduped via marker <!-- tend-pat-scope-audit -->) when scopes are missing, skips fine-grained PATs with a log line. Remediation in the issue body points at step 8 of the install-tend skill.

CLAUDE.md: added a short section capturing the split we settled on while designing this — agent drives diagnostics/remediation inside the action; Actions gate whether the agent runs at all. The reason this landed as an agent-driven skill step rather than deterministic YAML.

Fine-grained PAT self-introspection is not supported by GitHub (no documented endpoint exposes a fine-grained token's permissions), so those are reported and skipped rather than probed. The three prose locations documenting required scopes (docs/tend.example.toml, DESIGN.md, plugins/install-tend/skills/install-tend/SKILL.md) remain the reader-facing source; this script is the one executable reference — a comment in the script names them so future scope additions are easy to keep in sync.

Adds plugins/tend-ci-runner/scripts/pat-scope-audit.sh that parses the
bot PAT's X-OAuth-Scopes header and reports missing required scopes
(repo, workflow, notifications, write:discussion, gist). New Step 1 in
the nightly skill runs the script and drives the tracking-issue
open/update/close flow. Fine-grained PATs are reported as such and
skipped (no documented self-introspection endpoint).

Adds an "Agent-driven vs deterministic steps" section to CLAUDE.md
capturing the split: agent drives inside the action, Actions gate
whether it runs at all.

Co-authored-by: Claude <[email protected]>
@max-sixty
max-sixty merged commit d438d6a into main Apr 16, 2026
5 checks passed
@max-sixty
max-sixty deleted the pat-scope-check branch April 16, 2026 22:16
max-sixty added a commit that referenced this pull request Apr 18, 2026
Bumps generator version to 0.0.16 and syncs lockfile.

7 commits since 0.0.15: nightly bot PAT scope audit (#294), review-reviewers gist-backed evidence storage with single-fetch optimization (#291, #292), nightly closes bot-opened tracking issues when resolved (#290), drops GITHUB_STEP_SUMMARY writes that fail under Claude sandbox (#289), release docs clarification (#288), and notifications dedup of bot-authored PRs (#279).

Co-Authored-By: Claude <[email protected]>
@max-sixty max-sixty mentioned this pull request Apr 18, 2026
max-sixty added a commit that referenced this pull request Apr 18, 2026
Bumps generator to 0.0.16.

## Changes since 0.0.15

- #294 — nightly: audit bot PAT scopes via script
- #292 — review-reviewers: fetch current-month gist once per run
- #291 — review-reviewers: pilot gist-backed evidence storage
- #290 — nightly: close bot-opened tracking issues when resolved
- #289 — skills: drop `GITHUB_STEP_SUMMARY` writes that fail under
Claude sandbox
- #288 — docs(release): commit on the current branch, don't create a new
one
- #279 — notifications: dedup bot-authored PRs cross-referencing the
issue

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
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.

2 participants