Skip to content

feat: prove node-semver's version comparison and close stage 11 - #106

Merged
Sequela02 merged 2 commits into
mainfrom
feat/stage-11-semver
Nov 28, 2026
Merged

Sequela02 merged 2 commits into
mainfrom
feat/stage-11-semver

Conversation

@Sequela02

Copy link
Copy Markdown
Contributor

Stage 11's target (#83) is node-semver's version comparison, proved in Accord, with node-semver's own tests for it passing against the generated module. This slice (11h) ports it and closes the stage.

Where to start reading: conformance/programs/semver/compare.accord, then adapter.patch and scripts/check-semver.sh.

What is ported

From node-semver 7.8.6 at commit b37b033b585ad5e575afeccadb426ea41bc6cea4: the SemVer class's compareMain, comparePre, compareBuild and compare, and compareIdentifiers, which they call. Parsing stays in node-semver.

  • An identifier is PreId { Numeric(digits), Alpha(text) } and a version is a record. Each comparator states its result through spec functions, above all first_difference: the first index where two lists of identifiers differ or one ends.
  • accord check: 47 obligations proved, 6 examples passed.
  • Three planted faults, each trimmed to the functions it needs, are refuted: semver-numeric-fault compares digits as text ("9" after "10"), semver-prefix-fault ranks a list that ends first higher, semver-skip-fault stops at a tie on one list's last identifier.
  • The port follows SemVer §11 where node-semver doesn't quite: a numeric identifier compares exactly, and a tie goes on to the next. They differ only past 2^53 and on build identifiers with leading zeros, which no node-semver test exercises.

The adapter is trusted, not proved

adapter.patch is written by hand. It makes node-semver's classes/semver.js compare through the generated module, after reading each identifier as numeric or not and stripping a numeric one's leading zeros. The module is loaded as JavaScript, its types stripped by Node's module.stripTypeScriptTypes, because tap's require hooks compile a .mts file as CommonJS.

Verification

  • scripts/check-semver.sh <empty folder>: node-semver's 14 test files of comparison (compare, compare-build, compare-loose, rcompare, cmp, eq, neq, gt, gte, lt, lte, sort, rsort and the SemVer class) pass as released and with the generated module in place: 14 of 14 files, 3,907 assertions. With the port in place the whole node-semver suite also passes, 69 of 69 files (run by hand).
  • On Windows with the pinned solvers: cargo fmt --all --check passed; cargo clippy --workspace --all-targets --locked -- -D warnings passed; cargo test --workspace --locked: 126 passed, 0 failed, 2 ignored (as on main); score.py --self-test and materials.py: passed.
  • Linux and macOS: pending (CI, full-ci).

Not established

  • check-semver.sh needs git, Node 22.13 or later and network access, so CI doesn't run it.
  • For four comparators, whether their contract determines the result is undecided (cvc5 times out). It doesn't block the build; the generated module's header says so.
  • node-semver ships no lockfile, so the script installs the latest tap that matches ^16 at the time of the run.

Risk note

Door: two-way. The change adds a conformance program, its faults, a script and docs; no compiler code changes.
Blast radius: test time. Locally the suite went from about 4.5 to 9.5 minutes (library tests 150 s to 315 s, since the differential test builds the port; conformance 100 s to 228 s). CI's Linux job has a 15-minute limit.
Evidence: the checks above; the CI timings on this PR.

Refs #83

Atrium: 01a1e493-917d-7a14-bbc8-dfcae169a76c

Stage 11's target (#83): node-semver 7.8.6's compareMain, comparePre,
compareBuild, compare and compareIdentifiers, ported to Accord and proved,
each comparator's contract stated through spec functions, first_difference
above all. Three planted faults are refuted: digits compared as text, a
list that ends first ranked higher, and a stop at a tie on one list's last
identifier. compareIdentifiers tests both text orders, without which cvc5
ran out of time proving the third outcome.

adapter.patch makes node-semver's SemVer class compare through the
generated module; scripts/check-semver.sh runs node-semver's 14 test files
of comparison as released and with the port in place: 3,907 assertions
pass in both.

Refs #83
@Sequela02 Sequela02 added the full-ci Run Windows and macOS CI once before merging label Nov 28, 2026
@Sequela02
Sequela02 merged commit ca37223 into main Nov 28, 2026
5 checks passed
@Sequela02
Sequela02 deleted the feat/stage-11-semver branch November 28, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run Windows and macOS CI once before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant