From a19c86c59320ed29bfb528b230ff8afb1b25a80d Mon Sep 17 00:00:00 2001 From: bowenliang123 Date: Thu, 8 Oct 2026 01:05:01 +0800 Subject: [PATCH] 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. --- src/host/headers.ts | 4 ++-- src/host/logShapes.ts | 4 ++-- src/shared/days.ts | 7 +------ src/shared/version.ts | 12 ------------ tests/shared/version.spec.ts | 22 ++-------------------- 5 files changed, 7 insertions(+), 42 deletions(-) diff --git a/src/host/headers.ts b/src/host/headers.ts index 4b7d5af..d8f363c 100644 --- a/src/host/headers.ts +++ b/src/host/headers.ts @@ -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 diff --git a/src/host/logShapes.ts b/src/host/logShapes.ts index 6969ce8..e3e9e46 100644 --- a/src/host/logShapes.ts +++ b/src/host/logShapes.ts @@ -55,10 +55,10 @@ export function decodeKindOfBlock(blockType: unknown): DecodeKind | undefined { } /** Per-kind decode spans (see {@link decodeTallyOfStream}). */ -export type DecodeSpans = Record +type DecodeSpans = Record /** Per-kind count of opened decode blocks (see {@link decodeTallyOfStream}). */ -export type DecodeCounts = Record +type DecodeCounts = Record /** Both decode tallies of one stream: the spans that price the split and the marker counts that qualify its rows. */ export interface DecodeTally { diff --git a/src/shared/days.ts b/src/shared/days.ts index a2cd4b3..99869fa 100644 --- a/src/shared/days.ts +++ b/src/shared/days.ts @@ -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')}` } /** diff --git a/src/shared/version.ts b/src/shared/version.ts index 55d2644..c3d130c 100644 --- a/src/shared/version.ts +++ b/src/shared/version.ts @@ -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 diff --git a/tests/shared/version.spec.ts b/tests/shared/version.spec.ts index 5e9faa5..22618f0 100644 --- a/tests/shared/version.spec.ts +++ b/tests/shared/version.spec.ts @@ -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')