feat(cycle): token governance scheduled sweep (#15)#34
Merged
Conversation
Inventories org fine-grained PAT grants and revokes org access for policy violators (expired / over max-lifetime / idle). New TokenPolicyConfig + LiveTokenGrant + pure evaluateTokenViolation + token-grant diff type. Violations modeled as UPDATE (revoke), not delete, so a routine sweep doesn't trip removalDeltaCap. Runner injects nowMs for time-based checks. Platform walls (App-only; user PATs not API-rotatable) documented. Mock-tested; verify against a real App/test-org later. Registered, exported, action bundle rebuilt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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 #15. Built mock-tested now (per roadmap decision); verify against a real App/test-org before relying on it.
Adds the token-governance cycle — a scheduled sweep that inventories the org's fine-grained PAT grants and revokes org access for any grant violating the token policy.
What it does
GET /orgs/{org}/personal-access-tokens— list active grants (paginated), mapped to epoch-ms timestamps.token_expired) / overmaxLifetimeDays/ idle pastmaxIdleDays.POST /orgs/{org}/personal-access-tokens/{id}{action:"revoke"}— revoke a violator's org access.Platform walls (documented in code)
User PATs cannot be created or rotated on a user's behalf via the API. warden can only inventory, gate approval (#16), and revoke org access — and these token APIs are App-only.
Modeling
TokenPolicyConfigonOrgConfig.tokenPolicy;LiveTokenGrant+ pureevaluateTokenViolationin the diff (unit-tested with explicitnowMs).token-grantUPDATE ("revoke access"), not a delete — so a routine revocation sweep does not tripremovalDeltaCap.diffOptions.nowMs ?? Date.now()so time-based diffs work in real runs while tests stay deterministic.Verification
npx tsc --noEmitcleannpm testgreen (436 tests; +16 intoken-governance.test.ts)🤖 Generated with Claude Code