Skip to content
Merged
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
54 changes: 54 additions & 0 deletions pkgs/fleet/crates/fleet-queue/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 — "<verb>: --<flag> ... is
// required" and the "<verb> requires --<flag>" 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<String> = 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<String> = 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,6 @@ pub(super) fn cmd_complete(rest: &[String]) -> i32 {
"result-file",
"telemetry",
"execution",
"queue",
],
&[],
);
Expand Down
22 changes: 11 additions & 11 deletions pkgs/fleet/crates/fleet-queue/src/client/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,21 @@ Run `repo-queue <verb> --help` for flags:\n\
enqueue <packet-path> [--queue <name>] [--platform <p>] [--dry-run] [--shadow-intent]\n\
list [--queue <name>] [--status <s>] [--limit <n>] [--not-before <ts>] [--lane <l>] [--worker <w>] [--task <id>]\n\
claim [--queue <name>] [--worker <id>] [--lease-seconds <n>] [--lane <l>] [--task <id>] [--count <n>] [--from-session <id>] [--platform <p>] [--session-id <id>] [--model-provider <p>] [--model-id <id>] [--model-variant <v>] [--filter <f>] [--pool <p>] [--launched-by <who>] [--remaining-budget-minutes <n>] [--handoff] [--bind]\n\
release <task-id> [--worker <id>] [--reason <text>]\n\
release <task-id> [--worker <id>] --reason <text>\n\
lane <task-id> [--worker <id>] [--exclusion-reason <text>] [--opencode-reason <text>] [--limit-platform <p>] [--limit-reason <text>] [--clear-platform-limit]\n\
bind <task-id> [--worker <id>] --session-id <id> [--launched-by <who>] [--model-provider <p>] [--model-id <id>] [--model-variant <v>]\n\
heartbeat <task-id> [--worker <id>] [--extend-seconds <n>] [--progress <p>] [--progress-file <f>]\n\
checkpoint <task-id> [--worker <id>] [--stage <s>] [--progress <p>] [--progress-file <f>]\n\
checkpoint <task-id> [--worker <id>] --stage <s> [--progress <p>] [--progress-file <f>]\n\
park <task-id> [--worker <id>] --reason <text> [--delay-seconds <n>] [--not-before <ts>] [--progress <p>] [--progress-file <f>] [--ready-condition <c>] [--execution <id>] [--required-budget-minutes <n>] [--hands <kind> --action <text>]\n\
wake <task-id> [--worker <id>] [--reason <text>]\n\
block <task-id> [--worker <id>] --reason-class <c> --blocker <b> [--progress <p>] [--progress-file <f>] [--ledger-id <id>] [--question <text>] [--context <text>] [--options-json <json>] [--links-json <json>] [--blocked-by-pr <n>] [--blocked-by-issue <n>] [--blocked-by-task <id>] [--blocked-by-ci <ref>] [--dep-recheck-seconds <n>] [--dep-max-ttl-seconds <n>] [--hands <kind> --action <text>]\n\
unblock <task-id> [--worker <id>] [--reason <text>] [--drop-dep <list>]\n\
dep-recheck [--task <id>] [--limit <n>]\n\
quarantine-recheck [--task <id>] [--limit <n>]\n\
cancel <task-id> [--worker <id>] [--reason <text>]\n\
cancel <task-id> [--worker <id>] --reason <text>\n\
revive <task-id> [--worker <id>] [--reason <text>] [--not-before <ts>]\n\
fail <task-id> [--worker <id>] [--error <text>] [--reason-class <c>] [--execution <id>]\n\
complete <task-id> [--worker <id>] [--result <json>] [--result-file <f>] [--telemetry <json>] [--execution <id>] [--queue <name>]\n\
fail <task-id> [--worker <id>] --error <text> [--reason-class <c>] [--execution <id>]\n\
complete <task-id> [--worker <id>] [--result <json>] [--result-file <f>] [--telemetry <json>] [--execution <id>]\n\
verify-disposition <issue> --repo <owner/name> [--pr <n,n>] [--follow-up-task <id> | --follow-up-issue <n|url> | --follow-up-pr <n>] [--reason <text>] [--staleness-seconds <n>] [--json]\n\
timeline <task-id> [--worker <id>] [--json]\n\
history <task-id> [--worker <id>] [--json] (alias of timeline)\n\
Expand Down Expand Up @@ -236,7 +236,7 @@ pub(crate) fn usage(verb: &str) -> &'static str {
"usage: repo-queue claim [--queue <name>] [--worker <id>] [--lease-seconds <n>] [--lane <l>] [--task <id>] [--count <n>] [--from-session <id>] [--platform <p>] [--session-id <id>] [--model-provider <p>] [--model-id <id>] [--model-variant <v>] [--filter <f>] [--pool <p>] [--launched-by <who>] [--remaining-budget-minutes <n>] [--handoff] [--bind]\n\nClaims the highest-priority eligible task."
}
"release" => {
"usage: repo-queue release <task-id> [--worker <id>] [--lane <id>] [--reason <text>]\n\nReleases a held claim."
"usage: repo-queue release <task-id> [--worker <id>] [--lane <id>] --reason <text>\n\nReleases a held claim."
}
"lane" => {
"usage: repo-queue lane <task-id> [--worker <id>] [--exclusion-reason <text>] [--opencode-reason <text>] [--limit-platform <p>] [--limit-reason <text>] [--clear-platform-limit]\n\nReports lane progress on a task."
Expand All @@ -248,7 +248,7 @@ pub(crate) fn usage(verb: &str) -> &'static str {
"usage: repo-queue heartbeat <task-id> [--worker <id>] [--lane <id>] [--extend-seconds <n>] [--progress <p>] [--progress-file <f>]\n\nRefreshes a claim lease."
}
"checkpoint" => {
"usage: repo-queue checkpoint <task-id> [--worker <id>] [--lane <id>] [--stage <s>] [--progress <p>] [--progress-file <f>]\n\nRecords a progress checkpoint."
"usage: repo-queue checkpoint <task-id> [--worker <id>] [--lane <id>] --stage <s> [--progress <p>] [--progress-file <f>]\n\nRecords a progress checkpoint."
}
"park" => {
"usage: repo-queue park <task-id> [--worker <id>] [--lane <id>] --reason <text> [--delay-seconds <n>] [--not-before <ts>] [--progress <p>] [--progress-file <f>] [--ready-condition <c>] [--execution <id>] [--required-budget-minutes <n>] [--hands <kind> --action <text>]\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."
Expand All @@ -269,16 +269,16 @@ pub(crate) fn usage(verb: &str) -> &'static str {
"usage: repo-queue quarantine-recheck [--task <id>] [--limit <n>]\n\nRechecks quarantined tasks."
}
"cancel" => {
"usage: repo-queue cancel <task-id> [--worker <id>] [--reason <text>]\n\nCancels a task."
"usage: repo-queue cancel <task-id> [--worker <id>] --reason <text>\n\nCancels a task. Without --worker, the cancellation is recorded under the default worker fleet-monitor."
}
"revive" => {
"usage: repo-queue revive <task-id> [--worker <id>] [--reason <text>] [--not-before <ts>]\n\nRevives a terminal task."
}
"fail" => {
"usage: repo-queue fail <task-id> [--worker <id>] [--lane <id>] [--error <text>] [--reason-class <c>] [--execution <id>]\n\nFails a task."
"usage: repo-queue fail <task-id> [--worker <id>] [--lane <id>] --error <text> [--reason-class <c>] [--execution <id>]\n\nFails a task. --reason-class is one of transient (the default), deterministic, blocked."
}
"complete" => {
"usage: repo-queue complete <task-id> [--worker <id>] [--lane <id>] [--result <json>] [--result-file <f>] [--telemetry <json>] [--execution <id>] [--queue <name>]\n\nCompletes a task."
"usage: repo-queue complete <task-id> [--worker <id>] [--lane <id>] [--result <json>] [--result-file <f>] [--telemetry <json>] [--execution <id>]\n\nCompletes a task."
}
"verify-disposition" => {
"usage: repo-queue verify-disposition <issue> --repo <owner/name> [--pr <n,n>] [--follow-up-task <id> | --follow-up-issue <n|url> | --follow-up-pr <n>] [--reason <text>] [--staleness-seconds <n>] [--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."
Expand Down Expand Up @@ -329,7 +329,7 @@ pub(crate) fn usage(verb: &str) -> &'static str {
"usage: repo-queue stack restack --stack <id> --position <n> --base <b> [--head-sha <sha>] [--worker <id>]\n\nRestacks intents."
}
"stack replay" => {
"usage: repo-queue stack replay [--stack <id>] [--worker <id>] [--repo-dir <dir>] [--dry-run]\n\nReplays a stack plan."
"usage: repo-queue stack replay --stack <id> [--worker <id>] [--repo-dir <dir>] [--dry-run]\n\nReplays a stack plan."
}
_ => TOP_USAGE,
}
Expand Down