Repository navigation
fix(infra): enforce -boon.N correction floors in plugin API compat matcher - #347
Conversation
…matcher `satisfiesPluginApiRange` unconditionally stripped the host's `-boon.N` fork-correction suffix before comparing it to a plugin's declared `compat.pluginApi` floor. Since plain semver ranks a bare release above any prerelease of the same base, a `2026.7.35-boon.2` host normalized to `2026.7.35` and incorrectly satisfied a `>=2026.7.35-boon.3` floor, so a bundled plugin's correction-pinned floor (as `pnpm plugins:sync` writes on every fork version bump) was never actually enforced against an older fork host. Route any correction-pinned comparator target (`-boon.N` or upstream numeric `-N`) through the existing `compareOpenClawReleaseVersions` fork release ordering instead of plain semver, where a correction outranks its bare base. Falls back to the prior suffix-normalizing semver path for non-correction targets. Found during review of #341 (cubic-dev-ai). Closes ENG-23072 Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
APPROVE — code verdict for 3720d217db7ef8051c677f044e2288ccc9e66065 (base 766c304c9a6bfe629be39cdad05d23c4b3cb6170).
No actionable code findings. Correction-pinned plugin API floors now use the existing fork release ordering, while other targets retain the prior suffix-normalizing semver path. The regression coverage exercises older/current/newer and bare hosts, upstream numeric corrections, caret lower bounds, and the caret upper-bound edge case.
Focused exact-head tests:
node scripts/run-vitest.mjs src/infra/clawhub.test.ts— 68 passed, 2 skipped.node scripts/run-vitest.mjs src/plugins/install.test.ts src/plugins/discovery.test.ts src/plugins/update.test.ts src/plugins/manifest-registry.test.ts— 368 passed.node scripts/run-vitest.mjs src/plugins/clawhub.test.ts— 79 passed.
Hosted exact-head check runs: 152 total (success: 118, skipped: 32, neutral: 2; none failed or pending). CI workflow run #46285429946 completed successfully.
Merge gates are separate: the active branch rules require 1 approving review(s) and signed commits; 1 PR commit(s) are GitHub-verified. Classic branch-protection details were not readable by this integration (HTTP 403), so additional required-check contexts and merge readiness remain unverified. No auto-merge request or merge-queue membership was active at review time. This review does not merge the PR.
Closes ENG-23072
What Problem This Solves
Found during review of #341 (cubic-dev-ai,
extensions/tlon/package.json:76), which bumped every bundled plugin'scompat.pluginApifloor from-boon.2to-boon.3. A bundled plugin'scompat.pluginApifloor pinned to a specific-boon.Nfork correction (the shapepnpm plugins:syncwrites on every fork version bump) was not actually enforced against an older fork host. A host running2026.7.35-boon.2would incorrectly satisfy a>=2026.7.35-boon.3floor and load a plugin that declared it needed the newer correction, because the host's-boon.Nsuffix was being stripped before the comparison regardless of what the floor itself required.Why This Change Was Made
satisfiesPluginApiRange→satisfiesComparator→normalizePluginApiVersionForComparator(src/infra/clawhub.ts) callednormalizeOpenClawNumericCorrectionForPluginApiunconditionally on the host's running version, stripping any-boon.Ndown to the bareYYYY.M.PATCHbefore comparing against the floor. Because standard semver ranks a bare release above any prerelease of the same base,2026.7.35 >= 2026.7.35-boon.3evaluatedtrue.The fix adds
comparePluginApiVersionToTarget, which special-cases a correction-pinned comparator target (-boon.Nor upstream numeric-N) to rank both sides with the fork's existingcompareOpenClawReleaseVersionsrelease ordering (src/infra/npm-registry-spec.ts, already used byupdate-check.ts) instead of plain semver — a correction outranks its bare base there. Non-correction targets keep the prior suffix-normalizing semver path unchanged. Both the>=/operator comparator and the caret (^) range's lower bound now go through it; the caret's upper bound (always a bare bumped version, never correction-pinned) deliberately keeps normalizing againstbaseexactly as before, to avoid a stripped-prerelease edge case at the next-major boundary.The fix is symmetric: a bare upstream host (no
-boon.Nat all) now also correctly fails a correction-pinned floor, matching the fork's own release ranking where a correction outranks the bare base.Out of scope (recorded here per review, not fixed in this PR):
satisfiesGatewayMinimum(clawhub.ts) has the same class of defect (parseSemverdrops the prerelease entirely), butminGatewayVersiononly ever arrives from remote ClawHubcompatibilitymetadata and is set in no manifest in this repo, so it cannot carry a fork suffix in practice.src/plugins/install.ts,src/plugins/update.ts) uses rawcompareComparableSemverwith the same bare-above-correction skew, but that's a different decision surface (plugin artifact versions, not host compat).User Impact
A host older than a bundled plugin's declared
-boon.Nfloor now correctly fails to load that plugin instead of silently loading it. In practice, sincescripts/sync-plugin-versions.tswrites>=<root version>into every bundled manifest in the same run that bumps the host version, floor and host version are equal on every release today, so this only changes behavior for hosts that have fallen behind the bundled plugin versions they ship with.Evidence
node scripts/run-vitest.mjs src/infra/clawhub.test.ts— 70/70 passed (8 new correctness assertions for the ticket's test plan, 3 new edge-case regression assertions for the caret-range fix).node scripts/run-vitest.mjs src/plugins/install.test.ts src/plugins/discovery.test.ts src/plugins/update.test.ts src/plugins/manifest-registry.test.ts— 368/368 passed (all consumer call sites ofsatisfiesPluginApiRange).node scripts/run-vitest.mjs src/plugins/clawhub.test.ts— 79/79 passed.oxfmt --checkandnode scripts/run-oxlint.mjsclean on both touched files./code-review(medium): first round caught a real edge-case regression in my own initial fix (the caret upper bound's normalization basis), which was corrected and locked in with a regression test; second round came back clean except one accepted efficiency nit (a cheap duplicate regex normalization call, not worth the added complexity to dedupe).blacksmithCLI missing, confirmed viacrabbox doctor); tests were run via the narrow local fallback (node scripts/run-vitest.mjs) per policy after a one-timepnpm install.🤖 Generated with Claude Code
Summary by cubic
Fixes the plugin API compatibility matcher so a host running an older
-boon.Nfork correction no longer satisfies a plugin floor that requires a newer correction. Previously the matcher stripped the host's correction suffix before comparing, so a2026.7.35-boon.2host could pass>=2026.7.35-boon.3because plain semver ranks the bare release above any prerelease of the same base.Correction-pinned floors now compare with the fork's release ordering, where a correction outranks its bare base, and a bare host without any correction now also correctly fails a correction-pinned floor. Non-correction floors and the caret upper bound keep the previous suffix-normalizing semver path unchanged.
Closes ENG-23072.
Written for commit 3720d21. Summary will update on new commits.