Skip to content

feat(cycle): token governance scheduled sweep (#15)#34

Merged
lex00 merged 1 commit into
mainfrom
feat/token-governance-cycle
Jun 19, 2026
Merged

feat(cycle): token governance scheduled sweep (#15)#34
lex00 merged 1 commit into
mainfrom
feat/token-governance-cycle

Conversation

@lex00

@lex00 lex00 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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.
  • Violation = expired (clock-free, from GitHub's token_expired) / over maxLifetimeDays / idle past maxIdleDays.
  • 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

  • New TokenPolicyConfig on OrgConfig.tokenPolicy; LiveTokenGrant + pure evaluateTokenViolation in the diff (unit-tested with explicit nowMs).
  • A violation is emitted as a token-grant UPDATE ("revoke access"), not a delete — so a routine revocation sweep does not trip removalDeltaCap.
  • The runner now injects diffOptions.nowMs ?? Date.now() so time-based diffs work in real runs while tests stay deterministic.

Verification

  • npx tsc --noEmit clean
  • npm test green (436 tests; +16 in token-governance.test.ts)
  • Action bundle rebuilt for the CI freshness check

🤖 Generated with Claude Code

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>
@lex00 lex00 merged commit 3ce85dd into main Jun 19, 2026
2 checks passed
@lex00 lex00 mentioned this pull request Jun 19, 2026
1 task
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.

cycle: token governance (scheduled sweep)

1 participant