7.1 KiB
| id | ticket | title | created | tags | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LSN-0029 | studio-frontend-owned-semantic-editor-presentation | Frontend-Owned Semantic Presentation Descriptor and Host Consumption | 2026-04-02 |
|
Context
The first semantic highlight wave for frontend documents had already proved that Studio could consume semantic spans through the integrated LSP path. The remaining ownership problem was narrower but important:
- semantic colors for frontend documents were still effectively hosted by Studio,
- the frontend did not publish a first-class semantic presentation contract,
- and the semantic bridge risked collapsing frontend meaning into host-owned categories.
This discussion closed that gap by moving semantic presentation ownership fully to the frontend while keeping Studio and LSP in narrow host roles.
Key Decisions
Make FrontendSpec the Canonical Semantic Presentation Contract
What:
The canonical semantic presentation contract now lives in FrontendSpec and carries frontend-owned semanticKeys plus frontend-owned resources in a single descriptor shape.
Why:
Semantic presentation is part of the frontend's meaning, not just an editor skin.
Keeping the contract in FrontendSpec lets semantic vocabulary and presentation resources evolve with the frontend itself.
Trade-offs: Frontend metadata becomes slightly richer and must now be kept coherent with shipped resources. That extra discipline is worth it because it keeps ownership explicit and versionable.
Keep LSP as a Contract Bridge, Not a Semantic Owner
What:
LSP derives a semantic presentation descriptor from the resolved FrontendSpec and exposes it to Studio, but it does not own resources and does not translate frontend semantics into host-owned generic buckets.
Why:
The LSP layer should bridge analysis products into host consumption, not normalize language identity away.
If LSP emitted categories such as fe-keyword, it would pull frontend semantics into the wrong layer.
Trade-offs: DTOs and semantic indexing need to preserve language-owned keys all the way through transport. That is a better cost than growing a fake shared semantic vocabulary in the host stack.
Keep Studio Mechanical and Fallback-Free
What: Studio now projects frontend semantic keys mechanically into CSS classes and consumes frontend-owned resources through the descriptor. If descriptor data or usable resources are absent, Studio simply skips semantic highlight for that frontend document.
Why: Studio owns rendering plumbing and editor UX, not frontend semantics. Mechanical projection preserves that boundary, and no generic fallback theme avoids silently reintroducing host ownership.
Trade-offs: The host no longer guarantees a semantic color scheme for misconfigured frontend contracts. That is intentional, because degraded no-highlight behavior is safer than a misleading generic fallback.
Final Implementation
The final implementation landed across specs, compiler/frontend metadata, LSP transport, and Studio consumption:
docs/specs/studio/5. Code Editor Workspace Specification.mdanddocs/specs/studio/7. Integrated LSP Semantic Read Phase Specification.mdnow state that frontend semantic presentation is frontend-owned, derived fromFrontendSpec, and fallback-free.docs/specs/compiler-languages/pbs/README.mdnow declares PBS ownership of semantic vocabulary and semantic editor presentation contract.FrontendSpecis now used as the canonical source of semantic presentation metadata consumed by the editor pipeline.PBSDefinitionspublishes PBS semantic keys and resource paths, andPbsSemanticKinddefines the stable frontend-owned semantic vocabulary.prometeu-lspnow transports frontend-owned semantic keys and exposesLspSemanticPresentationDTOderived from the resolved frontend spec instead of collapsing highlights into host-ownedfe-*buckets.- Studio consumes descriptor resources through
EditorDocumentPresentationRegistry, projects keys mechanically throughEditorDocumentSemanticHighlighting, and applies frontend-owned stylesheets such as PBS semantic highlight resources.
Patterns and Algorithms
Pattern: Treat Semantic Presentation as Language Metadata
When editor semantic styling is language-specific, the contract should live with the frontend definition rather than with the host renderer. That keeps vocabulary, resources, and evolution under the same owner.
Pattern: Bridge Metadata Without Reinterpreting It
The correct transport flow is:
- frontend defines semantic vocabulary and resources,
- LSP derives and transports the descriptor,
- Studio consumes and renders it mechanically.
The bridge must preserve keys, not rename them into a host dialect.
Example: Mechanical Projection Rule
The resulting projection flow is:
- PBS publishes a semantic key such as
pbs-function. - LSP returns highlight spans with that same key and a descriptor containing PBS resources.
- Studio projects the key to
editor-semantic-pbs-function. - PBS-owned stylesheet resources style that class.
Pitfalls
- Do not reintroduce generic host-owned semantic keys such as
fe-keywordorfe-type. - Do not move frontend semantic stylesheets back into Studio just because the renderer loads them.
- Do not treat LSP DTO ownership as presentation ownership; transport is not authorship.
- Do not add a generic fallback theme for missing frontend metadata, because that silently restores host semantic ownership.
- Do not make Studio perform deep contract validation that belongs in frontend tests.
References
DEC-0012Frontend-owned semantic editor presentation via FrontendSpec-derived descriptorPLN-0026Propagate DEC-0012 into Studio and frontend normative specsPLN-0027Add frontend semantic presentation contract to FrontendSpec and expose it through LSPPLN-0028Consume frontend-owned semantic presentation in Studio and retire generic FE theme usagedocs/specs/studio/5. Code Editor Workspace Specification.mddocs/specs/studio/7. Integrated LSP Semantic Read Phase Specification.mddocs/specs/compiler-languages/pbs/README.mdprometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/PBSDefinitions.javaprometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/PbsSemanticKind.javaprometeu-lsp/prometeu-lsp-api/src/main/java/p/studio/lsp/dtos/LspSemanticPresentationDTO.javaprometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/models/SemanticIndex.javaprometeu-studio/src/main/java/p/studio/workspaces/editor/EditorDocumentPresentationRegistry.javaprometeu-studio/src/main/java/p/studio/workspaces/editor/syntaxhighlight/EditorDocumentSemanticHighlighting.java
Takeaways
- Semantic presentation belongs to the frontend when semantic meaning belongs to the frontend.
- LSP should transport frontend-owned contracts without flattening them into host-owned categories.
- Studio stays cleaner when it renders semantic presentation mechanically and degrades to no highlight instead of inventing a fallback theme.