hash
hash copied to clipboard
H-4823: Read policies for actors filtered by actions
🌟 What is the purpose of this PR?
We typically only need a few policies based on the actions we're going to do.
🔍 What does this change?
- Add functions to allow adding actions to the policy components
- The actions are persisted in the policy set, so if a request with a different action is being issued, it will fail if the action was not previously used. This helps in tracking issues, e.g. when it was forgotten to request the
instantiatepolicy and the request evaluates to "cannot instantiate" it is hard to track down why a user may cannot instantiate an entity type. With tracked actions there is a clear error message that theinstantiateaction was not tracked at all
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
Codecov Report
Attention: Patch coverage is 8.88889% with 82 lines in your changes missing coverage. Please review.
Project coverage is 52.69%. Comparing base (
4caeded) to head (6888992). Report is 3 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #7453 +/- ##
==========================================
- Coverage 52.70% 52.69% -0.01%
==========================================
Files 1080 1080
Lines 95588 95632 +44
Branches 4430 4431 +1
==========================================
+ Hits 50381 50396 +15
- Misses 44258 44286 +28
- Partials 949 950 +1
| Flag | Coverage Δ | |
|---|---|---|
| apps.hash-ai-worker-ts | 1.32% <ø> (ø) |
|
| apps.hash-api | 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.43% <0.00%> (ø) |
|
| rust.hash-graph-authorization | 30.37% <19.04%> (+0.07%) |
:arrow_up: |
| rust.hash-graph-postgres-store | 19.44% <0.00%> (-0.02%) |
:arrow_down: |
| rust.hash-graph-store | 29.94% <ø> (ø) |
|
| 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.
Benchmark results
@rust/hash-graph-benches – Integrations
scaling_read_entity_linkless
| Function | Value | Mean | Flame graphs |
|---|---|---|---|
| entity_by_id | 1 entities | $$5.52 \mathrm{ms} \pm 21.8 \mathrm{μs}\left({\color{lightgreen}-31.906 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 10 entities | $$5.60 \mathrm{ms} \pm 22.9 \mathrm{μs}\left({\color{lightgreen}-31.135 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 10000 entities | $$13.5 \mathrm{ms} \pm 118 \mathrm{μs}\left({\color{lightgreen}-13.349 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 100 entities | $$6.00 \mathrm{ms} \pm 36.0 \mathrm{μs}\left({\color{lightgreen}-28.497 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 1000 entities | $$6.67 \mathrm{ms} \pm 34.5 \mathrm{μs}\left({\color{lightgreen}-25.548 \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.75 \mathrm{ms} \pm 28.2 \mathrm{μs}\left({\color{lightgreen}-30.791 \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 | $$57.8 \mathrm{ms} \pm 298 \mathrm{μs}\left({\color{lightgreen}-5.969 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_property | depths: DT=0, PT=0, ET=2, E=2 | $$52.8 \mathrm{ms} \pm 350 \mathrm{μs}\left({\color{lightgreen}-6.321 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_property | depths: DT=0, PT=0, ET=0, E=2 | $$47.8 \mathrm{ms} \pm 311 \mathrm{μs}\left({\color{lightgreen}-5.842 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_property | depths: DT=0, PT=0, ET=0, E=0 | $$43.7 \mathrm{ms} \pm 360 \mathrm{μs}\left({\color{gray}-4.209 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_property | depths: DT=255, PT=255, ET=255, E=255 | $$72.4 \mathrm{ms} \pm 764 \mathrm{μs}\left({\color{gray}-3.030 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_property | depths: DT=2, PT=2, ET=2, E=2 | $$62.1 \mathrm{ms} \pm 661 \mathrm{μs}\left({\color{lightgreen}-5.181 \mathrm{\%}}\right) $$ | Flame Graph |
| link_by_source_by_property | depths: DT=0, PT=2, ET=2, E=2 | $$93.5 \mathrm{ms} \pm 510 \mathrm{μs}\left({\color{lightgreen}-5.582 \mathrm{\%}}\right) $$ | Flame Graph |
| link_by_source_by_property | depths: DT=0, PT=0, ET=2, E=2 | $$88.7 \mathrm{ms} \pm 339 \mathrm{μs}\left({\color{lightgreen}-6.315 \mathrm{\%}}\right) $$ | Flame Graph |
| link_by_source_by_property | depths: DT=0, PT=0, ET=0, E=2 | $$79.8 \mathrm{ms} \pm 582 \mathrm{μs}\left({\color{lightgreen}-5.051 \mathrm{\%}}\right) $$ | Flame Graph |
| link_by_source_by_property | depths: DT=0, PT=0, ET=0, E=0 | $$43.9 \mathrm{ms} \pm 320 \mathrm{μs}\left({\color{lightgreen}-7.430 \mathrm{\%}}\right) $$ | Flame Graph |
| link_by_source_by_property | depths: DT=255, PT=255, ET=255, E=255 | $$107 \mathrm{ms} \pm 562 \mathrm{μs}\left({\color{gray}-4.224 \mathrm{\%}}\right) $$ | Flame Graph |
| link_by_source_by_property | depths: DT=2, PT=2, ET=2, E=2 | $$96.2 \mathrm{ms} \pm 582 \mathrm{μs}\left({\color{lightgreen}-7.019 \mathrm{\%}}\right) $$ | Flame Graph |
scaling_read_entity_complete_one_depth
| Function | Value | Mean | Flame graphs |
|---|---|---|---|
| entity_by_id | 50 entities | $$283 \mathrm{ms} \pm 1.63 \mathrm{ms}\left({\color{gray}0.357 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 1 entities | $$24.8 \mathrm{ms} \pm 124 \mathrm{μs}\left({\color{lightgreen}-10.516 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 10 entities | $$61.7 \mathrm{ms} \pm 314 \mathrm{μs}\left({\color{gray}-2.914 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 5 entities | $$30.9 \mathrm{ms} \pm 105 \mathrm{μs}\left({\color{lightgreen}-9.361 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 25 entities | $$90.2 \mathrm{ms} \pm 404 \mathrm{μs}\left({\color{lightgreen}-52.800 \mathrm{\%}}\right) $$ | Flame Graph |
scaling_read_entity_complete_zero_depth
| Function | Value | Mean | Flame graphs |
|---|---|---|---|
| entity_by_id | 50 entities | $$8.79 \mathrm{ms} \pm 81.0 \mathrm{μs}\left({\color{lightgreen}-19.304 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 1 entities | $$5.56 \mathrm{ms} \pm 27.9 \mathrm{μs}\left({\color{lightgreen}-30.906 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 10 entities | $$5.77 \mathrm{ms} \pm 30.3 \mathrm{μs}\left({\color{lightgreen}-30.624 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 5 entities | $$5.54 \mathrm{ms} \pm 38.5 \mathrm{μs}\left({\color{lightgreen}-32.173 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | 25 entities | $$6.72 \mathrm{ms} \pm 88.6 \mathrm{μs}\left({\color{lightgreen}-28.204 \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/song/v/1 |
$$20.1 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{lightgreen}-13.694 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 |
$$20.2 \mathrm{ms} \pm 198 \mathrm{μs}\left({\color{lightgreen}-33.192 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 |
$$21.6 \mathrm{ms} \pm 205 \mathrm{μs}\left({\color{lightgreen}-10.620 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 |
$$20.9 \mathrm{ms} \pm 262 \mathrm{μs}\left({\color{lightgreen}-29.893 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 |
$$21.6 \mathrm{ms} \pm 183 \mathrm{μs}\left({\color{lightgreen}-8.824 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 |
$$21.3 \mathrm{ms} \pm 222 \mathrm{μs}\left({\color{lightgreen}-7.595 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 |
$$20.8 \mathrm{ms} \pm 240 \mathrm{μs}\left({\color{lightgreen}-11.670 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 |
$$22.8 \mathrm{ms} \pm 249 \mathrm{μs}\left({\color{lightgreen}-24.462 \mathrm{\%}}\right) $$ | Flame Graph |
| entity_by_id | entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 |
$$19.5 \mathrm{ms} \pm 239 \mathrm{μs}\left({\color{lightgreen}-15.939 \mathrm{\%}}\right) $$ | Flame Graph |