Add a collection layer#

Add a new kind of data to an existing collection, with its own schema, source authority and capabilities, without changing core models or the vector store.

A collection layer is a versioned, schema-governed view of a collection’s records. A layer declares an arbitrary data_kind, a local JSON Schema, a source authority, a policy and the capabilities it supports. Imagery fields and embeddings are optional. Unknown metadata stays opaque. The code is in knowledge/collection_layers/; the API is under /v1/catalog/collections/{collection_id}/layers (see REST API).

Prerequisites#

  • A development stack or a test environment. Layers are off by default: set GEONEMO_COLLECTION_LAYERS_ENABLED=1 and run geonemo-services database migrate-layers first. The runtime performs no DDL.

  • GEONEMO_COLLECTION_ASSETS_ROOT names a private volume for source assets. Back it up with catalog state, because snapshots pin its bytes.

Who may do what#

Action

Needs

List and read collections, layers and records

services:read

Create a collection under a new ID

tools:execute; the caller becomes its owner

Create a layer collection under an existing catalog name such as sentinel-2

collections:manage

Register layers, ingest records, upload assets, snapshot, bind

The collection’s owner

Publish an ontology

ontology:publish

Collections are not private: any caller with services:read can read every collection. Workload credentials read only the collections they were granted and never change them.

Steps#

  1. Declare the layer with the typed client models in geonemo.client.layers: CollectionLayer (schema, kind, authority, capabilities) and LayerRecord. Use opaque asset IDs, never backend paths.

  2. Pick or write a source adapter. An adapter has capabilities, page(layer, principal, after=, limit=) and read(layer, principal, record_id, revision_id), and a watermark that changes when membership changes. Exact reads return the requested revision or fail. The built-in adapters are collection-import (records stored through the API), catalog and gkb (read-only views of existing authority). A new adapter is operator composition, added to the adapters mapping in knowledge/collection_layers/composition.py; it is never uploaded code.

  3. Register the layer through LayerService.register, which checks source policy and that the adapter supports every declared capability. A layer version is bound to one adapter.

  4. Optional: bind records to embedding recipes with LayerRetrievalBridge and POST /v1/layer-corpus-bindings, so layer records can be embedded and searched. Metadata is not an image tensor, and a layer can have no embedding branch or several.

  5. Optional: propose an ontology that maps concepts and properties to the layer’s fields, then review and publish it. Typed semantic search then runs through POST /v1/ontology/search.

Limits that shape an adapter#

Limit

Value

Record page

The prefix that fits 2 MiB of records, marked partial with a continuation

Single record

At most 2 MiB

Native import

At most 4 MiB, original bytes kept by SHA-256

GeoTIFF window

At most 512 by 512, 16 bands

Snapshot

Up to 16 layers and 1,000 records

Semantic query

1,000 examined rows, 10,000 join pairs, 10 seconds, 2 MiB response

A snapshot pins exact source revisions and asset bytes. Revoked policy or lost bytes deny replay.

Try it offline#

python -m geonemo.knowledge.collection_layers.example
python -m pytest knowledge/tests/test_collection_layer*.py

The example adds an unfamiliar instrument adapter, binds layers to the embedding pipeline with fixture vectors and runs a semantic query. All values are synthetic.

Result#

The layer appears in GET /v1/catalog/collections/{collection_id}/layers, and its records read through the same API. The MCP server exposes read access only, through collection_layers_list, collection_layer_read, ontology_get and ontology_search.