feat(decisioning): built-in fields projection on get_products responses#503
Merged
Conversation
Closes #492 Adds framework-level projection of `GetProductsRequest.fields` to `MediaBuyHandler.get_products`. After the adopter's platform method returns, if `params.fields` is set the framework strips unrequested product fields before the response reaches the buyer, honoring the lightweight-discovery contract without requiring every adopter to reimplement the same post-filter. Three field categories always pass through regardless of the buyer's selection: (1) all eight schema-required Product fields (derived dynamically from `Product.model_fields.is_required()`), (2) nine optional declared fields that have no GetProductsField enum entry and are therefore not selectable by the buyer, and (3) all extra='allow' extension fields. When `params.fields` is None the response is returned unchanged with no allocation. https://claude.ai/code/cse_01H7Q7ZKYj9Atw5KCBBo5ndC
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.
Closes #492
Adds framework-level projection of
GetProductsRequest.fieldstoMediaBuyHandler.get_products. After the adopter's platform method returns, ifparams.fieldsis set the framework strips unrequested product fields before the response reaches the buyer — honoring the lightweight-discovery contract without requiring every adopter to reimplement the same post-filter.Three field categories always pass through regardless of the buyer's selection:
Productfields (derived dynamically fromProduct.model_fields.is_required()so schema regenerations stay in sync):product_id,name,description,publisher_properties,format_ids,delivery_type,pricing_options,reporting_capabilitiesGetProductsFieldenum entry (buyer has no mechanism to select/deselect them):cancellation_policy,ext,is_custom,material_submission,measurement_readiness,measurement_terms,performance_standards,property_targeting_allowed,signal_targeting_allowedextra='allow'extension fieldsWhen
params.fieldsisNonethe response is returned unchanged with no allocation.New files:
src/adcp/decisioning/_get_products_helpers.py—_project_product_fieldshelper + three module-level constants; mirrors thewebhook_emit.pyintercept-at-the-seam patterntests/test_get_products_projection.py— 17 tests covering constant integrity, projection correctness, extra-field preservation, default-false boolean preservation, handler integrationWhat was tested:
pytest tests/test_get_products_projection.py tests/test_decisioning_handler.py→ 29/29 passedmypy src/adcp/decisioning/_get_products_helpers.py src/adcp/decisioning/handler.py→ no issuesruff check→ cleanPre-PR review:
_FIELD1_VALUES→_GET_PRODUCTS_FIELD_VALUES, removed redundant__all__, renamed test for enum-count accuracy, appliedmode="json"consistency nit)fields_projection_supportedcapability gate in spec); confirmedproposals[]exclusion is correctNits surfaced (not blocking):
apply_fields_projection: bool = True) would benefit adopters who project at the DB query level. The issue author explicitly ruled out a capability gate; this can be added as a non-breaking follow-up if needed.Session: https://claude.ai/code/cse_01H7Q7ZKYj9Atw5KCBBo5ndC
Generated by Claude Code