TEST-INFRA: [coverage-gaps] Add test coverage for src/cleveragents/application/services/uko_loader.py #1751

Open
opened 2026-04-02 23:41:48 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: test/coverage-gaps-uko-loader
  • Commit Message: test(uko_loader): add Behave BDD scenarios for application/services/uko_loader.py
  • Milestone: v3.8.0
  • Parent Epic: #933

Description

Project: cleveragents-core
Area: Test Infrastructure
File: src/cleveragents/application/services/uko_loader.py
Current Coverage: 0%

The file src/cleveragents/application/services/uko_loader.py currently has 0% test coverage (0/332 executable lines covered). This is the lightweight TTL parser that loads UKO ontology files into UKOOntology Pydantic models — a critical component of the ACMS (Advanced Context Management System) pipeline.

While a features/uko_loader_coverage_boost.feature file exists, it is not being picked up by the coverage pipeline, resulting in zero coverage for this module. This lack of testing introduces a risk of undiscovered regressions in the UKO ontology loading path and makes it unsafe to refactor or extend the loader.

The UKOLoader class provides the following functionality that must be covered:

  • load(ttl_path) — reads a TTL file from disk and delegates to load_from_string
  • load_from_string(text) — full parse pipeline: prefixes → blocks → nodes → ontology → validation
  • validate(ontology) — validates node types, parent URI references, prefix resolution, and version support
  • resolve_inheritance(ontology, node_uri) — BFS traversal of the rdfs:subClassOf DAG
  • get_layer_nodes(ontology, layer) — filters nodes by UKO layer (0–3)
  • _detect_cycle_dfs(uri_map, start_uri) — iterative DFS cycle detection with gray/black colouring
  • _parse_prefixes(text)@prefix line parsing
  • _split_blocks(text) — TTL statement splitting (handles <>, "", . terminators)
  • _parse_predicates(predicates_str)predicate object ; pair parsing
  • _split_on_semicolon(text) — semicolon splitting outside <> and ""
  • _resolve_uri(prefixed, prefix_map) — prefix expansion to full IRI
  • _extract_version_string(version_iri) — semver extraction from version IRI

All execution paths — including error paths (UKOValidationError), edge cases (empty TTL, unknown prefixes, cycles, multi-parent inheritance, diamond inheritance), and the full four-layer UKO namespace detection — must be exercised.

Subtasks

  • Audit the existing features/uko_loader_coverage_boost.feature and features/steps/uko_loader_coverage_boost_steps.py to determine why they are not contributing to coverage
  • Fix or replace the existing feature/steps so they are correctly discovered and executed by the coverage pipeline
  • Write additional BDD scenarios in Gherkin to cover all remaining uncovered lines (332 lines at 0%)
  • Cover load() (file-based entry point), load_from_string() happy path and error paths
  • Cover validate() — all error branches: missing rdf:type, non-existent internal parent, undefined prefix in parent, undefined prefix in node URI, unsupported version
  • Cover resolve_inheritance() — BFS traversal, diamond inheritance deduplication, cycle detection via _detect_cycle_dfs()
  • Cover get_layer_nodes() — all four layers (0–3)
  • Cover _split_blocks() — IRI/string escape handling, statement terminator edge cases
  • Cover _parse_predicates() — IRI-valued predicates, plain-value predicates
  • Cover _resolve_uri() — angle-bracket IRI, prefixed name, unknown prefix passthrough
  • Cover _extract_version_string() — valid semver, non-semver segment, empty IRI
  • Add Robot Framework integration tests in robot/ for the UKO loader service
  • Add ASV performance benchmark in benchmarks/ for UKOLoader.load_from_string()
  • Verify nox -s unit_tests passes
  • Verify nox -s integration_tests passes
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

  • All subtasks above are completed and checked off.
  • The test coverage for src/cleveragents/application/services/uko_loader.py is at least 97%.
  • All existing and new tests pass successfully.
  • All new Behave tests are written in Gherkin syntax under features/.
  • All new Robot tests are placed under robot/.
  • All new ASV benchmarks are placed under benchmarks/.
  • No pytest-style or xUnit-style tests introduced.
  • All mocks placed exclusively in features/mocks/ — no mock code in production source.
  • All code is statically typed and passes nox -e typecheck.
  • All nox stages pass.
  • Coverage >= 97%.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: Unknown | Agent: ca-new-issue-creator

## Metadata - **Branch**: `test/coverage-gaps-uko-loader` - **Commit Message**: `test(uko_loader): add Behave BDD scenarios for application/services/uko_loader.py` - **Milestone**: v3.8.0 - **Parent Epic**: #933 ## Description **Project:** cleveragents-core **Area:** Test Infrastructure **File:** `src/cleveragents/application/services/uko_loader.py` **Current Coverage:** 0% The file `src/cleveragents/application/services/uko_loader.py` currently has **0% test coverage** (0/332 executable lines covered). This is the lightweight TTL parser that loads UKO ontology files into `UKOOntology` Pydantic models — a critical component of the ACMS (Advanced Context Management System) pipeline. While a `features/uko_loader_coverage_boost.feature` file exists, it is not being picked up by the coverage pipeline, resulting in zero coverage for this module. This lack of testing introduces a risk of undiscovered regressions in the UKO ontology loading path and makes it unsafe to refactor or extend the loader. The `UKOLoader` class provides the following functionality that must be covered: - `load(ttl_path)` — reads a TTL file from disk and delegates to `load_from_string` - `load_from_string(text)` — full parse pipeline: prefixes → blocks → nodes → ontology → validation - `validate(ontology)` — validates node types, parent URI references, prefix resolution, and version support - `resolve_inheritance(ontology, node_uri)` — BFS traversal of the `rdfs:subClassOf` DAG - `get_layer_nodes(ontology, layer)` — filters nodes by UKO layer (0–3) - `_detect_cycle_dfs(uri_map, start_uri)` — iterative DFS cycle detection with gray/black colouring - `_parse_prefixes(text)` — `@prefix` line parsing - `_split_blocks(text)` — TTL statement splitting (handles `<>`, `""`, `.` terminators) - `_parse_predicates(predicates_str)` — `predicate object ;` pair parsing - `_split_on_semicolon(text)` — semicolon splitting outside `<>` and `""` - `_resolve_uri(prefixed, prefix_map)` — prefix expansion to full IRI - `_extract_version_string(version_iri)` — semver extraction from version IRI All execution paths — including error paths (`UKOValidationError`), edge cases (empty TTL, unknown prefixes, cycles, multi-parent inheritance, diamond inheritance), and the full four-layer UKO namespace detection — must be exercised. ## Subtasks - [ ] Audit the existing `features/uko_loader_coverage_boost.feature` and `features/steps/uko_loader_coverage_boost_steps.py` to determine why they are not contributing to coverage - [ ] Fix or replace the existing feature/steps so they are correctly discovered and executed by the coverage pipeline - [ ] Write additional BDD scenarios in Gherkin to cover all remaining uncovered lines (332 lines at 0%) - [ ] Cover `load()` (file-based entry point), `load_from_string()` happy path and error paths - [ ] Cover `validate()` — all error branches: missing rdf:type, non-existent internal parent, undefined prefix in parent, undefined prefix in node URI, unsupported version - [ ] Cover `resolve_inheritance()` — BFS traversal, diamond inheritance deduplication, cycle detection via `_detect_cycle_dfs()` - [ ] Cover `get_layer_nodes()` — all four layers (0–3) - [ ] Cover `_split_blocks()` — IRI/string escape handling, statement terminator edge cases - [ ] Cover `_parse_predicates()` — IRI-valued predicates, plain-value predicates - [ ] Cover `_resolve_uri()` — angle-bracket IRI, prefixed name, unknown prefix passthrough - [ ] Cover `_extract_version_string()` — valid semver, non-semver segment, empty IRI - [ ] Add Robot Framework integration tests in `robot/` for the UKO loader service - [ ] Add ASV performance benchmark in `benchmarks/` for `UKOLoader.load_from_string()` - [ ] Verify `nox -s unit_tests` passes - [ ] Verify `nox -s integration_tests` passes - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done - [ ] All subtasks above are completed and checked off. - [ ] The test coverage for `src/cleveragents/application/services/uko_loader.py` is at least 97%. - [ ] All existing and new tests pass successfully. - [ ] All new Behave tests are written in Gherkin syntax under `features/`. - [ ] All new Robot tests are placed under `robot/`. - [ ] All new ASV benchmarks are placed under `benchmarks/`. - [ ] No pytest-style or xUnit-style tests introduced. - [ ] All mocks placed exclusively in `features/mocks/` — no mock code in production source. - [ ] All code is statically typed and passes `nox -e typecheck`. - [ ] All nox stages pass. - [ ] Coverage >= 97%. - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Supervisor: Unknown | Agent: ca-new-issue-creator
freemo added this to the v3.8.0 milestone 2026-04-02 23:44:26 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#1751
No description provided.