Skip to content

fleet-queue(validate): pr-set dedupe keys accept non-canonical spellings (single/repeated number) and maintenance keys accept impossible ISO weeks (W99) #5482

Closed

Description

@dezren39

Problem

pkgs/fleet/crates/fleet-queue/src/validate.rs — match_dedupe accepts dedupe-key spellings that the validator's own pattern contract forbids, so the same queue work can be enqueued under two different "deterministic" keys and the dedupe guarantee is bypassable at validation time (the DB backstop only catches identical keys, not alternate spellings of the same coverage).

The contract is in the same file, DEDUPE_PATTERNS_DOC (validate.rs:24-30, also printed verbatim in the validator's own error messages):

pr-set:      repo-health:v1:pr-set:<repo>:<n>-<n>[-...] (sorted)
maintenance: repo-health:v1:maintenance:<repo>:<kind>:<YYYY-Www>

Verified this run (shipped repo-queue validate, packets derived from the known-good packet for issue #5424)

  1. Single-number pr-set validates. Key repo-health:v1:pr-set:developing-today/code:5424 (kind pr_shepherd, payload prs: [{number: 5424}]) → {"valid": true}. The doc pattern requires <n>-<n> — at least two numbers. Root cause: the pr-set arm (validate.rs:203-215) splits the tail on - and only checks every part is digits; a one-element split passes. Consequence: one PR can be enqueued as either pr:…:pr:5424 or pr-set:…:5424 — two valid keys, one unit of work, dedupe defeated.
  2. Repeated-number pr-set validates. Key …:pr-set:developing-today/code:5424-5424 with prs listing 5424 twice → {"valid": true}. A "set" with a repeated element is not a set; the sortedness check in dedupe_errors (validate.rs:337-355) treats equal neighbours as sorted, and the payload comparison compares the same duplicated list, so nothing rejects it.
  3. Impossible ISO week validates. Key repo-health:v1:maintenance:developing-today/code:weekly:2026-W99 (kind triage) → {"valid": true}. The week check (validate.rs:231-235) verifies only shape (YYYY-W + two digits); ISO weeks run 01–53, so W99 (and W00) name no real week — a maintenance key for a week that does not exist can never collide with the correctly-spelled key for any real week, splitting maintenance dedupe by spelling.

Controls in the same run: a proper two-number pr-set key (…:100-5424) validates, and a non-numeric pr-set tail (…:abc) is rejected with the pattern doc — the matcher is live and the shapes above are genuine holes, not a disabled validator.

Why it matters

Dedupe keys are the queue's determinism contract: producers rely on validate to guarantee one canonical key per unit of work before enqueue. Every non-canonical spelling that validates is a second key for the same work — duplicate tasks for one PR set, or a maintenance task that the correctly-keyed weekly packet cannot dedupe against.

Acceptance criteria

  • match_dedupe's pr-set arm requires at least two numbers, all distinct (equivalently: strictly ascending at match time, with the existing dedupe_errors sortedness/payload checks unchanged).
  • Maintenance keys require the ISO week number in 01..=53.
  • Unit tests in validate.rs pin all three rejected shapes above plus the valid controls (single pr: key, two-number pr-set, 2026-W44-style maintenance key).
  • cargo test -p fleet-queue green (laptop or CI); the shipped repo-queue validate rejects the three repro packets and still accepts the controls.

Found by new-issue-creator-code-b (Lane B) during the 2026-11-04 run; verified against the live validator binary and the source at main 49d11b5.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    on Nov 4, 2026
  2. developing-today commented on Nov 4, 2026

    @developing-today
    Contributor
  3. added
    priority/normalOrdinary priority (the default)
    work/self-assignedAn agent grabbed this item directly, outside the queue
    app/fleetpkgs/fleet multicall binary + platform crates
    on Nov 4, 2026
  4. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b, Lane B)
    • Session / ID: cron new-issue-creator-code-b, 2026-11-04 07:50 CST run
    • Found via: filed this run
    • Task: Filed after verifying with the shipped repo-queue validate that pr-set dedupe keys accept a single number and a repeated number, and maintenance keys accept impossible ISO week W99 — all contrary to the pattern doc in the same file.
    • Expectation: effort xs — guarded self-solve this run: tighten match_dedupe in pkgs/fleet/crates/fleet-queue/src/validate.rs (pr-set ≥2 distinct numbers; maintenance week 01–53), pin with unit tests, PR + merge when green.
    • Links: branch creator-b/5482-dedupe-canonical (to come)
  5. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/fleetpkgs/fleet multicall binary + platform crateskind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions