fix(secrets): UI reports a committed change as saved when its audit throws (scadaproj#34)

SecretEditor and ConfirmDeleteModal wrote the success audit inside the same
try as the store write, so a throwing IAuditWriter after a committed
add/rotate/delete showed an error, wrote a Failure audit and skipped the
resolver-cache eviction - the old plaintext kept resolving for the TTL.

The mutation try now covers only the cipher + store call; the success audit
is best-effort afterwards and logs a warning (no value) on failure, so the
change is reported saved, the callback fires and the cache is evicted.

- tests: AuditFailureAfterCommitTests (add, rotate, delete) with a throwing
  success audit; all fail without the fix
- code-reviews: Secrets-013 Resolved; README regenerated

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 14:56:14 -05:00
parent 6112a9f447
commit e1487fbf10
8 changed files with 215 additions and 35 deletions
+7
View File
@@ -43,6 +43,13 @@ Fixes six scadaproj#15 code-review findings (`code-reviews/Secrets/findings.md`)
`StartAsync` when no lifetime is registered. Behaviour change: the application's `ActorSystem` must be
resolvable once the host has started even if no secret is ever touched; a failure there is logged.
OtOpcUa's own `SecretReplicationStarter` becomes redundant (harmless — same actor).
- **UI: a committed add/rotate/delete is no longer reported as failed when its audit write throws**
(scadaproj#34, Secrets-013). `SecretEditor` and `ConfirmDeleteModal` wrote the success audit inside the
store write's `try`, so a throwing `IAuditWriter` produced an error message, a `Failure` audit row and no
cache eviction for a change that had committed. The success audit is now best-effort after the commit:
the change is reported saved, `OnSaved`/`OnDeleted` fire, the resolver cache is evicted, and the audit
failure is logged as a warning (`ILogger<SecretEditor>` / `ILogger<ConfirmDeleteModal>`, when the host
registers logging).
## 0.6.5 — unreleased (NOT published to the feed)