|
|
|
@@ -0,0 +1,366 @@
|
|
|
|
|
# UKO Vocabulary Extensions (Layer 2 & Layer 3)
|
|
|
|
|
|
|
|
|
|
**Package:** `cleveragents.acms.uko`
|
|
|
|
|
**Introduced:** v3.6.0 (UKO Runtime), extended in v3.8.0
|
|
|
|
|
|
|
|
|
|
This module guide covers the Layer 2 paradigm vocabularies and Layer 3
|
|
|
|
|
technology-specific vocabulary extensions of the Universal Knowledge Ontology
|
|
|
|
|
(UKO) runtime. These extensions refine the base Layer 0/1 ontology with
|
|
|
|
|
programming-paradigm and language-specific semantic concepts.
|
|
|
|
|
|
|
|
|
|
For the full UKO runtime API reference, see
|
|
|
|
|
[`docs/reference/uko_runtime.md`](../reference/uko_runtime.md).
|
|
|
|
|
For the Layer 2 vocabulary reference, see
|
|
|
|
|
[`docs/reference/uko_layer2_paradigm_vocabularies.md`](../reference/uko_layer2_paradigm_vocabularies.md).
|
|
|
|
|
For the Layer 3 vocabulary reference, see
|
|
|
|
|
[`docs/reference/uko_layer3_technology_vocabularies.md`](../reference/uko_layer3_technology_vocabularies.md).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Architecture Overview
|
|
|
|
|
|
|
|
|
|
The UKO vocabulary system is organized into four layers:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Layer 0 (uko:) — Universal foundation: Container, Atom, Boundary, dependsOn
|
|
|
|
|
Layer 1 (uko-code:) — Code domain: TypeDefinition, Callable, Module, File
|
|
|
|
|
Layer 2 (uko-oo/func/proc:) — Paradigm specializations
|
|
|
|
|
Layer 3 (uko-py/ts/rs/java:) — Language-specific refinements
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Each layer inherits from the layer above it via `rdfs:subClassOf` and
|
|
|
|
|
`rdfs:subPropertyOf` relationships. The `DetailLevelMap` inheritance chain
|
|
|
|
|
allows child layers to insert new named detail levels without breaking parent
|
|
|
|
|
level semantics.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Layer 2: Paradigm Vocabularies
|
|
|
|
|
|
|
|
|
|
Layer 2 provides three paradigm-specific vocabulary namespaces.
|
|
|
|
|
|
|
|
|
|
### Object-Oriented (`uko-oo:`)
|
|
|
|
|
|
|
|
|
|
**Namespace:** `https://cleveragents.ai/ontology/uko/oo#`
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.vocabularies import get_oo_vocabulary
|
|
|
|
|
|
|
|
|
|
vocab = get_oo_vocabulary()
|
|
|
|
|
oo_class = vocab.get_class("Class")
|
|
|
|
|
oo_method = vocab.get_class("Method")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Key classes:**
|
|
|
|
|
|
|
|
|
|
| Class | Superclass | Description |
|
|
|
|
|
|-------|-----------|-------------|
|
|
|
|
|
| `uko-oo:Class` | `uko-code:TypeDefinition`, `uko:Container` | OO class containing methods and attributes |
|
|
|
|
|
| `uko-oo:Interface` | `uko-code:TypeDefinition`, `uko:Boundary` | Interface or abstract base class |
|
|
|
|
|
| `uko-oo:Method` | `uko-code:Callable` | Method defined within a class |
|
|
|
|
|
| `uko-oo:Attribute` | `uko:Atom` | Class or instance attribute |
|
|
|
|
|
|
|
|
|
|
**Key properties:**
|
|
|
|
|
|
|
|
|
|
| Property | Domain | Range | Description |
|
|
|
|
|
|----------|--------|-------|-------------|
|
|
|
|
|
| `uko-oo:inheritsFrom` | `uko-oo:Class` | `uko-oo:Class` | Inheritance relationship |
|
|
|
|
|
| `uko-oo:implements` | `uko-oo:Class` | `uko-oo:Interface` | Interface implementation |
|
|
|
|
|
|
|
|
|
|
**DetailLevelMap insertions** (added on top of `uko-code:` base map):
|
|
|
|
|
|
|
|
|
|
| Depth | Name | Description |
|
|
|
|
|
|-------|------|-------------|
|
|
|
|
|
| 3 | `CLASS_HIERARCHY` | Inheritance chains and interface implementations |
|
|
|
|
|
| 7 | `VISIBILITY_ANNOTATED` | Public/protected/private modifiers |
|
|
|
|
|
|
|
|
|
|
### Functional (`uko-func:`)
|
|
|
|
|
|
|
|
|
|
**Namespace:** `https://cleveragents.ai/ontology/uko/func#`
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.vocabularies import get_func_vocabulary
|
|
|
|
|
|
|
|
|
|
vocab = get_func_vocabulary()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Key classes:**
|
|
|
|
|
|
|
|
|
|
| Class | Superclass | Description |
|
|
|
|
|
|-------|-----------|-------------|
|
|
|
|
|
| `uko-func:PureFunction` | `uko-code:Callable` | Pure function with no side effects |
|
|
|
|
|
| `uko-func:TypeClass` | `uko-code:TypeDefinition`, `uko:Boundary` | Type class defining operations for types |
|
|
|
|
|
| `uko-func:Monad` | `uko-code:TypeDefinition` | Monadic type encapsulating computation context |
|
|
|
|
|
|
|
|
|
|
### Procedural (`uko-proc:`)
|
|
|
|
|
|
|
|
|
|
**Namespace:** `https://cleveragents.ai/ontology/uko/proc#`
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.vocabularies import get_proc_vocabulary
|
|
|
|
|
|
|
|
|
|
vocab = get_proc_vocabulary()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Key classes:**
|
|
|
|
|
|
|
|
|
|
| Class | Superclass | Description |
|
|
|
|
|
|-------|-----------|-------------|
|
|
|
|
|
| `uko-proc:ProceduralFunction` | `uko-code:Callable` | Procedural function declaration |
|
|
|
|
|
| `uko-proc:GlobalVariable` | `uko:Atom` | Global variable declaration |
|
|
|
|
|
| `uko-proc:HeaderFile` | `uko:Container` | Header file defining exported declarations |
|
|
|
|
|
| `uko-proc:StructDefinition` | `uko-code:TypeDefinition` | C-style struct type definition |
|
|
|
|
|
| `uko-proc:Macro` | `uko:Atom` | Preprocessor macro definition |
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Layer 3: Technology Vocabularies
|
|
|
|
|
|
|
|
|
|
Layer 3 provides language-specific vocabulary extensions that further
|
|
|
|
|
specialize Layer 2 paradigm concepts.
|
|
|
|
|
|
|
|
|
|
### Python (`uko-py:`)
|
|
|
|
|
|
|
|
|
|
**Namespace:** `https://cleveragents.ai/ontology/uko/py#`
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.layer3_py import (
|
|
|
|
|
PYTHON_VOCABULARY,
|
|
|
|
|
PYTHON_DETAIL_LEVELS,
|
|
|
|
|
PythonClass,
|
|
|
|
|
PythonFunction,
|
|
|
|
|
PythonModule,
|
|
|
|
|
PythonDecorator,
|
|
|
|
|
PythonTypeStub,
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Key classes:**
|
|
|
|
|
|
|
|
|
|
| Class | Superclass | Description |
|
|
|
|
|
|-------|-----------|-------------|
|
|
|
|
|
| `uko-py:PythonClass` | `uko-oo:Class` | Python class (supports multiple inheritance) |
|
|
|
|
|
| `uko-py:PythonFunction` | `uko-func:PureFunction` | Python function or method |
|
|
|
|
|
| `uko-py:PythonModule` | `uko-code:Module` | Python module (`.py` file) |
|
|
|
|
|
| `uko-py:PythonDecorator` | `uko:Atom` | Python decorator applied to a class or function |
|
|
|
|
|
| `uko-py:PythonTypeStub` | `uko:Atom` | Type stub (`.pyi` file) |
|
|
|
|
|
|
|
|
|
|
**Usage example:**
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.layer3_py import PYTHON_VOCABULARY, PYTHON_DETAIL_LEVELS
|
|
|
|
|
|
|
|
|
|
# Resolve a named detail level for Python
|
|
|
|
|
depth = PYTHON_DETAIL_LEVELS.resolve("CLASS_HIERARCHY")
|
|
|
|
|
# → integer depth in the effective map
|
|
|
|
|
|
|
|
|
|
# Get the Python vocabulary
|
|
|
|
|
py_class = PYTHON_VOCABULARY.get_class("PythonClass")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### TypeScript (`uko-ts:`)
|
|
|
|
|
|
|
|
|
|
**Namespace:** `https://cleveragents.ai/ontology/uko/ts#`
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.layer3_ts import (
|
|
|
|
|
TYPESCRIPT_VOCABULARY,
|
|
|
|
|
TYPESCRIPT_DETAIL_LEVELS,
|
|
|
|
|
TypeScriptClass,
|
|
|
|
|
TypeScriptFunction,
|
|
|
|
|
TypeScriptInterface,
|
|
|
|
|
TypeScriptModule,
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Key classes:**
|
|
|
|
|
|
|
|
|
|
| Class | Superclass | Description |
|
|
|
|
|
|-------|-----------|-------------|
|
|
|
|
|
| `uko-ts:TypeScriptClass` | `uko-oo:Class` | TypeScript class |
|
|
|
|
|
| `uko-ts:TypeScriptFunction` | `uko-func:PureFunction` | TypeScript function |
|
|
|
|
|
| `uko-ts:TypeScriptInterface` | `uko-oo:Interface` | TypeScript interface |
|
|
|
|
|
| `uko-ts:TypeScriptModule` | `uko-code:Module` | TypeScript module (`.ts` / `.tsx` file) |
|
|
|
|
|
|
|
|
|
|
### Rust (`uko-rs:`)
|
|
|
|
|
|
|
|
|
|
**Namespace:** `https://cleveragents.ai/ontology/uko/rs#`
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.layer3_rs import (
|
|
|
|
|
RUST_VOCABULARY,
|
|
|
|
|
RUST_DETAIL_LEVELS,
|
|
|
|
|
RustStruct,
|
|
|
|
|
RustTrait,
|
|
|
|
|
RustImpl,
|
|
|
|
|
RustFunction,
|
|
|
|
|
RustDeriveAttribute,
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Key classes:**
|
|
|
|
|
|
|
|
|
|
| Class | Superclass | Description |
|
|
|
|
|
|-------|-----------|-------------|
|
|
|
|
|
| `uko-rs:RustStruct` | `uko-proc:StructDefinition` | Rust struct |
|
|
|
|
|
| `uko-rs:RustTrait` | `uko-oo:Interface` | Rust trait |
|
|
|
|
|
| `uko-rs:RustImpl` | `uko:Container` | Rust `impl` block |
|
|
|
|
|
| `uko-rs:RustFunction` | `uko-func:PureFunction` | Rust function |
|
|
|
|
|
| `uko-rs:RustDeriveAttribute` | `uko:Atom` | Rust `#[derive(...)]` attribute |
|
|
|
|
|
|
|
|
|
|
### Java (`uko-java:`)
|
|
|
|
|
|
|
|
|
|
**Namespace:** `https://cleveragents.ai/ontology/uko/java#`
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.layer3_java import (
|
|
|
|
|
JAVA_VOCABULARY,
|
|
|
|
|
JAVA_DETAIL_LEVELS,
|
|
|
|
|
JavaClass,
|
|
|
|
|
JavaInterface,
|
|
|
|
|
JavaMethod,
|
|
|
|
|
JavaAnnotation,
|
|
|
|
|
JavaCheckedException,
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Key classes:**
|
|
|
|
|
|
|
|
|
|
| Class | Superclass | Description |
|
|
|
|
|
|-------|-----------|-------------|
|
|
|
|
|
| `uko-java:JavaClass` | `uko-oo:Class` | Java class |
|
|
|
|
|
| `uko-java:JavaInterface` | `uko-oo:Interface` | Java interface |
|
|
|
|
|
| `uko-java:JavaMethod` | `uko-oo:Method` | Java method |
|
|
|
|
|
| `uko-java:JavaAnnotation` | `uko:Atom` | Java annotation (`@Annotation`) |
|
|
|
|
|
| `uko-java:JavaCheckedException` | `uko:Atom` | Java checked exception declaration |
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## DetailLevelMap Inheritance
|
|
|
|
|
|
|
|
|
|
The `DetailLevelMap` inheritance chain resolves named levels by walking up
|
|
|
|
|
the map hierarchy from most-specific to least-specific:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Layer 3 (uko-py:) → Layer 2 (uko-oo:) → Layer 1 (uko-code:) → Layer 0 (uko:)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Building a Custom Map
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.detail_level_maps import (
|
|
|
|
|
CODE_DETAIL_LEVEL_MAP,
|
|
|
|
|
OO_DETAIL_LEVEL_MAP,
|
|
|
|
|
DetailLevelMapBuilder,
|
|
|
|
|
build_effective_map,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Build a custom map that extends OO with a new level
|
|
|
|
|
builder = DetailLevelMapBuilder(OO_DETAIL_LEVEL_MAP, "my-lang:")
|
|
|
|
|
builder.insert_after("CLASS_HIERARCHY", "MIXIN_RESOLUTION")
|
|
|
|
|
my_map = builder.build()
|
|
|
|
|
|
|
|
|
|
# Resolve a named level
|
|
|
|
|
depth = my_map.resolve("MIXIN_RESOLUTION")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `build_effective_map(maps)`
|
|
|
|
|
|
|
|
|
|
Merges multiple `DetailLevelMap` objects into a single effective map,
|
|
|
|
|
resolving conflicts by preferring the most-specific (last) map:
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.detail_level_maps import build_effective_map
|
|
|
|
|
|
|
|
|
|
effective = build_effective_map([
|
|
|
|
|
CODE_DETAIL_LEVEL_MAP,
|
|
|
|
|
OO_DETAIL_LEVEL_MAP,
|
|
|
|
|
PYTHON_DETAIL_LEVELS,
|
|
|
|
|
])
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## VocabularyRegistry
|
|
|
|
|
|
|
|
|
|
The `VocabularyRegistry` provides a unified lookup across all registered
|
|
|
|
|
paradigm vocabularies:
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.vocabulary_registry import VocabularyRegistry, DuplicateVocabularyError
|
|
|
|
|
from cleveragents.acms.uko.vocabularies import (
|
|
|
|
|
get_oo_vocabulary,
|
|
|
|
|
get_func_vocabulary,
|
|
|
|
|
get_proc_vocabulary,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
registry = VocabularyRegistry(
|
|
|
|
|
vocabularies=(
|
|
|
|
|
get_oo_vocabulary(),
|
|
|
|
|
get_func_vocabulary(),
|
|
|
|
|
get_proc_vocabulary(),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Look up a vocabulary by namespace prefix
|
|
|
|
|
oo = registry.get_by_prefix("uko-oo:")
|
|
|
|
|
assert oo is not None
|
|
|
|
|
|
|
|
|
|
# Look up a class across all vocabularies
|
|
|
|
|
cls = registry.find_class("uko-oo:Class")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**`DuplicateVocabularyError`** is raised when two vocabularies share the
|
|
|
|
|
same namespace prefix.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Base Vocabulary Types
|
|
|
|
|
|
|
|
|
|
These types are shared across all layers and are the building blocks for
|
|
|
|
|
vocabulary definitions:
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from cleveragents.acms.uko.vocabulary import (
|
|
|
|
|
UKOVocabulary,
|
|
|
|
|
UKOClass,
|
|
|
|
|
UKOProperty,
|
|
|
|
|
Layer2Dependency,
|
|
|
|
|
ProvenanceInfo,
|
|
|
|
|
build_detail_level_map,
|
|
|
|
|
resolve_detail_level,
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
| Type | Description |
|
|
|
|
|
|------|-------------|
|
|
|
|
|
| `UKOVocabulary` | Container for a set of OWL classes and properties |
|
|
|
|
|
| `UKOClass` | OWL class definition with superclasses and description |
|
|
|
|
|
| `UKOProperty` | OWL property definition with domain, range, and superproperty |
|
|
|
|
|
| `Layer2Dependency` | Declares a dependency on a Layer 2 vocabulary URI |
|
|
|
|
|
| `ProvenanceInfo` | Provenance metadata for vocabulary definitions |
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Gotchas
|
|
|
|
|
|
|
|
|
|
- **Layer 1 (`uko-code:`) Python module is not yet implemented.** The Python
|
|
|
|
|
code works standalone using the `DetailLevelMap` from `crp.py`, but full
|
|
|
|
|
OWL reasoning against Layer 1 URIs is not available.
|
|
|
|
|
- **Turtle files are validated by `UKOLoader` but not by a full OWL reasoner.**
|
|
|
|
|
Structural validation is performed; semantic entailment is not.
|
|
|
|
|
- **Procedural vocabulary classes are inferred from spec rendering tables.**
|
|
|
|
|
Explicit Turtle definitions for `uko-proc:` are pending.
|
|
|
|
|
- **`DuplicateVocabularyError` is raised eagerly at registry construction.**
|
|
|
|
|
Ensure each vocabulary has a unique namespace prefix before registering.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Related Documentation
|
|
|
|
|
|
|
|
|
|
- [UKO Runtime Services](../reference/uko_runtime.md) — full API reference
|
|
|
|
|
- [UKO Ontology](../reference/uko.md) — four-layer ontology and provenance property definitions
|
|
|
|
|
- [UKO Layer 2 Paradigm Vocabularies](../reference/uko_layer2_paradigm_vocabularies.md) — detailed class/property tables
|
|
|
|
|
- [UKO Layer 3 Technology Vocabularies](../reference/uko_layer3_technology_vocabularies.md) — language-specific vocabulary details
|
|
|
|
|
- [UKO Provenance Tracking](uko-provenance.md) — provenance metadata and temporal versioning
|
|
|
|
|
- [ACMS](../reference/acms.md) — how UKO feeds into context assembly
|