Skip to content

rfc22: decode unordered input and resolve ambiguities in the text - #569

Merged
mergify[bot] merged 6 commits into
flux-framework:masterfrom
garlick:refine_idset
Nov 6, 2026
Merged

mergify[bot] merged 6 commits into
flux-framework:masterfrom
garlick:refine_idset

Conversation

@garlick

@garlick garlick commented Nov 6, 2026

Copy link
Copy Markdown
Member

Problem: a case came up where decoding an idset from a list of ids presented out of order would be useful

There's really no reason that idset_decode() couldn't allow this, so relax the RFC so that it can. While there, tighten up some ambiguities in the spec and add test vectors.

A few changes will be needed to the idset decoder in flux-core

  • reject empty elements
  • accept elements in any order
  • fix maxid in the sizing pre-pass
  • fix idset_decode_info() counts
  • match test coverage to the RFC
  • docs review

One user-visible change would be that command line idsets like flux exec -r 2,1 would no longer be rejected.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

⚠️ linkcheck failed with status code 2

@grondo grondo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I had just one trivial suggestion.

Comment thread spec_22.rst
Comment on lines +52 to +54
A range SHALL consist of two ids separated by a hyphen, where the
first id is less than the second, e.g. ``1-3,5-6,42``. A range SHALL
represent the first id, the second id, and all ids between them.

@grondo grondo Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: This paragraph describes "A range" so the example should include only a single range, e.g. 1-3. The current example shows a comma-separated list and includes a singleton.

@mergify

mergify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

Problem: RFC 22 permits consecutive ids to be compressed into
hyphenated ranges, but does not say what a range denotes or
constrain its endpoints.  It is unclear whether "3-0", "2-2", or
"1-2-3" are valid, and what ids they represent.

Define an idset string as a comma-delimited list of elements,
each either a single id or a range.  Define a range as two ids
separated by a hyphen, the first less than the second, which
represents both ids and all ids between them.  Restate the
ascending order requirement in terms of the ids the elements
represent.

Assisted-by: claude:opus-5.5
Problem: RFC 22 does not say how the empty idset is represented,
yet implementations rely on decoding the empty string to the
empty set, e.g. the flux-core shell decodes an unset GPU list as
"".

State that an idset string with no elements, such as the empty
string or "[]", represents the empty idset.

Assisted-by: claude:opus-5.5
Problem: RFC 22 allows one idset to be written many ways, e.g.
"1-4", "1-2,3-4", "1,2-4", and "[1-4]", but names no preferred
form and places no requirements on encoders or decoders
separately.  Idset strings cannot be compared as text, and
encoders have no single output to agree on.

Add a Syntax heading over the existing rules.  Define a
normalized idset string as one that represents each id exactly
once in ascending order, with ranges, if used, covering each
maximal run of consecutive ids.  Define the canonical idset
string as the normalized string that uses ranges and no
brackets, so each idset has exactly one.  Require encoders to
produce a normalized string and recommend the canonical one,
and require decoders to accept any idset string.
Allow an implementation to limit the largest id it supports,
treating strings with larger ids as invalid.

Assisted-by: claude:opus-5.5
Problem: RFC 22 requires the ids in an idset string to be in
ascending order, so a string like "6,4,2,0" is invalid even
though it unambiguously names a set.  MPICH's PMI-1.2
PMI_Barrier_group() emits rank lists in communicator order,
which need not be ascending, so Flux cannot decode them as
idset strings.

Drop the ascending order requirement.  Allow elements to
appear in any order and the ids they represent to repeat or
overlap, and define the idset an idset string represents as
the union of its elements.  Normalized and canonical idset
strings remain ascending, so encoders are unaffected.

Assisted-by: claude:opus-5.5
Problem: RFC 22 requires decoders to accept every idset string
but says nothing about other strings.  A decoder may silently
accept malformed input such as "1,,2", so a typo can go
unnoticed, and implementations may disagree about what such a
string means.

Require decoders to reject any string that is not an idset
string.

Assisted-by: claude:opus-5.5
Problem: RFC 22 has no test vectors, so implementations have no
shared reference for which strings are valid, what idset each
represents, or which strings are normalized.

Add a table of idset strings with the canonical idset string of
the idset each represents and whether each is normalized, and a
table of strings that are not idset strings.

Assisted-by: claude:opus-5.5
@garlick

garlick commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Thanks! Good catch. I pushed that change and will set MWP.

@mergify mergify Bot added the queued label Nov 6, 2026
@mergify
mergify Bot merged commit 87d815d into flux-framework:master Nov 6, 2026
7 of 8 checks passed
@mergify

mergify Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

✅ Merged into master as 87d815d at 17:40 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Fri 6 Nov, 17:40 · rule default · triggered by rule rebase and merge when passing all checks
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 17:40 · 87d815d · merge
4 merge conditions met
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = docs/readthedocs.org:flux-rfc
    • check-neutral = docs/readthedocs.org:flux-rfc
    • check-skipped = docs/readthedocs.org:flux-rfc
  • any of · required by GitHub branch protection:
    • check-success = make check
    • check-neutral = make check
    • check-skipped = make check
  • any of · required by GitHub branch protection:
    • check-success = validate commits
    • check-neutral = validate commits
    • check-skipped = validate commits

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot removed the queued label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

⚠️ linkcheck failed with status code 2

@garlick
garlick deleted the refine_idset branch November 6, 2026 17:58
garlick added a commit to garlick/flux-core that referenced this pull request Nov 7, 2026
Problem: the idset decoder rejects a string whose elements do not
ascend, such as "6,4,2,0", even though it unambiguously names a set.
RFC 22 (flux-framework/rfc#569) now allows elements in any order,
including repeated and overlapping ids, and defines the idset as the
union of the elements.

Drop the ascending order check when adding or subtracting elements.
Track the maximum id as a running maximum rather than the last
element's upper bound, so idsets sized from a pre-pass are large
enough.

idset_decode_info() sums the sizes of the elements, which overcounts
overlapping input.  When the elements overlap or do not ascend, re-parse
them into an array of ranges, sort it, and merge overlapping and abutting
ranges to count exactly.  The cost is proportional to the number of
elements rather than the id space, so the documented promise that
idset_decode_info() and idset_decode_empty() do not create an idset
still holds.  idset_decode_empty() needs no count at all, only
whether any element was parsed.

Update tests that expected unordered input to fail.
Add tests for unordered and overlapping input.

Fixes flux-framework#7888

Assisted-by: claude:opus-5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants