type-inference-validation
БесплатноБез исполняемых скриптовНе проверенStatic type inference and validation for navigation paths
от plurigrid★ 73 звезды на GitHubОб этом скилле
Type Inference Validation
Core Concept
Static type validation that rejects invalid path compositions before caching. Every Navigator path must prove type compatibility with its input structure—this skill enforces that proof.
Works alongside Möbius filtering as a second line of defense: Möbius eliminates topological impossibilities, Type Inference eliminates structural impossibilities.
Why Type Validation?
Consider this dangerous scenario:
data_numbers = [1, 2, 3, 4, 5]
data_dict = Dict("x" => 10, "y" => 20)
# This path makes sense for numbers
nav1 = @late_nav([ALL, pred(iseven)]) # Type ✓: Vector → Numbers → Numbers
# But what if someone mistakenly uses it on the dict?
nav_select(nav1, data_dict, x -> [x])
# => IndexError! (dicts don't support ALL enumeration this way)
Type Inference Validation prevents this at compile time, not runtime.
Architecture
Type System
Each Navigator carries a type signature:
Navigator{InputType, OutputType, PathSteps}
Examples:
nav_vector = Navigator{Vector, Vector, [ALL, pred(f)]}
nav_dict = Navigator{Dict, Vector, [keypath(k), ALL]}
nav_sexp = Navigator{SExpression, Symbol, [sexp_nth(2), SEXP_HEAD]}
Type Refinement Pipeline
Input Type
↓
@late_nav(path_expr) triggers validation
↓
Type each step in path:
[ALL] : Vector{T} → T
[keypath(k)] : Dict{K,V} → V
[pred(f)] : T → T (preserves type)
[INDEX(i)] : Vector{T} → T
[SEXP_HEAD] : SExpr → Symbol
↓
Unify step outputs with next step inputs
↓
Final output type computed
↓
Cache with type signature
↓
Accept or Reject
Type Incompatibility Detection
| Step | Input Type | Output Type | Valid? |
|---|---|---|---|
[ALL] |
Vector{T} | T | ✓ |
[ALL] |
Dict{K,V} | ⚠️ (ambiguous) | ✗ |
[keypath(k)] |
Dict{K,V} | V | ✓ |
[keypath(k)] |
Vector{T} | ✗ | ✗ |
[pred(f)] |
T | T | ✓ |
[INDEX(i)] |
Vector{T} | T | ✓ |
[INDEX(i)] |
Dict | ✗ | ✗ |
API
Type Inference
infer_type(path_expr, input_type) :: Result{OutputType, Error}
Computes the output type of a path given an input type.
infer_type([ALL, pred(iseven)], Vector{Int})
# => Result(Int) # outputs Int values
infer_type([keypath("x"), ALL], Dict{String, Vector{Int}})
# => Result(Int) # navigates to x, then enumerates integers
infer_type([keypath("x")], Vector{Int})
# => Result(TypeError("Cannot apply keypath to Vector"))
validate_path(navigator::Navigator, input_type) :: Bool
Checks if a Navigator is compatible with a given input type.
nav = @late_nav([ALL, pred(f)])
validate_path(nav, Vector{Int}) # => true
validate_path(nav, Dict{String, Int}) # => false ✗
# Causes @late_nav to reject the Navigator before caching
Type Signatures
navigator_signature(nav::Navigator) :: TypeSignature
Returns the full type signature of a cached Navigator.
nav = @late_nav([ALL, pred(iseven)])
sig = navigator_signature(nav)
# => TypeSignature(
# input: Vector{T},
# output: T,
# constraints: [iseven(T)],
# steps: [[ALL], [pred(iseven)]],
# valid_for: Vector{Int}, Vector{BigInt}, ...
# )
Polymorphic Inference
polymorphic_infer(path_expr) :: PolymorphicType
Infers the most general type for a path (before knowing input type).
polymorphic_infer([ALL, pred(iseven)])
# => ∀T. (T ∈ Enumerable, T ∈ HasEven) → T
# This means: works for ANY type T that:
# - Can be enumerated (Vector, Set, List, etc.)
# - Has an iseven() method defined
Integration with Caching
Cache keys now include type information:
cache_key = hash((path_expr, inferred_type))
# Different input types → different cache entries
nav_vec = @late_nav([ALL, pred(f)]) # cache for Vector
nav_set = @late_nav([ALL, pred(f)]) # cache for Set (if compatible)
# => Different NavigatorObjects, despite same path!
Refinement Types
Supports refinement types for predicates:
# pred(iseven) refines Int → EvenInt
# pred(x -> x > 5) refines Int → IntGt5
nav = @late_nav([ALL, pred(x -> x > 5)])
# Type: Vector{Int} → IntGt5
# (output is proven to be > 5)
Refinement types enable:
- Automatic constraint propagation downstream
- Proof that outputs satisfy predicates without re-checking
- Composition of constraints with type safety
Type Mismatch Examples
❌ INVALID: Wrong container type
nav = @late_nav([keypath("name"), ALL])
# Type error: keypath returns a string, ALL requires enumerable
# KeyPath{Dict, String} → String
# ALL{String} → ✗ (String not enumerable in that way)
❌ INVALID: Incompatible predicate
nav = @late_nav([ALL, pred(x -> x > 5)])
# If input is Vector{String}, predicate fails
# Type error: `(String > 5)` is nonsense
✓ VALID: Polymorphic path
nav = @late_nav([ALL, pred(identity)]) # identity always works
# Type: ∀T. Vector{T} → T
# Works for ANY vector
Установить type-inference-validation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл type-inference-validation?
Static type inference and validation for navigation paths
Как установить скилл type-inference-validation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл type-inference-validation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
slack-gif-creator
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
от Anthropicautomate-this
Analyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
от GitHubfrom-the-other-side-vega
Patterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
от GitHubplantuml-ascii
Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…
от GitHub