fix(scripting): #1083 a dynamic tag path is an editor error only where the gate refuses it (predicate), a warning in value/Calculation mode; #1093 Calculation-mode {{equip}} hover says it is refused

#1083: OTSCRIPT_DYNPATH was an error in every editor mode while the deploy gate refuses a
non-literal tag path only for a scripted-alarm predicate (editor stricter than the gate).
Decision: do not make the gate stricter (it would reject configurations that deploy today).
ScriptCompileRules now owns the split — RefusesNonLiteralTagPaths(kind) and
TagPathFindings(kind, source), each finding carrying Refuses — the gate refuses on exactly
those findings and the editor draws them as errors (8) and the rest as warnings (4), whose
text says what the path does at runtime (not a declared input: not subscribed, does not
re-trigger, reads BadNodeIdUnknown unless also read literally). DependencyRejection gains
Kind + MethodName for that wording. EditorGateParityTests carries dynamic / concatenated /
interpolated / empty paths in all three modes (14 rows fail with the old always-error
severity).

#1093: hovering a {{equip}} path literal in Calculation mode showed the VirtualTag
"resolves ... when deployed" text, contradicting the OTSCRIPT_EQUIPCALC marker on the same
span. It now says the token is refused in a Calculation script and why (no owning
equipment, never substituted, the gate refuses it). The {{equip}} hover no longer needs a
tag catalog.
This commit is contained in:
Joseph Doherty
2026-12-04 15:02:41 -05:00
parent ec4eed337c
commit bd4fff6444
8 changed files with 234 additions and 33 deletions
+23 -10
View File
@@ -124,7 +124,7 @@ the `ConfigEditor` authorization policy (`AdminUiPolicies.ConfigEditor`: Adminis
| Route | Request DTO | Response DTO | Purpose |
|-------|-------------|--------------|---------|
| `POST /api/script-analysis/diagnostics` | `DiagnoseRequest(Code)` | `DiagnoseResponse(Markers)` | Roslyn + ForbiddenType + dynamic-path error markers |
| `POST /api/script-analysis/diagnostics` | `DiagnoseRequest(Code)` | `DiagnoseResponse(Markers)` | Roslyn + ForbiddenType + dynamic-path markers (error for a predicate, warning otherwise — #1083) |
| `POST /api/script-analysis/completions` | `CompletionsRequest(CodeText, Line, Column)` | `CompletionsResponse(Items)` | Scope, dot-member, and tag-path completions |
| `POST /api/script-analysis/hover` | `HoverRequest(CodeText, Line, Column)` | `HoverResponse(Markdown?)` | Type + XML doc markdown |
| `POST /api/script-analysis/signature-help` | `SignatureHelpRequest(CodeText, Line, Column)` | `SignatureHelpResponse(Label?, Parameters?, ActiveParameter)` | Parameter help |
@@ -212,9 +212,10 @@ scripted alarms are the script's only users, and to *value* otherwise; pick whic
seam you are authoring for. The per-equipment VirtualTag editor is value mode and the
Calculation tag editor is Calculation mode. A body that lacks a `return` on some path
(CS0161) is flagged while you type since #1063 (it used to be filtered as a "phantom"
wrapper diagnostic while the gate refused it). Known remaining divergence: a dynamic
tag path (`OTSCRIPT_DYNPATH`) is an editor error in every mode but a gate refusal only
for a predicate. See `docs/VirtualTags.md` §"Deploy-time script compile gate" for
wrapper diagnostic while the gate refused it). A dynamic tag path (`OTSCRIPT_DYNPATH`)
is an editor **error** only in predicate mode, where the gate refuses it, and a
**warning** in value and Calculation mode, where it deploys (#1083 — it used to be an
error in every mode). See `docs/VirtualTags.md` §"Deploy-time script compile gate" for
modes, caching and the upgrade note.
### Runtime safety (what happens after publish)
@@ -314,11 +315,20 @@ scripted-alarm predicates) runs scripts through the shared `ScriptRunGuard`:
`DependencyExtractor.Extract(code).Rejections` enumerates every `ctx.GetTag` /
`ctx.SetVirtualTag` call whose first argument is NOT a string literal (variable,
concatenation, interpolation). Each rejection carries a `TextSpan` in
user-source coordinates, emitted as code `OTSCRIPT_DYNPATH`. This is the exact
check the deploy gate (and the scripted-alarm load) enforces for a scripted-alarm
predicate — the editor shows the squiggle where the literal must appear. In value
and Calculation mode the editor marks it an error too, but the gate does not refuse
it there: a known editor-stricter divergence, excluded from `EditorGateParityTests`.
user-source coordinates, emitted as code `OTSCRIPT_DYNPATH`. Which seams it refuses is
decided in `ScriptCompileRules` (#1083): `RefusesNonLiteralTagPaths(kind)` is true for a
scripted-alarm predicate only (the alarm load runs the extractor and refuses the alarm),
and `TagPathFindings(kind, source)` returns each rejection with a `Refuses` flag. The
deploy gate refuses on exactly those findings, and the editor draws them as an **error**
(severity 8) where `Refuses` and a **warning** (severity 4) otherwise — so the two cannot
drift. In value and Calculation mode the warning says what the path does at runtime:
those seams read only their *declared* inputs (the literal `ctx.GetTag` paths, which
are what gets subscribed and what re-triggers the script), so a dynamic read returns
Bad (`BadNodeIdUnknown`, null value) unless the same path is also read with a literal
elsewhere in the script; an empty literal path always reads Bad (and an empty
`SetVirtualTag` path throws). Making the gate refuse these in value/Calculation scripts
was declined — it would reject configurations that deploy today. `EditorGateParityTests`
carries dynamic, concatenated, interpolated and empty paths in all three modes.
---
@@ -520,7 +530,10 @@ inline script panel):
- **Hover** — hovering a `{{equip}}/<RefName>` path literal shows an
*"Equipment-relative path — resolved through the equipment's tag reference at
deploy"* note.
deploy"* note. In **Calculation** mode it instead says the token is refused there and
why — a Calculation tag is raw/device-level with no owning equipment, so nothing
substitutes it and the deploy gate refuses the script (#1093, matching the
`OTSCRIPT_EQUIPCALC` marker on the same span). This hover needs no tag catalog.
- **Completions** — typing `{{equip}}/` inside a `GetTag`/`SetVirtualTag` literal
offers the owning equipment's **reference effective names** (needs an equipment
context; inert on the shared ScriptEdit page).