feat: TR-069 CWMP state machine hardening + exchange viewer improvements
- TR-069 CWMP state machine hardening (14 phases): shared event utility, multi-event routing, GPN circuit breaker, IdleState GPN guard, expanded GPN fault codes, CriticalReadsState, ConfigEval GPN guard, task queue race condition fix, explicit error handling, terminal states (OperationalState/PartialOperationalState), consolidated reclassify, crash pattern detection, removed enqueueImmediate, state flow wiring - Fix SOAP Fault not processed by state machine (soap-env:Fault detection) - Fix GPN circuit breaker not persisting after session drops - Fix CriticalReadsState GPV response parsing (xsi:type normalization) - Fix CriticalReadsState not processing GPV response values - Skip SPV when device is already compliant (ProvisioningCode check) - Add Device.DeviceInfo.ModelName to critical reads GPV - Fix TypeError on DeviceDetail parameters view (null guards) - Log empty 204 responses in exchange trace UI - TR-181 catalog: type corrections and new entries (+6640 lines) - SequenceViewer: replace session-nav buttons with compact dropdown select - SequenceViewer: fix CPE/ACS lifeline headers wrapping to 2 lines - Add 20 unit tests for state machine fixes (SOAP Fault, GPN circuit breaker, CriticalReads, stale session, ConfigEval/ComplianceUpdate skips) Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
This commit is contained in:
1 parent
dabe15839d
commit
aad93911e4
35 files changed
+8593
-4497
No files matched your search
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Shared CWMP event normalization and priority resolution utilities.
|
||||
* Single source of truth for event code handling (fixes MINEUR-9).
|
||||
*/
|
||||
|
||||
export const EVENT_PRIORITY: Record<string, number> = {
|
||||
'BOOTSTRAP': 100,
|
||||
'BOOT': 90,
|
||||
'CONNECTION REQUEST': 80,
|
||||
'PERIODIC': 70,
|
||||
'VALUE CHANGE': 60,
|
||||
'DIAGNOSTICS COMPLETE': 50,
|
||||
'TRANSFER COMPLETE': 40,
|
||||
'SCHEDULE': 30,
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize an EventCode from an Inform message.
|
||||
* Strips numeric prefix and normalizes the label.
|
||||
* Examples: '0 BOOTSTRAP' → 'BOOTSTRAP', '1 BOOT' → 'BOOT', '6' → 'CONNECTION REQUEST'
|
||||
*/
|
||||
export function normalizeEventCode(raw: string): string {
|
||||
const trimmed = raw.trim().toUpperCase()
|
||||
|
||||
// Already a known label without numeric prefix
|
||||
if (EVENT_PRIORITY[trimmed] !== undefined) return trimmed
|
||||
|
||||
// Full format like "0 BOOTSTRAP" → strip numeric prefix
|
||||
const match = trimmed.match(/^\d+\s+(.+)$/)
|
||||
if (match) return match[1]
|
||||
|
||||
// Numeric-only → expand to standard label
|
||||
switch (trimmed) {
|
||||
case '0': return 'BOOTSTRAP'
|
||||
case '1': return 'BOOT'
|
||||
case '2': return 'PERIODIC'
|
||||
case '3': return 'SCHEDULED'
|
||||
case '4': return 'VALUE CHANGE'
|
||||
case '5': return 'KICKED'
|
||||
case '6': return 'CONNECTION REQUEST'
|
||||
case '7': return 'TRANSFER COMPLETE'
|
||||
case '8': return 'DIAGNOSTICS COMPLETE'
|
||||
default: return trimmed
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the highest priority event from a list of raw event codes.
|
||||
* Returns the normalized name of the highest-priority event.
|
||||
*/
|
||||
export function resolveHighestPriorityEvent(events: string[]): string {
|
||||
if (events.length === 0) return ''
|
||||
|
||||
let highest = ''
|
||||
let highestPriority = -1
|
||||
|
||||
for (const raw of events) {
|
||||
const normalized = normalizeEventCode(raw)
|
||||
const priority = EVENT_PRIORITY[normalized] ?? 0
|
||||
if (priority > highestPriority) {
|
||||
highestPriority = priority
|
||||
highest = normalized
|
||||
}
|
||||
}
|
||||
|
||||
return highest
|
||||
}
|
||||
Reference in new issue
Block a user