Repository navigation
fix(common): order a pre-release version when importing a report - #345
Conversation
fromDict gated its escape-version comparisons on v?\d+(\.\d+)*, which no PEP 440 pre-release matches, so a report written by 4.8.0rc1 took the "no valid version information" branch and had every pic_hash and nesting depth recomputed on import. A pre-release now sorts directly below its own release, so a candidate for the release that changed an escaper is still recomputed while every later one is trusted. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
📊 SMDA Performance Evaluation Benchmark ResultsGenerated on: 2026-09-14 12:52:25 Summary
Per-side Timing Context (best of 3/3 runs per file)
Paired per-file timing (positive speedup = PR faster):
Determinism (self-check across repeated runs)
Pairwise run matrix (individual run medians, diagnostic)Diagnostic only: each row compares one raw PR run against one raw base run. The headline verdict above uses paired per-file best-of-runs timings.
|
Found while setting up the first rehearsal of #343's release workflow, which needs a
v4.8.0rc1tag and therefore a pre-release string in__version__.The defect
SmdaFunction.fromDictdecides whether a report's storedpic_hashcan be trusted by comparing its version against the per-architecture escape-version constants. The comparison is gated on a regex:No PEP 440 pre-release matches it:
A non-match falls to the
elsebranch — the one commented "if we don't have valid version information, always recalculate". So a report written by the newest build in existence is handled as one too old to trust.Measured on the bundled
cutwail_xoredreport, importing the same dict twice with onlysmda_versionchanged:smda_versiongetPicHashcalls on import4.8.04.8.0rc1The hashes come out identical, so nothing was ever wrong in the output — this is cost and classification, not corruption. The cost is proportional to function count, which is why it matters where reports are imported in bulk rather than one at a time.
It is not hypothetical now that #343 has landed:
RELEASING.mdprescribes pre-release tags with a matching__version__across the ecosystem, so any rc ever shipped produces reports that every later import re-hashes.The fix
A report version becomes a comparable key of
(release numbers, 1 for a release / 0 for a pre-release), so4.8.0rc1sorts directly below4.8.0rather than nowhere.A pre-release of the version that changed an escaper still recomputes.
4.3.5rc1precedes4.3.5, and a candidate cut before the escaper change merged would otherwise be trusted on stored hashes it did not produce. Recomputing is the safe direction and costs only that one release's candidates.The tuple shape is what keeps every already-ordered string ordering exactly as before, including the truncated form:
4.3against a[4, 3, 5]gate still compares by the list prefix rule and still recomputes. Appending the flag to a flat list would have silently reversed that one.A version this cannot order —
4.4.4-dev,MCRIT4IDA,4..5— is unchanged and still takes the recalculate-everything branch, whichtest_imported_report_with_a_suffixed_version_recalculates_instead_of_raisingalready pins.Tests
Three cases in
tests/testCommonModels.py, beside the existing escape-version ones, each overa1/b2/rc1:pic_hash;4.3.5,v4.3.5,4.3.4,4.3,4.3.6,5— plus the five strings that must stay unorderable.Each verified to fail under a mutation of the line it covers, and only that one:
Verification
python -m pytest tests/→ 2,171 passed, 1 skipped, 2,618 subtestsruff check .andruff format --check .→ cleanty→ 276 diagnostics, which is this tree's own count formasterto the number4.8.0rc1imports with 0 recalculations and4.4.4-devstill with 33, hashes identical in bothNo bundled fixture baseline moves: no report in the tree carries a pre-release version, so the only behaviour that changes is for versions nothing has produced yet.
🤖 Generated with Claude Code