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=1and rungeonemo-services database migrate-layersfirst. The runtime performs no DDL.GEONEMO_COLLECTION_ASSETS_ROOTnames 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 |
|
Create a collection under a new ID |
|
Create a layer collection under an existing catalog name such as |
|
Register layers, ingest records, upload assets, snapshot, bind |
The collection’s owner |
Publish an ontology |
|
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#
Declare the layer with the typed client models in
geonemo.client.layers:CollectionLayer(schema, kind, authority, capabilities) andLayerRecord. Use opaque asset IDs, never backend paths.Pick or write a source adapter. An adapter has
capabilities,page(layer, principal, after=, limit=)andread(layer, principal, record_id, revision_id), and awatermarkthat changes when membership changes. Exact reads return the requested revision or fail. The built-in adapters arecollection-import(records stored through the API),catalogandgkb(read-only views of existing authority). A new adapter is operator composition, added to theadaptersmapping inknowledge/collection_layers/composition.py; it is never uploaded code.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.Optional: bind records to embedding recipes with
LayerRetrievalBridgeandPOST /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.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 |
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.