Skip to content
Open
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
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ jobs:
- name: Every packable project declares a release train
run: bash scripts/verify-package-trains.sh

# L'ordre des versions NuGet et l'analyse des plages sont la partie de la
# garde de release qui peut être fausse SUBTILEMENT — un `preview.5` jugé
# supérieur à `preview.5.11` la rendrait muette pile sur le cas qui l'a
# motivée. L'auto-test ne demande ni réseau ni paquet, donc il tourne ici
# sur chaque poussée, et pas seulement le jour d'une release.
- name: Version-range comparator self-test
run: bash scripts/verify-package-dependencies-exist.sh --self-test

- name: Enforce 90% line coverage gate
# Per ADR-0006: with the heavy integration-bound adapters extracted to their
# own repos, the framework's aggregate line coverage is well above 90 % and
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ jobs:
- name: Verify no version is being republished
run: bash scripts/verify-package-not-published.sh artifacts/

# La quatrième garde, et la seule qui regarde ce dont le paquet DÉPEND.
#
# Le 2026-09-29, `testing-v1.0.5-preview.6` a été tagué SEUL, sur un commit
# onze commits après `core-v1.0.5-preview.5`. MinVer a donc tamponné les
# dépendances du paquet en `1.0.5-preview.5.11` — jamais publiée, et qui
# sort AU-DESSUS de `preview.5` (une suite plus longue d'identifiants de
# préversion avec le même préfixe gagne), donc le `>=` qu'elle exprime
# n'était satisfait par rien. La release est passée VERTE et a produit un
# paquet que personne ne pouvait installer (`NU1102`), sur un registre qui
# n'autorise pas la suppression.
#
# Les trois gardes ci-dessus regardent toutes LE paquet : son train, sa
# provenance, sa version. Aucune ne regarde ce dont il dépend.
#
# La règle que ça grave : un train aval se tague AVEC son train amont, sur
# le même commit. Elle était déjà écrite — en prose, dans le `$comment` de
# `compendium-floor-gaps.json` côté Nexus — là où elle pouvait être, et a
# été, manquée.
- name: Verify every Compendium dependency can be resolved
run: bash scripts/verify-package-dependencies-exist.sh artifacts/

- name: Push to nuget.org
run: |
dotnet nuget push "artifacts/*.nupkg" \
Expand Down
60 changes: 58 additions & 2 deletions docs/operations/release-trains.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,44 @@ and nothing else changes version.
Adding a package means adding a `<MinVerTagPrefix>` and seeding its first tag.
Nothing else: the release job discovers trains from the `.csproj` files.

## The two gates
## A downstream train is tagged WITH its upstream train

One train at a time is true of what gets *packed*. It is **not** true of what gets
*tagged*, and the difference cost a broken public package on 2026-09-29.

`Compendium.Testing` depends on the `core-v` train. MinVer derives each dependency
version from the depended-on project's own tag **at the commit being tagged**. Tag
`testing-v` alone, on a commit that has moved past the last `core-v` tag, and
MinVer stamps the dependency with a height-suffixed version — `1.0.5-preview.5.11`
for eleven commits past `core-v1.0.5-preview.5`. That version was never published.
Worse, it sorts **above** `1.0.5-preview.5`: a longer run of prerelease identifiers
with the same prefix wins, so the `>=` it expresses is satisfied by nothing on the
feed. The release went green and produced a package that answered `NU1102` to
every consumer.

So:

```bash
# Compendium.Testing moves -> the core train moves with it, same commit.
git tag core-v1.0.5-preview.7
git tag testing-v1.0.5-preview.7
git push origin core-v1.0.5-preview.7 testing-v1.0.5-preview.7
```

Publish the upstream train first and let it land on the feed; the downstream
package's own gate reads the feed, so the order matters for the gate, not for
MinVer.

`Compendium.Abstractions.FeatureFlags` belongs to the same release unit in
practice: Nexus pins it alongside the core train, and a `featureflags-v` left
behind makes `CompendiumProvenanceRuleTests` fail there. The 2026-09-05 release
tagged `core-v`, `featureflags-v` and `testing-v` together, and that was not a
coincidence.

**The third gate below now enforces this mechanically.** Do not rely on
remembering it.

## The three gates

Two packages are public today whose nuspec records a commit that is on no tag.
Neither went through the test gate or the coverage gate, and neither can be
Expand All @@ -80,7 +117,26 @@ between `Pack` and `Push`, so a failure means nothing is published:
collision means a tag was moved. An unreachable feed is also a failure — not
knowing is not permission.

Both take a directory or individual packages, read id, version and commit from
- **`scripts/verify-package-dependencies-exist.sh artifacts/`** — the only gate
that looks at what a package DEPENDS ON rather than at the package. For every
`Compendium.*` dependency in the packed nuspec it asks the feed whether any
published version satisfies the declared range. A dependency nothing can satisfy
means a downstream train was tagged without its upstream train — see the section
above. Only `Compendium.*` is judged: third-party dependencies came from versions
the build already restored, so the build itself proves they exist. An unreachable
feed is a failure here too.

The range is treated as a **range**, not an equality: `1.0.5-preview.7` means
`>= 1.0.5-preview.7`, and a higher published version satisfies it. Checking for
the exact string would turn the gate red on legitimate releases, which on the
only irreversible step of a release is worse than no gate.

Version ordering and range parsing live in
`scripts/nuget-version-satisfies.py`, which carries a `--self-test` that needs
neither network nor package. `ci.yml` runs it on every push, so the comparator
cannot rot between releases.

All three take a directory or individual packages, read id, version and commit from
the embedded nuspec rather than from the file name, and report every offending
package before exiting.

Expand Down
263 changes: 263 additions & 0 deletions scripts/nuget-version-satisfies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
#!/usr/bin/env python3
"""Decide whether any published version satisfies a NuGet dependency range.

Used by verify-package-dependencies-exist.sh. Kept as its own file rather than a
heredoc so that `--self-test` can exercise it without a network and without a
packed .nupkg.

A nuspec dependency `version` is a RANGE, not an equality. `1.0.5-preview.7`
means `>= 1.0.5-preview.7`. Checking for the exact string would reject a
legitimate release the moment a higher version exists and the exact floor does
not — a false red on the only irreversible step of a release, which is worse
than no check at all.

Reads the flat-container index JSON on stdin.

Usage:
nuget-version-satisfies.py <range> [--self-test]

Exit status:
0 at least one published version satisfies the range
1 none does
2 the range could not be parsed, or the index is unreadable
(not knowing is not permission — the caller must treat this as a failure)
"""
import io
import json
import re
import sys

# --------------------------------------------------------------------------- #
# NuGet version ordering
# --------------------------------------------------------------------------- #

_VERSION = re.compile(
r"^\s*(?P<release>\d+(?:\.\d+){0,3})"
r"(?:-(?P<pre>[0-9A-Za-z.-]+))?"
r"(?:\+(?P<meta>[0-9A-Za-z.-]+))?\s*$"
)


def parse(text):
"""Return a sort key, or None when `text` is not a version."""
m = _VERSION.match(text or "")
if not m:
return None

release = [int(p) for p in m.group("release").split(".")]
# NuGet compares on four parts; a missing part is zero.
release += [0] * (4 - len(release))

pre = m.group("pre")
if pre is None:
# No prerelease sorts ABOVE any prerelease of the same release.
return (release, 1, [])

parts = []
for ident in pre.split("."):
if ident.isdigit():
# Numeric identifiers compare numerically and below alphanumeric ones.
parts.append((0, int(ident), ""))
else:
parts.append((1, 0, ident.lower()))
return (release, 0, parts)


def less(a, b):
"""a < b, on keys produced by parse()."""
if a[0] != b[0]:
return a[0] < b[0]
if a[1] != b[1]:
return a[1] < b[1]
# Prerelease identifiers: compare element by element; a shorter run of
# identifiers sorts below a longer one with the same prefix, which is why
# `preview.5` < `preview.5.11` — the exact trap that shipped a package
# nobody could install on 2026-09-29.
for x, y in zip(a[2], b[2]):
if x != y:
return x < y
return len(a[2]) < len(b[2])


# --------------------------------------------------------------------------- #
# Range parsing
# --------------------------------------------------------------------------- #

def bounds(spec):
"""Return (low, low_inclusive, high, high_inclusive) or None if unparseable.

`low`/`high` are parse() keys, or None for "unbounded on that side".
"""
spec = (spec or "").strip()
if not spec:
return None

if not (spec[0] in "[(" and spec[-1] in "])"):
# Bare version: a MINIMUM, inclusive. This is what `dotnet pack` writes.
key = parse(spec)
return None if key is None else (key, True, None, False)

low_inc = spec[0] == "["
high_inc = spec[-1] == "]"
inner = spec[1:-1]

if "," not in inner:
# `[1.2.3]` — an exact version. `(1.2.3)` is not legal NuGet.
if not (low_inc and high_inc):
return None
key = parse(inner)
return None if key is None else (key, True, key, True)

low_text, _, high_text = inner.partition(",")
low = parse(low_text) if low_text.strip() else None
high = parse(high_text) if high_text.strip() else None
if (low_text.strip() and low is None) or (high_text.strip() and high is None):
return None
return (low, low_inc, high, high_inc)


def satisfies(key, rng):
low, low_inc, high, high_inc = rng
if low is not None:
if less(key, low):
return False
if not low_inc and not less(low, key):
return False
if high is not None:
if less(high, key):
return False
if not high_inc and not less(key, high):
return False
return True


# --------------------------------------------------------------------------- #
# Self-test — offline, no network, no .nupkg
# --------------------------------------------------------------------------- #

class _Stdin:
"""Minimal stand-in for sys.stdin exposing the `.buffer` main() reads."""

def __init__(self, payload):
self.buffer = io.BytesIO(payload)



def self_test():
ordering = [
# (lower, higher) — every pair must hold in this direction.
("1.0.4", "1.0.5"),
("1.0.5-preview.1", "1.0.5-preview.2"),
("1.0.5-preview.2", "1.0.5-preview.10"), # numeric, not lexical
("1.0.5-preview.5", "1.0.5-preview.5.11"), # THE 2026-09-29 trap
("1.0.5-preview.7", "1.0.5"), # release beats prerelease
("1.0.5-alpha", "1.0.5-beta"),
("1.0.5-preview.5", "1.0.5-preview.5.0"),
]
cases = [
# (range, published versions, expected exit)
("1.0.5-preview.7", ["1.0.5-preview.7"], 0),
("1.0.5-preview.7", ["1.0.5-preview.8"], 0), # higher satisfies a minimum
("1.0.5-preview.7", ["1.0.5"], 0),
("1.0.5-preview.5.11", ["1.0.5-preview.5"], 1), # the real failure, reproduced
("1.0.5-preview.5.11", ["1.0.5-preview.5",
"1.0.5-preview.4"], 1),
("1.0.5-preview.5.11", ["1.0.5-preview.6"], 0),
("1.0.5-preview.7", [], 1),
("[1.0.5-preview.7]", ["1.0.5-preview.8"], 1), # exact range, nothing matches
("[1.0.5-preview.7]", ["1.0.5-preview.7"], 0),
("[1.0.0,2.0.0)", ["2.0.0"], 1),
("[1.0.0,2.0.0)", ["1.9.9"], 0),
("(1.0.0,)", ["1.0.0"], 1), # exclusive lower bound
("(1.0.0,)", ["1.0.1"], 0),
("(,1.0.0]", ["0.9.0"], 0), # no lower bound
("not-a-version", ["1.0.0"], 2),
("", ["1.0.0"], 2),
]

failures = []

for lower, higher in ordering:
a, b = parse(lower), parse(higher)
if a is None or b is None:
failures.append(f"ordering: unparseable pair {lower} / {higher}")
elif not less(a, b):
failures.append(f"ordering: expected {lower} < {higher}")
elif less(b, a):
failures.append(f"ordering: {higher} < {lower} must not hold")

# Exercised THROUGH main(), deliberately — not through bounds() and
# satisfies() directly. The first version of this self-test called the
# internals and passed 23/23 while main() was broken by an off-by-one on
# argv: every real invocation exited 2 and the guard refused every package,
# valid ones included. A self-test that skips the entry point does not test
# the thing that runs.
import io

for spec, published, expected in cases:
# stderr is captured too: two cases exercise the unparseable-range path
# on purpose, and their diagnostics are expected output, not a problem.
# A self-test that prints them on success buries its own verdict.
saved = (sys.stdin, sys.stdout, sys.stderr)
sys.stdin = _Stdin(json.dumps({"versions": published}).encode("utf-8"))
sys.stdout, sys.stderr = io.StringIO(), io.StringIO()
try:
got = main([spec])
finally:
sys.stdin, sys.stdout, sys.stderr = saved
if got != expected:
failures.append(
f"main([{spec!r}]) against {published}: expected exit {expected}, got {got}")

for problem in failures:
print(f"FAIL {problem}", file=sys.stderr)

total = len(ordering) + len(cases)
if failures:
print(f"\n{len(failures)} of {total} self-test case(s) failed.", file=sys.stderr)
return 1
print(f"nuget-version-satisfies: all {total} self-test case(s) pass.")
return 0


# --------------------------------------------------------------------------- #

def main(argv):
if "--self-test" in argv:
return self_test()

if len(argv) != 1:
# Terse, not the whole docstring: this is called in a loop, and dumping
# the module doc per dependency buried the real verdict when it happened.
print("usage: nuget-version-satisfies.py <range> [--self-test]", file=sys.stderr)
return 2

rng = bounds(argv[0])
if rng is None:
print(f"unparseable version range: {argv[0]!r}", file=sys.stderr)
return 2

try:
# utf-8-sig: the flat container is served from blob storage and its
# bodies can carry a BOM (measured 2026-09-04) — same reason as
# verify-package-not-published.sh.
index = json.loads(sys.stdin.buffer.read().decode("utf-8-sig"))
except (UnicodeDecodeError, json.JSONDecodeError) as exc:
print(f"unreadable flat-container index: {exc}", file=sys.stderr)
return 2

published = index.get("versions", [])
if not isinstance(published, list):
print("flat-container index has no version list", file=sys.stderr)
return 2

for text in published:
key = parse(str(text))
if key is not None and satisfies(key, rng):
print(text)
return 0
return 1


if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
Loading
Loading