implements PLN-0035 pbs inline type hint payload production

This commit is contained in:
2026-04-03 11:35:29 +01:00
parent 3e8f53dc16
commit 09d9bb4c96
14 changed files with 559 additions and 25 deletions
@@ -0,0 +1,110 @@
---
id: PLN-0035
ticket: studio-editor-inline-type-hints-for-let-bindings
title: PBS inline type hint payload production
status: done
created: 2026-04-03
completed: 2026-04-03
tags: [compiler, pbs, inline-hints, type-inference, lsp]
---
## Objective
Produce frontend-owned inline hint payloads for PBS inferred local bindings, starting with `let` bindings whose types are omitted in source.
## Background
DEC-0015 explicitly leaves hint eligibility frontend-owned. The initial user need comes from PBS inferred `let` bindings, and PBS already computes the inferred type during flow analysis. That semantic fact now needs to be surfaced as frontend-produced hint payload rather than remaining internal-only analysis state.
## Scope
### Included
- Surface PBS-produced inline type hints for inferred `let` bindings.
- Reuse existing flow-analysis type information rather than adding parallel inference.
- Preserve valid hints under partial degradation wherever the frontend can still produce them.
- Add PBS/LSP-facing tests for hint eligibility and payload correctness.
### Excluded
- Host rendering policy.
- Non-PBS frontend hint production.
- Hint categories not chosen by PBS.
## Execution Steps
### Step 1 - Identify stable anchor and payload sources in PBS analysis
**What:** Determine the exact PBS semantic source for inferred binding type and anchor location.
**How:** Trace `let` analysis through the PBS flow-analysis pipeline and identify:
- where inferred local binding type becomes stable;
- how to render that type as display text;
- which source position should anchor the hint;
- what happens when the binding has explicit type text and therefore should not receive an inferred-type hint.
This step must avoid recomputing types outside the existing semantic pipeline.
**File(s):**
- `prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/semantics/`
- `prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/services/`
### Step 2 - Emit frontend-owned hint payloads for eligible bindings
**What:** Make PBS produce inline hint payloads for eligible inferred bindings.
**How:** Extend the PBS semantic-read production path so it emits frontend-owned hint entries for `let` bindings with omitted type syntax and stable inferred type results.
The production path must:
- suppress hints when PBS does not want one;
- avoid emitting hints for explicitly typed bindings;
- preserve valid hints even if unrelated parts of the document degrade.
**File(s):**
- `prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/services/`
- `prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/semantics/`
- any accepted frontend semantic contract surface used by `prometeu-lsp`
### Step 3 - Add PBS-focused hint production tests
**What:** Lock PBS hint policy and payload behavior with tests.
**How:** Add tests for:
- inferred `let` bindings receiving hints;
- explicit `let name: Type = ...` bindings receiving no inferred-type hint;
- payload text stability for scalar, struct, optional, result, tuple, or other supported type forms chosen by PBS;
- partial-degradation cases where unaffected bindings still produce hints.
**File(s):**
- `prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/`
- `prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/` where end-to-end analyze assertions are required
## Test Requirements
### Unit Tests
- PBS semantic tests for inferred binding hint eligibility.
- Type-surface formatting tests if payload display text is factored into a helper.
### Integration Tests
- LSP analyze tests verifying PBS-produced hints appear in transported results.
- Partial-degradation tests preserving unaffected hints.
### Manual Verification
- Open a PBS document with inferred `let` bindings and inspect the LSP analyze payload.
- Confirm no hints appear for explicit type annotations.
## Acceptance Criteria
- [ ] PBS produces frontend-owned inline hint payloads for eligible inferred `let` bindings.
- [ ] Explicitly typed bindings do not receive inferred-type hints.
- [ ] Valid hints survive unrelated local degradation when PBS can still analyze those bindings.
- [ ] Tests lock the frontend-owned eligibility policy.
## Dependencies
- Accepted decision `DEC-0015-studio-editor-inline-type-hints-contract-and-rendering-model.md`
- `PLN-0033-inline-hint-spec-and-contract-propagation.md`
- `PLN-0034-lsp-inline-hint-transport-contract.md`
## Risks
- If inferred-type display text is not normalized, hint output may become unstable across equivalent semantic forms.
- If hint production is attached too late in the pipeline, degraded documents may lose more valid hints than necessary.