Repository navigation
Add UI HTTP server - #6
Merged
Merged
Conversation
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
jerome-benoit
force-pushed
the
ui-rest-server
branch
from
May 19, 2022 14:21
45e067e to
026afd4
Compare
…mulator into ui-rest-server
…tations-simulator into ui-rest-server
jerome-benoit
force-pushed
the
ui-rest-server
branch
from
June 1, 2022 16:35
790b490 to
e799331
Compare
1 task done
jerome-benoit
marked this pull request as draft
June 10, 2022 22:14
…mulator into ui-rest-server Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
1 task done
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
|
SonarCloud Quality Gate failed. |
jerome-benoit
marked this pull request as ready for review
August 26, 2022 21:53
jerome-benoit
added a commit
that referenced
this pull request
Feb 28, 2026
…actices - Add Testing Philosophy section with core principles - Add Async Testing Patterns section (async/await, Promise rejection, timeout) - Add Error & Exception Testing section with examples - Soften AAA comments rule (required for complex, optional for simple tests) - Add anti-pattern #6: Non-strict assertions guidance - Align with Node.js test runner best practices 2024-2025
jerome-benoit
added a commit
that referenced
this pull request
Jul 6, 2026
…t validation Round-3 review (subagents #1 + #2 + harmonization #6) found three issues with the extracted predicate: 1. Naming inversion — neighbors follow subject-first (isValidDate, isNotEmptyString, isNotEmptyArray) but isRandomIntBoundsValid put the operation before the subject. Rename to isValidRandomIntBounds. 2. Under-validation — the predicate only checked min <= max, so it returned true for NaN/Infinity/non-integers/negatives even though node:crypto.randomInt throws RangeError on all of them (safe integer 0 <= min < 2^48 <= max required). NaN was accidentally rejected because 'NaN <= NaN' is false. Strengthen to reject explicitly: Number.isSafeInteger(minValue) && Number.isSafeInteger(maxValue) && minValue >= 0 && minValue <= maxValue. 3. JSDoc leaked ATG-specific '+1' convention into a general utility contract. Trim @PARAM maxValue to just 'Upper bound (inclusive).' The +1 semantics belong in the description (kept there) and at the call site. Log messages in ATG updated to match: - randomInt(min, max) -> randomInt(min, max + 1) to reflect the actual call - Semicolon comma joining consequence clauses replaced with em-dash for readability Gates pass (format / typecheck / lint).
jerome-benoit
added a commit
that referenced
this pull request
Jul 7, 2026
…bustness, comment sweep (#1962) * docs: fill JSDoc gaps on public/protected abstract methods Nine public/protected abstract methods across five base classes lacked JSDoc, forcing new implementers to read existing subclasses to reconstruct the contract. Add minimal-accurate JSDoc (one-line description, @param, @returns) matching the style used by neighboring already-documented methods in the same files. Covered: - Storage.close / open / storePerformanceStatistics (contract for MongoDB / MariaDB / MySQL / SQLite / JSON storage backends) - OCPPIncomingRequestService.stop - OCPPIncomingRequestService.isIncomingRequestCommandSupported - OCPPRequestService.requestHandler (contract for OCPP 1.6 / 2.0 request services) - OCPPResponseService.isRequestCommandSupported - AbstractUIServer.sendRequest / sendResponse (contract for HTTP / WebSocket / stdio UI transports) No behavior change. Gates pass (format / typecheck / lint). * fix(physics): warn on voltageOut=400 V likely intended as line-to-line voltageOut is line-to-neutral (V_LN) throughout the simulator. V_LL is derived as sqrt(3) * V_LN in a balanced 3-phase Y system (see OCPPServiceUtils.buildVoltageMeasurandValue and CoherentMeterValueBuilder). The Voltage enum offers four closed values: 110, 230, 400, 800. Users familiar with EU 3-phase infrastructure often configure voltageOut=400 V thinking of the standard 400 V line-to-line nominal, unaware that the simulator interprets it as line-to-neutral. Downstream this yields an unrealistic simulated L-L ~= 693 V that only surfaces when a meter value is inspected. Emit a targeted logger.warn once per station init when (currentOutType === AC && numberOfPhases === 3 && voltageOut === 400) so the ambiguity surfaces at station start and the message tells the user how to reach 400 V L-L (set voltageOut=230, the closest enum L-N value). No behavior change beyond the log line. Voltage.VOLTAGE_400 remains a valid L-N configuration for the fraction of deployments that truly want a 400 V L-N (rare but not unphysical), so the warning is not an error. Gates pass (format / typecheck / lint). * fix(atg): make in-flight transaction wait AbortSignal-aware The AutomaticTransactionGenerator run loop at internalStartConnector uses two long sleeps drawn from randomInt-clamped uniform distributions: - Line 319: await sleep(wait), up to maxDelayBetweenTwoTransactions - Line 345: await sleep(waitTrxEnd), up to maxDuration (potentially hours for a realistic charging session) Neither observed the connectorsStatus.get(connectorId)?.start flag while sleeping. stopConnector() flipped start=false immediately, but the run loop only saw it AFTER the current sleep expired — so a maxDuration=3600 config could keep the loop alive for an entire hour after a stop request. Introduce a small module-scope interruptibleSleep(ms, signal) primitive that races setTimeout against an AbortSignal, cleaning up whichever listener does not win. Add a per-connector AbortController map on the class, wire stopConnector() to abort the current controller, and thread the signal through both long sleeps in internalStartConnector. The controller is recreated per invocation of internalStartConnector so a stale abort from a previous run cannot short-circuit a fresh loop. The polling helpers (waitChargingStationAvailable / waitConnectorAvailable / waitRunningTransactionStopped) keep their DEFAULT_ATG_WAIT_TIME_MS sleeps — they iterate on much shorter timescales and are not the audit target. Gates pass (format / typecheck / lint). * fix(atg): validate min/max delay and duration bounds before starting the run loop The AutomaticTransactionGenerator run loop draws its between-transaction wait and in-transaction duration from randomInt(min, max + 1) of node:crypto. That primitive throws RangeError when min >= max, so a mis-configured template with minDelay > maxDelay or minDuration > maxDuration kills the async loop at the first iteration with an unhandled rejection that surfaces only as a generic 'Error while starting connector' log line — the actual mis-config value is lost. Add a private validateConfiguration() that checks both min/max invariants up front and, on violation, logs a targeted error naming the offending pair and refuses to schedule internalStartConnector. Called from startConnector() before the internalStartConnector spawn so external callers of startConnector() also benefit; start() reaches startConnectors() → startConnector() and inherits the guard. Config absence is not a violation (returns true); the run loop already defaults to 0 for missing min/max fields and no randomInt call fires. No behavior change for a valid configuration. Gates pass (format / typecheck / lint). * refactor(charging-station): remove 24 redundant restatement comments The audit's M4-M6 finding covered ~63 imperative/redundant/narrative comments across the codebase, roughly a quarter of which sat in ChargingStation.ts as one-line WHAT-restatements directly above a self-documenting method call: // Start heartbeat this.startHeartbeat() or above a specifically-named event handler: // Handle WebSocket close this.wsConnection.on('close', this.onClose.bind(this)) Delete such restatements when the next line already conveys the same information via method / event / status name. Comments that carry a non-obvious WHY, a spec reference, a race condition note, or a subtle behavioural invariant are preserved unchanged (e.g. the response- handling deferred-promise reject-is-no-op explanation at line 2472). 24 comment lines removed; no code change beyond comment deletion. Gates pass (format / typecheck / lint). * refactor(ocpp): remove 10 redundant restatement comments in request/incoming request services Continue the M4-M6 comment sweep in the OCPP request/incoming-request dispatch layer: OCPPRequestService.ts (8 deletions) - // Send error message (above sendError → internalSendMessage) - // Send response message (above sendResponse → internalSendMessage) - // Build request (above JSON.stringify of OutgoingRequest) - // Build response (above JSON.stringify of Response) - // Send a message through wsConnection (above the WebSocket Promise) - // Handle the request's response (above responseHandler call) - // Remove request from the cache (above requests.delete) - // Check if wsConnection opened (above isWebSocketConnectionOpened()) OCPPIncomingRequestService.ts (2 deletions) - // Log (above logger.error) - // Send the built response (above sendResponse call) The '// Build Error Message per OCPP-J §4.2.3: [4, messageId, errorCode, errorDescription, errorDetails]' comment carries a spec reference and the tuple shape, and stays. The '// Emit command name event to allow delayed handling only if there are listeners' comment carries the listener-count WHY and stays. No code change. Gates pass (format / typecheck / lint). * refactor(auth): remove 14 redundant restatement comments in OCPPAuthServiceImpl Continue the M4-M6 comment sweep in the auth service. Delete pure WHAT-restatement comments that immediately precede a self-descriptive line (method call, property assignment, or self-explaining condition): - // Initialize metrics tracking / Initialize default configuration (above obvious property assignments in the constructor) - // Update request metrics / Update failure metrics (above metrics counter increments) - // Update metrics based on result (above updateMetricsForResult call) - // Create a minimal request to check applicability (above testRequest object literal) - // Check if adapter reports remote availability (above adapter.isRemoteAvailable() call) - // Merge new config with existing / Validate merged configuration / Apply validated configuration (updateConfiguration WHAT-narration) - // Check for specific error patterns that indicate critical issues (above criticalPatterns array literal) - // Track successful vs failed authentication / Track strategy usage / Track cache hits/misses based on method (updateMetricsForResult WHAT-narration) Preserved for their WHY / non-obvious context: - // Note: Adapter and strategies will be initialized async via initialize() (async lifecycle note) - // Try each strategy in priority order (section marker in a 100+ line method) - // Continue to next strategy unless it's a critical error (has WHY) - // Get rate limiting stats from cache via remote strategy (describes routing indirection) - // Try local strategy first for quick cache/list lookup (fast-path rationale) - // Create a type guard to check if strategy has configure method / Use type guard instead of any cast (non-obvious TS pattern) No code change. Gates pass (format / typecheck / lint). * refactor(charging-station): remove 6 residual restatement comments in ATG and HelpersChargingProfile Final M4-M6 comment sweep pass on the two remaining files with clear pure-restatement comments: AutomaticTransactionGenerator.ts (2 deletions) - // Start transaction (above await this.startTransaction(connectorId)) - // Wait until end of transaction (above const waitTrxEnd = secondsToMilliseconds(randomInt(minDur, maxDur+1)) — the waitTrxEnd variable name is the comment) HelpersChargingProfile.ts (4 deletions) - // Check if the charging profile is active (above isWithinInterval(currentDate, {...}) condition) - // Check if the first schedule period startPeriod property is equal to 0 (above the equality check on chargingSchedulePeriod[0].startPeriod) - // Handle only one schedule period (above chargingSchedule.chargingSchedulePeriod.length === 1 branch) - // Handle the last schedule period within the charging profile duration (above the composite last-period + duration-overflow condition) Preserved WHY-comments in these two files: the § references, physics / priority-order rationale, race-condition notes, and the ATG interruptibleSleep + AbortController design comments introduced by fa2bea32 / 5a066a51. No code change. Gates pass (format / typecheck / lint). * docs(atg): document onAbort cleanup semantics in interruptibleSleep The empty JSDoc bloc above the onAbort function inside interruptibleSleep was an auto-generated placeholder from the jsdoc/require-jsdoc lint rule firing on function declarations. It read like a TODO left in place. Replace with a targeted comment covering the two non-obvious invariants this cleanup function relies on: - clearTimeout(timeout) prevents the setTimeout callback from firing after the promise has already resolved on the abort path - addEventListener({ once: true }) auto-removes the abort listener so no explicit removeEventListener is needed on the abort path No behavior change. Gates pass (format / typecheck / lint). * fix(physics): broaden voltageOut warning to Voltage.VOLTAGE_800 and harmonize with CoherentSession Round-1 review of this PR surfaced a harmonization violation: my M13 warning at ChargingStation.getStationInfoFromTemplate covered only Voltage.VOLTAGE_400 and gated on numberOfPhases===3, while the pre-existing per-session warning at CoherentSession.createCoherentSession covered Voltage.VOLTAGE_400 or Voltage.VOLTAGE_800 in AC without a phase gate. Broaden the station-init warning: - Add Voltage.VOLTAGE_800 (common L-L nominal in DC HPC / industrial systems; users configuring it as L-N in AC produce sqrt(3) * 800 ~= 1386 V simulated L-L). - Drop the numberOfPhases === 3 gate so single-phase AC configurations with 400 V / 800 V voltageOut also surface at station init (matches CoherentSession coverage). - Message shows the actual derived L-L (sqrt(3) * voltageOut) so users see the physical implausibility of both enum values. - Suggestion 'set voltageOut=230' is emitted only for the 400 case; the 800 case has no clean L-N enum alternative (462 V is not in the Voltage enum), so the message stops at the diagnostic. The two warning sites remain complementary: - ChargingStation station-init: fires once per station lifetime, regardless of coherentMeterValues flag. - CoherentSession per-session: fires per transaction, only when coherentMeterValues=true. Users with coherentMeterValues=false now get consistent enum coverage without depending on the session-level flag. Gates pass (format / typecheck / lint). * refactor(atg): memoize validateConfiguration result to dedupe per-connector log noise Round-1 review noted that validateConfiguration() fires N times for a station with N connectors (once per startConnector call inside the startConnectors loop), so an invalid ATG configuration produces N identical error log lines instead of one. Add a private configurationValidationResult field cached on first invocation and reset in stop() so a station with N connectors emits the diagnostic log line at most once per session, while still allowing a subsequent start() with a mutated configuration to re-validate from scratch. Cache lifecycle: - Initialized to undefined in the constructor. - Set to true or false on the first validateConfiguration() call after a start() (or after a fresh instance). - Cleared back to undefined at the end of stop() so the next start() observes any config changes and re-emits the log line if invalid. No behavior change for the valid-configuration path. For the invalid path, log-line count drops from N (per-connector) to 1 (per-session). Gates pass (format / typecheck / lint). * refactor(utils): extract isRandomIntBoundsValid predicate and apply in ATG Round-1 review noted that the min > max guard in AutomaticTransactionGenerator.validateConfiguration is a specific instance of a general concern: any caller of randomInt(min, max + 1) from node:crypto risks a RangeError when configuration-driven min/max values are mis-ordered. Extract a pure predicate isRandomIntBoundsValid(min, max) into src/utils/Utils.ts (co-located with other random primitives: secureRandom, getRandomFloat, getRandomFloatFluctuatedRounded, getRandomFloatRounded). The predicate carries the +1 semantics contract in its JSDoc so consumers cannot misuse it. Zero logger dependency, zero side effects, testable in isolation. Apply in ATG's validateConfiguration where the same check now goes through the named predicate for readability and reuse. The two log lines remain in ATG with their full field-name context (which the predicate intentionally does not embed to stay pure). Other randomInt(min, max + 1) sites in the codebase remain unchanged, each documented as low-risk: - OCPP16IncomingRequestService.updateFirmwareSimulation lines 1860, 1871, 1908, 1925, 1936, 1947: min/max are function-parameter defaults (maxDelay=30, minDelay=15, hardcoded and safe by construction); the internal callers respect the default ordering. - OCPPServiceUtils.buildSocMeasurandValue line 270: socMaximumValue is the Constants.SOC_MAXIMUM_PERCENT (100), socMinimumValue is the Zod- schema-validated template field (bounded by the schema). The Zod schema guarantees the invariant at load time. These sites can adopt the predicate in a follow-up config-validation sweep PR if the constraints ever loosen. No behavior change in this commit. Gates pass (format / typecheck / lint). * fix(atg): guarantee AbortController cleanup and prevent per-connector race Round-3 review (subagents #1 design/impl + #2 algo) surfaced two concurrency bugs in internalStartConnector's per-connector controller lifecycle: 1. Leak on abort/exception path: the delete at line 412 was only reached when the while-loop exited normally. Any await inside the loop that rejected (waitChargingStationAvailable, startTransaction, stopTransaction, etc.) propagated through the caller's .catch handler in startConnector — bypassing the delete and leaving the controller in connectorAbortControllers indefinitely. 2. Race in stopConnector→startConnector→cleanup ordering: if the old loop was still draining (e.g. resolving an aborted interruptibleSleep) when a new startConnector fired, the new run set(controller_new) at line 349, and shortly after the old loop reached the unconditional delete(connectorId), wiping the successor controller. A subsequent stopConnector could then not abort the new loop. Fix both with a single try/finally + conditional delete pattern: - try { while-loop } finally { conditional delete } guarantees cleanup on every exit path (normal, break, throw) without leaking. - Delete only when this.connectorAbortControllers.get(connectorId) === abortController (identity check on the run-local reference) so a successor controller cannot be wiped by a predecessor's finally. No behavior change on the happy path. Gates pass (format / typecheck / lint). * fix(atg): unconditionally reset validation cache in stop() to enable recovery Round-3 review (subagents #1 + #2) found a stuck-state bug: The cache reset was at the END of stop(), inside the branch guarded by 'if (!this.started) { return }'. So if a caller invoked startConnector() directly (without going through start()), this.started never became true, and any subsequent stop() early-returned without resetting the cache — the user was stuck with a cached-false configurationValidationResult and no path to recover. Move the reset to the TOP of stop(), before the started/stopping guards. The reset is idempotent (undefined -> undefined is a no-op), so unconditional execution has no side effect on the already-stopped path. This lets external startConnector() callers recover by calling stop() to clear the cache. Gates pass (format / typecheck / lint). * refactor(utils): rename to isValidRandomIntBounds and strengthen input validation Round-3 review (subagents #1 + #2 + harmonization #6) found three issues with the extracted predicate: 1. Naming inversion — neighbors follow subject-first (isValidDate, isNotEmptyString, isNotEmptyArray) but isRandomIntBoundsValid put the operation before the subject. Rename to isValidRandomIntBounds. 2. Under-validation — the predicate only checked min <= max, so it returned true for NaN/Infinity/non-integers/negatives even though node:crypto.randomInt throws RangeError on all of them (safe integer 0 <= min < 2^48 <= max required). NaN was accidentally rejected because 'NaN <= NaN' is false. Strengthen to reject explicitly: Number.isSafeInteger(minValue) && Number.isSafeInteger(maxValue) && minValue >= 0 && minValue <= maxValue. 3. JSDoc leaked ATG-specific '+1' convention into a general utility contract. Trim @param maxValue to just 'Upper bound (inclusive).' The +1 semantics belong in the description (kept there) and at the call site. Log messages in ATG updated to match: - randomInt(min, max) -> randomInt(min, max + 1) to reflect the actual call - Semicolon comma joining consequence clauses replaced with em-dash for readability Gates pass (format / typecheck / lint). * refactor(utils): export interruptibleSleep and apply to ATG polling helpers Round-3 review (subagent #4 harmonization) found interruptibleSleep was private to ATG and could not be reused, plus the three ATG polling helpers (waitChargingStationAvailable / waitConnectorAvailable / waitRunningTransactionStopped) called plain sleep() and were blind to the abort signal. Changes: 1. Move interruptibleSleep from AutomaticTransactionGenerator.ts to src/utils/Utils.ts next to sleep(). Export from utils/index.ts. 2. Reorder to declare 'timeout' before the 'onAbort' arrow function so there is no forward reference (subagent #1 finding). 3. Expand JSDoc: describe both cleanup paths symmetrically (timer-path explicit removeEventListener, abort-path clearTimeout + { once: true } auto-removal). Also document that the promise resolves (does not reject) on abort so callers can drop try/catch noise. 4. Add signal: AbortSignal parameter to the three ATG wait helpers. 5. Replace sleep(DEFAULT_ATG_WAIT_TIME_MS) with interruptibleSleep(DEFAULT_ATG_WAIT_TIME_MS, signal) in each helper. 6. Include !signal.aborted in each while-loop condition so the poll exits immediately when the connector is stopped mid-wait. 7. Thread abortController.signal from internalStartConnector into all three helper calls. 8. Add 'interruptible' to cspell.config.yaml. Impact: a stopConnector() call during an availability-wait now unblocks the poll immediately rather than after DEFAULT_ATG_WAIT_TIME_MS. Gates pass (format / typecheck / lint). * fix(physics): scope L-L derivation to 3-phase and harmonize voltageOut warning Round-3 review (subagents #1 impl elegance + #2 physics + #4 harmonization + #5 content) found the M13 warning had three related issues: 1. Message inaccuracy for single-phase AC: the phrase '3-phase Y-derived line-to-line = X V' fired for single-phase AC stations too (F1 had intentionally dropped the numberOfPhases===3 gate for enum coverage symmetry with CoherentSession). But sqrt(3) only applies to balanced 3-phase Y — for single-phase there is no L-L, so the number cited was physically meaningless. 2. Missing VOLTAGE_800 suggestion: only the VOLTAGE_400 case emitted a remediation hint. VOLTAGE_800 warned but did not tell the operator what to do next; 800 V L-L has no clean L-N enum equivalent, so the suggestion should say so. 3. Terminology drift vs CoherentSession: this site said 'line-to-neutral' while CoherentSession said 'line-to-neutral (phase voltage)'; missing space before V in CoherentSession's log message. Fix: - Gate the 3-phase-Y clause behind getNumberOfPhases===3 (conditional string, still fires for all AC phase counts on enum match). For 1-phase and DC, the derived-L-L clause is elided. - Emit a VOLTAGE_800 remediation: 'no standard L-N enum value exists; verify template voltageOut intent (~462 V L-N)'. - Adopt 'line-to-neutral (phase voltage)' terminology matching CoherentSession. Add space before V in CoherentSession log message. - Trim the 10-line explanatory comment block to 6 lines: keep the invariant (voltageOut is L-N; VOLTAGE_400/800 commonly mis-configured); drop the cross-site harmonization prose (belongs in commit history). Gates pass (format / typecheck / lint). * docs(charging-profile): restore structural 'last period' navigation comment Round-3 review (subagent #1 design/impl) found the M4-M6 comment sweep had over-deleted one non-restatement comment at HelpersChargingProfile line ~404: '// Handle the last schedule period within the charging profile duration'. The composite condition below (last-in-array OR next-period-would-exceed-duration) is not self-evident from the boolean expression alone; the comment aids navigation through this OCPP-specific boundary case. Restore with a tighter version: 'Last period: last in array OR next period would exceed the charging profile duration.' No code change. Gates pass (format / typecheck / lint). * docs(ocpp): use backtick-quoted `true` in @returns for consistency Round-3 review (subagent #5 content finding 3) found @returns lines in the M11 JSDocs used capitalized 'True when' while neighboring JSDocs used backtick-quoted `true`. Normalize both: - OCPPIncomingRequestService.isIncomingRequestCommandSupported - OCPPResponseService.isRequestCommandSupported No behavior change. Gates pass (format / typecheck / lint). * docs: remove/trim redundant comments per DRY (AGENTS.md no-duplication rule) User feedback: comments that repeat info already conveyed by log messages, method names, or field names violate concision + AGENTS.md 'No duplication: maintain single authoritative documentation source; reference other sources rather than copying'. Changes: 1. ChargingStation.ts:1676-1681 - DELETE the 6-line voltage warning block comment. Every fact it stated (voltageOut is L-N, 400/800 are L-L nominals) is already in the log message immediately below ('matches a line-to-line nominal value', 'treats voltageOut as line-to-neutral (phase voltage)'). The 'harmonized with CoherentSession' cross-reference is trivially discoverable via 'rg Voltage.VOLTAGE_400'. 2. AutomaticTransactionGenerator.ts stop() - trim 4-line 'Reset unconditionally' comment to 3 lines. Drop the redundant 'configurationValidationResult' field name (visible on next line) and 'this.started never transitioned to true' (obvious from the guard structure). 3. AutomaticTransactionGenerator.ts stopConnector() - trim 5-line 'Wake' comment to 3 lines. Drop the redundant second sentence about controller lifecycle (visible from the field name 'connectorAbortControllers' and its usage in internalStartConnector). 4. AutomaticTransactionGenerator.ts internalStartConnector() - trim 4-line 'Fresh AbortController' comment to 3 lines. The 'new AbortController()' on the next line already conveys freshness; only the abort-before-replace ordering (unblock lingering sleep) needs documenting. 5. AutomaticTransactionGenerator.ts try/finally - trim 5-line 'Only clear' comment to 2 lines. The try/finally structure self-documents the 'guarantees cleanup on all paths' claim; only the identity check for concurrent stopConnector→startConnector needs explanation. No behavior change. Gates pass (format / typecheck / lint). * fix(atg): close two ATG concurrency correctness gaps Round-4 review (subagents #1 design/impl HIGH, #2 algo HIGH): 1. **Concurrent-loop race on back-to-back stopConnector→startConnector** (subagent #2 finding 3): after stopConnector aborts the controller, the old internalStartConnector loop resumes from its interruptible sleep. When startConnector fires immediately after and resets connectorStatus.start=true, the old loop's while condition (which only reads the shared 'start' flag) sees true again and continues running with an already-aborted signal — subsequent interruptibleSleep calls resolve synchronously → tight-loop, or worse, the old loop calls stopConnector again and aborts the NEW controller. Fix: add !abortController.signal.aborted to the while condition. The old loop now exits immediately after abort regardless of the shared 'start' flag. 2. **waitRunningTransactionStopped stale connectorStatus snapshot** (subagent #1 finding 7): the helper fetched connectorStatus once before the loop and re-read the same object on each iteration. This works today because getConnectorStatus returns a Map reference that mutates in place, but the pattern was inconsistent with waitChargingStationAvailable / waitConnectorAvailable which call their predicates inline, and would silently break if getConnectorStatus ever returned a new object per call. Fix: inline the getConnectorStatus call in the while condition and inline it again for the one-time log message. Matches the pattern of the two sibling wait helpers. Gates pass (format / typecheck / lint). * fix(atg): move post-loop bookkeeping inside finally for exception paths Round-4 review (subagent #1 design/impl MEDIUM finding 3): the connectorStatus.stoppedDate assignment and the two 'Stopped on connector' logger calls at the end of internalStartConnector sat OUTSIDE the try/finally block. If any await inside the while loop rejected (waitChargingStationAvailable, startTransaction, stopTransaction, etc.), the finally block ran the controller cleanup — but the throw propagated past the post-loop block, leaving connectorStatus.stoppedDate undefined and skipping the 'Stopped on connector' + 'Stopped with connector status' log lines. The connector observably appeared to be still running for a stopped station. Move the four post-loop statements inside the finally block so the connector's stoppedDate is always set and the operator always sees the 'Stopped' log lines, regardless of exit path (normal exit, break, throw). The ChargingStationEvents.updated emit also relocates so the UI reflects the stopped state on every path. Gates pass (format / typecheck / lint). * docs: harmonize voltage warnings and @returns JSDoc across OCPP layer Round-4 review (subagents #3 OCPP+TS, #4 harmonization, #5 content) surfaced three harmonization drifts in JSDoc/log content: 1. ChargingStation.ts:1697 voltage warning said 'voltageOut=X V with AC output matches…' — 'with AC output' is redundant (the warning already gates on currentOutType === AC) and not spec terminology. Drop the qualifier. 2. CoherentSession.ts:103 voltage warning framed the diagnostic differently than ChargingStation.ts ("is treated as line-to-neutral by ACElectricUtils" vs "matches a line-to-line nominal value"). Also attributed the interpretation to ACElectricUtils, an implementation detail that leaked into a user-facing log. Align framing to match ChargingStation.ts and drop the ACElectricUtils attribution. 3. AutomaticTransactionGenerator.ts:302-304 abort-before-replace comment ended with 'before installing the new controller' — the 'new AbortController()' + 'connectorAbortControllers.set()' calls on the immediately following two lines restate that fact. Trim. 4. Four OCPP validate*Payload JSDocs used "@returns True if payload validation succeeds, false otherwise" — capitalized bare 'True'/'false' without backticks and no trailing period. Established pattern elsewhere in the same files uses "\ when … \ otherwise." Normalize in OCPPIncomingRequestService, OCPPRequestService, OCPPResponseService, and OCPPServiceUtils. Gates pass (format / typecheck / lint). * docs: polish batch from round-4 review Round-4 subagents flagged five small content-quality items, none blocking: 1. Utils.ts interruptibleSleep: delete two inline comment blocks that duplicate the JSDoc (timer-path cleanup and abort-path cleanup are already documented symmetrically in the JSDoc body). 2. Utils.ts isValidRandomIntBounds JSDoc: drop the last sentence that leaked call-site usage guidance into a general-utility predicate contract. Document the >= 0 constraint in @param. 3. AutomaticTransactionGenerator.ts validateConfiguration JSDoc: trim the memoization-mechanism sentence to a single clause. The full rationale already lives in the stop() reset comment. 4. AutomaticTransactionGenerator.ts validateConfiguration log messages: the > description understated the predicate rejection surface (it also rejects NaN/Infinity/non-integer/negative). Rewrite as invalid bounds matching the predicate contract. 5. Storage.ts three JSDoc @returns: backtick-quote void to match the codebase convention of quoting type names. No behavior change. Gates pass (format / typecheck / lint). * fix(ocpp/1.6): guard updateFirmwareSimulation against invalid delay bounds Round-4 review (subagent #4 harmonization finding 3): six sites in updateFirmwareSimulation call randomInt(minDelay, maxDelay + 1) using function-parameter bounds. Current callers (constructor lines 586 and 596) pass no arguments so the safe defaults (maxDelay=30, minDelay=15) apply. But the parameters are exposed, and any future caller passing config-driven values could hit a randomInt RangeError inside the async firmware simulation loop that surfaces only as a generic caught error. Add an early isValidRandomIntBounds guard immediately after the existing checkChargingStationState guard. On invalid bounds, log an error naming the offending pair and return without scheduling any simulation. Defensive-only — no behavior change for the current default-only callers. Gates pass (format / typecheck / lint). * fix(ocpp/2.0): thread abort signal through simulateFirmwareUpdateLifecycle sleeps Round-4 review (subagent #4 harmonization finding 1): the OCPP 2.0 firmware simulation lifecycle owns an AbortController (activeFirmwareUpdateAbortController set at line 3703) so a concurrent UpdateFirmware request can cancel an in-progress simulation (line 3091 aborts the previous controller). However, the eight await sleep(...) calls inside simulateFirmwareUpdateLifecycle did not observe that signal. The pattern was: await sleep(delayMs) if (checkAborted()) return which correctly exits after abort but only ONCE the sleep expires. A long sleep (retrieveDateTime scheduling, InstallDateTime scheduling) could keep the simulation running for hours after the abort. Replace each of the eight sleeps inside simulateFirmwareUpdateLifecycle with interruptibleSleep(delay, abortController.signal). The abort now wakes the sleep immediately; the subsequent checkAborted() guard observes the aborted state and returns. Callback semantics identical on the non-abort path. The ninth sleep at line 3902 (simulateLogUploadLifecycle) is left unchanged - that function does not own an AbortController and log uploads are not user-cancellable in this simulator. Gates pass (format / typecheck / lint). * fix(utils): enforce node:crypto randomInt 2^48 range limit in predicate Round-5 review (subagent OCPP+TS finding 8, HIGH): Number.isSafeInteger allows values up to 2^53 - 1, but node:crypto.randomInt rejects any call where max - min > 2^48 - 1 with a RangeError. The predicate's documented contract ('safe for randomInt') was therefore incorrect for wide ranges — the false-positive latent because current callers use small integer delays (15-30s) and SoC bounds (0-100). Add the 2^48 range check to the predicate and document it in the JSDoc. Empirically verified against Node 22: randomInt(0, 2**48) throws RangeError Number.isSafeInteger(2**48) === true Gates pass (format / typecheck / lint). * fix(ocpp): guard SOC randomInt against invalid template bounds The SoC MeterValues fallback path in buildSocMeasurandValue drew a random integer via randomInt(socMinimumValue, socMaximumValue + 1) where socMinimumValue comes from the (user-supplied) template minimumValue field and socMaximumValue is Constants.SOC_MAXIMUM_PERCENT (=100). If a template set minimumValue >= 101, randomInt would throw RangeError inside a MeterValues emission — surfacing only as a caught error in the OCPP path. Guard with isValidRandomIntBounds before the randomInt call. On invalid bounds, log a warn line naming the offending pair and fall back to socMaximumValue (100) so the measurand still produces a value. Gates pass (format / typecheck / lint). * fix(atg): gate all post-loop bookkeeping on controller ownership Round-5 review (design/impl finding 3, MEDIUM): the round-4 finally block gated only the connectorAbortControllers.delete() on the identity check (map.get === abortController). It then wrote connectorStatus.stoppedDate unconditionally, emitted the Stopped log lines, and fired the updated event. On a back-to-back stopConnector -> startConnector, the sequence is: t0: old loop finally fires t1: identity check: map.get === NEW controller (the successor already installed by startConnector); check fails, delete correctly skipped t2: connectorStatus.stoppedDate = new Date() <-- corrupts the new run's status object (shared reference in connectorsStatus) t3: 'Stopped on connector' log fires for a connector the operator just re-started Gate all four post-loop operations (delete, stoppedDate, info log, debug log, updated event) on a single isOwner boolean. Non-owner paths silently exit — the successor run owns the status object and will emit its own Stopped log when it eventually completes. Gates pass (format / typecheck / lint). * fix(ocpp/2.0): guarantee clearActiveFirmwareUpdate on every exit path Round-5 review (harmonization finding C-2, MEDIUM): simulateFirmwareUpdateLifecycle called clearActiveFirmwareUpdate only on three specific paths (empty location, signature failure, happy completion). Any other early-return path (7 abort returns) or a thrown await left activeFirmwareUpdateAbortController set. A subsequent UpdateFirmware.req would then abort() a non-existent in-progress update, and stationState.activeFirmwareUpdateRequestId would never re-populate — the station appeared stuck with a phantom in-progress firmware update. Wrap the entire body in try/finally with a single clearActiveFirmwareUpdate call in finally. Delete the three now-redundant site-local calls. Also correct the abort-controller store comment from 'cancel' to 'abort' (codebase terminology finding B1/D4 from the round-5 content review). Gates pass (format / typecheck / lint). * docs: polish batch from round-5 review Four small content-quality items surfaced by round-5 review: 1. AutomaticTransactionGenerator.waitRunningTransactionStopped: the first-iteration log line called getConnectorStatus a second time (separate from the loop condition) to read transactionId. Between the two reads the transaction could theoretically end and a new one start, logging a different id than the one that triggered the wait. Snapshot transactionId into a local const before the log. 2. AutomaticTransactionGenerator.validateConfiguration error messages and OCPP16IncomingRequestService.updateFirmwareSimulation abort message both suffixed 'for randomInt(min, max + 1)' — misleading because isValidRandomIntBounds validates raw bounds, not the +1 form. Drop the suffix; the 'invalid bounds' clause is sufficient. 3. CoherentSession voltage warning lacked the actionable remediation hint present in the ChargingStation counterpart. Append 'Set voltageOut to the L-N equivalent in the station template to resolve.' No behavior change. Gates pass (format / typecheck / lint). * fix(utils): tighten isValidRandomIntBounds boundary by one The predicate validated maxValue - minValue < 2^48, but every call site passes randomInt(min, maxValue + 1). node:crypto's randomInt requires max_exclusive - min <= 2^48 - 1, so the effective constraint on the inclusive bounds is maxValue - minValue <= 2^48 - 2. The old boundary permitted maxValue - minValue = 2^48 - 1, which after the +1 offset would throw RangeError at the randomInt call. Practical impact is nil (all real config paths are far below the limit) but the predicate is now nominally correct. Also trim JSDoc overexplanation of caller convention. * fix(ocpp): skip SoC measurand emission on invalid bounds buildSocMeasurandValue previously fabricated a synthetic 100 % SoC reading when the template's minimumValue was misconfigured (e.g. a negative float that fails isValidRandomIntBounds). Emitting 100 % looks like a valid meter reading to the CSMS and could distort billing, session-end triggers, and analytics on the operator side. Skip the measurand entirely instead — consistent with the existing null-return path when the SoC template itself is absent (line 261). The warn log still surfaces the misconfiguration. * refactor(ocpp20): extract resetActiveFirmwareUpdateState helper handleRequestUpdateFirmware's abort-and-replace path directly wrote undefined to the two activeFirmwareUpdate* fields, while the lifecycle finally routed through clearActiveFirmwareUpdate. Any future logic added to the helper (logging, metrics, invariants) would silently diverge for the abort-and-replace path. Extract resetActiveFirmwareUpdateState as the single source of truth for the field reset. clearActiveFirmwareUpdate still guards on requestId identity (protecting a successor's state from being cleared by a stale finally); handleRequestUpdateFirmware calls the reset unconditionally because the abort-and-replace semantics require it. * feat(atg): log displaced-loop exit at debug level The isOwner gate silently returned from the finally block when a concurrent stopConnector→startConnector had already installed a successor controller. Diagnosing 'why did the old loop stop?' under concurrency required knowing the silent path existed. Emit a debug line on the non-owner path so displaced-loop exits are observable without adding noise at higher log levels. Also trim the redundant second half of the ownership comment (the consequence is already implied by the WHY sentence above). * docs(coherent): align voltage warning voice with ChargingStation CoherentSession's L-L/L-N mismatch warning used passive voice ('If this value is meant as line-to-line') while the parallel warning in ChargingStation.ts uses direct second-person ('If you intended'). Align to the second-person form for cross-file consistency. * docs(utils): align isValidRandomIntBounds JSDoc notation The description body stated 'maxValue - minValue <= 2^48 - 2' while @param stated 'maxValue - minValue < 2^48 - 1'. Both are equivalent for integers but forced a reader to verify equivalence. Also drop the derivation showing how the node:crypto max_exclusive - min <= 2^48 - 1 constraint reduces to maxValue - minValue <= 2^48 - 2 — the derivation belongs in commit history, not in the live docblock. @param and description now use the same notation (<= 2^48 - 2). * docs(logs): align tense and specificity in round-6 messages Two log-message polish items surfaced by round-7: ATG.internalStartConnector displaced-loop debug log used present participle 'Exiting' while the sibling info log at line 391 uses past tense 'Stopped'. Both fire from the finally block reporting a completed event. Align to 'Exited'. OCPPServiceUtils.buildSocMeasurandValue skip-log action clause read 'skipping measurand'. Sibling messages in ATG and OCPP16 use fully qualified action noun phrases ('aborting connector startup', 'aborting firmware update simulation'). Add the 'SoC' qualifier for parallelism: 'skipping SoC measurand'. * refactor(ocpp20): harmonize firmware-state cleanup + log superseded Three coherence gaps identified by round-7 harmonization review: stop() aborted the active firmware update but wrote the delete without routing through resetActiveFirmwareUpdateState. Latent-only because the stationsState.delete makes the fields unreachable, but the pattern diverged from every other cleanup site. Route through the helper. clearActiveFirmwareUpdate silently returned when the requestId did not match the active one — the exact 'displaced' pattern the ATG round-6 fix addressed. A stale finally firing after a successor took over is diagnostically important. Emit a debug line for the superseded path. Naming distinction (reset = unconditional, clear = identity-guarded) is now self-documenting via the guard in clearActiveFirmwareUpdate. * fix(ocpp20): prevent state resurrection in clearActiveFirmwareUpdate getStationState is a lazy-init getter: on cache miss it creates an empty entry and adds it to stationsState. clearActiveFirmwareUpdate runs in the finally of simulateFirmwareUpdateLifecycle. If stop() has already deleted the station entry before the aborted lifecycle's finally fires, the lazy-init would resurrect a fresh empty entry — leaking state past shutdown. Use stationsState.get() directly and no-op silently when the entry is absent. The non-owner debug log now only fires for genuine supersession (state present, requestId mismatched). * docs: revert isValidRandomIntBounds JSDoc to match code + fix typo Round-7 aligned the JSDoc @param to '<= 2^48 - 2' while the code kept '< 2 ** 48 - 1'. Both forms are equivalent for integers but the JSDoc notation deviated from the code's literal. Revert JSDoc to '< 2^48 - 1' which mirrors the code and stays close to node:crypto's own docs phrasing ('range must be less than 2^48'). Also fix a pre-existing typo in the Constants.MAX_RANDOM_INTEGER comment: 'randomInit()' -> 'randomInt()'. * fix(ocpp20): use raw stationsState.get() in FirmwareStatusNotification trigger The TriggerMessage/FirmwareStatusNotification case at line 564 is a reporting path — it reads activeFirmwareUpdateRequestId to build the notification payload but does not otherwise mutate station state. Calling getStationState (which lazy-inits on cache miss) here means a TriggerMessage arriving for a station that has never had a firmware update creates a spurious empty state entry, and a TriggerMessage arriving between stop() and WS close would resurrect state after shutdown — same pattern as the round-8 clearActiveFirmwareUpdate fix. Use stationsState.get() directly and optional-chain the requestId read. When no state exists the notification carries requestId undefined, which is spec-compliant for status = Idle (OCPP 2.0.1 L01.FR.20: requestId is mandatory only for non-Idle statuses). * docs(utils): drop @param maxValue range-width restatement The @param maxValue clause restated 'with maxValue - minValue < 2^48 - 1', which is already stated in the description body. Trim to just the intrinsic bound (inclusive safe integer >= minValue) and let the range-width constraint live where it belongs (the body). * refactor(ocpp20): rename getStationState to getOrCreateStationState The private getter lazily creates a station state entry on cache miss. Callers seeing 'getStationState(cs)' vs 'stationsState.get(cs)' side by side could not tell that the former creates state while the latter does not — the very split rounds 8 and 9 introduced to fix state-resurrection bugs (clearActiveFirmwareUpdate, TriggerMessage/ FirmwareStatusNotification). Rename the lazy-init getter so its name carries the semantics: this.getOrCreateStationState(cs) // creates on miss - handler paths this.stationsState.get(cs) // undefined on miss - cleanup/reporting Nine call sites + one definition. Zero behavior change. * docs(utils): make @param minValue structurally symmetric with @param maxValue Round-9 trimmed @param maxValue to 'safe integer >= minValue' but left @param minValue as 'non-negative safe integer'. Both bounds now state 'safe integer >= X' — @param minValue relative to 0, @param maxValue relative to minValue. The description body still carries the rejection list (NaN, Infinity, floats, negatives, range-width). * fix(ocpp20): cross-check firmware status against active requestId in trigger FirmwareStatusNotification TriggerMessage read from two independent sources: hasFirmwareUpdateInProgress reads chargingStation.stationInfo .firmwareStatus, activeFirmwareUpdateRequestId lives on stationsState. They can diverge in real windows: 1. simulateFirmwareUpdateLifecycle sets activeFirmwareUpdateRequestId at line 3716 before its first sendFirmwareStatusNotification (line 3467). During any await between the two — notably the retrieveTime sleep at 3730 — a trigger would emit { requestId: X, status: Idle/undefined }. 2. On exception paths the finally resets activeFirmwareUpdateRequestId but leaves stationInfo.firmwareStatus at its last-set value. A trigger fired between the exception and the next UpdateFirmware.req would emit { requestId: undefined, status: <non-Idle> } — an OCPP 2.0.1 L01.FR.20 violation (requestId mandatory for non-Idle). Gate the non-Idle firmwareStatus branch on requestId being defined — activeFirmwareUpdateRequestId is the authoritative signal for 'an update is in progress'. When it is undefined we always emit Idle, which is spec-compliant regardless of the stationInfo staleness. * refactor(ocpp): extract getOrCreateWarnedMeasurands helper The resolveEnabledMeasurands warn-once path had a 4-line inline lazy-init block on warnedInvalidMeasurands (WeakMap<ChargingStation, Set<string>>). Extract it as a module-level helper mirroring the round-10 getOrCreateStationState naming. Same semantic distinction as OCPP20IncomingRequestService: - getOrCreate* — lazy-init, always returns a live reference - .get() — raw WeakMap read, may return undefined * fix(ocpp20): apply dual-gate to LogStatusNotification trigger The LogStatusNotification TriggerMessage case sent { status: Idle } unconditionally, with no requestId — losing the signal when a log upload is genuinely in progress and mirroring the same pre-fix gap round-11 closed for FirmwareStatusNotification. Round-11 established the dual-gate pattern: an active requestId in stationsState is the authoritative 'operation in progress' signal; the status is emitted from the same source of truth to guarantee consistency between requestId and status. Log upload has no stationInfo.logStatus equivalent (unlike firmware's stationInfo.firmwareStatus), so store the status alongside the requestId in the stationState. Wrap simulateLogUploadLifecycle in try/finally to guarantee cleanup on exception. The trigger now reports Uploading/Uploaded with the active requestId when in-flight, Idle otherwise — matching the firmware pattern structurally. * docs(ocpp20): enumerate all 8 in-progress statuses in hasFirmwareUpdateInProgress @returns The JSDoc @returns listed 3 statuses (Downloading, Downloaded, Installing) but the body checks 8 (also DownloadScheduled, DownloadPaused, InstallScheduled, InstallRebooting, SignatureVerified). Enumerate all 8 to match the implementation. * fix(ocpp20): guard log-upload mid-lifecycle mutation + wrap firmware JSDoc Two round-13 findings surfaced in the same file: 1. simulateLogUploadLifecycle mutated activeLogUploadStatus = Uploaded without an identity guard. If a concurrent GetLog request installed a new lifecycle during the sleep, the old lifecycle's post-sleep resume would overwrite the new lifecycle's status with a stale Uploaded, causing the TriggerMessage handler to report the wrong signal for the in-flight upload. Guard the mid-lifecycle status mutation with the same identity check used in the finally. Extract clearActiveLogUpload as a helper mirroring clearActiveFirmwareUpdate — same raw-.get() + null-guard + identity-check + debug-log-on-superseded pattern for observability parity with the firmware peer. 2. hasFirmwareUpdateInProgress @returns clause was 183 chars on one line and used unbacktick'd 'true'. Wrap the enumeration across three lines and restore the `true` backtick style established by 92a8dac1. * fix(ocpp20): implement log-upload supersession per OCPP 2.0.1 N01.FR.12 Round-14 subagent C surfaced a HIGH spec-conformance gap: when a new GetLog request arrives with a prior upload in progress, the CS was returning Accepted and letting the old lifecycle run to completion (sending a spurious Uploaded for the superseded requestId). This violates N01.FR.12 + FR.20 and fails TC_N_36_CSMS step 7 which expects LogStatusNotification(AcceptedCanceled) for the old id. handleRequestGetLog now mirrors handleRequestUpdateFirmware: - detect active upload, capture the previous requestId - reset log state so the old lifecycle exits gracefully - send LogStatusNotification(AcceptedCanceled) for the old id - return GetLogResponse with status AcceptedCanceled The GET_LOG on-hook now accepts both Accepted and AcceptedCanceled to start the new lifecycle. The mid-lifecycle Uploaded emission is now co-located inside the identity guard: a superseded lifecycle skips both the state mutation AND the wire notification, preventing the spurious Uploaded that would follow an already-emitted AcceptedCanceled. Extracted resetActiveLogUploadState mirroring resetActiveFirmwareUpdateState (round-14 subagent A finding 2) so clearActiveLogUpload delegates to the two-field wipe rather than inlining it — full structural parity with the firmware peer. * fix(ocpp20): round-15 clear-log parity + stop() log reset + JSDoc Three findings from the same review round, one file: 1. clearActiveFirmwareUpdate and clearActiveLogUpload logged the debug 'superseded requestId X (active: Y)' message even when the active field was undefined (the state was reset, not superseded). The post-supersession trace fires clearActive* with the old requestId after resetActive*State cleared the active field — the log said 'active: undefined' which reads as a bug. Tighten the else branch to fire only when a DIFFERENT non-null requestId is active; drop the String() wrapper since only the number path can reach it. 2. stop() aborted the firmware controller and reset firmware state before deleting the stationsState entry, but skipped the log upload state. The delete makes the fields unreachable so it is not a memory leak, but the asymmetry breaks the structural mirror with firmware and the aborted-but-still-running log lifecycle would see inconsistent state post-stop. Add resetActiveLogUploadState for parity. 3. handleRequestGetLog @returns still said 'Accepted status' only — stale since the round-14 supersession fix. Extend to mention both Accepted (no prior upload) and AcceptedCanceled (superseded prior upload) with a description sentence on the supersession behavior. * fix(ocpp20): cancel cert-signing retry timer in stop() + JSDoc polish Three findings from round-16 review of the round-15 changes: 1. MEDIUM: OCPP20StationState.certSigningRetryManager holds a live setTimeout whose callback closes over chargingStation. The stationsState.delete() in stop() drops the WeakMap entry but the timer keeps chargingStation alive until it fires. Add certSigningRetryManager?.cancelRetryTimer() alongside the firmware abort() call, before the resets and the delete — closes the leak and matches the abort-before-reset pattern established for firmware. 2. LOW: 'simulates a Uploading' — wrong article. Fix to 'simulates an Uploading' (starts with vowel sound). 3. LOW: The @returns clause exceeded 140 chars on a single line. Wrap onto two lines to match the ~100-char convention. * fix(ocpp20): add AbortController to log-upload lifecycle + canceled spelling Round-17 findings from rounds 13-17 flagged the log-upload/firmware structural asymmetry repeatedly: firmware had AbortController + reset, cert-signing had cancelRetryTimer + reset, log had only identity-guard + state reset. A superseded lifecycle woke from sleep on its own schedule, wasted the delay, and the aborted-but-still-running coroutine emitted spurious wire notifications until the identity guard caught it. Round-17's harmonization subagent explicitly said 'worth fixing in this PR while the pattern is fresh'. Add activeLogUploadAbortController to OCPP20StationState, create it in simulateLogUploadLifecycle, replace sleep() with interruptibleSleep threading the signal, and gate the mid-lifecycle status write and send on both signal.aborted and the identity check. abort() the controller in handleRequestGetLog supersession, in stop(), and reset it via resetActiveLogUploadState. sleep import is now unused — removed. Also fix pre-existing British/American spelling drift surfaced by round-17 content review: 'Retry timer cancelled' -> 'canceled', for consistency with the cancelRetryTimer method name and OCPP enum values (AcceptedCanceled).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Close #155
Close #33
Signed-off-by: Jérôme Benoit jerome.benoit@piment-noir.org