Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-2206, H-2242: Support entities with multiple types in frontend, everywhere else #5312

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

CiaranMn
Copy link
Member

@CiaranMn CiaranMn commented Oct 4, 2024

🌟 What is the purpose of this PR?

Following work to enable entities to have multiple types in #4140, this PR adds support for multi-type entities to the rest of the application.

🚫 Blocked by

To be addressed before merging:

  • H-3379: Because changes to types (adding, upgrading) happen as soon as the user confirms them, rather than being part of the 'local draft changes', it's impossible to add some entity types to entities if they introduce new requirements (e.g. new required property), because there is no facility to make a type change and property changes at the same time. The ticket is to bring type changes into the same pool of local draft changes as property/link changes, so that users can create an update which both adds/upgrades a type and makes the entity valid for the change.
  • H-3410: Allow setting multiple types on an entity before it's even created (blocked by H-3379)

🔍 What does this change?

  • TODO

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

📜 Does this require a change to the docs?

  • The changes in this PR are internal and do not require a docs change

🕸️ 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

To be addressed post-merge:

  1. H-3408: When a user wants to add/remove/upgrade a type, show the difference in properties/links it would create, and flag any blocking changes they need to make to properties/links to be able to create the update – currently, it's not possible to tell what needs to be fixed if anything is blocking the change.
  2. H-1834: Highlight validation errors in the form UI when attempting to submit an update to an entity, so that users know progressively what remains to be fixed (rather than just the initial list of changes based on types which (1) above implies)

🐾 Next steps

Fix the above known issues.

🛡 What tests cover this?

  • TODO

❓ How to test this?

  1. Can only be tested locally as it depends on changes to the Node API

📹 Demo

TODO

@github-actions github-actions bot added area/apps > hash* Affects HASH (a `hash-*` app) area/infra Relates to version control, CI, CD or IaC (area) area/apps > hash-api Affects the HASH API (app) area/apps > hash.dev Affects the `hash.dev` developer site (app) labels Oct 4, 2024
@github-actions github-actions bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team type/eng > backend Owned by the @backend team area/tests New or updated tests area/tests > integration New or updated integration tests area/tests > playwright New or updated Playwright tests area/apps labels Oct 4, 2024
@@ -108,28 +107,12 @@ export function generateEntityLabel(
);
}
Copy link

Choose a reason for hiding this comment

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

Error messages with stack traces may expose sensitive information about the application.

Ignore this finding from generic_error_disclosure.

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 0.60976% with 163 lines in your changes missing coverage. Please review.

Project coverage is 20.18%. Comparing base (a824cd9) to head (b5d0835).
Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
...ed/migrate-ontology-types/util/upgrade-entities.ts 0.00% 22 Missing ⚠️
...i/src/graph/knowledge/system-types/notification.ts 0.00% 22 Missing ⚠️
...-activities/shared/propose-entities-from-claims.ts 0.00% 15 Missing ⚠️
...r-ts/src/activities/shared/find-existing-entity.ts 0.00% 15 Missing ⚠️
.../@local/hash-backend-utils/src/simplified-graph.ts 0.00% 12 Missing ⚠️
...s/hash-api/src/graph/knowledge/primitive/entity.ts 0.00% 7 Missing ⚠️
...ties-action/shared/simplify-for-llm-consumption.ts 0.00% 5 Missing ⚠️
...es-from-claims/propose-entity-from-claims-agent.ts 0.00% 5 Missing ⚠️
apps/hash-api/src/integrations/linear/sync-back.ts 0.00% 5 Missing ⚠️
...ivities/flow-activities/persist-entities-action.ts 0.00% 4 Missing ⚠️
... and 31 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5312      +/-   ##
==========================================
- Coverage   20.23%   20.18%   -0.05%     
==========================================
  Files         508      508              
  Lines       17260    17295      +35     
  Branches     2537     2538       +1     
==========================================
- Hits         3492     3491       -1     
- Misses      13730    13766      +36     
  Partials       38       38              
Flag Coverage Δ
apps.hash-ai-worker-ts 1.38% <0.00%> (-0.01%) ⬇️
apps.hash-api 1.19% <0.00%> (-0.01%) ⬇️
blockprotocol.type-system 47.40% <20.00%> (-1.06%) ⬇️
local.hash-backend-utils 8.79% <0.00%> (-0.03%) ⬇️
local.hash-isomorphic-utils 1.07% <0.00%> (+<0.01%) ⬆️
local.hash-subgraph 24.54% <ø> (+0.22%) ⬆️

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

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

Copy link
Contributor

github-actions bot commented Oct 4, 2024

Benchmark results

@rust/graph-benches – Integrations

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$53.5 \mathrm{ms} \pm 280 \mathrm{μs}\left({\color{gray}-0.263 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$49.0 \mathrm{ms} \pm 242 \mathrm{μs}\left({\color{gray}-0.690 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$42.5 \mathrm{ms} \pm 235 \mathrm{μs}\left({\color{gray}-0.462 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$67.1 \mathrm{ms} \pm 365 \mathrm{μs}\left({\color{gray}-0.207 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$58.4 \mathrm{ms} \pm 491 \mathrm{μs}\left({\color{gray}0.399 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$38.6 \mathrm{ms} \pm 297 \mathrm{μs}\left({\color{gray}0.373 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$93.0 \mathrm{ms} \pm 602 \mathrm{μs}\left({\color{gray}-0.161 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$88.1 \mathrm{ms} \pm 450 \mathrm{μs}\left({\color{gray}-0.784 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$78.7 \mathrm{ms} \pm 444 \mathrm{μs}\left({\color{gray}0.091 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$106 \mathrm{ms} \pm 737 \mathrm{μs}\left({\color{gray}-0.212 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$97.0 \mathrm{ms} \pm 463 \mathrm{μs}\left({\color{gray}-0.719 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$41.0 \mathrm{ms} \pm 362 \mathrm{μs}\left({\color{gray}0.227 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$14.6 \mathrm{ms} \pm 169 \mathrm{μs}\left({\color{gray}-3.940 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$17.0 \mathrm{ms} \pm 200 \mathrm{μs}\left({\color{gray}0.578 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$15.9 \mathrm{ms} \pm 193 \mathrm{μs}\left({\color{lightgreen}-33.431 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.6 \mathrm{ms} \pm 229 \mathrm{μs}\left({\color{gray}3.18 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$16.7 \mathrm{ms} \pm 238 \mathrm{μs}\left({\color{lightgreen}-9.692 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$16.3 \mathrm{ms} \pm 208 \mathrm{μs}\left({\color{gray}0.756 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$15.3 \mathrm{ms} \pm 193 \mathrm{μs}\left({\color{lightgreen}-36.916 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$17.8 \mathrm{ms} \pm 245 \mathrm{μs}\left({\color{red}7.57 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.4 \mathrm{ms} \pm 223 \mathrm{μs}\left({\color{gray}1.00 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: d4e16033-c281-4cde-aa35-9085bf2e7579 $$1.42 \mathrm{ms} \pm 6.19 \mathrm{μs}\left({\color{gray}0.268 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$2.06 \mathrm{ms} \pm 7.91 \mathrm{μs}\left({\color{gray}0.974 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$2.77 \mathrm{ms} \pm 80.8 \mathrm{μs}\left({\color{gray}2.87 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.90 \mathrm{ms} \pm 12.3 \mathrm{μs}\left({\color{gray}-1.360 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$4.04 \mathrm{ms} \pm 23.8 \mathrm{μs}\left({\color{gray}-2.011 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.87 \mathrm{ms} \pm 11.1 \mathrm{μs}\left({\color{gray}-1.331 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 10 entities $$50.9 \mathrm{ms} \pm 200 \mathrm{μs}\left({\color{red}59.5 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$72.2 \mathrm{ms} \pm 434 \mathrm{μs}\left({\color{gray}-3.767 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$24.9 \mathrm{ms} \pm 221 \mathrm{μs}\left({\color{gray}-1.319 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$267 \mathrm{ms} \pm 2.24 \mathrm{ms}\left({\color{lightgreen}-82.375 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.7 \mathrm{ms} \pm 68.3 \mathrm{μs}\left({\color{gray}-1.872 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 10000 entities $$12.3 \mathrm{ms} \pm 140 \mathrm{μs}\left({\color{red}36.7 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.87 \mathrm{ms} \pm 6.29 \mathrm{μs}\left({\color{gray}-1.326 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.01 \mathrm{ms} \pm 10.1 \mathrm{μs}\left({\color{gray}-1.577 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.73 \mathrm{ms} \pm 21.0 \mathrm{μs}\left({\color{lightgreen}-14.491 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.85 \mathrm{ms} \pm 6.18 \mathrm{μs}\left({\color{gray}-1.517 \mathrm{\%}}\right) $$ Flame Graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apps > hash.dev Affects the `hash.dev` developer site (app) area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests > integration New or updated integration tests area/tests > playwright New or updated Playwright tests area/tests New or updated tests 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.

1 participant