3413 Commits

Author SHA1 Message Date
Joseph Doherty cbdd9fc40b fix(transport): template Overwrite clears compositions and cascades removed slots' derived templates (TRN-4, TRN-5, WP2 task 2.6)
TRN-4: the composition rewire skipped any bundle template with zero
compositions before the clear ran, so an Overwrite never removed the target's
slots although the preview reported the removals. It now skips only an
Add/Rename (nothing to clear).

TRN-5: a slot the bundle removes is deleted through
TemplateService.DeleteCompositionAsync, which cascades the slot-owned derived
template (no DB relationship on OwnerCompositionId, so the row-only delete
orphaned it and blocked deleting its base). A slot the bundle re-composes keeps
the row-only delete so a pre-#118 bundle that re-composes the slot onto its
derived template by name still resolves. Tests run the real importer against
an EF context and fail on the previous importer.
2026-12-03 09:55:53 -05:00
Joseph Doherty 5f7b850af2 fix(outbox): persist a delivery outcome on its own token, not the shutdown token (NTF-1, WP4 task 4.5) 2026-12-03 09:54:37 -05:00
Joseph Doherty 2e8bede3b2 fix(dcl): retry failed alarm re-subscribes, check alarm item create status, retry connection-level re-subscribe rows (DCL-2, DCL-3, DCL-8, WP3 task 3.2) 2026-12-03 09:53:44 -05:00
Joseph Doherty 2969ee44e5 fix(centralui): no-tracking default on the circuit DbContext; mutations on their own scope (UI-1, WP5 task 5.1)
The circuit-lifetime ScadaBridgeDbContext tracked every entity a page ever
loaded, so a reload returned the first-loaded instance and never saw changes
made in another scope (Move to Site, Topology area renames, a template script
edited by the CLI/import - which a later save then silently reverted).

- CircuitDbContextTrackingHandler (CircuitHandler, registered by AddCentralUI)
  sets QueryTrackingBehavior.NoTracking on the circuit scope's context only,
  when the circuit host is built (before any component). Management-actor,
  command-transaction, HTTP-request and hosted-service scopes keep TrackAll.
- Every remaining page mutation that ran a load-modify-save service on the
  circuit context now runs it via ScopeFactory.InNewScopeAsync (fresh tracking
  context): TemplateEdit (17 TemplateService calls), Templates (5 TemplateService
  + 5 TemplateFolderService), TemplateCreate, SharedScripts, SharedScriptForm,
  TransportImport.ApplyAsync. (Sites/Topology moved in 5.2.)
- Design doc: Component-CentralUI.md 'Circuit DbContext lifetime'.

Tests: CircuitDbContextTrackingTests - handler scoping + registration, the three
finding scenarios against a real SQLite context (moved connection also asserts
the pre-fix staleness without the handler), and a source-scan guard that fails
on any mutating call through a circuit-injected load-modify-save service.
2026-12-03 09:52:56 -05:00
Joseph Doherty f02fe9d696 fix(comm): key site liveness on central receive time; gRPC connect timeout + connect-phase deadline failover (COMM-4, COMM-5, WP4 task 4.4) 2026-12-03 09:52:54 -05:00
Joseph Doherty fe60c4a1dc fix(template-engine): resolve alarm on-trigger scripts by name per composition chain (TPL-1, TPL-2, TPL-5, WP2 tasks 2.2+2.3)
Alarm -> on-trigger script links went through one flatten-wide
'TemplateScript.Id -> canonical name' map. Slot-derived templates hold only
IsInherited placeholders, so every slot of a module composed twice resolved to
the base script row id and the LAST slot's canonical name won: pump 1's alarm
ran pump 2's script in pump 2's scope (TPL-1). A derived script override has a
different row id, so the base alarm's link resolved to null (TPL-2). And the
base pass over a nested slot overwrote a slot-level on-trigger override (TPL-5).

ResolveInheritedAlarms now looks the id up among the script rows of the
alarm's own chain, takes the row's NAME and path-qualifies it with the alarm's
prefix, carrying it on the ResolvedAlarm, so only the pass that actually adds
the alarm decides it. An id outside the alarm's chain keeps the old flatten-wide
fallback; a name with no resolved script is still nulled.

BY DESIGN this changes the revision hash of multi-slot compositions (and of
derived templates that override an alarm's on-trigger script, and nested slot
overrides): affected instances read Out of date once and redeploy with the
corrected on-trigger script.
2026-12-03 09:51:00 -05:00
Joseph Doherty 6adfc9f449 fix(dcl): seeds never overwrite a newer live value; Good on reconnect resets only the subscribe backoff (DCL-1, SRT-6, WP3 tasks 3.1 + 3.8)
3.1: seed values are flagged on TagValueReceived; a reconnect/resolution
re-seed for a tag that already delivered a live value in the current
adapter generation is dropped, an initial-subscribe seed is replaced by the
latest live value (a joining instance may have missed earlier live values).
3.8: the connection actor tells subscribers ConnectionQualityChanged(Good)
on re-entering Connected; InstanceActor's Good branch only resets the
Lever-1 backoff and no longer stamps bound attributes Good.
2026-12-03 09:49:57 -05:00
Joseph Doherty f7d3c69071 fix(inbound,security): bound the sync prefix of inbound scripts by the method timeout; persist a role refresh done on a passive request (INB-1, SEC-1, WP7 task 7.6) 2026-12-03 09:49:51 -05:00
Joseph Doherty 76c50a29c2 fix(commons): flow fold ranks lifecycle before time, schema required/legacy-type checks, CSV trailing comma, case-insensitive audit enum parse (CMN-6,7,8,9,12, WP7 task 7.5) 2026-12-03 09:48:24 -05:00
Joseph Doherty 61c6278bd0 fix(cli): site/data-connection/api-method update are preserve-if-null partial updates (CLI-2, WP2 task 2.8)
Decision 2.8: preserve-if-null on the server. UpdateSiteCommand,
UpdateDataConnectionCommand and UpdateApiMethodCommand fields (except the id)
are now nullable; the ManagementActor handlers apply only non-null values and
treat an empty string as 'clear this optional field'. The CLI update commands
no longer require --name/--protocol/--script and drop the --failover-retry-count
(3) and --timeout (30) defaults, so an omitted option travels as null instead of
overwriting the stored value (site update --name used to null both gRPC
addresses). The site gRPC-address validation now runs on the merged values.

Additive/compatible: the fields only became nullable, so an older CLI that
always sends every field still deserializes (pinned by a test) and now simply
updates every field as before. The Central UI full-entity forms send "" for a
field the operator cleared (description/addresses, removed backup endpoint,
cleared parameter/return definitions) so clearing keeps working.
2026-12-03 09:48:00 -05:00
Joseph Doherty 2e194f4eac fix(centralui): run long/concurrent page actions in their own DI scope (UI-2, UI-3, UI-8, WP5 task 5.2)
- Deployments: every LoadDataAsync flight reads through its own scope, so
  overlapping flights (push reload, debounce, page/tile click) no longer
  collide on the circuit DbContext; the generation guard still orders results.
- Sites: Deploy Artifacts (per site and to all sites) resolves
  ArtifactDeploymentService from a fresh scope, so the post-fan-out record,
  audit rows and revision stamp neither share the circuit context nor die
  with the circuit.
- Topology: Diff and Enable/Disable/Delete resolve DeploymentService from
  their own scope (like Deploy/Deploy all), so they cannot overlap the 15 s
  live tick; drops the unused AreaService/InstanceService injections.
- New ScopedServiceExtensions.InNewScopeAsync helper.

Tests: DeploymentsPerFlightScopeTests, SitesPageTests
DeployToAllSites_RunsInItsOwnScope_DisposedAfterTheAction, TopologyPageTests
UI8_InstanceActions_RunOnTheirOwnScope (all fail on the pre-fix pages).
2026-12-03 09:47:43 -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 c1db7094eb fix(comm): fold post-snapshot debug events into the snapshot and fail fast on a snapshot-request failure (COMM-3, COMM-7, WP4 task 4.3) 2026-12-03 09:47:29 -05:00
Joseph Doherty 5469ece012 fix(script-analysis): key the trust verdict cache on every verdict input (CMN-5, WP1 task 1.3)
TrustVerdictCache keyed on the code hash alone while the verdict also
depends on the analysis reference set (and its degraded-fallback mode).
The key is now (code SHA-256, degraded flag, base-reference fingerprint,
extra-reference digest), length-prefixed. File-backed extra references
are digested (path/size/mtime/kind/aliases/embed) so the Central UI run
gate's calls are cached under their own key; an extra reference with no
stable identity stays uncacheable.

The old extras test passed a PortableExecutableReference[] positionally,
which binds to the explicit-base overload, so it never exercised the
extras path; the tests now use the named argument.
2026-12-03 09:46:32 -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 517f093ce9 fix(deployment): take the operation lock before validating the state transition (DEP-2, WP7 task 7.4)
Deploy/Disable/Enable/Delete now acquire the per-instance lock first, then reload the instance
(new IDeploymentManagerRepository.ReloadInstanceAsync) and validate on the fresh state, so a
Delete queued behind a deploy no longer takes the NotDeployed shortcut and orphans the running instance.
2026-12-03 09:45:24 -05:00
Joseph Doherty a9549fbc6e fix(script-analysis): forbid System.AppDomain in scripts (CMN-2, WP1 task 1.2)
AppDomain's assembly-loading members (ExecuteAssembly[ByName], Load,
CreateInstanceFrom[AndUnwrap], CreateInstanceAndUnwrap) were neither a
forbidden scope nor exact gateway names, so a script could load and run
an external assembly (even from a UNC path) in the host process. The
whole type is now a forbidden scope, like System.Environment and
System.GC. AppContext/Debugger were considered and left alone (no
assembly-load surface).

Tests: every AppDomain loading spelling (member access, ?., using static,
alias) is flagged; the ban is exact-type.
2026-12-03 09:44:42 -05:00
Joseph Doherty 8a4b466a03 fix(comm): site stream server refuses/ends subscriptions on a non-active node with Unavailable (COMM-2, WP4 task 4.2) 2026-12-03 09:44:08 -05:00
Joseph Doherty 29192eeb44 fix(script-analysis): inspect ?. member bindings and CreateDelegate in the trust gate (CMN-1, WP1 task 1.1)
The reflection-gateway check ran only in VisitMemberAccessExpression, so
recv?.GetMethod(...) (a MemberBindingExpression) was never inspected and
Delegate.CreateDelegate turned the MethodInfo into a callable delegate:
one character defeated the trust gate on all four call sites.

- HardeningWalker gains VisitMemberBindingExpression with the same check.
- CreateDelegate joins ReflectionGatewayMembers.
- Pass 1 also flags a gateway-named framework member reached as a bare
  identifier (using static System.Delegate / System.Type).

Tests: the review's probe script (compiles clean, now rejected, also on
the minimal fallback set), the ?. variant of every .-form rejection test,
every gateway member via ?., and legitimate ?. use stays clean.
2026-12-03 09:43:55 -05:00
Joseph Doherty 47a7c0dde4 fix(cli): exit 1 on success:false, atomic bundle export, invariant parsing, export timeout, re-subscribe retry (CLI-1,3,4,5,6,7, WP7 tasks 7.1-7.3)
- cached-call retry|discard and data-connection certs list|trust|remove exit 1 when the relayed record carries success:false
- bundle export probes the output path first, writes a temp file, compares the byte count, then moves it into place
- bodyless / textless HTTP errors report 'HTTP <status> <reason>'; bad --trigger-config, sms update, unreadable bundle file and out-of-range --since give the JSON error envelope
- numeric alarm setpoint options and --from/--to date options parse with the invariant culture (de-DE test); offset-less dates are UTC
- audit export gets --timeout-seconds (default 600) for both the headers wait and the mid-stream idle deadline
- debug stream retries a failed re-subscribe and exits 1 with SUBSCRIBE_FAILED if it cannot recover
2026-12-03 09:43:10 -05:00
Joseph Doherty 1aa8710e72 fix(sf): per-lane due-ness keeps per-target FIFO; post-delivery storage error is not a delivery failure (SF-1, SF-2, WP3 task 3.5) 2026-12-03 09:43:05 -05:00
Joseph Doherty c207809ef3 fix(transport): range-check the manifest KDF iteration count before deriving the key (TRN-10, WP2 task 2.7)
BundleSecretEncryptor.Decrypt now refuses an iteration count outside
[MinPbkdf2Iterations, MaxPbkdf2Iterations] before PBKDF2 runs. The manifest
JSON path was already guarded by the EncryptionMetadata constructor (pinned by
a new test), but a record 'with' (or any non-ctor path) bypassed it and
derived with int.MaxValue iterations; the encryptor no longer relies on it.
2026-12-03 09:43:00 -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 34527374ec fix(health): wall-clock-anchored report sequence, nack stale reports, drain standby counters (COMM-1, COMM-6, WP4 task 4.1) 2026-12-03 09:40:50 -05:00
Joseph Doherty 405ca6367e fix(commons): codec handles non-finite list floats, ISO-8601 UTC scalar DateTime, JSON null converts to null (CMN-3, CMN-4, CMN-10, WP3 task 3.11)
Wire stays compatible: the scalar DateTime is a string either way and every
reader parses with RoundtripKind/invariant, which still accepts the old
invariant general form.
2026-12-03 09:39:36 -05:00
Joseph Doherty f42c17d2ce fix(transport): notification-list Overwrite replaces recipients instead of appending (TRN-1, WP2 task 2.1)
GetListByNameAsync now eager-loads Recipients, so the importer's Overwrite
Clear() removes the target's rows before the bundle's are re-added. Fixed in
the repository method (decision 2.1) so every caller gets the recipients.
Regression: target {A,B} + bundle {A,C} -> {A,C}, stable on re-import.
2026-12-03 09:38:41 -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