From 11cc0a37c7c72640a1fb5c5bc561a71ef3b4241d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 4 Jul 2026 21:54:07 +0200 Subject: [PATCH] refactor(meter-values): rename Prng.ts to PRNG.ts (issue #1936 c) (#1940) * refactor(meter-values): rename Prng.ts to PRNG.ts (issue #1936 c) PRNG is the canonical uppercase abbreviation (Pseudo-Random Number Generator). Uppercase acronyms in file names align with the codebase's TypeScript PascalCase-for-modules convention (e.g. `OCPPServiceUtils.ts`). `Prng.ts` was the outlier. Rename performed via two-step `git mv` to survive case-insensitive filesystems (macOS APFS default). Updates: - Path imports (4 sites): `CoherentSampleComputer.ts`, `CoherentSession.ts`, `CoherentMeterValues.test.ts`, `PRNG.test.ts`. - JSDoc `{@link}` module references (3 sites): `CoherentSession.ts` (2), `index.ts` (1). - JSDoc backtick module references (2 sites): `CoherentSession.ts` (1), `CoherentMeterValues.test.ts` (1). - Test suite description string: `describe('Prng', ...)` to `describe('PRNG', ...)` in `PRNG.test.ts`. camelCase identifiers containing "Prng" (`voltagePrng`, `profilePickPrng`, `socPrng`, `createStreamPrng`) preserved per TypeScript camelCase-for- variables/functions convention. Cosmetic; zero runtime change. Test invariant `fail: 0, skipped: 6` preserved (2895 pass / 2901 total). Build passes. Closes issue #1936 item (c). * style(meter-values): normalize prose em-dash to ASCII on PR-C-touched lines (issue #1936 c) R1 Lane C flagged em-dash (U+2014) in `+` lines of PR-C delta: - `src/charging-station/meter-values/CoherentSession.ts:71` (JSDoc backtick reference line updated by rename) - `src/charging-station/meter-values/index.ts:23` (JSDoc `{@link}` reference line updated by rename) Both lines were modified by the PR-C rename (`Prng.ts` -> `PRNG.ts` reference updates) and therefore appear in the branch `+` diff. Session ASCII rule permits only the section sign (U+00A7) plus pre-existing physics/math notation in JSDoc as non-ASCII exceptions; em-dash as prose punctuation is not covered. Fix: replace both `--` (U+2014) with ASCII `-`. Semantic content preserved. Em-dashes on lines NOT modified by PR-C (CoherentSession.ts:15, index.ts:14/18/21, PRNG.test.ts x3, CoherentMeterValues.test.ts x1) remain SUB-THRESHOLD per pre-existing outside line-level delta convention. Test invariant `fail: 0, skipped: 6` preserved. Build passes. --- .../meter-values/CoherentSampleComputer.ts | 2 +- src/charging-station/meter-values/CoherentSession.ts | 8 ++++---- src/charging-station/meter-values/{Prng.ts => PRNG.ts} | 0 src/charging-station/meter-values/index.ts | 2 +- .../meter-values/CoherentMeterValues.test.ts | 4 ++-- .../meter-values/{Prng.test.ts => PRNG.test.ts} | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) rename src/charging-station/meter-values/{Prng.ts => PRNG.ts} (100%) rename tests/charging-station/meter-values/{Prng.test.ts => PRNG.test.ts} (97%) diff --git a/src/charging-station/meter-values/CoherentSampleComputer.ts b/src/charging-station/meter-values/CoherentSampleComputer.ts index b1ea65a0..59b6dcd6 100644 --- a/src/charging-station/meter-values/CoherentSampleComputer.ts +++ b/src/charging-station/meter-values/CoherentSampleComputer.ts @@ -41,7 +41,7 @@ import type { CoherentSession, ICoherentContext } from './types.js' import { CurrentType } from '../../types/index.js' import { Constants, roundTo } from '../../utils/index.js' import { interpolateChargingCurve } from './EvProfiles.js' -import { createStreamPrng } from './Prng.js' +import { createStreamPrng } from './PRNG.js' /** * Runtime-only per-session state. Kept in a module-scope WeakMap keyed by diff --git a/src/charging-station/meter-values/CoherentSession.ts b/src/charging-station/meter-values/CoherentSession.ts index 6e88f0f2..1f3be68b 100644 --- a/src/charging-station/meter-values/CoherentSession.ts +++ b/src/charging-station/meter-values/CoherentSession.ts @@ -10,8 +10,8 @@ * (`disposeCoherentSessionRuntime`) live in * {@link ./CoherentSampleComputer}; MeterValue emission lives in * {@link ./CoherentMeterValueBuilder}; PRNG primitives - * ({@link ./Prng.createStreamPrng}, `deriveSeed`, `hashLabel`, - * `mulberry32`) live in {@link ./Prng}. This module owns only + * ({@link ./PRNG.createStreamPrng}, `deriveSeed`, `hashLabel`, + * `mulberry32`) live in {@link ./PRNG}. This module owns only * session identity and the strategy predicate — it has no cross-module * private dependencies. */ @@ -21,7 +21,7 @@ import type { CoherentSession, EvProfile, ICoherentContext } from './types.js' import { CurrentType, Voltage } from '../../types/index.js' import { Constants, logger } from '../../utils/index.js' import { selectEvProfile } from './EvProfiles.js' -import { createStreamPrng, hashLabel } from './Prng.js' +import { createStreamPrng, hashLabel } from './PRNG.js' const moduleName = 'CoherentSession' @@ -68,7 +68,7 @@ export interface CreateSessionOptions { * and per-transaction seed material. Weight-based profile selection uses a * dedicated `'PROFILE_PICK'` stream and initial SoC uses `'INITIAL_SOC'`, * so adding one consumer does not shift any other stream's sequence - * (stream-splitting via FNV-1a label hashing — see `deriveSeed` in `Prng.ts`). + * (stream-splitting via FNV-1a label hashing - see `deriveSeed` in `PRNG.ts`). * * The nominal AC voltage is treated as phase voltage (line-to-neutral) per * {@link ../../utils/ElectricUtils.ACElectricUtils}. If the station is AC diff --git a/src/charging-station/meter-values/Prng.ts b/src/charging-station/meter-values/PRNG.ts similarity index 100% rename from src/charging-station/meter-values/Prng.ts rename to src/charging-station/meter-values/PRNG.ts diff --git a/src/charging-station/meter-values/index.ts b/src/charging-station/meter-values/index.ts index 310889a7..4e8e91d8 100644 --- a/src/charging-station/meter-values/index.ts +++ b/src/charging-station/meter-values/index.ts @@ -20,7 +20,7 @@ * module-scope runtime WeakMap (`disposeCoherentSessionRuntime`). * - {@link ./CoherentMeterValueBuilder} — emit order, phase families, * unit conversion, OCPP MeterValue assembly. - * - {@link ./Prng} — PRNG primitives (`mulberry32`, `hashLabel`, + * - {@link ./PRNG} - PRNG primitives (`mulberry32`, `hashLabel`, * `deriveSeed`, `createStreamPrng`). */ diff --git a/tests/charging-station/meter-values/CoherentMeterValues.test.ts b/tests/charging-station/meter-values/CoherentMeterValues.test.ts index 25cc62e4..0bb99c70 100644 --- a/tests/charging-station/meter-values/CoherentMeterValues.test.ts +++ b/tests/charging-station/meter-values/CoherentMeterValues.test.ts @@ -5,7 +5,7 @@ * and same-seed determinism across AC 1-phase, AC 3-phase, and DC modes. * Cross-module tests spanning `CoherentSampleComputer` (physics), * `CoherentMeterValueBuilder` (emission), `CoherentSession` (lifecycle), - * and `Prng` (stream splitting). + * and `PRNG` (stream splitting). */ import assert from 'node:assert/strict' @@ -33,7 +33,7 @@ import { createCoherentSession, resolveRootSeed, } from '../../../src/charging-station/meter-values/CoherentSession.js' -import { hashLabel } from '../../../src/charging-station/meter-values/Prng.js' +import { hashLabel } from '../../../src/charging-station/meter-values/PRNG.js' import { AvailabilityType, CurrentType, diff --git a/tests/charging-station/meter-values/Prng.test.ts b/tests/charging-station/meter-values/PRNG.test.ts similarity index 97% rename from tests/charging-station/meter-values/Prng.test.ts rename to tests/charging-station/meter-values/PRNG.test.ts index 702d6ad0..218117d5 100644 --- a/tests/charging-station/meter-values/Prng.test.ts +++ b/tests/charging-station/meter-values/PRNG.test.ts @@ -16,10 +16,10 @@ import { deriveSeed, hashLabel, mulberry32, -} from '../../../src/charging-station/meter-values/Prng.js' +} from '../../../src/charging-station/meter-values/PRNG.js' import { standardCleanup } from '../../helpers/TestLifecycleHelpers.js' -await describe('Prng', async () => { +await describe('PRNG', async () => { afterEach(() => { standardCleanup() }) -- 2.53.0