Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ontoplato Data Retrieval?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ontomato-ai-ontoplato-data-retrieval)
---
name: ontoplato-data-retrieval
description: Deliver a pure DSL or Python query logic package as a formal dataset (.dataset.json) by rerunning it through OntoPlato under the user's authorization.
compatibility: Requires Node.js 24+ and an authorized OntoPlato ontology service credential.
---
# Data Retrieval
Every result table must be delivered as a formal dataset (`.dataset.json`): the server reruns your query logic under the user's permissions, records column-level lineage and an execution receipt, and writes the immutable result file. Run commands from the workspace root as `node <this-skill>/scripts/dataset.mjs <command>`, where `<this-skill>` is the directory containing this `SKILL.md`; `@file` paths are relative to the workspace root.
## Connection and Commands
The script adapts automatically to the runtime environment:
- **Platform-hosted retrieval**: The host injects `ONTOMATO_RETRIEVAL_CALLBACK_URL` and `ONTOMATO_EXECUTION_CALLBACK` and owns the retrieval lifecycle. Pass `--active` to `deliver` / `preview`; never call `begin` or `close`.
- **External standalone runs**: Set `ONTOMATO_ONTOLOGY_URL` (or `ONTOMATO_URL`, deriving `<ONTOMATO_URL>/api/data-query`) and `ONTOMATO_API_KEY` or `ONTOMATO_TK` (falling back to `application.yml` in the current working directory or skill directory), plus optional `ONTOMATO_LANGUAGE`, `ONTOMATO_CORRELATION_ID`, and `ONTOMATO_OUTPUT_DIR` (default `outputs`). Omit `--active`, run `begin @work/question.json` (with `{"question":"..."}`) before delivering, and run `close` when finished. Retain `work/.retrieval-*.json` and `work/.dataset-*.json` for external reconciliation.
| Command | Purpose |
| --- | --- |
| `deliver <work/files...> --meta @work/delivery.json [--params @work/parameters.json] [--out outputs/<name>.dataset.json] [--active]` | Reruns the logic package under the user's authorization, writes the formal file under `outputs/` (default `outputs/result-<hash>.dataset.json`), and prints `{path,rowCount,columns,truncation,receiptId,filesSha256}` (plus `rows` when rowCount ≤ 10) |
| `preview <work/files...> --meta @work/delivery.json [--params @work/parameters.json] [--active]` | Runs with the same arguments and prints the full dataset JSON without writing an output file; use only when you have a real doubt about the result |
| `begin @work/question.json` | Starts or resumes an external retrieval session (forbidden inside platform runs) |
| `close` | Closes the current external retrieval session (forbidden inside platform runs) |
All submitted source files must live under `work/` with no symbolic links; `--out` must end in `.dataset.json` under the output root (default `outputs/`).
## Query Logic Package
Choose the smallest set of files that produces one result table:
- **Pure DSL (preferred)**: `work/q.json` is a single ontology DSL object (not an array; see the `ontoplato-query` skill for full DSL syntax and `execute-dsl`). A single plain DSL file is already a complete package. Use pure DSL whenever it can express the whole calculation—it runs in the database, preserves traceable lineage, and can be read directly by quality checks and reuse.
- **Python with DSL**: Use only when one step cannot be expressed in DSL (for example, averaging an age stored as text or combining two independent queries into a ratio). Write `work/main.py` and supporting Python or DSL JSON files under `work/`, read data through `query_runtime.query(dsl)`, and pass every source file to `deliver` (for example, `node <this-skill>/scripts/dataset.mjs deliver work/main.py work/queries/staff.json --meta @work/delivery.json --active`). Supply business input values via `--params @work/parameters.json` (a JSON object). See "Python Packages" below for the exact layout.
## Delivery Metadata (`work/delivery.json`)
`work/delivery.json` describes the table for readers and has exactly these four top-level fields:
```json
{
"title": "Active employees",
"columnLabels": {"headcount": "Active employees"},
"assumptions": ["Employees count only status = active, the business knowledge's default."],
"selfCheck": {"scope": "", "filters": "", "grain": "", "denominator": "", "nullGroups": ""}
}
```
- `title`: Human-readable table title.
- `columnLabels`: A user-language label for every output column key.
- `assumptions`: Every scope decision you made (filters, deduplication, grouping) and why.
- `selfCheck`: Short text for each field explaining the covered population (`scope`), applied filters (`filters`), single-row grain (`grain`), denominator if a share exists (`denominator`), and treatment of empty/unknown groups (`nullGroups`); write `"not applicable"` where one does not apply.
The host fills in the question, decisions, column source graph, file hashes, and receipt automatically. A delivery is your own query logic; do not search for or reuse a published metric here.
## Delivery Rules
- **One table per delivery**: Each `deliver` produces one table. A question needing multiple tables gets multiple `deliver` calls with distinct `--out` paths; do not merge unrelated results with Python.
- **Write directly into the delivered file**: Deliver as soon as the logic is ready—`deliver` executes the query and reports any error. To inspect rows first, run that exact file with `ontoplato-query`'s `execute-dsl`, then deliver it unchanged rather than rewriting it. Use `preview` only for a real doubt about the result.
- **Reuse small-table receipts**: When the receipt includes `rows` (≤ 10 rows), use them directly without reopening the file.
- **Never edit delivered artifacts**: Reference the returned formal `.dataset.json` path; never hand-edit its rows or receipt.
### File Fields
For detailed records, check the ontology schema for file fields relevant to the request and return them as separate dataset columns with user-language labels. When the user asks to inspect, open, or download source files, return the corresponding file fields intact and associated with their source record; retain records with missing attachments and empty file cells rather than replacing file values with prose, guessed URLs, or links from other records. For vector fields, follow the DSL specification in `ontoplato-query`. If the schema does not expose a requested file field or a record has no file, state the limitation instead of fabricating a link.
## Python Packages
Use a Python package only for the step DSL cannot express. Data must still come from DSL queries; place `main.py` and all supporting files under `work/`, and list every source file in the `deliver` command. Paths sent to the service are relative to `work/`, and Python resolves relative paths from the function's working directory:
- **Entrypoint must be `work/main.py` (at the `work/` root)**: never nest it in a subdirectory such as `work/map/main.py`—the relative path `map/main.py` will be rejected with HTTP 400 because the root `main.py` is missing.
- **Multiple Python packages in one workspace**: rotate `work/main.py` between deliveries (archive the previous script under e.g. `work/archive/<name>.py` or use separate working directories) and pass only the active `work/main.py` plus its supporting files to each `deliver` call.
```text
work/main.py
work/queries/staff.json one DSL object, identical to what ontoplato-query execute-dsl accepts
```
Test each query on its own with `ontoplato-query`'s `execute-dsl @work/queries/staff.json`, then deliver all files in one command:
```sh
node <this-skill>/scripts/dataset.mjs deliver work/main.py work/queries/staff.json --meta @work/delivery.json --active
```
Example `main.py`:
```python
# ontomato-python:2
import json
from pathlib import Path
from query_runtime import query
dsl = json.loads(Path("queries/staff.json").read_text(encoding="utf-8"))
rows = query(dsl)
ages = [float(row["age"]) for row in rows if row["age"] not in (None, "")]
print(json.dumps({"answer": [{"average_age": round(sum(ages) / len(ages), 2)}]}, ensure_ascii=False))
```
- The first line `# ontomato-python:2` is mandatory; stdout must print exactly one JSON object: `{"answer": [rows]}`.
- Each call to `query(dsl)` takes one non-empty DSL dictionary and returns the row array keyed by output `as` aliases.
- Import `parameters` from `query_runtime` when passing business inputs via `--params @work/parameters.json`.
- Printed row keys must match the exact key set of `columnLabels` in `delivery.json`.
- The server supplies `query_runtime`, executes under the user's authorization, derives the column source graph, and masks final output before delivery. Preserve nulls, zeroes, and the meaning of any partial result.