Repository navigation
fleet gh: passthrough with personal + App token rotation (#8887) - #9014
Conversation
…8887) Implements code#8887 step 1: fleet gh runs the real gh CLI with all arguments unchanged, exporting a broker-resolved token as GH_TOKEN per attempt. Rotation: personal token (parsed from the broker-stored github-cli.hosts-yml), then installation tokens of the fleet GitHub App (developing.today fleet, App ID 5612056; key resolved by name, RS256 JWT signed via openssl with the key on an inherited fd, installations resolved live and paginated). Fails over on rate-limit and permission/scope refusals; writes repeat only on those pre-execution refusals, reads on any failure. Tokens are never printed, logged, or written to files. Registry gains the gh capability/domain (full build only); smoke caps updated. Tests: 7 new oracle-named unit tests (classification, retry gate, read whitelist, rotation order/owner hint, hosts.yml parse, base64url vectors, fake-gh failover + write-not-repeated).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a15e51a1dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if a == "-f" | ||
| || a == "-F" | ||
| || a == "--field" | ||
| || a == "--raw-field" |
There was a problem hiding this comment.
Recognize attached short field flags before classifying reads
An invocation such as fleet gh api repos/o/r/issues/1/comments -fbody=hello is classified as read-only because this check misses attached -f and -F values. The installed gh 2.96.0 accepts this syntax, and gh api --help states that “adding request parameters will automatically switch the request method to POST”; a local debug invocation also confirmed POST for -fbody=hello. If the mutation succeeds but its response is lost, may_retry consequently repeats it under another token, potentially creating duplicate comments or issues. Recognize attached short-field arguments before allowing retries on arbitrary failures.
Useful? React with 👍 / 👎.
| let out = Command::new(gh_bin) | ||
| .args(args) | ||
| .env("GH_TOKEN", token) | ||
| .stdin(Stdio::inherit()) |
There was a problem hiding this comment.
Replay piped input when retrying under another token
For fleet gh api ... --input -, the first subprocess consumes the caller's piped payload before receiving a rate-limit or permission rejection. Every subsequent attempt inherits that same, now-exhausted stream, so failover sends an empty or different body rather than repeating the original request. The inspected gh api --help explicitly documents “Use - to read from standard input” for --input. Capture and replay noninteractive input for each attempt, or decline retries when consumed input cannot be replayed.
Useful? React with 👍 / 👎.
| if let Some(v) = value { | ||
| let owner = v.split('/').next().unwrap_or(""); | ||
| if !owner.is_empty() && owner != "." && owner != ".." { | ||
| return Some(owner.to_string()); |
There was a problem hiding this comment.
Extract the owner from host-qualified repository selectors
For a write targeting -R github.com/dezren39/private-repo, this extracts github.com as the owner instead of dezren39, so the correct installation is not moved to the front of the App rotation. The inspected gh issue create --help documents -R, --repo [HOST/]OWNER/REPO, confirming that this is supported syntax. If the personal token is rate-limited and the default first installation, app:developing-today, cannot access that private repository and receives HTTP 404, the wrapper returns immediately because 404 is classified as Other for a write; it never tries the correct app:dezren39 token. Strip the optional host component before selecting the owner.
Useful? React with 👍 / 👎.
#8887) Passthrough fidelity fix from the reconcile acceptance run: callers that capture both streams (project-reconcile.sh item-add parses stdout JSON out of a 2>&1 capture) must see exactly what gh produced. Rotation/failover notes are trace-gated; the no-token terminal summary still prints (nothing ran to impersonate).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5990bd324e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if lower.contains("rate limit") | ||
| || lower.contains("rate_limit") | ||
| || lower.contains("too many requests") | ||
| || lower.contains("http 429") |
There was a problem hiding this comment.
Distinguish refusal errors from verbose request content
For a write such as fleet gh api repos/o/r/issues/1/comments --verbose -f 'body=rate limit', the request payload itself can trigger this classification. The inspected gh api --help describes --verbose as “Include full HTTP request and response in the output.” Because run_with_provider searches both captured streams, an ambiguous transport failure or HTTP 500 becomes a supposedly safe rate-limit refusal whenever the logged payload contains these words. The wrapper can then repeat a mutation that already landed, creating duplicate comments. Require evidence of an actual refusal response rather than matching arbitrary request or response content.
Useful? React with 👍 / 👎.
| assert_eq!(base64url(b""), ""); | ||
| assert_eq!(base64url(b"f"), "Zg"); | ||
| assert_eq!(base64url(b"fo"), "Zm8"); | ||
| assert_eq!(base64url(b"foo"), "Zm9v"); | ||
| assert_eq!(base64url(b"\xfb\xff"), "-_8"); |
There was a problem hiding this comment.
Add property coverage for the JWT base64url serializer
The new handwritten base64url serializer feeds App JWT signing, but its coverage consists only of five fixed vectors. The root AGENTS.md testing doctrine explicitly requires property tests for serializers and crypto formats, so example-only coverage does not satisfy the repository's verification contract. Add generated arbitrary-byte cases checked against an independent reference encoder or decoder, including the unpadded URL-safe output invariant.
AGENTS.md reference: AGENTS.md:L38-L38
Useful? React with 👍 / 👎.
What this is
The 60-day design audit register, committed into the PM stack at Drew's order (2026-11-11: "update pm stack to include all the items and the designs under them, the status of each design and its implementation follow-ups... I want to stop dropping them").
pm-stack/design-register-2026-11-11.md— the full register, byte-faithful to the audited source (~/workspace/design-audit-60d/REGISTER.md, sha256 b32540a8…):A tracking epic and the 8 still-live filings reference this file.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.