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 Capability Builder?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ontomato-ai-ontoplato-capability-builder)
---
name: ontoplato-capability-builder
description: "Authoritative guide to OntoPlato capability function packages (Actions and MetricViews): # ontomato-python:2 and pure-DSL authoring, sandbox testing, code explanation, query quality checks, dataset-settlement reuse criteria, and the platform-wide Action 3-step loop (save -> trial -> publish)."
compatibility: Node.js 24+
---
# Capability Builder
This skill is the single authoritative specification for OntoPlato capability function packages (Actions and MetricViews), covering package structure, sandbox testing and delivery inside platform generation sessions, code explanation (`explain`), query quality checks (`quality`), dataset-settlement reuse criteria, and the platform-wide Action 3-step lifecycle (`save -> trial -> publish`).
## Runtime modes and connection
- **Platform generation session (sandbox mode)**: the bundled script `node <this-skill>/scripts/generation.mjs <command>` (where `<this-skill>` is the directory containing this `SKILL.md`) relies on host-injected `ONTOMATO_GENERATION_URL` and callback credential `ONTOMATO_EXECUTION_CALLBACK`, and is only available inside an active platform generation session.
- **Outside generation sessions / general administration (including regular page assistants)**: when `ONTOMATO_GENERATION_URL` is not injected (outside a system generation session), do not invoke `generation.mjs`; use the live management page form or call public platform APIs via `ontoplato-app-builder` (`action` / `metric-view` commands) or `ontoplato-workflow-admin` (`action-save`, `action-trial`, `action-reexplain`, `action-publish`, `action-retire`), following the "Action 3-step release lifecycle" below.
- **Ontology exploration and DSL**: use `ontoplato-query` to explore permitted schema, relationships, and distinct values, and follow its DSL specification when writing read queries.
- **Bundled contracts**: read [Function files](references/function-package.md) and [Query subgraph](references/query-subgraph.md) before authoring any package (both files are mirrored verbatim from the single-source English contracts in `@ontomato/contracts`). Java server paths are never workspace paths.
## Sandbox generation commands
Run `node <this-skill>/scripts/generation.mjs <command> [arguments]` from the workspace root:
| Command | Arguments and purpose |
| --- | --- |
| `source [filePath]` | List draft source files when omitted; pass `filePath` to read that file's full source (e.g., for `explain`). |
| `explain` | Call `explainDraft` to refresh the structured explanation of the current conversation's newest draft when explicitly requested (do not edit source). |
| `helpers` | Return exact Python helper signatures and parameter rules for the current gate, generated from the single `python/query_runtime.py` source. Always run before authoring an Action. |
| `prepare <data.json>` | Validate and stage an Action sandbox fixture `{objDatas, relDatas, vectorDatas}` (`objDatas` items contain `className` and `rows`; `relDatas` items contain `relationName`, `sourceObjId`, `targetObjId`). Stages data only—does not import it into the sandbox yet. |
| `reset` | Clear the Action sandbox and import the fixture staged by `prepare`. Re-run before every independent Action test. |
| `query <dsl.json>` | Execute a DSL query against the Action sandbox to verify write side effects. |
| `test <files...> [--parameters @parameters.json] [--column-labels @labels.json]` | Run a business test with exact file bytes and parameter definitions. MetricView read tests must supply `--column-labels @labels.json`; a parameterless pure-DSL read test accepts a single DSL JSON file. |
## Authoring function packages
Follow [Function files](references/function-package.md) and place all final files under `outputs/` (relative POSIX paths, up to 64 files and 1 MiB total UTF-8; root names `query_runtime.py`, `parameters.json`, `identity.json`, `query-status.json` and the `_uploads/` prefix are reserved):
- **Pure DSL (preferred for parameterless MetricViews)**: submit a single `.json` file (e.g., `outputs/query.json`) containing one DSL object with a nonempty `answer.steps` array whenever DSL expresses the entire calculation. The platform recognizes the pure-DSL entrypoint, derives explanation and column lineage (`returnDef.sourceAnalysis`) deterministically, and executes without starting Python.
- **Python packages (Actions, or MetricViews needing parameters, multi-query merges, or post-processing)**:
- Entrypoint is `outputs/main.py`, whose **first line must be `# ontomato-python:2`**. Mount supporting `.py` and `.json` templates in the same package directory and read them by relative path.
- Always run `helpers` before writing an Action to get live runtime signatures; never guess helper names or argument order.
- Run read queries via `query_runtime.query(dsl)` with one nonempty DSL dictionary; read business inputs from `query_runtime.parameters`; in write functions, only `update` and `delete` accept a `where` argument.
- Read functions print one result table as JSON to stdout: `{"answer": rows}`. Output column keys must match `columnLabels` and output lineage.
- Only Action write functions may declare `TYPE_FILE` parameters (forbidden on read functions and MetricViews); uploaded files are staged under `_uploads/<paramName>/<sanitizedName>` for that execution only.
- **Retest after every change**: whenever any source file, parameter definition, or column label changes, re-run `test` with the exact final files and inputs.
```bash
# Parameterless pure-DSL MetricView sandbox test
node <this-skill>/scripts/generation.mjs test outputs/query.json --column-labels @labels.json
# Parameterized Python MetricView sandbox test
node <this-skill>/scripts/generation.mjs test outputs/main.py outputs/queries/sales.json --parameters @parameters.json --column-labels @labels.json
# Action sandbox test (prepare + reset, then test + query to verify side effects)
node <this-skill>/scripts/generation.mjs prepare sample.json
node <this-skill>/scripts/generation.mjs reset
node <this-skill>/scripts/generation.mjs test outputs/main.py --parameters @parameters.json
node <this-skill>/scripts/generation.mjs query verify-dsl.json
```
`parameters.json` is an array of typed parameter definitions with test values (e.g., `[{"name":"limit","type":"TYPE_NUMBER","value":10}]`); `labels.json` maps each final output column key to a label in the reader's language.
## Action 3-step release lifecycle (platform-wide authoritative contract)
Whether creating and publishing Actions from the UI, `ontoplato-app-builder`, or `ontoplato-workflow-admin`, always follow the three-step loop (**save draft → sandbox trial → gated publish**):
1. **Save draft (`POST /action/save`)**:
- Saves the Action as `PENDING_REVIEW`. **Never invent `id` (or `function.id`) on create**—omit `id` so the server generates and returns it, and pass `id` only when editing an existing draft.
- **Never set `status=PUBLISHED` directly through `/action/save`.**
- `/action/save` returns immediately while code explanation is generated asynchronously on `Function` and projected to the Action.
2. **Sandbox trial (`POST /action/trial` — sole external trial entry point)**:
- Targets a saved Action (including `PENDING_REVIEW`) with payload `{ "id": "<actionId>", "sample": { "objDatas": [...], "relDatas": [], "vectorDatas": [] }, "parameters": { ... } }`.
- In one call, the server creates an ephemeral business-database sandbox, loads `sample`, evaluates `submissionCriteria`, executes with `parameters`, persists a receipt keyed by canonical digest, and tears down the sandbox (**never mutates production data**).
- Omitting `sample` defaults to an empty sample (pure-computation Python only—no data reads or writes permitted). Actions targeting, reading, or writing classes must provide sample rows under `sample.objDatas` using technical class names.
- A failed trial (`passed=false`) fails the command; common rejection codes are `ACTION_NOT_FOUND`, `ACTION_TRIAL_INVALID`, `ACTION_TRIAL_FORBIDDEN`, and `ACTION_TRIAL_SANDBOX_UNAVAILABLE`.
- **Canonical digest and re-trial rule**: trial receipts bind to `(domainId, codeHash, target {className, keyParameter}, parameters [{name, type, classNames}])`, where `codeHash` is the canonical SHA-256 over sorted `function.files`. **Editing any file, target class/key parameter, or parameter declaration invalidates the previous trial** and requires re-running `POST /action/trial`; changing only runtime trial argument values does not invalidate it.
3. **Publish and retire (`POST /action/setStatus`)**:
- Publishing (`status: "PUBLISHED"`) enforces two sequential gates:
1. **Explanation gate**: the function explanation is ready and matches the current `codeHash` (otherwise rejected with `ACTION_EXPLANATION_REQUIRED` or `FUNCTION_EXPLANATION_REQUIRED`; wait briefly or run `POST /action/re-explain` with `{"ids":["<actionId>"],"missingOnly":true}`, or `POST /function/reExplain`).
2. **Trial gate**: the latest trial for the current canonical digest passed (untested or stale → `ACTION_TRIAL_REQUIRED`; latest trial failed → `ACTION_TRIAL_FAILED`).
- Reading an Action returns `trialStatus` (`passed` | `failed` | `notRun`), `trialStatusLabel`, `lastTrialAt`, `lastTrialError`, `publishBlockedCode`, and `publishBlockedReason` for diagnosing publish blocks.
- To retire a published Action, transition it to `UNUSED` via `POST /action/setStatus` (retire rather than delete).
## Code explanation (`explain`) and query quality (`quality`)
- **Code explanation (`explain`)**: call `source` first to list and read every source file in full, then produce a package-wide structured explanation (`segs` citing file path and line ranges, `operations`, `negativeEffect`, plus `outputColumns` for read functions and optional `joins` when Python associates multiple queries on matching fields). When the user only asks to refresh the current draft's explanation, invoke the `explain` command without modifying source.
- **Program description (`describe`)**: summarize the full program logic (`meaning`) and concise `summary` strictly from the source files without prompt hints.
- **Query quality (`quality`)**: evaluate the result against the user's original wording and execution evidence according to the task's scoring rubric, outputting `conclusion`, numeric `score`, and `fittedQuestion`.
## Delivery (`outputs/result.json`)
At the end of a platform generation session, write a single JSON object to `outputs/result.json`. For Actions and MetricViews, `filePaths` must list every tested file with its `outputs/` prefix (e.g., `["outputs/main.py", "outputs/queries/sales.json"]`), and `parameters` must match the tested array (`[]` when parameterless).
| Task kind | Required `outputs/result.json` fields |
| --- | --- |
| `action` | `filePaths`, `parameters` (array), `classNames` (nonempty array), `name`, `logic`, optional `target` (`{className, keyParameter}`), optional `submissionCriteria` (`operator`, `conditions`, `unrepresentable`) |
| `metricview` | `filePaths`, `parameters`, `columnLabels`, `name`, `logic` |
| `explain` | `segs`, `operations`, `negativeEffect`, `outputColumns` for read functions (and optional `joins` when Python associates queries) |
| `describe` | `meaning` (complete program logic), `summary` |
| `quality` | `conclusion`, numeric `score`, `fittedQuestion` |
## Dataset settlement (MetricView reuse criteria)
Apply these criteria only when the host explicitly designates a **dataset-settlement** task:
1. Search published MetricViews via `ontoplato-query` and inspect candidate definitions, current `revision`, and parameter schemas.
2. Compare the complete requested business logic: **grain, population/object scope, filter predicates, time semantics, denominators, and null handling**—coincidentally matching preview numbers do not prove equivalence.
3. **Reuse when fully equivalent**: write `{"kind":"reuse","metricId":"...","revision":"...","parameters":{...}}` to `outputs/result.json` and do not author a new package.
4. **Create otherwise**: author and business-test the final package as above, writing `"kind": "create"` alongside `filePaths`, `parameters`, `columnLabels`, `name`, and `logic` in `outputs/result.json`.
Hard constraints:
- Perform all business grouping, aggregation, pivoting, and statistical computation inside the MetricView package (chart cards only select columns and apply display sorting/formatting).
- Never call another metric from inside a Function; never substitute row counts for zero, missing, or non-numeric values.
- Backend services exclusively own saving, adoption, publication, bindings, quality records, and permission enforcement; never publish an asset or fabricate receipts inside a generation session.