# SEC-01 — editor target and pending-operation isolation Implemented in managed worktree `codex/scada-ui-consistency` on 2026-11-13. This task depends on accepted GB only. Theme adoption, package versions, dialogs, filtering and host integration remain for SEC-02 onward after explicit G1 acceptance. ## Scope and behavior Changed only the two editor/list components and three named UI test/fake files from the plan. `SecretEditor` now owns an identity consisting of Add mode or the exact Rotate name. An identity change resets draft, errors, restore confirmation and load state, cancels its prior metadata read and rejects stale responses by generation (including A→B→A). Same-identity rerenders preserve drafts and save errors. Metadata-load failure blocks submit and explains reopening for retry. Submission captures target, mode, draft, authentication task, callbacks and lifetime token before any await. Optional cache invalidator and logger are resolved before mutation waits; completion does not resolve through an already-disposed circuit provider. A target change during authorization prevents the old draft from being written. Once an upsert commits, best-effort audit and cache invalidation retain the captured target; superseded/disposed editors suppress obsolete saved callbacks. No backend/storage, authorization policy, encryption or plaintext handling contract changes. Audit remains metadata-only. Both original mutation-success/audit-failure and fail-closed reveal tests remain passing. `SecretsList` keys editor instances by mode/name, keeps a generation for callbacks, preserves the same row draft and ignores stale saved/busy callbacks. While a submission is pending, Add/Rotate/Delete target switching and editor Cancel are blocked with non-sensitive pending text. Existing Theme 0.2.0 `Busy` is used to obtain an actually disabled button; the new Theme disabled/busy API and visual refinements are deferred to SEC-02. No current Theme pin changes are included. ## State checks | Transition | Verified outcome | |---|---| | Rotate A → Rotate B / Add | Clear old value, description/type/error and restore confirmation; load current metadata only | | Same target rerender | Preserve unsaved text and failed-save error | | Slow metadata A → B → A | Cancel obsolete token; ignore late old generation even when name repeats | | Pending authorization + target change | No upsert under either target | | Pending upsert | Disabled Cancel and parent target controls; no duplicate upsert | | Forced target change during upsert | Captured rotate target/action, matching cache invalidation; no obsolete saved callback | | Component removed after commit, audit pending | Success audit remains captured; matching cache invalidation; no saved callback | | Old parent saved/busy callback | Cannot close/unlock a newer editor | ## Verification Working directory: `ZB.MOM.WW.Secrets` inside the managed worktree. ```sh dotnet test tests/ZB.MOM.WW.Secrets.Ui.Tests/ZB.MOM.WW.Secrets.Ui.Tests.csproj -c Release --logger 'trx;LogFileName=SEC01-before.trx' --results-directory ../components/ui-theme/validation/secrets-ui dotnet test tests/ZB.MOM.WW.Secrets.Ui.Tests/ZB.MOM.WW.Secrets.Ui.Tests.csproj -c Release --filter 'FullyQualifiedName~SecretEditor|FullyQualifiedName~SecretsList|FullyQualifiedName~AuditFailureAfterCommit' --logger 'trx;LogFileName=SEC01-red.trx' --results-directory ../components/ui-theme/validation/secrets-ui dotnet test tests/ZB.MOM.WW.Secrets.Ui.Tests/ZB.MOM.WW.Secrets.Ui.Tests.csproj -c Release --logger 'trx;LogFileName=SEC01-after.trx' --results-directory ../components/ui-theme/validation/secrets-ui ``` - Before production changes: **34 passed, 0 failed, 0 skipped** (`SEC01-before.trx`). - Initial added regressions against original components: **10 failed / 10 passed** (`SEC01-red.trx`, `SEC01-red.log`), demonstrating draft leakage, stale metadata/callbacks, missing pending locks, and rotate incorrectly audited as Add after a target change. - Focused implementation check: **27 passed, 0 failed** (`SEC01-focused.trx`, `SEC01-focused.log`). - Final full UI suite: **50 passed, 0 failed, 0 skipped** (`SEC01-after.trx`, `SEC01-after.log`). All 34 baseline test identities and passing outcomes preserved; 16 meaningful regression tests added. Two supplementary render fixtures initially failed (parameter conversion and actual unmount setup); corrected without weakening assertions; final artifacts contain the passing run. - Independent source review identified late service resolution after commit. Added a provider-wrapper regression with an explicit invocation assertion and a success-audit fault. Restoring late cache/logger resolution reproduces missing eviction: **1 failed** (`SEC01-lifetime-red.trx`, `.log`). Captured services pass in the final full suite. bUnit’s built-in IServiceProvider ignores a normal service registration, so this fixture explicitly replaces only the editor’s private injected provider after rendering; it does not change the public API. The initial ineffective wrapper registration was corrected before acceptance. - `git diff --check -- ZB.MOM.WW.Secrets`: passed. All delayed operations use synthetic fixtures and TaskCompletionSource control, without sleeping or production connections. No deployment or real-secret activity. No browser/host verification claimed in this state-only task; actual keyboard/focus, responsive and two-host checks remain mandatory in later tasks. List refresh failure recovery and delete/reveal lifetime improvements remain their planned follow-up tasks. ## Rollback and review Rollback the five SEC-01 source/test files together; there are no schema or package changes. Keep the regression evidence to show why rollback restores the old defect. Review checkpoint precedes an explicit-path commit; do not include another worker’s staged changes.