feat(worker): split agent git auth from publication write auth (#4) - #37
Merged
Conversation
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
…hases (#4) Installation tokens are now minted per role and constrained to the single target repository: orchestration (contents:read, checks:write, issues:write, pull_requests:read) held by the adapter; agent git (contents:write only) injected via COVEN_GIT_TOKEN; publication (pull_requests:write, issues:write) minted only after the result envelope passes contract validation. The result envelope is sanitized before any persistence or publication, and the worker refuses to write a session brief containing a live token. Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens the worker’s security boundary by separating GitHub App installation tokens by phase/role and ensuring token redaction occurs before anything is persisted or published back to GitHub. It fits the adapter’s responsibility to strictly control publication authority while keeping the agent constrained to the minimum required Git capability.
Changes:
- Introduces role-scoped installation token minting (orchestration vs agent git vs publication) and mints publication authority only post-result validation.
- Adds a centralized redaction/sanitization module to scrub live token values and token-shaped patterns from all free-text result fields and surfaced error strings.
- Adds an integration-style wiremock test to assert per-endpoint token routing and prevent token leakage in outgoing payloads.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/security.md | Documents the new three-token role split and the redaction guarantees/hardening targets. |
| docs/headless-contract.md | Clarifies the scoped permission set for COVEN_GIT_TOKEN within contract v2. |
| crates/worker/src/redact.rs | Adds token scanning/redaction and result sanitization helpers with unit tests. |
| crates/worker/src/lib.rs | Splits token minting by role, injects only agent-git token into the child process, sanitizes results pre-publication, and adds a wiremock test for routing/leak prevention. |
| crates/worker/Cargo.toml | Adds wiremock as a dev dependency for worker tests. |
| crates/github/src/installation.rs | Adds TokenRole and scoped token minting that constrains permissions to a single repo + phase-specific permission sets. |
| Cargo.toml | Adds workspace dependency version for wiremock. |
| Cargo.lock | Locks new transitive dependencies introduced by wiremock. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| artifact. The 1-hour token TTL is the adapter's concern; the runtime treats the | ||
| token as opaque and valid for the session. | ||
|
|
||
| The adapter scopes this token to `contents: write` on the target repository |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #4.
contents:read,checks:write,issues:write,pull_requests:read) held by the adapter for refs, Check Runs, and progress comments; agent git (contents:writeonly) injected viaCOVEN_GIT_TOKEN; and publication (pull_requests:write,issues:write,contents:read) minted only after the result envelope passes contract validation.redactmodule scrubs live token values and GitHub token patterns from every free-text result field before the task store, comments, PR bodies, or Check Run output see them; error strings embedded in published surfaces are redacted too.docs/security.md;docs/headless-contract.md§1.1 gains a non-breaking clarification thatCOVEN_GIT_TOKENiscontents:writeon the target repo only.Plan and grooming trail: #4 (comment)
🤖 Generated with Claude Code