Skip to content

BE-1160: Replace the primitive-parent rule with a required type and reject Value in property types - #10525

Open
TimDiekmann wants to merge 3 commits into
mainfrom
t/be-1160-allow-abstract-data-types-to-inherit-from-value
Open

TimDiekmann wants to merge 3 commits into
mainfrom
t/be-1160-allow-abstract-data-types-to-inherit-from-value

Conversation

@TimDiekmann

@TimDiekmann TimDiekmann commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

🌟 Purpose

A data type cannot group children of different primitive types. An abstract Color with the children RGB Color (a list) and Color Label (a string) has to inherit from Value, and only the six primitive data types can do that.

🔍 Changes

Three rules replace the rule that only primitive data types inherit from Value:

  • Every data type inherits from Value, directly or indirectly. Any data type can name Value as its parent.
  • Every concrete data type needs a type. A data type that allows several types through anyOf has to be abstract. Value is exempt.
  • A property type cannot reference Value.

@TimDiekmann TimDiekmann self-assigned this Nov 16, 2026
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
hash Ignored Ignored Preview Nov 16, 2026 5:11pm UTC
hashdotdesign-tokens Ignored Ignored Preview Nov 16, 2026 5:11pm UTC
petrinaut Skipped Skipped Nov 16, 2026 5:11pm UTC
petrinaut-docs Skipped Skipped Nov 16, 2026 5:11pm UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Newly accepted abstract union schemas still throw errors in data-type pages and property-table rendering, so frontend support is needed alongside the validator change.

1 open issue
What changed in this PR

This PR updates the Rust type system to support abstract parents spanning multiple primitive types, while tightening validation for concrete data types and property references.

Changes:

  • Allows any data type to inherit directly from Value, while requiring concrete types other than Value to declare type.
  • Rejects property-type references to Value, including inside arrays.
  • Adds tests for validation failures and concrete children narrowing an abstract parent’s union constraints.
File Description
libs/​@blockprotocol/​type-system/​rust/​src/​ontology/​property_type/​schema/​validation.rs Rejects data-type references to Value.
libs/​@blockprotocol/​type-system/​rust/​src/​ontology/​property_type/​schema/​mod.rs Tests rejection of Value within array alternatives.
libs/​@blockprotocol/​type-system/​rust/​src/​ontology/​data_type/​schema/​validation.rs Replaces primitive-parent restrictions with required-type validation.
libs/​@blockprotocol/​type-system/​rust/​src/​ontology/​data_type/​schema/​mod.rs Exposes the shared Value identifier within the crate.
libs/​@blockprotocol/​type-system/​rust/​src/​ontology/​data_type/​schema/​closed.rs Tests abstract union inheritance and concrete-child constraint narrowing.

Review effort: Balanced

@codspeed

codspeed Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 80 skipped benchmarks1


Comparing t/be-1160-allow-abstract-data-types-to-inherit-from-value (f4e5cba) with main (164699c)2

Open in CodSpeed

Footnotes

  1. 80 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (46d7d9a) during the generation of this report, so 164699c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@TimDiekmann
TimDiekmann marked this pull request as ready for review November 16, 2026 16:31
@TimDiekmann
TimDiekmann requested a review from a team as a code owner November 16, 2026 16:31
@cursor

cursor Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes core ontology validation for data and property types; invalid schemas that previously passed (or vice versa) may fail at ingest time.

Overview
Replaces the rule that only primitive data types may inherit from value with stricter shape rules for inheritance and property typing.

DataTypeValidator no longer rejects non-primitive parents of value (the PRIMITIVE_DATA_TYPE_IDS check and NonPrimitiveValueInheritance error are gone). Instead, concrete data types that express multi-type unions via anyOf fail with MissingType; only abstract types may use anyOf without a single type. VALUE_DATA_TYPE_ID is exposed for reuse across modules.

Property type validation now rejects references to the base value data type (ValueDataTypeReference), including in array item oneOf lists.

Tests cover abstract anyOf parent closing (children narrow to their own type), failed validation for concrete anyOf, and property types that reference value.

Reviewed by Cursor Bugbot for commit f4e5cba. Bugbot is set up for automated code reviews on this repo. Configure here.

@veria-ai

veria-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.03%. Comparing base (aab2b25) to head (7f5c67d).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10525      +/-   ##
==========================================
- Coverage   69.03%   69.03%   -0.01%     
==========================================
  Files        2081     2081              
  Lines      214393   214393              
  Branches     9256     9256              
==========================================
- Hits       148012   148011       -1     
  Misses      64494    64494              
- Partials     1887     1888       +1     
Flag Coverage Δ
apps.hash-ai-worker-ts 9.44% <ø> (ø)
apps.hash-api 16.23% <ø> (ø)
hash-graph 21.71% <ø> (ø)
hash-graph-api 49.01% <ø> (ø)
hash-graph-atlas 80.10% <ø> (-0.01%) ⬇️
hash-graph-authentication 96.83% <ø> (ø)
hash-graph-authorization 68.20% <ø> (ø)
hash-graph-embeddings 91.92% <ø> (ø)
hash-graph-postgres-store 31.48% <ø> (ø)
hash-graph-store 51.17% <ø> (ø)
hash-graph-types 0.00% <ø> (ø)
hash-graph-validation 84.91% <ø> (ø)
hash-integrations-definition 93.70% <ø> (ø)
hash-middleware 87.62% <ø> (ø)
hashql-compiletest 28.71% <ø> (ø)
hashql-eval 81.55% <ø> (ø)
local.hash-backend-utils 24.83% <ø> (ø)
local.hash-graph-sdk 9.79% <ø> (ø)
local.hash-isomorphic-utils 40.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs November 16, 2026 17:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – petrinaut November 16, 2026 17:10 Inactive

This branch was successfully deployed

3 active (2 outdated) and 2 inactive deployments
pull-request — f4e5cba1 Deployed Nov 16, 2026 by TimDiekmann via Sourcemaps (@apps/hash-ai-worker-ts) #45329
Preview – petrinaut-docs — f4e5cba1 Deployed Nov 16, 2026 by vercel[bot]
Preview – petrinaut — f4e5cba1 Deployed Nov 16, 2026 by vercel[bot]
Preview – hash — b7fb51f3 Deployed Nov 16, 2026 by vercel[bot]
Preview – hashdotdesign-tokens — b7fb51f3 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants