feat(uko): add UKO ontology scaffolding #466
No reviewers
Labels
No labels
auto/needs-reevaluation
controller-managed
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveragents-core!466
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/m6-acms-uko-schema"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
docs/ontology/uko.ttl) with base URI, version IRI, and prefix conventionsUKOLoaderservice for URI parsing, inheritance resolution, and validationUKONode,UKOPrefix,UKOVersion,UKOOntologyfrozen Pydantic v2 modelsrdf:typefor nodesTesting
robot/uko_ontology.robot)benchmarks/uko_load_bench.py)Files Changed
docs/ontology/uko.ttl— RDF/TTL ontology skeletonsrc/cleveragents/domain/models/core/uko.py— UKO Pydantic v2 modelssrc/cleveragents/application/services/uko_loader.py— TTL parser + validator + inheritance resolverfeatures/uko_ontology.feature+features/steps/uko_ontology_steps.py— BDD testsrobot/uko_ontology.robot+robot/helper_uko_ontology.py— Integration testsbenchmarks/uko_load_bench.py— ASV benchmarksdocs/reference/uko.md— Reference documentationCHANGELOG.md— UpdatedCloses #189
Code Review Report
Commit:
8206fad—fix(uko): address review findings for UKO ontology scaffoldingAuthor: khyari hamza (Hamza Khyari)
Branch:
feature/m6-acms-uko-schemaIssue: #189 — feat(uko): add UKO ontology scaffolding
Files changed: 5 files, +96 / -4
Severity Summary
CRITICAL — Specification Mismatches
C-1. Ontology URI Namespace Diverges from Specification
Files:
docs/ontology/uko.ttl,src/cleveragents/application/services/uko_loader.py:42-47The specification (
docs/specification.md, ~line 40785-40800) defines the UKO namespace prefixes as domain-based names:uko:https://cleveragents.ai/ontology/uko#uko-code:https://cleveragents.ai/ontology/uko/code#uko-oo:https://cleveragents.ai/ontology/uko/oo#uko-py:https://cleveragents.ai/ontology/uko/py#The implementation uses a completely different naming convention — numeric layer IDs:
uko0:https://ontology.cleverthis.com/uko/layer0/uko1:https://ontology.cleverthis.com/uko/layer1/uko2:https://ontology.cleverthis.com/uko/layer2/uko3:https://ontology.cleverthis.com/uko/layer3/Both the base domain (
cleveragents.aivsontology.cleverthis.com) and the naming strategy (semantic domain names vs numeric indices) differ. The_LAYER_PREFIXESdict inuko_loader.py:42-47hardcodes the numeric scheme. This will require a complete rewrite when aligning with the specification.C-2. Layer 0 Class Hierarchy Does Not Match Specification
File:
docs/ontology/uko.ttl:17-35The specification defines five Layer 0 base classes following an information-theory model:
uko:InformationUnit(root)uko:Container(subClassOf InformationUnit)uko:Atom(subClassOf InformationUnit)uko:Annotation(subClassOf InformationUnit)uko:Boundary(subClassOf InformationUnit)The implementation defines four classes following an artifact-centric model:
uko0:Resource(root)uko0:Artifact(subClassOf Resource)uko0:CodeArtifact(subClassOf Artifact)uko0:Document(subClassOf Artifact)These are fundamentally different ontologies. The spec's Layer 0 is a general-purpose information classification system, while the implementation's Layer 0 is a software-artifact taxonomy. The test in
features/uko_ontology.feature:167hardcodescount: 4for Layer 0, cementing this divergence.C-3. Layers 1-3 Structure Does Not Match Specification
File:
docs/ontology/uko.ttl:37-80Module,Callable,TypeDefinition), Documents, Data, InfrastructureModule,Function,ClassClass,Interface,Method), Functional, Proceduralimports,defines,inheritsPythonModule,PythonClass,PythonFunctionNotable: the spec places
Classat Layer 2 (OO paradigm) but the implementation puts it at Layer 1. The spec's Layer 2 contains classes (OO specializations), while the implementation's Layer 2 contains only ObjectProperty relationships. The spec usesCallable(Layer 1) andMethod(Layer 2); the implementation usesFunction(Layer 1) which has no spec equivalent at that layer.BUG
B-1. Validation Produces False-Positive "Undefined Prefix" for Resolved HTTP URIs
File:
src/cleveragents/application/services/uko_loader.py:186-201Two problems:
False prefix error on external URIs. If
parent_uripoints to an external ontology class (e.g.,owl:Thingwhich resolves tohttp://www.w3.org/2002/07/owl#Thing), then":" in resolved_parentisTrue(because ofhttp:),prefix_partbecomes"http", and"http" not in known_prefixesisTrue. This produces a spurious "undefined prefix 'http:'" error. While the current TTL avoids this scenario, it violates standard RDF practice where cross-ontology references are common.Duplicate errors. The new existence check at line 197 is not guarded by
elif, so both the prefix error and the non-existent parent error fire for the same node. This clutters the error output with redundant messages for a single root cause.TEST FLAWS
T-1. No Test for
rdfs:domain/rdfs:rangeURI ResolutionImpact: The primary code fix in this commit
The commit message states "Resolve rdfs:domain and rdfs:range values to full URIs in parser" (
uko_loader.py:125-135), yet no Behave scenario or step verifies this behavior. There is no assertion checking thatnode.properties["rdfs:domain"]contains a fully resolved URI rather than a prefixed name. If this resolution logic regresses, no test will catch it.T-2. No Test for Parent-URI Existence Validation
Impact: New validation rule at
uko_loader.py:196-201The commit adds a new validation check that rejects nodes whose
parent_urireferences a non-existent node. But no test scenario exercises this path. The new "Validate rejects ontology with typeless node" test only verifies missingrdf:type, not missing parent references.T-3. Duplicate/Inconsistent Context Attributes in Step Definitions
File:
features/steps/uko_ontology_steps.pyThe commit introduces parallel naming conventions for the same concepts:
context.layer_nodes(line 117)context.uko_layer_nodes(line 123)context.validation_errors(line 129)context.uko_validation_errors(line 163)context.ontology(line 38)context.uko_ontology(line 155)The new step
step_when_get_all_layer_nodes(line 120-123) is functionally identical tostep_when_get_layer(line 114-117) — both callloader.get_layer_nodes()— but store results in different attributes. This creates maintenance confusion and increases the risk of reading the wrong attribute in a future step.T-4. Hardcoded Node Counts Coupled to Non-Spec TTL
File:
features/uko_ontology.feature:165-170These exact counts are tightly coupled to the current TTL file that diverges from the spec (see C-2, C-3). When the TTL is corrected to match the specification (Layer 0 = 5 classes, Layer 1 = many more domain classes), every row in this table will break. The older
there should be at least 4 nodesassertion (line 157) is more resilient to ontology evolution.DESIGN ISSUES
D-1. Validator Assumes Closed-World (All Parents Internal)
File:
uko_loader.py:196-201Standard RDF ontologies commonly reference classes from external vocabularies (
owl:Thing,rdfs:Resource, etc.). The new parent-existence check treats any reference to a class not defined within the same TTL file as an error. This closed-world assumption is incompatible with RDF best practices and will need to be relaxed when the ontology grows to reference standard vocabularies.D-2.
rdfs:subPropertyOfNot HandledFile:
uko_loader.pyThe spec's TTL definitions use
rdfs:subPropertyOffor property inheritance (e.g.,uko-oo:inheritsFrom rdfs:subPropertyOf uko:dependsOn). The parser extractsrdfs:domain,rdfs:range, andrdfs:subClassOfbut ignoresrdfs:subPropertyOf. When the ontology adds property hierarchies per the specification, this will need to be addressed.MINOR / STYLE
M-1. Inconsistent Quoting in Error Messages
File:
uko_loader.py:183-209Older error messages omit quotes around URIs (
f"Node {node.uri} missing rdf:type"), while the new messages added in this commit use quotes (f"Node '{node.uri}' references ..."). This should be consistent across all error strings.M-2. Premature
ISSUES CLOSED: #189Both commits on this branch include
ISSUES CLOSED: #189, but at least two subtasks from the issue's acceptance criteria remain unverified:nox -s coverage_report"nox(all default sessions, including benchmark), fix any errors"The issue should not be auto-closed until these are confirmed passing.
Recommendations
uko_loader.py:188-201— addelifto avoid duplicate errors and exclude fully-resolved HTTP URIs from the prefix check.step_when_get_all_layer_nodes/uko_layer_nodesand reuse the existingstep_when_get_layer/layer_nodespattern.noxand coverage verification are completed per the issue's acceptance criteria.Code Review — Commit
c8df7e5(fix(uko): add missing Layer 0 properties, fix validation and immutability)Reviewed against: Issue #189 acceptance criteria,
docs/specification.md(Section 14 / ACMS Architecture / UKO), and general code quality standards.Scope: test coverage, test flaws, performance, bug detection, security, spec fidelity.
Findings
BUG-1 (Medium): UKO namespace prefix match is overly broad
File:
src/cleveragents/application/services/uko_loader.py:227-245The internal-URI validation check uses a prefix string without a trailing delimiter:
"https://cleveragents.ai/ontology/ukobogus#Something".startswith(_uko_ns)evaluates toTrue. Any URI whose path happens to start with.../uko(e.g., a hypotheticalukobogus:, a typo likeukoo:, or any future external ontology whose IRI shares that prefix) would be incorrectly treated as an internal UKO URI and then rejected as non-existent — a false-positive validation error.Suggested fix — guard with a delimiter check:
BUG-2 (Low):
_extract_version_stringfix has no dedicated testFile:
src/cleveragents/application/services/uko_loader.py:515-527The old code returned the raw last path segment for non-semver IRIs (e.g.,
https://cleveragents.ai/ontology/ukowould return"uko"). The fix now correctly returns"".However, the only new test for version rejection uses version IRI
99.0.0, which is a valid semver string — it just isn't inSUPPORTED_VERSIONS. That test exercises thevalidate()version-check, not the_extract_version_stringcode path. There is no test that sends a version IRI with a non-semver last segment (e.g.,<https://cleveragents.ai/ontology/uko>or<https://example.com/foo/bar>) and verifies the loader rejects it with "Unsupported version" and version"".SPEC-1 (Medium):
rdfs:commentvalues truncated relative to specificationFile:
docs/ontology/uko.ttl:69-87Three content property comments are shortened compared to the specification (
docs/specification.mdlines ~40847-40861):hasRenderingrenderingDepthhasFullContentThe truncated portions carry important semantic constraints (multiplicity, pairing via blank node/reification, equivalence to max-depth rendering) that downstream consumers of the ontology may rely on. The TTL should mirror the specification comments verbatim.
TEST-1 (Medium): No BDD test for
rdfs:domain/rdfs:rangecorrectness of new propertiesFile:
features/uko_ontology.feature:230-257The three new scenarios verify that the 10 new properties exist as nodes with the correct labels. However, none of them verify:
rdfs:domainis correctly resolved touko:InformationUnitfor each property.rdfs:rangeis correctly set (e.g.,xsd:stringforhasRendering,xsd:dateTimeforvalidFrom,xsd:booleanforisCurrent,uko:InformationUnitforisRevisionOf).sourceResource(anowl:ObjectProperty) has nordfs:range— matching the spec.The existing
@uko_domain_rangescenarios only testcontainsandinheritsFrom. A similar pattern should cover the 10 new properties to ensure they match the specification.TEST-2 (Low): No test for duplicate-key handling after
propertiestype changeFile:
src/cleveragents/domain/models/core/uko.py:31,features/steps/uko_ontology_steps.py:355The
propertiesfield was changed fromdict[str, str]totuple[tuple[str, str], ...]. The step code now doesprop_dict = dict(node.properties)which silently drops duplicates (keeps last value). While the current loader code cannot produce duplicates (it populates from adict), a future TTL extension with multi-valued predicates (valid in RDF) could introduce them. A test asserting the expected lookup behavior for duplicate keys would prevent silent data loss.SPEC-2 (Low): Commit message references wrong specification line numbers
The commit body says "per specification lines 41909-41956", but the actual content/provenance/temporal property definitions are at approximately lines 40847-40894 in
docs/specification.md. Minor traceability issue that could confuse future reviewers.PERF-1 (Informational):
get_layer_nodesdoes a linear scan on every callFile:
src/cleveragents/application/services/uko_loader.py:317-323This is O(n) per call. For the current 32-node ontology it is negligible. As the spec envisions projects with 10,000+ indexed files (milestone v3.4.0 success criteria), precomputing a
dict[int, list[UKONode]]index during load would be more efficient. Not a blocker now but worth a# TODOfor the scaling milestone.Positive Notes
dict→tuple[tuple[str,str],...]change forpropertiescorrectly enforces deep immutability on afrozen=Truemodel._extract_version_stringreturning""for non-semver segments prevents confusing error messages.Severity Summary
c8df7e58c641254ccffcThanks for the UKO scaffolding work. I found several blocking issues before this can merge.
Good
docs/ontology/uko.ttl).src/cleveragents/application/services/uko_loader.py).src/cleveragents/domain/models/core/uko.py).Needs attention
alembic/versions/m6_001_checkpoint_metadata_table.py), services (src/cleveragents/application/services/checkpoint_service.py), specs/docs (docs/specification.md), tests (features/*,robot/*), and CI config. Please revert unrelated deletions and keep this PR focused on UKO scaffolding only.docs/specification.mdis massively reduced/edited in this PR without an ADR or clear alignment to the stated architecture. If this is intentional, it requires a dedicated ADR and a separate PR. Otherwise, revert the spec changes.Type/label and noState/,Priority/, orMoSCoW/labels. This PR currently has extra labels (e.g.,State/Verified,Priority/Medium,MoSCoW/Should have). Please fix the labels before merge.Given the P1 items, I’m marking this as request changes. Happy to re-review once the PR is reduced to the UKO changes and the process issues are corrected.
41254ccffc9f685ee9bbApprove.
9f685ee9bbad53a659deNew commits pushed, approval review dismissed automatically according to repository settings