Skip to content

Validate conflicting short flags in command signatures #400

Open

Description

@vikvang

Problem

A handwritten command signature can define the same short flag for multiple options within one command. This produces ambiguous generated shell completions because the completion engine cannot determine which option the short flag represents.

Desired behavior

Validate command-signature option definitions and report a clear error when two options on the same command use the same short flag.

Acceptance criteria

  • Detect duplicate short flags within a single handwritten command signature.
  • Identify the affected command, short flag, and conflicting options in the validation error.
  • Allow the same short flag on unrelated commands or subcommands.
  • Add focused valid and invalid fixture coverage.
  • Run the check through the repository’s existing validation or presubmit path.

Scope

This concerns command-completion signature correctness only; it does not require Warp application UI changes.

@warp-factory Please triage and route this issue using the deployed ownership source.

Activity

  1. warp-agent-staging commented on Sep 4, 2026

    @warp-agent-staging
    Contributor

    No Factory you can access is connected to warpdotdev/command-signatures. Go to platform.staging.warp.dev to connect this repository to a Factory or ask a Factory admin for access. See Factory GitHub integration docs. Then mention @warp-factory again.

  2. warp-factories commented on Sep 4, 2026

    @warp-factories
    Contributor

    Here's what I found while triaging this issue:

    What the code shows. Handwritten specs store option names — including short flags like -h — in each option's name array (CommandOption → Opt.exact_string). Short vs. long flags are already classified by is_short_hand_flag / Signature::short_hand_flags() in completion-metadata/src/signature.rs, but nothing asserts that short flags are unique within a command or subcommand. So the ambiguity you describe is real and currently unguarded.

    Where a check would live. The repository's signature invariants are unit tests in command-signatures/src/lib.rs (deserialization, generator existence, unsafe-newline checks), run by script/presubmit and the cargo test job in .github/workflows/CI.yml. A uniqueness check fits there, or as a shared helper in completion-metadata exercised by those tests. There is no fixture/testdata tree today, so the valid/invalid coverage you ask for would be new focused test cases.

    Worth knowing before implementing. A scan of the handwritten specs found 45 duplicate-short-flag instances across 13 files (brew.json, copilot.json, kubectl.json, rsync.json, yarn.json, and others). Enforcing this as a hard failure will break CI on main until those are fixed, so the work likely needs either a cleanup pass first or a phased/allowlisted rollout — worth a maintainer decision.

    Related, not duplicate. #399 asks for duplicate option name validation and #374 asks to document the short/long pairing convention; both are neighbours to this, not the same request.

    Maintainer details

    Classification

    Enhancement — a request to add repository-side validation that rejects duplicate short flags within a single command signature. Not a Warp runtime bug; the reporter supplied acceptance criteria for a new check.

    Reproducibility

    High. Verified against current main: no short-flag uniqueness check exists (is_short_hand_flag only classifies flags). Scanning command-signatures/json/** (excluding autogenerated specs and overrides) surfaced 45 conflicts in 13 handwritten specs, so the condition is already present in-tree and would be immediately observable from a new test.

    Investigation

    Option model and conversion: completion-metadata/src/fig_types.rs (CommandOption.name, From<CommandOption> for Opt ~485–498, From<Command> for Vec<Signature> ~341–393). Short-flag helpers: completion-metadata/src/signature.rs (is_short_hand_flag ~94–96, short_hand_flags ~107–118, Opt.exact_string ~169–176). Existing validation entry points: command-signatures/src/lib.rs tests (~56–259, incl. all_command_specs_succeed_deserialization), script/presubmit (format + clippy + cargo test), and the .github/workflows/CI.yml test job. No duplicate-short-flag validator, fixture directory, or dedicated validation module exists. Live offenders include brew/services (-v/-h), several copilot subcommands (-n), kubectl/kubecolor/oc expose (-l), rsync (-h), yarn (-s), flutter assemble/symbolize (-d), plus pscale, pulumi, sfdx, stripe, and zapier.

    Duplicate search

    Enumerated open issues and recent closed issues, searching the validate / duplicate / short-flag / conflicting-option themes. Closest neighbours are #399 (validate duplicate option names — same validation theme, different target: full option-name identity rather than short-flag uniqueness) and #374 (documentation of the short/long pairing convention). No second strong match, so this is not treated as a duplicate.

    Routing reasoning

    Resolved from the live warpdotdev/warp-ownership source: warpdotdev/warp-ownership/ownership-areas/app.md, ownership area ### Command Completions (Matches: command completions and suggestions triggered by slash or command entry, autocomplete specific to commands). This issue concerns the correctness of Warp's handwritten command-completion signatures, which is that area's surface. Sole owner listed: @acarl005; assignment succeeded. The adjacent ### Completions and Bootstrap area was considered and rejected — it covers shell-native tab completions and shell startup, not Warp's command signature specs.

    Routing to @acarl005 to review and apply a gate label (ready-to-spec / ready-to-implement) if this should proceed.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Responding as Warp for OSS: Open session · View run

  3. added
    triaged
    enhancement
    repro:high
    on Sep 4, 2026
  4. added
    ready-to-spec
    on Sep 4, 2026
  5. warp-factories commented on Sep 4, 2026

    @warp-factories
    Contributor

    This issue has been marked ready for a specification. Community contributions are welcome — feel free to pick it up. A maintainer can also mention or assign @warp-factory to start automated work on it.

  6. vikvang commented on Sep 4, 2026

    @vikvang
    ContributorAuthor

    @warp-factory get to work

  7. warp-agent-staging commented on Sep 4, 2026

    @warp-agent-staging
    Contributor

    No Factory you can access is connected to warpdotdev/command-signatures. Go to platform.staging.warp.dev to connect this repository to a Factory or ask a Factory admin for access. See Factory GitHub integration docs. Then mention @warp-factory again.

  8. warp-factories commented on Sep 4, 2026

    @warp-factories
    Contributor

    Spec approved. The specification for this issue is #401 (specs/GH400/product.md, specs/GH400/tech.md), and a maintainer has marked it plan-approved. I've cleared ready-to-spec since that stage is done.

    The spec pins down the uniqueness rule (per command and per subcommand, with subcommands as separate namespaces), the error content required by the acceptance criteria — command path, offending short flag, and the conflicting option names — and where the check hooks into the existing invariant tests that script/presubmit and CI already run.

    On rollout: current main (d69b340) has 45 conflicting short-flag keys across 13 handwritten specs — copilot.json alone accounts for 27, plus brew, flutter, kubecolor, kubectl, oc, pscale, pulumi, rsync, sfdx, stripe, yarn, and zapier. A hard check would fail CI on day one, so the spec lands a "no new conflicts" invariant with an exact baseline allowlist: unexpected conflicts fail, stale allowlist entries also fail, a linked burn-down issue tracks cleanup, and the mechanism is deleted once the list reaches zero.

    Next step is yours. Implementation is still gated — apply ready-to-implement here and assign @warp-factory, and the factory will pick it up. Merging #401 also stays a human decision.

    Reasoning

    Stage record for this issue.

    Spec stage ran under ready-to-spec plus a maintainer mention; the stage gate returned PROCEED. No spec or implementation PR referenced this issue beforehand, so #401 is the first. It is a draft against main from factory/spec-gh400-short-flag-validation, containing only the two spec documents — no command spec JSON and no production Rust touched.

    The offender counts were re-derived against origin/main at d69b340 rather than carried over from triage: brew (2), copilot (27), flutter (2), kubecolor (1), kubectl (1), oc (1), pscale (2), pulumi (1), rsync (1), sfdx (1), stripe (4), yarn (1), zapier (1).

    The spec notes that a shared validation helper could also serve #399 (duplicate option names); that overlap is called out but deliberately not implemented. #374 (documenting the short/long pairing convention) remains adjacent and untouched.

    The implement gate was checked after approval and returned BLOCKED: the issue does not carry ready-to-implement. No implementation work was started. Gate labels are never applied by the factory.

    One caveat on verification: cargo and prettier were unavailable in the sandbox, so no build or format check ran on the spec branch. The change is documentation-only, so git diff --check was the extent of the mechanical validation.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Responding as Warp for OSS: Open session · View run

  9. removed
    ready-to-spec
    on Sep 4, 2026
  10. added
    ready-to-implement
    on Sep 4, 2026
  11. vikvang commented on Sep 4, 2026

    @vikvang
    ContributorAuthor

    @warp-factory implement

  12. warp-agent-staging commented on Sep 4, 2026

    @warp-agent-staging
    Contributor

    No Factory you can access is connected to warpdotdev/command-signatures. Go to platform.staging.warp.dev to connect this repository to a Factory or ask a Factory admin for access. See Factory GitHub integration docs. Then mention @warp-factory again.

  13. warp-factories commented on Sep 4, 2026

    @warp-factories
    Contributor

    Implementation is ready for review: #401. It builds on the approved spec branch, so the spec and the code land together rather than as two PRs. @acarl005 has been requested as reviewer.

    What it adds: a find_short_flag_conflicts validator in completion-metadata/src/validation.rs that walks each authored command node and groups options by short flag, 14 valid/invalid JSON fixtures with 13 tests covering namespace boundaries and encoded-vs-literal spellings, and a repository invariant in command-signatures/src/lib.rs wired into the cargo test path that script/presubmit and CI already run.

    On the existing 45 conflicts: the invariant freezes them as a baseline of full conflict records — file, canonical command path, normalized flag, and the ordered claimant list. A new conflict fails, and so does adding, removing, or reordering a claimant under an already-baselined key. #402 tracks burning that baseline down to zero, after which the mechanism is deleted.

    CI is green (Rust CodeQL still finishing, nothing failing). Merging is yours to decide.

    Reasoning

    Stage record for this issue.

    Gate history: ready-to-spec plus a maintainer mention cleared the spec stage; plan-approved on #401 closed it; ready-to-implement plus a maintainer mention cleared the implement stage. A ready-to-implement label event that arrived without a mention was correctly treated as announce-only. The factory applied no gate labels at any point.

    PR #401 was converted in place from the spec PR rather than duplicated, per the rule that an approved factory spec PR becomes the implementation PR. Head is 8f25735; it carries plan-approved, cla-signed, and factory:warp-for-oss, and was promoted out of draft once the factory review accepted it.

    Three defects were found and fixed across the review passes before the PR was handed over:

    1. The baseline originally compared bare (file, path, flag) keys, so a third claimant added under an existing conflict — or a swapped claimant — would have slipped through the "no new conflicts" gate. It now freezes ordered claimant identity.
    2. Validation originally inspected raw CommandOption.name, but From<CommandOption> for Opt applies html_unescape before is_short_hand_flag classifies Opt.exact_string. &#45;h and -h are the same flag at runtime and would not have collided. Validation now applies the same normalization first, with a fixture pinning it.
    3. The invariant's own failure output used {:?} on raw tuples, emitting zero-based debug output instead of the actionable diagnostic the acceptance criteria require. All three failure modes now route through ShortFlagConflict::describe, with a pinned-text regression test.

    Verification: the author ran cargo build --workspace, cargo test --workspace (183 tests in warp-command-signatures, 12 unit + 13 integration in warp-completion-metadata), cargo fmt --check, cargo clippy -- -D warnings, and bash script/presubmit, all passing. The reviewer could not run cargo in its sandbox and said so rather than repeating the claim; it did independently cross-check all 45 baseline records against the handwritten JSON, finding no missing keys, no stale keys, and no claimant mismatches, and verified namespace isolation for siblings, parent/child, and separate roots. Security review found nothing: the change validates repository-local JSON during tests and adds no external input, credential, dependency, or authorization surface.

    None of the 45 offending command JSON files were modified; that cleanup is #402.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Responding as Warp for OSS: Open session · View run

  14. added a commit that references this issue on Sep 4, 2026
    95d904b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementready-to-implementrepro:hightriaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions