Metadata-Version: 2.5
Name: ontlas
Version: 0.31.0
Summary: One space for every kind of data an AI can use: files, documents, vectors, graphs and ontologies, tied to no store, model, domain or platform.
Project-URL: Homepage, https://ontlas.com
Project-URL: Repository, https://github.com/PlateerLab/ontlas
Project-URL: Changelog, https://github.com/PlateerLab/ontlas/blob/main/CHANGELOG.md
Author-email: jinsoo96 <wlstn010203@gmail.com>
License: Apache-2.0
License-File: LICENSE.md
Keywords: cypher,decision-table,gql,gremlin,knowledge-graph,mcp,ontology,owl,r2rml,semantic-layer,shacl,sparql,sql-pgq
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Provides-Extra: all
Requires-Dist: mcp>=1.2; extra == 'all'
Requires-Dist: openpyxl>=3.1; extra == 'all'
Requires-Dist: owlrl>=7; extra == 'all'
Requires-Dist: pypdf>=4; extra == 'all'
Requires-Dist: pyshacl>=0.26; extra == 'all'
Requires-Dist: pyyaml>=6; extra == 'all'
Requires-Dist: rdflib>=7; extra == 'all'
Requires-Dist: sqlglot>=25; extra == 'all'
Requires-Dist: xgen-omnifuse>=0.8.4; extra == 'all'
Requires-Dist: xgen-ontology-build>=0.17.1; extra == 'all'
Requires-Dist: zen-engine>=2; extra == 'all'
Provides-Extra: build
Requires-Dist: xgen-ontology-build>=0.17.1; extra == 'build'
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: embed
Requires-Dist: fastembed==0.7.3; extra == 'embed'
Provides-Extra: gremlin
Requires-Dist: gremlinpython>=3.7; extra == 'gremlin'
Provides-Extra: live
Requires-Dist: gremlinpython>=3.7; extra == 'live'
Requires-Dist: neo4j>=5; extra == 'live'
Requires-Dist: psycopg[binary]>=3; extra == 'live'
Requires-Dist: pymysql>=1.1; extra == 'live'
Provides-Extra: mcp
Requires-Dist: mcp>=1.2; extra == 'mcp'
Provides-Extra: mssql
Requires-Dist: pymssql==2.4.6; extra == 'mssql'
Requires-Dist: sqlglot>=29; extra == 'mssql'
Provides-Extra: mysql
Requires-Dist: pymysql>=1.1; extra == 'mysql'
Requires-Dist: sqlglot>=25; extra == 'mysql'
Provides-Extra: neo4j
Requires-Dist: neo4j>=5; extra == 'neo4j'
Provides-Extra: omnifuse
Requires-Dist: xgen-omnifuse>=0.8.4; extra == 'omnifuse'
Provides-Extra: oracle
Requires-Dist: oracledb>=2; extra == 'oracle'
Requires-Dist: sqlglot>=29; extra == 'oracle'
Provides-Extra: owl
Requires-Dist: owlrl>=7; extra == 'owl'
Requires-Dist: rdflib>=7; extra == 'owl'
Provides-Extra: pdf
Requires-Dist: pypdf>=4; extra == 'pdf'
Provides-Extra: postgres
Requires-Dist: psycopg[binary]>=3; extra == 'postgres'
Provides-Extra: rdf
Requires-Dist: rdflib>=7; extra == 'rdf'
Provides-Extra: reasonable
Requires-Dist: rdflib>=7; extra == 'reasonable'
Requires-Dist: reasonable==0.4.4; extra == 'reasonable'
Provides-Extra: shacl
Requires-Dist: pyshacl>=0.26; extra == 'shacl'
Requires-Dist: rdflib>=7; extra == 'shacl'
Provides-Extra: sql
Requires-Dist: sqlglot>=25; extra == 'sql'
Provides-Extra: xlsx
Requires-Dist: openpyxl>=3.1; extra == 'xlsx'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6; extra == 'yaml'
Provides-Extra: zen
Requires-Dist: zen-engine>=2; extra == 'zen'
Description-Content-Type: text/markdown

# Ontlas

**One space for every kind of data an AI can use, tied to no store, no model, no domain and no platform.**

The name is *ontology* and *atlas*: a map of what a company knows, drawn once and read by people and agents alike.

```bash
pip install "ontlas[all]"     # or pip install ontlas for the core alone, with no dependencies (JSON files, no YAML)
```

Ontlas runs at https://ontlas.com (sign-in required).

- **Every kind of data in one place.** Files, databases, documents, embeddings, graphs and ontologies sit in one space and know about each other.
- **Nothing is tied to a store.** Graph databases, vector databases, reasoners, embedding models and query languages are adapters, and a conformance test says whether a swap changed the answers.
- **Knowledge plugs in and out.** A domain is a versioned module. Commerce is the first one in the examples, and another domain is one more package.
- **So it fits anywhere.** MCP and a token REST API let any agent or platform use a space, and a space can read a platform's data through the connections that platform already manages.

Describe the business once (object types, properties, links, states, decisions, actions, roles) and bind it to the source
tables, or draft all of that from files. A question then becomes *one* ontology query, compiled for the store a deployment
actually has: SQL in any dialect, Cypher, ISO GQL, SPARQL, SQL/PGQ or Gremlin. Documents are cut, embedded into every vector
store the space has, and become a document ontology tied to the domain through the names both use, so a search can land on a
passage and go on to the definition. **Zero hard dependencies, zero infra to try it.**

```python
from ontlas import Ontology
from ontlas.studio import Studio
from ontlas.backends.sql import SqliteBackend
from ontlas.backends.rdf import RdflibBackend

studio = Studio(Ontology.load("examples/commerce/ontology.yaml").check())
studio.add_backend("source", SqliteBackend()).script(open("examples/commerce/seed.sql", encoding="utf-8").read())
studio.add_backend("graph", RdflibBackend())        # a graph only when you want one
studio.project()                                   # source rows -> RDF; later calls send only what changed

studio.run("revenueByCategory")                    # compiled to SQL, run on the source
studio.run("revenueByCategory", backend="graph")   # the same query as SPARQL, the same rows
studio.translate("revenueByCategory", "sql:oracle").text      # or cypher, gql, sparql, sqlpgq, sql:mysql, ...
studio.run_cypher("MATCH (o:Order)-[:hasItem]->(i:OrderItem) RETURN o.order_id, count(i) AS n")  # on SQL
studio.decide("returnEligibility", "I1001")        # outputs, the rule that fired, the columns it read
```

```bash
ontlas search examples/library/studio.yaml "포장을 뜯은 속옷도 돌려보낼 수 있나요"   # passages, and the definitions the question names
ontlas vectors examples/library/studio.yaml                                     # every vector store against exact search
ontlas serve examples/library/studio.yaml --embedder fastembed --api-token-env ONTLAS_API_TOKEN   # the page and /v1
```

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/architecture.png" alt="One ontology definition feeding execution adapters that compile one query IR to SQL, Cypher, GQL, SPARQL, SQL/PGQ and Gremlin for the backends a deployment has" width="920">
</p>

## Modules

Ontlas is one product in five parts, each named for what it does. They share one definition, so a part is a way in, not a
separate copy.

| Module | What it does | Where it is on the page |
|---|---|---|
| **Ontlas Studio** | Define and check: Objects, the Entities under them and their properties and relations, the workspace, validation questions and the flow's pass conditions | Ontology, Quality |
| **Ontlas Map** | Bind the definition to source tables, columns and codes, and to the words people use for it; check the definition against the database | Data Binding, Ontology › 용어 사전 |
| **Ontlas Rule** | Formulas and decision criteria in three layers (AXIOM, Custom, Standard): rule cards, decision tables in plain words, parameters, functions and computed properties | Semantic Layer › 규칙 |
| **Ontlas Query** | Answers from checked definitions: one query compiled for whatever store a deployment has, search over documents and records, the REST API and MCP tools | 검색 · 질문, Data Binding › 질의, Operations › 연동 · API |
| **Ontlas Guard** | What people and agents may do: actions with criteria and approval, roles, masking and row scope, change requests tried on a copy before they apply, and the versions they make | Data Binding › Action, Operations › 접근 정책, Ontology › 변경 요청 · 버전 |

## What it is for

The space sits between the systems a business already runs and the people and agents that ask about them.

| Use | What it does |
|---|---|
| Search that goes on to the definition | Documents are searched by meaning on any vector store, each passage names the ontology elements it speaks of, and an object shows the documents that mention it |
| One shared definition | Objects, properties, relations, states, rules and roles are defined once over the source tables, in versioned module files a person can read and review |
| The same question on every store | One query compiles to SQL, Cypher, GQL, SPARQL, SQL/PGQ or Gremlin, and a conformance run compares the rows each store returns |
| Decisions with their grounds | Decision tables decide, not a language model; each answer carries the rule, the clause it cites, the source columns and the module version |
| Action under control | Roles scope rows and mask properties; an agent only files a request and a person approves it, the source is written only on a server started to write, and an executed action can be rolled back |
| Changes that are tried first | A new module version runs on a copy of the studio against the rule checks, the database check, backend agreement, validation questions and past decisions before it can be approved |
| One domain across systems and customers | A standard stays as it is; a new system gets a binding and a customer's differences get a module of their own (see [Adapt a domain](#adapt-a-domain)) |

A language model is optional. It turns plain questions into the ontology query and policy text into draft decision
tables, and the engine checks what it writes; the rest of the studio runs without one.

## What sets it apart

| Feature | How it works | Try it |
|---|---|---|
| One query, compared across stores | A query is a typed IR, not text. Compilers write each language, SPARQL and Cypher read back into the same IR, and a conformance run compares the rows store by store | `ontlas conformance examples/library/studio.yaml` |
| Standards that are never edited | Every element knows the module it came from. A customer's difference extends or removes from a module of its own, and detaching a module shows what would go before anything goes | `ontlas modules examples/library/studio.yaml --impact fashion` |
| Anything goes in, one JSON comes out | SQL scripts, ERD files, definition sheets, glossaries, message lists, Word, PowerPoint, Hangul and PDF documents all roll up into one JSON, and the same path makes modules from it | `ontlas ingest examples/definitions/*.csv -o bundle.json` |
| A studio from what already exists | Drafts come from data, from table and code definitions with no rows, or onto a standard, and keep the reason for each choice. Composite keys and references stay whole | `ontlas draft examples/files/*.csv -o my-studio` |
| Answers that show their grounds | A decision gives the rule that fired, the clause it cites and the source column of each input. A question counts as grounded only when its answer has all of them and the version, and that share can be a pass condition | `ontlas decide examples/library/studio.yaml returnEligibility I1001` |
| Rules checked against what was decided | Past cases are decided again with the values they had then, and the ones that differ are listed with the rule that fired | `ontlas agreement examples/library/studio.yaml` |
| Changes tried before they count | A new module version runs on a copy of the studio, and it can be approved only when it passes the flow's conditions | `ontlas review examples/library/studio.yaml acme-1.1.0.yaml` |
| Edits that say what they take | Removing a property or a relation in the modelling workspace takes out the queries, decisions and questions that need it, and lists them before anything is filed; an element carries a status (초안 · 사용 중 · 폐기 예정) | The page's Ontology › 그래프 탐색 |
| Agents inside limits | Every MCP call runs inside the role's row filters and masks. An agent files a request, and nothing is written until a person approves it | `ontlas mcp examples/commerce/studio.yaml --role customer_agent --principal customer_id=C001` |
| Nothing to run first | The core has no required dependencies. SQLite and an in-process RDF graph are enough to try everything, and values stay in the source unless you ask for a projection | `python examples/commerce/demo.py` |

## How to use it

The walk-through runs on the examples in the repository, so take a checkout (`pip install "ontlas[all]"` installs the
same package without them).

```bash
git clone https://github.com/PlateerLab/ontlas.git
cd ontlas
pip install -e ".[all]"
```

**1. See it working.** The example library is one fictional shop: a commerce standard, its operations (sellers, payments,
refunds, shipping, coupons, reviews), a fashion extension and one customer's differences.

```bash
ontlas serve examples/library/studio.yaml --samples examples/files --policies examples/policies
```

Open http://127.0.0.1:7710. Each visitor gets a studio of their own, and the library folder is not written. A server
that offers more than one ontology (`--library`) opens on 온톨로지 선택; picking one opens its 홈, and the list at the top
left of every screen switches between them afterwards. 홈 shows where the ontology stands: how far its definition has
come (L0 개념 to L3 검증), its four parts with their numbers, the Objects, what waits, and the six steps of starting.
The menu holds 홈, AI 초안 생성 and five parts: Semantic Layer, Ontology, Data Binding, Quality and Operations.

**2. Define the ontology (Ontology).** A definition has three levels: an **Object** is a top-level
classification (주문, 상품, 결제: an area of the business with a definition of its own), an **Entity** is a concept under
it (주문, 주문상품) and a **Property** is a value an Entity carries. None of it needs data. Object lists the Objects
with their Entities, rules, maturity and owner; Entity is a tree of Entities by Object with the chosen one's
definition, grounds, readers, YAML and comments, its Properties with the vocabulary each comes from, restrictions and
state transitions with their conditions; 그래프 탐색 draws Objects, Entities and Relations as a graph whose edges are
edited beside it, with the diagram workspace one button away. Every item has its own screens: **추가 · 편집** (a form
that checks while you type), **삭제** (what uses the item is listed, and the delete is tried first, so one that would
fail later is refused there with the reason) and **이력** (each change with its fields before and after, who and why;
이 시점으로 되돌리기 writes an earlier version's values into the change request, 다른 버전과 비교 shows what differs between
two versions, and a deleted item keeps its history, with 되살리기). Saving does not change the ontology in use: the edit
joins the change request being written (step 6).

**3. Rules (Semantic Layer).** 규칙 opens on the three layers a rule belongs to, AXIOM (laws and integrity, checked
first), Custom (a customer's) and Standard (the common ones), with the rule cards and decision table rules in one list,
filtered by Object, by layer and by what the cards are filed under (분류, 근거 종류, 정책서 대조; see
[Rules in three layers](#rules-in-three-layers)). 판정 테스트 decides on values typed in and shows the path the
decision took through the layers; the checks name overlaps, unreachable rules, gaps and rules tied in priority; the
parameters, metrics and functions the rules read are listed below, each with what uses it. A Standard or Custom rule
is edited and removed on its own screens, and removing a decision table rule shows the rule that takes over its range
or the gap it leaves; an AXIOM card is changed as a change request to the module that defines it. The decision table
editor (cells in plain words, rows by dragging, the hit policy, boundary values and past cases recomputed) opens from
the rule; under 우선순위 each rule carries a number, and the lowest one that matches decides. 규칙 초안 lists the drafts
that wait, with what each stands on, and a reviewer approves, corrects or takes one out.

**4. Connect data (Data Binding), when you want live values.** Definitions, rules and decisions on typed values
work without it. 자료 업로드 in the top bar takes files and whole folders; each file says what it became (table data, a
definition sheet, a document, raw material). AI 초안 생성 turns them into drafts (Entities, Properties and Relations
from tables and definition sheets, a decision table from policy text) that are reviewed on 개념 초안 and 규칙 초안.
데이터 소스 connects a database, Mapping sets each Property against its column and says where they differ,
Entity Binding binds an Entity and shows the SQL it makes with a preview of rows, 질의 keeps the registered queries (each
read into nine store languages, run as an access policy) and Action the things an agent may ask to be done, with their
preconditions and approval. A data source is written only on a server started with `--action-write`: without it an
approved Action is recorded with what it would have changed, the source stays as it was, and the screen says 쓰기 꺼짐 ·
실행 결과만 기록. From the command line:

```bash
ontlas draft examples/files/*.csv --name shop --label "가상 쇼핑몰" --lang ko -o my-studio    # from files
ontlas draft --definitions 테이블정의서.csv --definitions 코드정의서.csv --name shop -o my-studio   # from definitions, no rows
ontlas draft --definitions schema.sql --definitions 코드정의서.xlsx --name shop -o my-studio       # from a SQL script
ontlas draft --dsn "$ONTLAS_DSN" --name shop -o my-studio                                     # from a database
ontlas serve my-studio/studio.yaml
```

A database needs `pip install "ontlas[postgres]"` (or `[mysql]`, `[oracle]`, `[mssql]`). A draft reads every table in full to
profile it, so point it at a copy or a replica with a read-only account, not at a busy production database.

**5. Check it (Quality).** 검증 질문 keeps the questions with known answers by kind (정의형 · 판정형 · 값 조회형), with a
held-out set apart; 검증 runs them, says why a wrong one is wrong, and shows the pass conditions as measured, which are
edited there. Four of them are on from the start: no gap in a decision table, no rule that can never apply, no
conflict with an AXIOM rule or bound, and no question a change newly answers wrong.

```bash
ontlas bindings my-studio/studio.yaml       # the definition against the database
ontlas questions my-studio/studio.yaml      # validation questions: right, and grounded
ontlas conformance my-studio/studio.yaml    # every registered query on every backend
ontlas gates my-studio/studio.yaml          # the flow's pass conditions, measured
```

**6. Review and approve (Ontology › 변경 요청 · 버전).** The edits saved on the item screens wait as the change
request being written: what changes, in the order saved, each undone on its own, tried on a copy, then filed. A filed
request opens with each element before and after, what reads it, comments, the regression test and the pass
conditions, and is rejected or approved into a new version; a rejected one can be taken back into the edits being
written, and the versions are listed with compare, export and rollback. In a team the author cannot approve their own,
and approving one request keeps the edits others have not filed yet (see [A team studio](#a-team-studio)). The same
review from the command line:

```bash
ontlas review examples/library/studio.yaml acme-1.1.0.yaml   # a module version tried on a copy, against the flow's conditions
```

**7. Use it and plug it in (검색 · 질문, Operations › 연동 · API).** The box in the top bar (`Ctrl K`) jumps to any screen,
Object, decision table or query; 검색 · 질문 answers a question with what it understood, the verdict, the layers it
went through and its sources. 연동 · API lists who calls, each with its access policy (a caller with none is refused),
gives the four ways an agent or a platform takes the ontology (the MCP server, the REST API, the ontology as a YAML or
OWL file, a database connection a platform lends), each with something to copy, and has a panel that calls an endpoint
as a chosen access policy. `ontlas serve --users` gives a team one studio with roles (see
[A team studio](#a-team-studio)), and `ontlas mcp` and the token REST API give agents and platforms the same studio
inside a role (see [Agents over MCP](#agents-over-mcp)).

```bash
ontlas run examples/library/studio.yaml revenueByCategory
ontlas translate examples/commerce/ontology.yaml revenueByCategory --to cypher
ontlas decide examples/library/studio.yaml returnEligibility I1001
```

The screens, as the menu names them. The list at the top left switches the ontology and, for those who may, leads to
the admin screens; the foot of the menu shows how far the definition has come.

| Part | Screen | Use it to |
|---|---|---|
| | 온톨로지 선택 · 온톨로지 만들기 | Pick the ontology to work in, with its domain pack, maturity and version; make one from domain pack modules, an existing ontology, files (definition drafts or an OWL vocabulary) or nothing, export it as a studio folder, and delete one made on the page (put back where the server keeps them) |
| | 홈 | See the maturity in four steps, the four parts, the Objects, what waits and the steps of starting |
| | AI 초안 생성 | Make drafts from uploaded material and follow them to their review |
| Semantic Layer | 규칙 | See the rules by layer, try a decision on typed values, read the checks, and keep the parameters, metrics and functions (see step 3) |
| | 규칙 초안 | Review the rule drafts: approve, correct and approve, or take out |
| Ontology | Object | List the Objects with their definition, Entities, rules, maturity and owner |
| | Entity | Keep Entities, Properties, restrictions and state transitions |
| | 그래프 탐색 | See and edit Relations as a graph; open the diagram workspace |
| | 용어 사전 | Keep the terms, the relations between expressions and the customer wording; bring a glossary in |
| | 개념 초안 | Review the Entities and Relations drawn from uploaded tables |
| | 모듈 라이브러리 | See the size, the layers with their modules, the versions and every module with its switch and its file; export |
| | 변경 요청 · 버전 | File, review, approve and roll back changes (see step 6) |
| Data Binding | 데이터 소스 | Connect a database or a platform's connection and see which tables are read |
| | Mapping | Set Properties against columns and codes, and see where they differ |
| | Entity Binding | Bind an Entity to a table, with the SQL it makes, a preview and the checks; the records are browsed from here |
| | 질의 | Keep registered queries, read them into each store's language and run them as an access policy |
| | Action | Define actions with preconditions and approval, try them, handle requests, and see whether the server writes to the source |
| Quality | 검증 질문 | Keep the questions with known answers and the held-out set |
| | 검증 | Run the questions, read why a wrong one is wrong, and set the pass conditions |
| Operations | 저장소 · 엔진 | See every store, query language, reasoner and embedding as measured now |
| | 연동 · API | See who calls and under which policy, copy the address, command or settings for each way in, and call the API as a policy |
| | 접근 정책 | Say what each caller may read, see and run |
| | 파이프라인 관제 | See the stages as they change, the log of decisions and the conditions that raise an alert |
| | 근거 지도 | Cross Objects with the documents that name their Entities and find what has no ground; its tabs hold the documents, the asset explorer and the asset graph |
| 상단 | 검색 · 질문 · 자료 업로드 · 할 일 · 알림 · 내 계정 | Search or ask, upload material, settle what waits, and see your roles, the guide and the way out |
| 관리 | 온톨로지 설정 · 멤버 · 권한 | See the names, the quality targets and how approval works; export; see the users and what each role may do |
| | 시스템 관리 | 관리 현황, 사용자 · 그룹, 인증 · 보안, 도메인 팩, 기준 어휘, AI 운영, 감사 로그 and 시스템, with what the server really holds |

## What it looks like

The screens below are the example library in `examples/library` (common concepts, commerce and its operations, a
fashion extension, one customer's differences, and the bindings to one database), rendered by `tools/render_screens.py`
from `ontlas preview` (the library, the query, the decision and the data map) and from a running `ontlas serve` (the
rest). Nothing on them is drawn by hand: the modules, the compiled queries, the rows from both backends, the decision
with its evidence and the reach of a column change are what the library computed for that example.

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/library.png" alt="Ontology library screen: every domain package with its kind, version, requirements and an on/off switch for this studio, the layers plugged in now, and what unplugging a module would take away" width="920">
</p>

<p align="center"><b>The ontology library.</b> Commerce and every domain added later live as separate, versioned packages;
a studio plugs in the ones it needs, and the screen shows what unplugging one would take away before it happens.</p>

<table>
  <tr>
    <td width="50%"><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/ontology.png" alt="그래프 탐색: Objects and Entities as nodes coloured by Object, Relations as arrows between them, the layout and zoom controls, and the pane of the chosen item beside the graph"></td>
    <td width="50%"><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/query.png" alt="Query screen: one ontology query, its text in nine backend languages, and identical rows from the SQL source and the SPARQL graph"></td>
  </tr>
  <tr>
    <td><b>The ontology as a graph.</b> Objects and their Entities as nodes coloured by Object, Relations as arrows between them. A node or a Relation picked is named in the bar above with its actions and opened in the pane beside the graph, where a Relation is edited; the search finds a node, the chips hide and show kinds, and the layouts are the graph engine's.</td>
    <td><b>One query, every language.</b> The ontology query, its text for PostgreSQL, MySQL, Oracle, SQL Server, Cypher 25, GQL, SPARQL, SQL/PGQ and Gremlin, and the rows from each backend side by side.</td>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/workspace.png" alt="Diagram workspace: the Entities of every module as cards on a canvas, the tree on the left and the chosen Entity's form on the right"></td>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/rules.png" alt="Decision table editor: a table edited in place with its hit policy, the simulator and the tests beside it"></td>
  </tr>
  <tr>
    <td><b>Model.</b> The workspace: cards on a canvas, a tree by Object or by module, and the picked Entity's form, data, uses, YAML and comments. Draw a relation from card to card, drop a column on a card, give an element a status, try the edits on a copy, file them.</td>
    <td><b>Rules.</b> A decision table edited where it stands, checked for overlaps and gaps as it is edited, and tried on a record with what single change would turn the answer.</td>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/decision.png" alt="Decision screen: the decision table with the rule that fired, the evidence path to source columns, and an action request waiting for a person's approval"></td>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/map.png" alt="Data map screen: everything that depends on one column, what an agent can reach, and the data nobody uses"></td>
  </tr>
  <tr>
    <td><b>Decide and act.</b> A decision table (here with the customer's own VIP rule plugged in ahead of the standard ones, each rule citing its policy), the source column behind every input, and an agent's action request waiting for a person.</td>
    <td><b>The data map.</b> What a column change touches, from property to agent; what one agent can reach; what nobody uses.</td>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/home.png" alt="홈: the maturity in four steps, the four parts with their numbers, the Objects, what waits and the steps of starting"></td>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/record.png" alt="Record page: one record with its values and columns, its state, linked records, the decisions on it and the documents that mention it"></td>
  </tr>
  <tr>
    <td><b>Home.</b> Where the ontology stands: the version in use, how far its definition has come in four steps (L0 개념 to L3 검증), its four parts (rules, ontology, data binding, quality) with their numbers and state, the Objects with their level, what waits, and the six steps of starting.</td>
    <td><b>A record.</b> Values with their columns, the state machine's current and next steps, the actions a role may take, linked records, what the decisions say of it now, the documents that name it, and its history.</td>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/rule-layers.png" alt="규칙: AXIOM, Custom and Standard with their counts, the rules in one list, and a test that decides on typed values"></td>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/objects.png" alt="Object: the Objects with their Entities, rules, maturity and owner, and the chosen one beside the list"></td>
  </tr>
  <tr>
    <td><b>Rules in three layers.</b> AXIOM (laws and integrity, checked first), a customer's Custom rules and the common Standard ones, with their counts; every rule in one list with its layer, source, version and owner; and beside it a decision tried on typed values, with the path it took through the layers.</td>
    <td><b>Objects.</b> The top-level classifications with their definition, tier, owner and how far their Entities have come (L0 to L3); one opened shows its Entities, relations, rules, rule drafts, questions, grounds and version.</td>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/rule-form.png" alt="규칙 추가 · 편집: a rule card's fields, what saving does, and the checks run while it is typed"></td>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/entity.png" alt="Entity: the Entities by Object, and the chosen one with its definition, grounds, readers, YAML and comments and its Properties"></td>
  </tr>
  <tr>
    <td><b>A rule on its form.</b> The card's statement, layer, the Object it applies to, conditions, result, exceptions, source, owner and type, and what a definition draft files it by (분류, 관련 대상, 대표 법령, 근거 종류, 정책서 대조). Beside it, what saving does (the edit joins the change request being written) and the checks run while it is typed.</td>
    <td><b>Entities.</b> A tree of Entities by Object, and the chosen one: its definition, grounds, readers, YAML and comments, and each Property with its vocabulary, type, allowed values and source column. Restrictions and state transitions follow below.</td>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/lexicon.png" alt="용어 사전: the terms with the definition each names, and the chosen term with its synonyms, the word it must not be taken for, its rules and what uses it"></td>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/changes.png" alt="변경 요청 · 버전: the change request being written with what it changes and the edits in the order saved, the version in use and the one it would make"></td>
  </tr>
  <tr>
    <td><b>The glossary.</b> Each term with its English label, kind, the definition it names and its rules; the chosen one with its synonyms, the word it must not be taken for, what uses it and its owner. The relations between expressions and the customer wording by channel follow below, and 가져오기 brings a glossary file in.</td>
    <td><b>Change requests and versions.</b> The request being written: what it changes, the edits in the order saved (each undone on its own), the regression test and 검토 요청; above it the version in use and the one this request would make.</td>
  </tr>
  <tr>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/actions.png" alt="Action: the actions, and the chosen one with its parameters, precondition, state change, approval and who may ask, marked as writing off"></td>
    <td><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/graph.png" alt="레코드 그래프: one record with the records it is linked to, opened relation by relation"></td>
  </tr>
  <tr>
    <td><b>Actions.</b> What an agent may ask to be done: parameters, the decision that must allow it, the state it moves to, how it is approved and who may ask or run it. 쓰기 꺼짐 · 실행 결과만 기록 says this server was not started to write to the source.</td>
    <td><b>The record graph.</b> From one record, the records it is linked to, opened relation by relation; the path between two records; and what the decisions say of the one picked.</td>
  </tr>
</table>

## The pieces

| Module | What it does |
|---|---|
| `model` · `validate` | The definition: object types (key, table, properties with type, enum values and column), links (`on` a join or `via` a link table; cardinality, inverse, transitive, symmetric, required), interfaces, state machines, decision tables, actions, roles with row filters, registered queries and validation questions. JSON or YAML, checked for consistency before anything runs |
| `expr` | Computed properties: arithmetic, comparisons and functions over an object's properties, aggregates along links (`sum(hasItem.line_total)`) and the latest or earliest value of a series, typed and checked, compiled into SQL, SPARQL and Cypher (GQL and SQL/PGQ take the ones without links and dates) |
| `modules` · `library` | Domain knowledge as packages: common concepts, domains, industry extensions, one customer's differences and the bindings to a database, each versioned and kept apart in a library, composed in requirement order with the origin of every element recorded, plugged in and out at run time and swapped for an edited version; an overlay holds modules in memory over a library folder |
| `draft` · `induce` · `mapping` | Files (CSV, TSV, Excel) and databases (SQLite, PostgreSQL) read into a drafted definition and its bindings: objects, keys, types, allowed values, relations, state machines from a history table, actions, roles, questions and queries, each with its reason; a decision table drawn from past outcomes; or the tables bound onto a standard module instead of becoming new types |
| `review` | The flow's stages and pass conditions, agreement with past decisions, and change requests: a new module version tried on a copy of the studio, reviewed against the conditions, approved by another person, saved as a version |
| `identity` | Records that several systems keep under their own keys, joined by match rules into one object with a crosswalk, with the evidence for every join |
| `bindings` | The definition checked against the actual database: tables and columns, types, duplicate keys, missing required values, enum values the definition does not know, links that point at nothing |
| `ir` · `check` | The ontology query: a typed graph pattern with filters, `exists`, multi-hop links, aggregates, order and parameters. The check resolves link direction (inverse names included), types every literal and parameter, and explains what is wrong in plain sentences |
| `compile` | One compiler per language: SQL (PostgreSQL and SQLite natively, every other dialect through sqlglot), Cypher 25, ISO GQL, SPARQL 1.1, SQL/PGQ, and the `CREATE PROPERTY GRAPH` for the bound tables. Literals are always bound as parameters; NULLs sort last everywhere |
| `parse` | SPARQL and Cypher read back into the IR, so a query in either runs on any backend |
| `backends` | SQLite, any DB-API connection, rdflib, any SPARQL 1.1 endpoint, Neo4j, Gremlin Server, and a callable adapter for engines without a driver here. Each declares what it can do |
| `projection` | Source rows to RDF triples or property-graph nodes and edges, and the change set between two projections for incremental loads |
| `decide` · `actions` · `roles` | Decision tables with evidence, exported to GoRules JDM and run on ZEN; actions with checked parameter values, human approval, write-back, an external request to allowed hosts, rollback and an audit trail; role scoping of every query and tool, with masked properties |
| `reason` | Inverse, symmetric and transitive links derived with their reasons; shape checks; SHACL generated and validated; OWL 2 RL materialization |
| `exchange` | OWL and R2RML export with a report of what each format cannot hold; OWL/RDFS import as a starting definition |
| `catalog` | The data space as a graph: databases, tables, columns, files, collections, ontology objects, queries, decisions, actions, roles, agents |
| `nl` | A schema card and IR guide for a language model, and a loop that checks its answer and asks again with the issues |
| `conformance` · `studio` · `cli` · `mcp_server` · `preview` | Runs across backends compared row for row; the facade; the `ontlas` command; the MCP server; the studio page as a file |
| `repository` | Repositories of raw files: folders and files by path in an index, bytes by hash, kept in a folder or gone with the visitor |
| `web` | The studio page served over HTTP with the standard library only: the pipeline board, flow with its pass conditions, the data catalog, the one JSON, the draft and standard bindings, library with the module editor and change review, ontology graph, queries, decisions, approvals and rollback, checks, and the guide with its video; one studio per visitor, or one per team behind a sign-in |

## Define once

```yaml
areas:                      # the top level (shown as Object): an area of the business with a definition of its own
  Order: {label: 주문, description: 주문과 주문에 담긴 주문상품, aligned: [https://schema.org/Order]}
objects:                    # the concepts under it (shown as Entity)
  OrderItem:
    label: 주문상품
    area: Order
    source: {table: order_items}
    key: item_id
    properties:
      delivered_at: {type: datetime, label: 배송 완료 일시}
      item_status:  {type: enum, values: [NORMAL, RETURN_REQUESTED, RETURNED]}
    states: {property: item_status, initial: NORMAL, transitions: [{from: NORMAL, to: RETURN_REQUESTED}]}
links:
  hasItem: {from: Order, to: OrderItem, cardinality: one_to_many, on: {order_id: order_id}, inverse: itemOf}
decisions:
  returnEligibility:
    target: OrderItem
    inputs:
      days_since_delivery: {type: integer, days_since: delivered_at}
      category_returnable: {type: boolean, path: [ofSku, skuOf, inCategory], property: returnable}
    outputs: {eligible: boolean, reason: string}
    rules:
      - {when: {days_since_delivery: "null"}, then: {eligible: false, reason: 배송 완료 전입니다}}
      - {when: {category_returnable: "false"}, then: {eligible: false, reason: 반품할 수 없는 카테고리입니다}}
      - {when: {days_since_delivery: "<= 7"}, then: {eligible: true, reason: 반품기간 7일 이내입니다}}
roles:
  customer_agent:
    read: [Order, OrderItem]
    row_filters:
      Order: {eq: [$self.customer_id, {principal: customer_id}]}
```

The full example is [`examples/commerce/ontology.yaml`](https://github.com/PlateerLab/ontlas/blob/main/examples/commerce/ontology.yaml): eight object types
(one of them a price history), nine links, eight computed properties, a decision, an action, three roles, twelve
registered queries and seven validation questions.
An object type with no `source` is a definition only: its decisions take typed values, and it binds to a table later
without being written again. `areas` and `area` are optional; a definition without them is grouped by module.
Decision cells are a small FEEL subset: `-`, `null`, `not null`, `<= 7`, `[1..7]`, `"VIP"`, `!= "NORMAL"`,
`in ["A", "B"]`, `true`.

A column that needs changing on its way in takes a `transform` over `value`. Every language reads the changed value, a graph holds
the stored one, and an action cannot write it back:

```yaml
price:   {type: decimal, column: price_cents, transform: "value / 100", source_type: integer}
on_sale: {type: boolean, column: on_sale_yn, transform: "value = 'Y'", source_type: string}
```

An interface is queried like a parent type. `{match: {x: Named}, return: [x.name]}` reads every type that implements it, on every
store, and a role reads through it only if it reads each of those types without a row limit. Its properties keep the same name on
each type and are stored, not computed.

## Computed properties and series

```yaml
OrderItem:
  properties:
    line_total: {type: decimal, expr: "unit_price * quantity"}
Order:
  properties:
    total:  {type: decimal, expr: "coalesce(sum(hasItem.line_total), 0)"}
    billed: {type: decimal, expr: "if(status = 'CANCELLED', 0, total)"}
PriceChange:
  series: {time: changed_at, of: priceOf}        # observations over time
Sku:
  properties:
    last_price: {type: decimal, expr: "latest(priceChanges.price)"}
```

A computed property is asked for like any other (`o.total`, in IR, SPARQL or Cypher) and compiled into each
language: a scalar subquery in SQL, `BIND` and a grouped subquery in SPARQL, a pattern comprehension in Cypher. It is
never copied into a graph, so the conformance run compares the expression itself across backends. Nulls follow one
rule everywhere (division by zero and an `if` on a null condition give null). Functions: `coalesce`, `if`, `abs`,
`round`, `floor`, `ceil`, `lower`, `upper`, `length`, `concat`, `year`, `month`, `day`, `days_between`; aggregates
along a link path: `sum`, `avg`, `min`, `max`, `count`, and `latest` / `earliest` on a series. A language that has no
form for one says so before it runs.

## Swap anything: the ports

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/adapters.png" alt="저장소 · 엔진: every store with what was measured now, the query languages, the reasoner and the vectors" width="100%">
</p>

Every part a deployment might want different is a port with a small interface, a registry, and a test that says the swap
changed nothing.

| Port | In the package | Add your own | The test |
|---|---|---|---|
| Query backends | SQLite, PostgreSQL, MySQL, Oracle, SQL Server, any DB-API, rdflib, SPARQL endpoints, Neo4j, Gremlin, a query gateway | `kind: dbapi`, or a `Backend` | `ontlas conformance`: the same rows on every store |
| Vector stores | memory (exact), Qdrant, pgvector | `register_vector_store` | `ontlas vectors`: every store against exact search |
| Embedders | hash (no model), any OpenAI-shaped service, fastembed (a local multilingual model) | `register_embedder` | Search checks in `space.checks`, a pass condition of the flow |
| Reasoners | rules, owlrl, shacl, reasonable, any HTTP service that takes and returns turtle | `register_reasoner` | `ontlas reasoners`: engines of one logic must derive the same facts |
| Relation readers | basic (any chat model), xgen-ontology-build's relation formation | `register_reader` | Both read the same passages; every relation's two ends are concepts its sentence names |
| Domains | modules in a library | a package | Validation questions and the flow's conditions |

Two OWL 2 RL engines run side by side is how `reasonable` 0.4.4 was found to join every subject of an inverse functional
property with `sameAs`. It stays available and off the default list. That is what the comparison is for.

```yaml
space:
  embedder: {kind: openai, url: https://models.example/v1, model: bge-m3, key_env: EMBED_KEY}
  vectors:
    main: {kind: qdrant, url: http://localhost:6333}
    pg:   {kind: pgvector, dsn: "${ONTLAS_PG}"}      # every store holds the same chunks
  documents: ["docs/*.md", "policies/*.pdf"]
  checks:
    - {text: 택배가 일주일째 안 와요, document: 배송안내}   # the flow's index stage: found in the top five?
reasoners:
  rl: {kind: owlrl}
  theirs: {kind: http, url: https://reasoner.example/infer}
```

## Documents in the space

A document that comes in, through the catalog or `space.documents`, goes two ways at once.

- **Vectors.** It is cut at sections and sentences, embedded, and written to every vector store. Only what changed is embedded; a store that missed a round catches up on the next one. Every vector carries the folder its file is in and the model that made it. A file's embedding can be turned off in the catalog: its documents leave the stores, and so the search, and stay in the document ontology.
- **Document ontology.** It becomes rows of document, section and concept. Concepts are the names the definitions give (objects, properties, allowed values, decisions, glossary terms) plus the words a document keeps returning to, found without a model. The rows run on the same engine as the domain ontology, so the same compilers and the same conformance apply.
- **Relations, when asked.** With a model connected, 관계 추출 (근거 지도 › 문서) sends the sentences that name two concepts or more to a reader, their concepts numbered, and keeps a relation only between concepts its sentence names, with that sentence. Relations join the document ontology (`relationsOf`, `relationNames`) and its graph, and an answer lists the ones its shown passages state. They do not change which passages a search finds: on a set of 100 relation questions the ranks were the same with and without them. Readers are a port: `basic` needs only the model, `ontology-build` is xgen-ontology-build's relation formation (`pip install "ontlas[build]"`). A reading runs on the server, stops and resumes, covers a folder or everything, and with `--repositories` is kept next to them; a passage that changes is read again.

<table>
  <tr>
    <td width="50%"><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/documents.png" alt="Document ontology screen: documents, sections and the concepts they mention as a graph"></td>
    <td width="50%"><img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/search.png" alt="검색 · 질문: a question answered with what was understood, the verdict, the layers it went through and its grounds"></td>
  </tr>
</table>

A search takes more passages from the store than it returns and orders them by the model's score and the question's own
words, since the nearest passage to a model is not always the one that says it.

Concepts tie the two together. `ontlas search` returns the passages and the definitions a question names, an Entity's 근거
tab shows the sections that mention it, and the asset graph shows which queries a document touches. Without a reading, concepts are tied
by co-mention only: two names in one section. A relation a reader found replaces the co-mention between its two concepts.

Folders are ranges. A search, a question (`folder` on `POST /v1/search` and `POST /v1/answer`, and on the MCP tools), the document
graph and a reading keep to one folder and the folders under it, and a role's `documents` take file paths and patterns such as
`정책/*` besides document names.

Vectors of two models do not compare, so changing the embedding model embeds every passage again. On 저장소 · 엔진 › 벡터 · 임베딩 a change first
lists what it embeds again (documents, passages, characters) and the time it takes, measured on a few passages with the new model;
the stores are emptied and filled again only when you go ahead. A model that fails leaves the stores as they were, and the files
it could not embed say so.

## One question over everything

Definitions and rules from the ontology and passages from the documents sit in one index, so a rule and the clause it cites land
side by side. How the index is searched is a port, `space.retriever`: `omnifuse` fuses lexical and dense seeds with the graph between
the entries (`pip install "ontlas[omnifuse]"`), and `words` needs nothing beyond the space. With nothing said, the best one
installed is used.

A question then goes to whatever can settle it, and a model is the last resort:

| The question has | What answers | A model? |
|---|---|---|
| a key and a decision's name: `주문상품 I1001 반품 되나요?` | the decision table, with the rule, the source values and the clause | no |
| a key alone | the record, under the role's limits and masks | no |
| a registered query's name | the query | no |
| anything else | rules and passages found; a data question becomes a query | words only what was found |

The page's 검색 · 질문, `POST /v1/answer` and the MCP tool `answer_question` are the same code. `ontlas compare` puts one question file to
one model three ways, with nothing, with the documents alone and through the space, and counts the right answers. What is right comes
from the file, not from a model:

```bash
ontlas compare examples/library/studio.yaml examples/library/answers.yaml --llm-url https://models.example/v1 --llm-model my-model
```

## Plug domains in and out

Domain knowledge comes and goes, so it is packaged. A library keeps each package apart as
`<name>/<version>.yaml`; a studio composes the ones it needs.

| Kind | Example | What it holds |
|---|---|---|
| `core` | `core` (공통 개념) | Concepts every domain hangs from: party, agreement, the `Named` interface |
| `domain` | `commerce`, `commerce-operations` | The standard definition of a domain, aligned to schema.org or GS1, with no tables in it |
| `industry` | `fashion`, `food` | What one industry adds on top of the standard: material and season, expiry and storage |
| `customer` | `acme-overlay` | Only what one customer does differently: an extra property, a VIP rule placed ahead of the standard ones, a query taken out |
| `binding` | `commerce-bindings` | The tables and columns of one database. Swap it, and the same definition reads another system |
| `quality` | `return-quality` | How a definition is checked: validation questions and the flow's pass conditions. Attached, it raises the studio's conditions where it asks more; detached, they go back |
| `method` | `build-rules` | How a draft is built from data: the draft rules (allowed-value limits, key, state and person hints) the data tab starts from |
| `dictionary` | a drafted `shop-dictionary` | A system's words and messages: a glossary finds the standard's names and reaches the language model's schema card, and a decision that answers with a message code shows the message |

```yaml
module: acme-overlay
kind: customer
requires: [commerce, commerce-bindings]
extend:
  objects:
    OrderItem: {properties: {gift_wrap: {type: boolean, label: 선물 포장}}}
  decisions:
    returnEligibility:
      inputs: {customer_grade: {type: string, path: [itemOf, placedBy], property: grade}}
      rules_prepend:
        - {id: vip-window, when: {customer_grade: '"VIP"', days_since_delivery: "<= 14"},
           then: {eligible: true, reason: VIP 고객은 14일까지 반품할 수 있습니다}, cite: ACME 운영 정책 4.1}
remove: {queries: [wishlistCount]}
```

```python
from ontlas.library import Library
lib = Library("examples/library")
studio = Studio.from_library(lib, ["commerce-operations-bindings", "fashion", "acme-overlay"])  # + requirements
db = studio.add_backend("source", SqliteBackend())
for seed in ("examples/commerce/seed.sql", "examples/library/seed_operations.sql"):
    db.script(open(seed, encoding="utf-8").read())

studio.composition.owner("property:OrderItem.gift_wrap")     # 'acme-overlay': every element knows its module
studio.detach_impact("fashion").removed                      # what would go, before anything goes
studio.detach("acme-overlay"); studio.attach("acme-overlay") # the VIP rule leaves and comes back
studio.detach("commerce")                                    # refused: three modules depend on it (cascade=True to take them too)
studio.run("allParties")                                     # one concept, two types: customers and sellers
studio.check_bindings()                                      # the definition against the actual database
```

A concept with no table of its own is asked through its subtypes: in SQL as the `UNION ALL` of their tables,
in SPARQL and Cypher through the concept's type or label, and the conformance run checks the answers agree.
`aligned` IRIs export as `skos:exactMatch`, `cite` as `dcterms:source`, the module as `rdfs:isDefinedBy`; an
imported standard keeps its original IRIs as alignments.

A deployment offers one library or several (`ontlas serve studio.yaml --library other/studio.yaml`), and the page switches
between them, each with its own definition, data and applied drafts. A new one is made on the page (온톨로지 선택 ›
온톨로지 만들기) four ways: from a domain pack (the modules chosen, with what they require), on an existing ontology
(its modules, to add Custom ones over), from files (a definition draft's YAML, JSON or Excel files read as one draft,
or an OWL vocabulary in Turtle or RDF/XML as a module), or empty, to fill from AI drafts. The result says what it holds
and, for an import, what was adjusted and what had no place in a module. On a server that writes (`--library-write`) a
library made this way is the server's: it is kept as a studio folder of its own under `made/` beside the studio file
(`--libraries DIR` names another folder, `--libraries-max` how many, 30 unless given), everyone on the server sees it,
and one that is deleted is moved to `.deleted` there and can be put back from the page. In a team each person opens
the ontology they look at, so opening or making one does not move anyone else. Elsewhere it lives with the
visitor's session, three at most. 내보내기 gives any library as a studio folder in a zip (the studio file and the file
of each module it applies), which `ontlas serve` serves and `--library` offers, and that is how one is reached over
`/v1`. Where approved changes are saved, each library is written to its own folder.

## Adapt a domain

Adapting a domain to a system means leaving its standard as it is and writing only what differs. Whatever you start
from, the result is the same kind of file, a module, so it is checked, reviewed, versioned, attached and detached like
the rest.

| You have | Path | It becomes |
|---|---|---|
| A standard that fits, and the system's tables | `mapping.suggest`, 표준에 연결 in the page's draft review | A `binding` module |
| Table and code definitions, a SQL script, an ERD file | `ontlas draft --definitions` | A definition and its `binding`, with no rows needed |
| A code definition whose codes refer to other codes | The same draft | Decision tables: what each code implies, or what each state allows |
| A glossary, a message list | The same draft | A `dictionary` module |
| Data files or a database | `ontlas draft` | A definition and its `binding` |
| Past outcomes | `induce`, the rules step of a draft | A decision table |
| Policy text, in any document format | `ontlas policy-draft`, the page's 규칙 초안 | A module with a decision table, each rule citing its clause |
| An OWL or RDFS ontology | `ontlas import-owl`, the page's 온톨로지 만들기 | A starting definition, or a library of its own |
| Definitions drafted as tables (Objects, Entities, rules by layer, named values, a glossary; YAML, JSON, or an Excel workbook with a sheet for each) | `ontlas library import-definitions`, the page's 온톨로지 만들기 › 파일 가져오기 | A domain module, an `axiom` module for the rules marked AXIOM, a `customer` module for those marked Custom |
| Edits on the item screens | Objects, Entities, properties, relations, rules, questions | The `workspace` module, of kind `customer` |
| Knowledge of the domain | A YAML file, or 파일 편집 on 모듈 라이브러리 | A module of any kind |

A definition drafted from one system describes that system. To carry a domain across systems, bind the tables to a
standard instead: its queries, decisions and questions carry over, less what the tables do not hold. Matching goes by
names, labels and types, and a glossary says which of the system's words mean what the standard names (회원 is 고객).
A system that abbreviates its names still gets partial suggestions, and a person picks the rest: choosing another
table matches its columns and relations again.

A studio reads one source database today. A draft from definitions alone is checked against an empty database of
the same shape, which says nothing about real rows: for that, get read-only access to a development database.

A definition draft kept as a workbook is read a sheet per section (Object, Entity, 규칙, 용어, ...), the header row
naming the columns by the keys the YAML uses or by their Korean names; it needs `pip install "ontlas[xlsx]"`. The
import's report says what was adjusted and what was left out, and for a workbook that includes every sheet and column
it did not read.

### Anything in, one JSON

`ontlas ingest` reads each file through an adapter and rolls everything into one JSON, which `ontlas draft --definitions`
takes like any other input. On the page, the same adapters read what reaches the catalog, and 변환 결과 on 자료 업로드 shows
the JSON.

| Input | Read as |
|---|---|
| `.sql`, `.ddl` (PostgreSQL, MySQL, Oracle, SQL Server, SQLite) | Tables, keys, references, comments as names, `ENUM` and `CHECK ... IN` as allowed values |
| `.dbml`, `.pdm` (PowerDesigner), `.mwb` (MySQL Workbench) | The same, from the modelling tool's own file |
| `.db`, `.sqlite` | The tables, keys and references of a SQLite file |
| `.csv`, `.xlsx`: table, index, code, glossary and message sheets | By their headers, Korean or English, under a title and behind a cover sheet. Group rows and reference columns of a code definition are understood |
| `.docx`, `.pptx`, `.hwp`, `.hwpx`, `.pdf`, `.html`, `.md`, `.txt` | Text by section, for policy drafting (`.pdf` needs `[pdf]`). A `.hwp` with a password or a viewing-only copy is refused |
| `.json`, `.yaml`: OpenAPI 3 or Swagger 2 | Schemas as tables, `$ref` and lists as references, `enum` as code groups, operations as sections, and each writing operation as an action to review, behind a person's approval |
| `.json` | The same shape, written by hand or by another tool |

```json
{"tables": [{"name": "TB_ORDER", "label": "주문", "primary_key": ["ORDER_NO"],
             "columns": [{"name": "ORDER_NO", "label": "주문번호", "type": "varchar"}, {"name": "STAT_CD", "code": "OD01"}],
             "references": [{"columns": ["MEMBER_NO"], "table": "TB_MEMBER", "ref_columns": ["MEMBER_NO"]}]}],
 "codes": {"OD01": {"label": "주문상태", "values": [{"code": "10", "name": "주문접수"}]}},
 "terms": [{"term": "고객", "synonyms": ["회원"]}],
 "messages": [{"code": "MSG-RT-001", "text": "반품 가능 기간이 지났습니다."}],
 "documents": [{"name": "교환정책서", "kind": "policy", "text": "...", "sections": [{"title": "1. 반품 기간", "text": "..."}]}]}
```

A format with no adapter here goes through a plug-in: a Python file that calls `ingest.register([".ext"], fn)` and
returns `Definitions`, loaded with `ontlas ingest --adapter FILE` or `ONTLAS_ADAPTERS`. A binary format nothing reads is
refused with what to export it to.

## The pipeline board

What is wrong is said as something to act on (`GET issues`), the same on the board, the home, 할 일 and 검증. An alert opens a
panel where it was pressed: the items behind it, why they came to be, what they reach and the ways to fix each, marked as fixed
here (in the workspace, then a change request), applied at once (taking a module off, shown first on a copy, or reading the source
again) or fixed at the source (with the list to hand over). Alerts that read the same broken column stand under one cause; a
failure is only gathered under another when what failed reads what is broken. Choosing a fix opens the field that mends it, with
a bar saying which problem this is and what is next, and when the change goes in the board measures again and the issue closes.
When each opened and closed is written to the journal.

파이프라인 관제, under Operations, shows the stages as tiles, with the log of decisions and the conditions that raise an
alert beside them. 그림 보기 draws the pipeline as a building: raw data at the bottom, then conversion, the ontology, the
storage adapters, its use, and verification at the top, with the data climbing one belt through the floors.

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/monitor.png" alt="파이프라인 관제: the stages as tiles, the log of decisions and the conditions that raise an alert" width="920">
</p>

Nothing on it is scripted. Every number comes from the space as it is now, so it works on any ontology, including a
draft from your own files: tables and rows, files by kind, modules, objects and relations, query results compared across
backends, decision agreement, question accuracy, pass conditions. Numbers refresh every 5 seconds. The flow is measured
again as soon as the definition or the files change, and otherwise every 20 seconds while the board is open.

A stage that misses its pass conditions stops the data at its floor, and a failure that crosses floors is told as a chain
from where it shows down to the module that brought it:

```text
질의 ← DB 대조 ← 식품 업종 확장 모듈   (Sku.expires_on, Sku.storage)
```

To see that on the example library, open 그림 보기 and choose 장애 테스트: it really applies a module whose columns the
database does not have, and 복구 takes it off again. A studio file names such modules itself:

```yaml
monitor:
  faults:
    - {label: 식품 업종 모듈 적용, attach: food}
```

For a visitor, each draft applied becomes a pipeline of its own. The 데이터 list on 데이터 소스 switches between them, the
one you started with (기본 데이터) included, and a visitor keeps up to five. In a team a draft goes into the change request
being written instead, so everyone stays on one definition.

## The data catalog

Raw material comes first. 자료 업로드 keeps files in repositories, by folder, and says what each one turned out to be.

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/catalog.png" alt="자료 업로드: files held before they are sent, and the uploaded material with what each file became" width="920">
</p>

| You do | It does |
|---|---|
| Drop files or a whole folder | Uploads into the current folder and keeps the folder's structure. `.DS_Store`, `Thumbs.db` and Mac archive metadata stay out |
| Upload something it cannot read | Keeps the file and says why on its row. Images, video and archives are kept as they are, so a repository can hold everything a project has |
| Look at a row | Kind, size, rows or sections, and where it goes: a table or a definition sheet to the domain and binding modules, a code sheet to value names and decision tables, a glossary to the term dictionary, a document to the policy draft |
| Open a file | First rows or sections, its share of the JSON, and a download |
| Clear a file's or folder's 초안 box | Leaves it out of 변환 결과, the next draft, the search and the document ontology, and keeps it in the catalog |
| Clear a file's or folder's 임베딩 box | Takes its documents out of the vector stores, and so out of search; they stay in the draft and in the document ontology. Each row says 임베딩됨, 임베딩 대기, 임베딩 실패 or 꺼짐 |
| Switch repository | The draft reads that repository's files from then on |

A path in a repository is a name in an index, never a path on disk: the bytes are stored under their SHA-256, so nothing
a visitor types reaches the file system, and two copies of a file cost one.

Without `--repositories` the files go with the visitor's session, which suits a public demo. With it they stay in that
folder across restarts, one set for all visitors. `--file-kb`, `--max-files` and `--total-mb` set the limits, and
`--allow-connect` adds 서버 경로, which brings in a file or folder from the server's own disk.

```bash
ontlas serve studio.yaml --repositories ./repositories --file-kb 51200 --max-files 2000 --total-mb 4096 --allow-connect
```

## Start from your own data

A definition does not have to be written first. `ontlas draft` reads files or a database and drafts the two
modules a library expects, a definition and its bindings, keeping the reason for every choice:

| | How it is decided |
|---|---|
| Objects | One per table, after the W3C Direct Mapping; a table of two relation columns and nothing else becomes a many-to-many link instead |
| Keys | The declared primary key; for files, a column whose values are all present and distinct (a row number when none is) |
| Types | A database's declared types (ISO text in SQLite is read as dates); for files, the values: integers with or without thousands separators, decimals, dates, date-times, booleans. Values with leading zeros stay text, as codes |
| Allowed values | Text columns whose few values repeat |
| Relations | Declared foreign keys; otherwise a column named after another table's key (the same name, `<table>_<key>`, `<table>_id`) whose values are all found among that key's values. A key name many tables share, such as `id`, does not make a relation by its name alone |
| States | A status column (by the state name hints) with allowed values; a table that keeps past states of the same rows gives the transitions in the order they happened and the usual first state, and becomes a series. One action per state things move into |
| Roles | A viewer, an operator when there are actions, and for a person-like table (by the person name hints) a role that reads only one person's rows |
| Queries | A list per object, a count per relation and per allowed value, so a conformance run has something to compare from the start |
| Questions | Each generated query with the rows it gives now, to check later changes against |

```bash
ontlas draft members.csv products.csv orders.csv -o shop-demo   # shop-demo/library/, data.sqlite, studio.yaml
ontlas draft --sqlite shop.db --name shop                     # opened read-only; prints the two modules
ontlas draft --dsn "$ONTLAS_DSN" -o shop                         # the studio file reads ${ONTLAS_DSN}, not the password
ontlas draft *.csv --rules '{"enum_max": 10, "infer_links": false}' --drop object:Log -o shop-demo
ontlas serve shop-demo/studio.yaml
```

`-o` (`--out`) is the folder the draft is written to: `library/`, `studio.yaml`, and `data.sqlite` when it is drafted
from files or from definitions alone. A folder that already holds a `studio.yaml` is refused; without `-o` the modules
are printed and nothing is written.

Nothing in the draft is fixed. The rules above are `DraftRules` (how many distinct values still make a category,
whether relations are inferred, whether link tables become many-to-many links, the name hints for titles, parents
and keys, which queries to generate), and `Draft.revise()` takes a person's edits on top: another key column, a
property's type and allowed values, labels, left-out objects, properties and queries, a relation's cardinality, a
relation added by hand. A type chosen for a file's column is how its values are loaded, and a value that does not
fit is reported with its table, column and value.

On the example commerce database (primary keys declared, foreign keys not) the draft finds the eight relations of
the hand-written commerce ontology, the wishlist table as a many-to-many link included, and every generated query
returns the same rows from SQLite and from the RDF projection. On the page, AI 초안 생성 does the same for the files in
the catalog (and, with `--allow-connect`, 데이터 소스 takes a database address): the candidates wait on 개념 초안, where
단계별 검토 · 적용 builds the draft step by step with the reason for each object, key, type and relation, a person sets
the rules and edits each step (every edit is checked again on the spot, and errors hold the draft back), and the
draft is plugged into that visitor's studio. Any module, the example ones and a plugged-in draft alike, opens from
모듈 라이브러리 as its file (파일 편집): edit its objects, decisions, questions or roles, check it, and save it into that
visitor's library; a plugged-in module is swapped in at once (`Studio.replace`). The library folder itself is not
written; download the file to keep it.
`examples/files` holds a fictional library's files to try it with.

Table and code definitions, the way projects keep them, name what the draft finds and give coded columns their
allowed values with their names: a table definition sheet (a row per column: table, column, their names, type, key,
code group, referenced table) and a code definition sheet (a row per code: group, code, name, in use), as CSV or
Excel with the usual Korean or English headers, or as JSON (`definitions.Definitions`). A column whose name says
its group, `주문상태(OD01)`, needs no group column. With definitions alone the draft reads the schema: an empty
database with the declared keys and references, so objects, keys, relations, allowed values and state lists
come before any row does.

A table keyed by several columns gets one key property that reads them all (`columns: [ORDER_NO, ITEM_SEQ]`). It is
one value to everything above the columns (`O1|2` to a decision, a request or a graph node), and SQL joins it column
by column. A standard's key can read several columns the same way, in a binding:
`columns: {item_id: [ORDER_NO, ITEM_SEQ]}`.

```bash
ontlas draft --definitions 테이블정의서.csv --definitions 코드정의서.csv --tables 'TB_*' -o shop   # the schema alone
ontlas draft --sqlite shop.db --definitions 코드정의서.xlsx                                       # names and codes for data
```

An allowed value carries its name in the definition itself: `values: {"10": 주문접수, "20": 결제완료}`, or `values`
with `labels`; an extension adds names to the ones given (`values_add: {"30": 배송중}`). On the page 자료 업로드
takes the same files beside the data (`examples/definitions` holds a fictional pair), and the diagram workspace's
Property form takes a value and its name as `10=주문접수`.

Two more ways to start. A decision table drawn from past outcomes (`induce.induce`, the rules step of the draft
review): a person picks the column that holds what was decided and the inputs, of the same table or one relation away;
each leaf of a shallow decision tree becomes a rule with how many past cases it covers and gets right, and a five-fold
cross-validation says how well it decides cases it was not drawn from. And bindings onto a standard instead of new
types (`mapping.suggest`, 표준에 연결 in the draft review): every table and column is scored against the standard's types
and properties (names, labels, aligned vocabulary, romanized Korean, types, allowed values, keys), relations come from
the draft's, and the confirmed matches become a binding module; what the tables do not carry is left out, with the
queries that need it. On the example commerce database it gives the bindings a person wrote, inherited properties
included.

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/draft.png" alt="AI 초안 생성: what to make, the material it stands on, and the jobs with where their review stands" width="920">
</p>

<p align="center"><b>AI 초안 생성 with the eight files of <code>examples/files</code> uploaded.</b> What to draft, the material it stands on (the domain pack, the uploaded files, the definition as it is), the four steps of a draft and the jobs. The candidates are then reviewed on 개념 초안, table by table: each source table is scored against the standards the draft compares with and bound to the standard object or kept as a new one, with an English name from the standards and the glossaries, its sample rows, why its key is a key and the match evidence. The later steps settle properties, relations, queries and rules the same way before the draft is applied.</p>

## A data source connected on the page

A server started with `--allow-connect` lets an ontology's admins connect its database on 데이터 소스 (Data Binding),
in a team as well: the setting is the ontology's, kept in its journal (or beside the repositories on a server of
one's own), and a restart connects it again. 연결 테스트 tries the form as it stands; 데이터 소스 연결 추가 connects it in
place of the source the studio file gives, reads it into the graphs and keeps it. 연결 해제 puts the studio file's back.

| | |
|---|---|
| Read-only | An account that may change data is refused when it is tried (PostgreSQL table privileges and superuser, MySQL grants, Oracle session and table privileges, SQL Server database permissions). A SQLite file is opened read-only; a PostgreSQL session is held read-only as well. An approved Action is recorded and the source left as it is |
| Secrets | The password, an SSH key pasted on the page and a token are sealed with the server's key (`ONTLAS_SECRET_KEY`, else `ontlas-secret.key` written once beside the journal or the repositories, readable by the server's account only), or named by an environment variable (`env:NAME`). The page never shows one again |
| Environment | 스테이징 or 운영 (읽기 복제본), shown with the source |
| How it is reached | 고정 IP 허용 shows the addresses the server reaches databases from (`--egress-ip`, repeat for more); SSH 터널 starts `ssh -N -L` for as long as the source is connected (`ONTLAS_SSH` names the program where it is not on the path); 사내 에이전트 is `ontlas agent` installed beside the database, which keeps the database's password, answers reads only (SELECT) in the shape of a query service, and is reached by its address and token |
| What it may read | Table groups by name prefix (`ord_*`), or groups a person makes of several prefixes with the Object they feed; a group left unread is out of the catalog, the drafts, the graphs and every query, and the Binding check says so (읽을 범위 밖) |
| Before it is connected | The uploaded table definition sheets stand in for the catalog: the binding forms choose tables and columns from them, with each column's words |

The catalog names each table's schema and the comment the database keeps for each column (or the definition sheet's
words for it); an Entity may name a schema and a row condition over its columns (`del_yn = 'N'`), which every
compiled query, the Binding check and the graphs read by. 이 데이터로 초안 생성 drafts from the connected tables
(in a team, into the request being written, where a relation named like one the ontology has takes the next free name).

```bash
ontlas serve studio.yaml --users users.yaml --journal journal.jsonl --library-write --repositories repos \
  --allow-connect --egress-ip 203.0.113.7 --egress-ip 203.0.113.8
ONTLAS_AGENT_DSN=postgresql://ro:...@db:5432/shop ONTLAS_AGENT_TOKEN=... ontlas agent --host 0.0.0.0 --port 7790
```

## Ask once

```json
{"match": {"o": "Order", "i": "OrderItem"},
 "edges": [["o", "hasItem", "i"]],
 "where": {"and": [{"eq": ["o.status", "DELIVERED"]},
                   {"not_exists": {"match": {"c": "Claim"}, "edges": [["i", "hasClaim", "c"]]}}]},
 "return": ["i.item_id", {"col": "o.order_id", "as": "order"}],
 "order": ["item_id"]}
```

Comparisons `eq ne lt lte gt gte`, `in` / `not_in`, `contains`, `is_null` / `not_null`, `and` / `or` / `not`,
`exists` / `not_exists`; aggregates `count count_distinct sum avg min max`; `{"from": "k", "link": "broader",
"to": "a", "hops": [1, 3]}` for a link from a type to itself; `{"optional": true}` for a left join. A link can be
written in either direction, by its name or its inverse. Named queries live in the definition with their
parameters, so a model or a person can pick one by name.

## Run anywhere

| Language | Backends (examples) | optional | exists | hops | contains | Adapter |
|---|---|---|---|---|---|---|
| SQL | PostgreSQL and SQLite natively; MySQL, Oracle, SQL Server, Snowflake, BigQuery, … through sqlglot | LEFT JOIN | EXISTS | recursive CTE | strpos · instr | `SqliteBackend`, `DbApiBackend` (qmark · format · numeric) |
| Cypher 25 | Neo4j, Memgraph, Neptune openCypher, Apache AGE | OPTIONAL MATCH | `EXISTS {}` | `*1..3` + WITH DISTINCT | CONTAINS | `Neo4jBackend`, loads by UNWIND · MERGE |
| GQL | Spanner Graph, BigQuery Graph, Fabric Graph | OPTIONAL MATCH | `EXISTS {}` | `{1,3}` + ANY | refused | `CallableBackend` around your driver |
| SPARQL 1.1 | rdflib, Fuseki, GraphDB, Stardog, Virtuoso, Oxigraph | OPTIONAL | FILTER EXISTS | path alternatives + DISTINCT | CONTAINS | `RdflibBackend`, `SparqlEndpointBackend` (Graph Store Protocol · Update) |
| SQL/PGQ | Oracle 26ai, Spanner | refused | refused | `{1,3}` | POSITION | `graph_ddl()` writes the property graph over the tables |
| Gremlin 3.8 | Gremlin Server, JanusGraph, Neptune | `optional()` | `where()` | `repeat().emit()` | TextP.containing | `GremlinBackend`, loads a projection with one list binding per script |

A backend declares its `Capabilities`; a query that needs something a backend lacks is refused before it runs,
with the reason. `tests/test_live.py` runs the same studio on live PostgreSQL, MySQL, Oracle, SQL Server, Fuseki, Neo4j and Gremlin Server when
their addresses are set (`ONTLAS_LIVE_PG`, `ONTLAS_LIVE_MYSQL`, `ONTLAS_LIVE_ORACLE`, `ONTLAS_LIVE_FUSEKI`, `ONTLAS_LIVE_NEO4J`,
`ONTLAS_LIVE_GREMLIN`), and the CI runs it against service containers (Oracle by hand). Values stay in the source: a graph backend gets a projection only when you ask for one, and
after that only the change set (`DELETE DATA` / `INSERT DATA`, or `MERGE` / `DELETE`).

The same IRIs are used by the SPARQL compiler, the projection and the R2RML export, so an R2RML-aware engine
(Ontop, Stardog, GraphDB) can answer the studio's SPARQL straight from the relational source.

## Decide, act, and stay in scope

```python
r = studio.decide("returnEligibility", "I1001")
r.outputs    # {'eligible': True, 'reason': '배송 완료 후 반품기간 7일 이내입니다'}
r.matched    # ['in-window']
r.evidence   # days_since_delivery = 4 <- order_items.delivered_at, category_returnable = True <- categories.returnable

from ontlas.actions import Actor
studio.actions.write = True  # off by default: an approved action is recorded and the source left as it is
p = studio.actions.request("requestReturn", "I1001", {"reason": "size"}, actor=Actor("bot", "agent", ["customer_agent"]))
p.status     # 'pending': role, parameters, state transition and decision all checked
studio.actions.approve(p.id, approver=Actor("kim", "human", ["operator"]))   # only a person approves
studio.actions.audit                                                       # requested, approved, executed

studio.run("myOrders", role="customer_agent", principal={"customer_id": "C001"})   # only that customer's rows
```

Decision tables export to GoRules JDM (`decide.zen.to_jdm`) and run on the ZEN engine when `use_zen=True`;
the tests check that ZEN and the built-in engine agree on every case.

Rules stay readable as they grow. All of this is in the module file, and 규칙 shows it:

| In a module | What it does |
|---|---|
| `hit_policy: priority` | Every rule carries a `priority`, and the matching rule with the lowest number decides (1 before 2, an AXIOM rule before any); the answer says which rules it overrode |
| `parameters` | One named value with its unit, bounds and owner, read as `@name` by rules and expressions, and as `{@name}` inside a rule's text, so a reason says the value in force; a customer module changes it alone |
| `metrics` | A number with its formula, denominator, time basis and owner |
| `conflicts` | Two sources that disagree stay open until a person picks one, and the pick is reviewed like any change |
| transitions | A state change with a guard, side effects and `after`; an action is asked again right before it runs |
| `view` | An object defined by a query, in the source, or carried along with `inline: true` where the source cannot be written |
| `format: YYYYMMDD` | Dates kept as text read as dates |
| `period`, `current(link.prop)` | The row valid now, out of rows valid for a period |
| scoped roles | Reads and writes limited to the signed-in organisation, closed when the scope is missing |
| `state_axes` | More state machines on one type, one per property: a claim's pickup and its shipping move apart |
| a start, `create` | A transition with no `from` makes the row; an action or a transition makes rows of other types too |
| `schedule`, `calendar` | Time transitions every few minutes, at an hour, on the last (business) day of a month, in business days |
| `given` | A guard or a criterion hands the request's values (a channel) to the decision it asks |
| `confirm` | A rule whose answer waits for a person: the verdict reads 확인 필요, and an empty answer 답 없음, never 불가 |
| `combine`, `settle` | A metric put together from other metrics and aggregates, and how long its number takes to settle |
| `{const}`, `{expr}` | A constant or an expression as a column, in a view or any query |
| `unbound` | A property its binding has no column for: read as empty, never written, 연결 안 됨 on the screens |

Each decision table is also read for what it leaves open: overlaps, rules that can never apply, and inputs no rule covers.
The last two, and a rule that goes against an AXIOM rule or bound, stop a change from being approved unless that
condition is turned off (see
[Changes are reviewed before they are approved](#changes-are-reviewed-before-they-are-approved)). A rule another source
answers first is not one that can never apply: the two sources disagree there, and the check says so as a conflict
(`kind: conflict`) that stays open until a person picks a source or confirms, with both rules in the table.

Actions check what is given (`{type, required, min, max, values, pattern, max_length}` per parameter), and may send
an external request after the change is written, only to hosts the studio file allows (`actions: {call_hosts:
[...]}`); a failed request puts the row back. An executed action can be rolled back, if nothing has changed the row
since, and an action with a request rolls back only when it declares the request that undoes it.

Nothing is written to the source unless that is turned on: `studio.actions.write = True`, or `--action-write` for
`ontlas serve` and `ontlas mcp` (every studio the server makes). Off, an action that would change the source still
runs every check and waits for its approval, then ends `recorded`: the values before and after and the request it
would send are kept in the audit trail, nothing is sent, and the source stays as it was. An action that only calls out
changes nothing in the source and runs as usual. With writing off, an executed action is not rolled back either, since
that writes too. `ontlas transitions --apply` writes, as it says.

```python
studio.actions.rollback(p.id, actor=Actor("kim", "human", ["operator"]))      # the values before, back in place
studio.run("customerValue", {"least": 0}, role="support_agent").rows[0]       # ('C001', '김하늘', '***-****-0101', ...)
```

A property marked `mask: partial | full` (or listed in a role's `mask`) is shown masked to every role that does not
`unmask` it, and so is a computed property built from it; filtering or ordering on a masked property is refused,
since the answer would give the value away. Queries the studio runs for itself see values in clear.

An action can also say how far it goes without a person. Inside every limit it runs at once for whoever may execute it; past one it
waits. An agent's request waits too, unless the action says `agents: true`. A limit reads a property's change (`delta`, `percent`),
a value (`max`, `min`) or a parameter, and takes a number or a named value:

```yaml
actions:
  changePrice:
    target: Sku
    parameters: {price: {type: decimal, min: 0}}
    set: {price: $price}
    approval:
      auto_within:
        - {property: price, percent: "@price_auto_percent"}
```

The request records how it stood against each limit, and the audit trail says it was approved by its limits.

Who settles a request is fixed too. A person approves or rejects it, with the right to execute it on that row, and not the one who
asked; a single visitor's own page is the one place a person plays both sides. A request that ran is rolled back, not rejected,
so the record never says rejected while the source holds the change. Each line of the audit trail names the module versions the
studio stood on, and a check that asked a decision names the rule that answered; an agent's decisions, answers and functions go
in with the same.

A role reads only the documents it lists, by name or pattern, when it has a list: an agent for customers does not find the
seller's terms in a search, an answer or the list of documents.

```yaml
roles:
  customer_agent:
    read: [Order, OrderItem]
    documents: [반품정책서, 배송안내, "쿠폰*"]   # no list: every document
```

### More than one state, rows made, and the clock

```yaml
objects:
  Exchange:
    states:                                       # the pickup, as before
      property: claimStatus
      states: ["32", "34", "36"]
      transitions:
        - {to: "32", action: openExchange}        # no from: the action makes the row (a key nobody holds yet)
        - {from: "34", to: "36", action: completePickup,
           create: [{type: Shipment, set: {exchangeId: $key, item: $self.itemId}}]}   # and one more row, elsewhere
        - {from: "32", to: "34", schedule: {every: minute, interval: 10}}             # a batch every ten minutes
    state_axes:                                   # the shipping, beside it
      shipStatus:
        states: ["21", "22", "26"]
        transitions:
          - {to: "21", action: startShipping}     # a start on a row that is there: the property was empty
          - {from: "22", to: "26", after: {days: 2, since: shippedAt, business: true}}
calendar: {weekend: [sat, sun], holidays: ["2026-01-01"]}        # or holidays: "@public_holidays"
actions:
  startShipping: {target: Exchange, transition_to: "21", axis: shipStatus, criteria: [{states: ["36"]}]}
  cancelLine:
    target: OrderItem
    transition_to: "13"
    parameters: {channel: {type: string, values: [FO, BO, CC]}}
    criteria: [{decision: cancelAcceptance, given: {channel: $channel}, expect: {allowed: true}}]
```

A schedule is `{every: minute | hour | day | week | month, interval, at: "07:00", day: 1..31 | last, weekday: mon,
business: true, between: ["09:00", "18:00"]}`; `when: {eq: [$self.giftStatus, "10"]}` keeps a time transition to the rows
it holds for, compiled into each language with the rest of the query. The clock takes a schedule once for each time it
comes round (`ticks`, kept in the journal), and `after` counts days, hours or minutes, or business days by the calendar.
`given` fills a decision's inputs from `$param`, `$self.prop`, `$key`, `$principal.x` or a value; a `param` input of
the decision takes the request's value of that name on its own. A new row of a view goes into the type behind it, with
what the view's where keeps to; a row of a type no table holds yet stays in the record.

A metric puts other numbers together, each part run in the backend's language:

```yaml
metrics:
  netSalesAmount:
    formula:
      combine: "sales - partner_discount"
      parts:
        sales: {metric: orderAmount}
        partner_discount: {match: {o: Order, c: OrderCharge}, edges: [[o, charge, c]], where: {eq: [c.bearer, Seller]},
                           value: {sum: c.price}, time: o.orderDate}
    settle: {hours: 48, basis: 방문 집계 확정}    # a window ending within it is answered as provisional (확정 전)
```

A view, or any query, returns a constant or an expression as a column: `{const: "10", as: kind}`,
`{expr: "qty * price", as: amount}`. A binding that has no column for a property says `unbound: true` (or lists them,
`unbound: [a, b]`, in an object's extend): the property reads as empty in every language and is never written, and the
bindings check says 연결 안 됨 as a warning where a column that is named and missing stays an error.

## Rules in three layers

Every decision rule belongs to the layer of the module that wrote it, and a table checks its AXIOM rules first.

| Layer | Written by | What it means |
|---|---|---|
| AXIOM | a module of kind `axiom` | Always true: laws, arithmetic integrity. No Custom or Standard module, and no workspace edit, rewrites or removes it |
| Custom | a `customer` module or the page's workspace | A customer's rules, over the Standard ones |
| Standard | any other module | The common defaults |

A module also carries `rule_cards`: the record of each rule, whether a decision row runs it or something else carries it
out (`type`: decide, compute, transition, restore, order, display, watch, and for what is not run at all duty, ban,
limit). A card has a statement, what it applies to (an Object among them), conditions, result, exceptions, source,
owner, `status` (draft, review, approved), `legal_review` (none, pending, done), what breaking it costs (`risk`), how far
its source was checked (`verification`) and `implements` (`decision:returnEligibility#in-window`,
`function:refundEstimate`, ...). It also keeps what a definition draft files a rule by: its group (`category`), the law
it rests on and the kind of source (`law`, `source_kind`), how it stands against the policy already written
(`policy_check`) and what else it concerns (`related`); the page shows them as 분류, 대표 법령, 근거 종류, 정책서 대조 and
관련 대상, on the rule, its form and the filters. An AXIOM card's
`check: {parameter: return_window_days, min: 7}` holds on the final values, so a module, an attach or a workspace edit
that sets the return window to 5 is refused with the card, the value, the bound and who set it. A card of any layer may
bound a property instead (`check: {property: OrderItem.unit_price, min: 0}`, a price is never negative), and each value a
caller gives is checked against it (`/v1/validate`, below). A reason may say a named
value (`반품기간 {@return_window_days}일 이내입니다`), and it reads the value in force. Each decision answer carries
`path`: per layer, how many rules, which fired or that none applied, and the module and version the answer came from
(`AXIOM 통과 › Custom vip-window 적용 › Standard 선행 규칙 적용`). The example's `commerce-law` module (법령 기준, 예시) shows all
three layers. `ontlas modules studio.yaml --check` lists the checks and `--rules` the layers and cards; the page reads
`/api/semantic`.

A card also says from when it applies (`effective`: a day, or the next deployed version when it is left out), how sure
the one who drafted it was (`confidence`: high, medium, low), where it came from (`origin`), the places it rests on
(`evidence`: a document and its section, or a line of source code) and the draft id it was approved from
(`drafted_as`). A card added with no id is numbered by its layer and area (AX-001, ST-ORD-001, CU-ORD-001). A table row
may carry `effective` too, and answers nothing before that day. A module may keep the laws its rules rest on with the
articles kept in house (`laws: [{key, name, articles: [{article, text}]}]`).

Anything defined can be stopped instead of deleted (사용 중지, `status: disabled`): a rule card or a table row, a named
value, a metric, an Object, an Entity, a relation, a state machine, a term or one of its expression relations, an access
policy. It stays in the definition and in its history, and decisions, search, questions and the API leave it out
(`ontlas.model.in_use`). Stopping what something still reads is refused as a delete is; an Object is stopped with its
Entities. 다시 사용 brings it back.

## Functions under a contract

A function is logic the ontology owns. It says what it takes and gives, which version runs, who owns it and what it stands on, and a
role is given it by name. The runtime is only how it is carried out.

```yaml
functions:
  refundEstimate:
    label: 예상 환불 금액
    target: OrderItem
    version: 1.0.0
    owner: 정산팀
    inputs: {fee_rate: {type: decimal, required: false, default: 0, min: 0, max: 1}}
    outputs: {amount: decimal}
    expr: "line_total * (1 - @fee_rate)"
```

| `runtime` | Carried out by |
|---|---|
| `expr` (the default) | An expression compiled into the language of the store, like a computed property |
| `decision`, `query` | A decision table or a registered query |
| `python` | A callable the deployment registered: `functions: {python: {score: package.module:callable}}` in the studio file |
| `http` | A service on the hosts the studio file allows, such as a model or a solver |

A module names a callable and brings no code, so a definition uploaded to a page cannot run anything. What comes back is held to the
declared outputs. `status` is `active`, `draft` (a person tries it out, no role runs it) or `retired`, and code outside the ontology
sees a row the way the caller's role sees it. An action can take a function as a condition.

```bash
ontlas functions examples/library/studio.yaml --run refundEstimate --key I1001 --param fee_rate=0.1
```

## Values held against the system

Rules can read right and a customer still see the wrong price. `flow.values` compares what the ontology answers with what the
transaction system recorded or answers now, case by case, and `max_value_errors` makes it a pass condition:

```yaml
flow:
  gates: {check: {max_value_errors: 0}}
  values:
    - {name: shipping, label: 배송비, query: checkoutRecords, key: order_id, truth: charged_shipping,
       answer: {decision: shippingFee, output: fee}}
    - {name: price, label: 판매가, query: checkoutRecords, key: sku_id,
       truth: {url: "https://shop.example/price/$key", method: GET, path: data.price},
       answer: {type: Sku, property: price}}
```

`truth` is a column of the case or a request to the system's API, on an allowed host. `answer` is a decision, a function or a
property. 검증 lists each case that differs (거래 값 불일치), and `ontlas values examples/library/studio.yaml` exits non-zero if any does.

## Identity across systems

```yaml
identities:
  Person:
    table: person_identity
    members:
      Customer: {phone: phone, name: name}
      Seller: {phone: phone, name: name}
    rules:
      - {id: same-phone-name, match: [phone, name], normalize: {phone: digits, name: trim}}
```

`studio.resolve_identity("Person")` joins the records that share every field of a rule (after normalizing), keeps
the evidence for each join, and writes the crosswalk in one transaction: `Person` is then an ordinary object with a
link to each member type, asked for the same way on every backend.

## Changes are reviewed before they are approved

A studio file's `flow:` names the stages that run and what each must pass:

```yaml
flow:
  gates:
    bind:   {max_errors: 0}          # the definition against the database
    query:  {min_agree: 1.0}         # every registered query answers the same on every backend
    decide: {min_agreement: 0.8}     # past decisions decided again give what was decided then
    check:  {min_accuracy: 0.9, min_grounded: 1.0}   # validation questions: right, and grounded
  agreement:
    decision: returnEligibility
    query: pastReturnCases           # one row per past case, with the values it had then
    inputs: {days_since_delivery: days_after_delivery, item_status: status_then}
    expect: {eligible: approved}
```

Four more conditions hold without being written, and a studio file turns one off by setting it to `null`:
`define: {max_gaps: 0, max_unreachable: 0, max_axiom_conflicts: 0}` (no decision table input that no rule answers, no
rule that can never apply, no rule or named value that goes against an AXIOM rule or bound) and
`check: {max_new_wrong: 0}` (no question a change newly answers wrong).

`studio.agreement()` decides every past case again and lists the ones that differ, with the rule that fired.
A question's answer is grounded when it carries its condition (the rule that matched, or the query), its source
(the rule's `cite` or its table's, the source column of each value) and the version of the module that answered;
`studio.questions().grounded` is the share, and each ungrounded answer says what it lacks. A `quality` module brings
its own `flow: {gates}`; attached, it holds the studio to whichever of the two asks more.
A change is a new version of one module: `studio.changes.propose(module, by="kim")` tries it on a copy of the
studio (the same source, a fresh graph) and records what it adds, removes and changes, the database check, the
conformance run, the questions and the agreement; `approve(id, by="lee")` refuses a change that does not pass the
flow or that its own author approves, then saves the version to the library and swaps it in. On the page, saving a
module files a change request and shows its review; `ontlas review studio.yaml module.yaml` prints the same review.

Each review also carries a regression against the studio as it stands: the questions the change newly fails or
fixes, accuracy, grounded share and agreement before and after, and the pass conditions it stops or starts meeting.
Every approved change makes a new version of the space; `/api/versions` lists them with who asked, who decided and
when, and every module version in the library. A studio file may name project milestones for the home:

```yaml
milestones:
  - {date: 2026-11-15, label: 검증 완료, detail: 검증 질문 정답률 0.9 이상}
```

Validation questions take a `type` (definition, decision, value), `holdout: true` and a `grading` (match, keywords,
evidence, llm). A definition question needs no query or decision, only the words its answer must hold (`keywords`).
Held-out questions are reported apart from the ones a definition is tuned on (`sets: {dev, holdout}`, and per type).

A request may name its reviewers and the version it is to be deployed as (`release: v0.3`); the versions it makes are
then called by those names. An item's history (`/api/item/history`) begins with the line it came with, the library
version that first held it (생성), and each entry names the version of the space it went into. The goals an ontology
aims at beside its pass conditions (`flow: {goals: {rule_cards: 50}}`) are shown where they are counted, never a gate.

## Manage objects, properties and relations

Each list changes one item at a time on its item screens. The modelling workspace (Ontology › 그래프 탐색 › 다이어그램 작업
공간) changes the definition as a whole: the Entities as cards on a canvas
with their keys, properties and named relations, grouped by Object; a tree by Object (or by module) with what is wrong; and the picked
element's form, data, uses, YAML and comments, each a view of the same element. One switch away the same objects,
properties and relations stand in three columns with a form under the picked row. Every element carries a status
(초안 · 사용 중 · 폐기 예정), and a deprecated element that something still reads says so where its uses are listed. The
source's tables with their rows, keys and references are on 데이터 소스, and the questions with known answers (add,
remove, or import a YAML or JSON list) on 검증 질문.

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/workspace.png" alt="Diagram workspace: the Entities of every module as cards on a canvas, the tree on the left and the chosen Entity's form on the right" width="920">
</p>

Every edit goes into one overlay module, `workspace` ("관리 변경"). Saved to the library, it comes back at the next start
without being listed in the studio file. What it defines it changes directly; a standard's
objects, properties and relations it extends or removes, so a standard is never edited in place, and a standard's
type and key and a property a type inherits stay where they are defined. Each edit takes out what it leaves broken
elsewhere and says what that was:

```python
from ontlas.manage import Workspace

ws = Workspace(studio.composition.modules)
ws.apply("update_property", {"object": "Customer", "name": "grade", "label": "회원 등급"})
edit = ws.apply("delete_link", {"name": "placed"})
edit.took_out    # ['action:requestReturn', 'decision:returnEligibility', 'property:Customer.order_count', ...]
ws.apply("add_question", {"id": "G1", "text": "...", "query": "nope"})    # EditError: question G1: unknown query 'nope'
studio.changes.propose(ws.module, by="kim", attach=True)                  # tried on a copy, then approved
```

`modules.settle(module, base)` does the taking out for any module: the queries, decisions, actions, questions,
links, identities, state machines and computed properties that read what the module removes, and the roles that read,
filter or mask it. What the module defines itself is left for a person to fix, so an edit that breaks its own element
is refused. On the page the edits are filed as one change request; a request the trial stops comes back with its
review (the conditions it failed and what the database check found), and the edits stay to be fixed.

Rules, named values, states, actions and roles go the same way, on forms: 규칙 › 결정표 edits a rule's conditions and outcome input by
input, and a rule from a standard is replaced over it (`rules_replace`, `rules_remove`) without touching the standard. Every edit lands in
the workspace module, is tried on a copy and is approved like any other change. A library keeps its versions: open an earlier one in the
module editor and file it, and it comes back as a new version. With `--library-write`, what is switched on stays on across a restart; if a
kept module no longer fits the source, the studio starts from its file's own list and says so.

용어 사전 holds what people call each definition: preferred and English labels, synonyms and abbreviations, what each
screen calls it, hidden labels used only for matching, related, broader and narrower terms, and pairs that must not be
swapped (결제금액 ≠ 주문금액, with why). A term names its definition (`concept: property:Payment.amount`); conflicts (one
label on two definitions, a synonym that is also a pair not to swap, a definition that is not there) are reported, never
refused. A question is read in the lexicon's preferred words, and an answer names the other word of a pair when one of
them was used. A glossary comes in as one edit, as a term list or a pair table (구분, 용어 A, 용어 B, 관계, 설명, 근거, 확인
필요): `ontlas lexicon import 용어집.csv --config studio.yaml -o shop-dictionary.yaml`, or 가져오기 on the screen (CSV,
Excel, YAML or JSON). In a pair row 관계 says what B is to A: 동의어, 약어, 관련어, 상위어 or 하위어 (or 상위 · 하위, where the
note names the side that is above), 혼동주의, or 채널 표기 for what a channel calls the term (BO→FO in 구분 names the
channel). A remark in brackets after a word, set off by a space (`주문 합계 (상담 화면 표기)`), is kept as the term's note
and not as part of its label. The screen lists the
relations between expressions by kind, broader and narrower apart from the rest, and the customer wording by channel.
Objects take an `owner` and a `tier`, Entities and decision tables an `owner`.

Terms are numbered when added (T-001), and so is each expression relation (R-001), which may keep its own note,
ground, owner and status (`synonyms: [{term: 리턴, note: 구어, code: R-002}]`; a plain word is still read). A term with
`preserve` (보존어, its kind) is a word a question keeps whole though it reads as a stopword (안, 못), and names no
definition. A relation says how it was found (`extraction`: key, model, manual), who owns it, and its type from the
module's relation type dictionary (`relation_types: {contains: {label: 포함함, inverse: 포함됨}}`); one pair of Entities
is not said twice with the same type. State machines keep a ground (`cite`) and an owner, and an access policy what it
was based on, its owner and the Entities whose records it may read beside their definition (`read_data`).

### Monitoring rules

파이프라인 관제 › 모니터링 규칙 › 추가 watches one thing of the ontology open (규칙 · 개념 초안, 변경 요청, 검증 결과 or
API 호출) against a condition (승인 대기 상태로 3일 경과, 정답률 90% 미만, 최근 7일 오류율 5% 이상, ...). The server checks
every rule each minute. While one holds it is in the to-do list of the people it names (영역 담당: those who answer for
the Objects concerned; 온톨로지 관리자; or people picked), and when it starts to hold it is sent to the webhooks that take
`monitor.alert`. Email follows the mail settings of the server. Rules are kept in the ontology's journal; one paused is
kept and not checked, one revoked stays listed.

### Stores added on the page

저장소 · 엔진 › 저장소 추가 adds a graph store (SPARQL 1.1, or a property graph over Cypher), a vector store (pgvector,
Qdrant) or the source the rows are read from (PostgreSQL, MySQL, Oracle, SQL Server, a SQLite file), on a server that
allows connections. Its password or key is sealed and never shown again; the source is read with a read-only account
and only the tables named. [연결 테스트] connects first, and for a graph store loads the definition and compares its
answers with the source's. A store is rebuilt on every deploy or by hand, can be paused (left out of deciding, search,
indexing and comparing) and revoked (kept on the list as 폐기됨), and is connected again when the server starts. The
stores the studio file names keep their address and account there; their role, rebuild and pause are set on the page.

## A team studio

```bash
ontlas users add users.yaml kim --name 김하람 --system user    # the password from ONTLAS_PASSWORD, or asked
ontlas serve studio.yaml --users users.yaml --library-write --journal records/journal.jsonl --sync 60
```

With `--users`, people sign in (PBKDF2 hashes, a session cookie that is HttpOnly and SameSite=Strict, writes only
from the page itself, failed sign-ins limited) and share the studio of each ontology. `--library-write` saves approved
versions to the library folder; `--sync` reads the source again every N seconds and sends each graph the change set.

Rights come in three layers:

- **System role**, one a person: 시스템 관리자 opens 관리 › 시스템 관리 and every ontology (and its 온톨로지 관리),
  온톨로지 생성자 makes, copies and imports ontologies, 사용자 works in the ontologies they take part in.
- **Work role**, in each ontology, given to a person or to a local group (whose members follow it as they come and go):
  조회 reads, searches and asks; 편집 also uploads, edits, files change requests, edits and runs checks and asks to go
  back; 영역 담당 also approves drafts and change requests, deploys, rolls back and asks for an access policy change,
  each for the Objects it looks after; 관리자 does all of it and connects data sources, sets up the store, the members and
  the ontology (온톨로지 관리); 관리자 and 법무 검토 settle AXIOM rules (a change to an `axiom` module, or switching
  one on or off), 법무 검토 doing nothing else but read. Nobody approves their own request. The one who makes an ontology on the page is its 관리자.
- **Data scope**, an access policy of the definition given to a member: what they ask and query, and every screen that
  reads records (a record, the list of a type, finding one, its relations and the path between two, the rows of an
  Entity, a decision on one, a metric), is read as that policy reads it: its row filters, its masks, the decisions and
  metrics it runs. Rows a policy keeps to a caller (`{principal: customer_id}`) are read by the caller values
  (호출자 속성) the admin gives the member on the member form, whatever the page picks or types. A key on /v1 and MCP
  reads the same records the same way.

An ontology a person takes part in opens; the others are listed by name with 참여 요청, which lands in the 할 일 of
that ontology's admins (as does a 권한 요청 from a screen the person's role does not open). Signing in leads to the
home of the one ontology taken part in or the one used last, to 온톨로지 선택 where there are several, and to
참여 온톨로지 없음 where there is none. 온톨로지 관리 › 멤버 · 권한 adds people and groups with a work role, a
steward's Objects, a data scope and what lands in their 할 일; 시스템 관리 › 사용자 · 그룹 sets the system role, the
groups and the ontologies each person takes part in. A screen or route a role does not open answers 403 with whom to ask.

Signing in works as a company deployment needs it:

- **First run.** A server whose users file has no admin yet (or does not exist) prints a setup code on stderr and
  writes it beside the users file (`users.setup`). The page opens on 최초 설치 설정, where the code makes the first
  admin; the code is gone once used.
- **Sign-in.** A user id or an email, with 로그인 상태 유지 for `keep_days`; otherwise the session lasts `session_hours`.
  Sign-ins are kept beside the users file (`users.logins.json`, by the sha256 of each token only), so a restart or a
  redeploy signs no one out. Wrong passwords are counted (실패 n/5) and lock the account for `lock_minutes` after
  `lock_after` of them; an admin can unlock it sooner. One address may fail ten times a minute; a sign-in that goes
  in is not counted, so an office behind one address signs in freely. Asking to join and the first setup are counted
  apart.
- **Two-step sign-in.** Anyone can turn on a six-digit authenticator code (TOTP, with a QR code drawn on the page and no
  outside service) on 내 계정, and the policy can require it of everyone, who then register at their next sign-in.
- **Joining.** 회원가입 asks for an account; the person waits as 승인 대기 until an admin approves them
  with a system role or turns them down, and then asks to take part in an ontology. The policy can stop taking requests.
- **Passwords.** One an admin sets is temporary and is changed at the next sign-in. A new password may not repeat the
  last three. Changing it signs that person out everywhere.
- **Accounts.** 내 계정 changes the name and email and lists the devices signed in, each of which can be signed out.
  An admin adds, edits, unlocks and retires people (a retired account stays in the list as 폐기됨 and can be brought
  back), and resets a lost authenticator.
- **Policy.** 시스템 관리 › 인증 · 보안 sets the session length, how long 로그인 상태 유지 lasts, the password length, the lock, two-step
  sign-in for everyone, whether requests to join are taken, and the addresses let in (CIDR ranges; the admin's own
  address must be among them). The client address is read from `CF-Connecting-IP` or `X-Forwarded-For` first, so run
  the server behind the proxy that sets them and do not expose its port directly.
- **Audit.** Sign-ins, sign-outs, failures, locks and every change to an account go into the audit trail (로그인) with
  the address they came from. On a team, 감사 로그 is the whole server's: every ontology's records beside the server's
  own, each naming its ontology, picked by kind, period, ontology and words. CSV로 내보내기 writes every record kept that
  the filter shows (not only the newest the screen lists), and taking it out is itself recorded. With a journal the
  records are only ever added to, never rewritten or taken out; without one, a team's are kept three years while the
  server runs.
- **Mail.** 시스템 관리 › 시스템 sets the company's SMTP server: host, port, STARTTLS, SSL/TLS or none, an account, the
  sender and the address the links in a mail open. The password is never written anywhere: the settings name the
  environment variable that holds it, set when the server starts. 시험 메일 보내기 sends one at once and says how it
  went. With no SMTP server set, nothing is mailed and every screen is as it was.
- **A forgotten password.** Where mail is set, 비밀번호 초기화 takes an id or an email and mails a link that sets a new
  password: it lasts 30 minutes, works once, and stops working if the password is changed another way first. Only the
  sha256 of its token is kept. The answer is the same whether anyone has the id or email typed. The new password
  follows the policy and may not repeat the last three, and setting it signs the person out everywhere and unlocks the
  account. Requests and refused links are limited per address, mails per person. Without mail, an admin gives a
  temporary password as before.
- **Notices.** 내 계정 › 알림 chooses, for each kind (승인 요청, 변경 요청 검토 · 배포, 댓글 · 멘션, 모니터링, 자료 회신, API
  키 만료 · 시스템 공지), whether it comes to 할 일 · 알림 and whether by mail (the email column shows once mail is set).
  A change request filed reaches those who approve one, its decision whoever filed it; a concept draft filed to be
  applied reaches those who apply one, and its outcome whoever filed it; an action request waiting reaches the
  approvers; a request to join reaches the system admins; an `@id` or `@name` in a comment reaches that person; a saved
  security policy reaches everyone. Each person's notices are their own, read one by one or all at once, and picked by
  the ontology they came from. 자료 회신 is a reply to a request for material (자료 업로드 › 자료 요청).
- **Time zone.** 내 계정 picks the time zone the screens show times in (the server's own clock by default); the
  language is kept with it.
- **The log server.** 시스템 관리 › 시스템 sends every audit record, as it is written, to the company's log server as
  RFC 5424 syslog over UDP, or over TCP with each message preceded by its length (RFC 6587): who, from where and in
  which ontology in its structured data. 시험 전송 tries it at once.
- **An ontology brought back.** 온톨로지 만들기 › 파일 가져오기 takes the ZIP 내보내기 gave (a studio folder: the studio
  file and each module it applies) and makes a new ontology of it with the same modules at the same versions. The zip
  is read in memory and checked whole before anything is made: entries that climb out (`..`, an absolute path, a
  drive, a link), files that are not YAML, more than 400 entries or 32MB unpacked are refused, and the modules must
  compose. With `--library-write` it is kept under `made/` like any other made here.
- **API keys.** The keys `/v1` takes are given only by environment variables (`--api-token-env`, `--api-agents`), so
  they carry no expiry date and the policy sets no longest life for them.

The users file holds the policy, the groups and who takes part in what beside the people:

```yaml
users:
  kim: {name: 김하람, email: kim@example.com, system: user, password: "pbkdf2_sha256$..."}
groups:
  cs: {name: CS기획팀, description: 클레임 · 배송, members: [kim, lee]}
members:                            # by ontology; "*" is every ontology on the server
  library.studio-1a2b3c: {"user:kim": {role: steward, areas: [Claim]}, "group:cs": {role: editor, scope: customer_agent}}
requests: [{id: q1, ontology: library.studio-1a2b3c, user: park, role: viewer, kind: join, state: pending}]
policy: {session_hours: 12, keep_days: 14, password_min: 8, lock_after: 5, lock_minutes: 15,
         two_factor: false, signup: true, allow_ip: [], password_kinds: false, idle_hours: 0, inactive_days: 0}
```

A users file from before 0.27 gave each person `roles` for the whole server. It is read without losing what anyone
did: admin as 시스템 관리자 and 관리자 of every ontology, approver as 영역 담당 of every Object, editor as 편집, viewer as
조회, and it is written in the new form at its next change. AXIOM rules are settled by 관리자 as before, and by
법무 검토 where the admin gives that role.

The page writes this file; `ontlas users add` on a running server's file is overwritten at the server's next write, so
add people on the page, or stop the server first. Keep the file as a secret: it holds the authenticator keys.

Beside it the server keeps `users.server.json` (the SMTP and log servers as set, the password's variable name only),
`users.people.json` (each person's notices, what they chose to hear of and their time zone) and `users.resets.json`
(the reset links that are still good, by the sha256 of each token).

```bash
ONTLAS_SMTP_PASSWORD=... ontlas serve studio.yaml --users users.yaml --journal records/journal.jsonl --library-write
```

The team works in one place. Everyone's edits go into the change request being written, each with who made it, and
approving one request does not drop what others have not filed: their edits are applied again on the new version, and
an edit on an item the approval changed is held (보관된 편집), with who made it and why, for its writer to apply over the
approved content or drop. An editor discards only their own edits and an admin all of them, a rejected request can be
taken back into the edits being written, and applying a concept draft adds it to that request instead of moving
everyone to another pipeline.

The source database keeps what an action wrote, but not who asked for it, who approved it or what it replaced. Add
`--journal records/journal.jsonl` and requests, approvals, change requests and the audit trail are written there one line
each, and read back when the server starts: a request still waits, a change can still be rolled back, and the trail is
whole. The edits not yet filed, the pass conditions and quality targets set on the page and the AI draft history are
kept there too. One process writes to one file. What to start a team's server with, and what to back up, is under
[A server that keeps what a team enters](#a-server-that-keeps-what-a-team-enters).

### Running a team's server

시스템 관리 and 온톨로지 관리 keep what a company sets for the whole installation and for each ontology, beside the
users file (`users.server.json`); none of it is written where nobody signs in, where each visitor's own settings last
their session.

- **거버넌스 정책.** The approval and AI draft defaults every ontology starts from (영역 담당 1명 이상, 법무 검토 for AXIOM,
  regression checks, nobody approves their own request, a pack update made into change requests; AI results are
  always drafts, no candidate without a source location, each draft with its model, guideline and material versions,
  a verification level on regulation drafts), what each grade of material may go to (공개 · 내부 · 기밀 · 개인정보 ×
  the model, a platform, an export) and how long things are kept (rejected drafts, prompt logs, the audit log, three
  years at the least). 외부 연동 holds for a caller of /v1 and MCP: a document whose grade says 마스킹 comes with what reads
  as personal information masked in its passages (search, an answer and its sources), one that says 불가 is not there,
  and one that says 접근 정책 only where the caller's access policy names it; a webhook carries the rows a monitoring
  rule found as the 개인정보 grade lets them leave. 반려한 초안 (a rule draft turned down, a term or a question candidate
  left out) are taken out of the journal once a day when their days are over, the chain left whole: the line becomes a
  stub with who and when and its own `_h`, and a retention line after it names the stub, so every line still checks. An ontology may only be stricter; to be looser in one item a system admin grants an exception
  until a day, with why. 정책 적용 현황 says each ontology's standing; every change is in 정책 이력 and the audit log.
- **온톨로지 설정.** The name and description, the field (분야), language and time zone (the clock "days since" is
  counted on), the extension prefix (the ontology's namespace in its OWL export), the reference vocabularies, the
  naming rules, whether AI drafts are made in it and under which guideline and checks, the approval policy, when its
  people are told of what waits (승인 대기 n일, 키 만료 n일 전, 신규 오답), and the quality targets, rule cards, questions
  and the holdout share among them as pass conditions. 내보내기 › 자료 포함 전체 adds every version of its modules, its
  journal and the material its grades let the person take out. The records (that journal, 결정 로그, who called a
  query) are the ontology's admins' to read, a row of the permission table no table changes (저장 기록 조회 ·
  내보내기): anyone else sees the action requests they made themselves, and the change requests and comments of their
  work as before; who signed in, and from where, goes out to a system admin alone. 보관 makes an ontology read only (a system admin puts
  it back or deletes it); a deleted one can be put back for 30 days and is then gone.
- **멤버 · 권한** ticks, for this ontology, which work role does each row of the permission table (the admin column,
  AXIOM and the members row stay as they are).
- **AI 운영.** How the model is reached (사내 모델 서버, 외부 모델 API where 인증 · 보안 allows one, or none), its address
  and the environment variable that holds its key, a model for each use from the list the model server gives, and the
  generation guidelines (a pack may carry its own). Every call is counted by use and month and held to the month's
  limit, waits while as many run as the model server is given, has what reads as personal information covered when
  that is asked, and is kept with its answer for the days set (`users.prompts.jsonl`). The screen says this month's
  drafts, how many were approved, what was left out for having no source, and how the model server stands. A rule
  draft, term candidates or question candidates the model server did not answer for wait in the ontology's journal
  (대기 중인 생성): every 30 seconds the server is asked whether it answers, and the oldest is made once it does, where a
  person would find it; each try that fails waits longer, and one still waiting a day later is given up.
- **인증 · 보안.** A password may be asked to hold letters, digits and symbols; a sign-in unused for some hours ends;
  an account not signed in for some days is set disabled; an admin locks an account until a time or until unlocked.
  외부 인터넷 차단 (망 분리) takes only a model address inside the company's network and serves the page with nothing
  from outside (the fonts from `static/fonts` where they are there, else the system's). `serve --tls-cert --tls-key`
  serves HTTPS, TLS 1.2 or later. Stored data is encrypted by the disk and the operating system: the server itself
  does not encrypt its files, and there is no KMS to reach.
- **시스템.** 지금 백업 and a daily one (a zip of the users file and what is beside it, the journals, the ontologies made on
  the page, the library and the repositories, kept 14 days), 이 시점으로 복원 under maintenance until the server starts
  again, an update wheel put up and installed at a maintenance time with a backup first, and 점검 모드: only system
  admins are answered, everyone else sees the notice (503 with the request id every answer carries). The parts are
  measured again each minute, the work queue, the record files and the vector index with them.
- **도메인 팩.** Packs by field, which ontologies use each, what changed between two versions, and 온톨로지에 반영 · 변경
  요청 만들기: a change request in each ontology that applies an older version (its Custom modules untouched), deployed
  once it passes its regression checks and is approved. A package (`.ontlas-pkg`: a manifest with each file's sha256,
  the modules, and an HMAC-SHA256 signature under the publisher's key, held in an environment variable 서명 확인 키
  names) is checked whole before anything is kept. 온톨로지를 팩으로 저장 makes an ontology's approved Custom part a pack.
- **기준 어휘.** Vocabularies registered from OWL, Turtle or JSON-LD with a prefix, field and scope, which ontologies use
  each and take it as their reference, the mappings between them, and a new version's names that an ontology is
  aligned to and that it no longer has (확인 필요).
- **자료 업로드.** A file's version, Object and grade; personal information covered before a file is kept (a text file,
  and a Word, PowerPoint or Excel file in the file itself; a PDF or any other format is kept as it came and withheld:
  never downloaded or exported, its covered text exported in its place, and read covered by search, drafts, the model,
  answers and /v1); a new
  version under the same path keeps the one before and names the sections that changed (the only passages a reader
  of relations reads again); the company's Git (a branch by its archive address, a read-only token by environment
  variable) and wiki (Confluence) read into a folder now and on a schedule; a request for material mailed and told in
  할 일 · 알림, answered by an upload that names it; and the drafts waiting for the model with when the next starts and
  how often each was tried.
- **할 일 · 알림** reads every ontology the person takes part in, each row with its ontology and how long it has waited;
  rule drafts waiting reach those who approve them. The change request being written has its number from its first
  edit. A form open when a sign-in runs out is kept and comes back after signing in.
- **감사 로그.** Each journal line carries a hash of the one before; the screen says whether every line follows.
  Connecting a data source, a platform or a Git or wiki, and changing the embedding model are in it as 연결 · 키.

## Reason, validate, exchange

| Need | Call | Result |
|---|---|---|
| Derived links | `reason.rules.run_rules(onto, projection)` | inverse, symmetric and transitive (depth-capped) links, each with the facts it came from; findings for missing required links, cardinality, exclusive links, required properties, enum values, states |
| Shape validation | `reason.shacl.to_shacl(onto)`, `validate(onto, projection)` | SHACL shapes from the definition, checked with pySHACL |
| OWL reasoning | `reason.owl_rl.materialize(onto, projection)` | owlrl closure; tested to derive exactly what the built-in rules derive |
| Standards out | `exchange.owl.to_owl(onto)`, `exchange.r2rml.to_r2rml(onto)` | OWL 2 and R2RML, with a report of what was preserved, adjusted or left out |
| Standards in | `exchange.importer.from_owl(ttl)` | a starting definition from schema.org, GS1 or any OWL/RDFS, with the same report |

## The data map

근거 지도 holds each Object against the material that grounds it. What is missing is asked for: 자료 요청 names what, of
whom and for which Object, and makes a link anyone opens without signing in to hand files in, once, within its days
(only the link's hash is kept; a new link ends the one before). What comes in lands under `요청 자료/` in the repository
and on 할 일. A file uploaded again under its name keeps the one before as a version; the material table says each
file's version, how it is read (definition sheets and drafts as they are, policies by a model) and what was made from
it. An Entity no table holds yet keeps its key and source candidates for the binding to take up.

The explorer shows the same assets as folders. A folder says how many of its files are indexed as documents and how many
go into a draft; a table names the objects that read it; a document, its chunks and the objects it mentions. One search
covers names and paths, the definitions a question names, and document text by words and by meaning. A deleted file goes to
the trash with its folder, comes back where it was, and every change is in the repository's work record.

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/explorer.png" alt="Asset explorer: everything the space holds as folders, with one search over it" width="100%">
</p>

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/space-map.png" alt="Asset graph: how files, tables, documents, stores, Entities and queries connect" width="100%">
</p>

```python
from ontlas.catalog import from_ontology
cat = from_ontology(studio.onto)                  # tables, columns, objects, properties, queries, decisions, roles
cat.add_file("policies/returns.pdf", folder="policies", collection="commerce-policies")
cat.add_agent("support", roles=["customer_agent"], uses=["collection:commerce-policies"])
cat.impact("column:order_items.delivered_at")     # the property, query, decision, action, role and agent it reaches
cat.sees("support")                               # every table, column and file that agent can reach
cat.unused()                                      # what no agent or workflow uses
```

## Validation questions, goals and comparisons

A validation question names what grounds its answer (클레임 정책서 v1.0 · 14일, checked against the material the space
holds), the Object it is about, and may be graded several ways at once (keywords and grounds: every one must hold). Its
step (L1 on the definition or given values, L2 on a record or a value the source holds, L3 where both are held
together) is shown beside its type. The flow's goals take a share of the core Properties given a mapping
specification (`bind.min_mapped`), how many questions the set should have (`check.least_questions`,
`check.max_questions`) and the share held out (`check.min_holdout`). A word question answered wrong says whether the
search found nothing to stand on (검색) or the answer missed the words (표현). A / B / C 비교 asks the development set of the
same model with nothing, with the documents alone and through the ontology, and keeps the share right of each; CS 문의에서
후보 받기 reads uploaded inquiries into question candidates to take into the set or drop. Both are jobs with a limit on
the model's calls. A question graded by LLM 심사 is answered as any other, and the model (AI 운영's 검증 · LLM 심사) holds
the answer against the expected one at temperature 0 and gives its reason; a verdict is kept by the question, the
expected answer and the answer, so a run gives what the run before gave without asking again. A run asks the model 40
times at the most; one it cannot grade (it failed, the run's calls ran out, it gave no verdict) is 채점 못 함, counted
apart from right and wrong. The verdicts are in 검증 실행 and in the pass conditions.

An element can be stopped (사용 중지) instead of deleted: a Property, an Entity, a query, an Action or a question keeps its
definition and history and is left out of decisions, search and every API answer until it is put back in use. A
Property may also say what a decision does when the source has no value (`on_missing: hold | default`), be left
unmapped for one source (`unbound`), be marked core (`core`), carry its specification state (`spec`) and an owner.

## Questions in plain language

`nl.IRGenerator(onto, llm)` gives a model a schema card (only what the role may read) and the IR format, and
takes back either an IR object or a registered query name with parameters. The answer is checked against the
ontology; if it fails, the model is asked again with the list of issues. The model never writes backend
query text. `llm` is any `(system, prompt) -> str`; `nl.openai_chat(url, model)` makes one for any
OpenAI-compatible endpoint, and `ontlas serve --llm-url ... --llm-model ...` adds 자연어 질의 to the 질의 screen. An answer
that checks but finds no rows goes back once with sample values of the properties it compared (only what the role
may read in clear). `ontlas nl-eval studio.yaml questions.yaml --llm-url ... --llm-model ...` scores a model on your
own questions by execution: the gold query's rows must be in the answer's;
[`examples/commerce/nl_questions.yaml`](https://github.com/PlateerLab/ontlas/blob/main/examples/commerce/nl_questions.yaml) has sixteen.

## Rules from policy text

`policy.PolicyDrafter(modules, llm).draft(text, target="OrderItem")` gives a model the same schema card, the
decision table format and the policy's clauses, and takes back one decision table. The engine checks it as a module
(inputs it can read from the target or along a path, tests it can evaluate, outputs the rules set) and checks that
every rule cites a clause the text numbers; whatever is wrong goes back to the model. The draft is a module of its
own, and a person files it as a change request, so it is tried on a copy and approved before it decides anything.
On the page, with `ontlas serve --llm-url ...`, 규칙 초안 drafts from the documents of the catalog or from a clause typed
in (`--policies examples/policies` puts an example policy one button away); the command is
`ontlas policy-draft studio.yaml policy.md --target OrderItem --llm-url ... --llm-model ...`. A draft takes a
minute or more with a model that reasons first, so it runs on the server and the page collects it (up to 5 minutes).
The draft is kept on the server until it is filed or turned down, so a refresh or a restart does not lose it. It says
how each part was made and how sure the model was of each row, and what its table leaves open: an input range no rule
answers would stop the change request, so the review says so and opens the table in the editor before it is filed.
[`examples/policies/교환정책서.md`](https://github.com/PlateerLab/ontlas/blob/main/examples/policies/교환정책서.md) is a made-up exchange policy.

## Any platform: REST and a borrowed connection

```bash
export ONTLAS_API_TOKEN=...
ontlas serve studio.yaml --api-token-env ONTLAS_API_TOKEN --api-role support_agent
curl localhost:7710/v1/search -H "Authorization: Bearer $ONTLAS_API_TOKEN" \
     -H "Content-Type: application/json" -d '{"text": "반품 기간", "k": 3}'
```

`/v1/openapi.json` describes the API for whatever imports OpenAPI, with the address it was reached at, and `/v1/tools` lists it as
function definitions; `ontlas openapi --server URL` writes the same file. `/v1/context` gives what a question is about as text for an
agent's prompt, and `/v1/function` runs a function. Search, queries in any language, translation and decisions run under the role of the token, with
its row filters and masks. A token with no role (no `--api-role`, an agent with no `role`) is refused with `403` and
`no_policy`, since it would read every row unmasked; `--api-open` lets such a token read everything. It is read-only
unless started with `--api-write`, and then an action is only a request a person approves; it writes to the source
only on a server started with `--action-write` (`/v1/space` says which as `action_write`). `/v1` stays off unless a token is set. Started with `--users`, it answers from the studio the team shares: a change a
person approves holds for it at once, and an action it requests waits on Action › 처리 요청 for a person to approve.

<p align="center">
  <img src="https://raw.githubusercontent.com/PlateerLab/ontlas/main/assets/screens/connect.png" alt="연동 · API: who calls and under which access policy, whether the REST API and Action writing are on, and the four ways an agent or a platform takes the ontology" width="920">
</p>

Operations › 연동 · API shows the same from the server's side: each caller with its access policy (정책 없음 · 거부 for a
token with none), whether the REST API and Action writing are on, the endpoints, and a panel that calls one as a chosen
policy.

Give each agent a token of its own, so the audit trail says which agent asked and one agent cannot read another's requests.
Tokens come from the environment, never from the file:

```yaml
# agents.yaml, for ontlas serve ... --api-agents agents.yaml
agents:
  - {name: 고객 응대 Agent, token_env: ONTLAS_CS_TOKEN, role: customer_agent, principal: {customer_id: C001}, write: true}
  - {name: 상담원 Agent, token_env: ONTLAS_SUPPORT_TOKEN, role: support_agent}
```

### Keys issued on the page

Operations › 연동 · API › 연동 대상 등록 issues a key for one caller of the ontology open: its name, the platform its
agent is made on, how it connects (REST `/v1`, MCP at `/mcp` on the same server, or the ontology file at
`/v1/export?format=owl|yaml`), the access policy it runs as (a key with no policy is not issued), the version it answers
from (the one deployed, the preview, which holds the requests under review and the one being written, or one version
kept), the tools it may call (조회 · 판정 · 검색 · 질의 · 함수 · Action 요청), the day it ends (a year at most), the
addresses it may come from (none given: the internal network only) and a note. The key is shown once, when it is
issued; only its SHA-256 is kept, in the first ontology's journal beside the users. A key revoked stays on the list as
폐기됨 and is refused from that call on. Keys are made by an admin on a team server, and where nobody signs in only on a
server started with `--allow-connect`. The tokens of `--api-token-env` and `--api-agents` answer as before, beside them.

Every call to `/v1` and `/mcp` is logged (who, which tool, the status, how long it took; `journal.calls.jsonl` beside
the journal), and the screen counts the decision tool's average time and the share of calls that failed in the last
seven days.

```json
{"mcpServers": {"ontlas": {"type": "http", "url": "https://ontlas.example/mcp", "headers": {"Authorization": "Bearer <key>"}}}}
```

### Webhooks

연동 · API › 웹훅 sends what happens in an ontology to an address: `ontology.version.deployed`, `monitor.alert`,
`draft.pending` and `qa.run.failed`. Each request carries `X-Ontlas-Event`, `X-Ontlas-Delivery`, `X-Ontlas-Timestamp`
and `X-Ontlas-Signature: sha256=<HMAC-SHA256 of "<timestamp>.<body>">` under the webhook's signing key. The key is
typed, or made for it and shown once; it is kept sealed with the server's own key (a `.vault` file beside the journal,
readable by its owner only) and never shown again. A send that fails is tried again six times within a day (1 minute,
5 minutes, 30 minutes, 2, 6 and 12 hours), or not at all; a test send and a resend are on the page.

`/v1/proposals` gives a token the requests it made and how each stands, and `/v1/record` one object by its key, inside the
token's rows and masks.

Every call, as `/v1/openapi.json` lists them:

| Call | It gives |
|---|---|
| `GET /v1/ontology` | Object types, properties, links, registered queries, decisions and actions the token may use |
| `POST /v1/find` · `/v1/context` | The definitions and rules a question is about, as a list or as text for an agent's prompt |
| `POST /v1/object` · `/v1/record` | One object type with what touches it; one object's values by its key |
| `POST /v1/terms` · `/v1/rules` | The glossary's reading of a sentence; the rule cards, AXIOM first |
| `POST /v1/decide` · `/v1/validate` | A decision on a record or on stated values; whether values keep to the definition and the rule cards |
| `POST /v1/questions` | The validation questions, on their own values and on the records they name |
| `POST /v1/answer` · `/v1/search` | One question answered with its grounds; passages by meaning with the definitions they name |
| `POST /v1/query` · `/v1/sparql` · `/v1/cypher` · `/v1/translate` | A registered query or an IR object run on a backend; SPARQL or Cypher written against the ontology, on any backend; the text of a query in a backend's language |
| `GET /v1/functions` · `POST /v1/function` | The functions the token may run, and one of them run |
| `POST /v1/actions` · `GET /v1/proposals` | A declared action requested (with `--api-write`); the requests the token made and how each stands |
| `GET /v1/documents` · `/v1/space` · `/v1/libraries` | The documents and their sections; what the space holds; the libraries the server offers |
| `GET /v1/openapi.json` · `/v1/tools` | The API as OpenAPI, and as function definitions |

### Deciding with no source

A workflow that only goes through the API decides on the values it already has, before any source is connected:

```bash
curl localhost:7710/v1/decide -H "Authorization: Bearer $ONTLAS_API_TOKEN" -H "Content-Type: application/json" \
     -d '{"decision": "returnEligibility", "values": {"delivered_at": "2026-10-26", "item_status": "NORMAL",
          "category_returnable": true, "customer_grade": "VIP"}}'
```

Each value goes by the decision's input name, or by the property of the target the input reads (a date stands for an
elapsed-days input, counted to `at` or now), or by its parameter. `null` is a value (no delivery date yet); an input not
given at all is never read as null: when the outcome turns on it the answer is `422` with `missing`, each input with
its label, type and the codes its property allows, so an agent can ask for it. Only those are asked for: where the given
values settle the outcome whatever the rest are (no delivery yet refuses a return, whatever the item's status), the
answer is the verdict and `not_needed` names the inputs it did without. A value that is not one of the allowed codes is not decided on either:
it comes back in `invalid` with the codes to choose from. With `key` instead, the record is read from the source. Either way the answer has `verdict`,
`decided_by` (the one rule that gave it, with its layer, module and version), `path` (AXIOM › Custom › Standard),
`evidence`, the `modules` and versions that decided and a `decision_id` the audit trail keeps.

`/v1/rules` gives the rule cards, AXIOM first, or those a text, a layer or a decision names, each with what carries it out.
`/v1/terms` reads a sentence in the glossary's preferred words and names the terms it must not be confused with.
`/v1/questions` runs the validation questions in two stages (below). Served with `--library`, `/v1/libraries` lists the
libraries and any call takes `library` to ask one of them; the first answers otherwise.

### What a platform asks first

Three calls answer before any source is connected, and a workflow can make each from one HTTP step:

| Call | It gives |
|---|---|
| `POST /v1/terms {text}` | The sentence in the glossary's preferred words. Each term with what it stands for (`meaning`: `주문 · 주문 상태 = DELIVERED` for a code value), the labels to search by (`expansions`, for widening a document search), the terms it must not be taken for, and the definitions the sentence names by their own label though no term covers them (`defined`) |
| `POST /v1/object {name}` | One Entity with where it sits (`area`, `parent`, `children`), its properties, relations, decisions and actions. `/v1/find` gives the definitions a question is about, each kind (Entity, rule, query, action) taking its turn so the rule that decides a long question is among them |
| `POST /v1/validate {object, values}` | Whether the values keep to the definition and to the rule cards that bound a property: `valid`, and per violation its `kind` (`rule`, `type`, `code`, `missing`, `unknown`), the card, its layer, source, module and version. `complete: true` asks for every required property too |

```bash
curl localhost:7710/v1/validate -H "Authorization: Bearer $ONTLAS_API_TOKEN" -H "Content-Type: application/json" \
     -d '{"object": "OrderItem", "values": {"unit_price": -100, "quantity": 2}}'
# {"valid": false, "violations": [{"property": "unit_price", "kind": "rule", "rule": "unit-price-not-negative",
#   "layer": "standard", "min": 0, "module": "commerce", "version": "1.0.0", ...}], "definition": {...}}
```

Every answer carries `definition`: the modules and versions it came from and one `version` for all of them, which changes
when any of them does. A platform keeps it with what it did, so a result that changed can be traced to the definitions
that changed. What a platform does when no answer comes is its own to set, and differs by call: a search goes on without
the wider labels of `/v1/terms`, but a decision that got no answer is held for a person rather than guessed, the same way
`/v1/decide` answers `422` rather than read a missing value as null.

### Validating in two stages

A decision question can state its values as well as, or instead of, a record:

```yaml
questions:
  - {id: OP4, text: "9만 7천원 주문 O1 의 배송비는 얼마인가요?", decision: shippingFee, key: O1,
     values: {order_total: 97000, order_status: DELIVERED}, expect: {fee: 0}}
```

On its values it is measured with no source (stage 1, 값 기준); on its key, once a source is connected (stage 2, 레코드
기준). Where they disagree the question says what to look at: `rule` when it is wrong on its own values too, `mapping`
when only the record is wrong (with the inputs the record reads otherwise, `differs`), `data` when the record could not
be read. The page's 검증 screen shows both stages and the cause; a question written on the page takes its values in typed
fields. 연동 · API tries `/v1/decide`, `/v1/validate`, `/v1/terms` and `/v1/object` on the page, through the same code a
platform's call takes, shows the request body, the cURL and the XGEN HTTP node settings, and keeps a decision call as a
validation question.

The other direction: a platform that manages database connections can lend one. `kind: gateway` sends SQL as text to its query
service and reads the rows back, so the password never reaches the space and the platform's read-only rule and table allow-list
stay in force. A space reads through it and never writes. An answer that comes back full is marked as possibly cut.

```yaml
backends:
  source: {kind: gateway, url: https://platform.example/query, connection: 12, dialect: postgres, token_env: PLATFORM_TOKEN, source: true}
```

## Agents over MCP

```bash
ontlas mcp examples/commerce/studio.yaml --role customer_agent --principal customer_id=C001 [--read-only]
ontlas mcp studio.yaml --agent "고객 응대 Agent" --journal records/agent.jsonl --transport streamable-http
```

Tools: `answer_question`, `agent_context`, `find_definitions`, `list_functions`, `run_function`, `describe_object`, `describe_ontology`, `list_modules`, `list_backends`, `translate_query`, `run_query`, `run_sparql`, `run_cypher`,
`decide`, `find_rules`, `read_terms`, `validate_values`, `run_questions`, `request_action`, `list_proposals`, `get_record`.
`decide` takes `values` as `/v1/decide` does, and answers `needs_values` with what the outcome still turns on instead of guessing.
Every call runs inside the role's row filters; `request_action`
only files a request, and nothing is written until a person approves it, and then only with `--action-write`
(without it the request ends recorded). `list_proposals` gives an agent with a role its own
requests. `--agent NAME` is what the audit trail calls it, `--journal FILE` keeps its requests across restarts, and
`--transport` is `stdio` (the default), `sse` or `streamable-http`. Works with the MCP Python SDK 1.x and 2.x.

An agent need not read a whole ontology: `find_definitions` gives what a question is about and `describe_object` one object with what
touches it. A running server reads the library again once an approved change is saved there (`--library-write`). A request stays in its own
process, so when people approve on a team's page, have the agent call `/v1` instead.

## Install

From PyPI, or `pip install -e ".[...]"` in a checkout (the examples and tests are only in the repository):

```bash
pip install ontlas                    # core, zero deps: SQLite, JSON, the IR, every compiler, decisions, rules
pip install "ontlas[all]"             # + PyYAML, rdflib, sqlglot, pySHACL, owlrl, ZEN, MCP, openpyxl
pip install "ontlas[postgres]"        # + psycopg      ("[neo4j]" for the Neo4j driver)
pip install "ontlas[mysql]"           # + PyMySQL, sqlglot      ("[oracle]" for oracledb, "[mssql]" for SQL Server)
pip install "ontlas[pdf]"             # + pypdf, for reading PDF documents
pip install "ontlas[xlsx]"            # + openpyxl, for drafting from Excel workbooks and reading a definition draft kept as one
pip install "ontlas[gremlin]"         # + gremlinpython, for Gremlin Server
pip install "ontlas[embed]"           # + fastembed, a multilingual embedding model on this machine
pip install "ontlas[reasonable]"      # + reasonable, a fast OWL RL engine, off by default
```

Qdrant and any OpenAI-shaped embedding service need no package: they are spoken to over HTTP.

Run the demo from a checkout with only PyYAML and rdflib installed:

```bash
python examples/commerce/demo.py
```

The tests need no server. With Docker, the same tests run against real ones, one at a time:

```bash
python tools/run_live.py                  # postgres, mysql, oracle, mssql, fuseki, neo4j, gremlin, qdrant, pgvector
python tools/run_live.py pgvector qdrant  # some of them
```

## Command line

```bash
ontlas validate examples/commerce/ontology.yaml
ontlas translate examples/commerce/ontology.yaml lowStock --to sql:snowflake --param threshold=5
ontlas translate examples/commerce/ontology.yaml "MATCH (o:Order) RETURN o.status, count(o) AS n" --from cypher --to sparql
ontlas export examples/commerce/ontology.yaml --format owl         # shacl · r2rml · pgq · jdm · json · yaml · report
ontlas import-owl vocabulary.ttl -o ontology.yaml
ontlas run examples/commerce/studio.yaml myOrders --role customer_agent --principal customer_id=C001
ontlas sparql examples/commerce/studio.yaml query.rq --backend source
ontlas cypher examples/commerce/studio.yaml "MATCH (o:Order) RETURN o.status, count(o) AS n"   # Cypher, on SQL too
ontlas decide examples/commerce/studio.yaml returnEligibility I1001
ontlas decide examples/library/studio.yaml returnEligibility --input days_since_delivery=3 --input item_status=NORMAL --input category_returnable=true --input customer_grade=VIP   # on values, no source read
ontlas questions examples/commerce/studio.yaml                    # validation questions and accuracy
ontlas conformance examples/commerce/studio.yaml                  # every registered query on every backend
ontlas rules examples/commerce/studio.yaml                        # links the rules derive, and what they find
ontlas shacl examples/commerce/studio.yaml                        # the projection held to the generated SHACL shapes
ontlas preview examples/library/studio.yaml -o studio.html        # the page in the screenshots
ontlas serve examples/library/studio.yaml --port 7710             # the same page, working: one studio per visitor
ontlas serve examples/library/studio.yaml --samples examples/files  # + example files a visitor loads with one click
ontlas serve examples/library/studio.yaml --library other/studio.yaml  # + another library a visitor can switch to
ontlas serve examples/library/studio.yaml --video demo.mp4          # + a demo video beside the guide (demo.chapters.json)
ontlas serve examples/library/studio.yaml --allow-connect --file-kb 4096 --rows 50000  # inside your own network only
ontlas serve examples/library/studio.yaml --repositories ./repositories --max-files 2000 --total-mb 4096  # files kept across restarts
ontlas new energy-studio --label "에너지 설비"                     # an empty studio folder: definitions are made on the page
ontlas draft examples/files/*.csv -o lib-demo                     # a definition and bindings drafted from data
ontlas ingest schema.sql 코드정의서.xlsx 용어집.xlsx 정책서.docx -o bundle.json  # anything, rolled into one JSON
ontlas draft --definitions bundle.json --name shop -o shop        # the JSON, drafted into modules
ontlas gates examples/library/studio.yaml                         # the flow's pass conditions, measured
ontlas agreement examples/library/studio.yaml                     # past decisions decided again
ontlas values examples/library/studio.yaml                        # answers held against the transaction system
ontlas functions examples/library/studio.yaml                     # registered functions; --run NAME --key K to run one
ontlas metric examples/library/studio.yaml returnRate             # a metric with what it means; no name lists the dictionary
ontlas periods examples/library/studio.yaml                       # rows of one thing valid at the same time
ontlas transitions examples/library/studio.yaml                   # time-based transitions that have come due; --apply takes them
ontlas views examples/library/studio.yaml                         # the statements that make the views objects are defined by
ontlas catalog examples/library/studio.yaml                       # the asset graph; --impact what a change touches, --agent/--sees what an agent sees
ontlas review examples/library/studio.yaml acme-1.1.0.yaml        # a new module version, reviewed on a copy
ontlas identity studio.yaml Person --write       # join the records, write the crosswalk
ontlas sync examples/library/studio.yaml --every 60               # the graphs kept up with the source
ontlas nl-eval examples/commerce/studio.yaml examples/commerce/nl_questions.yaml --llm-url ... --llm-model ...
ontlas policy-draft examples/library/studio.yaml examples/policies/교환정책서.md --target OrderItem --llm-url ... --llm-model ...
ontlas users add users.yaml kim --system user                     # a person of a team studio (ontlas serve --users)
ontlas users add users.yaml lee --roles editor                    # as before 0.27: 편집 in every ontology
ontlas users list users.yaml                                      # the people, their system roles and their part everywhere
ontlas search examples/library/studio.yaml "반품 기간" -k 3          # passages by meaning, and the definitions named
ontlas documents examples/library/studio.yaml                     # what the space holds: documents, stores, embedder, reasoners
ontlas vectors examples/library/studio.yaml                       # every vector store against exact search
ontlas reasoners examples/library/studio.yaml                     # what each engine derives; engines of one logic must agree
ontlas openapi --server https://space.example > openapi.json      # the REST API, for a platform to import
ontlas library list examples/library                              # every package, its kind, versions and requirements
ontlas library show examples/library commerce                     # one package: what it defines, extends and removes
ontlas library create my-lib energy --kind domain --label "에너지 설비" --requires core
ontlas library import-owl my-lib schema-orders.ttl schema-orders --requires core
ontlas library import-definitions my-lib shop objects.yaml entities.yaml rules.yaml glossary.yaml --requires core
ontlas library import-definitions my-lib shop draft.xlsx --requires core   # the same draft as a workbook, a sheet per section
# the same on the page: 온톨로지 선택 > 온톨로지 만들기 (a domain pack, an existing ontology, files or empty), then 내보내기 for a studio folder to serve
ontlas library diff my-lib fashion 1.0.0 1.1.0                    # what a new version adds, removes, changes
ontlas library delete my-lib energy --version 0.1.0               # a version out of the library; no version, the whole package
ontlas library compose examples/library commerce-operations-bindings -o ontology.yaml
ontlas modules examples/library/studio.yaml --impact fashion      # what detaching it would take away
ontlas modules examples/library/studio.yaml --rules               # the rule layers and cards; --check adds the AXIOM checks
ontlas lexicon show examples/library/studio.yaml                  # the terms, what each names, conflicts
ontlas lexicon import 용어집.csv --config studio.yaml -o dictionary.yaml  # a glossary, as one module
ontlas bindings examples/library/studio.yaml                      # the definition against the database
```

`ontlas serve` takes these beside the studio file:

| For | Options |
|---|---|
| The address | `--host`, `--port`, `--quiet` (no request log) |
| Visitors | `--sessions` (studios kept at once; the least recent goes first), `--idle` (seconds before an unused one is dropped). With `--users FILE` the team shares the server's ontologies behind a sign-in, each person opening the one they look at (opening or making one moves no one else), and `--journal FILE` keeps their requests, approvals and audit trail across restarts |
| What a visitor may bring | `--samples DIR`, `--policies DIR`, `--file-kb`, `--max-files`, `--total-mb`, `--rows`, `--repositories DIR` (files kept across restarts), `--allow-connect` (a database by address, inside your own network only) |
| Libraries | `--library STUDIO` (another studio file to switch to, repeated for more), `--library-write` (approved module versions saved to the folder of the library they were made in, and the libraries made on the page kept), `--libraries DIR` (where those are kept: `made/` beside the studio file unless given), `--libraries-max N` (how many of them the server keeps, 30 unless given) |
| `/v1` | `--api-token-env VAR` turns it on; `--api-role`, `--api-principal key=value` and `--api-name` say who the token is, `--api-write` lets it request actions, `--api-agents FILE` gives each agent a token of its own. A token with no role is refused unless `--api-open` |
| Actions | `--action-write` lets an approved action write to the source; without it the action is recorded and the source left as it is |
| A language model | `--llm-url`, `--llm-model`, `--llm-key-env VAR`, `--llm-extra JSON` (merged into each chat request) |
| Embeddings | `--embedder hash`, `fastembed`, or `openai` with `--embedder-url` and `--embedder-model` |
| The rest | `--sync N` (re-read the source every N seconds), `--video FILE` (a demo beside the guide) |

### A server that keeps what a team enters

Started with the studio file alone, a server gives each visitor a studio of their own and forgets it when the visitor
goes. A team that shares a server starts it with four options together, and what its people enter is there after a
restart:

```bash
ontlas serve studio.yaml --users users.yaml --journal records/journal.jsonl --library-write --repositories ./repositories
```

| What was entered | Where it stays | Kept by |
|---|---|---|
| Approved versions of the definition, and which modules are switched on | The library folder of the studio file, one file per module version (`workspace/0.1.0.yaml` for what was edited on the page) | `--library-write` |
| Ontologies made on the page (온톨로지 만들기) | `made/` beside the studio file, a studio folder each; `--libraries DIR` names another folder | `--library-write` |
| Edits saved and not yet filed, change requests with their reviews and decisions, comments, action requests and approvals, the audit trail, the pass conditions and quality targets set on the page, the AI draft history | The journal, one line each: the first ontology's in the `--journal` file, one made on the page in its own folder (`made/<key>/journal.jsonl`), another offered with `--library` beside the journal file. What is done to the server's users is in the `--journal` file, whichever ontology was open | `--journal` |
| Uploaded files and their folders | The repositories folder | `--repositories` |

Back up those places (the library folder, `made/`, the journal, the repositories folder), and with them the users
file, which the page writes when a person is added, signs in wrongly or changes a password, and `users.logins.json`
beside it, which keeps people signed in, `users.server.json` (the mail and log servers) and `users.people.json` (each
person's notices and choices). The options belong together: with a journal
and no `--library-write`, approved versions are put back from the journal at each start and nothing is written to the
library folder, but a module switched on or off by hand is not kept that way, and without `--repositories` uploaded
files go with the session.

A studio file names the ontology, the backends and what to project at start:

```yaml
ontology: ontology.yaml
backends:
  source: {kind: sqlite, path: commerce.db, source: true}       # postgres (dsn) · dbapi (module, connect)
  graph:  {kind: rdflib}                                         # sparql (query_url, update_url, gsp_url)
  neo:    {kind: neo4j, uri: "bolt://localhost:7687", password: "${NEO4J_PASSWORD}"}
project: [graph]
```

## Design

- **Domains are packages.** Commerce and every later domain are versioned modules in a library; a
  customer's differences and a database's bindings are modules too, so the standard is never edited to fit one site.
- **Domains meet in concepts.** Domain types hang from shared concepts and align to public vocabularies, so a
  question about a concept reaches every domain that specialises it.
- **One definition, many executions.** The definition is the only artifact people edit; SQL, Cypher, GQL,
  SPARQL, SQL/PGQ, OWL, SHACL, R2RML and JDM are all generated from it.
- **Values stay in the source.** Object types are bound to tables; a graph store is a projection you opt into,
  kept current by change sets.
- **A language model writes the IR, never the backend text.** Generated queries are checked against the
  ontology before they run, and every literal is a bound parameter.
- **Rules decide, reasoners derive.** Business decisions live in decision tables with their evidence;
  OWL RL and SHACL derive and validate facts. A decision does not depend on which reasoner is installed.
- **Prove it with the same rows.** Conformance runs compare every registered query across backends, and the
  readers are tested by compiling each query to SPARQL and Cypher and reading it back.
- **`dependencies = []`.** Everything optional is an extra; with all of them blocked the core test suite still passes.

```
src/ontlas/
  model.py validate.py      # the definition and its checks
  modules.py library.py     # packages, composition, attach / detach; the library of versioned packages
  bindings.py               # the definition against the actual database
  expr.py                   # computed properties: parse, type, render per language
  draft.py induce.py mapping.py   # drafted definitions, decision tables from outcomes, bindings onto a standard
  review.py identity.py     # flow, agreement, change requests; identities and crosswalks
  ir.py check.py values.py  # the query IR, its check, typed values
  compile/                  # sql (+ dialects) · cypher (+ gql) · sparql · pgq · gremlin
  parse/                    # sparql · cypher -> IR
  backends/                 # sql (sqlite, dbapi) · rdf (rdflib, endpoint) · graph (neo4j, callable) · gremlin
  projection.py rdf.py      # rows -> RDF / property graph, change sets; IRIs and Turtle
  decide/ actions.py roles.py
  reason/                   # rules · shacl · owl_rl
  exchange/                 # owl · r2rml · importer
  space.py embed.py vectors.py    # documents and their ontology, the embedding port, the vector store port
  knowledge.py answer.py relations.py   # one index over rules and passages, one question answered, relations read from documents
  semantic.py lexicon.py functions.py   # rule layers and rule cards, the glossary, functions under a contract
  manage.py journal.py      # the workspace's edits as one module; what outlives a restart
  ingest.py definitions.py codetables.py   # anything in, one JSON; table and code definitions; decision tables from codes
  rest.py                   # the token API, its OpenAPI and tool definitions
  catalog.py repository.py nl.py policy.py conformance.py studio.py config.py tools.py mcp_server.py preview.py cli.py
  web/                      # ontlas serve: api.py (answers from one studio), server.py, team.py, routes.py and areas/
                            # (the routes of each part), static/ (the page; v2/ holds the screens of each part)
examples/commerce/          # one ontology file, seed data, studio file, demo
examples/library/           # the same domain as packages, plus shop operations, fashion, food and a customer overlay
examples/files/             # a fictional shop's CSV files, for drafting from data
examples/documents/         # the shop's policies and guides, for search and the document ontology
tools/                      # render_screens.py (the README images), make_commerce_seed.py (the shop), graph-kit/ (the graph engine bundle)
```

## Prior art

Ontlas is an independent project. It is not affiliated with the products below and does not copy them; these are the public
ideas it studied and what it took from each.

| Reference | What it took | Where it is here | Where it differs |
|---|---|---|---|
| [Palantir Foundry Ontology](https://www.palantir.com/docs/foundry/ontology/core-concepts) | Objects, properties and links over data sources, with actions and functions as parts of the model; language, engine and tools kept apart | `model.py`, `actions.py`, `functions.py`, the management screens | Definitions are module files anyone can read and diff; one query runs on any store rather than one backend |
| [Foundry interfaces](https://www.palantir.com/docs/foundry/interfaces/interface-overview) | One shape shared by object types, read without naming the type | `check.interface_view` | Properties keep their names across types; no property mapping and no interface extending another |
| [Microsoft Fabric IQ ontology](https://learn.microsoft.com/en-us/fabric/iq/ontology/overview) | Definitions and bindings over data left in its own system; rules beside entities; RDF and OWL in and out | Bindings, `bindings.py` check, `exchange/` | Rules run as decision tables, not as text for a model |
| [W3C Direct Mapping](https://www.w3.org/TR/rdb-direct-mapping/) and [R2RML](https://www.w3.org/TR/r2rml/) | Table to class, column to property, foreign key to link; a mapping others can read | `draft.py`, `exchange/r2rml.py` | Keys and references are also inferred from values, with the reason kept |
| [SHACL](https://www.w3.org/TR/shacl/) and [OWL 2 RL](https://www.w3.org/TR/owl2-profiles/) | Structure checks and derived facts as a layer over the store | `reason/` | Business decisions stay out of the reasoner |
| [Ontop](https://ontop-vkg.org/) and [Stardog virtual graphs](https://docs.stardog.com/virtual-graphs/) | A graph view over tables that stay where they are | `compile/`, `projection.py` | Compiles from its own query IR to six languages |
| [GoRules ZEN](https://github.com/gorules/zen) | Decision tables as data, run by an engine | `decide/`, `decide/zen.py` | A built-in evaluator gives the same answer with the grounds |
| [LinkML](https://linkml.io/) | One definition, many artifacts | `exchange/`, `ontlas export` | The definition also carries rules, actions and roles |
| [TinkerPop](https://tinkerpop.apache.org/) | A conformance suite that every provider must pass | `conformance.py`, `ontlas conformance` | Compares rows across languages, not one language across providers |
| [schema.org](https://schema.org/), [GS1 Web Vocabulary](https://ref.gs1.org/voc/), [FIBO](https://spec.edmcouncil.org/fibo/), [Brick](https://brickschema.org/) | Terms an element can align with, kept as `aligned` | `aligned`, `exchange/owl.py` | A domain stays a module, so no vocabulary is built in |
| [LightRAG](https://github.com/HKUDS/LightRAG) and [sigma.js](https://www.sigmajs.org/) | The look of the graph screen | `static/graph.js`, `static/graph-kit.js` | Clusters fold past 120 nodes for a schema of hundreds of tables |

## Roadmap

- GQL run on a real engine: its text is compiled and checked as text, and no server here executes it
- `MIN` and `MAX` over a group with a missing value on Jena and Oxigraph, which leave the whole group unbound
- TinkerPop 4 once it is released
- sign-in through an organisation's identity provider for team studios
- decision tables drawn from outcomes with dates as inputs (days between two columns)
- several source databases in one studio
- interface properties mapped to differently named properties, and interfaces that extend others

## Repository model

[`PlateerLab/ontlas`](https://github.com/PlateerLab/ontlas) is the source of truth.
Members of the PlateerLab organization commit there directly; CI runs the full suite on Python 3.10–3.12 and the
core suite with no optional dependencies.

## License

Apache License 2.0. See [LICENSE.md](https://github.com/PlateerLab/ontlas/blob/main/LICENSE.md) for details.
