Variable Scope - Overriding Package and Sub-Package Variables

The problem I’m having

I cannot seem to pass variables “up” to my packages when those variables are consumed in the package’s dbt_project.yml file. I can’t do this even when invoking dbt run --vars '{"some_package_variable": "desired_value"}' in my main project.

The context of why I’m trying to do this

I have a top-level project that I maintain. I have a package, P, that I maintain as well. My top-level project consumes P as a package, and P itself has 3rd party packages. I want to be able to dynamically disable certain 3rd-party models in P when I run P directly (say, for testing). However, I also want to be able to dynamically disable P’s 3rd-party models from my top-level project, in the same way (depending on the needs of my top-level project, I want only some models of P and its 3rd-party sub-packages to run).

I can’t disable these models any other way (e.g. the config block of a model file), because they are themselves in a sub-package.

What I’ve already tried

In P’s dbt_project.yml, I have models config that disables a subset of 3rd-party models based on a variable passed on the command line dbt run --vars '{"marketing_source": "google_analytics_4"}'. The enabled field for several 3rd party models looks like so: enabled: "{{ var('marketing_source') == 'google_analytics_4' }}".

This works when I run P directly (for testing/CI/etc) as long as I pass those variables on the command line (because dbt_project.yml has a variable scope of the command line + some builtins only).

However, when I “add another layer” and try to do this from a top-level project that uses P as a package, I can’t do this, even when passing from the command line. See below for the error.

Some example code or error messages

From my top-level project…

> dbt run --vars '{"marketing_source": "google_analytics_4"}'        
04:28:44  Running with dbt=1.9.1
04:28:46  Registered adapter: bigquery=1.9.0
04:28:46  Encountered an error:
Compilation Error
  Could not render {{ var('marketing_source') == 'google_analytics_4' }}: Required var 'marketing_source' not found in config:
  Vars supplied to <Configuration> = {}

All in all, what gives? What is a sane way to do this?