No description
Find a file
Jon Vanvik 203465913c Apply code-review fixes: identity/pagination, load races, TLS pin, leaks
Addresses a multi-agent code review (26 confirmed findings + a URLSession
leak) across correctness, concurrency, security, and cleanup:

- MongoDocument.id: deterministic fallback (was UUID() on every access) to stop
  SwiftUI List/ForEach identity churn; getAll pagination drives its cursor off
  the real _id via documentId, so a missing _id stops paging instead of looping
  on a fabricated cursor.
- View models: per-load generation guard (+ captured-tab guard on ONU detail)
  so a cancelled or overlapping load can't commit stale results or land data on
  the wrong tab.
- JSONValue.intValue: guard Int(d) against NaN/inf/out-of-range (crash).
- ServerTrustEvaluator: hash the real SubjectPublicKeyInfo (prepend the
  algorithm-specific ASN.1 SPKI header) so a standard openssl-captured
  public-key pin actually matches; unknown key types fail closed.
- AppEnvironment.configure: clear stale cookies + Keychain creds on host change.
- FirmwareFile.isCompatible: empty metadata no longer passes as compatible-for-all.
- APIClient: invalidate URLSession on deinit (per-configure/probe leak).
- Dashboard best-effort sections keep last-good on transient failure; unified
  optical thresholds; LoginView prefill-once; populatedBuckets unique ForEach id;
  Format rounding rollover; dead-code/docstring/dedup cleanups.

Verification pending on the Mac (no Swift toolchain on the Linux dev box).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 16:36:49 +02:00
Assets.xcassets/AppIcon.appiconset initial commit 2026-05-31 14:11:29 +02:00
323-1961-302_mcms_6_2_pon_manager_user_guide.pdf initial commit 2026-05-31 14:11:29 +02:00
323-1961-306_mcms_6_2_rest_api_developer_guide.pdf initial commit 2026-05-31 14:11:29 +02:00
APIClient.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
APIConfiguration.swift initial commit 2026-05-31 14:11:29 +02:00
APIEnvelope.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
APIError.swift initial commit 2026-05-31 14:11:29 +02:00
APIQuery.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
AppEnvironment.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
AuthModels.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
AuthRepository.swift initial commit 2026-05-31 14:11:29 +02:00
Components.swift initial commit 2026-05-31 14:11:29 +02:00
DashboardDrilldownViews.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
DashboardView.swift initial commit 2026-05-31 14:11:29 +02:00
DashboardViewModel.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
DeviceModels.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
DeviceRepositories.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
Firmware.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
FirmwareUpdateSheet.swift initial commit 2026-05-31 14:11:29 +02:00
Format.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
GUI-NOTES.md initial commit 2026-05-31 14:11:29 +02:00
HANDOFF.md initial commit 2026-05-31 14:11:29 +02:00
KeychainStore.swift initial commit 2026-05-31 14:11:29 +02:00
LoginView.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
MCMS_API.md initial commit 2026-05-31 14:11:29 +02:00
MCMSConnection.swift initial commit 2026-05-31 14:11:29 +02:00
MCMSEndpoint.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
MCMSMobileApp.swift initial commit 2026-05-31 14:11:29 +02:00
MongoTimestamp.swift initial commit 2026-05-31 14:11:29 +02:00
OLTDetailView.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
OLTDetailViewModel.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
OLTListView.swift initial commit 2026-05-31 14:11:29 +02:00
OLTListViewModel.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
ONUDetailView.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
ONUDetailViewModel.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
ONUListView.swift initial commit 2026-05-31 14:11:29 +02:00
ONUListViewModel.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
ONURepository.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
README.md initial commit 2026-05-31 14:11:29 +02:00
ResetConfirmSheet.swift initial commit 2026-05-31 14:11:29 +02:00
ServerTrustEvaluator.swift Apply code-review fixes: identity/pagination, load races, TLS pin, leaks 2026-05-31 16:36:49 +02:00
SessionStore.swift initial commit 2026-05-31 14:11:29 +02:00
SettingsView.swift initial commit 2026-05-31 14:11:29 +02:00

PON Go — iOS

Native iOS app for Ciena MCMS 6.2 PON Manager basics on the go — dashboard, ONU and OLT browsing/diagnostics, firmware updates, resets. SwiftUI + URLSession, no external dependencies. Sibling of the Android app (../mcms_android); the REST behaviour and field paths are identical and documented in MCMS_API.md.

App name PON Go (Xcode project/target is currently SVO_MCMS).

⚠️ Source layout — read this first

This folder holds the canonical flat Swift sources (plus docs, the app icon, and the dev-guide PDFs). The actual Xcode project lives elsewhere (~/Documents/mcms_ios_xcode/run<N>/SVO_MCMS/); the workflow so far has been to copy changed .swift files into the Xcode project and build there.

For a clean git repo, consolidate: move these .swift files + Assets.xcassets/ into the Xcode project directory, make that the iOS repo (with docs/MCMS_API.md and the PDFs alongside), and drop the copy-sync dance. Until then, this folder is the source of truth — edit here, copy into Xcode.

Build (Xcode)

  • Xcode 26 (iOS 26 SDK), deployment target iOS 17+. New iOS App (SwiftUI lifecycle); delete the template ContentView.swift / generated App struct (this scaffold provides its own @main in MCMSMobileApp.swift).
  • Build Settings → Default Actor Isolation → nonisolated. Xcode 26 defaults this to MainActor, which makes the pure-data types (APIQuery.empty, JSONValue: Equatable, …) emit ~8 main-actor warnings (errors under Swift 6 mode). The code is designed nonisolated-by-default; only UI/stateful classes are explicitly @MainActor.
  • App name / icon: set the target's Display Name → "PON Go", and drag Assets.xcassets/AppIcon.appiconset into the project's asset catalog (replacing the existing AppIcon).
  • App Transport Security: self-signed TLS is handled in code by ServerTrustEvaluator (no Info.plist change for HTTPS cert validation). For plain HTTP hosts, add a scoped NSAppTransportSecurityNSExceptionDomains entry for that host in Info.plist — never NSAllowsArbitraryLoads.

Verify off-device (no iOS SDK needed)

The networking core + AppEnvironment + view models import only Foundation/Observation, so they typecheck against the macOS SDK:

swiftc -typecheck -sdk "$(xcrun --show-sdk-path)" \
  <core + AppEnvironment + *ViewModel .swift files> /tmp/loadphase_stub.swift

Add a one-line stub for LoadPhase (it lives in the SwiftUI Components.swift): enum LoadPhase: Equatable { case idle, loading, loaded; case failed(String) }. Target every run: 0 errors, 0 warnings. SwiftUI views that use iOS-only APIs can't be compiled this way — validate those with isolated snippets or in Xcode.

Layout

App:        MCMSMobileApp (@main), RootView routing, AppEnvironment
Networking: APIConfiguration, MCMSConnection, APIClient, APIEnvelope (JSONValue),
            APIError, APIQuery, MCMSEndpoint, SessionStore, ServerTrustEvaluator,
            KeychainStore, MongoTimestamp, Format
Models:     DeviceModels, AuthModels, Firmware
Repos:      AuthRepository, ONURepository, DeviceRepositories
UI:         Components, Login/Settings/Dashboard/ONUList/ONUDetail/OLTList/
            OLTDetail views + view models, ResetConfirmSheet, FirmwareUpdateSheet,
            DashboardDrilldownViews
Docs:       MCMS_API.md (field guide), the two 323-1961-30x dev-guide PDFs

See HANDOFF.md for architecture, the API gotchas, and status. GUI-NOTES.md is early scaffold notes (historical — superseded by this README).