id: embedding_similarity
name: Embedding Similarity
description: >
  Compute cosine similarity between a reference embedding vector and
  all other embeddings in a feature collection. Typically used after
  eofm_embed to find spatially similar regions.
version: 1.0.0
category: analysis
type: vector-to-vector

inputs:
  - name: embeddings
    type: vector
    description: FeatureCollection with emb_0..emb_N properties per feature
    required: true

# No `embedding` concept exists in registry/concepts/ yet (foundation-model
# embeddings live in the Tessera/AEF/Clay substrate, not the concept DAG).
# Gap candidate for a future ticket. requires: omitted.

outputs:
  - name: similarity
    type: vector
    format: geojson
    description: Input features with added similarity property (0-1)

params:
  reference_chip:
    type: integer
    required: true
    description: Index of the reference feature to compare against
  metric:
    type: enum
    enum: [cosine]
    default: cosine
    description: Distance metric

# backends: audited 2026-08-14 (defect 50). A key means a runtime that DISPATCHES this op —
# folia-engine `dispatch_op` (products/sdk/folia-engine/src/lib.rs), a `registerOp`/OP_TABLE
# entry in packages/compute, `_BUILTIN_OP_MAP` in folia/compute.py, or a backend manifest
# (folia/backends/*/backend.yaml).
backends:
  js:
    function: embedding_similarity
