hash icon indicating copy to clipboard operation
hash copied to clipboard

H-4727: Remove usage of `viewer` and `viewFromWeb` relationships

Open TimDiekmann opened this issue 7 months ago • 2 comments

🌟 What is the purpose of this PR?

When the new policy engine is used, we don't need the old relationships. However, this was not done in a single PR so we have some time where both, the policies and relationships are maintained. In the case something goes wrong with the policies and we need to revert the policy PR, we still have a working permission system.

🚫 Blockers

  • #7352

🔍 What does this change?

Remove

  • viewer and viewFromWeb entity relationships
  • modification of entity owner/admins
  • reading entity relationships

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • [x] 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:

  • [x] are internal and do not require a docs change

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

The changes in this PR:

  • [x] do not affect the execution graph

TimDiekmann avatar Jun 06 '25 10:06 TimDiekmann

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 52.57%. Comparing base (f732535) to head (e3da6c8). Report is 53 commits behind head on main.

Files with missing lines Patch % Lines
...i/src/graphql/resolvers/knowledge/entity/entity.ts 0.00% 6 Missing :warning:
apps/hash-api/src/graphql/resolvers/index.ts 0.00% 5 Missing :warning:
libs/@local/graph/api/src/rest/entity.rs 0.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7351      +/-   ##
==========================================
- Coverage   53.14%   52.57%   -0.57%     
==========================================
  Files        1080     1078       -2     
  Lines       95837    94685    -1152     
  Branches     4439     4395      -44     
==========================================
- Hits        50930    49783    -1147     
- Misses      43949    43971      +22     
+ Partials      958      931      -27     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.32% <ø> (+<0.01%) :arrow_up:
apps.hash-api 0.00% <0.00%> (ø)
local.hash-backend-utils 3.68% <ø> (ø)
local.hash-graph-sdk 0.00% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 3.61% <0.00%> (+0.17%) :arrow_up:
rust.hash-graph-authorization 32.70% <ø> (+0.37%) :arrow_up:
rust.hash-graph-postgres-store 20.03% <ø> (ø)
rust.hash-graph-store 36.79% <ø> (ø)
rust.hash-graph-validation 83.30% <ø> (ø)

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Jun 06 '25 11:06 codecov[bot]

Benchmark results

@rust/hash-graph-benches – Integrations

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$15.7 \mathrm{ms} \pm 69.7 \mathrm{μs}\left({\color{gray}0.645 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$15.7 \mathrm{ms} \pm 64.2 \mathrm{μs}\left({\color{gray}0.683 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$22.8 \mathrm{ms} \pm 138 \mathrm{μs}\left({\color{gray}1.81 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$14.9 \mathrm{ms} \pm 76.6 \mathrm{μs}\left({\color{gray}-0.123 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$15.4 \mathrm{ms} \pm 72.5 \mathrm{μs}\left({\color{gray}-0.783 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$5.93 \mathrm{ms} \pm 19.8 \mathrm{μs}\left({\color{gray}-0.752 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$121 \mathrm{ms} \pm 641 \mathrm{μs}\left({\color{gray}0.357 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$112 \mathrm{ms} \pm 630 \mathrm{μs}\left({\color{gray}-0.685 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$106 \mathrm{ms} \pm 416 \mathrm{μs}\left({\color{gray}-2.226 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$96.5 \mathrm{ms} \pm 568 \mathrm{μs}\left({\color{gray}-0.923 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$133 \mathrm{ms} \pm 608 \mathrm{μs}\left({\color{gray}-1.075 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$122 \mathrm{ms} \pm 763 \mathrm{μs}\left({\color{gray}-0.614 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$212 \mathrm{ms} \pm 1.17 \mathrm{ms}\left({\color{gray}-0.909 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$205 \mathrm{ms} \pm 943 \mathrm{μs}\left({\color{gray}-1.765 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$198 \mathrm{ms} \pm 1.22 \mathrm{ms}\left({\color{gray}-1.234 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$146 \mathrm{ms} \pm 625 \mathrm{μs}\left({\color{gray}-1.940 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$229 \mathrm{ms} \pm 1.50 \mathrm{ms}\left({\color{gray}-0.209 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$215 \mathrm{ms} \pm 892 \mathrm{μs}\left({\color{gray}-1.447 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$5.28 \mathrm{s} \pm 588 \mathrm{ms}\left({\color{red}1348 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$72.3 \mathrm{ms} \pm 436 \mathrm{μs}\left({\color{gray}-0.415 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$117 \mathrm{ms} \pm 383 \mathrm{μs}\left({\color{gray}-1.198 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$85.5 \mathrm{ms} \pm 909 \mathrm{μs}\left({\color{gray}2.26 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$248 \mathrm{ms} \pm 1.42 \mathrm{ms}\left({\color{gray}-2.267 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 50 entities $$18.7 \mathrm{ms} \pm 77.6 \mathrm{μs}\left({\color{red}9.12 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$15.6 \mathrm{ms} \pm 70.3 \mathrm{μs}\left({\color{gray}-0.492 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$15.7 \mathrm{ms} \pm 94.5 \mathrm{μs}\left({\color{gray}0.797 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$14.8 \mathrm{ms} \pm 68.4 \mathrm{μs}\left({\color{gray}0.510 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 25 entities $$16.5 \mathrm{ms} \pm 79.4 \mathrm{μs}\left({\color{gray}-4.761 \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 $$30.4 \mathrm{ms} \pm 308 \mathrm{μs}\left({\color{gray}2.56 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$29.6 \mathrm{ms} \pm 294 \mathrm{μs}\left({\color{gray}-3.104 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$30.1 \mathrm{ms} \pm 261 \mathrm{μs}\left({\color{gray}-0.356 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$29.7 \mathrm{ms} \pm 314 \mathrm{μs}\left({\color{gray}-1.326 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$30.1 \mathrm{ms} \pm 249 \mathrm{μs}\left({\color{gray}1.36 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$29.8 \mathrm{ms} \pm 256 \mathrm{μs}\left({\color{gray}-0.227 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$29.7 \mathrm{ms} \pm 276 \mathrm{μs}\left({\color{gray}0.315 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$28.9 \mathrm{ms} \pm 241 \mathrm{μs}\left({\color{lightgreen}-5.354 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$29.2 \mathrm{ms} \pm 260 \mathrm{μs}\left({\color{gray}-2.873 \mathrm{\%}}\right) $$ Flame Graph

github-actions[bot] avatar Jun 30 '25 08:06 github-actions[bot]

Superseded by https://github.com/hashintel/hash/pull/7587

TimDiekmann avatar Jul 08 '25 22:07 TimDiekmann