# catalog/operations/analysis/summary.yaml
#
# Renamed from analysis_summary → summary (ADR-0071 D2, ADR-0036 D6 prefix-drop pattern).
# Wired as builtin:summary@1 — the answer op for terminal type:stats layers.

id: summary
name: Summary Statistics
description: >
  Compute summary statistics for a raster. Returns a selection of: min, max, mean,
  standard deviation, count, and sum. Use as a terminal layer to get a scalar answer
  from a recipe (type: stats in the layer DAG, ADR-0071 D1/D2).
version: 1.0.0
op_identity: builtin:summary@1    # ADR-0065 D4 — bump on numerics change
category: analysis
type: raster-to-stats

inputs:
  - name: raster
    type: raster
    format: geotiff
    description: Input raster to summarize
    required: true

# Structural: scalar summary statistics on any raster. requires: omitted.

outputs:
  - name: summary
    type: stats
    format: json
    description: >
      Summary statistics object. Keys depend on the `stats` param selection;
      the full set the kernel can return is: min, max, mean, std, count, sum.

params:
  stats:
    type: array
    default: [mean, min, max, count]
    description: >
      Statistics to compute. Supported values: mean, min, max, count, std, sum
      (the basic_stats kernel computes all six; this param selects the subset
      returned in the AnswerDoc). Default matches the ADR-0071 D5 AnswerDoc
      example output.

# 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:
  rust-engine:
    op: summary                          # folia-engine dispatch arm (sdk/031)
    function: stats_ops::basic_stats
  python:
    function: geo.stats.summary
    dispatch: folia/compute.py _BUILTIN_OP_MAP

cache_policy:
  ttl_days: 30
  invalidate_on: [source_update]

display_hints:
  table:
    renderer: tanstack-table
  info:
    fields: [min, max, mean, std]
    section: Statistics

ui:
  icon: info
  color: "#2F4F4F"

performance:
  reduction_class: reduce              # per plan-lock.md#placement — scalar output from raster input
