Commit Graph

3343 Commits

Author SHA1 Message Date
Joseph Doherty 59817f5017 perf(deployment,template-engine): batched untracked staleness loads, staging-failure detach, lock-held Disabled re-check, targeted single-entity loads (DEP-4, DEP-5, DEP-6, TPL-4, WP6 task 6.6)
DEP-4: new ITemplateEngineRepository.GetInstancesByIdsUntrackedAsync (one
AsNoTracking split query per 500-id chunk). GetInstanceStalenessAsync preloads
each chunk into its FlattenSession; FlattenCoreAsync takes a preloaded
instance (consumed once) before falling back to the tracked per-instance load.
Deploy sessions never preload, so prepare keeps its tracked load.
  Throwaway harness, SQLite, 1,000 instances x 50 overrides:
  before: 5,000 reader commands, 51,000 tracked entities
  after:  10 reader commands, 0 tracked entities
  (wall time on in-process SQLite 2.7 s -> 2.3 s; the win on SQL Server is
  the 4,990 saved round-trips and the change tracker staying empty)

DEP-5: AddPendingDeploymentAsync supersedes prior rows with a set-based
delete (DeletePendingWhereAsync) instead of tracked key stubs, and a failed
staging save calls DetachPendingChanges under dbGate so it cannot poison the
next instance's staging save on the shared bulk context.
  Regression: prior row purged between supersede and save -> before:
  DbUpdateConcurrencyException; after: stages cleanly.

DEP-6: bulk prepare (reconcileGate != null) re-reads the instance state
untracked (new IDeploymentManagerRepository.GetInstanceStateAsync) once the
operation lock is held; Disabled -> reported in SkippedInstances with the
Disabled reason, never flattened/sent/re-enabled. Placed at the top of
PrepareUnderLockAsync so it is independent of WP7's lock-ordering change.

TPL-4: area delete uses the new shallow untracked GetInstancesBySiteIdShallowAsync;
SetAlarmOverride and Delete{Attribute,Alarm,Script} read the analysis closure
instead of the whole template table; MoveTemplate's collision check is the new
TemplateNameExistsInFolderAsync (one folder's names). SiteService already used
the include-free ISiteRepository read (unchanged).
2026-12-03 10:09:41 -05:00
Joseph Doherty 04e3969071 perf(audit-log,site-event-log): channel+age purge index with varchar binding; instance+timestamp event index (AUD-5, SEL-1, WP6 task 6.5)
AUD-5: PurgeChannelOlderThanAsync binds @channel as varchar(32) and the model
gains IX_AuditLog_Channel_Occurred (Category, OccurredAtUtc). The migration +
partition-aligned SQL script land in the WP's final migration commit
(AuditLogChannelOccurredIndex).
  sqlcmd -I, SQL_Latin1_General_CP1_CI_AS, scratch DB with 1M AuditLog rows
  (6 channels, clustered (OccurredAtUtc, EventId), ScriptTrace override 30 d),
  steady-state per-channel tick (nothing left to purge):
  before (nvarchar, old indexes): 5,858 logical reads, 124 ms
  after  (varchar + new index):   6 logical reads, 0 ms
  new index but nvarchar param:   4,747 logical reads, 114 ms (binding matters)

SEL-1: site_events idx_events_instance -> idx_events_instance_timestamp
(instance_id, timestamp), dropped/rebuilt in place by SiteEventLogSchema.Apply
like #123; the storage-cap size model now charges 4 x timestamp per row.
  sqlite3, 2.7M rows / 20 instances, instance-filtered 501-row page:
  before: SEARCH idx_events_instance + USE TEMP B-TREE FOR ORDER BY; 396 ms
  after:  SEARCH idx_events_instance_timestamp (temp b-tree for id tiebreak only); 0.7 ms
2026-12-03 10:00:42 -05:00
Joseph Doherty 9f03726fc7 perf(audit-log): private-cache connections, owed-range pull index, age-seekable purge, batched tracking reads (AUD-2, AUD-3, AUD-4, AUD-7, WP6 task 6.4)
AUD-2: drop Cache=Shared from the file-backed site audit connection string
(kept only by the in-memory test override). Two private WAL connections no
longer share table-level locks.
  Test OpenReadTransaction_DoesNotStallTheWriter (deferred read txn open on a
  connection with the writer's connection string): with Cache=Shared the
  write timed out (>5 s; would retry to the 30 s command timeout and fault);
  without it the write completes in well under 1 s.

AUD-3: new partial index IX_fwd_owed (OccurredAtUtc, EventId) WHERE
ForwardState IN (owed states); ReadPendingSinceAsync names it (INDEXED BY),
repeats the literal state list (bound parameters never satisfy a partial
index's WHERE), and orders/keysets on fs.EventId (same value, no join for
the sort).
  sqlite3 3.54, 1,000,000 audit rows (90% Pending), no ANALYZE stats, 256-row page:
  before: SEARCH fs USING INDEX IX_fwd (ForwardState=?) + TEMP B-TREE FOR ORDER BY; 2.6-3.5 s
  after:  SEARCH fs USING INDEX IX_fwd_owed (OccurredAtUtc>?), no sort; 0.6-0.7 ms
          (keyset page with afterId: 3.6 s -> 0.6 ms)

AUD-4: purge page adds IsCachedKind IN (0, 1) so IX_fwd seeks
(state, kind, age).
  same DB, 100k Forwarded rows, nothing expiring (the final short page):
  before: SEARCH IX_fwd (ForwardState=?) 16.9 ms (linear in retained rows)
  after:  SEARCH IX_fwd (ForwardState=? AND IsCachedKind=? AND OccurredAtUtc<?) 0.06 ms

AUD-7: new optional Commons IOperationTrackingBatchReader (separate interface
so test doubles/implementations are untouched); OperationTrackingStore
implements GetStatusManyAsync (one writer-queue barrier, chunked IN reads on
one connection). SiteAuditTelemetryActor resolves a drain's distinct ids with
one batched read when available, else memoises per-id reads per drain.
  A BatchSize-256 drain: 256 sequential barriers + 256 connections -> 1 barrier,
  1 connection, 1 query (ids sharing an operation are read once).
2026-12-03 09:58:29 -05:00
Joseph Doherty 54416e33bf perf(store-and-forward): rank sweep lanes over a covering narrow index, join payloads for the page only (SF-3, WP6 task 6.3)
The fair-paging sweep computed ROW_NUMBER() over every column of every due
row, so each sweep sorted the whole due backlog with payloads into temp
storage. The ranking now projects only id + lane keys over the new covering
idx_sf_messages_lane (status, category, target, created_at,
last_attempt_at_ms, retry_interval_ms, id), takes the page of ids, and joins
back by primary key. The index is created in place by StoreAndForwardSchema
(idempotent, local only — not part of CDC capture). idx_sf_messages_category
is kept (still used by parked-count filters).

EXPLAIN QUERY PLAN + timing, sqlite3 3.54, 200,000 due rows x ~1 KB payload,
20 targets x 3 categories, LIMIT 500:
  before: SEARCH idx_sf_messages_status_created (status=?) + USE TEMP B-TREE
          FOR ORDER BY (window over full rows) + outer temp b-tree; 1.29 s
  after:  SEARCH USING COVERING INDEX idx_sf_messages_lane (no window sort),
          outer temp b-tree over (id, rank, created_at) only, PK join of 500
          rows; 0.15 s
2026-12-03 09:47:29 -05:00
Joseph Doherty d3c6295670 perf(site-runtime): route expression triggers by referenced keys; heap cap eviction; O(1) predictor lane (SRT-7, SRT-14, CMN-11, WP6 task 6.2)
SRT-7: TriggerExpressionKeys extracts the literal Attributes["k"] /
Children["c"].Attributes["k"] reads of an Expression trigger; the Instance
Actor routes the child only those attributes (new MonitoredAttributes routing
kind). Anything not pinnable (non-literal key, alias/member access of the
globals, Parent, parse error, zero reads) falls back to all-changes. Child
actors are unchanged (narrow: WP3 edits ScriptActor/AlarmActor).
  Evidence: instance with 250 attributes at 1 Hz and 10 expression children
  each reading 2 attributes — child mailbox deliveries (and per-eval snapshot
  copies + CTS allocations) go from 2,500/s to 20/s (routing-map test pins
  that a non-read attribute has no route).

SRT-14: EnforceCap selects the oldest conditions with a bounded max-heap and
rate-limits the eviction Warning (1/min with an eviction count).
  Stopwatch, n=1001 k=1 per transition at the cap: OrderBy 13.0-18.2 us -> heap 1.2 us.

CMN-11: FlowShapePredictor looks up a node by the index encoded in its
append-only id (O(1)) instead of a linear scan per AddNode/Annotate.
  Stopwatch PredictSiteScript, Release: 5,000 nodes 125.5 -> 54.9 ms,
  20,000 nodes 434.2 -> 83.3 ms.
2026-12-03 09:45:50 -05:00
Joseph Doherty 8b64d1ec9c fix(site-runtime): move synchronous SQLite work off the Akka dispatcher (SRT-5, WP6 task 6.1)
Follows the InstanceActor static-override pattern: the storage call runs in
Task.Run, flushes chain on a persist-tail task so batches stay ordered, and
reads PipeTo(Self).

- NativeAlarmActor: FlushDirtyUpserts runs ApplyNativeAlarmChangesAsync on an
  ordered persist tail; the PreStart rehydration read runs in Task.Run and
  seeds the tail, so no flush can commit before the read.
- InstanceActor: the ungated PreStart override read runs in Task.Run; the
  List-override normalising re-persist joins the static-override persist tail
  (off-dispatcher and ordered behind/before batched flushes).

Evidence (NativeAlarmActorTests.Flush_BlockedOnWriteLock_DoesNotBlockTheActorThread,
another connection holding BEGIN IMMEDIATE for ~1.6 s, busy_timeout 5 s):
  before: the next transition's emit stalled until the lock was released
          (ExpectMsg 500 ms timed out; actor thread parked in the flush)
  after:  next transition emitted while the flush waits; both rows commit
          once the lock is released.
2026-12-03 09:41:03 -05:00
Joseph Doherty f7e4f5b4ed docs(plans): record accepted recommendations for open choices in the code-review remediation plan 2026-12-03 09:35:03 -05:00
Joseph Doherty 28b6651a89 docs(plans): full code review 2026-12-02 (112 findings) + remediation plan
Nine parallel read-only reviewers over every src/ project at d4d5be3b:
9 High, 51 Medium, 52 Low. Remediation grouped into WP1-WP7.
2026-12-02 16:06:45 -05:00
Joseph Doherty d4d5be3b1c docs(claude): note SiteStream proto field 26 display_name (#147) 2026-11-28 09:30:12 -05:00
Joseph Doherty b47002b45e perf(host): cap thread-pool spin (UnfairSemaphoreSpinLimit=10) (#146)
Mirror of mxaccessgw#237 (659bb831). DEV vd03 showed 229k context switches
in ZB.MOM.WW.ScadaBridge.Host at ~240 MxGateway events/s. Akka's default
dispatcher, gRPC/Kestrel and async continuations all run on the .NET thread
pool, so a trickle of small work items makes idle pool workers spin with
Sleep(0) (default limit 70) before parking.

- Host csproj: RuntimeHostConfigurationOption
  System.Threading.ThreadPool.UnfairSemaphoreSpinLimit=10, written into
  ZB.MOM.WW.ScadaBridge.Host.runtimeconfig.json (verified in the publish
  output, which docker/Dockerfile copies into the image).
- RuntimeConfigTests pins the value in the built runtimeconfig.
- Component-Host.md: new "Runtime thread-pool settings" section (what, why,
  override/revert via DOTNET_ThreadPool_UnfairSemaphoreSpinLimit).

Local synthetic trickle bench (macOS, ~185 chains/s): involuntary context
switches 17-28k -> 6-13k, CPU 430-560 -> 200-295 ms per 20 s. The vd03
before/after WPR measurement is pending the next vd03 deploy.
2026-11-28 09:15:20 -05:00
Joseph Doherty d3067ca036 fix(dcl): key OPC UA alarms on ConditionId (#147)
OtOpcUa now exposes conditions imported over gRPC data connections in the
namespace https://zb.com/otopcua/mapped/conditions. Their ConditionId is
an opaque c1. NodeId stable for the life of the connection, but their
SourceName (<anchor>/<placement path>) moves when the primary placement
mapping changes. ScadaBridge keyed every condition on
SourceName.ConditionName, so a mapping change read as one alarm clearing
and a new one raising.

- Event filter selects ConditionId (select clause 19: ConditionType,
  empty browse path, AttributeId = NodeId).
- When the ConditionId (or SourceNode, which OtOpcUa sets to it) is in the
  mapped/conditions namespace, the per-condition key is its durable
  nsu=... string (index-proof across an OtOpcUa pair / upgrade). Every
  other OPC UA condition keeps the SourceName.ConditionName key, so no
  existing persisted row, MES script or operator view is re-keyed.
- The old SourceName.ConditionName text becomes an additive, display-only
  DisplayName: NativeAlarmTransition -> AlarmStateChanged ->
  AlarmStateUpdate.display_name (26) / DebugAlarmStateDto.display_name
  (22) -> ScriptAlarm.DisplayName. Persisted in native_alarm_state
  metadata_json (no column, no CDC trigger change); updates in place on
  every transition under the fixed key. Protos regenerated.
- Alarm Summary and Debug View show DisplayName (key as tooltip) and
  filter on it; site event log writes "label [key]".
- Upgrade: a pre-#147 row for an imported condition is retired by the
  first completed refresh snapshot (one return-to-normal + drop), then the
  condition continues under its ConditionId.

Tests: RealOpcUaImportedConditionKeyTests, OpcUaAlarmMapperTests,
NativeAlarmActorTests (DisplayName, rehydration, legacy-row retirement),
StreamRelayActorTests, SiteCommand golden sample, AlarmsAccessorTests,
DebugTreeBuilderTests; filter select-clause count 19 -> 20.
Docs: Component-DataConnectionLayer/Commons/Communication/SiteRuntime.
2026-11-28 09:14:49 -05:00
Joseph Doherty a117f79ad1 fix(dcl): handle RefreshRequired by issuing ConditionRefresh (#148)
OtOpcUa now emits RefreshRequiredEventType (SourceNode = Server, no
condition fields) on an incomplete condition snapshot, a removed imported
condition, or a resync that leaves pre-failover EventIds answering
BadEventIdUnknown. RealOpcUaClient had no branch for it: the event fell
through HandleAlarmEvent as a phantom condition keyed "Server" and no
refresh was issued, so the mirror could hold stale / un-ackable state.

- HandleAlarmEvent recognises RefreshRequiredEventType, emits nothing, and
  hands the item's handle to the new ConditionRefreshCoalescer.
- The coalescer runs off the SDK publish thread, debounces 500 ms so a
  burst (one event per affected item) costs one refresh, never overlaps
  refreshes (a request during an in-flight refresh is served by the next),
  logs and swallows failures, and is cleared on disconnect.
- Execution: targeted ConditionRefresh2(eventSubscription, item) per asking
  item; one subscription-wide ConditionRefresh when every live alarm item
  asked, an item has no server id, or ConditionRefresh2 fails. The replay is
  the usual RefreshStart/End frame, so NativeAlarmActor's snapshot swap
  clears conditions the refreshed snapshot no longer lists.
- The server-side OfType WhereClause built from a condition filter now ORs
  in OfType(RefreshRequiredEventType): the server queues RefreshRequired
  through the item's filter, so a bare condition-type clause dropped it.

Tests: RealOpcUaRefreshRequiredTests (branch, no-session tolerance, burst
coalescing, no overlap, failure tolerance, Clear, framing intact);
RealOpcUaClientAlarmFilterTests updated for the added operand.
Component-DataConnectionLayer.md documents the behaviour.
2026-11-28 09:03:02 -05:00
Joseph Doherty 8010fee2d2 fix(central-ui): Test Run banner says Notify is simulated; sandbox Send logs it (#151)
The Test Run banner in TemplateScriptDialog and SharedScriptForm claimed
External, Database and Notify all fire for real ("real emails"). Notify
is SandboxNotifyTarget, which returns a random GUID and sends nothing.
The banner now says External/Database are real and Notify is simulated,
pointing at Flow Debugger on a deployed instance for a real send. The
sandbox Send also writes a [sandbox] ... not delivered line to the
console pane. Notify.Status is unchanged (reports Unknown). Tests pin
the banner wording and the console line; Component-CentralUI.md notes
the simulated Notify.
2026-11-28 06:56:21 -05:00
Joseph Doherty 607ffc2e15 fix(template-engine): validate CallShared/CallScript parameters object by name (#150)
The semantic validator treated each comma-separated argument after the
script name as a positional parameter and required the count to equal the
declared ParameterDefinitions. The runtime has no positional form: both
calls take ONE parameters object that ScriptArgs.Normalize turns into a
name -> value dictionary, so every Scripts.CallShared("X", new { ... })
was rejected unless exactly one parameter was declared, blocking deploy.

Call sites are now found with a Roslyn script-mode syntax parse (named
arguments and a trailing CancellationToken handled; calls in comments or
strings ignored). The parameters argument is classified as:
- anonymous object: validated by name (ordinal) - missing required
  parameter = error, undeclared member = warning, clear literal type
  mismatch per member = error (same conservative inference as before);
- any other expression (variable, dictionary, call, null): not checked;
- absent: error only if the target declares required parameters.

Required-ness comes from the shared InboundApiSchema parser (JSON Schema
'required' list; legacy array entries required unless required:false).
Positional-argument tests replaced by by-name CallShared/CallScript tests;
Component-TemplateEngine.md updated.
2026-11-28 06:55:58 -05:00
Joseph Doherty a4523e090e feat(notifications): SMTP delivery policy settable via management/CLI/UI (#149)
SmtpConfiguration.MaxRetries/RetryDelay (and ConnectionTimeoutSeconds/
MaxConcurrentConnections) drive the outbox Email policy but had no write
path, so every row sat at 0/0 and was clamped with a Warning; DEV vd03 had
to be fixed by direct SQL.

- Update/CreateSmtpConfigCommand: four trailing additive nullable fields
  (null = preserve on update / entity default on create; 0 = fallback).
- ManagementActor: preserve-if-null, negatives refused.
- CLI notification smtp create|update: --max-retries, --retry-delay-seconds,
  --connection-timeout-seconds, --max-concurrent-connections (>= 0).
- Central UI /notifications/smtp: fields on the form + read-only panel;
  new rows pre-fill 10 retries / 60 s.
- README + Component-NotificationService; tests for apply/preserve/reject.
2026-11-25 10:54:20 -05:00
Joseph Doherty a87c05754a docs(deploy): PROD CVD reactor content 2026-11-22 (9 instances on site-par, 7 API methods, BTDB, keys)
Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
2026-11-22 12:06:09 -05:00
Joseph Doherty dc87289faf docs(deploy): PROD site-app (id 2) co-located on app-vp03/vp04, MxGateway connection id 2 Connected
Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
2026-11-20 17:43:47 -05:00
Joseph Doherty 3ca968e26b docs(deploy): PROD site-par MxGateway connection re-pointed to the PAR gateways (not installed yet)
Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
2026-11-20 17:23:23 -05:00
Joseph Doherty 530eaf32c1 docs(deploy): PROD cluster config - Site site-par (id 1), mxgw key scadabridge-prod shared vp03/vp04, MxGateway connection id 1 Connected
Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
2026-11-20 16:37:41 -05:00
Joseph Doherty facf24b295 docs(deploy): PROD 2e0ce81e installed on vp03/vp04 (stopped, gated on DB indexes) + site-par pair running on par-vp03/04
Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
2026-11-20 15:39:40 -05:00
Joseph Doherty 9109e4e905 docs(deploy): QA vq03/vq04 on 2e0ce81e (#144/#145) + NAM AD login, one window
Claude-Session: https://claude.ai/code/session_01GT67AD5mc2BnaaAfY3hqqQ
2026-11-19 16:13:55 -05:00
Joseph Doherty 98a8df1f9d deploy(vd03): 2e0ce81e (#144/#145) + NAM AD login on DEV 2026-11-19 15:17:16 -05:00
Joseph Doherty 2e0ce81ea0 Merge branch 'fix/145-management-zero-role': refuse zero-role principals on management/CLI surfaces (#145)
Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:48:03 -05:00
Joseph Doherty a5243b1e87 docs(security): no role, no login now covers the management/CLI surfaces (#145)
Component-Security "No role, no login": replace the "HTTP Basic is not covered
yet" note with the Basic and Bearer behaviour, the throttle and log details;
bearer section notes a role-less token is refused. Component-CLI: a zero-role
user sees the bad-password 401. Component-ManagementService: 401 covers it.
CLAUDE.md Security & Auth bullet updated.

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:45:51 -05:00
Joseph Doherty 1d2170a152 fix(management): refuse zero-role principals on the management/CLI surfaces (#145)
ManagementAuthenticator — the only identity source for POST /management, the
audit REST endpoints and the debug-stream hub — now enforces "no role, no
login" the way #144 does for /auth/login and /auth/token:

- HTTP Basic: a bind whose groups map to zero roles, or whose role mapping
  throws, answers the bad-password 401 AUTH_FAILED body and counts as a
  LoginThrottle failure. RecordSuccess moved after the mapping, so a refusal
  no longer clears earlier failures. Request cancellation still propagates.
- Bearer: a token with no role claim (minted before #144 shipped) gets the
  invalid-token 401; no throttle, as for every bearer failure.
- Each refusal is logged at Warning (category ManagementAuthenticator) with
  the request path, the username and the reason.

Before this, a zero-role Basic caller reached every command that
ManagementActor.GetRequiredRoles opens to any authenticated user.
DisableLogin is unchanged.

Tests: ManagementZeroRoleRefusalTests — zero roles / mapper throws / one role
over Basic and Bearer for /management (ListSites), /api/audit/query and the
debug-stream hub; every null-role command is unreachable by a zero-role
principal; throttle accounting. 47 of the 58 fail against the old
authenticator (the 11 that pass are the one-role/bypass regression guards).

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:45:51 -05:00
Joseph Doherty d48e1667f1 Merge branch 'fix/144-refuse-zero-role-login': refuse zero-role sign-in and sessions (#144)
Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:29:48 -05:00
Joseph Doherty 764e75c32f test(integration): give the live GLAuth auth tests a seeded group mapper (#144)
The integration factory's in-memory configuration database is never seeded, so
it holds no LdapGroupMappings and the live GLAuth users mapped to zero roles.
LoginEndpoint_WithValidLdapCredentials_SetsCookieAndRedirects and
ActiveSession_GroupsAreReReadFromTheDirectory_AndAnUnknownUserIsEnded were
passing only because zero-role sign-in and zero-role sessions were allowed.
They now run against a factory variant whose IGroupRoleMapper mirrors the
seeded mappings (SecurityConfiguration.HasData).

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:27:23 -05:00
Joseph Doherty 2d8d5a3d6f fix(auth): end a cookie session whose roles drop to zero on refresh (#144)
The mid-session refresh ended a session only when the directory returned no
groups (or the user was gone/disabled/ambiguous). A user still in some groups
but in no mapped one, or whose DB mappings were all revoked, kept a signed-in,
role-less session that could read the bare-[Authorize] pages. CookieSessionValidator
now rejects when the re-map yields zero roles, on ordinary and fail-closed paths.
A mapper fault keeps its existing policy (keep grants; fail closed when asked).

Docs: Component-Security "No role, no login" (incl. the HTTP Basic gap left as a
follow-up), Component-CentralUI, CLAUDE.md.

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:21:00 -05:00
Joseph Doherty 5a642d1cdf fix(auth): refuse zero-role sign-in at /auth/login and /auth/token (#144)
A successful LDAP bind whose groups map to no ScadaBridge role, or whose role
mapping throws, is now refused at both sign-in endpoints exactly like a bad
password: the same redirect/401 body, no cookie, no token, and a login-throttle
failure (so the throttle is not an oracle). The reason is logged server-side at
Warning with the endpoint and username. Family standard: scadaproj NAM AD
cutover plan §3.2 (Phase A2, §2A).

Tests: zero roles, mapper throws, and one role for both endpoints, plus the
throttle accounting; RoutePolicyCoverageTests now notes that the two bare
[Authorize] pages rely on this rule.

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-17 11:21:00 -05:00
Joseph Doherty 5bf6d1fa5b Merge branch 'feat/116-leader-auto-down-default': leader-auto-down is the shipped default (#116)
Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 19:57:45 -05:00
Joseph Doherty efade2eab0 feat(cluster)!: leader-auto-down is the shipped default downing strategy (#116)
SplitBrainResolverStrategy now defaults to leader-auto-down (the in-repo
LeaderAutoDowningProvider, #106, with the #132 shut-out restart on). auto-down and
keep-oldest stay supported. Drilled on the docker rig, docker-env2 and the QA pair
(central + site, kill and stop-and-hold) before the flip.

- ClusterOptions default + validator/HOCON comments updated.
- Shipped Host appsettings.Central/Site.json and every docker/ and docker-env2/
  node appsettings now say leader-auto-down. The leader-auto-down overlays are
  kept as no-ops (drill records reference them); new docker-compose.auto-down.yml
  overlays keep Akka AutoDowning available for comparison drills.
- Tests: default asserts leader-auto-down; new HOCON test for an unset strategy;
  TwoNodeClusterFixture defaults to the production posture.
- Docs: CLAUDE.md, Component-ClusterInfrastructure, components/Host + Cluster,
  README, failover procedures, Traefik, docker + env2 READMEs; register row 70 closed.

No deploy needed: DEV, QA and both rigs set the key explicitly.

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 19:57:45 -05:00
Joseph Doherty 1213a74353 deploy(#116): DEV vd03 central + site on leader-auto-down (config only)
One key per file: ScadaBridge:Cluster:SplitBrainResolverStrategy auto-down ->
leader-auto-down in appsettings.Central.json and appsettings.Site.json, build
061432c8 unchanged. G6 boot lines on both services, health 200, MxGateway and
Z28062 at baseline, bogus key 401, Overview 6/6 Up. Downtime ~23 s central,
~30 s site. No drill: single-node clusters.

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 19:46:47 -05:00
Joseph Doherty 50a5291b64 deploy(#143): DEV vd03 + QA vq03/vq04 to 061432c8 — hash chain removed (migration 65), #116 QA site-pair drills
DEV: ~48 s site / ~29 s central outage; QA: pair stop/start, ~2m40s site / ~1m37s central.
Chain schema + chainer role gone, env key removed, all gates pass on both tiers.
#116 QA site drills (all reactors idle): kill → takeover +7.7 s; stop-and-hold →
[leader-auto-down] DOWNING +27.2 s, takeover +27.4 s, recovery restored byte-identical.

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 19:36:04 -05:00
Joseph Doherty 061432c8c4 deploy(#52/#142): Z28061 redeployed on QA (idle, verified); DEV skipped — idle attributes Bad quality
Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 18:08:30 -05:00
Joseph Doherty 997e36a2bc deploy(#116): QA stop-and-hold drill proves the leader-auto-down timer path
vq04 (active central) killed with SCM auto-restart disabled and held down 94 s:
UNREACHABLE +11.4 s, [leader-auto-down] DOWNING +26.4 s, survivor vq03 active
+26.7 s. Recovery config restored byte-identical before Start-Service; vq04 rejoined
as standby in ~4.7 s with no exit-75. Also corrects the earlier Drill A 'sampler gap'
(an awk keying error; vq04 was ready at +20.8 s).

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 18:02:21 -05:00
Joseph Doherty cae5ab958c deploy(#116): QA central kill drill (G14 central) — takeover ~10 s via new-incarnation path
Both centrals killed in turn (Stop-Process on the service PID). SCM restart in ~5 s;
the survivor downed the old incarnation at ~+9-10 s and took the active role; the
victim rejoined as standby at ~+21 s. leader-auto-down stood aside (already Down),
so its 15 s timer path was not exercised on QA. Site-pair drill still pending
(Z28061 slot, #142).

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 17:53:09 -05:00
Joseph Doherty 3dea146c03 Merge branch 'chore/remove-audit-hash-chain': remove the AuditLog hash chain and two-login hardening (IT security, 2026-11-15)
Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 17:51:07 -05:00
Joseph Doherty b418408c0f docs(audit): record the removal of the hash chain and the two-login hardening
Component-AuditLog (Security & Tamper-Evidence now a removal note, archive format v2, config),
Component-CLI, Component-ManagementService, HighLevelReqs AL-11/AL-12, docs/components/CLI, the CLI
README, alog.md §11.4/§15 and CLAUDE.md. New production script docs/plans/sql/RemoveAuditLogHashChain.sql
(idempotent, from migration 64); AddAuditLogHashChain.sql marked superseded. Historical plans,
deployment records and deploy-prep packs are left as written.

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 17:38:22 -05:00
Joseph Doherty ed2ed0a367 feat(audit)!: remove the AuditLog hash chain, head export and two-login maintenance hardening
Owner decision 2026-11-15, at IT security's request, pending a family-wide general solution.

Removed: the chaining service, hasher, verifier, chain head/tombstone entities and store, the #139
chain-start cutoff, AuditLog:HashChain (incl. ChainBacklog and HeadExport with its File/Syslog sinks
and export service), the audit-chain-head-export health check, the VerifyAuditChain /
VerifyAuditChainHeads management commands and the `audit verify-chain` / `audit verify-heads` CLI
commands, and the two-login plumbing (AuditLog:MaintenanceConnectionString, AuditMaintenanceContext,
the keyed audit-maintenance repository/archive). Purge, archive, retention, partition roll-forward
and backfill-source-node all run on the runtime connection again, as before #107.

Parquet archive (#42) kept, chain-free: format v2 (ten stored columns, no tombstone file, manifest
without chain state), the switch guard is the row count only (51003 gone), verify = data-file size,
SHA-256 and row count, and superseded-stale cleanup proves coverage by EventId. Format-v1 archives
still list, verify and are cleaned up (their tombstone file too).

Migration RemoveAuditLogHashChain drops the chain indexes, the scadabridge_audit_chainer role
(members first), both chain tables, ChainSeq/RowHash and the purger's AuditMaintenanceGrants grants;
writer/purger roles stay. Down restores them. Every chain-column reference is EXEC-deferred for the
idempotent script (#126); FlipAuditLogClusteredKey's two chain index statements get the same
deferral, behaviour unchanged, so re-running the idempotent script on a migrated database works.
The partition-switch staging table adds the chain columns only when the live table has them, so the
new binary purges either schema. Deploy gate: old binaries map the chain columns, so the migration
ships with the new binaries, both centrals stopped.

A leftover AuditLog:HashChain section or MaintenanceConnectionString (DEV/QA still carry
AuditLog__HashChain__Enabled=true) is ignored with one startup warning (RetiredAuditSettingsWarning).

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 17:38:22 -05:00
Joseph Doherty 125db03232 deploy(#52): DelmiaReceiver child-name fix applied on DEV + QA (Z28061 excluded)
CvdReactor.ProcessRecipeDownload now addresses Children["DelmiaReceiver"] on DEV vd03
and QA vq03/vq04. Redeployed DEV Z28062 + Z28061Sim, QA Z28062-Z28069; Z28061 left
stale on both tiers (shared with another team, no slot agreed). Traced read-only call
on Z28062 (ReadyFlag False): the pre-fix 'DelmiaRecv.ReadyFlag not found' warning is
gone after the fix.

apply.sh: every CLI call passes --url/--username/--password explicitly (an env-only
SCADABRIDGE_URL silently reached DEV), plus SB_EXPECT (refuse unless the expected
instances exist = tier proof) and SB_SKIP (never deploy the listed instances).

Record: docs/deployment/deployment-records/2026-11-15-gate-52-delmiareceiver-fix.md

Claude-Session: https://claude.ai/code/session_01GT67AFKC45MBz1wPZnVbX8
2026-11-15 17:25:37 -05:00
Joseph Doherty 6489c9fc0f Guard dialog completion by presentation identity 2026-11-13 21:25:42 -05:00
Joseph Doherty d370dbd37c fix(ui): preserve precise audit submissions and adopt delivered secrets 2026-11-13 19:42:53 -05:00
Joseph Doherty 9dbfe7bcaf refactor(ui): prioritize permitted operational views and touch topology 2026-11-13 19:24:12 -05:00
Joseph Doherty 0c41b613ac refactor(ui): unify semantic presentation and table hierarchy 2026-11-13 19:06:18 -05:00
Joseph Doherty 2d30323ae8 Validate audit windows and isolate dashboard count reads 2026-11-13 18:23:12 -05:00
Joseph Doherty 102cbb2e90 Correct raw JSON accessibility regression fixture premise 2026-11-13 18:00:12 -05:00
Joseph Doherty 915a8a5914 Associate ScadaBridge controls, guidance and editor errors 2026-11-13 17:59:00 -05:00
Joseph Doherty 20885b6161 Adopt published Theme 1.0.1 reflow patch 2026-11-13 17:42:14 -05:00
Joseph Doherty 87c882ec0a Name dialogs and contain native overlay keyboard focus 2026-11-13 17:42:14 -05:00
Joseph Doherty cdd3adf6fc Adopt Theme 1.0.0 with supported dark palette 2026-11-13 16:12:40 -05:00