| 1 | <!-- English translation of adr/0056-semantic-map-pipeline-adoption.md. Canonical Russian: ../../adr/0056-semantic-map-pipeline-adoption.md --> |
| 2 | |
| 3 | # ADR 0056: Semantic Map adoption of Skia composition pipeline |
| 4 | |
| 5 | **Status:** Accepted · Implemented |
| 6 | **Date:** 2026-04-17 |
| 7 | |
| 8 | ## Related ADRs |
| 9 | |
| 10 | | ADR | Role | |
| 11 | |-----|------| |
| 12 | | [0053](0053-semantic-map-control-flow-pfd.md) | controlFlow intent, layout | |
| 13 | | [0055](0055-skia-instrument-composition-pipeline.md) | General Skia pipeline | |
| 14 | | [0067](0067-graph-backed-surfaces-contract.md) | Contract graph-backed surface | |
| 15 | |
| 16 | --- |
| 17 | ## Context |
| 18 | |
| 19 | After implementing `controlFlow` for Semantic Map it turned out: |
| 20 | |
| 21 | 1. Layout and density policy were partially spread between the VM/control/engine. |
| 22 | 2. On the compact PFD viewport, the nodes stuck together, route reading deteriorated. |
| 23 | 3. MCP behavior without explicit `line/column` required a predictable fallback to the current cursor. |
| 24 | |
| 25 | --- |
| 26 | |
| 27 | ## Solution |
| 28 | |
| 29 | <a id="adr0056-p1"></a> |
| 30 | ### 1) Translate Semantic Map to a separate composer tool |
| 31 | |
| 32 | Introduced `CodeNavigationMapCompositor` as the first domain adapter of the general approach from ADR 0055: |
| 33 | |
| 34 | - selection of layout by `semantic_map.level`; |
| 35 | - calculating the recommended viewport height for readability; |
| 36 | - return scene + display parameters. |
| 37 | |
| 38 | <a id="adr0056-p2"></a> |
| 39 | ### 2) Explicitly split file/controlFlow composition |
| 40 | |
| 41 | - `file` uses a compact layout (historical star layout); |
| 42 | - `controlFlow` uses a vertical flight-plan layout with a large step between levels. |
| 43 | |
| 44 | <a id="adr0056-p3"></a> |
| 45 | ### 3) Preserve the semantics of the "under the cursor" method |
| 46 | |
| 47 | For `controlFlow`: |
| 48 | |
| 49 | - without a valid position, do not fallback to the “first file method”; |
| 50 | - if `line/column` is not sent via MCP, substitute the current carriage position; |
| 51 | - if there is no position and caret, return an empty subgraph rather than false content. |
| 52 | |
| 53 | --- |
| 54 | |
| 55 | ## Consequences |
| 56 | |
| 57 | ### Pros |
| 58 | |
| 59 | - Semantic Map became the first validated consumer of the common pipeline. |
| 60 | - The "instrument internals vs host surface" border has become transparent in the code. |
| 61 | - Improved readability of controlFlow in a narrow viewport. |
| 62 | |
| 63 | ### Cons |
| 64 | |
| 65 | - An additional layer of composition and new tests have appeared. |
| 66 | - Declutter-policy is still minimal and requires further evolution. |
| 67 | |
| 68 | --- |
| 69 | |
| 70 | ## Implementation (slice) |
| 71 | |
| 72 | - `Services/Navigation/CodeNavigationMapCompositor.cs` |
| 73 | - `Services/Navigation/ICodeNavigationMapCompositor.cs` |
| 74 | - `ViewModels/MainWindowViewModel.WorkspaceNavigationMap.cs` |
| 75 | - `Views/WorkspaceNavigationMapView.axaml` |
| 76 | - `Services/Navigation/CodeNavigationMapControlFlowGraphLayoutEngine.cs` |
| 77 | - `Services/CodeNavigation/CodeNavigationControlFlowSubgraphBuilder.cs` |
| 78 | |
| 79 | --- |
| 80 | |
| 81 | ## Tests |
| 82 | |
| 83 | - `CodeNavigationMapCompositorTests` |
| 84 | - `CodeNavigationMapControlFlowGraphLayoutEngineTests` |
| 85 | - `CodeNavigationControlFlowSubgraphBuilderTests` |
| 86 | - `CodeNavigationControlFlowMcpCursorFallbackTests` |