Repository navigation
feat: prove node-semver's version comparison and close stage 11 - #106
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, thenadapter.patchandscripts/check-semver.sh.What is ported
From node-semver 7.8.6 at commit
b37b033b585ad5e575afeccadb426ea41bc6cea4: theSemVerclass'scompareMain,comparePre,compareBuildandcompare, andcompareIdentifiers, which they call. Parsing stays in node-semver.PreId { Numeric(digits), Alpha(text) }and a version is a record. Each comparator states its result through spec functions, above allfirst_difference: the first index where two lists of identifiers differ or one ends.accord check: 47 obligations proved, 6 examples passed.semver-numeric-faultcompares digits as text ("9"after"10"),semver-prefix-faultranks a list that ends first higher,semver-skip-faultstops at a tie on one list's last identifier.The adapter is trusted, not proved
adapter.patchis written by hand. It makes node-semver'sclasses/semver.jscompare 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'smodule.stripTypeScriptTypes, because tap's require hooks compile a.mtsfile 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,rsortand theSemVerclass) 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).cargo fmt --all --checkpassed;cargo clippy --workspace --all-targets --locked -- -D warningspassed;cargo test --workspace --locked: 126 passed, 0 failed, 2 ignored (as on main);score.py --self-testandmaterials.py: passed.full-ci).Not established
check-semver.shneeds git, Node 22.13 or later and network access, so CI doesn't run it.^16at 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