]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(meter-values): rename Prng.ts to PRNG.ts (issue #1936 c) (#1940)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 4 Jul 2026 19:54:07 +0000 (21:54 +0200)
committerGitHub <noreply@github.com>
Sat, 4 Jul 2026 19:54:07 +0000 (21:54 +0200)
* 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.

src/charging-station/meter-values/CoherentSampleComputer.ts
src/charging-station/meter-values/CoherentSession.ts
src/charging-station/meter-values/PRNG.ts [moved from src/charging-station/meter-values/Prng.ts with 100% similarity]
src/charging-station/meter-values/index.ts
tests/charging-station/meter-values/CoherentMeterValues.test.ts
tests/charging-station/meter-values/PRNG.test.ts [moved from tests/charging-station/meter-values/Prng.test.ts with 97% similarity]

index b1ea65a0d3501d25be213fd18304fb0885ab6847..59b6dcd65ba79f014476e4f27d88ea4a920f20a1 100644 (file)
@@ -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
index 6e88f0f20b6047ec6555577c04df306e4357f8a4..1f3be68b60fdc7323f2830daffec419f6a4f3677 100644 (file)
@@ -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
index 310889a7d7a7c451504eadf1a811944ebe9c4c4b..4e8e91d847cd6afff9e91209a4d0902b98c2eeb6 100644 (file)
@@ -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`).
  */
 
index 25cc62e436eeed4084690eadfe8666418fdb3d21..0bb99c708c3cf299d430920cbe2a8c9607681ae2 100644 (file)
@@ -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,
similarity index 97%
rename from tests/charging-station/meter-values/Prng.test.ts
rename to tests/charging-station/meter-values/PRNG.test.ts
index 702d6ad07fd1943f775177c762942ac261a1d8f7..218117d565704d767a9605131f7b98932d2978a2 100644 (file)
@@ -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()
   })