Skip to content

fleet gh: passthrough with personal + App token rotation (#8887) - #9014

Merged
dezren39 merged 2 commits into
mainfrom
fleet-gh-8887
Nov 12, 2026
Merged

dezren39 merged 2 commits into
mainfrom
fleet-gh-8887

Conversation

@dezren39

@dezren39 dezren39 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

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…):

  • 110 entries — Atlas 17 · ID & fleet 37 · PM stack 17 · Cloudflare 12 · Turso 5 · Adjacent infra 22 — each with Drew's original ask + date, design status, implementation status, tracking, and open follow-ups.
  • Plus the 131 idea-engine entries as one parent (Appendix A, titles preserved).
  • Never-issued triage (§7): 42 items — 8 still-live (being filed as issues alongside this PR), 29 done-without-issue, 5 superseded/dead (register-only by design).

A tracking epic and the 8 still-live filings reference this file.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…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).
@dezren39
dezren39 requested a review from a team as a code owner November 12, 2026 20:26
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 039d0efc-c108-4eea-9e80-b769d13b5500
Commits

Reviewing files that changed from the base of the PR and between 6a7843c and 5990bd3.

Files ignored due to path filters: 1

  • pkgs/fleet/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 5

  • pkgs/fleet/crates/fleet-registry/src/lib.rs
  • pkgs/fleet/crates/fleet/Cargo.toml
  • pkgs/fleet/crates/fleet/src/gh.rs
  • pkgs/fleet/crates/fleet/src/main.rs
  • pkgs/fleet/smoke.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T21:17:38.506918Z 5990bd3 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +161 to +164
if a == "-f"
|| a == "-F"
|| a == "--field"
|| a == "--raw-field"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +219 to +222
if let Some(v) = value {
let owner = v.split('/').next().unwrap_or("");
if !owner.is_empty() && owner != "." && owner != ".." {
return Some(owner.to_string());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +126 to +129
if lower.contains("rate limit")
|| lower.contains("rate_limit")
|| lower.contains("too many requests")
|| lower.contains("http 429")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +871 to +875
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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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.

1 participant