Skip to content

FE-1832: Send an email from a flow - #10693

Draft
kostandinang wants to merge 9 commits into
mainfrom
ka/fe-1832-add-a-send-email-flow-action
Draft

kostandinang wants to merge 9 commits into
mainfrom
ka/fe-1832-add-a-send-email-flow-action

Conversation

@kostandinang

@kostandinang kostandinang commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🌟 Purpose

This PR adds the action for internal use on staging. It sends one plain-text email to one address, from the sender its deployment sets, through the transporters the API already uses, and returns the provider's message ID. Live delivery on staging also needs the AI worker deployment configured, which is outside this repo.

🔍 Changes

  • Shared transporters. The SES, SMTP and dummy transporters move from hash-api to @local/hash-backend-utils/email. sendMail takes an optional from, replyTo and text, returns the message ID, and throws an EmailSendError whose outcome says whether the email was rejected, is unavailable for now, or is unknown (it may have been sent).
  • API emails behave as before. The API wraps the shared transporter in its own EmailTransporter type, which logs a failed send and resolves. The sender, the [STAGING SITE] and [DEV SITE] prefixes and the AWS SDK's own retries are unchanged. The log still carries the provider's own error, now with what became of the email (outcome).
  • Send email action. Inputs are to, subject, body and an optional replyTo, all Text; the output is messageId. Reply-to defaults to the email of the person who started the run, read from their User entity as that user.
  • One address check. validateEmailAddress accepts a single bare address. The editor runs it on typed values through the action's check, and the worker runs it on every value, since one can come from a flow input or an earlier step.
  • At-most-once sending. Only the step's first attempt sends. The worker's SES client makes one request per send, with timeouts well inside the activity's five minutes. A send known not to have reached SES (throttling, a connection that was never made, missing credentials) is tried again within the attempt, up to three times. Nothing is thrown for Temporal to retry.
  • Later attempts don't send. Temporal starts another attempt when one times out or its worker stops, which can be after SES took the email. A later attempt therefore fails the step, saying the email may have been sent.
  • Editor. The existing Send email entry now points at the definition, so it can be added and configured like any other action.

🤔 Decisions to review

  • Retry policy. The issue says a failed send should throw so Temporal retries it. SESv2 SendEmail has no idempotency token, so retrying a send that may have succeeded can deliver twice. A 5xx, a timeout or a dropped connection therefore fails the step with "may have been sent"; only throttling (429), a connection that was never made and missing credentials are tried again. This needs agreement before a live send.
  • Recipients. Only @hash.ai addresses are allowed unless ENVIRONMENT is production, so a deployment that doesn't say which it is stays restricted. The API's isProdEnv also treats NODE_ENV=production without ENVIRONMENT as production; the worker deliberately doesn't.
  • Scheduled runs. A run a schedule started has nobody to default Reply-to to, so the step fails and asks for one. Who the default should be is still open in the issue.
  • Sender. The worker sends from HASH_FLOW_EMAIL_SENDER and has no default. With the aws or smtp transporter and no sender, the step fails as not set up, rather than fall back to the API's SYSTEM_EMAIL_* settings. Incomplete settings, such as a missing AWS_REGION, fail it the same way. The dummy transporter has a sender of its own. The value isn't checked before sending.
  • Dummy transporter. The worker ignores dummy when NODE_ENV=production, so a deployed step can't report an email as sent when nothing was.
  • Body. It is sent as text plus an HTML alternative, never as HTML, since it can come from an AI step. The HTML part is the text escaped with lodash's escape, with <br> for line breaks, as not every email client keeps them for white-space. Runs of spaces collapse there.
  • Subject. Whitespace is collapsed to one line so a line break can't add a header. Flow emails get no site prefix.
  • Tries inside the attempt. The run view doesn't show them as attempts; the worker logs each as a warning. A step's retryCount adds none. If the worker stops between a throttled try and the next, the step fails saying the email may have been sent, although it wasn't.

🙅 Left out

  • Deployment settings. This PR configures no deployment. One that sends through SES sets HASH_EMAIL_TRANSPORTER=aws, HASH_FLOW_EMAIL_SENDER and AWS_REGION on the AI worker, and lets the worker's AWS credentials send from that sender.
  • Per-flow sender. Every flow sends from the worker's one sender. The transporter accepts a from, so a per-flow sender can be added without changing it.
  • Approval. The action doesn't depend on Ask a person or Read entity.
  • Person entities as recipients, custom domains, bounces and complaints. These are the issue's later items.

🛡 Tests

  • Transporters. The SES transporter runs against a local HTTP stand-in for SES and the SMTP transporter against a local TCP stand-in. They cover the message ID, From and Reply-to, each failure outcome, and one request per send with singleAttempt.
  • Address check. email-address.test.ts covers lists, display names, angle brackets, line breaks and over-long addresses. validate-flow-definition.test.ts covers the check reporting on the right input and a blank Reply-to.
  • Action. send-email-action.test.ts covers the Reply-to default and override, the recipient restriction, scheduled runs, each failure outcome with the number of tries it gets, incomplete worker settings failing the step without a throw, and a later attempt not sending. get-email-transporter.test.ts covers a deployment getting no transporter when it is set to the dummy one or names no sender, and the sender HASH_FLOW_EMAIL_SENDER names.
  • API. create-email-transporter.test.ts covers a failed send being logged with the provider's error rather than rejecting.
  • Gates. lint:tsc, lint:eslint and test:unit ran locally for the six touched packages, and yarn lint:format passes. Everything passed except the frontend test:unit, which timed out in process-editor.integration.test.tsx, a file this PR doesn't touch; that file passes when run alone. The edits since that run touch only the AI worker, hash-backend-utils and hash-isomorphic-utils, and the three gates pass for each at the current head.
  • Local stack, at the current head. send-email.scenario.ts met 7 of 7 expectations through Temporal with the dummy transporter: a composed email with Reply-to alice@example.com, Draft email into Send email with an explicit Reply-to, and a rejected ada@example.com.
  • Fake SES, at the current head. Through Temporal with the aws transporter and HASH_FLOW_EMAIL_SENDER=flows@example.com: a 200 sent with one request; a 429 once sent on the second try, with two requests; a 429 always made three requests and failed; a 400 and a 500 each made one request. Every request was From flows@example.com. With no sender, the step failed as not set up and made no request.
  • Worker killed mid-send, on an earlier revision. It made one request, and the attempt Temporal started after the timeout didn't send. The attempt check hasn't changed since.
  • Browser, on an earlier revision of this branch. The step can be added, takes typed values, flow inputs and Draft email outputs, shows the address check, and shows the message ID or the rejection in the run view.
  • Not run. A real SES send.

❓ How to test this?

  1. Start the stack and the AI worker with the default HASH_EMAIL_TRANSPORTER=dummy.
  2. In the flow editor, add Draft email, then Send email after it. Type a @hash.ai recipient and pick the draft's Subject and Body.
  3. Run the flow. The run shows a message ID, and the email is in var/ai-worker/dummy-email-transporter/email-dumps.yml with your address as Reply-to.
  4. Change the recipient to another domain and run again. The step fails and names the @hash.ai restriction.
  5. Or run yarn workspace @apps/hash-ai-worker-ts run-flow-scenario scripts/flow-scenarios/scenarios/send-email.scenario.ts.

kostandinang and others added 2 commits December 2, 2026 16:43
The SES, SMTP and dummy transporters move out of hash-api so that a
worker can send email. `sendMail` takes an optional sender, Reply-to and
plain-text body, returns the message ID, and throws an `EmailSendError`
that says whether the email was rejected, wasn't sent for now, or may
have been sent.

The API keeps its behavior through its own transporter type, which logs
a failed send and resolves.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a23729-12d1-7170-9bcb-f973b88c359d
Sends one plain-text email to one address from the AI worker, and
returns the provider's message ID. Replies go to the address given, or
to the person who started the run. Outside production, only hash.ai
addresses can be emailed.

SES can't tell a repeated send from a new email, so the step sends at
most once: only an attempt known not to have sent the email is retried,
and a later attempt refuses to send unless the one before it said so.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a23729-12d1-7170-9bcb-f973b88c359d
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
hash Ready Ready Preview Dec 3, 2026 11:32pm UTC
petrinaut Ready Ready Preview Dec 3, 2026 11:32pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Dec 3, 2026 11:32pm UTC
petrinaut-docs Ignored Ignored Preview Dec 3, 2026 11:32pm 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/apps > hash-api Affects the HASH API (app) 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/apps labels Dec 2, 2026
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.11111% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.41%. Comparing base (aeda173) to head (2a4bfc1).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
libs/@local/hash-backend-utils/src/email.ts 0.00% 12 Missing ⚠️
...pps/hash-api/src/email/create-email-transporter.ts 35.71% 4 Missing and 5 partials ⚠️
...ts/flow-scenarios/scenarios/send-email.scenario.ts 0.00% 8 Missing ⚠️
...backend-utils/src/email/dummy-email-transporter.ts 0.00% 8 Missing ⚠️
...-backend-utils/src/email/smtp-email-transporter.ts 78.26% 0 Missing and 5 partials ⚠️
...rc/activities/flow-activities/send-email-action.ts 93.33% 1 Missing and 3 partials ⚠️
...low-activities/send-email-action/get-user-email.ts 0.00% 3 Missing ⚠️
...ivities/send-email-action/get-email-transporter.ts 85.71% 0 Missing and 1 partial ⚠️
...orker-ts/src/activities/shared/get-flow-context.ts 0.00% 1 Missing ⚠️
...ackend-utils/src/email/shared/email-transporter.ts 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10693      +/-   ##
==========================================
+ Coverage   70.40%   70.41%   +0.01%     
==========================================
  Files        2126     2133       +7     
  Lines      225388   225600     +212     
  Branches     9784     9854      +70     
==========================================
+ Hits       158674   158856     +182     
- Misses      64671    64682      +11     
- Partials     2043     2062      +19     
Flag Coverage Δ
apps.hash-ai-worker-ts 10.55% <78.48%> (+0.83%) ⬆️
apps.hash-api 25.54% <35.71%> (+0.28%) ⬆️
local.hash-backend-utils 29.62% <63.38%> (+0.64%) ⬆️
local.hash-isomorphic-utils 45.58% <100.00%> (+1.31%) ⬆️

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.

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.

🔵 Needs a closer look

Irreversible live sending requires maintainer agreement on retry and scheduled Reply-to behavior, plus verification of staging SES configuration, permissions, and real delivery.

No open issues 🎉

What changed in this PR

Adds a Send email flow action for internal staging use, sharing email infrastructure with the API while preserving existing API behavior.

Changes:

  • Adds address validation, Reply-to defaults, message ID output, and retry safeguards.
  • Moves SES, SMTP, and dummy transporters into shared backend utilities.
  • Enables the editor action and adds documentation, unit tests, and flow scenarios.
File Description
yarn.lock Updates dependency ownership.
tests/​hash-backend-integration/​src/​tests/​email.test.ts Uses the shared SES transporter.
README.md Documents worker email configuration.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​validate-flow-definition.test.ts Tests email input diagnostics.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​email-address.ts Adds shared address validation.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​email-address.test.ts Tests accepted and rejected addresses.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​action-definitions.ts Defines Send email inputs and output.
libs/​@local/​hash-backend-utils/​src/​flows/​signal-step-attempts.ts Exposes previous-attempt failure details.
libs/​@local/​hash-backend-utils/​src/​email/​smtp-email-transporter.ts Adds shared SMTP delivery and failure classification.
libs/​@local/​hash-backend-utils/​src/​email/​smtp-email-transporter.test.ts Tests SMTP delivery outcomes.
libs/​@local/​hash-backend-utils/​src/​email/​shared/​email-transporter.ts Defines shared email contracts.
libs/​@local/​hash-backend-utils/​src/​email/​dummy-email-transporter.ts Moves dummy delivery and adds message IDs.
libs/​@local/​hash-backend-utils/​src/​email/​aws-ses-email-transporter.ts Adds shared SES delivery and single-attempt configuration.
libs/​@local/​hash-backend-utils/​src/​email/​aws-ses-email-transporter.test.ts Tests SES content, outcomes, and retries.
libs/​@local/​hash-backend-utils/​src/​email.ts Creates and exports shared transporters.
libs/​@local/​hash-backend-utils/​package.json Adds email dependencies.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​flows/​[flow-def-id]/​edit.page/​shared/​step-display.ts Enables Send email in the editor.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​flows/​[flow-def-id]/​edit.page/​shared/​step-display.test.ts Updates upcoming-action expectations.
apps/​hash-api/​src/​graphql/​resolvers/​knowledge/​org/​invite-user-to-org.ts Uses the API wrapper type.
apps/​hash-api/​src/​graphql/​create-apollo-server.ts Updates the transporter type import.
apps/​hash-api/​src/​graphql/​context.ts Updates the transporter type import.
apps/​hash-api/​src/​graph/​context-types.ts Updates the transporter type import.
apps/​hash-api/​src/​email/​transporters/​types.ts Removes superseded transporter types.
apps/​hash-api/​src/​email/​transporters/​smtp-email-transporter.ts Removes the API-local SMTP implementation.
apps/​hash-api/​src/​email/​transporters/​index.ts Removes obsolete transporter exports.
apps/​hash-api/​src/​email/​transporters/​aws-ses-email-transporter.ts Removes the API-local SES implementation.
apps/​hash-api/​src/​email/​create-email-transporter.ts Wraps shared delivery with existing API error handling.
apps/​hash-api/​package.json Removes relocated email dependencies.
apps/​hash-ai-worker-ts/​src/​activities/​shared/​get-flow-context.ts Exposes the run’s trigger identity.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities/​send-email-action/​get-user-email.ts Reads the starter’s email as that user.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities/​send-email-action/​get-email-transporter.ts Configures worker delivery and timeouts.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities/​send-email-action/​get-earlier-attempt.ts Guards retries after uncertain delivery.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities/​send-email-action/​get-earlier-attempt.test.ts Tests retry eligibility.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities/​send-email-action.ts Implements validation, sending, and delivery outcomes.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities/​send-email-action.test.ts Tests action behavior and safeguards.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities.ts Registers the Send email activity.
apps/​hash-ai-worker-ts/​scripts/​flow-scenarios/​scenarios/​send-email.scenario.ts Adds composed, drafted, and restricted-recipient scenarios.

Review effort: Balanced

Shorten comments that repeated the retry policy or restated a name, and
remove test cases that took the same branch as another case or tested
the AWS SDK rather than this code.

Co-authored-by: Amp <amp@ampcode.com>
A later attempt of the step read how the attempt before it failed from
the run, to decide whether it could send. Only the first attempt sends
now, and a send that didn't reach the provider is tried again within it.
The step no longer reads the run from Temporal, and
`signal-step-attempts.ts` is as it was.

Co-authored-by: Amp <amp@ampcode.com>
…rror

Not every email client keeps line breaks for `white-space`, so the HTML
part of a flow's email uses `<br>`, and escapes the body with lodash
rather than by hand. The API logs the provider's own error for a failed
send again, with what became of the email.

Add tests for the API's transporter not rejecting and for a deployment
set to the dummy transporter, and mark the test credentials of the SES
stand-in as a Semgrep false positive.

Co-authored-by: Amp <amp@ampcode.com>

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

Resetting a workflow before the email activity gives it a fresh attempt counter, allowing already-delivered emails to be sent again without a persistent, atomic send claim.

1 open issue

Review effort: Balanced

);
}

if (Context.current().info.attempt > 1) {
kostandinang and others added 2 commits December 3, 2026 11:47
The AI worker sent every flow email from `ops@hash.ai`. A deployment
that can't send from that address can now name its own in
`HASH_FLOW_EMAIL_SENDER`. Without it the sender is unchanged.

Co-authored-by: Amp <amp@ampcode.com>
Semgrep still lists a finding marked `nosemgrep` in the report CI
uploads, and code scanning opens an alert for it, so the check failed on
the placeholder secret of the SES stand-in. Setting the variables as one
object doesn't match the rule.

Co-authored-by: Amp <amp@ampcode.com>
The AI worker no longer has a sender of its own in the code. With the
`aws` or `smtp` transporter and no `HASH_FLOW_EMAIL_SENDER`, a Send
email step fails as not set up rather than send from the API's system
address. The `dummy` transporter keeps its own sender, and the
transporter tests use `example.com` senders.

Co-authored-by: Amp <amp@ampcode.com>
A Send email step looked up who started the run before it knew whether
the worker had an email transporter. It now gets the transporter first,
and incomplete email settings fail the step as not set up instead of as
an email that wasn't sent.

The step's description no longer says the email is from HASH, as the
sender is the deployment's, and the README lists
`HASH_FLOW_EMAIL_SENDER` with the other email variables.

Co-authored-by: Amp <amp@ampcode.com>
@github-actions

github-actions Bot commented Dec 4, 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 $$20.5 \mathrm{ms} \pm 176 \mathrm{μs}\left({\color{gray}-2.500 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.73 \mathrm{ms} \pm 19.5 \mathrm{μs}\left({\color{gray}-0.491 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1002 $$10.9 \mathrm{ms} \pm 116 \mathrm{μs}\left({\color{gray}1.50 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$123 \mathrm{ms} \pm 1.46 \mathrm{ms}\left({\color{gray}-1.248 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$12.0 \mathrm{ms} \pm 119 \mathrm{μs}\left({\color{gray}-4.431 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1527 $$19.8 \mathrm{ms} \pm 171 \mathrm{μs}\left({\color{lightgreen}-7.103 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$21.7 \mathrm{ms} \pm 198 \mathrm{μs}\left({\color{gray}-1.445 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.06 \mathrm{ms} \pm 22.5 \mathrm{μs}\left({\color{gray}2.60 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$12.5 \mathrm{ms} \pm 96.2 \mathrm{μs}\left({\color{red}7.63 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.00 \mathrm{ms} \pm 25.4 \mathrm{μs}\left({\color{gray}0.097 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.37 \mathrm{ms} \pm 15.0 \mathrm{μs}\left({\color{gray}-2.976 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 52 $$2.73 \mathrm{ms} \pm 27.5 \mathrm{μs}\left({\color{gray}-1.086 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$4.12 \mathrm{ms} \pm 40.0 \mathrm{μs}\left({\color{gray}-1.864 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.84 \mathrm{ms} \pm 17.6 \mathrm{μs}\left({\color{gray}-2.755 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 108 $$3.34 \mathrm{ms} \pm 26.7 \mathrm{μs}\left({\color{gray}-0.028 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$3.56 \mathrm{ms} \pm 26.4 \mathrm{μs}\left({\color{gray}-3.720 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.78 \mathrm{ms} \pm 20.0 \mathrm{μs}\left({\color{gray}0.209 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.30 \mathrm{ms} \pm 25.2 \mathrm{μs}\left({\color{gray}-0.955 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.19 \mathrm{ms} \pm 16.0 \mathrm{μs}\left({\color{gray}-1.191 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.13 \mathrm{ms} \pm 13.3 \mathrm{μs}\left({\color{gray}-2.223 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 2 $$2.19 \mathrm{ms} \pm 15.4 \mathrm{μs}\left({\color{gray}-1.640 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.44 \mathrm{ms} \pm 19.7 \mathrm{μs}\left({\color{gray}-0.557 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.31 \mathrm{ms} \pm 17.0 \mathrm{μs}\left({\color{gray}0.373 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.50 \mathrm{ms} \pm 24.8 \mathrm{μs}\left({\color{gray}-1.682 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.46 \mathrm{ms} \pm 26.7 \mathrm{μs}\left({\color{gray}-1.697 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.23 \mathrm{ms} \pm 14.3 \mathrm{μs}\left({\color{gray}-3.442 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 26 $$2.36 \mathrm{ms} \pm 15.1 \mathrm{μs}\left({\color{gray}-2.408 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$2.81 \mathrm{ms} \pm 26.5 \mathrm{μs}\left({\color{gray}-2.368 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.50 \mathrm{ms} \pm 24.2 \mathrm{μs}\left({\color{gray}0.949 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 27 $$2.70 \mathrm{ms} \pm 20.0 \mathrm{μs}\left({\color{gray}0.951 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$2.74 \mathrm{ms} \pm 26.5 \mathrm{μs}\left({\color{gray}-2.282 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.43 \mathrm{ms} \pm 13.4 \mathrm{μs}\left({\color{gray}-4.138 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$2.72 \mathrm{ms} \pm 33.9 \mathrm{μs}\left({\color{gray}0.642 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$28.5 \mathrm{ms} \pm 269 \mathrm{μs}\left({\color{gray}0.201 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$57.9 \mathrm{ms} \pm 383 \mathrm{μs}\left({\color{gray}-2.095 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$31.4 \mathrm{ms} \pm 222 \mathrm{μs}\left({\color{lightgreen}-7.028 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$33.3 \mathrm{ms} \pm 248 \mathrm{μs}\left({\color{gray}-0.819 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$39.5 \mathrm{ms} \pm 302 \mathrm{μs}\left({\color{lightgreen}-6.954 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$29.6 \mathrm{ms} \pm 296 \mathrm{μs}\left({\color{gray}1.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$328 \mathrm{ms} \pm 1.41 \mathrm{ms}\left({\color{red}5.34 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$101 \mathrm{ms} \pm 568 \mathrm{μs}\left({\color{gray}3.34 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$60.1 \mathrm{ms} \pm 466 \mathrm{μs}\left({\color{gray}-0.402 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$274 \mathrm{ms} \pm 1.04 \mathrm{ms}\left({\color{lightgreen}-7.461 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$9.26 \mathrm{ms} \pm 70.9 \mathrm{μs}\left({\color{gray}-1.123 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$9.55 \mathrm{ms} \pm 87.2 \mathrm{μs}\left({\color{gray}-2.421 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$9.61 \mathrm{ms} \pm 69.6 \mathrm{μs}\left({\color{gray}-4.796 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$9.68 \mathrm{ms} \pm 89.6 \mathrm{μs}\left({\color{gray}0.817 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$9.52 \mathrm{ms} \pm 106 \mathrm{μs}\left({\color{gray}-2.693 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$9.26 \mathrm{ms} \pm 64.4 \mathrm{μs}\left({\color{gray}-2.672 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$9.27 \mathrm{ms} \pm 70.7 \mathrm{μs}\left({\color{gray}-4.640 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$9.71 \mathrm{ms} \pm 68.8 \mathrm{μs}\left({\color{gray}3.96 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$9.36 \mathrm{ms} \pm 77.5 \mathrm{μs}\left({\color{gray}-1.193 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$9.79 \mathrm{ms} \pm 103 \mathrm{μs}\left({\color{gray}4.02 \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 $$11.3 \mathrm{ms} \pm 82.5 \mathrm{μs}\left({\color{red}5.47 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$11.1 \mathrm{ms} \pm 105 \mathrm{μs}\left({\color{gray}3.47 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$11.0 \mathrm{ms} \pm 82.4 \mathrm{μs}\left({\color{gray}3.55 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$11.4 \mathrm{ms} \pm 112 \mathrm{μs}\left({\color{red}6.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$10.9 \mathrm{ms} \pm 72.8 \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 $$11.4 \mathrm{ms} \pm 91.3 \mathrm{μs}\left({\color{red}5.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$11.0 \mathrm{ms} \pm 159 \mathrm{μs}\left({\color{gray}-0.143 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$11.0 \mathrm{ms} \pm 88.1 \mathrm{μs}\left({\color{gray}2.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$11.0 \mathrm{ms} \pm 66.0 \mathrm{μs}\left({\color{gray}2.33 \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 $$6.34 \mathrm{ms} \pm 61.0 \mathrm{μs}\left({\color{gray}0.539 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$47.6 \mathrm{ms} \pm 469 \mathrm{μs}\left({\color{gray}0.773 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$89.0 \mathrm{ms} \pm 771 \mathrm{μs}\left({\color{gray}0.849 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$52.4 \mathrm{ms} \pm 420 \mathrm{μs}\left({\color{gray}-1.495 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$60.0 \mathrm{ms} \pm 489 \mathrm{μs}\left({\color{gray}-0.119 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$67.6 \mathrm{ms} \pm 653 \mathrm{μs}\left({\color{gray}1.36 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$71.6 \mathrm{ms} \pm 571 \mathrm{μs}\left({\color{gray}-1.673 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$44.6 \mathrm{ms} \pm 295 \mathrm{μs}\left({\color{gray}0.841 \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 $$65.6 \mathrm{ms} \pm 378 \mathrm{μs}\left({\color{gray}-2.312 \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 $$50.6 \mathrm{ms} \pm 659 \mathrm{μs}\left({\color{gray}1.16 \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 $$56.4 \mathrm{ms} \pm 500 \mathrm{μs}\left({\color{gray}0.279 \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 $$57.9 \mathrm{ms} \pm 379 \mathrm{μs}\left({\color{gray}-0.282 \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 $$59.0 \mathrm{ms} \pm 570 \mathrm{μs}\left({\color{gray}1.05 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$105 \mathrm{ms} \pm 747 \mathrm{μs}\left({\color{gray}-4.285 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$114 \mathrm{ms} \pm 800 \mathrm{μs}\left({\color{gray}-1.031 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$25.4 \mathrm{ms} \pm 211 \mathrm{μs}\left({\color{gray}2.75 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$421 \mathrm{ms} \pm 1.53 \mathrm{ms}\left({\color{gray}0.522 \mathrm{\%}}\right) $$ Flame Graph

This branch was successfully deployed

2 active and 1 inactive (outdated) deployments
Preview – hash — 2a4bfc12 Deployed Dec 3, 2026 by vercel[bot]
Preview – petrinaut — 2a4bfc12 Deployed Dec 3, 2026 by vercel[bot]
Preview – petrinaut-docs — b788caf3 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 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/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

3 participants