Skip to content

fix(cli): fail early on GitHub permission gaps#34

Open
biaoxie wants to merge 1 commit into
chekusu:mainfrom
biaoxie:codex/issue-7-github-preflight
Open

fix(cli): fail early on GitHub permission gaps#34
biaoxie wants to merge 1 commit into
chekusu:mainfrom
biaoxie:codex/issue-7-github-preflight

Conversation

@biaoxie

@biaoxie biaoxie commented Jul 17, 2026

Copy link
Copy Markdown

Problem

wanman takeover tells dev and CTO agents to push branches, create and review pull requests, and inspect Actions runs. Startup did not verify those GitHub capabilities, and the isolated agent HOME could hide the host gh keyring credential. Agents therefore discovered missing permissions only after work had started.

The existing repository-role check alone is also insufficient for fine-grained PAT and GitHub App credentials because PR and Actions permissions are independent.

Fix

Takeover startup now:

  1. Detects the GitHub owner/repository from the origin remote.
  2. Resolves the exact host gh token before creating the isolated agent home.
  3. Uses that same token for the preflight and passes it to agents as GH_TOKEN.
  4. Verifies repository metadata access, push capability, PR read/write capability, and Actions visibility.
  5. Aborts before starting the supervisor with concrete remediation when any required check fails.

PR-write access is checked without creating repository state: the preflight calls the create-PR endpoint with the same nonexistent branch as head and base. An authorized credential reaches GitHub validation and returns HTTP 422; a credential without Pull requests: write is rejected before validation.

The quickstart now documents minimum permissions for classic PAT/OAuth, fine-grained PAT, and GitHub App installation-token modes.

Tests

  • Added unit coverage for HTTPS/SSH remote parsing, missing authentication, metadata access, push access, PR read/write access, Actions access, and fatal remediation.
  • Added takeover integration coverage proving a failed preflight prevents supervisor startup.
  • Added token-resolution and isolated-agent propagation coverage.
  • Full @wanman/cli suite: 34 files, 382 tests passed.
  • pnpm --filter @wanman/cli typecheck clean.
  • pnpm --filter @wanman/cli build clean.
  • Live non-mutating preflight passed against biaoxie/wanman.

Closes #7

Run takeover preflight checks with the exact token inherited by agents, verify repository, push, pull-request, and Actions capabilities, and abort startup with concrete remediation when a required permission is missing.\n\nDocument required user-token and GitHub App permissions.\n\nRefs chekusu#7
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.

takeover mode: agents cannot auto-open PRs — GitHub App missing pull_requests / actions / secrets permissions

1 participant