id: eofm_predict
name: Foundation Model Prediction
description: >
  Run a foundation model on satellite imagery for segmentation
  or classification. Preprocessing (band selection, normalization,
  chipping) is driven by the model profile in registry/models/.

  The model handles the full pipeline: STAC search → preprocess →
  chip → infer → reassemble → output GeoTIFF with provenance.
version: 1.0.0
category: inference
type: raster-to-raster
default_implementation: native

inputs:
  - name: imagery
    type: raster
    format: [cog, tif]
    description: Input satellite imagery
    required: true

# Parametric on `params.model:` — bands and target concept are declared by
# the model record in registry/models/<model>.yaml. The resolver must inspect
# the model record (input.bands, output.task) at plan time.
requires: {}

outputs:
  - name: prediction
    type: raster
    format: cog
    dtype: uint8
    # No fixed output concept — depends on the chosen model's task
    # (burned-area, land-cover, crop-type, etc.). Recipes that fix a model
    # should declare the concept at the recipe layer.
    description: Classified raster (segmentation map or class labels)
  - name: confidence
    type: raster
    format: cog
    dtype: float32
    description: Per-pixel confidence scores (optional)

params:
  model:
    type: string
    default: prithvi-eo-2.0-300m
    description: Foundation model name from registry/models/
  task:
    type: select
    options: [segmentation, classification]
    default: segmentation
    description: Prediction task type
  device:
    type: select
    options: [auto, cpu, cuda]
    default: auto
  batch_size:
    type: integer
    default: 16
  overlap:
    type: integer
    default: 32
    description: Overlap in pixels between adjacent chips

execution:
  realtime_max_km2: 10
  cost_per_km2: 0.05
  time_per_km2_sec: 30
  memory_profile: high

cache_policy:
  ttl_days: 365
  invalidate_on: [model_update, source_update]

# 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:
  python:
    function: ml.eofm.predict
    dispatch: folia/compute.py _BUILTIN_OP_MAP
