diff --git a/pkgs/fleet/crates/fleet-queue/src/client.rs b/pkgs/fleet/crates/fleet-queue/src/client.rs index 6459bd4a3f..408babc136 100644 --- a/pkgs/fleet/crates/fleet-queue/src/client.rs +++ b/pkgs/fleet/crates/fleet-queue/src/client.rs @@ -2477,6 +2477,60 @@ esac .count(); assert_eq!(positionals, n, "usage for {verb:?} positionals: {synopsis}"); } + // Required-vs-optional is part of the contract (#13174): a + // flag the handler dies without must be written bare in the + // synopsis, and a flag written bare must be one the handler + // dies without. The requirement is read from the handlers' + // own die(2, ...) messages — ": -- ... is + // required" and the " requires --" form — so a + // requirement added without its usage (or the reverse) + // fails here. Conditional requirements are phrased + // differently in the source (claim --bind's --session-id, + // lane's --limit-reason) and stay out of this set. + let mut source_required: Vec = want + .iter() + .filter(|flag| { + let colon_form = format!("{verb}: --{flag}"); + let requires_form = format!("{verb} requires --{flag}"); + if src.contains(&requires_form) { + return true; + } + src.match_indices(&colon_form).any(|(at, _)| { + let rest = &src[at + colon_form.len()..]; + let literal = &rest[..rest.find('"').unwrap_or(rest.len())]; + literal.contains("is required") + }) + }) + .cloned() + .collect(); + source_required.sort(); + // Flags written outside any [...] group in the synopsis. + let mut depth = 0i32; + let mut documented_required: Vec = Vec::new(); + let mut chars = synopsis.chars().peekable(); + while let Some(c) = chars.next() { + match c { + '[' => depth += 1, + ']' => depth -= 1, + '-' if depth == 0 && chars.peek() == Some(&'-') => { + chars.next(); + let name: String = chars + .by_ref() + .take_while(|c| c.is_ascii_alphanumeric() || *c == '-') + .collect(); + if !name.is_empty() { + documented_required.push(name); + } + } + _ => {} + } + } + documented_required.sort(); + documented_required.dedup(); + assert_eq!( + documented_required, source_required, + "usage for {verb:?} must write required flags bare and optional flags bracketed: {synopsis}" + ); checked += 1; } assert!(checked >= 30, "scanned only {checked} verbs"); diff --git a/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs b/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs index 236708bdc1..82e03645ee 100644 --- a/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs +++ b/pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs @@ -1431,7 +1431,6 @@ pub(super) fn cmd_complete(rest: &[String]) -> i32 { "result-file", "telemetry", "execution", - "queue", ], &[], ); diff --git a/pkgs/fleet/crates/fleet-queue/src/client/support.rs b/pkgs/fleet/crates/fleet-queue/src/client/support.rs index 5e25b65216..68c401f6ab 100644 --- a/pkgs/fleet/crates/fleet-queue/src/client/support.rs +++ b/pkgs/fleet/crates/fleet-queue/src/client/support.rs @@ -191,21 +191,21 @@ Run `repo-queue --help` for flags:\n\ enqueue [--queue ] [--platform

] [--dry-run] [--shadow-intent]\n\ list [--queue ] [--status ] [--limit ] [--not-before ] [--lane ] [--worker ] [--task ]\n\ claim [--queue ] [--worker ] [--lease-seconds ] [--lane ] [--task ] [--count ] [--from-session ] [--platform

] [--session-id ] [--model-provider

] [--model-id ] [--model-variant ] [--filter ] [--pool

] [--launched-by ] [--remaining-budget-minutes ] [--handoff] [--bind]\n\ - release [--worker ] [--reason ]\n\ + release [--worker ] --reason \n\ lane [--worker ] [--exclusion-reason ] [--opencode-reason ] [--limit-platform

] [--limit-reason ] [--clear-platform-limit]\n\ bind [--worker ] --session-id [--launched-by ] [--model-provider

] [--model-id ] [--model-variant ]\n\ heartbeat [--worker ] [--extend-seconds ] [--progress

] [--progress-file ]\n\ - checkpoint [--worker ] [--stage ] [--progress

] [--progress-file ]\n\ + checkpoint [--worker ] --stage [--progress

] [--progress-file ]\n\ park [--worker ] --reason [--delay-seconds ] [--not-before ] [--progress

] [--progress-file ] [--ready-condition ] [--execution ] [--required-budget-minutes ] [--hands --action ]\n\ wake [--worker ] [--reason ]\n\ block [--worker ] --reason-class --blocker [--progress

] [--progress-file ] [--ledger-id ] [--question ] [--context ] [--options-json ] [--links-json ] [--blocked-by-pr ] [--blocked-by-issue ] [--blocked-by-task ] [--blocked-by-ci ] [--dep-recheck-seconds ] [--dep-max-ttl-seconds ] [--hands --action ]\n\ unblock [--worker ] [--reason ] [--drop-dep ]\n\ dep-recheck [--task ] [--limit ]\n\ quarantine-recheck [--task ] [--limit ]\n\ - cancel [--worker ] [--reason ]\n\ + cancel [--worker ] --reason \n\ revive [--worker ] [--reason ] [--not-before ]\n\ - fail [--worker ] [--error ] [--reason-class ] [--execution ]\n\ - complete [--worker ] [--result ] [--result-file ] [--telemetry ] [--execution ] [--queue ]\n\ + fail [--worker ] --error [--reason-class ] [--execution ]\n\ + complete [--worker ] [--result ] [--result-file ] [--telemetry ] [--execution ]\n\ verify-disposition --repo [--pr ] [--follow-up-task | --follow-up-issue | --follow-up-pr ] [--reason ] [--staleness-seconds ] [--json]\n\ timeline [--worker ] [--json]\n\ history [--worker ] [--json] (alias of timeline)\n\ @@ -236,7 +236,7 @@ pub(crate) fn usage(verb: &str) -> &'static str { "usage: repo-queue claim [--queue ] [--worker ] [--lease-seconds ] [--lane ] [--task ] [--count ] [--from-session ] [--platform

] [--session-id ] [--model-provider

] [--model-id ] [--model-variant ] [--filter ] [--pool

] [--launched-by ] [--remaining-budget-minutes ] [--handoff] [--bind]\n\nClaims the highest-priority eligible task." } "release" => { - "usage: repo-queue release [--worker ] [--lane ] [--reason ]\n\nReleases a held claim." + "usage: repo-queue release [--worker ] [--lane ] --reason \n\nReleases a held claim." } "lane" => { "usage: repo-queue lane [--worker ] [--exclusion-reason ] [--opencode-reason ] [--limit-platform

] [--limit-reason ] [--clear-platform-limit]\n\nReports lane progress on a task." @@ -248,7 +248,7 @@ pub(crate) fn usage(verb: &str) -> &'static str { "usage: repo-queue heartbeat [--worker ] [--lane ] [--extend-seconds ] [--progress

] [--progress-file ]\n\nRefreshes a claim lease." } "checkpoint" => { - "usage: repo-queue checkpoint [--worker ] [--lane ] [--stage ] [--progress

] [--progress-file ]\n\nRecords a progress checkpoint." + "usage: repo-queue checkpoint [--worker ] [--lane ] --stage [--progress

] [--progress-file ]\n\nRecords a progress checkpoint." } "park" => { "usage: repo-queue park [--worker ] [--lane ] --reason [--delay-seconds ] [--not-before ] [--progress

] [--progress-file ] [--ready-condition ] [--execution ] [--required-budget-minutes ] [--hands --action ]\n\nParks a task. A park that waits on a person is refused unless it is a hands item (FDR-0013): --hands physical|interactive-login|payment|signature with --action, one sentence a person can do in five minutes." @@ -269,16 +269,16 @@ pub(crate) fn usage(verb: &str) -> &'static str { "usage: repo-queue quarantine-recheck [--task ] [--limit ]\n\nRechecks quarantined tasks." } "cancel" => { - "usage: repo-queue cancel [--worker ] [--reason ]\n\nCancels a task." + "usage: repo-queue cancel [--worker ] --reason \n\nCancels a task. Without --worker, the cancellation is recorded under the default worker fleet-monitor." } "revive" => { "usage: repo-queue revive [--worker ] [--reason ] [--not-before ]\n\nRevives a terminal task." } "fail" => { - "usage: repo-queue fail [--worker ] [--lane ] [--error ] [--reason-class ] [--execution ]\n\nFails a task." + "usage: repo-queue fail [--worker ] [--lane ] --error [--reason-class ] [--execution ]\n\nFails a task. --reason-class is one of transient (the default), deterministic, blocked." } "complete" => { - "usage: repo-queue complete [--worker ] [--lane ] [--result ] [--result-file ] [--telemetry ] [--execution ] [--queue ]\n\nCompletes a task." + "usage: repo-queue complete [--worker ] [--lane ] [--result ] [--result-file ] [--telemetry ] [--execution ]\n\nCompletes a task." } "verify-disposition" => { "usage: repo-queue verify-disposition --repo [--pr ] [--follow-up-task | --follow-up-issue | --follow-up-pr ] [--reason ] [--staleness-seconds ] [--json]\n\nReads the issue and its linked PRs back from GitHub and prints the disposition a terminal completion must carry (#10611); exits 1 when the broker's gate would reject it." @@ -329,7 +329,7 @@ pub(crate) fn usage(verb: &str) -> &'static str { "usage: repo-queue stack restack --stack --position --base [--head-sha ] [--worker ]\n\nRestacks intents." } "stack replay" => { - "usage: repo-queue stack replay [--stack ] [--worker ] [--repo-dir

] [--dry-run]\n\nReplays a stack plan." + "usage: repo-queue stack replay --stack [--worker ] [--repo-dir ] [--dry-run]\n\nReplays a stack plan." } _ => TOP_USAGE, }