Skip to content
Back to skills

Ontoplato Query

ASecurity

Query OntoPlato ontology catalogs, object classes, attributes, relationships, distinct values, business knowledge, and published metric views, and write and execute ontology DSL queries.

  • 13 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentspythongonodeapibackend

Works with

  • cursor
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add ontomato-ai/OntoPlato --skill ontoplato-query --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ontoplato Query?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ontoplato Query
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ontomato-ai-ontoplato-query/badge)](https://www.skillsdirectory.com/skills/ontomato-ai-ontoplato-query)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ontoplato-query
description: Query OntoPlato ontology catalogs, object classes, attributes, relationships, distinct values, business knowledge, and published metric views, and write and execute ontology DSL queries.
compatibility: Requires Node.js 24+ and an authorized OntoPlato ontology service credential.
---

# Query

This skill is the single authoritative ontology query and DSL specification across OntoPlato. Run commands from the workspace root as `node <this-skill>/scripts/ontomato.mjs <command>`, where `<this-skill>` is the directory containing this `SKILL.md`; `@file` arguments are resolved relative to the workspace root.

## Connection

The script automatically adapts to the runtime environment in this order, without separate command sets:

1. **Platform-hosted runs**: The host injects `ONTOMATO_EXECUTION_CALLBACK` (sent as `X-Ontomato-Callback-Credential`) and run context; `run-metric` automatically uses the host-injected `ONTOMATO_RETRIEVAL_CALLBACK_URL`.
2. **External environment variables**: Set `ONTOMATO_ONTOLOGY_URL` (including any ontology gateway prefix, or derived from `ONTOMATO_URL` as `<ONTOMATO_URL>/api/data-query`) together with `ONTOMATO_API_KEY` (sent as `X-API-Key`) or `ONTOMATO_TK` (sent as `tk`).
3. **Configuration fallback**: When those environment variables are unset, the script falls back to `application.yml` in the current working directory or this skill directory (supporting `ontologyUrl`, `envUrl`, `apiKey`, `tk`, or `user`/`password`/`domainId` for automatic RSA SSO login).

`ONTOMATO_LANGUAGE` and `ONTOMATO_CORRELATION_ID` are forwarded when set. `run-metric` honors `ONTOMATO_OUTPUT_DIR` as the output root (default `outputs`).

## Commands

| Command | API and output |
| --- | --- |
| `dataset-desc` | `POST /ontology/query/overview`; prints the ontology dataset overview description |
| `classes` | `POST /ontology/query/overview`; prints visible class names and descriptions |
| `schema <class>...` | `POST /ontology/query/schema`; prints enabled fields and direct relationships for the named classes (omitting empty fields) |
| `relationships <class>...` | `POST /ontology/query/schema`; prints only direct relationships for the named classes |
| `distinct-values <class> <attribute> [--like text] [--limit n]` | `POST /ontology/query/distinct-values`; prints distinct values and the completeness marker (`--limit` defaults to 100) |
| `execute-dsl <json\|@file>` | `POST /ontology/query/execute-dsl`; executes one ontology DSL object and prints rows and execution metadata |
| `knowledge <question> [--limit n]` | `POST /ontology/query/knowledge/search`; searches matching business knowledge entries (`--limit` defaults to 10) |
| `metrics <question> [--cursor id] [--limit n]` | `POST /ontology/query/metrics/search`; searches published metric views, revisions, and pagination cursor (`--limit` defaults to 10) |
| `execute-metric <id> --revision <revision> [<json\|@file>] [--binding id]` | `POST /ontology/query/metrics/execute`; executes the specified metric revision directly and prints the result JSON |
| `recall-metrics <question>` | `POST /ontology/query/metrics/recall`; recalls candidate published metrics for a natural-language question, failing with `RECALL_TIMEOUT` after 3 seconds |
| `run-metric <id> --revision <revision> --question <question> [--binding id \| --params <json\|@file>]` | Starts a formal metric retrieval run, waits for completion, writes original bytes to `outputs/metrics/<key>.dataset.json`, and prints `{path,title,rowCount,columns,truncation,receiptId}` |

Argument and output conventions:

- `--binding` selects an existing preset parameter set; `--params` supplies a parameter JSON object. They are mutually exclusive (pass the complete parameter object via `--params` whenever changing any parameter).
- `execute-metric` prints query JSON directly for quick inspection; use `run-metric` when you need a traceable formal dataset file (`.dataset.json`) with a receipt.
- A command that succeeds prints its result on stdout and exits 0. A command that fails prints only the service's own error message on stderr (for example `limit must be between 1 and 100`), prints nothing on stdout, and exits 1.
- Downstream scripts must check the exit status first and parse stdout only after success. Never merge stderr into a file you parse (no `2>&1`), or an error string will be parsed as JSON and hide the real failure.
- Parse JSON output with `node` or `python3` (`jq` is not installed).

## Ontology DSL Specification

Send a single JSON object to `execute-dsl` containing `problem` (the question) and `answer.steps` (an ordered array of query steps; a one-step query still uses a `steps` array). Use exact class names, field names, field types, and relationship names returned by `schema`, without adding a leading slash.

### Graph patterns and filters

- Each step has `graph` and `output`. `graph.patterns` lists graph patterns, and `graph.pattern_logic` (`and` or `or`) combines multiple patterns.
- Each pattern contains `objects`. Every object needs a pattern-unique integer `idx`, a `variable` for field references, a class name `class`, and optional `conditions`.
- Put `relationship` in the same pattern as its objects. Each edge uses `from` and `to` pointing to the source and target object `idx` of the declared relationship. Read `fromclass`/`fromField` and `toclass`/`toField` from `schema`: the edge connects the `from` object's `fromField` to the `to` object's `toField` (for a self-relationship such as `id` → `parent_id`, the parent is `from` and the child is `to`). `type` takes an array of declared relationship names (`["*"]` means all), `min_hops: 1`, and `max_hops: 1` for relational key columns; on sources supporting multi-hop traversal, `-1` means unlimited hops. In a multi-object pattern, edges must connect all objects; a single object can omit `relationship`; query unrelated objects separately.
- An object's `conditions` can contain `properties`, `text`, `vector`, and `timeseries`. Different constraint types combine with AND; an omitted type adds no constraint.
- A property condition has `field`, `operator`, and `value` matching the field's declared type. Supported operators: `=`, `!=`, `>`, `>=`, `<`, `<=`, `between` (two-element array), `like`, `not like`, `in` (array), `is`, and `is not` (with JSON `null`). For list exclusion, wrap `in` inside `not`. Compound logic uses `operator: "logic"` with `and`, `or`, or `not` arrays (put exactly 1 predicate in `not`; to negate multiple conditions, wrap a single `and`/`or` inside it). Text compares lexicographically (`'100' < '45'`); when numbers stored as text need numeric comparison or `avg`/`sum`, convert them in a Python package per `ontoplato-data-retrieval`. `null` matches none of `=`, `!=`, `like`, `not like`, or `in` (even under `not`); add an explicit `is null` with `or` when null rows belong in the result.
- Full-text `text` accepts `fields` (array of field names), `query`, `operator` (`match`, `phrase`, or `fuzzy`), and `boost` (weight).
- Vector `vector.properties` uses `operator: "logic"` with `and`/`or` arrays; each entry specifies vector `field`, text `query`, and optional `topK` (1–50, default 20). It finds the `topK` files nearest to `query` across the whole class and keeps the objects that own them (an object owning multiple matching files counts once, so fewer than `topK` objects may match). Vector search has no relevance threshold and returns no score, returning nearest neighbors even when no file is directly relevant.
- Time-series `timeseries.properties` uses `operator: "logic"` with `and`/`or` arrays; each entry names bucket `field`, `time_range`, `conditions`, and a non-empty `asserts` array. `time_range` `start`/`end` use `yyyy-MM-dd HH:mm:ss` (empty `end` means now). Metric conditions combine with AND, each having `metric`, `operator`, and `value` (`name` supports `=`/`like` with a string or `in` with a string array; `value` supports `=`/`>`/`>=`/`<`/`<=` with a number). Each assertion has `function` (`avg`/`sum`/`max`/`min`), `interval` (positive integer followed by `m`/`h`/`d`/`w`/`M`/`y`), numeric comparison `operator`, and `value`; assertions combine with AND on the filtered time series.

### Output, aggregation, and temporary tables

- `output.fields` is the projection list; a normal projection specifies `variable`, `field`, and `as` (output alias). `to_user: true` returns that step's result.
- **Only a step with a single object and no relationship can aggregate, group, or deduplicate.** A step with two or more objects must never use `function`, `distinct`, or `group_by` (not even for a total count or quick check): first join and project detail columns with `to_user: false` and `save_table`, then compute from that temporary table in the next step. Joined detail rows without calculation can be returned in one step. Name temporary tables starting with a letter (for example `temp01`); subsequent steps use that exact `save_table` name as `class` and its projected `as` aliases as fields. Temporary tables live only for one DSL execution, and object filters belong on the step that saves them.
- Aggregate with `function`: `count`, `sum`, `avg`, `min`, or `max`; `distinct: true` deduplicates output or aggregate inputs. `group_by.fields` lists `variable` and `field` for each group key; all non-aggregated input fields in projection, arithmetic, or sorting must appear in `group_by.fields`. `group_by.having` filters groups using `variable`, `field`, `function`, optional `distinct`, `operator` (`=`/`!=`/`>`/`>=`/`<`/`<=`), and `value`.
- Numeric arithmetic reads from a temporary table using a projection with only `expr` and `as` (supporting field references, numbers, parentheses, and `+` `-` `*` `/`); place aggregates in `function` fields. Arithmetic, grouping, and sorting follow each field's declared type.
- To return a vector field or time-series bucket field, project it into a temporary table first. In the later step, a vector projection may specify `query` and optional `topK` to return matching files: it finds files the same way as a vector condition, keeps only rows whose object owns a matching file, and lists each row's matching files nearest first; without `query`, it returns all files. Each returned file entry contains `path`, `text`, and optional `name` when an original filename was saved; results with a `query` default to similarity order unless sorting is specified. A time-series bucket projection may specify `time_range`, metric `conditions`, and optional `function`/`interval` for in-bucket aggregation, outputting timestamp, metric name, value, and labels together. Keep vector and bucket fields out of group keys, HAVING, and sort keys.
- `sort.fields` lists `variable`, `field`, and `order` (`asc` or `desc`); to sort by a calculated result, use its output alias and omit `variable`. `limit` takes `count` and `offset` and belongs only on the final step (where it can share the step with sorting and grouping). Omitting `limit` applies a default cap of 20,000 rows; use explicit pagination or aggregation for complete results.

Source adapters reject constructs they do not support. Use the complete example below as a query shape and replace placeholders with actual class, field, and relationship names from `schema`.

### Complete example

```json
{
  "problem": "Summarize matching records by category and bounds",
  "answer": {
    "steps": [
      {
        "graph": {
          "patterns": [
            {
              "objects": [
                {
                  "idx": 0,
                  "variable": "record",
                  "class": "record",
                  "conditions": {
                    "properties": {
                      "operator": "logic",
                      "and": [
                        {"field": "status", "operator": "=", "value": "active"},
                        {"field": "reading", "operator": "between", "value": [20, 30]},
                        {"field": "length", "operator": ">", "value": 10},
                        {"field": "name", "operator": "in", "value": ["Example A", "Example B"]},
                        {"field": "label", "operator": "like", "value": "sample"},
                        {"field": "owner", "operator": "is not", "value": null},
                        {"field": "upper_bound", "operator": ">", "value": 0}
                      ]
                    },
                    "text": {"fields": ["description"], "query": "example terms", "operator": "match", "boost": 1.0},
                    "vector": {
                      "properties": {
                        "operator": "logic",
                        "and": [{"field": "feature_vector", "query": "example terms", "topK": 10}]
                      }
                    },
                    "timeseries": {
                      "properties": {
                        "operator": "logic",
                        "and": [
                          {
                            "field": "metrics",
                            "time_range": {"start": "2024-01-01 00:00:00", "end": "2024-01-31 23:59:59"},
                            "conditions": [
                              {"metric": "name", "operator": "=", "value": "example_metric"},
                              {"metric": "value", "operator": ">", "value": 80}
                            ],
                            "asserts": [
                              {"function": "avg", "interval": "1h", "operator": ">", "value": 80},
                              {"function": "max", "interval": "1m", "operator": "<", "value": 80}
                            ]
                          }
                        ]
                      }
                    }
                  }
                },
                {"idx": 1, "variable": "collection", "class": "collection"}
              ],
              "relationship": [{"from": 0, "to": 1, "type": ["record_collection"], "min_hops": 1, "max_hops": 1}]
            }
          ],
          "pattern_logic": "and"
        },
        "output": {
          "to_user": false,
          "save_table": "temp01",
          "fields": [
            {"variable": "record", "field": "id", "as": "record_id"},
            {"variable": "record", "field": "category", "as": "category"},
            {"variable": "record", "field": "lower_bound", "as": "lower_bound"},
            {"variable": "record", "field": "upper_bound", "as": "upper_bound"}
          ]
        }
      },
      {
        "graph": {"patterns": [{"objects": [{"class": "temp01", "variable": "temp01", "idx": 0}]}], "pattern_logic": "and"},
        "output": {
          "to_user": true,
          "fields": [
            {"variable": "temp01", "field": "category", "as": "category"},
            {"variable": "temp01", "field": "lower_bound", "as": "lower_bound"},
            {"variable": "temp01", "field": "upper_bound", "as": "upper_bound"},
            {
              "variable": "temp01",
              "field": "record_id",
              "function": "count",
              "distinct": true,
              "as": "record_count"
            },
            {"expr": "(temp01.lower_bound / temp01.upper_bound) * 100", "as": "bound_percent"}
          ],
          "sort": {
            "fields": [
              {"field": "record_count", "order": "desc"},
              {"variable": "temp01", "field": "category", "order": "asc"},
              {"variable": "temp01", "field": "lower_bound", "order": "asc"},
              {"variable": "temp01", "field": "upper_bound", "order": "asc"}
            ]
          },
          "limit": {"count": 100, "offset": 0},
          "group_by": {
            "fields": [
              {"variable": "temp01", "field": "category"},
              {"variable": "temp01", "field": "lower_bound"},
              {"variable": "temp01", "field": "upper_bound"}
            ],
            "having": [
              {
                "variable": "temp01",
                "field": "record_id",
                "function": "count",
                "distinct": true,
                "operator": ">",
                "value": 5
              }
            ]
          }
        }
      }
    ]
  }
}
```

### Execution results

Run `execute-dsl @query.json`. The backend endpoint takes one DSL object and derives caller identity and domain from credentials. Data rows live at `data[0].answer`, with each row keyed by its output `as` aliases. A Python function calling `query_runtime.query(dsl)` with the DSL dictionary receives the same row array. Preserve nulls and source limits; a capped response includes `truncated: true`, `rowLimit`, and `truncationHint` in `data[0]`. An empty partial result does not establish that no matching objects exist.

Files in this skill

  • SKILL.md16.4 KB
  • application.yml233 B
  • ontoplato.json68 B
  • scripts/ontomato.mjs24.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.