feat(container): truthful container with one validated write path (V8 S2) - #507
Merged
Merged
Conversation
Empty, duplicate and reserved names raise e.ValidationError through one private write path over a single registrations mapping; reserved core names live in c.CONTAINER_RESERVED_NAMES. shared(auto_register_factories) raises when the caller module cannot be resolved, and scanned factories pass the validated factory record. The string-only dependency_injector bridge (provide, wire, the _di_* state and FlextRuntime.DependencyIntegration) is removed after a fleet-wide zero-use proof, and SkipValidation leaves the container registration models. scope() binds its own core services and keeps LOGGER internal. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…n fixed point A class passed as a service value is recorded as a service, never mistaken for a ready registration; the type-mismatch path returns the typed failure without a cast. Examples and the architecture overview follow the truthful container. make mod removed test-suite __all__ declarations (ban-test-suite-module-all) and make gen reprojected the test inits. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts: # tests/unit/__init__.py # uv.lock
…ice record A class object is never an instance of the ServiceRegistration model, so the extra isinstance(value, type) branch changed no behavior and broke mypy's narrowing (return-value: ServiceRegistration | type[object]). Caught by the local pre-push gate. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
t.RegisterableService admits type[object], and mypy keeps type[object] after isinstance(value, ServiceRegistration) because a class may be an instance through its metaclass. Excluding classes in the same condition keeps one construction path and gives mypy the exact narrowing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
_service_record, _factory_record and _resource_record only built Pydantic models and accepted either a raw value or a prebuilt record (m.X | t.Y) sorted out by isinstance. The bootstrap spec now declares raw values only (t.RegisterableService, t.FactoryCallable, t.ResourceCallable), the container builds each record with the model itself, the spec delegates to bind/factory/resource, and service_type is a computed field derived from the service. The spec test asserts raw declarations resolve and a prebuilt record is rejected at the boundary. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
scope() handed the parent's registration records to the bootstrap spec: factories and resources failed the raw-callable contract, and a service record was silently registered as the service value itself. The scope now passes record.service and record.factory, the one declared type. Runtime: examples.ex_08_flext_container passes its 77 checks. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
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.



Slice S2 of plan V8 (bead flext-4jtcb.2).
Local pre-push gate (R23), GREEN on the committed head: make gen with a clean tree, make audit, make check (15 gates, mypy clean), make test (2709 passed). Runtime: examples.ex_08_flext_container passes its 77 checks.
🤖 Generated with Claude Code
Summary by cubic
Container registrations now pass through one validated write path: empty, duplicate, and reserved names raise
e.ValidationErrorinstead of being silently ignored. The string-keyeddependency_injectorbridge (provide,wire,_di_*state,FlextRuntime.DependencyIntegration) and the_service_record/_factory_record/_resource_recordregistration helpers are removed.config,logger,context,command_bus) live inc.CONTAINER_RESERVED_NAMES; public writes reject them while internal core writes may use them.scope()passesrecord.service/record.factoryinto the spec, fixing factories and resources that failed and services that were silently registered as their own record.ServiceRegistrationSpecnow declares raw values only (droppingSkipValidation), and the container builds each record itself.shared(auto_register_factories=True)raises when the caller module cannot be resolved.Migration
e.ValidationErroron container writes; duplicate and reserved names no longer pass silently.provide,wire,initialize_di_components,sync_config_to_di, andregister_existing_providers.Written for commit f8726a5. Summary will update on new commits.