Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkgs/fleet/crates/fleet-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,20 @@ pub const DOMAINS: &[Domain] = &[
capabilities: &[Capability::Gh],
primary: Capability::Gh,
aliases: &[],
subcommands: &["tiers", "cache-serve", "cache-status", "closures"],
subcommands: &[
"tiers",
"cache-serve",
"cache-status",
"closures",
"sync-labels",
"sync-view",
"sync-comment",
"sync-issue-create",
"sync-issue-get",
"sync-labels-add",
"sync-label-ensure",
"sync-issue-close",
],
},
Domain {
name: "bridge",
Expand Down
34 changes: 33 additions & 1 deletion pkgs/fleet/crates/fleet/src/gh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ use crate::gh_cache;
use crate::gh_closure;
use crate::gh_guard;
use crate::gh_metadata;
use crate::gh_sync;
use fleet_config::{Config, DEFAULT_GH_CACHE_PORT};
use fleet_secrets::Resolver;
use std::io::{IsTerminal, Write};
Expand Down Expand Up @@ -189,7 +190,20 @@ FLEET_GH_CACHE as a comma list; an address without a port gets port
`fleet gh cache-status` probes the configured daemons. `--cache-addr`
overrides every daemon address for one call; `--no-cache` resolves
in-process. When no daemon answers, the call resolves in-process and
says so on stderr — never silently.";
says so on stderr — never silently.

Sync verbs (code#10973, step 2.2 of #9016): the `sync-*` shadow
verbs are the typed Queue/GitHub sync surface for scripted flows
(pm-stack dispatch's fallback, the opencode claimant, job bodies).
Each declares its whole command line, validates it strictly, and
rewrites to the canonical gh call before the guard, closure and
metadata layers run, inheriting the rotation and the retry-safety
rule. `fleet gh sync-labels --repo OWNER/REPO <issue|pr> <n>` prints
an item's label names as JSON; `sync-view` prints labels,state,title
JSON; `sync-comment` posts a comment (`--body` or `--body-file`);
`sync-issue-create`, `sync-issue-get`, `sync-labels-add`,
`sync-label-ensure` and `sync-issue-close` (fleet closure reasons)
cover the issue writes dispatch composes. See gh_sync.rs.";

/// The fleet's GitHub Apps, in rotation order. Each carries its
/// private key (and, except the fleet App whose ID is a public
Expand Down Expand Up @@ -1500,6 +1514,24 @@ pub fn run(config: &Config, args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "closures") {
return run_closures(&args[1..]);
}
// Sync verbs (#10973, step 2.2 of #9016): strictly-parsed typed
// verbs that rewrite to the canonical gh call. The rewrite is
// applied here, before the close guard, the closure layer and
// the metadata create path parse the arguments, so a sync call
// inherits every passthrough control — and the rotation below —
// exactly as the hand-written call it replaces would have.
let sync_rewrite;
let args: &[String] = match gh_sync::parse(args) {
Comment on lines +1523 to +1524

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 Preserve migrated reads under the raw-mode environment

When a claimant or dispatch process inherits FLEET_GH_RAW=1, the early return in gh::run at lines 1485–1488 executes before this rewrite and forwards sync-* arguments unchanged to the real gh binary. Raw mode is a documented identity-pinning escape hatch (doc/fleet/gh-credential-lifecycle.md:204–213), and checking gh sync-labels --help confirms the result: unknown command "sync-labels" for "gh". Previously the migrated callers supplied ordinary issue/pr commands that worked in that environment; now their label/state reads fail, causing the claimant's fail-closed checks to prevent launches. Account for the sync translation when handling inherited raw mode.

Useful? React with 👍 / 👎.

Ok(Some(canonical)) => {
sync_rewrite = canonical;
&sync_rewrite
}
Ok(None) => args,
Err(e) => {
eprintln!("{e}");
return EXIT_USAGE;
}
};
let guard_intent = match gh_guard::parse(args) {
Ok(intent) => intent,
Err(e) => {
Expand Down
Loading