Metadata-Version: 2.4
Name: semlayerio
Version: 0.1.0
Summary: Validate RDF instance data (ABox) against a pinned Semlayer ontology, its SHACL shapes, and dependency closure.
Project-URL: Homepage, https://semlayer.io
Project-URL: Documentation, https://semlayer.io/docs
Author: Semlayer
License-Expression: MIT
License-File: LICENSE
Keywords: knowledge-graph,ontology,owl,rdf,semantic-web,shacl,validation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: pyshacl>=0.26
Requires-Dist: pyyaml>=6.0
Requires-Dist: rdflib>=7.0
Requires-Dist: rich>=13.0
Requires-Dist: typer>=0.12
Provides-Extra: aws
Requires-Dist: botocore>=1.34; extra == 'aws'
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Description-Content-Type: text/markdown

# semlayer

The **Semlayer validation client** — validate your RDF **instance data (ABox)** against a
**pinned** ontology (`owner/repo@version`), its SHACL shapes, and its full dependency
closure, pulled from the [Semlayer](https://semlayer.io) registry. Runs **in your
environment** — your data never leaves your network.

> **Status:** functional (v0.1.0). Self-contained + contextual validation, registry bundle
> fetch, token auth, and `semlayer login` (device flow) all work end-to-end. Designed in
> Semlayer's `CLIENT.md`. Not yet published to PyPI.

## Why

Semlayer hosts the *TBox* (versioned ontologies + author SHACL shapes). This client is the
*quality gate*: check that new instance data conforms to a pinned schema **before** it hits
your production triple store or an LLM/RAG pipeline. CI-native, engine = **pySHACL** (full
SHACL Core + SPARQL + Advanced Features).

## Install (once published)

```bash
pip install semlayerio            # CLI + SDK — installs the `semlayer` command
pip install "semlayerio[aws]"     # + AWS SigV4 signing for Amazon Neptune
```

(The PyPI distribution is named `semlayerio` — `semlayer` was already taken
by an unrelated project — but the installed command is still `semlayer`.)

## Usage

```bash
# self-contained: validate a payload as a closed graph
semlayer validate --schema acme/health-model@v1.2.0 --data ./incoming.ttl

# contextual: resolve references against a target store (GraphDB/Fuseki/…)
semlayer validate --schema acme/health-model@v1.2.0 --data ./incoming.ttl \
  --target-endpoint https://graphdb.internal/repositories/prod --target-auth basic \
  --context-depth 2 --inference none --format json

# contextual against Amazon Neptune (IAM auth → SigV4)
semlayer validate --schema acme/health-model@v1.2.0 --data ./incoming.ttl \
  --target-endpoint https://…neptune.amazonaws.com:8182/sparql \
  --target-auth sigv4 --aws-region eu-west-1

# authenticate for local dev (OAuth device flow)
semlayer login
```

Auth: all programmatic pulls need a Semlayer token — `--token`, `SEMLAYER_API_TOKEN`, or
`semlayer login` (device flow). Exit codes: `0` conforms · `1` non-conforming · `2` error.

## Layout

| Module | Responsibility |
|---|---|
| `cli.py` | `semlayer` command (`validate`, `login`) |
| `client.py` | `SemlayerClient` SDK — fetch pinned schema + shapes + closure, validate |
| `registry.py` | Semlayer registry API client (token auth) |
| `validation.py` | Orchestration: assemble graph, run pySHACL, report-scope (design §5) |
| `context.py` | Contextual mode: bounded context fetch from the target endpoint (§5, §5.1) |
| `report.py` | Report formats: text / json / jsonld (§8.1) |
| `auth.py` | Token storage + `semlayer login` device flow (§9.3) |
| `models.py` | Core types (`SchemaRef`, `ValidationReport`, `Violation`) |

## Develop

```bash
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev,aws]"
pytest && ruff check . && mypy src
```

**License:** [MIT](./LICENSE).
