Skip to content

Fixes #39598: Lineage: Architecture Layer overlay for ordered warehouse layers - #39611

Open
muyanli wants to merge 16 commits into
open-metadata:mainfrom
muyanli:feat/lineage-architecture-layers
Open

muyanli wants to merge 16 commits into
open-metadata:mainfrom
muyanli:feat/lineage-architecture-layers

Conversation

@muyanli

@muyanli muyanli commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #39598

Phase 1 of #35872.

Many warehouses are built in ordered technical layers, such as medallion (bronze → silver → gold) or Data Vault (staging → raw vault → business vault → marts), and data is expected to move forward through them. Lineage can group assets by service, domain or data product, but nothing shows which layer an asset is in, or flags lineage that runs against the layer order.

#35872 asks for this. This PR is its first phase: it marks layers on the asset lineage canvas and flags edges that break the order. The Lineage Map rollup by layer, which the issue centres on, needs server-side work and comes in a later phase.

This PR lets admins describe their layers once in lineage settings, by name patterns or by tags (such as dbtTags.layer_* from dbt), and adds an Architecture Layer overlay to the asset lineage canvas, next to Column and Observability. When it is on:

  • each asset shows its layer: the layer's colour along the node's top edge and a tag with the layer name;
  • edges that go backward (to an earlier layer) or skip a layer are drawn wider, in a warning colour.

The overlay is offered only once layers are configured, so nothing changes for anyone who doesn't use it.

Type of change:

  • New feature

High-level design:

Configuration (lineageSettings.json, recorded in ADR:2026-12-02-lineage-architecture-layers-are-ordered-groups-matched-by-fqn-or-tag)

lineageSettings gets an optional architectureLayers array. Its order is the layer order. Each layer has a unique name, an optional color (#rrggbb), and fqnPatterns, tags or both:

"architectureLayers": [
  { "name": "bronze", "color": "#b54708", "fqnPatterns": ["*.*.bronze.*", "lake_raw.*"] },
  { "name": "silver", "fqnPatterns": ["*.*.silver.*", "*.stg_*"] },
  { "name": "gold",   "fqnPatterns": ["*.*.gold.*", "*.fact_*", "*.dim_*"] },
  { "name": "marts",  "tags": ["dbtTags.layer_mart"] }
]
  • A pattern is a glob matched against an asset's whole FQN, ignoring case: * matches any run of characters, dots included, and ? matches one character. Since an FQN is service.database.schema.name, one rule kind covers layering by service, database, schema or name prefix, for every entity type.
  • A tag is a tag FQN, compared with the asset's tags ignoring case. This covers teams that already mark layers with tags, such as the dbtTags.layer_* tags dbt ingestion creates; the tags give membership and the layer list gives the order tags lack.
  • An asset belongs to the first layer, in layer order, with a matching pattern or tag. Assets no layer matches have no layer and are drawn as before.
  • Limits: at most 10 layers, and 20 patterns and 20 tags per layer, enforced by the schema. More layers would not fit as bands on the canvas (phase 2), and patterns are matched for every node of a graph.
  • LineageLayer gets an ArchitectureLayer value, so the overlay can also be chosen as the default layer in lineage settings.

Edge rule. An edge is judged only when both ends have a layer. With i the upstream layer's position and j the downstream one's:

  • j < i: backward (e.g. gold → bronze);
  • j > i + 1: skipped layer (e.g. bronze → gold);
  • otherwise (same layer or the next one): normal.

Column edges are not judged separately; the table edge they belong to carries the warning.

UI. The overlay follows how the Observability layer is built, so it adds no new mechanism:

lineageSettings.architectureLayers ──(loaded at app start)──► appPreferences.lineageConfig
                                                                    │
                                  useArchitectureLayers(): { hasLayers, isEnabled, matchLayer }
                                   │                        │                         │
                      LineageLayers menu          CustomNodeV1 + ArchitectureLayerTag   CanvasEdgeRenderer
                      (offers the overlay         (layer colour and tag on              (getLayerOrderIssueEdgeIds →
                       when hasLayers)             matching nodes)                       warning stroke)
  • utils/Lineage/architectureLayer.utils.ts: pure functions for glob → RegExp, the layer matcher on an asset's FQN and tags (patterns are compiled once per configuration, not per node), the edge rule, the edges with a layer-order issue (each end read from its canvas node, which carries the asset's tags), and the layer colour (a default palette for layers without one). getLineage already returns each node's tags (the search documents' source fields), so no API change is needed; getNodeLineageData now keeps tags when it trims a lineage node for the canvas.
  • hooks/lineage/useArchitectureLayers.ts: reads the configured layers from app preferences, and whether the overlay is on.
  • hooks/useAppConfigurations.ts: the app-start load of limits and lineage settings, moved out of AppContainer. AppShell calls it too, because app-shell pages render outside AppContainer.
  • LineageLayers.tsx: adds the overlay to the asset layer menu when layers are configured. The new label.architecture-layer is translated in every locale. useLineageStore.setActiveLayer clears the platform view for it, as it does for the other overlays.
  • CustomNodeV1 + ArchitectureLayerTag: the layer color goes to the node's top border through a CSS variable, and the tag floats on that border at the right, so it doesn't change the node height the layout uses and doesn't cover the Base badge. The stripe stays when a node is traced, selected or hovered, since those states recolour the whole border and the layer matters most while a path is traced. The tag uses the card's surface token, so it matches the card in dark mode. Scene (container) nodes are skipped.
  • CanvasEdgeRenderer / useCanvasEdgeRenderer: computes the issue edges; withLayerOrderWarning (EdgeStyleUtils) draws them at twice the normal width and, unless the edge is hovered, selected or traced, in layerOrderWarning (warning-600). Hovered, selected and traced edges keep their emphasis colour, and tracing still dims warning edges off the path. The wider stroke stays in every state, so the warning does not rely on colour alone. Dashes were not used because a dashed edge already means the edge has a pipeline. A failing data quality highlight still wins over a layer-order warning. The default layer palette leaves out oranges and browns, which would read like the warning. Layer colors and the warning colors use theme tokens, so they follow dark mode.

Alternatives considered

  • Tags only. Not every team tags its assets, and many already encode layers in service, schema or table names, so a layer takes patterns, tags or both. Tags alone also carry no order, which the layer list supplies.
  • Separate rules per field (service / database / schema / name). More schema surface than one FQN glob, with no extra expressive power for the layering conventions in the issue.
  • Most specific pattern wins. Harder to predict and explain than "first layer in order wins"; admins can order layers to resolve overlaps.
  • A Lineage Map lens ("Architecture Layer" next to Service / Domain / Data Product). The map's rollup is computed server-side in the lineage/scene API, so it needs backend work; it is planned as a later phase rather than mixed into this one.

Compatibility. architectureLayers is optional, so existing settings stay valid and no migration is needed. Both lineage settings forms already send back the fields they don't edit, so saving them keeps the configured layers. Until a layers editor lands (phase 2), layers are set through PUT /api/v1/system/settings.

Next phases (separate PRs)

  1. A layers editor in Settings → Lineage Config, and an optional layered layout (one band per layer, using ELK partitioning).
  2. Rolling the Lineage Map up by architecture layer, with server-side support in lineage/scene.

Tests:

Use cases covered

  • An admin configures bronze / silver / gold layers by schema and a marts layer by a dbt tag; on a table's Lineage tab, turning on Architecture Layer shows each asset's layer, and edges from bronze straight to gold, or from gold back to silver, are drawn as warnings.
  • Without configured layers, the overlay is not offered and the canvas is unchanged.
  • Saving the lineage config form keeps the configured layers.

Unit tests

  • I added unit tests for the new/changed logic.
  • utils/Lineage/architectureLayer.utils.test.ts: glob matching (* across dots, ?, case, literal special characters), tag matching (case, first layer wins across patterns and tags), unmatched nodes, the backward / skipped edge rule, issue edges (column edges skipped, layers read from node tags), default colours.
  • utils/EdgeStyleUtils.test.ts: warning edges are drawn in the warning colour and wider; a failing data quality edge keeps its style.
  • utils/EntityLineageNodeUtils.test.ts: lineage nodes keep their tags (fails without the change).
  • hooks/lineage/useArchitectureLayers.test.ts: layers from app preferences; off when the overlay is not active; no layers before settings load.
  • hooks/useAppConfigurations.test.ts: loads lineage settings into app preferences once the user is known.
  • AppShell.test.tsx: the shell loads the app configuration.
  • ArchitectureLayerTag.test.tsx, LineageLayers.test.tsx (overlay offered only with configured layers, toggling it).

Backend integration tests

  • Not applicable (schema-only change to an optional settings field; no API code changed).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Flow/LineageSettings.spec.ts › Architecture Layer overlay tags nodes with their layer by FQN pattern or tag: tags the topic, sets layers through the settings API (the table by FQN pattern, the topic by tag), turns on the overlay and checks each node's layer tag, then restores the settings.

Full run: 824 passed, 21 failed (16 timeouts). The failures are Domain tests on all entity types and a few others. They also fail without this change, and they pass when run alone. Lineage specs pass.

Manual testing performed

  1. Built the backend from this branch with ./docker/run_local_docker.sh -m no-ui -d mysql -i false and ran the UI with yarn start.
  2. Created a small lakehouse through the API, acme_lakehouse.analytics with bronze, silver, gold, reporting and sandbox schemas, lineage between its tables, and a dbtTags.layer_mart tag on reporting.revenue_finance_mart. Set layers through PUT /api/v1/system/settings: bronze / silver / gold by schema pattern (plus raw_*, dim_*, fact_* for the sample data), and marts by the dbt tag.
  3. On gold.fct_revenue's Lineage tab, turned on Architecture Layer: each table shows its layer, revenue_finance_mart shows marts from its tag, sandbox.revenue_adhoc shows none, and raw_payments → fct_revenue (skips silver) and fct_revenue → finance_reconciliation (gold → silver) are drawn as warnings. Turning the overlay off restores the canvas.

UI screen recording:

after_feature.mp4

Checklist:

  • I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (Optional field; see Compatibility.)

  • For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md and fixed every 🔴 finding, or answered it on the line below.

  • Decision check: adds ADR:2026-12-02-lineage-architecture-layers-are-ordered-groups-matched-by-fqn-or-tag for the architectureLayers format, the matching rule and the edge rule.

  • I have added tests around the new logic.

@harshach

harshach commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

@muyanli thanks for the PR. Could you please proivde a screen recording on how it looks in light and dark mode and also address the above bot comments cc @chirag-madlani for further review

@muyanli muyanli changed the title Fixes #39598: Lineage: Architecture Layer overlay for ordered warehouse layers Feat #39598: Lineage: Architecture Layer overlay for ordered warehouse layers Dec 4, 2026
@muyanli
muyanli marked this pull request as ready for review December 4, 2026 04:05
@muyanli
muyanli requested a review from a team as a code owner December 4, 2026 04:05
@muyanli
muyanli requested review from harsh-vador and removed request for a team December 4, 2026 04:05
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@muyanli

muyanli commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Hi @harshach @chirag-madlani ! I have uploaded video to show the flow plus how it looks with dark mode. Also resolved the comments. Thank you!

@chirag-madlani chirag-madlani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left 1 comment and check CI failures, Thanks for the PR

Comment on lines +33 to +51
const loadArchitectureLayers = () => {
layersRequest ??= getSettingsByType(SettingType.LineageSettings)
.then(
(settings) =>
(settings as LineageSettings).architectureLayers ?? NO_LAYERS
)
.catch(() => {
layersRequest = undefined;

return NO_LAYERS;
});

return layersRequest;
};

/** For tests: forget the shared request. */
export const resetArchitectureLayersRequest = () => {
layersRequest = undefined;
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already loading settings on a App load can't we use it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! App-mode routes render outside AppContainer, so the app-load settings were not there. I moved the app-load fetch into a shared useAppConfigurations hook. AppContainer and AppShell both call it. useArchitectureLayers now only reads appPreferences and does not fetch. As a side effect, app-shell pages now also get the saved lineage depth. This also fixes the browser test failures. The extra request had no MSW handler.

muyanli and others added 2 commits December 6, 2026 13:38
Move the app-start load of limits and lineage settings from AppContainer
into a shared useAppConfigurations hook. AppShell calls it as well, since
app-mode routes render outside AppContainer. useArchitectureLayers now only
reads app preferences and no longer fetches settings itself.
@gitar-bot

gitar-bot Bot commented Dec 6, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 5 closed / 5 findings

The lineage overlay classifies assets and highlights backward or skipped edges from configured patterns and tags, so misconfiguration could mislead lineage interpretation.

Adds an Architecture Layer overlay to the asset lineage canvas, driven by ordered layers configured in lineage settings by FQN pattern or tag, with layer stripes on nodes and warning-width edges for backward or layer-skipping links. Five review findings were resolved: layer-order warnings no longer override tracing dimming or hover/trace colours, the new label is translated in all locales, the layer tag uses the surface token, layer regexes are compiled once per configuration, and hovering a layered node keeps its layer stripe colour. No issues remain open.

✅ 5 closed
✅ Bug: Layer-order warning undoes tracing dimming and hover/trace colour

📄 openmetadata-ui/src/main/resources/ui/src/utils/EdgeStyleUtils.ts:254-268 📄 openmetadata-ui/src/main/resources/ui/src/hooks/useCanvasEdgeRenderer.ts:317-331
withLayerOrderWarning swaps the whole style for { stroke: warning, opacity: 1, ... }, so it throws away what computeEdgeStyle worked out. When a user traces a node, calculateEdgeStyle dims the unrelated edges to opacity 0.3. Any warning edge among them goes back to opacity 1 and stays as bright as the traced path. A traced, hovered or selected warning edge also loses its colors.primary stroke, so tracing gives no visible feedback on it. With the overlay on, tracing shows the wrong focus.

Fix: keep the incoming opacity, and only recolour edges that are not traced or hovered (or let the trace/hover colour win).

✅ Quality: New label left in English in all 20 non-English locales

📄 openmetadata-ui/src/main/resources/ui/src/locale/languages/ar-sa.json:292 📄 openmetadata-ui/src/main/resources/ui/src/locale/languages/de-de.json 📄 openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json 📄 openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json 📄 openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json
label.architecture-layer is set to "Architecture Layer" in ar-sa, de-de, fr-fr, ja-jp, zh-cn and the other 15 non-English locale files. That is the placeholder yarn i18n copies in. The i18n rules treat English left under a non-English key as a review defect unless keeping it is a deliberate choice (an acronym or product name), and neither applies here. The layer menu and the settings dropdown will show English in every other language.

Fix: translate the value in each non-en-us file.

✅ Quality: Layer tag background uses page colour instead of surface token

📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/custom-node.less:957
The floating .architecture-layer-tag pill sits on the node card's top edge and uses var(--tw-background-color-primary) for its background. The styling rules say LESS should use the surface bridge var (--tw-background-color-surface) and not -primary, because -primary is the page colour in dark mode. In dark mode the pill takes the page colour instead of the card's surface, so it does not read as part of the card.

Fix: use var(--tw-background-color-surface).

✅ Performance: Every lineage node recompiles all layer regexes

📄 openmetadata-ui/src/main/resources/ui/src/hooks/lineage/useArchitectureLayers.ts:33-44 📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNodeV1.component.tsx:277-284
useArchitectureLayers calls createArchitectureLayerMatcher inside its own useMemo, and CustomNodeV1 calls the hook once per node. Each node therefore compiles its own copy of up to 200 RegExps (10 layers × 20 patterns), and does it again whenever activeLayer changes. On a graph with 1,000 nodes that is about 200k regex compiles per toggle. This undoes the util's stated goal ("Patterns are compiled once").

Fix: build the matcher once per layers reference, for example with a single-entry memo at module scope keyed on the array, or a selector in the store. Keep activeLayer out of the matcher memo.

✅ Edge Case: Hovering a layered node still turns its layer stripe brand blue

📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/custom-node.less:945-952 📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/custom-node.less:704-714
The new .react-flow__node > .lineage-node.architecture-layer-node rule has specificity 0,3,0, which is enough to beat the traced and selected rules. The hover rule at custom-node.less:704-714 is stronger, though: .react-flow__node-default.selectable:hover .lineage-node { border-color: … } is 0,4,0. So whenever the pointer is over a layered node, its 4px top stripe turns brand blue and the layer colour disappears. The comment says the rule "matches their specificity", but that is not true for hover. One fix is to raise the rule to 0,4,0 (for example by prefixing .react-flow), since it already comes after the hover rule. Another is to set only border-top-color in a selector that also covers :hover.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@muyanli muyanli changed the title Feat #39598: Lineage: Architecture Layer overlay for ordered warehouse layers Fixes #39598: Lineage: Architecture Layer overlay for ordered warehouse layers Dec 6, 2026
@muyanli

muyanli commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @chirag-madlani!

  • Your comment: done. Settings now load once at app start, in both AppContainer and AppShell, through a shared useAppConfigurations hook.
  • CI: the browser test failures came from the same extra settings request. They pass now.
  • I also merged main to fix a conflict in AppShell.tsx.

The only red check is PR Metadata Validation. It needs #39598 in the Shipping project, and I don't have access. Could you add it please? Thank you!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lineage: Architecture Layer overlay on the asset lineage canvas (phase 1 of #35872)

3 participants