plainontology 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. plainontology-0.1.0/.gitattributes +1 -0
  2. plainontology-0.1.0/.github/workflows/ci.yml +38 -0
  3. plainontology-0.1.0/.github/workflows/release.yml +50 -0
  4. plainontology-0.1.0/.gitignore +10 -0
  5. plainontology-0.1.0/CHANGELOG.md +11 -0
  6. plainontology-0.1.0/CITATION.cff +20 -0
  7. plainontology-0.1.0/CONTRIBUTING.md +31 -0
  8. plainontology-0.1.0/LICENSE +21 -0
  9. plainontology-0.1.0/PKG-INFO +181 -0
  10. plainontology-0.1.0/README.md +154 -0
  11. plainontology-0.1.0/ROADMAP.md +28 -0
  12. plainontology-0.1.0/SPEC.md +102 -0
  13. plainontology-0.1.0/examples/agent-tools.json +29 -0
  14. plainontology-0.1.0/examples/article.schema.json +41 -0
  15. plainontology-0.1.0/examples/library.onto +61 -0
  16. plainontology-0.1.0/examples/library.sql +35 -0
  17. plainontology-0.1.0/pyproject.toml +42 -0
  18. plainontology-0.1.0/src/plainontology/__init__.py +25 -0
  19. plainontology-0.1.0/src/plainontology/__main__.py +3 -0
  20. plainontology-0.1.0/src/plainontology/api.py +48 -0
  21. plainontology-0.1.0/src/plainontology/check.py +124 -0
  22. plainontology-0.1.0/src/plainontology/cli.py +150 -0
  23. plainontology-0.1.0/src/plainontology/export/__init__.py +4 -0
  24. plainontology-0.1.0/src/plainontology/export/linkml.py +129 -0
  25. plainontology-0.1.0/src/plainontology/export/turtle.py +122 -0
  26. plainontology-0.1.0/src/plainontology/extract/__init__.py +45 -0
  27. plainontology-0.1.0/src/plainontology/extract/jsonschema.py +165 -0
  28. plainontology-0.1.0/src/plainontology/extract/sqlite.py +128 -0
  29. plainontology-0.1.0/src/plainontology/extract/tools.py +58 -0
  30. plainontology-0.1.0/src/plainontology/mcp_server.py +151 -0
  31. plainontology-0.1.0/src/plainontology/merge.py +154 -0
  32. plainontology-0.1.0/src/plainontology/model.py +189 -0
  33. plainontology-0.1.0/src/plainontology/naming.py +56 -0
  34. plainontology-0.1.0/src/plainontology/textformat.py +162 -0
  35. plainontology-0.1.0/tests/__init__.py +0 -0
  36. plainontology-0.1.0/tests/conftest.py +14 -0
  37. plainontology-0.1.0/tests/test_check.py +45 -0
  38. plainontology-0.1.0/tests/test_cli.py +42 -0
  39. plainontology-0.1.0/tests/test_export.py +41 -0
  40. plainontology-0.1.0/tests/test_extract.py +98 -0
  41. plainontology-0.1.0/tests/test_mcp.py +45 -0
  42. plainontology-0.1.0/tests/test_merge.py +84 -0
  43. plainontology-0.1.0/tests/test_textformat.py +61 -0
  44. plainontology-0.1.0/tests/test_version.py +23 -0
@@ -0,0 +1 @@
1
+ * text=auto eol=lf
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ${{ matrix.os }}
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ os: [ubuntu-latest, windows-latest]
18
+ python: ["3.10", "3.11", "3.12", "3.13"]
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python }}
24
+ - run: pip install -e ".[dev]"
25
+ - run: pytest -q
26
+
27
+ example-drift:
28
+ # The example file must match its sources, as a demo of using drift as a CI gate.
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ - uses: actions/setup-python@v5
33
+ with:
34
+ python-version: "3.13"
35
+ - run: pip install -e .
36
+ - run: plainonto check --strict examples/library.onto
37
+ - run: |
38
+ plainonto drift examples/library.onto
@@ -0,0 +1,50 @@
1
+ name: Release
2
+
3
+ # Runs when a GitHub release is published. Builds the package and uploads it to
4
+ # PyPI with Trusted Publishing (no API token stored anywhere). The same release
5
+ # makes Zenodo mint a DOI, once the repository is switched on at zenodo.org.
6
+
7
+ on:
8
+ release:
9
+ types: [published]
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ build:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.13"
22
+ - name: Tag must match the package version
23
+ run: |
24
+ version=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
25
+ if [ "v$version" != "$GITHUB_REF_NAME" ]; then
26
+ echo "Release tag $GITHUB_REF_NAME does not match pyproject version v$version"
27
+ exit 1
28
+ fi
29
+ - run: pip install build twine
30
+ - run: python -m build
31
+ - run: twine check --strict dist/*
32
+ - uses: actions/upload-artifact@v4
33
+ with:
34
+ name: dist
35
+ path: dist/
36
+
37
+ publish:
38
+ needs: build
39
+ runs-on: ubuntu-latest
40
+ environment:
41
+ name: pypi
42
+ url: https://pypi.org/project/plainontology/
43
+ permissions:
44
+ id-token: write
45
+ steps:
46
+ - uses: actions/download-artifact@v4
47
+ with:
48
+ name: dist
49
+ path: dist/
50
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,10 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ examples/*.ttl
9
+ examples/*.yaml
10
+ examples/*.db
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-11-26)
4
+
5
+ First release.
6
+
7
+ - Plain text format, version 0.1 (see SPEC.md)
8
+ - Extractors: `sqlite` (database or `.sql` file), `jsonschema`, `tools` (Anthropic, OpenAI and MCP tool definitions)
9
+ - Commands: `init`, `refresh`, `drift`, `check`, `export`, `validate`, `mcp`
10
+ - Exports: Turtle (OWL + SKOS), LinkML
11
+ - MCP server: `list_concepts`, `describe_concept`, `search`, `validate_record`, `drift`, and opt-in `propose`
@@ -0,0 +1,20 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ type: software
4
+ title: "PlainOntology: the ontology and semantic layer of a running system as one plain text file"
5
+ abstract: "PlainOntology extracts the implicit ontology of a running system (database schemas, JSON Schema, LLM tool definitions) into a plain text file, keeps hand-written semantic lines across re-extraction, reports drift, exports to OWL/SKOS and LinkML, and serves the file to AI agents over the Model Context Protocol."
6
+ authors:
7
+ - family-names: "Furacão"
8
+ given-names: "Christopher"
9
+ orcid: "https://orcid.org/0009-0001-4154-6267"
10
+ version: 0.1.0
11
+ license: MIT
12
+ repository-code: "https://github.com/cfuracao-academic/plainontology"
13
+ keywords:
14
+ - ontology
15
+ - semantic layer
16
+ - knowledge graph
17
+ - SKOS
18
+ - LinkML
19
+ - schema drift
20
+ - Model Context Protocol
@@ -0,0 +1,31 @@
1
+ # Contributing
2
+
3
+ Thanks for helping. Issues and pull requests are welcome.
4
+
5
+ ## Set up
6
+
7
+ ```bash
8
+ python -m venv .venv
9
+ .venv/bin/pip install -e ".[dev]" # Windows: .venv\Scripts\pip
10
+ pytest
11
+ ```
12
+
13
+ ## Ground rules
14
+
15
+ 1. **Never overwrite a person's line.** Any change to merge must keep the refresh rules in [SPEC.md](SPEC.md) and the tests in `tests/test_merge.py` passing.
16
+ 2. **Keep the core dependency-free.** Only the standard library in `src/plainontology`, except `mcp_server.py`. New extractors that need a library go behind an optional extra.
17
+ 3. **Format changes need a spec change.** If the text format changes, update SPEC.md in the same pull request.
18
+ 4. **Test with public data only.** Examples and fixtures must be public or made up.
19
+
20
+ ## Adding an extractor
21
+
22
+ 1. Add `src/plainontology/extract/<kind>.py` with a function `extract_<kind>(path: Path) -> list[Concept]`.
23
+ 2. Tag every concept and statement it produces with `Tag("auto", ...)`.
24
+ 3. Register it in `EXTRACTORS` in `src/plainontology/extract/__init__.py`.
25
+ 4. Add an example under `examples/` and tests under `tests/`.
26
+
27
+ ## Releasing
28
+
29
+ 1. Set the new version in `pyproject.toml`, `src/plainontology/__init__.py` and `CITATION.cff` (a test checks they match), and add a CHANGELOG entry.
30
+ 2. Commit and push to `main`; wait for CI to pass.
31
+ 3. Create a GitHub release with the tag `vX.Y.Z`. The release workflow builds the package and uploads it to PyPI, and Zenodo mints a DOI for the release.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christopher Furacão
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.5
2
+ Name: plainontology
3
+ Version: 0.1.0
4
+ Summary: Write down the ontology and semantic layer a system already has as one plain text file: editable, diffable, exportable to OWL/SKOS and LinkML, and served to AI agents over MCP.
5
+ Project-URL: Homepage, https://github.com/cfuracao-academic/plainontology
6
+ Project-URL: Issues, https://github.com/cfuracao-academic/plainontology/issues
7
+ Author: Christopher Furacão
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: data dictionary,knowledge graph,linkml,llm,mcp,ontology,owl,schema drift,semantic layer,skos
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Database
16
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
17
+ Classifier: Topic :: Software Development :: Documentation
18
+ Requires-Python: >=3.10
19
+ Provides-Extra: dev
20
+ Requires-Dist: mcp<3,>=2; extra == 'dev'
21
+ Requires-Dist: pytest>=8; extra == 'dev'
22
+ Requires-Dist: pyyaml>=6; extra == 'dev'
23
+ Requires-Dist: rdflib>=7; extra == 'dev'
24
+ Provides-Extra: mcp
25
+ Requires-Dist: mcp<3,>=2; extra == 'mcp'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # PlainOntology
29
+
30
+ [![CI](https://github.com/cfuracao-academic/plainontology/actions/workflows/ci.yml/badge.svg)](https://github.com/cfuracao-academic/plainontology/actions/workflows/ci.yml)
31
+ [![PyPI](https://img.shields.io/pypi/v/plainontology)](https://pypi.org/project/plainontology/)
32
+ [![Python](https://img.shields.io/badge/python-3.10%20to%203.13-blue)](pyproject.toml)
33
+ [![Licence: MIT](https://img.shields.io/badge/licence-MIT-green)](LICENSE)
34
+
35
+ **Write down the ontology your system already has, as one plain text file that people can edit and AI agents can read.**
36
+
37
+ Every running system carries an implicit ontology: tables and foreign keys, JSON schemas, the tool definitions an LLM agent calls. Its meaning (what a "loan" is, that a "Title" is a "Book", that `member` holds personal data) usually lives in people's heads. PlainOntology extracts the structure into a readable text file, keeps your hand-written meaning next to it, and tells you when the system drifts away from it.
38
+
39
+ ```text
40
+ concept Book [auto: sqlite table books]
41
+ has id : integer key [auto]
42
+ has title : text required [auto]
43
+ has isbn : text unique "ISBN-13 without hyphens."
44
+ author -> Author required [auto: fk books.author_id]
45
+ tags -> Tag many [auto: via book_tags]
46
+ definition "A title the library holds; one record per edition."
47
+ synonym "Title"
48
+ same_as schema:Book
49
+ ```
50
+
51
+ Lines tagged `[auto]` come from the sources and are refreshed. **Every other line is yours and is never overwritten.**
52
+
53
+ ## What it does
54
+
55
+ | | |
56
+ |---|---|
57
+ | **Extract** | SQLite databases or `.sql` schema files, JSON Schema (draft 7 and 2020-12), and LLM tool definitions (Anthropic, OpenAI Chat and Responses, MCP `tools/list`) |
58
+ | **Keep your edits** | Refresh replaces `[auto]` lines only. If you rewrite an extracted line, your version wins and is reported |
59
+ | **Report drift** | `plainonto drift` exits 1 when the sources changed, so it can gate CI |
60
+ | **Check** | Duplicate lines, unknown targets, undeclared prefixes, proposals waiting for review |
61
+ | **Validate** | Check JSON records (for example an agent's structured output) against a concept |
62
+ | **Export** | RDF Turtle (OWL structure, SKOS meaning) and LinkML YAML |
63
+ | **Serve to agents** | An MCP server so agents look concepts up, validate their output, and propose new lines for a person to review |
64
+
65
+ The core has no dependencies beyond the Python standard library. The MCP server needs the `mcp` extra.
66
+
67
+ ## Quick start
68
+
69
+ ```bash
70
+ pip install "plainontology[mcp]"
71
+
72
+ cd examples
73
+ plainonto init library.onto --from sqlite:library.sql --from tools:agent-tools.json
74
+ # edit library.onto: add definitions, synonyms, same_as mappings
75
+ plainonto refresh library.onto # re-extract; your lines stay
76
+ plainonto drift library.onto # report only; exit 1 on drift
77
+ plainonto check library.onto
78
+ plainonto export library.onto --to turtle -o library.ttl
79
+ plainonto export library.onto --to linkml -o library.yaml
80
+ plainonto validate library.onto Loan record.json
81
+ ```
82
+
83
+ The command is `plainonto` (short for `plainontology`; both work).
84
+
85
+ Sources are written `KIND:PATH` and stored in the file, relative to it:
86
+
87
+ | Kind | Path |
88
+ |---|---|
89
+ | `sqlite` | a SQLite database, or a `.sql` schema file (loaded into memory) |
90
+ | `jsonschema` | a JSON Schema file; `$defs` and nested objects become concepts. For Pydantic, dump `Model.model_json_schema()` first |
91
+ | `tools` | a JSON list of tool definitions, or an object with a `tools` list |
92
+
93
+ ## Use it from an AI agent (MCP)
94
+
95
+ ```bash
96
+ plainonto mcp path/to/library.onto # read-only tools
97
+ plainonto mcp path/to/library.onto --allow-proposals # also lets agents propose lines
98
+ ```
99
+
100
+ Claude Code:
101
+
102
+ ```bash
103
+ claude mcp add plainontology -- plainonto mcp /absolute/path/to/library.onto
104
+ ```
105
+
106
+ Claude Desktop or any MCP client (`mcpServers` in the client's config):
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "plainontology": { "command": "plainonto", "args": ["mcp", "/absolute/path/to/library.onto"] }
112
+ }
113
+ }
114
+ ```
115
+
116
+ | Tool | What it does |
117
+ |---|---|
118
+ | `list_concepts` | every concept with its definition |
119
+ | `describe_concept` | a concept's lines, inherited properties and who points to it |
120
+ | `search` | find concepts by name, label, synonym, definition or property |
121
+ | `validate_record` | check a JSON object against a concept before acting on it |
122
+ | `drift` | compare the file with its sources now |
123
+ | `propose` | only with `--allow-proposals`: add a line tagged `[proposed]`; a person accepts it by deleting the tag |
124
+
125
+ The file is re-read on every call, so edits show up at once. Agents can never change or delete an existing line.
126
+
127
+ ## Why a text file
128
+
129
+ * **Diffable.** Ontology changes go through pull requests like code.
130
+ * **Two layers in one place.** Structure (`has`, `->`, `is_a`) and meaning (`label`, `definition`, `synonym`, `same_as`, `note`) sit together, so neither drifts from the other.
131
+ * **Interoperable.** Export to OWL/SKOS and LinkML when you need the standard toolchains.
132
+
133
+ ## How it compares
134
+
135
+ | | PlainOntology | LinkML | OWL editors (Protégé) | Data catalogues (DataHub, OpenMetadata) |
136
+ |---|---|---|---|---|
137
+ | Direction | extracts from a running system | you write the schema, it generates | you write the ontology | ingests metadata |
138
+ | Format | one plain text file | YAML | RDF/OWL | database behind a server |
139
+ | Keeps hand edits across re-extraction | yes | n/a | n/a | partly |
140
+ | LLM tool schemas and MCP | yes | no | no | no |
141
+ | Setup | `pip install` | `pip install` | desktop app | servers |
142
+
143
+ PlainOntology does not replace these. It exports to LinkML and OWL so you can move to them when you need more.
144
+
145
+ ## Format
146
+
147
+ The full grammar and refresh rules are in [SPEC.md](SPEC.md). In short:
148
+
149
+ ```text
150
+ prefix : <https://example.org/library#>
151
+ source sqlite:library.sql
152
+
153
+ concept NAME [auto: where it came from]
154
+ has PROPERTY : TYPE [FLAGS] ["description"]
155
+ PROPERTY -> CONCEPT [FLAGS] ["description"]
156
+ is_a CONCEPT
157
+ label "..."
158
+ definition "..."
159
+ synonym "..."
160
+ note "..."
161
+ same_as prefix:Term
162
+ ```
163
+
164
+ Types: `text integer decimal boolean date datetime binary json any enum(a|b)`. Flags: `key required unique many`. The empty prefix line sets the base IRI for exports.
165
+
166
+ ## Development
167
+
168
+ ```bash
169
+ python -m venv .venv && .venv/bin/pip install -e ".[dev]"
170
+ pytest
171
+ ```
172
+
173
+ See [CONTRIBUTING.md](CONTRIBUTING.md) and [ROADMAP.md](ROADMAP.md).
174
+
175
+ ## Citing
176
+
177
+ If you use PlainOntology in research, please cite it using [CITATION.cff](CITATION.cff).
178
+
179
+ ## Licence
180
+
181
+ MIT
@@ -0,0 +1,154 @@
1
+ # PlainOntology
2
+
3
+ [![CI](https://github.com/cfuracao-academic/plainontology/actions/workflows/ci.yml/badge.svg)](https://github.com/cfuracao-academic/plainontology/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/plainontology)](https://pypi.org/project/plainontology/)
5
+ [![Python](https://img.shields.io/badge/python-3.10%20to%203.13-blue)](pyproject.toml)
6
+ [![Licence: MIT](https://img.shields.io/badge/licence-MIT-green)](LICENSE)
7
+
8
+ **Write down the ontology your system already has, as one plain text file that people can edit and AI agents can read.**
9
+
10
+ Every running system carries an implicit ontology: tables and foreign keys, JSON schemas, the tool definitions an LLM agent calls. Its meaning (what a "loan" is, that a "Title" is a "Book", that `member` holds personal data) usually lives in people's heads. PlainOntology extracts the structure into a readable text file, keeps your hand-written meaning next to it, and tells you when the system drifts away from it.
11
+
12
+ ```text
13
+ concept Book [auto: sqlite table books]
14
+ has id : integer key [auto]
15
+ has title : text required [auto]
16
+ has isbn : text unique "ISBN-13 without hyphens."
17
+ author -> Author required [auto: fk books.author_id]
18
+ tags -> Tag many [auto: via book_tags]
19
+ definition "A title the library holds; one record per edition."
20
+ synonym "Title"
21
+ same_as schema:Book
22
+ ```
23
+
24
+ Lines tagged `[auto]` come from the sources and are refreshed. **Every other line is yours and is never overwritten.**
25
+
26
+ ## What it does
27
+
28
+ | | |
29
+ |---|---|
30
+ | **Extract** | SQLite databases or `.sql` schema files, JSON Schema (draft 7 and 2020-12), and LLM tool definitions (Anthropic, OpenAI Chat and Responses, MCP `tools/list`) |
31
+ | **Keep your edits** | Refresh replaces `[auto]` lines only. If you rewrite an extracted line, your version wins and is reported |
32
+ | **Report drift** | `plainonto drift` exits 1 when the sources changed, so it can gate CI |
33
+ | **Check** | Duplicate lines, unknown targets, undeclared prefixes, proposals waiting for review |
34
+ | **Validate** | Check JSON records (for example an agent's structured output) against a concept |
35
+ | **Export** | RDF Turtle (OWL structure, SKOS meaning) and LinkML YAML |
36
+ | **Serve to agents** | An MCP server so agents look concepts up, validate their output, and propose new lines for a person to review |
37
+
38
+ The core has no dependencies beyond the Python standard library. The MCP server needs the `mcp` extra.
39
+
40
+ ## Quick start
41
+
42
+ ```bash
43
+ pip install "plainontology[mcp]"
44
+
45
+ cd examples
46
+ plainonto init library.onto --from sqlite:library.sql --from tools:agent-tools.json
47
+ # edit library.onto: add definitions, synonyms, same_as mappings
48
+ plainonto refresh library.onto # re-extract; your lines stay
49
+ plainonto drift library.onto # report only; exit 1 on drift
50
+ plainonto check library.onto
51
+ plainonto export library.onto --to turtle -o library.ttl
52
+ plainonto export library.onto --to linkml -o library.yaml
53
+ plainonto validate library.onto Loan record.json
54
+ ```
55
+
56
+ The command is `plainonto` (short for `plainontology`; both work).
57
+
58
+ Sources are written `KIND:PATH` and stored in the file, relative to it:
59
+
60
+ | Kind | Path |
61
+ |---|---|
62
+ | `sqlite` | a SQLite database, or a `.sql` schema file (loaded into memory) |
63
+ | `jsonschema` | a JSON Schema file; `$defs` and nested objects become concepts. For Pydantic, dump `Model.model_json_schema()` first |
64
+ | `tools` | a JSON list of tool definitions, or an object with a `tools` list |
65
+
66
+ ## Use it from an AI agent (MCP)
67
+
68
+ ```bash
69
+ plainonto mcp path/to/library.onto # read-only tools
70
+ plainonto mcp path/to/library.onto --allow-proposals # also lets agents propose lines
71
+ ```
72
+
73
+ Claude Code:
74
+
75
+ ```bash
76
+ claude mcp add plainontology -- plainonto mcp /absolute/path/to/library.onto
77
+ ```
78
+
79
+ Claude Desktop or any MCP client (`mcpServers` in the client's config):
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "plainontology": { "command": "plainonto", "args": ["mcp", "/absolute/path/to/library.onto"] }
85
+ }
86
+ }
87
+ ```
88
+
89
+ | Tool | What it does |
90
+ |---|---|
91
+ | `list_concepts` | every concept with its definition |
92
+ | `describe_concept` | a concept's lines, inherited properties and who points to it |
93
+ | `search` | find concepts by name, label, synonym, definition or property |
94
+ | `validate_record` | check a JSON object against a concept before acting on it |
95
+ | `drift` | compare the file with its sources now |
96
+ | `propose` | only with `--allow-proposals`: add a line tagged `[proposed]`; a person accepts it by deleting the tag |
97
+
98
+ The file is re-read on every call, so edits show up at once. Agents can never change or delete an existing line.
99
+
100
+ ## Why a text file
101
+
102
+ * **Diffable.** Ontology changes go through pull requests like code.
103
+ * **Two layers in one place.** Structure (`has`, `->`, `is_a`) and meaning (`label`, `definition`, `synonym`, `same_as`, `note`) sit together, so neither drifts from the other.
104
+ * **Interoperable.** Export to OWL/SKOS and LinkML when you need the standard toolchains.
105
+
106
+ ## How it compares
107
+
108
+ | | PlainOntology | LinkML | OWL editors (Protégé) | Data catalogues (DataHub, OpenMetadata) |
109
+ |---|---|---|---|---|
110
+ | Direction | extracts from a running system | you write the schema, it generates | you write the ontology | ingests metadata |
111
+ | Format | one plain text file | YAML | RDF/OWL | database behind a server |
112
+ | Keeps hand edits across re-extraction | yes | n/a | n/a | partly |
113
+ | LLM tool schemas and MCP | yes | no | no | no |
114
+ | Setup | `pip install` | `pip install` | desktop app | servers |
115
+
116
+ PlainOntology does not replace these. It exports to LinkML and OWL so you can move to them when you need more.
117
+
118
+ ## Format
119
+
120
+ The full grammar and refresh rules are in [SPEC.md](SPEC.md). In short:
121
+
122
+ ```text
123
+ prefix : <https://example.org/library#>
124
+ source sqlite:library.sql
125
+
126
+ concept NAME [auto: where it came from]
127
+ has PROPERTY : TYPE [FLAGS] ["description"]
128
+ PROPERTY -> CONCEPT [FLAGS] ["description"]
129
+ is_a CONCEPT
130
+ label "..."
131
+ definition "..."
132
+ synonym "..."
133
+ note "..."
134
+ same_as prefix:Term
135
+ ```
136
+
137
+ Types: `text integer decimal boolean date datetime binary json any enum(a|b)`. Flags: `key required unique many`. The empty prefix line sets the base IRI for exports.
138
+
139
+ ## Development
140
+
141
+ ```bash
142
+ python -m venv .venv && .venv/bin/pip install -e ".[dev]"
143
+ pytest
144
+ ```
145
+
146
+ See [CONTRIBUTING.md](CONTRIBUTING.md) and [ROADMAP.md](ROADMAP.md).
147
+
148
+ ## Citing
149
+
150
+ If you use PlainOntology in research, please cite it using [CITATION.cff](CITATION.cff).
151
+
152
+ ## Licence
153
+
154
+ MIT
@@ -0,0 +1,28 @@
1
+ # Roadmap
2
+
3
+ ## 0.1 (this release)
4
+
5
+ - [x] Plain text format with `[auto]`, `[proposed]` and hand-written lines
6
+ - [x] Extractors: SQLite and `.sql`, JSON Schema, LLM tool definitions
7
+ - [x] Refresh that keeps hand-written lines, and drift reports for CI
8
+ - [x] Check and record validation
9
+ - [x] Export to Turtle (OWL + SKOS) and LinkML
10
+ - [x] MCP server with opt-in proposals
11
+
12
+ ## Next
13
+
14
+ - [ ] PostgreSQL and MySQL extractors (via SQLAlchemy inspection)
15
+ - [ ] OpenAPI extractor (components/schemas and operations)
16
+ - [ ] Pydantic extractor without dumping JSON Schema first
17
+ - [ ] RAG metadata extractor (field names and values in a vector store's payloads)
18
+ - [ ] GitHub Action: `plainonto drift` on pull requests, with the report as a comment
19
+ - [ ] Import from Turtle/SKOS so an existing vocabulary can seed the meaning layer
20
+ - [ ] `plainonto diff A.onto B.onto` between two files or two commits
21
+
22
+ ## Community and visibility
23
+
24
+ - [ ] README demo GIF: extract, edit, refresh, your edit survives
25
+ - [ ] Hugging Face Space: paste a schema, get the file
26
+ - [ ] Hugging Face dataset: PlainOntology files extracted from public OpenAPI specs
27
+ - [ ] Zenodo DOI for each release
28
+ - [ ] Demo paper (ISWC, ESWC or SEMANTiCS demo track)
@@ -0,0 +1,102 @@
1
+ # PlainOntology file format, version 0.1
2
+
3
+ A PlainOntology file is UTF-8 plain text, one statement per line. Files conventionally end in `.onto`.
4
+
5
+ ## File layout
6
+
7
+ ```text
8
+ # comments before the first concept are the file header
9
+ prefix : <https://example.org/library#>
10
+ prefix ex: <https://example.org/terms/>
11
+ source sqlite:library.sql
12
+ source tools:agent-tools.json
13
+
14
+ # a comment at the start of a line, before a concept, belongs to that concept
15
+ concept Book [auto: sqlite table books]
16
+ has title : text required [auto]
17
+ # an indented comment stays inside the concept
18
+ definition "A title the library holds."
19
+ ```
20
+
21
+ * Blank lines are ignored.
22
+ * `prefix` and `source` lines must come before the first concept.
23
+ * `prefix : <IRI>` (empty prefix) sets the base IRI used by exports.
24
+ * These prefixes are known without declaring them: `owl rdf rdfs xsd skos schema dcterms foaf prov`.
25
+ * A statement line is indented (spaces or tabs) and belongs to the concept above it.
26
+
27
+ ## Concepts
28
+
29
+ ```text
30
+ concept NAME [TAG]
31
+ ```
32
+
33
+ `NAME` starts with a letter or `_` and may contain letters, digits, `_ . : / -`. Each name appears once per file.
34
+
35
+ ## Statements
36
+
37
+ | Statement | Meaning | Layer |
38
+ |---|---|---|
39
+ | `has NAME : TYPE [FLAGS] ["description"]` | an attribute with a datatype | structure |
40
+ | `NAME -> CONCEPT [FLAGS] ["description"]` | a relation to another concept (or a `prefix:Term`) | structure |
41
+ | `is_a CONCEPT` | subclass of | structure |
42
+ | `label "text"` | preferred human name | meaning |
43
+ | `definition "text"` | what the concept is | meaning |
44
+ | `synonym "text"` | another name people use | meaning |
45
+ | `same_as prefix:Term` | the same concept in another vocabulary | meaning |
46
+ | `note "text"` | anything else worth knowing | meaning |
47
+ | `# text` | a comment | |
48
+
49
+ **Types:** `text`, `integer`, `decimal`, `boolean`, `date`, `datetime`, `binary`, `json`, `any`, or `enum(a|b|c)`. Enum values may contain spaces but not `|` or `)`.
50
+
51
+ **Flags:** `key` (identifier), `required`, `unique`, `many` (list or to-many relation).
52
+
53
+ **Strings** are double-quoted; inside them use `\"` for a quote, `\\` for a backslash and `\n` for a new line.
54
+
55
+ ## Tags
56
+
57
+ A tag at the end of a concept or statement line says who owns it:
58
+
59
+ | Tag | Owner | On refresh |
60
+ |---|---|---|
61
+ | `[auto]` or `[auto: detail]` | the sources | replaced by what the sources say now |
62
+ | `[proposed]` or `[proposed: detail]` | an agent, waiting for review | kept; accept by deleting the tag |
63
+ | no tag | a person | always kept |
64
+
65
+ The detail after `auto:` records where a line came from, for example `fk books.author_id`.
66
+
67
+ ## Identity of a line
68
+
69
+ Merge matches lines by key, one line per key per concept:
70
+
71
+ | Statement | Key |
72
+ |---|---|
73
+ | `has` and `->` | the property name (they share one namespace) |
74
+ | `label`, `definition` | the statement kind (one each per concept) |
75
+ | `is_a`, `same_as` | the target |
76
+ | `synonym`, `note`, comment | the text |
77
+
78
+ ## Refresh rules
79
+
80
+ When `plainonto refresh` re-extracts the sources:
81
+
82
+ 1. Lines without a tag and `[proposed]` lines are kept, in place.
83
+ 2. Each `[auto]` line is replaced by the extracted line with the same key, or removed if the sources no longer produce it. New extracted lines are appended to their concept.
84
+ 3. If a person's line has the same key as an extracted line, the person's line wins and the extracted line is not written. The drift report shows both (`=`).
85
+ 4. A concept that is gone from the sources is removed if it was extracted and holds none of your lines. If it holds your lines, it is kept, its tag is removed, and the report says so (`!`).
86
+ 5. Refresh is idempotent: running it twice changes nothing the second time.
87
+
88
+ ## Drift report symbols
89
+
90
+ | Symbol | Meaning |
91
+ |---|---|
92
+ | `+` | added from the sources |
93
+ | `-` | gone from the sources |
94
+ | `~` | changed in the sources |
95
+ | `=` | your line kept over a different extracted line (not counted as drift) |
96
+ | `!` | concept gone from the sources, kept because it holds your lines |
97
+
98
+ ## Exports
99
+
100
+ **Turtle:** each concept is an `owl:Class`; `has` lines become `owl:DatatypeProperty` and relations `owl:ObjectProperty`, scoped as `Concept/property`. Single-valued properties are also `owl:FunctionalProperty`; `required` and `key` add an `owl:minCardinality 1` restriction. Labels, definitions, synonyms and notes map to SKOS; `same_as` maps to `owl:equivalentClass`.
101
+
102
+ **LinkML:** each concept is a class with `attributes`; `key` maps to `identifier`, `many` to `multivalued`, enums to LinkML enums, `same_as` to `exact_mappings`, synonyms to `aliases`.