- Fixed a TOCTOU race in `AuthorityFrontierService.seed_from_wanted_authorities` (`opencontractserver/enrichment/services/authority_frontier_service.py`): the per-key create-or-refresh now runs inside a single `transaction.atomic()` + `select_for_update()` critical section instead of `get_or_create` followed by an unconditional `save`. Two concurrent seed passes could previously both clear `get_or_create` and have one silently clobber the other's count update, and a freshly created row was briefly visible at `mention_count=0` (the field default) between the insert and its follow-up save. The lock serialises the second writer and seeds the real counts atomically. The "prefer existing non-null" semantics for `jurisdiction`/`authority_type` are preserved (issue #2020 finding 1).
- Fixed stale `last_error` on a successful retry in `AuthorityFrontierService.mark()` (same file): a row transitioning `failed (error=...) -> ingested` previously retained the old error string, so downstream health checks reading `last_error` misread a healthy row as broken. `mark()` now clears `last_error` implicitly when transitioning into a terminal success state (`enrichment.constants.DISCOVERY_SUCCESS_STATES`, i.e. `ingested`); the failure history is still preserved in the append-only `candidate_sources` audit trail (issue #2020 finding 2).
- Fixed a double XML traversal in `CFRAuthoritySourceProvider._fetch_impl` (`opencontractserver/pipeline/authority_source_providers/cfr_provider.py`): the `<P>` flatten list comprehension called `_flatten_element_text(p_el)` twice per element (once for the value, once for the truthiness filter). A walrus binds the result once so each `<P>` is traversed a single time (issue #2020 finding 5).
- Added regression tests in `opencontractserver/tests/test_authority_frontier.py`: the seed upsert takes a `SELECT ... FOR UPDATE` row lock, a `failed -> ingested` transition clears the stale error (while a non-success transition preserves it), and `dequeue_for_provider` excludes freshly-seeded `provider=None` rows (issue #2020 findings 11, 12).
