fix(di): @bean(primary) for shared return type + @lazy init pipeline (v26.06.32)#59
Merged
Merged
Conversation
… full init pipeline + bump v26.06.32 Two regressions found by the final parity audit: - @bean(primary=True): the direct return-type registration was created only for the first @bean method and never updated, so resolve(Interface) returned a non-primary impl. A later @bean(primary=True) for the same return type now overwrites the direct registration. - @lazy beans skipped @post_construct + BeanPostProcessors + AOP weaving (built post-startup via _create_instance, never run through the init passes). The container now calls a post-create hook (installed by ApplicationContext after startup) that runs BeanPostProcessors + @post_construct on lazily-created singletons; async @post_construct on lazy beans warns. Tests: tests/container/test_di_audit_regressions.py (3). Gates: mypy --strict (614), ruff + format, full suite 3790 passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two regressions surfaced by the final Spring-parity audit (both in features shipped this session):
@bean(primary=True)ignored across multiple@beanof one return type — the single-bean direct return-type registration kept the first-processed impl; a later@bean(primary=True)now overwrites it soctx.get_bean(Interface)returns the primary. (Class-level@primarywas already correct; the Protocol-return test passed but an ABC/concrete interface failed — now both covered.)@lazybeans skipped the init pipeline — a lazily-created singleton got ctor + field injection only, never@post_construct/ BeanPostProcessors / AOP weaving (verified: aspects didn't fire on lazy beans). The container now runs a post-create hook (installed byApplicationContextafter startup) over lazily-created singletons. Async@post_constructon a lazy bean is unsupported in the sync path and warns.Tests
tests/container/test_di_audit_regressions.py(3):@bean(primary)wins for a shared ABC return type;@lazyruns@post_construct;@lazyruns BeanPostProcessors (the AOP-weaving path).Gates
mypy --strict(614) ✓ ·ruff+ruff format✓ · full suite 3790 passed.Wave A of the audit fixes. Next: FastAPI serialization wiring, @transactional CancelledError commit + read_only, Kafka per-message isolation.