Files
cleveragents-core/features/tdd_di_audit_cache_failure.feature
T
brent.edwards a0c6ecd3ad
CI / typecheck (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / unit_tests (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
CI / security (push) Has been cancelled
CI / quality (push) Has been cancelled
CI / status-check (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
CI / build (push) Has been cancelled
CI / docker (push) Has been cancelled
CI / helm (push) Has been cancelled
fix(di): get_container() permanently caches failed audit subscriber in Singleton provider
Introduced a module-level flag _audit_subscriber_initialized to track
whether audit_event_subscriber() has been successfully called.  When
get_container() is invoked and the flag is False, the subscriber
initialization is reattempted regardless of whether _container already
exists.  On success the flag is set to True so no further attempts
are made; on failure the warning is logged and the flag remains False
so the next get_container() call retries.

Previously, a failed audit subscriber init during the first
get_container() call was permanently cached: _container was set but
the subscriber was never retried.  In CLI mode this is masked because
each invocation is a new process, but in long-lived server processes
the audit subscriber would remain unregistered for the process
lifetime.

Also brings in the TDD regression test from issue #1096 (branch
tdd/m6-di-audit-cache-failure) with the @tdd_expected_fail tag
removed, converting it to a normal passing regression guard.  Added
an ASV benchmark measuring retry-path performance.

ISSUES CLOSED: #992

Reviewed-by: reviewer-pool-1
Closes #992

Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-04-02 16:51:29 +00:00

21 lines
1.2 KiB
Gherkin

@tdd_issue @tdd_issue_992
Feature: TDD Bug #992 — get_container() caches failed audit subscriber initialization
As a long-lived process using the shared DI container
I want get_container() to retry audit subscriber initialization after an initial failure
So that audit subscriptions are eventually registered once prerequisites become available
This feature captures bug #992. Previously, get_container() eagerly called
audit_event_subscriber() only during first container creation. If that first call
failed, the exception was logged and swallowed, but the global _container remained set.
Subsequent get_container() calls returned the cached container without retrying the
subscriber initialization.
Originally tagged @tdd_expected_fail while the bug was unfixed (see TDD issue
#1096). The @tdd_expected_fail tag was removed when the fix for #992 was
implemented so this now runs as a normal regression test.
Scenario: Bug #992 — get_container retries audit subscriber initialization after first failure
Given g992- a container whose audit subscriber init fails once then succeeds
When g992- I call get_container twice
Then g992- audit subscriber init should have been attempted twice