Design doc · product catalog

GeoStack product catalog

A product catalog records what you made, from which inputs, with which code, in a database other people and apps can search. This doc fixes its record, its write path and its backends, and keeps the database itself a deployment choice.

geotoolz 640670c pipekit 9e86a56 geostack 343d60e

Summary

Products are recorded in a catalog that is a protocol, not a particular database. geocatalog owns the record and the path that writes it; which store holds it (PostGIS, pgstac, GeoParquet or another) is chosen per deployment. Nothing on the data path changes: the Icechunk repo stays the truth, and the catalog can be rebuilt from its tags.

End state. The Icechunk repo holds data and its meta/ rows; geocatalog holds the record definition, ProductCatalog, publish and one adapter per backend, each behind its own extra; your apps own the table's DDL and any extra columns; pgstac, if used, is a disposable search index; pipekit-experiment supplies the recipe stamp each record carries.

Ownership rules

The catalog is always derived: data flows down from the repo, and search flows back up to the next task.

Icechunk repo data and meta/ rows; the truth (L2 page, A, B) publish(tag), after the commit geocatalog: record + ProductCatalog CORE_FIELDS · publish · search adapters: PostGIS · pgstac · STAC API · GeoParquet F K upsert, by id Products table (PostGIS) catalog of record; DDL owned by your app sync: upsert_items (optional) L pgstac behind stac-fastapi STAC search index; rebuildable from the table Your apps add columns: alerts, labels, notes pipekit-experiment the recipe stamp (G) search → next task
Blue boxes and arrows are what this doc adds. Writes go down and are idempotent; searches go back up through the same protocol and return a working catalog.
  1. 1

    The Icechunk repo owns the data and its meta/ rows and is the only source of truth. It never reads the catalog.

  2. 2

    geocatalog owns the record (CORE_FIELDS), the ProductCatalog protocol, publish and the adapters. It never imports a database driver outside an adapter's extra, and never creates or alters a table.

  3. 3

    Your app owns the products table's DDL, through one migration tool, and its extra columns. It never writes the core columns except through publish.

  4. 4

    pgstac, when used, owns STAC search. It is fed by a sync through its own functions, never by an ORM, and holds nothing that cannot be rebuilt from the table.

  5. 5

    pipekit-experiment owns the recipe stamp each record carries (recipe registries, G). It never imports geocatalog.

How it composes: one running example

A month of matched-filter products over one site. S Sentinel-2 scenes over the site in June 2026 have each been filtered and committed into the repo s3://bkt/s2_site, on branch mf-v0.3, and the commit tagged mf-v0.3-2026-06 (L2 page, B). Each product is one group products/mf/<scene id> with one meta/ row.

Stage 1: publish the month (Icechunk → geocatalog → products table)

TL;DR. Turn every product row of the tagged snapshot into one catalog record, written so that running it twice changes nothing.

Problem. Let ρ₁, …, ρ_S be the product rows of meta/ at the tag's snapshot σ. Each record carries an id, a footprint g ⊂ ℝ² in EPSG:4326, a time interval [t₀, t₁], a location (the icechunk:// group at σ), and properties. Publishing writes one record per row and is idempotent: upserting the same set twice leaves the catalog unchanged.

r_s = (id, g, [t0, t1], href@σ, properties)
upsert(C, R) = upsert(upsert(C, R), R)
import geocatalog
import geocatalog.storage

# Shapes: R rows in meta/ at the tag; S of them are products

# proposed (A)
catalog = geocatalog.open_catalog("icechunk://s3://bkt/s2_site")  # → R rows
# proposed (F)
products = geocatalog.storage.PostGISCatalog(dsn, table="products")
# r_s = (id, g, [t₀, t₁], href@σ, π), s = 1 … S
# proposed (F)
published = geocatalog.storage.publish(                         # → S records
    catalog,
    products,
    tag="mf-v0.3-2026-06",
    collection_id="products-mf",
)

Today the closest thing is geocatalog.build.append_files, which appends rows to a GeoParquet file and knows nothing about snapshots. The payoff of F is that the record names σ, so it can never point at data that changes under it.

Stage 2: find them next month (products table → geocatalog)

TL;DR. Search the catalog for products over the site, and get back the same kind of working catalog a source search returns.

Problem. For a query with bounds B ⊂ ℝ² and interval T, keep every record whose footprint meets B and whose interval meets T, with the same rule the working catalog uses for its query.

keep(r) ⇔ g ∩ B ≠ ∅ ∧ [t0, t1] ∩ T ≠ ∅
import geocatalog.load

# Shapes: K records kept; per product 1 band on its own H × W grid

# keep(r) ⇔ g ∩ B ≠ ∅ ∧ [t₀, t₁] ∩ T ≠ ∅
# proposed (F)
found = products.search(site_june)                              # → K rows
# proposed (C)
tree = geocatalog.load.load_scenes(found, site_june)            # → K nodes

search returns a GeoCatalog, so everything downstream (load_scenes, matchup, a training dataset) works unchanged. A product made last month is found exactly like a public scene.

Stage 3: trace a map back (catalog → sources, recipe)

TL;DR. From one product, recover the scenes it came from and the code that made it.

Problem. A product α was made by recipe R from inputs x. Its record names x through derived_from links and R through its recipe stamp, so both can be followed without reading any code or folder names.

α = R(x)
import pipekit_experiment

# Shapes: one record; N input items

# proposed (F)
record = products.get("mf-v0.3/S2A_20260601_T30SYJ")
# proposed (F)
inputs = record.links_of("derived_from")                         # → N items
# today* (pipekit-experiment)
recipes = pipekit_experiment.S3ModelRegistry("s3://bkt/recipes/")
# R = registry.load(h_R)
# today (pipekit-experiment)
recipe = recipes.load(record.properties["pipekit:pipeline_hash"])

The stamp is defined on the recipe registries page (G). With inputs at their snapshot and the recipe by hash, the product can be rebuilt and compared, which is that page's gate G1.

Current-state audit

No product catalog exists today; the five pieces it builds on are healthy. Read on main on 12 Nov 2026 at geotoolz 640670c.

SymbolsDefined inUsed byVerdict
STACSourcegeocatalog/_src/sources/stac.pythe source layer (_stac_item.py, gee.py, _extras.py)Healthy. Reads any STAC API, so it reads a pgstac index back with no new code.
to_stac_collectiongeocatalog/_src/storage/stac.py:205no internal callers; public exportHealthy. Groups rows into items; the base publish builds on.
append_files_src/storage/streaming.py:838, exported from geocatalog.buildno internal callers; public exportHealthy. Appends to GeoParquet; becomes the GeoParquet adapter's upsert.
RESERVED_COLUMNSgeocatalog/_src/_schema.py:19both backends, the storage writersHealthy. filepath, start_time, end_time, geometry, bbox: almost the core K needs.
DuckDBGeoCatalog, from_geoparquet_src/backends/duckdb_backend.py, _src/storage/parquet.pyopen_catalog, staging, vector loadingHealthy. The query engine a GeoParquet-backed catalog already has.

Smaller findings:

Workstream F

Publish to a product catalog behind one protocol

geocatalog writes product records through ProductCatalog, and never through a database driver directly.

SymbolDestinationReason
ProductCataloggeocatalog.storageThe protocol: upsert, set_collection, search, get.
publishgeocatalog.storageTagged snapshot to records; builds on to_stac_collection.
PostGISCataloggeocatalog.storage, extra [postgis]Uses K's ProductRecord over your table.
PgstacCatalog, StacApiCataloggeocatalog.storage, extra [stac]upsert_items and search, or the Transactions extension over HTTP (L).
GeoParquetCataloggeocatalog.storagestac-geoparquet files; upsert wraps append_files. No server.
  1. 1

    Define the protocol and the GeoParquet adapter. It needs no server, so the whole path can be tested in CI.

  2. 2

    Write publish. Refuse untagged snapshots, stamp each item with repo, key, snapshot and lineage, upsert by id.

  3. 3

    Add the PostGIS adapter once K's record exists, then the pgstac and STAC API adapters with L.

The refactor, as the user sees it:

# Today:
# today* (geocatalog)
geocatalog.build.append_files(archive, product_paths, extract_row, ...)
# After:
# proposed (F)
geocatalog.storage.publish(catalog, products, tag=tag, collection_id=collection)

Publishing reuses the STAC export that ships today and adds the snapshot stamp, the lineage links and the upsert. The backend hides behind ProductCatalog, whose search returns a working catalog, which closes the loop. Each row's parent extra names the source item it came from.

# geocatalog/_src/storage/products.py
"""Publish a tagged Icechunk snapshot to a product catalog, whatever its backend."""

from collections.abc import Sequence
from typing import Protocol

import pystac

from geocatalog._src.backends.icechunk import IcechunkGeoCatalog
from geocatalog._src.base import GeoCatalog
from geocatalog._src.geoslice import GeoSlice
from geocatalog._src.storage.stac import to_stac_collection

# Shapes: R rows in meta/ at the tag


class ProductCatalog(Protocol):
    """Where products are recorded: one STAC-shaped record per product.

    Adapters, each behind its own extra: PostGISCatalog (ProductRecord over
    your own table), PgstacCatalog (upsert_items and search), StacApiCatalog
    (a STAC API with Transactions) and GeoParquetCatalog (stac-geoparquet).
    """

    def upsert(self, items: Sequence[pystac.Item]) -> int: ...

    def set_collection(self, collection: pystac.Collection) -> None: ...

    def search(self, slice_: GeoSlice) -> GeoCatalog: ...


def publish(
    catalog: IcechunkGeoCatalog,
    products: ProductCatalog,
    *,
    tag: str,
    collection_id: str,
) -> int:
    """Upsert one record per meta/ row of a tagged snapshot.

    Algorithm:
        1. Refuse an untagged snapshot, since only a tag is safe from expiry.
        2. Build the collection and its items from the rows at the tag.
        3. Stamp each item with the repo, key, snapshot and derived_from links.
        4. Upsert the items by id, so a rerun changes nothing.
        5. Point the collection-level asset at repo@tag.

    Args:
        catalog: The repository's catalog.
        products: The product catalog to record into, any backend.
        tag: The Icechunk tag to publish.
        collection_id: The product collection, e.g. "products-mf".

    Returns:
        The number of records upserted.

    Raises:
        ProductCatalogError: If the tag does not exist or the backend refuses
            a write.
    """
    # proposed (F)
    tagged = catalog.at_tag(tag)                                    # → R rows
    # today (geocatalog)
    collection = to_stac_collection(                                # → R items
        tagged,
        collection_id=collection_id,
    )
    # proposed (F)
    stamped = stamp_items(                                          # R → R items
        collection,
        uri=catalog.uri,
        snapshot=tagged.snapshot,
    )
    # proposed (F)
    upserted = products.upsert(stamped)                             # R → ()
    # proposed (F)
    tag_asset = with_tag_asset(collection, uri=catalog.uri, tag=tag)
    # proposed (F)
    products.set_collection(tag_asset)
    return upserted

Which database, and how many

The product catalog is a protocol, not a product. Its record is STAC-shaped (geometry, time, properties, links, assets), so any store that holds a geometry and some JSON can back it. geocatalog talks to an adapter and never to a driver.

BackendGood forCosts
PostgreSQL + PostGIS, your own tableJoins with your other tables (alerts, labels, watchlists); spatial SQL; a schema you ownYou write the search API yourself
pgstac behind stac-fastapiSTAC search for free; STACSource reads it back with no new codeSTAC's schema, and a service to run
GeoParquet (stac-geoparquet)No server; DuckDB queries; lives next to the reposNo live search; a write rewrites a file
Other storesA warehouse or search index your platform already runsOne more adapter to maintain

How many: two catalogs do not need two servers. One PostgreSQL instance can hold a source family (your mirror) and a product family (products/mf, products/plumes, …) as separate collections or tables. Split them when access or lifetime differ, for example private products beside a public mirror; the derived_from links still work across them, since they are URLs.

RecommendedKeep the record STAC-shaped and the backend behind ProductCatalog. Pick the store per deployment: GeoParquet while it is just you, PostGIS or pgstac once apps or other people need live search.
AlternativeCommit to one backend in the code (say, pgstac) and skip the protocol. Less code now, but every other store becomes a rewrite.

Rules that keep the product catalog honest

What one record looks like

{
  "type": "Feature",
  "id": "mf-v0.3/S2A_20260601_T30SYJ",
  "collection": "products-mf",
  "geometry": { … },                          from meta/geometry
  "properties": {
    "datetime": "2026-06-01T11:03:21Z",       from meta/start_time
    "processing:software": { "geotoolz-ops": "0.12" },
    "icechunk:repo": "s3://bkt/s2_site",
    "icechunk:snapshot": "<snapshot id>",
    "icechunk:key": "products/mf/S2A_20260601_T30SYJ"
  },
  "links": [
    { "rel": "derived_from",
      "href": "<source catalog>/collections/sentinel-2-l2a/items/S2A_…" }
  ],
  "assets": {
    "data": {
      "href": "icechunk://s3://bkt/s2_site@<snapshot id>/products/mf/S2A_…",
      "roles": ["data"]
    }
  }
}
Workstream K

One record, three encodings

The core fields are defined once, and the GeoParquet schema, the SQL table and the STAC mapping are generated from them.

SymbolDestinationReason
CoreField, CORE_FIELDSgeocatalog.storageOne definition of the core, by name, Arrow type, SQL type and STAC path.
core_table, ProductRecordgeocatalog.storage, extra [postgis]The SQLAlchemy mapping of the core; maps a subset of the real table.

A product record has a small core that every encoding shares. geocatalog's GeoParquet already reserves filepath, start_time, end_time, geometry and bbox, and treats every other column as an extra; that is almost the same core a PostGIS table or a STAC item needs.

Fieldgeocatalog GeoParquetPostGIS tableSTAC item
identityid extraid, primary keyid
groupingone file per collectioncollectioncollection
wherefilepathfilepathassets.data.href
footprintgeometry, WKBgeometry, SRID 4326, GIST indexgeometry
timestart_time, end_timetwo timestamptzstart_datetime, end_datetime
native CRSfile metadatacrsproj:code
everything elseflat extra columnsproperties JSONB, plus promoted columnsproperties

Keep geocatalog's names everywhere it owns the storage (GeoParquet and your table) and rename only at the STAC edge. They are already in a versioned on-disk schema, so renaming them would need a migration for no gain.

An ORM that maps only the core

A SQLAlchemy model reads and writes only the columns it declares. geocatalog can therefore map the core while your apps add their own columns to the same table (alert status, labels, reviewer notes) without geocatalog knowing they exist. Three conditions make that safe:

Defining the core once, and generating both the table and the Arrow schema from it, keeps the encodings aligned by construction.

# geocatalog/_src/storage/record.py
"""The catalog record's core fields, defined once for SQL, Arrow and STAC."""

import dataclasses

import pyarrow as pa
import sqlalchemy as sa
import sqlalchemy.orm as orm
from geoalchemy2 import Geometry
from sqlalchemy.dialects.postgresql import JSONB


@dataclasses.dataclass(frozen=True)
class CoreField:
    """One core field and its type or path in each encoding.

    Args:
        name: The column name, in GeoParquet and in the table.
        arrow: Its Arrow type in GeoParquet.
        sql: Its SQL type in the table.
        stac: Where it lives in a STAC item.
    """

    name: str
    arrow: pa.DataType
    sql: sa.types.TypeEngine
    stac: str


# proposed (F)
CORE_FIELDS = (
    CoreField("id", pa.string(), sa.Text(), "id"),
    CoreField("collection", pa.string(), sa.Text(), "collection"),
    CoreField("filepath", pa.string(), sa.Text(), "assets.data.href"),
    CoreField(
        "geometry",
        pa.binary(),
        Geometry("GEOMETRY", srid=4326),
        "geometry",
    ),
    CoreField(
        "start_time",
        pa.timestamp("ms"),
        sa.DateTime(timezone=True),
        "properties.start_datetime",
    ),
    CoreField(
        "end_time",
        pa.timestamp("ms"),
        sa.DateTime(timezone=True),
        "properties.end_datetime",
    ),
    CoreField("crs", pa.string(), sa.Text(), "properties.proj:code"),
)


# proposed (F)
def core_table(name: str, metadata: sa.MetaData) -> sa.Table:
    """The columns geocatalog maps; the real table may hold more."""
    columns = [
        sa.Column(field.name, field.sql, primary_key=field.name == "id")
        for field in CORE_FIELDS
    ]
    properties = sa.Column("properties", JSONB)
    return sa.Table(name, metadata, *columns, properties)


# not pinned (sqlalchemy)
class Base(orm.DeclarativeBase):
    pass


# proposed (F)
class ProductRecord(Base):
    """A row of your products table, as far as geocatalog is concerned."""

    __table__ = core_table("products", Base.metadata)

Moving between encodings is one query. DuckDB with its postgres and spatial extensions can COPY the table to GeoParquet, and geopandas does the same with read_postgis and to_parquet. A GeoParquet file is then a dated snapshot of the table, or the seed that fills it.

Workstream L

pgstac as a synced index

Your own PostGIS table is the catalog of record; pgstac is an optional search index fed from it.

SymbolDestinationReason
sync_to_pgstacgeocatalog.storage, extra [stac]Renders records as STAC items and calls pgstac.upsert_items.

pgstac does not fit the ORM pattern. Its items table is partitioned by collection and stores items "dehydrated", with the parts shared by a collection stripped out, so a row is not a plain STAC item and should not be written row by row. Writes go through its SQL functions (upsert_items and friends, which pypgstac and stac-fastapi call) and reads through its search. Objects of your own also belong outside the pgstac schema, since its migrations may remove them.

The way out is to decide which table is the catalog of record. Make it your own PostGIS table, and treat pgstac as a search index fed from it:

  Icechunk repo     meta/ + products/        truth for the data
      │  publish(tag), after the commit
      ▼
  products table    PostGIS, your schema     catalog of record
      │  ProductRecord maps the core; apps add their own columns
      │  sync: render STAC items, call pgstac.upsert_items   optional
      ▼
  pgstac            STAC search index        rebuildable from the table
      │  stac-fastapi
      ▼
  STAC API          STACSource reads it back, other tools find your products
# geocatalog/_src/storage/pgstac_sync.py
"""Copy product records into pgstac as STAC items, after they are committed."""

import json

import sqlalchemy as sa
import sqlalchemy.orm as orm

# Shapes: N records in one collection


def sync_to_pgstac(session: orm.Session, engine: sa.Engine, collection: str) -> int:
    """Upsert every record of a collection into pgstac; a rerun changes nothing."""
    # proposed (F)
    query = sa.select(ProductRecord).where(ProductRecord.collection == collection)
    # not pinned (sqlalchemy)
    records = session.scalars(query).all()                         # → (N,)
    # proposed (F)
    items = [to_stac_item(record) for record in records]           # (N,) → (N,)
    payload = json.dumps(items)
    # not pinned (pgstac): its SQL function, never row INSERTs
    statement = sa.text("SELECT pgstac.upsert_items(CAST(:items AS jsonb))")
    with engine.begin() as connection:
        connection.execute(statement, {"items": payload})
    return len(items)
RecommendedYour PostGIS table is the catalog of record, mapped by ProductRecord; pgstac, if you want STAC search, is an index synced from it with upsert_items. One ORM, one schema owner, and pgstac stays disposable.
Alternativepgstac alone, with no table of your own: PgstacCatalog writes with upsert_items and reads with search. Simpler to run, but your apps' extra fields must live inside the STAC item, and there is no ORM.

Testing gates

Each workstream merges only when its gate passes. This corrects two ids from the L2 page: its F4 and F5 belong to the new workstreams, so they are K1 and L1 here.

GateWorkstreamPasses when
F1 RebuildFDropping a product collection and publishing every tag again gives the same record ids, geometries, hrefs and links.
F2 Commit firstFA publish that fails after the commit leaves the repo valid, and a rerun gives the same catalog as an uninterrupted run.
F3 Round tripFOn every adapter, products.search over the site returns rows whose filepaths open the same groups that load_scenes reads, and every derived_from link resolves in the source catalog.
K1 EncodingsKA record written through ProductRecord, exported to GeoParquet, rendered as a STAC item and loaded back keeps every core field: equal strings, equal times, geometries equal to 1e-9 degrees.
L1 Index parityLAfter sync_to_pgstac, a pgstac search over the site returns the same ids as a PostGIS query on the products table; rerunning the sync changes no row.

Sequencing and risks

The record first, because every adapter depends on it; then publishing with the server-free adapter; then the databases.

  K  one record, three encodings
      │
      ◆ K1
      │
  F  publish: GeoParquet adapter, then PostGIS
      │
      ◆ F1 · F2 · F3
      │
  L  pgstac sync                 optional
      │
      ◆ L1

Sources