Skip to content

Commit d413de1

Browse files
ksalihucursoragent
andauthored
SP-141: Document BUSINESS validation layer (#355)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 04851c6 commit d413de1

4 files changed

Lines changed: 150 additions & 12 deletions

File tree

.cursor/skills/asset-registry-endpoints/SKILL.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,13 @@ export_<uuid>/
7777
$CLI config import -d <export_dir> --validate --overwrite
7878
```
7979

80-
- `--validate` — performs schema validations before importing. If there are
81-
validation errors the import is **not** performed and the errors are returned.
82-
If there are no errors, the package and its assets are imported normally.
80+
- `--validate` — performs **SCHEMA-layer** validation on each node before
81+
importing. If there are validation errors the import is **not** performed and
82+
the errors are returned. If there are no errors, the package and its assets
83+
are imported normally. To also run **BUSINESS-layer** rules (e.g. PQL
84+
parsing, data-model availability, KPI uniqueness for Knowledge Models), run
85+
`config validate --layers SCHEMA BUSINESS` against the imported staging
86+
version — see *Validating an imported package* below.
8387
- `--overwrite` — required when updating an existing package
8488
- Without `--overwrite` — creates a **new** package (use for first-time import)
8589

@@ -286,17 +290,43 @@ build-from-options flags.
286290
$CLI asset-registry validate --assetType <ASSET_TYPE> -f request.json -p <profile>
287291
```
288292

289-
You can also validate during import with `config import --validate`:
293+
You can also validate during import with `config import --validate` — this
294+
runs the SCHEMA layer only:
290295

291296
```bash
292297
$CLI config import -d <export_dir> --validate --overwrite -p <profile>
293298
```
294299

295-
**Important**: If validation returns errors, do **not** proceed with the import.
296-
Instead, fix the schema violations in the node JSON and re-validate. If you
297-
cannot resolve the errors automatically, present the validation results to the
298-
user and ask whether they want to continue importing with invalid configuration
299-
or stop to fix it manually.
300+
### Validating an imported package
301+
302+
To run **business-layer** rules against the staging version of a package (e.g.
303+
PQL parsing, data-model availability, KPI uniqueness for `SEMANTIC_MODEL`),
304+
use `config validate`:
305+
306+
```bash
307+
$CLI config validate --packageKey <pkg> --layers SCHEMA BUSINESS -p <profile>
308+
```
309+
310+
- `--layers SCHEMA BUSINESS` runs both layers in a single request. Supported
311+
values today are `SCHEMA` and `BUSINESS`.
312+
- `--nodeKeys <key1> <key2>` (optional) restricts validation to specific nodes.
313+
- `--json` writes the full structured report to a file in the current working
314+
directory instead of printing to the console.
315+
316+
The console output prints a summary plus one line per finding:
317+
318+
```
319+
info: Validation result: INVALID
320+
info: Errors: 1 | Warnings: 0 | Info: 0
321+
info:
322+
info: ERROR my-kpi-model (SEMANTIC_MODEL) - Data Model should not be empty [dataModelId.empty]
323+
```
324+
325+
**Important**: If validation returns errors, do **not** proceed with the
326+
import. Instead, fix the schema or business-rule violations in the node JSON
327+
and re-validate. If you cannot resolve the errors automatically, present the
328+
validation results to the user and ask whether they want to continue importing
329+
with invalid configuration or stop to fix it manually.
300330

301331
## Troubleshooting
302332

@@ -351,4 +381,5 @@ $CLI config import -d <export_dir> --validate --overwrite -p <profile>
351381
| `asset-registry methodology --assetType X` | Get methodology / best-practices (if available) |
352382
| `config list` | List packages |
353383
| `config export --packageKeys X --unzip` | Export packages |
354-
| `config import -d <dir> --validate --overwrite` | Validate and import packages |
384+
| `config import -d <dir> --validate --overwrite` | Validate (SCHEMA only) and import packages |
385+
| `config validate --packageKey P --layers SCHEMA BUSINESS` | Validate a package's staging version against the SCHEMA and/or BUSINESS layers |

docs/user-guide/agentic-development-guide.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,18 @@ content-cli asset-registry validate --assetType <ASSET_TYPE> \
8282
--packageKey <package-key> --configuration '{ ... }'
8383
```
8484

85-
Or validate during import with the `--validate` flag:
85+
Or validate during import with the `--validate` flag — note that this runs the `SCHEMA` layer only:
8686

8787
```bash
8888
content-cli config import -d <export_dir> --validate --overwrite
8989
```
9090

91+
To also run business-layer rules (PQL parsing, data-model availability, KPI uniqueness, …), run `config validate` against the just-imported staging version:
92+
93+
```bash
94+
content-cli config validate --packageKey <package-key> --layers SCHEMA BUSINESS
95+
```
96+
9197
If validation returns errors, fix the issues before importing.
9298

9399
### 6. Import

docs/user-guide/config-commands.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,103 @@ Finally, the result of this command will be a list of PostPackageImportData expo
167167
info: Config import report file: 9560f81f-f746-4117-83ee-dd1f614ad624.json
168168
```
169169

170+
### Validate During Import
171+
172+
Add `--validate` to `config import` to run validation against each node **before** the import is committed:
173+
174+
```bash
175+
content-cli config import -p <sourceProfile> -d <export_dir> --validate --overwrite
176+
```
177+
178+
`config import --validate` runs the **SCHEMA** layer only. It does **not** run BUSINESS-layer checks (PQL parsing, data-model availability, KPI uniqueness, etc.). To run business validation, use [`config validate`](#validate-package-configurations) after the import.
179+
180+
## Validate Package Configurations
181+
182+
The `config validate` command validates the **staging (draft) version** of a package by sending its nodes through one or more validation layers. The command runs against the Pacman validate API and returns a structured report of errors, warnings, and info findings.
183+
184+
This command requires **edit permission** on the target package (see [Permissions](#permissions)).
185+
186+
```bash
187+
content-cli config validate --packageKey <packageKey>
188+
```
189+
190+
By default, only the `SCHEMA` layer is run. The console output looks like:
191+
192+
```bash
193+
info: Validation result: VALID
194+
info: Errors: 0 | Warnings: 0 | Info: 0
195+
```
196+
197+
If there are findings, each one is printed on its own line with the severity, node key, asset type, message, and code:
198+
199+
```bash
200+
info: Validation result: INVALID
201+
info: Errors: 1 | Warnings: 0 | Info: 0
202+
info:
203+
info: ERROR my-knowledge-model (SEMANTIC_MODEL) - $.requiredField: is missing but it is required [REQUIRED_PROPERTY_MISSING]
204+
```
205+
206+
### Validation Layers
207+
208+
The `--layers` option selects which validation layers to run. Multiple layers can be passed and are executed in a single request; their findings are merged into one report.
209+
210+
| Layer | What it checks | Owner |
211+
|---|---|---|
212+
| `SCHEMA` | Asset-schema conformance of each node's `configuration` field — required properties, enum values, type checks, conditional schemas. | Asset registry |
213+
| `BUSINESS` | Asset-type-specific business rules — for `SEMANTIC_MODEL`, e.g. PQL parsing, data-model availability, KPI uniqueness. Rules live in the owning asset service. | Owning asset service (e.g. `cloud-semantic-layer` for Knowledge Models) |
214+
215+
Currently `SCHEMA` and `BUSINESS` are the only layers accepted by the Pacman API. Other values are rejected with a `400 layers.unsupported` error.
216+
217+
To run both layers:
218+
219+
```bash
220+
content-cli config validate --packageKey <packageKey> --layers SCHEMA BUSINESS
221+
```
222+
223+
### Validate Specific Nodes
224+
225+
By default, every node in the package's staging version is validated. To restrict the scope to a subset of nodes, use `--nodeKeys`:
226+
227+
```bash
228+
content-cli config validate --packageKey <packageKey> --nodeKeys node-key-1 node-key-2
229+
```
230+
231+
### Export Validation Report as JSON
232+
233+
Use `--json` to write the full validation report to a JSON file in the current working directory instead of printing it to the console:
234+
235+
```bash
236+
content-cli config validate --packageKey <packageKey> --layers SCHEMA BUSINESS --json
237+
```
238+
239+
The filename is printed on success:
240+
241+
```bash
242+
info: Validation report file: config_validate_report_9560f81f-f746-4117-83ee-dd1f614ad624.json
243+
```
244+
245+
The JSON report has the shape:
246+
247+
```typescript
248+
interface ValidationReport {
249+
packageKey: string;
250+
valid: boolean;
251+
summary: { errors: number; warnings: number; info: number };
252+
results: ValidationResult[];
253+
}
254+
255+
interface ValidationResult {
256+
layer: "SCHEMA" | "BUSINESS";
257+
severity: "ERROR" | "WARNING" | "INFO";
258+
nodeKey: string;
259+
assetType: string;
260+
path: string;
261+
code: string;
262+
message: string;
263+
suggestion?: string;
264+
}
265+
```
266+
170267
## Listing & Mapping Variables
171268

172269
### Listing Package Variables

src/commands/configuration-management/module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ class Module extends IModule {
6363
configCommand.command("validate")
6464
.description("Validate package node configurations")
6565
.requiredOption("--packageKey <packageKey>", "Key of the package to validate")
66-
.option("--layers <layers...>", "Validation layers to run", ["SCHEMA"])
66+
.option(
67+
"--layers <layers...>",
68+
"Validation layers to run. Allowed values: SCHEMA, BUSINESS (can be combined, e.g. --layers SCHEMA BUSINESS). Defaults to SCHEMA.",
69+
["SCHEMA"]
70+
)
6771
.option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
6872
.option("--json", "Return the response as a JSON file")
6973
.action(this.validatePackage);

0 commit comments

Comments
 (0)