[1.x Bug] Metric in an installed package links to its in-model `semantic_model` under the ROOT project namespace
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this a new bug in dbt-core?
- [x] I believe this is a new bug in dbt-core
- [x] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
When an installed package defines a semantic model + metrics via the in-model spec (`models[].semantic_model + inline models[].metrics`), dbt Core resolves the metric's dependency on its generated semantic model under the ROOT project namespace instead of the package's, so `compile`/`ls` fails:
```
Compilation Error
'metric.ad_reporting.active_ads' depends on 'semantic_model..ad_report' which is not in the graph!
```
The same project compiles successfully with dbt Fusion.
### Expected Behavior
`metric.ad_reporting.active_ads` should depend on `semantic_model.ad_reporting.ad_report` (same package namespace), matching Fusion.
### Steps To Reproduce
1. In a package (e.g. `ad_reporting`), define a model using the in-model spec ([[1](https://docs.getdbt.com/reference/model-properties?version=2)], [[2](https://docs.getdbt.com/reference/metric-properties?version=2)]), e.g.:
```yaml
models:
- name: ad_reporting__ad_report
semantic_model:
enabled: true
name: ad_report
agg_time_dimension: date_day
columns:
- name: date_day
granularity: day
dimension: {type: time}
- name: ad_id
entity: {type: primary, name: ad}
- name: spend
dimension: {type: categorical}
metrics:
- name: active_ads
type: simple
agg: count_distinct
expr: ad_id
filter: "{{ Dimension('ad__spend') }} > 0"
```
2. Install the package in a root project (add a `metricflow_time_spine`).
3. On dbt Core 1.12.3, run: `dbt --no-partial-parse ls --resource-type semantic_model` (or `dbt compile`).
### Relevant log output
```shell
```
### Environment
```markdown
- dbt: Core 1.12.3 (works on dbt Fusion)
```
### Which database adapter are you using with dbt?
_No response_
### Additional Context
- Persists under --no-partial-parse and after dbt clean, so it is not the partial-parse bug #8859.
- Confirmed no name collisions between root project and package.
- Real-world repro: fivetran/dbt_ad_reporting#186.
Contributor guide
Assessment
This issue has not been assessed yet.