Skip to content

Fixes #35987: Offer registry relation types with their inverses on native ontologies - #35995

Merged
harshach merged 102 commits into
mainfrom
harshach/ontology-studio/04-native-relations
Oct 29, 2026
Merged

harshach merged 102 commits into
mainfrom
harshach/ontology-studio/04-native-relations

Conversation

@harshach

@harshach harshach commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #35987

Native ontology authors can select registry relationship types and their inverses. Native inverse links remain reciprocal through edits, imports, deletion and restoration, while the picker follows bounded registry pagination.

The published stack targets release 2.1.0. Each linked Shipping issue is In Progress with Product, P1 and Governance metadata.

PR1 #35990, PR2 #35994 and PR3 #35997 are merged, and this PR now targets main. Two chains start at PR4:

PR9, PR11, PR13, PR14 and PR16 are not published yet.

Current assessment for 8f4748f4a5f, recorded 2026-10-29.

Verdict. PASS. Gitar flagged that a failed registry write could leave an orphan or one-way inverse type. One round and three fix-forwards answered it with eight commits, 56bf99b12e1 to 09b4142bcec, and an independent review checked each round. The last review passed 09b4142bcec, with no blocker or major left open from the four reviews. 8f4748f4a5f then merges PR3's landed head 9021493db4a and main's daec19a5ab6, and records PR3's squash 5575a2d4d5e with an ours merge. Neither merge had a conflict. The diff against main has the same patch-id as the reviewed diff against PR3's head fca4419074b. Earlier reviews passed the merge with main's AI-mode restyle at 4868c52ace0 and cf429f94388.

Retrying a failed type creation. When a registry write fails while an author creates a relationship type pair, the next try now finishes the pair. The view remembers the inverse type it registered until the back link is written. On a retry it reloads the registry. It links that inverse back to the type that names it, whatever the retry is called, or reuses it when the primary write failed. It then writes the relation the author drew, once. A retry never patches or reuses a type this view did not register. The error from the failed write still shows once.

Known limits. None of these blocks the merge.

  • The repair runs only when the author opens the type dialog again. Picking a cached type, from the picker or by typing its label, skips it.
  • When two registry types name the remembered inverse, the repair links it back to the first one in registry order.
  • With an approval gate on relationship types, a staged back link or repair does not reach the ontology until the change request is approved and the pair is drawn again. Meanwhile, a retry drawn as the inverse is written one-way. No test stages a registry patch.
  • The view keeps the memory only while it is mounted, and only for the latest inverse. After a reload, or when an inverse create commits on the server but fails on the client, a retry leaves the earlier inverse unlinked and creates a suffixed one, as before this round.
  • The AI-mode case in OntologyConceptInspector.test.tsx repeats PR4's partOf and hasPart fixtures with other IRIs.
  • Restoring one property alone inside a deleted ontology throws EntityNotFoundException and stores nothing when its stored inverse partner is live. Restoring the ontology works. That gap needs a design call and an issue, which is not filed yet.

Test evidence. On 09b4142bcec, TypeScript reports 0 errors and Jest passes 82 of 82 in PR4's 5 UI test files. ESLint reports 0 errors and the one known review-sequential-api-calls warning, Prettier is clean, the Playwright impact map is current, and CI's lint sequence makes no change. The round changed 3 UI files and no Java. The Java gates ran on the earlier merge tree 21999f30ecd. Package and spotless passed, and 465 unit tests in 26 classes passed. The 7 database classes ran on local MySQL 9.3 and PostgreSQL 14, one new database per run. All passed apart from two invocations of OntologyEntityDAOTest.reviewLocksSeeEditsAndArchivalCommittedWhileWaiting, whose rows share one database on the local engines. The Java impact map check passed at 8f4748f4a5f.

CI. Checks at 8f4748f4a5f were still running when this block was written. At cf429f94388, every check passed except maven-collate-ci, which failed with HTTP 422 because the Collate repository has no branch named after this PR's old base. This PR now targets main.

Still owed. None of these has run yet. Run each IT on -Pmysql-elasticsearch and then -Ppostgres-opensearch, and confirm a Tests run: line.

  • PR4's own ITs IndependentOntologyInverseIT and IndependentOntologyAxiomIT.
  • TaskResourceIT and the task ITs listed on PR1, which this head carries.
  • PR1's review-list ITs IndependentOntologyApprovalIT, IndependentOntologyPublicationIT and IndependentOntologyReleaseIT, and WorkflowDefinitionResourceIT in the global-state lane.
  • The full openmetadata-service unit suite and every merge-queue IT the planner selects against main, with the cache-tests and postgres-opensearch lanes.
  • Playwright OntologyNativeRelations.spec.ts and OntologyNativeStudio.spec.ts against a live stack. They drive classic mode.
  • The two invocations of OntologyEntityDAOTest.reviewLocksSeeEditsAndArchivalCommittedWhileWaiting under Testcontainers.
  • Changed-class coverage, which needs the ITs above.
  • The plan's live and performance lanes for this PR.

AI mode. main's Ontology Studio AI-mode restyle #36433 now gates new screens on AI mode. AI mode lacks none of PR4's controls. The inverse label, the relation type dialog, the registry-backed picker with its create option and the permission-denied toast all render in code both modes share.

Not verified yet. This PR is verified only when its unit, live and performance boxes in the plan are all checked. The operator lands the stack.

Earlier description and verification records

These records preserve the earlier design notes, test results and attachments. Earlier statements about the current head or readiness apply to their recorded revisions. The integration assessment above supersedes those statements.

Fixes #35987

Describe your changes

Native Ontology Studio now offers shared registry relationship types alongside the ontology's own object properties. Selecting Part Of reuses or creates native properties by exact predicate IRI, stores a restriction on the source concept, and shows Has Part on the target's incoming relation. Subclass Of keeps its native hierarchy behavior; annotation properties stay out of the picker.

Inverse links remain reciprocal through edits, imports, deletion, and restoration. New inverse claims release displaced partners. Restoring a self-inverse property preserves its link; restoring a missing partner drops the stale link. Both soft and hard deletion attribute partner cleanup to the deleting user inside the retained transaction. Registry types without an inverse create one native property without inventing a partner.

The picker loads all registry pages within a documented bound, shows inverse labels across page boundaries, and rejects invalid pagination instead of displaying an incomplete catalog. Administrators can create custom registry pairs in the dialog; authors without relationship-type Create permission can use existing types.

Design: ADR:2026-10-21-native-relations-instantiate-registry-relationship-types.

Validation

Current source snapshot: 213ae3115fdf740d405d7cecd338a6f343743c52.

  • Backend reactor build passed across 16 modules, including compilation of the new storage and API tests. Normal commit hooks passed.
  • 532 UI tests passed in 71 suites. Changed UI line coverage: native relation utility 100%, picker 98.41%, concept inspector 98.01%, graph view 90.86%. A subsequent focused run passed all 12 relation utility tests, including the new no-inverse contract assertion.
  • Full TypeScript diagnostics were compared against exact base ba6d06c88bd931b5854bfe003a288be3c9dee255 with identical dependencies, generated models, and external fixtures. Both compilations exit 2 with the same 562 diagnostics; normalized full messages and multiplicity have zero additions or removals.
  • Fresh API proof passed against the rebuilt Docker backend: reciprocal set/clear, self-inverse restoration, protected soft-deleted IRIs, source-only restrictions, OWL inverse export, one-sided import normalization, competing claims, and rejected-delete rollback. A separate RED-to-GREEN proof verifies that another user's hard delete credits that deleter on the surviving partner.
  • The focused Playwright flow passed against Vite on port 3640 and the rebuilt backend on port 8640. It covers registry groups, own object properties, Part Of reuse and incoming labels, Subclass Of, custom type creation, and a DataSteward with explicit native-author permissions but no registry Create permission.
  • Java impact ownership, UI formatting/lint, i18n generation, and decision-record checks passed. Harness warnings are retained in the local receipts.

Remaining verification

This is a published implementation snapshot; the following gates remain open under the shared test coordinator:

  • Re-run the current focused Java storage slice and changed-class coverage. The previous 159-test run passed before the deletion-actor fix; its outer repository coverage was 89.04%. Added metadata and rollback cases are compiled but not yet executed.
  • Run the current 14-case inverse API suite on both MySQL/Elasticsearch and PostgreSQL/OpenSearch. Earlier 12-case results do not cover this final unit.
  • Run the full affected Java selection and the 31-spec affected Playwright selection, including the required repeat/parallel stability checks.
  • Upload the reviewed screenshots and 37-second H.264 recording. The local artifacts are complete, but the available browser is signed out of GitHub; no hosted media URL is claimed.
  • Complete the independent review and performance verdict.

Type of change

  • Feature

Checklist

  • Self-review against REVIEW.md
  • Unit, current-artifact API, and focused Playwright evidence recorded
  • Full affected Java and Playwright gates
  • Final backend changed-class coverage
  • Screen recording uploaded
  • Independent verdict

Summary by Gitar

  • Review rules:
    • Approval rule freezes reviewers and approvalRule while a release is in review
  • Publication status:
    • Ontologies expose derived publicationStatus from active and latest releases
  • Definition status:
    • Concepts and properties derive Draft, In Review, or Approved from release membership
  • Class model:
    • Concepts gain abstract, definitionSource, deprecated, and replacedBy fields
    • Properties enforce at least two enumValues and support replacedBy
  • Working diff:
    • Added concept-grouped working diff pages with deprecation change type

This will update automatically on new commits.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge as part of the reviewed stack, with the fresh-registry permission concern addressed by PR #35991.

Summary

Native ontologies now offer registry relationship types and their inverse labels alongside their own object properties.

  • Native ontology authors can build relations from shared registry types.
  • Native property inverse links stay reciprocal through edits and lifecycle changes.
  • Incoming relations use their inverse label when the ontology declares one.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Choose a relationship type] --> B[Plan native writes]
  B --> C[Create missing properties or link existing ones]
  C --> D[Server settles reciprocal inverse links]
  D --> E[Validate final changes]
  E --> F[Save source restriction]
  F --> G[Refresh ontology model]
  G --> H[Show inverse label on incoming relation]
Loading

Reviews (21) · Last reviewed commit: "Merge class model fixes into native rela..." · Reviewed by Greptile

First unit of #35983. The enum carries the Any or All reviewer rule that
later commits put on the ontology, freeze into the review target, and
turn into the review task's approval threshold.
…ionship types

Decision record for the native relation picker: registry types become native
object properties matched by exact predicate IRI, inverses stay reciprocal on
write, and the create option is gated on the relationshipType permission.
@harshach harshach added safe to test Add this label to run secure Github workflows on PRs backend labels Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

harshach and others added 14 commits October 22, 2026 08:16
Adds the fields to the concept and property schemas, the create
requests, the release payload allowlist, and the RDF catalog vocabulary.
Adds the DEPRECATED change type, the REPLACED_BY reference role, and the
concept-grouped rows of the working diff. Regenerates the TypeScript
types.
The IT states the contract before the implementation: setting, creating with,
repointing, clearing, deleting and restoring an object property's inverse keeps
both sides reciprocal; a one-directional import normalizes on apply and is
reused by exact IRI; the release export carries owl:inverseOf both ways.
Concepts and properties now carry deprecation and replacement, and
concepts carry abstract and a definition source:

- A replacement must name another definition of the same kind in the
  same ontology. It is indexed as a REPLACED_BY reference, so deleting
  a replacement target is refused like any other dangling reference.
- An enumeration needs at least two allowed values. One-value
  enumerations stored before this rule stay editable until their values
  change.
- Release projection writes om:abstract, dct:source, owl:deprecated,
  and dct:isReplacedBy, and native import reads them back.
- Release and working diffs classify a member whose deprecated flag
  turned true as DEPRECATED.
- GET /ontologies/{id}/working/diff?groupBy=concept returns the working
  changes grouped by the concept they define, with parent labels and a
  property count, paged by group under its own revision-bound cursor.
…sion

IndependentOntologyClassModelIT covers the field round trips, the
enumeration minimum and its legacy carve-out, replacedBy integrity, the
DEPRECATED diff row, and grouped diff paging with the 412 cursor rule.
NativeOntologyMemoryIT adds a class-create change set and its rollback.
Existing ITs that stored one-value enumerations now use two values.
Adds the fields to the concept and property schemas, the create
requests, the release payload allowlist, and the RDF catalog vocabulary.
Adds the DEPRECATED change type, the REPLACED_BY reference role, and the
concept-grouped rows of the working diff. Regenerates the TypeScript
types.
Concepts and properties now carry deprecation and replacement, and
concepts carry abstract and a definition source:

- A replacement must name another definition of the same kind in the
  same ontology. It is indexed as a REPLACED_BY reference, so deleting
  a replacement target is refused like any other dangling reference.
- An enumeration needs at least two allowed values. One-value
  enumerations stored before this rule stay editable until their values
  change.
- Release projection writes om:abstract, dct:source, owl:deprecated,
  and dct:isReplacedBy, and native import reads them back.
- Release and working diffs classify a member whose deprecated flag
  turned true as DEPRECATED.
- GET /ontologies/{id}/working/diff?groupBy=concept returns the working
  changes grouped by the concept they define, with parent labels and a
  property count, paged by group under its own revision-bound cursor.
…sion

IndependentOntologyClassModelIT covers the field round trips, the
enumeration minimum and its legacy carve-out, replacedBy integrity, the
DEPRECATED diff row, and grouped diff paging with the 412 cursor rule.
NativeOntologyMemoryIT adds a class-create change set and its rollback.
Existing ITs that stored one-value enumerations now use two values.
OntologyWorkingState runs registered finalizers at the outermost
mutation's exit, before validation. OntologyPropertyRepository registers
one that settles inverse links over the affected neighbourhood: the side
that states a link decides it, the latest statement wins, and a partner
no longer pointed back at is released. Partners are written through the
updater so they version, index and validate like any edit. The RDF
importer reads owl:inverseOf as symmetric, so a one-directional file
describes both sides and a re-import changes nothing.
IndependentOntologyAxiomIT drops its indirect inverse variant, which
relied on one-sided inverse chains.
@harshach
harshach requested a review from a team as a code owner October 23, 2026 01:04
@harshach
harshach requested a review from IceS2 October 23, 2026 01:04
An ontology carries an approvalRule, AnyReviewer by default or
AllReviewers. prepareReview freezes the rule into the task's review
target and leaves the requester's and the author's own user entries out
of the assignees. The rule reaches the workflow as the start variable
approvalMode=allAssignees, which CreateTask turns into the task's
approvalThreshold, so the shared counters stay unchanged.

Each counted vote is recorded on the task in reviewVotes with its
comment; the deciding vote is recorded in the decision transaction with
any voter whose record was lost. Reviewers and the approval rule are
locked with 409 while a release of the ontology is in review.

GET /v1/ontologyReleases/{id}/review and
GET /v1/ontologies/reviews?view=assigned|created|pending read a review
from the task's recorded votes.

Amends ADR:2026-10-14-ontology-reviews-bind-workflow-tasks-to-revisions
as v13.
An incoming relation whose property has an inverse now reads the inverse label in both the classic and the AI panel, because the label logic moved into main's shared renderRelationRow. The relation type dialog renders in both modes, so a new relation type can be created from AI mode too. A new AI-mode test covers the inverse label.
Main moved 26 commits before PR1 landed. The merge had no conflicts.
PR1 landed on main as 5f2b733. This branch already holds PR1's final code, so the merge keeps the tree.
The type dialog registers the inverse, then the primary, then patches the
inverse to name the primary. These cases fail one of the later writes once
and retry the same draft through the dialog. A retry after a failed primary
write must reuse the inverse already registered, and a retry after a failed
back link must patch the inverse to name the primary. Either way the
registry ends with one reciprocal pair and no suffixed duplicate.
PR2's branch brings main through 7843a02 and records PR1's squash merge 5f2b733. The merge had no conflicts.
The type dialog registers the inverse, then the primary, then patches the
inverse to name the primary. When the primary write failed, a retry
registered a second inverse with a numeric suffix and left the first one
unlinked. When the back link failed, a retry found the primary and returned
it, so the pair stayed one-way.

The view now remembers the inverse it registered until the back link is
written. On a retry, the planner names the draft's inverse after that type
and reuses it, or, when the primary is already registered and names it, the
view patches the back link. No other type is patched, and the error from
the failed write is still shown.

A rollback would need the Delete right on relationship types, which the
dialog does not check, and the registry's soft delete keeps the name taken,
so the retry's create would conflict.
PR2 landed on main as 8c01d4c, a squash of ae01b93 with the same tree.
This merge records the squash so that main is an ancestor of this branch. The
tree does not change.
A new case puts another author's unlinked "approves" in the registry and
creates "approved by" with the inverse "approves". The view registers
"approves2" and links only that type back, so it never claims a type it
did not register.

The case where the back link failed now also checks that the retry
writes the relation once and that only the first failure is reported.
After the back link of "approved by" fails, the author retries with the
label "signed off by" and the same inverse "approves". The new case
expects the retry to link "approves" back to "approvedBy" and to give
"signedOffBy" its own inverse, "approves2", so no type is the inverse of
two primaries. It fails until the view finishes the earlier pair before
it plans the retry.
When the back link fails, the primary names the inverse but the inverse
names nothing. A retry under a new label reused that inverse for the new
primary, so the inverse ended up named by two primaries.

Before it plans a retry, the view now links the inverse it registered
back to the type that already names it, whatever the retry is called,
and then plans the draft with no reuse, so the new primary gets its own
inverse. The inverse is reused only while nothing names it, after a
failed primary write. Only the inverse this view registered is patched.
Two cases in OntologyGraphView.test.tsx pin behavior the view already has.
A retry whose back-link repair fails keeps the remembered inverse, so a
later retry links it back. A retry drawn from the other end, under the
inverse's own label, still links the earlier pair back.
Base automatically changed from harshach/ontology-studio/03-class-model to main October 29, 2026 21:40
After the back link of "approved by" fails, the author draws the
relation from the other end and types "approves". The case already
checks that the retry links the earlier pair back. It now also checks
the relation the retry writes: the property "approvedBy" first, then
"approves" naming it as its inverse, and one axiom on "approves". That
is what a first draw of "approves" writes. It fails until the view
looks the label up in the registry as the repair left it, because the
retry still writes "approves" with no inverse.
When the back link of "approved by" fails and the author retries by
drawing "approves", the view links the pair back in the registry. It
then looked the label up in the list it loaded before that repair,
where "approves" names no inverse. So the retry wrote the property
"approves" with no inverse and never declared "approvedBy". A first
draw of "approves" writes both properties, linked.

finishUnlinkedPair now returns the registry with the patched inverse in
place of the stale entry, and the view looks the label up and plans the
draft in that list. The retry now writes "approvedBy", then "approves"
naming it, then one axiom, as a first draw does. The view still patches
only the inverse it registered, keeps it when the repair fails, and
reports the failed write once.
PR3's landed head 9021493 brings main through 8c01d4c and records PR2's
squash merge. The merge had no conflicts.
Main moved to daec19a before PR3 landed. The merge had no conflicts.
PR3 landed on main as 5575a2d, a squash of 9021493 merged with daec19a.
This merge records the squash so that main is an ancestor of this branch. The
tree does not change.
@gitar-bot

gitar-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 6 closed / 6 findings

🔴 High risk · Reciprocal inverse-link writes across ontology edits, imports, deletion, and restoration could leave stored property relationships inconsistent or remove links unexpectedly.

Native ontology authors can now pick shared registry relationship types and their inverses, with inverse links kept reciprocal through edits, imports, deletion and restoration. Six issues were resolved this session, including one-sided inverse pairs, reuse of soft-deleted IRIs, restore dropping dangling inverses, review-list task loading, and orphaned registry types on failed pair creation. No open findings remain.

✅ 6 closed
✅ Edge Case: Reciprocal-inverse rule skips retargeting, so pairs can stay one-sided

📄 docs/decisions/2026-10-21-native-relations-instantiate-registry-relationship-types.md:19 📄 docs/decisions/2026-10-21-native-relations-instantiate-registry-relationship-types.md:15
OntologyProperty.inverse holds one value (ontologyProperty.json:126). The record covers setting an inverse and clearing or deleting one side, but not moving an inverse to a different property. Example: P↔Q exists and someone sets P.inverse = R. Following the rule as written, R.inverse becomes P, but Q.inverse is still P. If R already pointed at some S, then S.inverse is still R. Either way the pairs end up one-sided, which is exactly what this record says it prevents. This can happen through the picker's "reused by IRI" path (line 15) whenever an existing property such as an imported skos:broader already has a different inverse. It can also happen through a one-direction import statement, which the record normalizes. Since implementers will check code against this record, it should state the retarget behaviour.

✅ Edge Case: Reuse-by-IRI ignores soft-deleted properties that still hold the IRI

📄 docs/decisions/2026-10-21-native-relations-instantiate-registry-relationship-types.md:15
ADR:2026-10-14-ontology-definitions-have-independent-entity-storage makes property IRIs unique within an ontology, and soft-deleted definitions count toward that uniqueness. This record reuses a property only when the ontology "already has" one with the registry predicate, and otherwise creates a new one. Suppose an author picks hasPart, later deletes the native …/hasPart property, then picks hasPart again. Creating a new property with that IRI breaks the unique (ontologyId, iriHash) index, so the picker's instantiate step fails. The record should say whether a soft-deleted match is restored (PUT restore already keeps the IRI) or reported to the author.

✅ Quality: SETTLE_PASSES=8 finalizer budget is an unrecorded judgment call

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/OntologyWorkingState.java:26 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/OntologyWorkingState.java:64-78
OntologyWorkingState.settle() adds a retry budget: finalizers run again until a pass adds no change, and after 8 passes the write fails with IllegalStateException (a 500, not a 400). The value 8 is a judgment call, and the finalizer order it depends on (finalizers run before requireValid, ontologies in sorted UUID order, each key registered once per outermost mutation) can't be seen from any single repository. None of the records in docs/decisions/ states it, and the new ADR covers reciprocity but not how it is reached. Add a sentence to ADR:2026-10-21-native-relations-instantiate-registry-relationship-types (or a new record) such as: "Pre-validation finalizers run at the end of the outermost ontology mutation, before validation, until a pass records no new change; a mutation that has not settled after 8 passes is rejected." Cite it from the constant.

✅ Quality: Restore silently drops a dangling inverse; the ADR says it is refused

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/OntologyPropertyRepository.java:87-93 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/OntologyPropertyRepository.java:208-214 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/IndependentOntologyInverseIT.java:157-169
The Accepted record says "An inverse IRI that names no live object property is still refused." reconcileInverses makes an exception for restore. When a revived property's inverse dangles, the code calls links.link(iri, null) and clears the link without telling anyone, and the new test restoringAPropertyWhosePartnerIsGoneDropsTheLink locks that in. The record states neither this exception nor the rule that a new claim takes an occupied partner and releases its previous holder (claimingAnOccupiedPartnerMovesIt). Either refuse the restore, or amend the record's Decision with: "Restoring a property whose inverse no longer names a live object property clears that inverse instead of refusing the restore."

✅ Performance: listReviews loads a task for every open review on each page request

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/OntologyReleaseRepository.java:237-251 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/OntologyReleaseRepository.java:296-306
listReviews scans every In Review release across all ontologies in batches of 1000. For each release the caller can view, it calls reader(...), which runs tasks.get(..., "assignees,reviewers,createdBy") before reader.matches(view) can filter it out (OntologyReleaseRepository.java:255-270, 296-306). That makes every page request O(open reviews) task loads, each with relationship lookups, no matter what limit or after asks for, and later pages repeat the whole scan. Suggested fix: bulk-load the tasks for each batch with one tasks.get(uriInfo, ids, fields, include) call (the setFieldsInBulk path) before building readers. Alternatively, pre-filter on the task's assignee and creator relationships in SQL so only matching reviews get hydrated.

...and 1 more closed from earlier reviews

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@harshach
harshach merged commit 92d4e43 into main Oct 29, 2026
72 checks passed
@harshach
harshach deleted the harshach/ontology-studio/04-native-relations branch October 29, 2026 23:03
manerow pushed a commit that referenced this pull request Oct 30, 2026
…tive ontologies (#35995)

* WIP: add OntologyApprovalRule schema for release review rules

First unit of #35983. The enum carries the Any or All reviewer rule that
later commits put on the ontology, freeze into the review target, and
turn into the review task's approval threshold.

* WIP: record that ontology definition status is derived from releases

* Fixes #35987: Record that native relations instantiate registry relationship types

Decision record for the native relation picker: registry types become native
object properties matched by exact predicate IRI, inverses stay reciprocal on
write, and the create option is gated on the relationshipType permission.

* WIP: add abstract, source, and deprecation fields to native classes

Adds the fields to the concept and property schemas, the create
requests, the release payload allowlist, and the RDF catalog vocabulary.
Adds the DEPRECATED change type, the REPLACED_BY reference role, and the
concept-grouped rows of the working diff. Regenerates the TypeScript
types.

* Update generated TypeScript types and dereferenced schemas

* Add IndependentOntologyInverseIT for reciprocal native inverses

The IT states the contract before the implementation: setting, creating with,
repointing, clearing, deleting and restoring an object property's inverse keeps
both sides reciprocal; a one-directional import normalizes on apply and is
reused by exact IRI; the release export carries owl:inverseOf both ways.

* Validate, project, and diff the class model fields

Concepts and properties now carry deprecation and replacement, and
concepts carry abstract and a definition source:

- A replacement must name another definition of the same kind in the
  same ontology. It is indexed as a REPLACED_BY reference, so deleting
  a replacement target is refused like any other dangling reference.
- An enumeration needs at least two allowed values. One-value
  enumerations stored before this rule stay editable until their values
  change.
- Release projection writes om:abstract, dct:source, owl:deprecated,
  and dct:isReplacedBy, and native import reads them back.
- Release and working diffs classify a member whose deprecated flag
  turned true as DEPRECATED.
- GET /ontologies/{id}/working/diff?groupBy=concept returns the working
  changes grouped by the concept they define, with parent labels and a
  property count, paged by group under its own revision-bound cursor.

* Cover the class model fields in integration tests and record the decision

IndependentOntologyClassModelIT covers the field round trips, the
enumeration minimum and its legacy carve-out, replacedBy integrity, the
DEPRECATED diff row, and grouped diff paging with the 412 cursor rule.
NativeOntologyMemoryIT adds a class-create change set and its rollback.
Existing ITs that stored one-value enumerations now use two values.

* WIP: add abstract, source, and deprecation fields to native classes

Adds the fields to the concept and property schemas, the create
requests, the release payload allowlist, and the RDF catalog vocabulary.
Adds the DEPRECATED change type, the REPLACED_BY reference role, and the
concept-grouped rows of the working diff. Regenerates the TypeScript
types.

* Validate, project, and diff the class model fields

Concepts and properties now carry deprecation and replacement, and
concepts carry abstract and a definition source:

- A replacement must name another definition of the same kind in the
  same ontology. It is indexed as a REPLACED_BY reference, so deleting
  a replacement target is refused like any other dangling reference.
- An enumeration needs at least two allowed values. One-value
  enumerations stored before this rule stay editable until their values
  change.
- Release projection writes om:abstract, dct:source, owl:deprecated,
  and dct:isReplacedBy, and native import reads them back.
- Release and working diffs classify a member whose deprecated flag
  turned true as DEPRECATED.
- GET /ontologies/{id}/working/diff?groupBy=concept returns the working
  changes grouped by the concept they define, with parent labels and a
  property count, paged by group under its own revision-bound cursor.

* Cover the class model fields in integration tests and record the decision

IndependentOntologyClassModelIT covers the field round trips, the
enumeration minimum and its legacy carve-out, replacedBy integrity, the
DEPRECATED diff row, and grouped diff paging with the 412 cursor rule.
NativeOntologyMemoryIT adds a class-create change set and its rollback.
Existing ITs that stored one-value enumerations now use two values.

* Fix class model integration test assertions for wrapped SDK errors and per-operation revisions

* Fixes #35981: Derive concept lifecycle status, ontology publication status and release change summary

* WIP: record that ontology definition status is derived from releases

* Fixes #35981: Derive concept lifecycle status, ontology publication status and release change summary

* WIP: add approvalRule, reviewVotes and the release review read schemas

* Keep native inverses reciprocal on write

OntologyWorkingState runs registered finalizers at the outermost
mutation's exit, before validation. OntologyPropertyRepository registers
one that settles inverse links over the affected neighbourhood: the side
that states a link decides it, the latest statement wins, and a partner
no longer pointed back at is released. Partners are written through the
updater so they version, index and validate like any edit. The RDF
importer reads owl:inverseOf as symmetric, so a one-directional file
describes both sides and a re-import changes nothing.
IndependentOntologyAxiomIT drops its indirect inverse variant, which
relied on one-sided inverse chains.

* Decide ontology release reviews by the ontology's approval rule

An ontology carries an approvalRule, AnyReviewer by default or
AllReviewers. prepareReview freezes the rule into the task's review
target and leaves the requester's and the author's own user entries out
of the assignees. The rule reaches the workflow as the start variable
approvalMode=allAssignees, which CreateTask turns into the task's
approvalThreshold, so the shared counters stay unchanged.

Each counted vote is recorded on the task in reviewVotes with its
comment; the deciding vote is recorded in the decision transaction with
any voter whose record was lost. Reviewers and the approval rule are
locked with 409 while a release of the ontology is in review.

GET /v1/ontologyReleases/{id}/review and
GET /v1/ontologies/reviews?view=assigned|created|pending read a review
from the task's recorded votes.

Amends ADR:2026-10-14-ontology-reviews-bind-workflow-tasks-to-revisions
as v13.

* Record votes only for ontology reviews and test the review read model

Only an ontology review reconciles the deciding vote, so recording
counted votes on any other multi-approval task would always leave its
last vote out and add version bumps to glossary approvals. The waiting
branch now records a vote only for an ontology review.

OntologyReleaseReviewReaderTest reads reviews through the reader with
literal tasks and votes. OntologyReleaseRepository.page and offset are
static so the cursor math has a test with literal rows.

* Validate the net change of each ontology definition

A restore relinks or drops its inverse through the reciprocity finalizer,
which writes the same row a second time inside one mutation. Validation
kept the first row per id, so it still saw the dangling inverse and
refused the restore. OntologyWorkingState now folds a mutation's changes
to one per definition before finalizers and validation see them.

A restored property whose partner was hard-deleted meanwhile drops the
link before its updater runs, so the restore response matches the stored
row, and IndependentOntologyInverseIT covers it on both profiles.

* Offer registry relation types with their inverses in the native picker

The native relation picker lists the relationship-type registry in two
groups, Core and Custom, with each type's inverse beside it, plus the
ontology's own object properties that no registry predicate backs.
Picking a type writes the missing property pair with the registry
predicates as IRIs, linked through inverse, then the restriction axiom.
An admin can create a custom type with its inverse from the picker; the
dialog writes both registry types and links them before instantiating.
The concept inspector labels incoming relations with the inverse. The
Playwright spec covers the groups, Part Of, a custom type, and a steward
who sees the types but no create option.

* chore(playwright): auto-refresh impact-map.generated.json

* Skip the reference delete for a definition that does not exist yet

* Keep the review task's own reviewers and declare approvalRule in the RDF ontology

The release inherits its reviewers from the ontology, and the entity
updater drops inherited references from a reviewer list, so the task's
REVIEWS rows vanished on the workflow's first stage update.
OntologyReview.eligibleReviewers now returns plain copies.

A counted vote whose record loses every optimistic-locking retry answers
200 with a warning, because the vote already counted in Flowable and the
decision records it.

openmetadata.ttl declares om:approvalRule, which the ontology projection
writes. The ITs unwrap the SDK's wrapped 409 and fetch the task with its
reviewers.

* Fixes #35981: Cover property and ontology edits in the unpublished-changes count, drop restating comments

* Match registry inverses by id and link reused property pairs

The server fills only `id` on a relationship type's `inverse` reference,
so the catalog and the picker now resolve a type's inverse by `id`, with
`fullyQualifiedName` as the fallback, instead of by a `name` that is
never set. Custom types with an inverse show both labels again.

When both properties of a pair are already live but the one the type
names does not point at the type's partner, the plan patches that
property's `inverse` instead of leaving the pair unlinked. The spec
covers a second Part Of that reuses the pair and a Subclass Of that
writes only the hierarchy axiom.

* Fix review vote durability and authorized pagination

* Keep restored inverses and load every registry page

* Attribute inverse cleanup to the deleting user

* fix: persist workflow votes with terminal task decisions

* Fixes #35981: Clarify the derived publication status contract

* Fixes #35987: Map native ontology changes to browser coverage

* test: assert ontology review approval rule round trips

* Fix inverse deletion actor test email length

* test(ontology): cover property validation and grouped diff cursors

* test(ontology): reject release headers as captured definitions

* Use the registered fixture actor for inverse rollback tests

* Recheck review setup under the lock, list reviews by caller, vote per stage

Starting a review now rechecks the frozen approval rule and the chosen
reviewers against the ontology under the review lock and refuses with
409 when either changed since the request was prepared, so the lock has
no window before the release is In Review.

The review list starts from the caller's own open approval tasks, which
the database narrows to the caller as reviewer, assignee or requester,
instead of scanning every release in review and loading its task.

A reviewer's vote is recorded once per workflow stage, so a task that
moves through several approval stages keeps every stage's vote.

Regenerate the API reference so it lists the two review endpoints.

* Cover relationship type reuse after the picker's list went stale

The 409 fallback in OntologyGraphView adopted whichever registry type
held a planned name. A reused primary lost the inverse it already had,
because the inverse was resolved against only the two types in hand,
and a reused inverse had its own partner overwritten by the back-link
patch. These tests pin the behavior the picker should have and fail on
the current code.

* Reload the registry before registering a relationship type

The picker planned names against a list up to 30 s old and recovered
from a 409 by fetching the existing type by name. That treated a name
collision as the same type: a reused primary dropped the inverse the
registry already held, and a reused inverse was re-pointed at the new
primary, orphaning its partner for every glossary and ontology that
uses it.

The picker now reloads the registry after the dialog. A type registered
since the list was cached is reused as it is, with its real inverse.
Otherwise names are planned apart from everything the registry holds,
and the back link is written only to the inverse this flow just
created. A 409 after that is a race and surfaces as an error instead of
being papered over.

* Test ontology review votes through TaskWorkflowHandler.resolveTask

A non-final vote leaves the task open and records one vote with its comment.
A repeat voter is recorded once, and a voter keeps one vote in each approval stage.

* Cover relationship type creation for users who cannot edit registry types

A user whose policy grants Create but not EditAll on relationshipType
could register a primary type and its inverse and then fail on the
back-link patch, which the server authorizes as EditAll. The new tests
expect the dialog to disable its inverse field for that user and the
flow to write a single type, plain or symmetric, with no patch. The
first test fails on the current component.

* Offer a registry inverse only to users who can edit relationship types

The inverse's back link is a PATCH of /inverse on the inverse type,
which the server authorizes as EditAll on relationshipType, and the
creator holds no owner right on a type it just made. The create dialog
now disables the inverse field for a user without that right and shows
the standard permission message under it, so a create-only user
registers one type, plain or symmetric, and never leaves a half-linked
pair. The decision record gains a v2 amendment with the rule.

* Keep release and member ID binds within one parameter budget in definition status queries

The status resolver and the unpublished-change counter chunked only the member IDs and bound every release ID into each chunk. A large page could pass the database bind-parameter limit and fail the list request. Both lists now share one budget and every release and member pair is still queried once.

* Test that restoring an ontology keeps inverse links between its properties

* Keep inverse links between properties that a restore brings back together

* Test that relation choices follow the rights their writes need

A user who can create axioms but not properties is offered only the
relations an axiom completes, and a reused pair is offered from the side
whose inverse the user can edit. Submitting a choice the user cannot
complete shows the permission message and writes nothing.

* Offer only the relations whose writes the user may make

The native relation picker offered every registry type to any user who
could create axioms. Picking a type can also declare the properties the
ontology lacks, which needs create rights on properties, or point a
reused property at its partner, which needs edit rights on that
property. A user without those rights picked the type, and the server
refused the first write.

The picker now offers a type only when the user holds every right its
planned writes need, and it reads edit rights per property. Submitting
a type the user cannot complete shows the permission message before any
write. Hierarchy relations and pairs that the ontology already holds
linked need only the axiom right, so they stay available.

Planning every type on each model refresh made the planner quadratic in
the number of properties, because each plan built a set of all property
names and scanned the properties by IRI. The planner now indexes the
properties by IRI once per model and builds the name set only when it
declares a property. With 100 registry types and 10,000 properties,
planning the whole catalog takes about 41 ms instead of about 1.9 s, and
the plans match the previous planner's.

The decision record gains a v3 amendment that states the rule.

* Test that restoring an ontology drops a link its partner no longer names back

A property deleted on its own keeps its inverse, while the server clears
the partner's side. The new case gives the partner another inverse,
deletes and restores the ontology, and expects the partner's current
pair back with the older claim cleared. It runs every order of the three
properties' ids, because a write applies its changes in id order.

* Drop a restored inverse that its returning partner no longer names

Restoring an ontology also brings back the properties that were deleted
on their own. Such a property keeps the inverse it held, but the server
cleared its partner's side when it was deleted, and the partner may have
taken another inverse since. The restore kept that older claim whenever
the partner came back in the same write, so the pair that survived
depended on the order of the properties' ids.

A link to a partner that the same restore brings back now survives only
when the partner's stored inverse names the property. Pairs that were
linked on both sides come back as they were, and the older claim is
cleared, whatever the id order. A property whose partner was left
without an inverse comes back unlinked. A single restore still relinks a
live partner and drops a partner that stays deleted.

* Test that restoring an ontology drops claims that compete for a live partner

A property can be restored on its own inside a deleted ontology. When
two properties that were deleted earlier still name it as their inverse,
restoring the ontology brings both claims back at once, and both pass
the check that the partner is live. The claim that reconciles last
wins, so the pair that survives depends on the order of the properties'
ids.

The new test runs every order of three properties' ids on both engines
and expects all three properties to come back unlinked. Two more tests
cover the claims an ontology restore keeps. A lone claim on a live
partner relinks it. Two claims on a vocabulary property both survive,
because the server never writes the side of a vocabulary property.

* Drop restored claims that compete for one live partner

Restoring an ontology brings back every property deleted in it,
including properties that were deleted on their own earlier, and each
keeps the inverse it held. A partner they name can already be live,
because a property can be restored on its own inside a deleted
ontology. When two of the restored properties named the same live
partner, both claims passed the check that the partner is live, and
the claim that reconciled last won. The pair that survived depended on
the order of the properties' ids.

A restore states its links all at once, so none of these claims is the
latest. When two or more properties that one restore brings back name
the same live partner, the restore now clears every one of those
claims and leaves the partner as it was. A lone claim on a live
partner still relinks it. A claim on a partner that returns in the same
restore is still kept only when that partner names the property back.
Claims on a vocabulary property that the ontology does not declare
never compete, because no write changes that property, so a round trip
keeps them.

The decision record states the rule beside its restore exception, and
its Guard names the test that covers it.

* Reword the restore rule in the record and split the restore test setup

* Test each ontology review view over stored tasks

List the assigned, pending and created views through listReviews on
MySQL and PostgreSQL, over approval tasks stored the way TaskRepository
stores them: about, the requester and the reviewers live in relationship
rows, not in the task JSON. The test database gains user_entity so the
task's people resolve.

Every view returns no reviews on the current head.

* List ontology reviews with the release each task is about

TaskRepository keeps a task's about out of the stored JSON and clears it
unless the read asks for it. The review list read tasks without about, so
it matched no release and returned no rows in any view.

* Test that the review list never reads the caller's glossary approvals

A steward who reviews glossary approvals and one release review lists
pending reviews, and a requester who created them lists created reviews.
Each gets the one release, and no statement the list runs names a
glossary approval task.

* List only the approval tasks that are about an ontology release

The review list read every open approval task the caller was on,
glossary and data product approvals included, and hydrated each one.
The task filter now also requires a task about an ontology release, and
the list reads the releases of the listed tasks in one query instead of
one query per task.

* Name the tasks in the glossary approval list test

* Keep the review list test from registering a glossary repository

Surefire runs every service test class in one JVM, and a repository
the test registers stays bound to its database after the class ends.
The fixed list never reads a glossary term, so the test now names the
term's type on its reference instead of registering the repository.

* Test that the review list drops a superseded review task

A release can be in review under a new task while the task it was in
review under before is still open. The list must show the release once,
under the current task. No test covered the check in reviewedRelease
that drops the older task, so every test passed without it.

* Test that the review list reads its releases in one statement

The list loads the releases of all listed tasks in one batched read.
The list test now asserts that exactly one statement reads release rows
and that it covers both releases, so a read per task fails it. Resolving
each task's about reads only the names of its release, so the assertion
does not count that lookup.

* Order the AI-mode import and space the graph helpers

* Test that a retried relation type finishes the pair a failed write left

The type dialog registers the inverse, then the primary, then patches the
inverse to name the primary. These cases fail one of the later writes once
and retry the same draft through the dialog. A retry after a failed primary
write must reuse the inverse already registered, and a retry after a failed
back link must patch the inverse to name the primary. Either way the
registry ends with one reciprocal pair and no suffixed duplicate.

* Finish a relation type pair on retry after a registry write fails

The type dialog registers the inverse, then the primary, then patches the
inverse to name the primary. When the primary write failed, a retry
registered a second inverse with a numeric suffix and left the first one
unlinked. When the back link failed, a retry found the primary and returned
it, so the pair stayed one-way.

The view now remembers the inverse it registered until the back link is
written. On a retry, the planner names the draft's inverse after that type
and reuses it, or, when the primary is already registered and names it, the
view patches the back link. No other type is patched, and the error from
the failed write is still shown.

A rollback would need the Delete right on relationship types, which the
dialog does not check, and the registry's soft delete keeps the name taken,
so the retry's create would conflict.

* Test that a retry reuses no other inverse and draws the relation once

A new case puts another author's unlinked "approves" in the registry and
creates "approved by" with the inverse "approves". The view registers
"approves2" and links only that type back, so it never claims a type it
did not register.

The case where the back link failed now also checks that the retry
writes the relation once and that only the first failure is reported.

* Test that a relabelled retry finishes the earlier pair first

After the back link of "approved by" fails, the author retries with the
label "signed off by" and the same inverse "approves". The new case
expects the retry to link "approves" back to "approvedBy" and to give
"signedOffBy" its own inverse, "approves2", so no type is the inverse of
two primaries. It fails until the view finishes the earlier pair before
it plans the retry.

* Finish the earlier pair before planning a relabelled retry

When the back link fails, the primary names the inverse but the inverse
names nothing. A retry under a new label reused that inverse for the new
primary, so the inverse ended up named by two primaries.

Before it plans a retry, the view now links the inverse it registered
back to the type that already names it, whatever the retry is called,
and then plans the draft with no reuse, so the new primary gets its own
inverse. The inverse is reused only while nothing names it, after a
failed primary write. Only the inverse this view registered is patched.

* Test that a failed repair keeps the inverse and a reverse retry links it

Two cases in OntologyGraphView.test.tsx pin behavior the view already has.
A retry whose back-link repair fails keeps the remembered inverse, so a
later retry links it back. A retry drawn from the other end, under the
inverse's own label, still links the earlier pair back.

* Check the property writes when a retry is drawn as the inverse

After the back link of "approved by" fails, the author draws the
relation from the other end and types "approves". The case already
checks that the retry links the earlier pair back. It now also checks
the relation the retry writes: the property "approvedBy" first, then
"approves" naming it as its inverse, and one axiom on "approves". That
is what a first draw of "approves" writes. It fails until the view
looks the label up in the registry as the repair left it, because the
retry still writes "approves" with no inverse.

* Look up the retry label in the repaired registry

When the back link of "approved by" fails and the author retries by
drawing "approves", the view links the pair back in the registry. It
then looked the label up in the list it loaded before that repair,
where "approves" names no inverse. So the retry wrote the property
"approves" with no inverse and never declared "approvedBy". A first
draw of "approves" writes both properties, linked.

finishUnlinkedPair now returns the registry with the patched inverse in
place of the stale entry, and the view looks the label up and plans the
draft in that list. The retry now writes "approvedBy", then "approves"
naming it, then one axiom, as a first draw does. The view still patches
only the inverse it registered, keeps it when the repair fails, and
reports the failed write once.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ontology Studio: offer registry relation types with their inverses on native ontologies

2 participants