Skip to content

BE-610: Add migration for generic supply chain ontology#8872

Open
thehabbos007 wants to merge 10 commits into
mainfrom
asa/supply-chain
Open

BE-610: Add migration for generic supply chain ontology#8872
thehabbos007 wants to merge 10 commits into
mainfrom
asa/supply-chain

Conversation

@thehabbos007

@thehabbos007 thehabbos007 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🌟 What is the purpose of this PR?

This PR adds new ontology types for supply chains. I have moved some ontology types that were in the aviation migration, as they are now useful for concepts of the ontology here. A rundown:

Entity types (23)

Company  ·  Customer  ·  Vendor  ·  Material  ·  Site  ·  Batch
Bill of Materials  ·  Bill of Materials Item
Sales Order  ·  Sales Order Item
Purchase Order  ·  Purchase Order Item  ·  Purchase Order Schedule Line
Production Order  ·  Production Order Item
Delivery  ·  Delivery Item
Shipment  ·  Shipment Item
Material Document  ·  Material Reservation  ·  Material Valuation  ·  Site Material Data
(Company is the abstract parent of Customer/Vendor.)

Link types (19), forward (inverse)

Has Line Item     (Line Item Of)
Has Customer      (Customer For)
Has Vendor        (Vendor For)
Has Material      (Material For)
Of Material       (Makes up)
Located At        (Location For)
Produces          (Produced By)
Consumes          (Consumed By)
Procures          (Procured By)
Yields            (Yielded By)
Moves             (Moved By)
Records           (Recorded By)
Fulfills          (Fulfilled By)
Delivers          (Delivered By)
Transports        (Transported By)
Departs From      (Departure For)
Arrives At        (Arrival For)
Posted Against    (Has Posting)
References        (Referenced By)

🔗 Related links

🚫 Blocked by

🔍 What does this change?

  • Adds new graph/api migrations for new ontology concepts
  • Adds icons for new types

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing
  • [] modifies an npm-publishable library and I have added a changeset file(s)
  • [] modifies a Cargo-publishable library and I have amended the version
  • [] modifies a Cargo-publishable library, but it is not yet ready to publish
  • [] modifies a block that will need publishing via GitHub action once merged
  • [] I am unsure / need advice

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change
  • [] are in a state where docs changes are not yet required but will be
  • [] require changes to docs which are made as part of this PR
  • [] require changes to docs which are not made in this PR
    • Provide more detail here
  • [] I am unsure / need advice

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph
  • [] affected the execution graph, and the turbo.json's have been updated to reflect this
  • [] I am unsure / need advice

⚠️ Known issues

🐾 Next steps

🛡 What tests cover this?

❓ How to test this?

  1. Checkout the branch
  2. run the system with the graph running to inspect new types

📹 Demo

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

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

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
hash Ignored Ignored Preview Jun 26, 2026 5:27pm
hashdotdesign-tokens Ignored Ignored Preview Jun 26, 2026 5:27pm
petrinaut Skipped Skipped Jun 26, 2026 5:27pm

@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) type/eng > backend Owned by the @backend team area/apps labels Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 237 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.24%. Comparing base (882e794) to head (bedc578).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...migrations/026-add-supply-chain-types.migration.ts 0.00% 228 Missing ⚠️
...s/025-add-initial-currency-data-types.migration.ts 0.00% 8 Missing ⚠️
...s-initialized/migrate-ontology-types/currencies.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8872      +/-   ##
==========================================
- Coverage   59.76%   59.24%   -0.53%     
==========================================
  Files        1348     1349       +1     
  Lines      131817   130165    -1652     
  Branches     5944     5898      -46     
==========================================
- Hits        78784    77115    -1669     
- Misses      52125    52142      +17     
  Partials      908      908              
Flag Coverage Δ
apps.hash-api 3.12% <0.00%> (-0.15%) ⬇️

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 June 25, 2026 10:08 Inactive
@github-actions github-actions Bot added the type/eng > frontend Owned by the @frontend team label Jun 25, 2026
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 25, 2026 15:46 Inactive
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 26, 2026 09:51 Inactive
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 26, 2026 10:58 Inactive
@thehabbos007 thehabbos007 marked this pull request as ready for review June 26, 2026 11:02
Copilot AI review requested due to automatic review settings June 26, 2026 11:02
@cursor

cursor Bot commented Jun 26, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Large additive system-graph ontology migrations run on init and permanently extend the shared type catalog; wrong ordering or partial runs could break migration 026, but changes use create-if-not-exists patterns rather than altering existing types.

Overview
Adds system ontology migrations for generic supply-chain modeling and expands currency support beyond the old dev-only USD/GBP/EUR seed.

Migration 025 introduces a shared activeCurrencies ISO 4217 list and seeds an abstract Currency data type plus one child data type per active code (display symbols for USD, GBP, EUR, JPY, CNY, INR). The previous 087-add-initial-currency-data-types.dev.migration is removed in favor of this production migration.

Migration 026 is a large additive seed: measure data types (mass/volume/area/duration with conversions), quantity and currency-backed property types, ~19 link types, and entity types spanning Company/Customer/Vendor, Material, Site, Batch, orders (sales/purchase/production), BOM, Delivery, Shipment, Material Document, valuations, site material planning, and reservations—with links wiring fulfillment, movement, and logistics flows. It requires migration 025’s currency types (fails fast if a currency data type is missing).

Frontend adds SVG icons under public/icons/types/ for the new entity/link visuals.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f3d0a8a. Configure here.

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.

Pull request overview

Adds system ontology migrations to seed a generic supply-chain ontology (entity + link types) along with currency data types, and introduces new frontend SVG icons used by those types.

Changes:

  • Added 025 migration to seed a Currency abstract data type plus one data type per ISO 4217 currency code.
  • Added 026 migration to create supply-chain entity/link types and supporting property/data types.
  • Added multiple new SVG icons for the new ontology types, and removed the older dev-only currency seeding migration.

Reviewed changes

Copilot reviewed 4 out of 25 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
apps/hash-frontend/public/icons/types/warehouse.svg New icon for Site / warehouse-related types
apps/hash-frontend/public/icons/types/user-tag.svg New icon for Customer-related types
apps/hash-frontend/public/icons/types/truck.svg New icon for Delivery-related types
apps/hash-frontend/public/icons/types/truck-ramp-box.svg New icon for Delivery Item / handling-related types
apps/hash-frontend/public/icons/types/truck-container.svg New icon for Shipment / transport-related types
apps/hash-frontend/public/icons/types/receipt.svg New icon for Sales Order Item
apps/hash-frontend/public/icons/types/list-tree.svg New icon for Bill of Materials
apps/hash-frontend/public/icons/types/list-ol.svg New icon for Bill of Materials Item
apps/hash-frontend/public/icons/types/industry.svg New icon for production/industry concepts
apps/hash-frontend/public/icons/types/handshake.svg New icon for Vendor-related types
apps/hash-frontend/public/icons/types/file-invoice.svg New icon for Purchase Order
apps/hash-frontend/public/icons/types/file-invoice-dollar.svg New icon for Sales Order
apps/hash-frontend/public/icons/types/coins.svg New icon for Material Valuation
apps/hash-frontend/public/icons/types/clipboard-list.svg New icon for record/list concepts
apps/hash-frontend/public/icons/types/clipboard-check.svg New icon for posting/check concepts
apps/hash-frontend/public/icons/types/calendar-days.svg New icon for schedule-line concepts
apps/hash-frontend/public/icons/types/building.svg New icon for Company
apps/hash-frontend/public/icons/types/boxes-stacked.svg New icon for Batch
apps/hash-frontend/public/icons/types/boxes-packing.svg New icon for yield/packing concepts
apps/hash-frontend/public/icons/types/box.svg New icon for Material
apps/hash-frontend/public/icons/types/arrows-rotate.svg New icon for Material Document / movement concepts
apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/087-add-initial-currency-data-types.dev.migration.ts Removed dev-only currency seeding migration (superseded by 025)
apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/026-add-supply-chain-types.migration.ts Adds supply-chain ontology types (entity/link/property/data types)
apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/025-add-initial-currency-data-types.migration.ts Adds currency data types seeded from activeCurrencies
apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/currencies.ts New ISO 4217 currency list used by migration(s)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +55
for (const { code, name } of activeCurrencies) {
const symbol = currencySymbols[code];
await createSystemDataTypeIfNotExists(context, authentication, {
dataTypeDefinition: {
allOf: [{ $ref: currencyDataType.schema.$id }],
title: code,
description: `An amount denominated in ${name} (ISO 4217 ${code}).`,
type: "number",
...(symbol ? { label: { left: symbol } } : {}),
},
conversions: {},
webShortname: "h",
migrationState,
});
}
Comment on lines +1060 to +1064
"Has Line Item",
"Line Item Of",
"A line item that something has.",
"/icons/types/list-ul.svg",
);
Comment on lines +1084 to +1088
"Fulfills",
"Fulfilled By",
"Something that something fulfills.",
"/icons/types/check-double.svg",
);
Comment on lines +1090 to +1094
"Located At",
"Location For",
"The site where something is located or takes place.",
"/icons/types/location-dot.svg",
);
Comment on lines +1102 to +1106
"Consumes",
"Consumed By",
"Something consumed by something.",
"/icons/types/arrow-down-to-bracket.svg",
);
Comment on lines +1108 to +1112
"Procures",
"Procured By",
"Something procured by something.",
"/icons/types/cart-shopping.svg",
);
Comment on lines +1114 to +1118
"Moves",
"Moved By",
"Something moved by something.",
"/icons/types/arrows-turn-to-dots.svg",
);
Comment on lines +1151 to +1155
"Departs From",
"Departure For",
"Something from which something departs.",
"/icons/types/arrow-right-from-bracket.svg",
);
Comment on lines +1157 to +1161
"Arrives At",
"Arrival For",
"Something at which something arrives.",
"/icons/types/arrow-right-to-bracket.svg",
);
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 26, 2026 13:44 Inactive
Copilot AI review requested due to automatic review settings June 26, 2026 17:25
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 26, 2026 17:25 Inactive
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 26, 2026 17:26 Inactive

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.

Pull request overview

Copilot reviewed 4 out of 33 changed files in this pull request and generated 3 comments.

Comment on lines +1174 to +1179
const postedAgainstLink = await link(
"Posted Against",
"Has Posting",
"Something a posting or movement is recorded against, such as the order or document it fulfils.",
"/icons/types/clipboard-check.svg",
);
"A good or material that can be produced, stored, sold, or procured, including raw materials, intermediates, and finished goods.",
labelProperty: blockProtocolPropertyTypes.name.propertyTypeBaseUrl,
properties: [
{ propertyType: blockProtocolPropertyTypes.name.propertyTypeId },
"A physical site, such as a plant, warehouse, or distribution hub, where goods are produced, stored, or shipped.",
labelProperty: blockProtocolPropertyTypes.name.propertyTypeBaseUrl,
properties: [
{ propertyType: blockProtocolPropertyTypes.name.propertyTypeId },
Copilot AI review requested due to automatic review settings June 26, 2026 17:32

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

4 participants