Skip to content

Typed pin literals: a value typed on an unwired input takes the input's type (ADR 0049) - #7

Merged
lpalbou merged 2 commits into
mainfrom
fix/typed-pin-literals
Nov 2, 2026
Merged

lpalbou merged 2 commits into
mainfrom
fix/typed-pin-literals

Conversation

@lpalbou

@lpalbou lpalbou commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Operator ruling 2026-11-02: a value typed on an unwired input must take the type the graph gives it, not always text. Since 0.13.0, Compare a wired to 5 with 5 typed in b compared 5 == "5" (false, silently). Root ADR 0049 (lpalbou/AbstractFramework, docs/adr-0049-typed-pin-literals).

What changes

  • Pin.typeVar on node templates: Compare a/b; Coalesce a/b/result; default with the read value of Get Property, Get Element, Get Random Element, Get Variable. Read from the template, never from a saved pin, so old flows resolve too.
  • src/utils/pinLiterals.ts (one module): resolves an input's literal type (declared type; else the type variable from a pin the node types itself, then wired inputs, then output consumers, through other generic nodes, cycle-safe, disagreeing wires = unresolved; else text), parses typed text by kind (decimal-number grammar, true/false, JSON object/list; never guesses from the text), converts stored values exactly or reports a problem.
  • Store: the existing relay-typing subscription now also runs typePinLiterals, so any rewire (connect, delete, undo, the assistant) converts exact values; loadFlow does the same and records literalsRetypedOnLoad, shown as a toast; the returned baseline stays the flow as stored (unsaved changes until saved).
  • Card: TypedLiteralInput for any inputs (keeps the draft while focused, empty = no value) with a type tag (number / text / true/false / JSON / list); a mismatched value is outlined and explained under its row, for declared number/boolean pins too.
  • Run checks: a mismatched value is a blocking preflight issue with the card's words.
  • Wait Until duration is text when the node waits for a timestamp (the runtime reads it as text then).
  • Unresolved inputs keep a stored value's own JSON type (generator [] defaults in deep-research / ltm flows stay lists); new typed text is text.

Evidence

  • npx vitest run: 144 files / 1364 tests pass; npm run lint clean; npm run build OK.
  • New: src/utils/pinLiterals.test.ts (20), src/components/nodes/typedLiteral.test.tsx (3). Mutation check: removing Compare b's typeVar and the store conversion turns 7 tests red.
  • scripts/typed_literals_smoke.py (added to the CI smokes job, real AbstractRuntime, no network): typed fixture 5 == 5 and 10 > 9 true; the 0.13.0-style fixture runs as stored (false). The unit test proves opening the 0.13.0 fixture yields exactly the typed fixture's values.
  • All 193 shipped example/fixture flows: 0 values converted, 0 flagged on load.
  • Screenshots 1440 px and 400 px (number tag, text tag, flagged abc) in the author's scratch.

Not changed

  • AbstractRuntime: it already executes pin defaults as stored (_normalize_pin_defaults). Its Compare returns false when Python refuses 10 > "9"; making that a visible error is a separate runtime decision (ADR 0049 follow-up).

…'s type

A number input stores a number, a true/false input a boolean; an any input
that shares a type variable with others of its node (Pin.typeVar on the
template: Compare a/b, Coalesce, Get Property/Element/Random Element and
Get Variable default+value) takes the type wired to them, resolved through
generic nodes; with nothing wired a typed value is text and a stored value
keeps its own JSON type. One pure module (utils/pinLiterals.ts) resolves,
converts exactly on rewire (store subscription and loadFlow) and flags
what does not convert (card row, type tag, blocking run check). Flows saved
by 0.13.0 are converted on open with a notice. Runtime smoke runs the typed
and the 0.13.0-style fixtures; catalog marks [type T] pins. Root ADR 0049.
…niencies, Add to List item and number-to-text formatting documented; legacy runtime expectation moves to AbstractRuntime's Compare test
@lpalbou
lpalbou merged commit ddf42f7 into main Nov 2, 2026
2 checks passed
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.

1 participant