Spec and unit tests for portal/ontology operations#20
Merged
Conversation
LinkedDataHub deprecated `ldh:template` (attached to classes) in favor of `ldh:view` / `ldh:inverseView` attached to properties — see LDH commits b54d8c8b6 (#267) and 1ec5da016. - Iterate distinct properties instead of (class, property) tuples - Attach views via `ldh:view` on the property (forward direction) - Skip `owl:FunctionalProperty` (clean property-level replacement for the old class-scoped `owl:maxQualifiedCardinality 1` check) - Drop class/range from view URI naming; sha1-suffix on local-name collisions Inverse views (`ldh:inverseView`) intentionally deferred. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`GeneratePortal`, `GenerateClassContainers`, and `GenerateOntologyViews` were the only ops under `linkeddatahub/` not registered with the `ldh-` prefix used by their siblings. Add `name()` overrides, update the example and README to match, and document a few previously unlisted ops while at it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`ExtractOntology`, `ldh-GenerateOntologyViews`, `ldh-GenerateClassContainers`,
and `ldh-GeneratePortal` were missing from `formal-semantics.md` and had no
unit tests. Add them.
- `formal-semantics.md`: four new entries (one under Schema Operations,
three under LinkedDataHub Operations) with abstract + Python signatures
in the existing style.
- `execute()` type guards: each of the four ops now rejects non-conforming
inputs at the pure-function layer, matching the project-wide convention
("All operations enforce strict input type checking") and bringing them
in line with siblings like `ExtractClasses` and `ldh-AddView`.
- Tests (per project test-workflow memory: spec-driven, all authored
before running pytest):
- Type-rejection coverage for each `execute()` argument.
- For `ldh-GenerateOntologyViews`: behavioral coverage of the spec's
`ldh:view` emission and `owl:FunctionalProperty` exclusion, plus a
guard against any `ldh:template` triple (the removed LDH vocabulary).
- Live HTTP and JSON-dispatch cases skipped with `UNCLEAR(spec)` notes,
matching the project's existing pattern.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts: # uv.lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ExtractOntology,ldh-GenerateOntologyViews,ldh-GenerateClassContainers, andldh-GeneratePortalwere missing fromformal-semantics.mdand had no unit tests. This PR adds them.formal-semantics.md(one under Schema Operations, three under LinkedDataHub Operations) following the existing terse format.execute()type guards on each of the four ops so they reject non-conforming inputs at the pure-function layer — matches the project-wide convention ("All operations enforce strict input type checking") and brings these ops in line with siblings likeExtractClasses/ldh-AddView.execute()argument.ldh-GenerateOntologyViews, behavioral coverage of the spec'sldh:viewemission andowl:FunctionalPropertyexclusion, plus a guard that noldh:templatetriple (the removed LDH vocabulary) appears in the output.UNCLEAR(spec)notes, matching the existing pattern.Dependencies
This branch is based on #19 (
ldh:viewvocabulary fix) and additionally cherry-picks #18'sldh-prefix rename so the spec entries can reference the post-rename names. Once both upstream PRs merge, this PR's diff will collapse to just the spec + guards + tests commit.Recommended merge order: #18 → #19 → this PR (or interleave; rebase as needed).
Test plan
uv run pytest tests/ -q— 119 passed, 49 skipped (was 106 + 13 new pure tests across the 4 files; no regressions)Notes
The guards in
execute()are a small impl correctness improvement (not a behavior change). They were uncovered by writing the type-rejection tests — the spec saysexecute()must validate, but these four ops only validated inexecute_json(). Sibling ops (e.g.ExtractClasses,ldh-AddView) already validate atexecute(); this PR brings the four portal ops up to the same bar.