type-inference-validation
Static type inference and validation for navigation paths
Best use case
type-inference-validation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Static type inference and validation for navigation paths
Teams using type-inference-validation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/type-inference-validation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How type-inference-validation Compares
| Feature / Agent | type-inference-validation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Static type inference and validation for navigation paths
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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:
```julia
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:
```julia
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.
```julia
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.
```julia
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.
```julia
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).
```julia
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:
```julia
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:
```julia
# 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
```julia
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
```julia
nav = @late_nav([ALL, pred(x -> x > 5)])
# If input is Vector{String}, predicate fails
# Type error: `(String > 5)` is nonsense
```
### ✓ VALID: Polymorphic path
```julia
nav = @late_nav([ALL, pred(identity)]) # identity always works
# Type: ∀T. Vector{T} → T
# Works for ANY vector type
```
## Error Messages
**Type validation errors are clear**:
```
TypeError: Path composition invalid
Step 1: [ALL]
Input: Vector{Int}
Output: Int
✓ Type check passed
Step 2: [keypath("x")]
Input: Int
Output: ???
✗ TypeError: Cannot apply keypath to Int
keypath requires Dict or record type
Got: Int
Suggestion: Remove [keypath("x")] or ensure input is Dict/Struct
```
## Performance
All type checking happens at **compile time** (during `@late_nav` expansion):
| Operation | Complexity | Notes |
|-----------|-----------|-------|
| infer_type | O(\|path\|) | Single pass through steps |
| validate_path | O(1) | Cached signature lookup |
| polymorphic_infer | O(\|path\|) | Compute most general type |
| **Runtime overhead** | O(0) | Zero cost—all checks are static |
## Composition with Other Skills
**Works with Möbius Filtering**:
1. Möbius filters topological impossibilities
2. Type Inference filters structural impossibilities
3. Both must pass for path to compile
**Works with Color Envelopes**:
Type signatures include color trit information:
```julia
nav = @late_nav([ALL, pred(f)]) # trit = -1 (filtering)
sig = navigator_signature(nav)
# => TypeSignature(..., trit: -1)
# Type system respects color: composition must balance trits AND types
```
**Enables Constraint Generalization** (next skill):
Once types are proven, constraints can be composed and generalized safely.
## Related Skills
- **möbius-path-filtering** - Topological validation (works alongside this)
- **tuple-nav-composition** - Uses type signatures to compose products
- **constraint-generalization** - Builds on type-proven constraints
- **specter-navigator-gadget** - Uses validated types for safe composition
## References
- Gradual typing: "Gradual Typing for Functional Languages" - Siek & Taha
- Refinement types: "Liquid Haskell: Haskell as a Theorem Prover" - Jhala et al.
- Type inference: "Algorithm W: Inference of Data Types" - Damas & MilnerRelated Skills
type-checker
Type Checker Skill
skill-validation-gf3
Skill Validation GF(3) - SLAVE (-1)
performing-soc2-type2-audit-preparation
Automates SOC 2 Type II audit preparation including gap assessment against AICPA Trust Services Criteria (CC1-CC9), evidence collection from cloud providers and identity systems, control testing validation, remediation tracking, and continuous compliance monitoring. Covers all five TSC categories (Security, Availability, Processing Integrity, Confidentiality, Privacy) with automated evidence gathering from AWS, Azure, GCP, Okta, GitHub, and Jira. Use when preparing for or maintaining SOC 2 Type II certification.
merkle-proof-validation
Merkle Proof Validation Skill
javascript-typescript
JavaScript and TypeScript development with ES6+, Node.js, React, and
implementing-continuous-security-validation-with-bas
Deploy Breach and Attack Simulation tools to continuously validate security control effectiveness by safely emulating real-world attack techniques across the kill chain.
implementing-api-schema-validation-security
Implement API schema validation using OpenAPI specifications and JSON Schema to enforce input/output contracts and prevent injection, data exposure, and mass assignment attacks.
exploiting-type-juggling-vulnerabilities
Exploit PHP type juggling vulnerabilities caused by loose comparison operators to bypass authentication, circumvent hash verification, and manipulate application logic through type coercion attacks.
exploiting-prototype-pollution-in-javascript
Detect and exploit JavaScript prototype pollution vulnerabilities on both client-side and server-side applications to achieve XSS, RCE, and authentication bypass through property injection.
active-inference-robotics
Second-order skill synthesizing Patrick Kenny's discrete active inference framework with K-Scale's JAX/MuJoCo robotics stack for predictive coding in robot locomotion
segal-types
Segal types for synthetic ∞-categories. Binary composites exist uniquely up to homotopy. Foundation for topological chemputer.
rezk-types
Rezk types (complete Segal spaces). Local univalence: categorical isomorphisms ≃ type-theoretic identities.