Commit Graph
2 Commits
Author SHA1 Message Date
Terry Howe 3d992713e5 feat(api): expire api-compat waivers written against an older baseline (#1374)
* feat(api): expire api-compat waivers written against an older baseline

A waiver that matches nothing failed the gate outright, so once a tag carrying the accepted break was published, every branch that rebased past it failed on an entry that was spent rather than wrong.

Waivers may now record the baseline they were written against (the failure stub fills it in). An unmatched waiver naming a different baseline than the current one is reported as expired and does not fail. A waiver with no baseline, or one that matches nothing against the baseline it names, still fails.

Signed-off-by: Terry Howe <thowe@nvidia.com>

* fix(api): expire a waiver only when the baseline is a later release

Inequality alone also covered checking against an older release, which is a
supported mode (--baseline, API_COMPAT_BASELINE), and covered naming today's
release some other way -- a SHA, refs/tags/..., a branch. Either would have
expired the waivers written for the current tag, stopping the matches-nothing
rule from applying in the run a reviewer reaches for.

Order the two as release tags instead, and treat a pair that cannot be ordered
as no supersession at all, so the waiver stays Unused and still fails.

Signed-off-by: Terry Howe <thowe@nvidia.com>

* fix(api): select only stable release tags as the compat baseline

git matches the tag glob with fnmatch, so controller/api/v0.0.29-rc1 matched
and --sort=-version:refname ranked it above the release it precedes. A
prerelease baseline cannot be ordered by supersedes, so a waiver written
against an earlier release stayed Unused and failed instead of expiring.
Pick the highest baseline through releaseVersion instead, the same function
supersedes uses, and qualify the README on which baselines expire a waiver.

Signed-off-by: Terry Howe <thowe@nvidia.com>

---------

Signed-off-by: Terry Howe <thowe@nvidia.com>
2026-10-09 09:47:10 -06:00
Terry Howe c3984a2e4e feat(api): gate openapi.yaml on backward compatibility (#1249)
* feat(api): gate openapi.yaml on backward compatibility

`generate-check` proves the committed *.gen.go match api/openapi.yaml. It says
nothing about whether the specification change itself is safe. A removed field,
a narrowed type or a newly required property regenerates perfectly -- the
generated code matches the new spec exactly -- and breaks every client already
built against the old one. Regeneration correctness and compatibility are
different questions, and only the first was being asked.

Adds `make -C controller api-compat-check`, a member of the merge gate. It
compares the working-tree specification against the newest published
controller/api version tag and fails on any breaking change that is not waived.

The baseline is the tag, not the merge base. controller-api-tag.yml publishes
controller/api/vX.Y.Z on every main commit that touches the directory, and that
tag is what a consumer pins. It is also only ever a patch bump, so no tag has
ever signalled a break -- which is why the gate has to hold the contract that
the version number does not.

Breaking changes are waived one at a time in
controller/api/openapi-compat-waivers.yaml, each with a reason, a named person
and a review date, and a waiver that matches nothing fails the gate. That is the
rule GOVULNCHECK_WAIVED is already held to: an entry cannot outlive its reason.
Waivers match on change kind, JSONPath and property rather than on the engine's
changeHash, which covers the shape of a change and not its location -- in one
sample diff 89 of 91 breaking changes shared five hashes.

It fails closed throughout. A missing baseline (a shallow checkout has no tags),
an unparsable specification, an empty or unrecognized engine report, and a
missing waiver file are all errors. A gate that could not run has not found the
change compatible, and the workflow checks out with fetch-depth: 0 so the usual
cause cannot arise silently.

The change engine is pb33f/openapi-changes, pinned as OPENAPI_CHANGES_VERSION
and run with `go run` so nothing is installed. It is from the same author as
vacuum, over the same libopenapi parser already lints this specification, so the
gate and the linter agree on what the document says. Its breaking/additive
classification is used as-is; what this repository owns is what happens next.

Documents the versioning and deprecation behaviour in controller/api/README.md:
there is one unversioned /api surface, the Go module tag is the pinnable
artifact, and deprecation is additive while removal is the breaking step that
needs a waiver. Also separates the authored files in that directory from the
generated ones.

Signed-off-by: Terry Howe <thowe@nvidia.com>

* feat(api): let a sunset deprecation discharge a removal

The gate landed with one route past it: every breaking change is waived,
including a removal. That makes the patient route -- announce it, wait,
then remove -- cost a reviewer exactly what the abrupt one costs, which
is the wrong incentive for the one operation a compatibility gate exists
to encourage.

So removal gets a second route. An operation marked `deprecated: true`,
carrying an `x-sunset` date, whose date has passed, may now be removed
with no waiver at all: the promise was made, kept and discharged, and
there is nothing left for anyone to sign. Removing it early, or without
having deprecated it, is unchanged -- still breaking, still waivable.

The price of offering that route is that the deprecation has to be real,
which is what the new rules enforce. `deprecated: true` with no
`x-sunset`, an `x-sunset` that is not a YYYY-MM-DD date, a date less
than 180 days out, and an `x-sunset` on an operation that is not marked
deprecated all fail. Each is a deprecation that announces nothing a
consumer can act on.

Every rule is scoped to what changed, never to the state of the
document. An operation whose deprecation fields are identical on both
sides is not examined at all, however they are set. A state rule would
fail a pull request that never touched the specification the moment some
older deprecation drifted out of compliance, and a gate that fails
unrelated work is a gate someone turns off.

The findings are plain `change` values, so everything already built for
the engine's findings works on them: the waiver file matches them the
same way, the failure message prints the same pasteable stub, and a
waiver for one goes stale the same way. They are deliberately not
emitted for removals, which the engine already reports -- two findings
for one edit would mean two waivers for one decision.

Discharge covers operations only. The engine reports a removed operation
as a single change naming it, which is what makes "this exact removal
was announced" decidable; a removed property or parameter is reported in
a shape where it is not. The two removal shapes were confirmed against
the engine rather than assumed.

--report now resolves both specifications too. It replaces the engine,
not the documents, and a mode that skipped them would be a mode in which
a removal looked sanctioned because nothing had checked.

Signed-off-by: Terry Howe <thowe@nvidia.com>

---------

Signed-off-by: Terry Howe <thowe@nvidia.com>
2026-10-08 07:33:09 -06:00