Skip to content

Spec and unit tests for portal/ontology operations#20

Merged
namedgraph merged 4 commits into
mainfrom
feat-spec-portal-ops
Jun 16, 2026
Merged

Spec and unit tests for portal/ontology operations#20
namedgraph merged 4 commits into
mainfrom
feat-spec-portal-ops

Conversation

@namedgraph

Copy link
Copy Markdown
Member

Summary

ExtractOntology, ldh-GenerateOntologyViews, ldh-GenerateClassContainers, and ldh-GeneratePortal were missing from formal-semantics.md and had no unit tests. This PR adds them.

  • Spec entries in 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 like ExtractClasses / ldh-AddView.
  • Unit tests authored per the spec-driven-tests rule:
    • 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 that no ldh:template triple (the removed LDH vocabulary) appears in the output.
    • Live HTTP and JSON-dispatch cases skipped with UNCLEAR(spec) notes, matching the existing pattern.

Dependencies

This branch is based on #19 (ldh:view vocabulary fix) and additionally cherry-picks #18's ldh- 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)
  • After upstream PRs land, rebase and confirm tests still pass

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 says execute() must validate, but these four ops only validated in execute_json(). Sibling ops (e.g. ExtractClasses, ldh-AddView) already validate at execute(); this PR brings the four portal ops up to the same bar.

namedgraph and others added 4 commits June 16, 2026 11:53
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>
@namedgraph namedgraph merged commit 4d027de into main Jun 16, 2026
6 checks passed
@namedgraph namedgraph deleted the feat-spec-portal-ops branch June 16, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant