feat(agent): write-permission readiness gate (#775) - #843
Conversation
The action layer (#778) must not attempt a PR-write action the App lacks the scope for. Add two pure helpers in agent-execution.ts: - agentRequiresPrWrite(autonomy): true when any acting autonomy level (auto / auto_with_approval) is configured for a PR-write action class (review / request_changes / approve / merge / close). label is excluded — it mutates via the Issues API, which the App already holds issues: write for. - resolveAgentPermissionReadiness({autonomy, installationPermissions}): not_required (no acting PR-write level) | ready (App holds pull_requests: write) | reconsent_required (maintainer must re-authorize with the upgraded scope). Deny-toward-safety and pure, mirroring resolveAgentActionMode (#776). #778 consults this before executing; the actual App pull_requests: write upgrade + re-consent prompt are the install-side follow-ups.
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
|
gittensory · advisory review Reviewed 2 changed file(s) — two independent AI reviewers. Changed files: Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · Worth double-checking
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #843 +/- ##
=======================================
Coverage 96.59% 96.59%
=======================================
Files 100 100
Lines 14240 14244 +4
Branches 5190 5192 +2
=======================================
+ Hits 13755 13759 +4
Misses 105 105
Partials 380 380 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #775
What & why
Phase 0 of the agent layer (#768) is deny-by-default trust scaffolding. Before the action layer (#778) can mutate a real PR, it must know whether the App even holds the scope to do so — and if not, surface that the maintainer needs to re-consent. This adds that readiness gate as two pure helpers in
src/settings/agent-execution.ts, alongside the kill-switch/dry-run mode resolver from #776.The gate
agentRequiresPrWrite(autonomy)—truewhen any acting autonomy level (auto/auto_with_approval) is configured for a PR-write action class (review/request_changes/approve/merge/close).labelis intentionally excluded: it mutates via the Issues API, which the App already holdsissues: writefor, so it never demandspull_requests: write.resolveAgentPermissionReadiness({ autonomy, installationPermissions })→not_required— no acting PR-write level configured, so the scope is irrelevantready— the installation grantspull_requests: writereconsent_required— an acting PR-write level is configured but the App only holdsread(or the scope is missing): the maintainer must re-authorize with the upgraded permissionBoth are pure and deny-toward-safety, mirroring
resolveAgentActionMode(#776). #778 consultsresolveAgentPermissionReadinessbefore executing any PR-write action.Scope boundary (follow-ups, not in this PR)
pull_requests: writepermission upgrade + the maintainer re-consent prompt UI are install-side ops. The App owner has approved requesting the upgraded scope; wiring the re-consent surface lands with the action layer (feat(agent): maintainer write-actions layer (request-changes/approve/merge/close/label) #778) that consumes this gate.Tests
test/unit/agent-execution.test.ts— newagent write-permission readiness (#775)block covering both helpers across acting/non-acting levels, thelabelexclusion, andready/reconsent_required/not_requiredfor write / read / missing / null granted scopes. Full suite green (2023 passed);agent-execution.tsat 100% statements + branches.