chore: drop the dead compareVersions and unexport nothing-imported symbols

- compareVersions had zero production callers (the gate rides
  meetsBaseline alone) and is not re-exported through the package entry;
  its spec block duplicated what meetsBaseline's cases already pin
  through compareParsed (a major-gap case joins meetsBaseline's block to
  keep every arm covered). isNewerVersion keeps its own numeric-only
  compare: ignoring prereleases there is the upgrade nudge's deliberate
  semantics, and adopting the channel-aware order would change
  user-visible behavior.
- pad2 hand-rolled padStart(2, '0') in a function that already used
  padStart for the year.
- StoredHeaderTool/StoredHeaderRecord and DecodeCounts/DecodeSpans lost
  export keywords nothing inside or outside the repo imported.
This commit is contained in:
bowenliang123 committed 2026-10-08 01:05:01 +08:00
1 parent 6a8f7a2ae1
commit a19c86c593
5 files changed
+7 -42

No files matched your search

+2 -2
View File
@@ -47,7 +47,7 @@ const HEADERS_MAX = 50
* One stored tool: the v1 row shape carried the producer description and the
* raw schema; folds since the #37 slim-down append metadata-only entries.
*/
export interface StoredHeaderTool {
interface StoredHeaderTool {
name: string
tokens: number
description?: string
@@ -56,7 +56,7 @@ export interface StoredHeaderTool {
}
/** One stored epoch: v1 rows carried `system`; folds since carry `systemTokens`. */
export interface StoredHeaderRecord {
interface StoredHeaderRecord {
seq: number
time: number
system?: string
+2 -2
View File
@@ -55,10 +55,10 @@ export function decodeKindOfBlock(blockType: unknown): DecodeKind | undefined {
}
/** Per-kind decode spans (see {@link decodeTallyOfStream}). */
export type DecodeSpans = Record<DecodeKind, number>
type DecodeSpans = Record<DecodeKind, number>
/** Per-kind count of opened decode blocks (see {@link decodeTallyOfStream}). */
export type DecodeCounts = Record<DecodeKind, number>
type DecodeCounts = Record<DecodeKind, number>
/** Both decode tallies of one stream: the spans that price the split and the marker counts that qualify its rows. */
export interface DecodeTally {
+1 -6
View File
@@ -10,11 +10,6 @@
/** The strict key shape (round-trip validated on construction too). */
export const DAY_KEY_RE = /^\d{4}-\d{2}-\d{2}$/
/** Zero-pad to two digits (no Intl allocation on the hot path). */
function pad2(n: number): string {
return n < 10 ? '0' + String(n) : String(n)
}
/**
* The local calendar-day key of an epoch-ms instant, or null when the time
* is not a finite number or falls outside the representable date range —
@@ -25,7 +20,7 @@ export function dayKeyOf(time: number): string | null {
const d = new Date(time)
const y = d.getFullYear()
if (!Number.isFinite(y) || y < 1970 || y > 9999) return null
return `${String(y).padStart(4, '0')}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`
return `${String(y).padStart(4, '0')}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
}
/**
-12
View File
@@ -65,18 +65,6 @@ function compareParsed(a: ParsedVersion, b: ParsedVersion): number {
return a.serial - b.serial
}
/**
* Compare two version strings (negative / zero / positive). An unparseable
* side compares EQUAL — the gate only ever acts on a strict, proven
* below-baseline result.
*/
export function compareVersions(a: string, b: string): number {
const x = parseVersion(a)
const y = parseVersion(b)
if (x === null || y === null) return 0
return compareParsed(x, y)
}
/**
* Whether `version` satisfies the supported baseline. FAIL OPEN by design: a
* version that cannot be parsed (a dev/nightly harness build) must not blank
+2 -20
View File
@@ -4,7 +4,7 @@
import assert from 'node:assert/strict'
import { describe, test } from 'vitest'
import { BASELINE_DSH_VERSION, compareVersions, meetsBaseline, parseVersion } from '../../src/shared/version'
import { BASELINE_DSH_VERSION, meetsBaseline, parseVersion } from '../../src/shared/version'
describe('parseVersion', () => {
test('parses plain releases, channels, serials, v-prefixes and build metadata', () => {
@@ -23,25 +23,6 @@ describe('parseVersion', () => {
})
})
describe('compareVersions', () => {
test('orders numerically, then channel (release > rc > beta > alpha), then serial', () => {
assert.ok(compareVersions('1.0.0', '0.9.9') > 0)
assert.ok(compareVersions('0.2.0', '0.1.9') > 0)
assert.ok(compareVersions('0.1.3', '0.1.2') > 0)
assert.ok(compareVersions('0.1.2', '0.1.2-rc.9') > 0, 'final outranks rc')
assert.ok(compareVersions('0.1.2-rc.1', '0.1.2-beta.9') > 0, 'rc outranks beta')
assert.ok(compareVersions('0.1.2-beta.1', '0.1.2-alpha.9') > 0, 'beta outranks alpha')
assert.ok(compareVersions('0.1.2-rc.2', '0.1.2-rc.1') > 0, 'higher serial wins')
assert.equal(compareVersions('0.1.2-rc.1', '0.1.2-rc.1'), 0)
assert.ok(compareVersions('0.1.3-alpha.1', '0.1.2') > 0, 'a newer X.Y.Z beats any older channel')
})
test('an unparseable side compares equal', () => {
assert.equal(compareVersions('dev-build', '0.1.2'), 0)
assert.equal(compareVersions('0.1.2', 'dev-build'), 0)
})
})
describe('meetsBaseline', () => {
test(`the supported baseline is ${BASELINE_DSH_VERSION}`, () => {
assert.equal(BASELINE_DSH_VERSION, '0.1.7-rc.2')
@@ -53,6 +34,7 @@ describe('meetsBaseline', () => {
assert.equal(meetsBaseline('0.1.7'), true, 'the final release of the baseline line')
assert.equal(meetsBaseline('0.2.0-rc.2'), true, 'the newest supported line')
assert.equal(meetsBaseline('0.2.0-alpha.1'), true, 'a newer X.Y.Z outranks any channel (the 0.2.0 previews pass)')
assert.equal(meetsBaseline('1.0.0-alpha.1'), true, 'a newer major outranks everything below it')
assert.equal(meetsBaseline('0.1.7-rc.1'), false, 'an older rc of the baseline line')
assert.equal(meetsBaseline('0.1.7-alpha.1'), false, 'alpha is below rc at equal X.Y.Z')
assert.equal(meetsBaseline('0.1.6'), false, 'a hypothetical final of the dropped cycle')