Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

docs+test: align docs with merged PRs and add resolver regression tests (PR #11)

FABIOTESSb9fe32cc046b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0553481c..7a684f97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,21 @@
All notable changes to Open Ontologies are documented here.
+## [0.1.13] - 2026-05-01
+
+### Added
+- **Compile cache + TTL eviction + tool-exposure filter** (PR #1). Parsed ontologies are serialized to N-Triples on disk and reused on subsequent loads. A background evictor unloads idle ontologies after `[cache] idle_ttl_secs` (alias `unload_timeout_secs`); the on-disk cache is preserved and reloaded transparently on the next query. New `[tools]` config and `--tools-allow` / `--tools-deny` CLI flags restrict which `onto_*` tools the MCP server advertises (groups: `read_only`, `mutating`, `governance`, `remote`, `embeddings`).
+- **New MCP tools**: `onto_cache_status`, `onto_cache_list`, `onto_cache_remove`, plus optional `name` parameter on `onto_unload` / `onto_recompile` for per-name cache management.
+- **Ontology repository directories** (PR #2). New `[general] ontology_dirs` config (alias `data_dirs`) and `OPEN_ONTOLOGIES_ONTOLOGY_DIRS` env var let containerized deployments mount a folder of ontologies. Two new MCP tools enumerate and load from those directories with path-traversal guards: `onto_repo_list`, `onto_repo_load`.
+- **OpenAI-compatible embeddings provider** (PR #3). New `[embeddings] provider = "openai"` mode targets any OpenAI-compatible gateway (official OpenAI, Azure, Ollama, vLLM, LocalAI, LM Studio, Together, …). Config fields: `api_base` (alias `base_url`), `api_key`, `model`, `dimensions`, `request_timeout_secs`. Env-var precedence: `OPEN_ONTOLOGIES_EMBEDDINGS_*` > `OPENAI_API_KEY` (for the key) > config > defaults. Remote responses are L2-normalized to remain comparable with local ONNX embeddings.
+- **Surfaced operational config** (PR #4). New `[webhook]`, `[http]`, `[monitor]`, `[reasoner]`, `[feedback]`, `[imports]`, `[repo]`, `[socket]`, `[logging]` config sections expose previously hardcoded limits (tableaux depth/nodes, RDFS/OWL-RL fixpoint iterations, monitor interval, webhook timeout, import depth and remote-follow policy, feedback suppress/downgrade thresholds, etc.). A `0` value in the timeout / iteration fields is a sentinel that falls back to the documented default.
+- New tests: `tests/registry_test.rs`, `tests/cache_management_test.rs`, `tests/toolfilter_test.rs`, `tests/repo_test.rs`, plus inline tests for embeddings config parsing and runtime knob initialization.
+
+### Documentation
+- New `docs/cache-and-registry.md` covering the compile cache, TTL eviction, tool-exposure filter, and ontology repository directories.
+- `docs/embeddings.md` expanded with the OpenAI-compatible provider, supported gateways, config block, and env-var precedence.
+- `CLAUDE.md` and `SKILL.md` Tool Reference tables updated with the seven new tools.
+
## [0.1.12] - 2026-03-27
### Added
diff --git a/CLAUDE.md b/CLAUDE.md
index f12b3a69..6d2021e9 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -88,9 +88,16 @@ Claude dynamically decides the next tool call based on what the previous tool re
| `onto_enforce_feedback` | To accept/dismiss an enforce violation — teaches enforce to suppress repeatedly dismissed violations |
| `onto_dl_explain` | To explain why a class is unsatisfiable using DL tableaux reasoning — returns clash trace |
| `onto_dl_check` | To check if one class is subsumed by another using DL tableaux reasoning |
-| `onto_embed` | After loading an ontology — generates text + Poincaré structural embeddings for all classes |
+| `onto_embed` | After loading an ontology — generates text + Poincaré structural embeddings for all classes. Honours `[embeddings] provider = "local" \| "openai"` in `config.toml`; OpenAI-compatible gateways (Azure, Ollama, vLLM, LocalAI, …) are supported via `OPEN_ONTOLOGIES_EMBEDDINGS_*` env vars |
| `onto_search` | To find classes by natural language description — requires onto_embed first |
| `onto_similarity` | To compute embedding similarity between two specific IRIs |
+| `onto_unload` | To unload the active ontology from memory. Optional `name` targets a specific cached entry; `delete_cache=true` also removes the on-disk N-Triples cache file |
+| `onto_recompile` | To re-parse the source file and rebuild the cache. Optional `name` rebuilds a non-active cached entry without disturbing the in-memory store (safe background refresh) |
+| `onto_cache_status` | To inspect the compile cache: active slot, all cached entries, and effective `[cache]` config (TTL, auto_refresh, dir) |
+| `onto_cache_list` | To list cached ontologies with metadata (`is_active`, `in_memory`, mtime, size) — lighter than `onto_cache_status` |
+| `onto_cache_remove` | To remove a cached ontology by `name`. Pass `delete_file=false` to keep the on-disk N-Triples |
+| `onto_repo_list` | To enumerate RDF/OWL files in directories configured under `[general] ontology_dirs`. Use in containerized deployments to discover ontologies without hardcoding paths |
+| `onto_repo_load` | To load an ontology from a configured `ontology_dirs` repo by bare name, relative path, or absolute path. Reuses the same compile-cache / TTL-eviction path as `onto_load` |
## Ontology Lifecycle
diff --git a/README.md b/README.md
index cf89ac07..600f46d4 100644
--- a/README.md
+++ b/README.md
@@ -639,6 +639,7 @@ The same tool, applied to any ontology, produces the same kind of improvement. T
| --- | --- | --- |
| **Core** | `validate` `load` `save` `clear` `stats` `query` `diff` `lint` `convert` `status` | RDF/OWL validation, querying, and management |
| **Repository** | `repo_list` `repo_load` | Browse and load ontologies from configured `[general] ontology_dirs` directories |
+| **Cache** | `cache_status` `cache_list` `cache_remove` `unload` `recompile` | On-disk N-Triples compile cache, idle-TTL eviction, per-name management ([details](docs/cache-and-registry.md)) |
| **Marketplace** | `marketplace` | Browse and install 32 standard W3C/ISO/industry ontologies |
| **Remote** | `pull` `push` `import` | Fetch/push ontologies, resolve owl:imports |
| **Schema** | `import-schema` | PostgreSQL → OWL conversion |
diff --git a/SKILL.md b/SKILL.md
index 785d1049..715cd1d6 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -177,6 +177,13 @@ For aligning two ontologies:
| `onto_lineage` | View session lineage trail (plan, enforce, apply, monitor, drift) |
| `onto_lint_feedback` | Accept/dismiss lint issues to teach suppression |
| `onto_enforce_feedback` | Accept/dismiss enforce violations to teach suppression |
+| `onto_unload` | Unload from memory. With `name` targets a specific cached entry; `delete_cache=true` also removes the on-disk file |
+| `onto_recompile` | Re-parse the source. With `name` rebuilds a non-active cached entry without disturbing the active in-memory store |
+| `onto_cache_status` | Inspect compile cache: active slot, all entries, effective `[cache]` config |
+| `onto_cache_list` | List cached ontologies with metadata (`is_active`, `in_memory`, mtime, size) |
+| `onto_cache_remove` | Remove a cached ontology by `name` (pass `delete_file=false` to keep the on-disk N-Triples) |
+| `onto_repo_list` | List RDF/OWL files in configured `[general] ontology_dirs` directories |
+| `onto_repo_load` | Load an ontology from a configured repo by bare name, relative path, or absolute path |
## Usage Examples
diff --git a/docs/embeddings.md b/docs/embeddings.md
index a265f938..f8bf35ce 100644
--- a/docs/embeddings.md
+++ b/docs/embeddings.md
@@ -27,3 +27,54 @@ The embedding model (~33MB) is downloaded on `open-ontologies init`. All inferen
| `text` | Cosine similarity on text embeddings only |
| `structure` | Poincare distance on structural embeddings only |
| `product` | Weighted combination of both (default, alpha=0.5) |
+
+## Providers
+
+The text-embedding side is pluggable via `[embeddings] provider`:
+
+| Provider | When to use |
+| -------- | ----------- |
+| `local` (default) | Offline / air-gapped; no API keys; bge-small-en-v1.5 ONNX runs in-process via tract |
+| `openai` | Any OpenAI-compatible HTTP gateway: official OpenAI, Azure OpenAI, Ollama, vLLM, LocalAI, LM Studio, Together, Mistral, etc. |
+
+### Configuring the OpenAI-compatible provider
+
+```toml
+[embeddings]
+provider = "openai"
+api_base = "https://api.openai.com/v1" # alias: base_url
+api_key = "sk-..." # optional — env vars take precedence
+model = "text-embedding-3-small" # any model your gateway serves
+dimensions = 1536 # optional — only sent when set
+request_timeout_secs = 30
+```
+
+Trailing slashes on `api_base` are stripped automatically. The gateway must accept `POST {api_base}/embeddings` with the OpenAI request shape.
+
+### Environment variables (override config)
+
+| Variable | Purpose | Precedence |
+| -------- | ------- | ---------- |
+| `OPEN_ONTOLOGIES_EMBEDDINGS_PROVIDER` | Force `local` or `openai` | Highest |
+| `OPEN_ONTOLOGIES_EMBEDDINGS_API_BASE` | Override gateway URL | Highest |
+| `OPEN_ONTOLOGIES_EMBEDDINGS_API_KEY` | Override bearer token | Highest |
+| `OPENAI_API_KEY` | Bearer token fallback when the dedicated var is unset | Higher than config |
+| `OPEN_ONTOLOGIES_EMBEDDINGS_MODEL` | Override model name | Highest |
+
+Auth is optional — many local gateways (Ollama, LocalAI) accept unauthenticated requests, so the resolver returns `None` rather than failing when no key is configured.
+
+### Example: Ollama (local OpenAI-compatible gateway)
+
+```toml
+[embeddings]
+provider = "openai"
+api_base = "http://localhost:11434/v1"
+model = "nomic-embed-text"
+# api_key is unnecessary for local Ollama
+```
+
+### Notes
+
+- API responses are L2-normalized in-process so cosine scores remain comparable with the local ONNX path.
+- The local and remote paths share the same downstream `onto_embed` / `onto_search` / `onto_similarity` tools — switching providers requires no code changes.
+- See `[embeddings]` block in the default config emitted by `open-ontologies init` (`src/main.rs::DEFAULT_CONFIG`) for the full set of fields with comments.
diff --git a/src/config.rs b/src/config.rs
index 65abeb6c..158dacf6 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -657,4 +657,55 @@ mod tests {
assert_eq!(cfg.logging.format, "compact");
assert_eq!(cfg.cache.hash_prefix_bytes, 64 * 1024);
}
+
+ #[test]
+ fn resolvers_pass_through_config_when_env_unset() {
+ // Regression: `resolve_*` functions must return the config-supplied
+ // value when no env override is set. This exercises the precedence
+ // path documented in PR #4 (env > config > default) without mutating
+ // process-wide env vars (which would race with parallel tests).
+ // We rely on these env vars being unset in CI; if a future test
+ // sets them, this assertion will surface that interference.
+ for var in [
+ "OPEN_ONTOLOGIES_WEBHOOK_REQUEST_TIMEOUT_SECS",
+ "OPEN_ONTOLOGIES_IMPORTS_REQUEST_TIMEOUT_SECS",
+ "OPEN_ONTOLOGIES_MONITOR_INTERVAL_SECS",
+ ] {
+ if std::env::var(var).is_ok() {
+ eprintln!("skipping resolver passthrough test: {var} is set");
+ return;
+ }
+ }
+
+ let webhook = WebhookConfig { request_timeout_secs: 7 };
+ assert_eq!(resolve_webhook_timeout_secs(&webhook), 7);
+
+ let imports = ImportsConfig {
+ max_depth: 5,
+ request_timeout_secs: 42,
+ follow_remote: true,
+ };
+ assert_eq!(resolve_imports_timeout_secs(&imports), 42);
+
+ let monitor = MonitorConfig { enabled: true, interval_secs: 11 };
+ assert_eq!(resolve_monitor_interval_secs(&monitor), 11);
+ }
+
+ #[test]
+ fn resolve_imports_timeout_preserves_zero_sentinel() {
+ // The `0` sentinel for `[imports] request_timeout_secs` is documented
+ // (commit cdd5384) as "disable the explicit per-call timeout and use
+ // reqwest's default". The resolver must propagate the 0 verbatim so
+ // downstream callers can decide whether to skip `.timeout()`.
+ if std::env::var("OPEN_ONTOLOGIES_IMPORTS_REQUEST_TIMEOUT_SECS").is_ok() {
+ eprintln!("skipping zero-sentinel test: env override is set");
+ return;
+ }
+ let imports = ImportsConfig {
+ max_depth: 3,
+ request_timeout_secs: 0,
+ follow_remote: true,
+ };
+ assert_eq!(resolve_imports_timeout_secs(&imports), 0);
+ }
}