Skip to content

BE-1233: Add the hash-queue crate for RabbitMQ jobs and an entity embedding worker - #10700

Draft
petscheit wants to merge 8 commits into
fs/be-1250-send-signed-webhooks-to-subscriber-endpoints-overfrom
pe/be-1233-graph-change-publishing
Draft

petscheit wants to merge 8 commits into
fs/be-1250-send-signed-webhooks-to-subscriber-endpoints-overfrom
pe/be-1233-graph-change-publishing

Conversation

@petscheit

Copy link
Copy Markdown
Contributor

Purpose

Graph changes have to reach consumers outside the graph: webhook delivery, workflow triggers and entity embeddings. Today the graph starts an embedding workflow directly on every write. This PR adds hash-queue, a crate for RabbitMQ job queues with delayed retries, and a first consumer of it: an embedding worker that starts one embedding workflow per batch of entities instead of one per write.

Changes

  • hash-queue defines a queue as a job type with a Queue implementation. Broker::publish sends a job, Broker::consume runs a handler on it. The README describes the topology.
    • Every queue is a durable quorum queue with one retry queue per delay and a parking queue. A failed job waits in the retry queue for its delay, then returns to the work queue. After its last retry it is published as failed.<queue>, so other queues can bind to it.
    • A queue can set a BatchPolicy: the most jobs in a batch and the longest a batch waits. A batch has one outcome, but each job keeps its own retry count.
    • Broker::with_consumer_priority lets one worker's batches fill before the next worker receives jobs.
  • There are three queues: webhook.delivery and temporal.trigger, which are placeholders for now, and embedding.entity.
  • hash-graph embedding-worker consumes embedding.entity in batches of up to 500 and starts updateEntityEmbeddings once per actor in a batch. It needs RabbitMQ and Temporal, not Postgres, so it can run and scale on its own.
  • Each queue has a producer and consumer example under examples, with a README on how to run it against the RabbitMQ in compose.yml.

Known issues

  • The graph does not publish embedding.entity jobs yet. It still starts embedding workflows itself, and only the example producer publishes jobs.
  • Which actor embeddings run as is still open. The job carries the writer for now, and a TODO records it.
  • A retried job returns behind newer jobs, and competing consumers can handle two jobs for the same entity at once. Jobs for one entity can therefore be handled out of order, which webhook delivery cannot accept. That needs its own design.

@petscheit petscheit self-assigned this Dec 3, 2026
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
petrinaut Ready Ready Preview Dec 3, 2026 1:38pm UTC
3 Skipped Deployments
Project Deployment Actions Updated
hash Ignored Ignored Preview Dec 3, 2026 1:38pm UTC
hashdotdesign-tokens Ignored Ignored Preview Dec 3, 2026 1:38pm UTC
petrinaut-docs Ignored Ignored Preview Dec 3, 2026 1:38pm UTC

Request Review

@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/apps > hash* Affects HASH (a `hash-*` app) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/apps area/apps > hash-graph labels Dec 3, 2026
@petscheit
petscheit added this pull request to stack #10688 December 3, 2026 09:22
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.38%. Comparing base (a4f3449) to head (2f2a436).

Files with missing lines Patch % Lines
apps/hash-graph/src/subcommand/embedding_worker.rs 0.00% 21 Missing ⚠️
apps/hash-graph/src/subcommand/mod.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@                                      Coverage Diff                                       @@
##           fs/be-1250-send-signed-webhooks-to-subscriber-endpoints-over   #10700    +/-   ##
==============================================================================================
  Coverage                                                         70.37%   70.38%            
==============================================================================================
  Files                                                              2138     2141     +3     
  Lines                                                            226210   226436   +226     
  Branches                                                           9801     9820    +19     
==============================================================================================
+ Hits                                                             159205   159381   +176     
- Misses                                                            64953    65004    +51     
+ Partials                                                           2052     2051     -1     
Flag Coverage Δ
apps.hash-ai-worker-ts 9.72% <ø> (ø)
apps.hash-api 25.11% <ø> (-0.15%) ⬇️
blockprotocol.type-system 41.73% <ø> (ø)
harpc-codec 84.61% <ø> (ø)
harpc-net 96.28% <ø> (+0.01%) ⬆️
harpc-tower 67.97% <ø> (ø)
harpc-types 0.00% <ø> (ø)
harpc-wire-protocol 93.85% <ø> (ø)
hash-codec 72.75% <ø> (ø)
hash-graph 21.14% <0.00%> (-0.41%) ⬇️
hash-graph-api 48.63% <ø> (ø)
hash-graph-atlas 80.18% <ø> (+0.02%) ⬆️
hash-graph-audit 83.09% <ø> (ø)
hash-graph-authentication 96.83% <ø> (ø)
hash-graph-authorization 68.20% <ø> (ø)
hash-graph-embeddings 91.92% <ø> (ø)
hash-graph-postgres-store 31.19% <ø> (ø)
hash-graph-store 55.73% <ø> (ø)
hash-graph-temporal-versioning 50.53% <ø> (ø)
hash-graph-types 0.00% <ø> (ø)
hash-graph-validation 84.91% <ø> (ø)
hash-integrations-definition 93.70% <ø> (ø)
hash-integrations-engine 92.35% <ø> (ø)
hash-middleware 87.26% <ø> (ø)
hashql-ast 89.62% <ø> (ø)
hashql-compiletest 28.62% <ø> (ø)
hashql-core 84.68% <ø> (ø)
hashql-eval 81.56% <ø> (ø)
hashql-hir 89.95% <ø> (ø)
hashql-mir 87.34% <ø> (ø)
hashql-syntax-jexpr 92.26% <ø> (+0.21%) ⬆️
local.hash-backend-utils 28.97% <ø> (ø)
local.hash-graph-sdk 20.15% <ø> (ø)
local.hash-isomorphic-utils 45.34% <ø> (+1.07%) ⬆️

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.

Comment on lines +221 to +222
/// Run the worker that starts entity embedding workflows for batches of queued entities.
EmbeddingWorker(Box<EmbeddingWorkerArgs>),

@TimDiekmann TimDiekmann Dec 3, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For simplicity this week we can keep it here, but we should think about moving away from the monolithic binary.

.init();

let count = env::args().nth(1).map_or(
NonZeroU32::new(1_100).expect("the default job count should not be zero"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

1100 as the default job count?

Comment on lines +1 to +3
//! Consumes `embedding.entity` and nothing else. A batch holds up to 500 jobs, or the jobs that
//! arrived within 5 seconds of its first one. Handling a batch takes 2 seconds, which stands in for
//! starting its embedding workflows.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where do the numbers come from?

Comment on lines +31 to +36
/// The queue's name, which is also the routing key its jobs are published under.
const NAME: &'static str;
/// The wait before each retry. A job is attempted once more than there are delays.
const RETRY_DELAYS: &'static [Duration];
/// When a consumer of this queue hands jobs to its handler.
const BATCH: BatchPolicy = BatchPolicy::SINGLE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a specific reason why we use consts here instead of functions? Or do the name/relays needs to be static?

Comment thread Cargo.toml
jsonschema = { version = "0.51.0", default-features = false }
jsonwebtoken = { version = "10.3.0", default-features = false }
kiddo = { version = "6.0.0" }
lapin = { version = "4.13.0", default-features = false }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Without the default features, what TLS etc. is used?

@TimDiekmann
TimDiekmann marked this pull request as ready for review December 3, 2026 10:56
@TimDiekmann
TimDiekmann requested a review from a team as a code owner December 3, 2026 10:56
@TimDiekmann
TimDiekmann requested review from a team as code owners December 3, 2026 10:56
Copilot AI balanced review requested due to automatic review settings December 3, 2026 10:56
@veria-ai

veria-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

This PR adds the hash-queue crate for RabbitMQ-backed jobs and an entity embedding worker in the graph application. It also adds a RabbitMQ Compose configuration.

The worker accepts actor identity from job messages, allowing a publisher with broker credentials to select the graph identity used for entity reads and embedding updates. The Compose configuration also exposes a broker with default credentials to peers that can reach the developer host, enabling unauthorized job access and manipulation. Missing TLS support and a mutable broker image tag remain additional transport-protection and supply-chain concerns; no issues have been addressed yet.

Open issues (4)

Fixed/addressed: 0 · PR risk: 7/10

Reviews

@cursor

cursor Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Adds new async infrastructure (RabbitMQ) and a worker that batches and starts Temporal embedding workflows; production rollout and ordering/dedup behavior need care until publishers switch over.

Overview
Introduces hash-queue, a RabbitMQ-based job system with durable quorum queues, per-delay retry queues, dead-letter parking, optional batching, and consumer priority. A typed Queue trait drives topology declaration; Broker::publish / consume handle confirmed publish, batch assembly, retries, and failed.<queue> routing. Initial queues: webhook.delivery, temporal.trigger (placeholders), and embedding.entity (500-job / 5s batch policy).

Adds hash-graph embedding-worker: connects to RabbitMQ (HASH_RABBITMQ_URL) and Temporal, consumes embedding.entity batches, groups entities by actor, and starts updateEntityEmbeddings workflows (acks after workflow start, not after embeddings finish). Wired into workspace (lapin, hash-queue on hash-graph) plus local RabbitMQ compose.yml and producer/consumer examples.

Not in this PR: the graph API still does not enqueue embedding jobs—it still triggers workflows directly on write.

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

@TimDiekmann TimDiekmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The PR is currently failing a lot of CIs. I'd propose we unstack it until that is resolved so follow-up PRs don't get blocked on that.

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

Publisher confirms can ACK unroutable retries, causing permanent job loss when the original is acknowledged; mandatory publishing and returned-message failure handling are needed.

1 open issue
What changed in this PR

Adds RabbitMQ job infrastructure and a standalone worker that batches entity embedding requests into Temporal workflows. Graph writes still start workflows directly; queue publishing is not yet integrated.

Changes:

  • Introduces durable queues with delayed retries, parking, batching, and consumer priorities.
  • Adds an embedding worker that groups entities by actor.
  • Provides local RabbitMQ setup, examples, and documentation.
File Description
libs/​@local/​queue/​turbo.json Defines crate maintenance tasks.
libs/​@local/​queue/​src/​topology.rs Declares queues, routing, and batch policies.
libs/​@local/​queue/​src/​queues/​webhook_delivery.rs Defines placeholder webhook jobs.
libs/​@local/​queue/​src/​queues/​temporal_trigger.rs Defines placeholder workflow jobs.
libs/​@local/​queue/​src/​queues/​mod.rs Registers queue topology.
libs/​@local/​queue/​src/​queues/​entity_embedding.rs Defines embedding jobs and batching.
libs/​@local/​queue/​src/​lib.rs Exposes the queue API.
libs/​@local/​queue/​src/​error.rs Defines queue operation errors.
libs/​@local/​queue/​src/​broker.rs Implements publishing, consumption, and retries.
libs/​@local/​queue/​README.md Documents queue behavior and usage.
libs/​@local/​queue/​examples/​webhook-delivery/​README.md Explains the webhook example.
libs/​@local/​queue/​examples/​webhook-delivery/​producer.rs Publishes sample webhook jobs.
libs/​@local/​queue/​examples/​webhook-delivery/​consumer.rs Demonstrates retries and parking.
libs/​@local/​queue/​examples/​temporal-trigger/​README.md Explains the Temporal example.
libs/​@local/​queue/​examples/​temporal-trigger/​producer.rs Publishes a workflow trigger.
libs/​@local/​queue/​examples/​temporal-trigger/​consumer.rs Starts a placeholder workflow.
libs/​@local/​queue/​examples/​entity-embedding/​README.md Explains batching and priority examples.
libs/​@local/​queue/​examples/​entity-embedding/​producer.rs Publishes and times sample embedding jobs.
libs/​@local/​queue/​examples/​entity-embedding/​consumer.rs Demonstrates prioritized batch consumption.
libs/​@local/​queue/​docs/​dependency-diagram.mmd Adds the crate dependency diagram.
libs/​@local/​queue/​compose.yml Provides local RabbitMQ infrastructure.
libs/​@local/​queue/​Cargo.toml Declares crate dependencies and examples.
Cargo.toml Registers the crate and Lapin dependency.
Cargo.lock Records resolved dependency changes.
apps/​hash-graph/​src/​subcommand/​mod.rs Registers the embedding-worker command.
apps/​hash-graph/​src/​subcommand/​embedding_worker.rs Starts embedding workflows per actor batch.
apps/​hash-graph/​Cargo.toml Adds the queue dependency.

Review effort: Balanced

Comment on lines +271 to +281
BasicPublishOptions::default(),
body,
properties,
)
.await?
.await
}
.await
.change_context(QueueError::Publish)?;

if confirmation.is_ack() {
volumes:
- rabbitmq-data:/var/lib/rabbitmq
ports:
- "5672:5672"

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.

Medium: Broker is network-exposed with default credentials

Both port mappings publish on all host interfaces by default, while the official image disables the guest account's loopback restriction; a fresh broker retains guest:guest with full access to the default virtual host. A peer that can reach the developer host can therefore authenticate and publish, consume, or purge jobs. (docs.docker.com)

Bind both mappings to loopback (127.0.0.1:5672:5672 and 127.0.0.1:15672:15672), and require dedicated credentials before using this stack on a shared network.

# Private third-party dependencies
derive_more = { workspace = true, features = ["display", "error"] }
futures-util = { workspace = true }
lapin = { workspace = true, features = ["default-runtime"] }

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.

Medium: Broker client has no TLS backend

The workspace disables Lapin's default features, and restoring only default-runtime leaves this client without a TLS backend; the resolved AMQP connector rejects amqps:// rather than establishing an encrypted connection. (raw.githubusercontent.com) Enable a certificate-validating backend here and use amqps:// for remote brokers so credentials and job traffic can be protected.

Suggested change
lapin = { workspace = true, features = ["default-runtime"] }
lapin = { workspace = true, features = ["default-runtime", "rustls"] }


services:
rabbitmq:
image: rabbitmq:4.4-management

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.

Low: Broker image is not digest-pinned

rabbitmq:4.4-management is a mutable tag, so a subsequent pull can execute different upstream code without a reviewed repository change. As supply-chain hardening, pin a reviewed image digest and keep it current through dependency-update PRs. (docs.docker.com)

for (actor_id, entity_ids) in entities_by_actor {
let entity_ids = entity_ids.into_iter().collect::<Vec<_>>();
temporal
.start_update_entity_embeddings_workflow(actor_id, &entity_ids, exclusions)

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.

Medium: Worker trusts actor identity from the queue message

The worker takes actor_id straight from the JSON job body and passes it as the workflow's authentication.actorId. createAndStoreEntityEmbeddingsActivity then reads the entities and calls updateEntityEmbeddings on the graph with actorHeaders(params.authentication.actorId). Nothing ties that actor to whoever published the job. That makes every service with broker credentials a trusted source of graph identity, the same as the server's write path.

The topology makes this harder to lock down with RabbitMQ permissions. Every job uses one shared hash topic exchange, retries are published to the default exchange (which routes to any queue by name), and Broker::connect declares every queue. So every service that uses this crate, including the future webhook delivery worker that talks to external endpoints, needs write access that also reaches embedding.entity. Any of them can then queue jobs that run as any actor, an instance admin included.

The impact is limited to embedding reads and writes and the OpenAI calls. Still, I'd fix this before a production publisher exists. Options:

  • Have the worker run as a fixed system or machine actor instead of a caller-supplied one (the TODO in entity_embedding.rs already mentions this).
  • Authenticate the message, for example with an HMAC over the payload using a key only the graph holds.
  • At minimum, put this queue on its own exchange or vhost so per-service write permissions can restrict who publishes to it.

I couldn't confirm how the production broker's users and permissions will be set up.

@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 using default effort and found 2 potential issues.

Fix All in Cursor

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

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 88344dd. Configure here.

temporal
.start_update_entity_embeddings_workflow(actor_id, &entity_ids, exclusions)
.await?;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Retries duplicate embedding workflows

Medium Severity

If starting updateEntityEmbeddings fails for one actor, the whole batch is failed and retried, including actors whose workflows already started. start_update_entity_embeddings_workflow allocates a new workflow id each call, and job.id is ignored, so those entities start again. A crash after Temporal accepts the starts and before the ack does the same.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 88344dd. Configure here.

delivery
.ack(BasicAckOptions::default())
.await
.change_context(QueueError::Consume)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unsent acknowledgements counted as success

Medium Severity

Delivery::ack returns Ok(false) when the acknowledgement is not sent, because the channel is closed or the acker is already spent. settle treats that as success. A failed job may already have been copied to its retry or parking queue, while the original delivery stays unacked and is delivered again.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 88344dd. Configure here.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark results

hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$15.7 \mathrm{ms} \pm 129 \mathrm{μs}\left({\color{lightgreen}-5.454 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.01 \mathrm{ms} \pm 15.4 \mathrm{μs}\left({\color{gray}-0.706 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1002 $$7.26 \mathrm{ms} \pm 73.2 \mathrm{μs}\left({\color{gray}1.40 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$109 \mathrm{ms} \pm 791 \mathrm{μs}\left({\color{red}29.6 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$9.86 \mathrm{ms} \pm 86.8 \mathrm{μs}\left({\color{gray}3.04 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1527 $$15.7 \mathrm{ms} \pm 157 \mathrm{μs}\left({\color{red}6.23 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2079 $$16.2 \mathrm{ms} \pm 196 \mathrm{μs}\left({\color{lightgreen}-15.787 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.21 \mathrm{ms} \pm 16.9 \mathrm{μs}\left({\color{lightgreen}-12.279 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1034 $$8.09 \mathrm{ms} \pm 72.6 \mathrm{μs}\left({\color{lightgreen}-24.223 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$2.18 \mathrm{ms} \pm 20.0 \mathrm{μs}\left({\color{gray}-0.074 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$1.76 \mathrm{ms} \pm 8.96 \mathrm{μs}\left({\color{gray}-0.879 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 52 $$1.99 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}-0.873 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$3.06 \mathrm{ms} \pm 29.3 \mathrm{μs}\left({\color{gray}0.089 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.12 \mathrm{ms} \pm 15.3 \mathrm{μs}\left({\color{gray}-1.007 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 108 $$2.46 \mathrm{ms} \pm 22.3 \mathrm{μs}\left({\color{gray}0.458 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 134 $$2.63 \mathrm{ms} \pm 22.1 \mathrm{μs}\left({\color{gray}-1.775 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.02 \mathrm{ms} \pm 9.93 \mathrm{μs}\left({\color{gray}-2.659 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 64 $$2.44 \mathrm{ms} \pm 18.6 \mathrm{μs}\left({\color{gray}-1.240 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$1.68 \mathrm{ms} \pm 10.4 \mathrm{μs}\left({\color{gray}-0.554 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$1.66 \mathrm{ms} \pm 8.78 \mathrm{μs}\left({\color{gray}-1.592 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 2 $$1.69 \mathrm{ms} \pm 10.4 \mathrm{μs}\left({\color{gray}-0.208 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 9 $$1.85 \mathrm{ms} \pm 15.0 \mathrm{μs}\left({\color{gray}-0.621 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$1.78 \mathrm{ms} \pm 10.7 \mathrm{μs}\left({\color{gray}2.39 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 4 $$1.87 \mathrm{ms} \pm 9.00 \mathrm{μs}\left({\color{gray}-2.594 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$1.86 \mathrm{ms} \pm 13.3 \mathrm{μs}\left({\color{gray}-4.558 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$1.72 \mathrm{ms} \pm 12.4 \mathrm{μs}\left({\color{gray}1.11 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 26 $$1.83 \mathrm{ms} \pm 19.0 \mathrm{μs}\left({\color{gray}-0.070 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$2.07 \mathrm{ms} \pm 14.6 \mathrm{μs}\left({\color{lightgreen}-6.297 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$1.84 \mathrm{ms} \pm 9.77 \mathrm{μs}\left({\color{lightgreen}-6.452 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 27 $$2.02 \mathrm{ms} \pm 13.0 \mathrm{μs}\left({\color{lightgreen}-5.444 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 67 $$2.05 \mathrm{ms} \pm 17.7 \mathrm{μs}\left({\color{gray}-3.541 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$1.86 \mathrm{ms} \pm 18.6 \mathrm{μs}\left({\color{gray}-2.750 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 30 $$2.04 \mathrm{ms} \pm 12.8 \mathrm{μs}\left({\color{gray}-1.467 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$22.3 \mathrm{ms} \pm 488 \mathrm{μs}\left({\color{red}7.85 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$41.8 \mathrm{ms} \pm 243 \mathrm{μs}\left({\color{gray}0.014 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$25.2 \mathrm{ms} \pm 244 \mathrm{μs}\left({\color{gray}2.26 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$25.6 \mathrm{ms} \pm 305 \mathrm{μs}\left({\color{gray}4.25 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$30.4 \mathrm{ms} \pm 368 \mathrm{μs}\left({\color{gray}4.26 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$23.1 \mathrm{ms} \pm 187 \mathrm{μs}\left({\color{gray}4.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$225 \mathrm{ms} \pm 1.27 \mathrm{ms}\left({\color{gray}0.364 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$71.6 \mathrm{ms} \pm 471 \mathrm{μs}\left({\color{red}11.2 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$46.0 \mathrm{ms} \pm 367 \mathrm{μs}\left({\color{red}6.48 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$226 \mathrm{ms} \pm 1.13 \mathrm{ms}\left({\color{lightgreen}-5.860 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$7.55 \mathrm{ms} \pm 50.4 \mathrm{μs}\left({\color{red}5.75 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$7.77 \mathrm{ms} \pm 53.1 \mathrm{μs}\left({\color{red}5.22 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$7.76 \mathrm{ms} \pm 85.7 \mathrm{μs}\left({\color{red}7.85 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$7.62 \mathrm{ms} \pm 58.4 \mathrm{μs}\left({\color{red}7.32 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$7.82 \mathrm{ms} \pm 87.1 \mathrm{μs}\left({\color{red}8.57 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$7.54 \mathrm{ms} \pm 55.7 \mathrm{μs}\left({\color{red}5.90 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$7.64 \mathrm{ms} \pm 73.7 \mathrm{μs}\left({\color{red}7.44 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$7.29 \mathrm{ms} \pm 56.4 \mathrm{μs}\left({\color{gray}1.83 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$7.31 \mathrm{ms} \pm 45.9 \mathrm{μs}\left({\color{gray}2.57 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$7.64 \mathrm{ms} \pm 54.8 \mathrm{μs}\left({\color{gray}3.94 \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/block/v/1 $$8.44 \mathrm{ms} \pm 60.5 \mathrm{μs}\left({\color{gray}4.00 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$8.43 \mathrm{ms} \pm 65.0 \mathrm{μs}\left({\color{gray}2.80 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$8.38 \mathrm{ms} \pm 57.0 \mathrm{μs}\left({\color{gray}3.17 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$8.66 \mathrm{ms} \pm 68.4 \mathrm{μs}\left({\color{red}6.37 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$8.23 \mathrm{ms} \pm 55.9 \mathrm{μs}\left({\color{gray}0.239 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$8.44 \mathrm{ms} \pm 88.0 \mathrm{μs}\left({\color{gray}3.51 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$8.06 \mathrm{ms} \pm 57.1 \mathrm{μs}\left({\color{gray}-2.495 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$8.41 \mathrm{ms} \pm 90.3 \mathrm{μs}\left({\color{gray}4.48 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$8.47 \mathrm{ms} \pm 65.2 \mathrm{μs}\left({\color{gray}4.47 \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.01 \mathrm{ms} \pm 47.7 \mathrm{μs}\left({\color{gray}-0.839 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$35.1 \mathrm{ms} \pm 407 \mathrm{μs}\left({\color{gray}-2.336 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$69.5 \mathrm{ms} \pm 589 \mathrm{μs}\left({\color{lightgreen}-8.497 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$40.6 \mathrm{ms} \pm 323 \mathrm{μs}\left({\color{gray}1.64 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$44.6 \mathrm{ms} \pm 515 \mathrm{μs}\left({\color{lightgreen}-10.182 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$52.8 \mathrm{ms} \pm 497 \mathrm{μs}\left({\color{gray}-3.084 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$59.0 \mathrm{ms} \pm 732 \mathrm{μs}\left({\color{gray}0.135 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$34.4 \mathrm{ms} \pm 247 \mathrm{μs}\left({\color{lightgreen}-5.005 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$52.5 \mathrm{ms} \pm 476 \mathrm{μs}\left({\color{gray}-1.486 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$36.0 \mathrm{ms} \pm 292 \mathrm{μs}\left({\color{lightgreen}-14.338 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$41.8 \mathrm{ms} \pm 325 \mathrm{μs}\left({\color{lightgreen}-13.610 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$47.1 \mathrm{ms} \pm 311 \mathrm{μs}\left({\color{gray}-0.981 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$45.5 \mathrm{ms} \pm 398 \mathrm{μs}\left({\color{gray}-2.550 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$77.6 \mathrm{ms} \pm 384 \mathrm{μs}\left({\color{gray}-1.440 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$84.8 \mathrm{ms} \pm 440 \mathrm{μs}\left({\color{gray}-0.859 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$19.5 \mathrm{ms} \pm 186 \mathrm{μs}\left({\color{gray}0.734 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$314 \mathrm{ms} \pm 1.22 \mathrm{ms}\left({\color{gray}-0.165 \mathrm{\%}}\right) $$ Flame Graph

@github-actions github-actions Bot added area/apps > hash-api Affects the HASH API (app) area/tests New or updated tests area/tests > integration New or updated integration tests type/legal Owned by the @legal team labels Dec 3, 2026

This branch was successfully deployed

3 active (2 outdated) deployments
Preview – petrinaut — 2f2a436f Deployed Dec 3, 2026 by vercel[bot]
Preview – hash — 88344dd9 Deployed Dec 3, 2026 by vercel[bot]
Preview – petrinaut-docs — 88344dd9 Deployed Dec 3, 2026 by vercel[bot]
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 > hash-graph area/apps area/deps Relates to third-party dependencies (area) 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 New or updated tests type/eng > backend Owned by the @backend team type/legal Owned by the @legal team

Development

Successfully merging this pull request may close these issues.

3 participants