Skip to content

BE-444: Fix email verification failing for uppercase signups#8901

Open
TimDiekmann wants to merge 8 commits into
mainfrom
t/be-444-email-verification-code-fails-when-signing-up-with-uppercase
Open

BE-444: Fix email verification failing for uppercase signups#8901
TimDiekmann wants to merge 8 commits into
mainfrom
t/be-444-email-verification-code-fails-when-signing-up-with-uppercase

Conversation

@TimDiekmann

Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

Signing up with a mixed-case email (e.g. T@HASH.ai) left the user stuck on the email-verification screen: Kratos delivered the code to the lowercased address and accepted it (consuming it), but the account never unlocked. The cause was case-sensitive email comparisons between Kratos verifiable_addresses[].value (the casing typed at signup) and a normalized/lowercased source — and that comparison logic was duplicated across the frontend and backend and had drifted.

This PR makes all email comparisons case-insensitive via a single shared helper, fixing the reported signup flow and several adjacent latent bugs of the same class.

🔗 Related links

  • BE-444 (internal)
  • Original report & Kratos/app logs in the Slack thread (internal)

🔍 What does this change?

  • Adds a shared normalizeEmail helper (@local/hash-isomorphic-utils/normalize, .trim().toLowerCase()) imported by both frontend and backend, so the comparison logic can no longer drift.
  • Frontend (the user-facing gate): normalizes both sides of the verification check in getPrimaryEmailVerificationStatus (_app.page.tsx) and isPrimaryEmailAddressVerified (user-and-org.ts). This is what unblocks the stuck verification screen.
  • Backend: normalizes emails read from Kratos at the single getUserFromEntity funnel and in getVerifiedEmailsFromKratosIdentity, the allowlist on parse (user-has-access-to-hash.ts), and checkEmailVerificationAndUsageStatus.
  • Cleanup job: isPrimaryEmailVerified now compares case-insensitively — previously a verified mixed-case account could be classed as unverified and archived + its Kratos identity deleted (data loss).
  • Removes the dead req.primaryEmailVerified machinery (computed in create-auth-handlers, never read anywhere; express.d.ts field included).

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

⚠️ Known issues

  • Emails are normalized on read (getUserFromEntity, the Kratos read helpers) rather than on write — the user entity still stores the email in its original casing. This is safe because every comparison path now normalizes (TS via normalizeEmail, and the graph admin delete-by-email already lowercases both sides in SQL). Flagged so a future exact-match graph filter against the stored email property doesn't get caught out.

🐾 Next steps

  • If stored canonicalization is ever wanted, normalize at write time in createUser (would also cover any future stored-value exact-match query).

🛡 What tests cover this?

  • New e2e (signup.spec.ts): registers with an uppercased allowlisted email, verifies via Mailslurper, completes signup. Demonstrably failed pre-fix (stuck at the verify gate, then at completion).
  • New unit (normalize.test.ts): pins the normalizeEmail contract (trim + lowercase, idempotent, no local-part canonicalization).
  • New unit (create-unverified-email-cleanup-job.test.ts): guards the data-loss path — a verified mixed-case identity is recognized as verified.
  • Existing signup e2e (lowercase + waitlist) still pass — no regression.

❓ How to test this?

  1. Check out the branch and run the test stack (Kratos + Mailslurper + API + frontend).
  2. Sign up with a mixed-case email such as Foo@Example.com.
  3. Enter the verification code from Mailslurper.
  4. Confirm you advance past the verification screen and can complete signup (set shortname + display name) rather than being stuck on "Verify your email address".

Automated: turbo run test:unit --filter '@local/hash-isomorphic-utils' --filter '@apps/hash-api' and the Playwright signup spec on account-chromium.

📹 Demo

n/a — backend + frontend logic fix; covered by the e2e regression test above.

Signing up with a mixed-case email (e.g. `T@HASH.ai`) left the user stuck on the verification screen: the code was consumed but the account never unlocked. The cause was case-sensitive comparisons between Kratos `verifiable_addresses[].value` and a normalized email source, duplicated across frontend and backend.

Introduce a single shared `normalizeEmail` helper (`@local/hash-isomorphic-utils/normalize`) and apply it at every comparison boundary (FE verification gate, allowlist, invitations, cleanup job). Normalize `user.emails` at the single `getUserFromEntity` funnel. Also removes the dead `req.primaryEmailVerified` machinery and adds unit + e2e coverage.
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
hash Ignored Ignored Preview Jun 25, 2026 12:15pm
hashdotdesign-tokens Ignored Ignored Preview Jun 25, 2026 12:15pm
petrinaut Skipped Skipped Comment Jun 25, 2026 12:15pm

@github-actions github-actions Bot added area/apps > hash* Affects HASH (a `hash-*` app) 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 > playwright New or updated Playwright tests area/apps labels Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.38%. Comparing base (da532c2) to head (d031a24).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
.../hash-api/src/graph/knowledge/system-types/user.ts 0.00% 3 Missing ⚠️
apps/hash-api/src/auth/create-auth-handlers.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8901      +/-   ##
==========================================
+ Coverage   59.25%   59.38%   +0.12%     
==========================================
  Files        1347     1347              
  Lines      131082   131077       -5     
  Branches     5946     5945       -1     
==========================================
+ Hits        77677    77842     +165     
+ Misses      52499    52325     -174     
- Partials      906      910       +4     
Flag Coverage Δ
apps.hash-api 3.28% <44.44%> (+3.28%) ⬆️

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.

@codspeed-hq

codspeed-hq Bot commented Jun 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 80 untouched benchmarks


Comparing t/be-444-email-verification-code-fails-when-signing-up-with-uppercase (893fafc) with main (3e96b0e)

Open in CodSpeed

The new cleanup-job unit test transitively imports `@local/hash-backend-utils` (and other workspace packages), which export from built `dist/`. `test:unit` only depended on `codegen`, so in CI those deps were never built and the import failed (`Cannot find package '@local/hash-backend-utils/error'`). This was a latent gap: no prior unit test crossed a package boundary into a dist-exported `@local` dependency. Adding `^build` builds upstream deps first (turbo-cached).
@cursor

cursor Bot commented Jun 24, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches authentication, verification gating, allowlist access, org invites, and a cleanup job that deletes Kratos identities; behavior change is intentional but broad across signup and account lifecycle paths.

Overview
Fixes mixed-case signups getting stuck on email verification by making all email comparisons case-insensitive through a shared normalizeEmail helper (trim + toLowerCase) in @local/hash-isomorphic-utils/normalize.

Frontend normalizes both sides when deciding if the primary email is verified (_app.page.tsx redirect gate, constructUser in user-and-org.ts). Backend applies the same at read time in getUserFromEntity, getVerifiedEmailsFromKratosIdentity, Kratos lookups (checkEmailVerificationAndUsageStatus), org invites, and the USER_EMAIL_ALLOW_LIST gate. The unverified-email cleanup job now treats verified mixed-case identities correctly, avoiding mistaken archive/delete.

Removes unused req.primaryEmailVerified from auth middleware and Express types. Adds unit, integration, and Playwright coverage (uppercase signup, Mailslurper recipient matching); test:unit now depends on ^build in Turbo.

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

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.

Pull request overview

Fixes a signup/verification edge case where mixed/uppercased emails could leave users stuck in the verification flow due to case-sensitive comparisons between Kratos trait emails and verifiable_addresses[].value. The PR introduces a shared normalization helper and applies it across the frontend verification gate and backend identity/email handling paths (including the cleanup job), plus adds regression tests.

Changes:

  • Add shared normalizeEmail(email) => email.trim().toLowerCase() helper in @local/hash-isomorphic-utils and use it to make email comparisons case-insensitive across frontend + backend.
  • Harden backend identity/email handling (Kratos verified-email extraction, allowlist parsing, and getUserFromEntity canonicalization) and remove unused req.primaryEmailVerified plumbing.
  • Add unit + e2e coverage for uppercase signup verification and for the cleanup-job “verified despite casing mismatch” guard.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
turbo.json Ensure unit tests depend on upstream builds (and codegen), supporting cross-package imports like the new shared helper.
tests/hash-playwright/tests/shared/test-users.ts Add a new allowlisted test user for uppercase-email signup coverage.
tests/hash-playwright/tests/shared/get-kratos-verification-code.ts Match Mailslurper recipient addresses case-insensitively when polling for Kratos codes.
tests/hash-playwright/tests/account/signup.spec.ts Add an e2e regression test for signup with an uppercased email address.
libs/@local/hash-isomorphic-utils/src/normalize.ts Introduce shared normalizeEmail helper used by frontend and backend for comparisons.
libs/@local/hash-isomorphic-utils/src/normalize.test.ts Add unit tests pinning the normalizeEmail contract (trim + lowercase only).
apps/hash-frontend/src/pages/_app.page.tsx Normalize email values when determining primary email verification status from Kratos session data.
apps/hash-frontend/src/lib/user-and-org.ts Normalize email comparisons when deriving isPrimaryEmailAddressVerified.
apps/hash-api/src/shared/user-has-access-to-hash.ts Normalize parsed allowlist entries to match canonicalized user.emails.
apps/hash-api/src/graph/knowledge/system-types/user.ts Canonicalize User.emails at the single entity-to-User construction point; normalize email in Kratos identity lookup checks.
apps/hash-api/src/express.d.ts Remove unused Request.primaryEmailVerified augmentation.
apps/hash-api/src/auth/ory-kratos.ts Normalize verified email values extracted from Kratos identities.
apps/hash-api/src/auth/create-unverified-email-cleanup-job.ts Make primary-email verification detection case-insensitive via shared verified-email extraction + normalization.
apps/hash-api/src/auth/create-unverified-email-cleanup-job.test.ts Add unit tests guarding against erroneous cleanup of verified mixed-case identities.
apps/hash-api/src/auth/create-auth-handlers.ts Remove dead computation/propagation of primaryEmailVerified and the unused verification check call.
.env.test Add the new uppercase-signup test email to the allowlist for test runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TimDiekmann TimDiekmann requested review from a team June 24, 2026 11:43
alex-e-leon
alex-e-leon previously approved these changes Jun 24, 2026

@alex-e-leon alex-e-leon 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.

A few minor comments, but LGTM otherwise - might still be worth getting a review from someone more familiar with this code though.

Comment thread apps/hash-api/src/graph/knowledge/system-types/user.ts Outdated
Comment thread tests/hash-playwright/tests/shared/get-kratos-verification-code.ts Outdated
- getUserFromEntity: model the email property's real nullability (property-level masking can drop it for non-owners) instead of coercing the result type + disabling the lint rule.
- get-kratos-verification-code: reuse the shared `normalizeEmail` helper instead of an inline `.toLowerCase()`.
Copilot AI review requested due to automatic review settings June 25, 2026 08:22
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 25, 2026 08:22 Inactive
@TimDiekmann TimDiekmann requested a review from CiaranMn June 25, 2026 08:22
Comment thread apps/hash-api/src/graph/knowledge/system-types/user.ts Outdated
Co-authored-by: Ciaran Morinan <37743469+CiaranMn@users.noreply.github.com>
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 25, 2026 08:23 Inactive
@TimDiekmann TimDiekmann requested a review from CiaranMn June 25, 2026 08:23
@TimDiekmann TimDiekmann enabled auto-merge June 25, 2026 08:23

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.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.

Comment thread apps/hash-api/src/graph/knowledge/system-types/user.ts Outdated
CiaranMn
CiaranMn previously approved these changes Jun 25, 2026

@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 and found 1 potential issue.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 3b52014. Configure here.

Comment thread apps/hash-api/src/graph/knowledge/system-types/user.ts
Copilot AI review requested due to automatic review settings June 25, 2026 11:26
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 25, 2026 11:27 Inactive
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 25, 2026 11:30 Inactive

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.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Comment thread apps/hash-api/src/graph/knowledge/system-types/user.ts
Drives the real invite/accept resolvers (not a reimplementation) to prove a user who signed up with a mixed-case email can be found, invited by a differently-cased email, and accept the invitation to become an org member.
Copilot AI review requested due to automatic review settings June 25, 2026 12:14
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 25, 2026 12:14 Inactive
@github-actions github-actions Bot added the area/tests > integration New or updated integration tests label Jun 25, 2026
@TimDiekmann TimDiekmann requested a review from CiaranMn June 25, 2026 12:16

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.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

@@ -0,0 +1,201 @@
import { beforeAll, describe, expect, it } from "vitest";
Comment on lines +115 to +124
return async () => {
await deleteKratosIdentity({
kratosIdentityId: invitee.kratosIdentityId,
});
await deleteKratosIdentity({
kratosIdentityId: inviter.kratosIdentityId,
});
await resetGraph();
};
});
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$27.2 \mathrm{ms} \pm 213 \mathrm{μs}\left({\color{gray}-1.512 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.34 \mathrm{ms} \pm 22.4 \mathrm{μs}\left({\color{gray}0.572 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$12.1 \mathrm{ms} \pm 111 \mathrm{μs}\left({\color{gray}0.773 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$42.1 \mathrm{ms} \pm 469 \mathrm{μs}\left({\color{gray}-1.186 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.9 \mathrm{ms} \pm 128 \mathrm{μs}\left({\color{gray}1.33 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$23.1 \mathrm{ms} \pm 223 \mathrm{μs}\left({\color{gray}0.471 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$27.8 \mathrm{ms} \pm 195 \mathrm{μs}\left({\color{gray}0.201 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.66 \mathrm{ms} \pm 23.0 \mathrm{μs}\left({\color{gray}0.269 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$13.2 \mathrm{ms} \pm 115 \mathrm{μs}\left({\color{gray}2.17 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.76 \mathrm{ms} \pm 26.7 \mathrm{μs}\left({\color{gray}0.987 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.93 \mathrm{ms} \pm 17.3 \mathrm{μs}\left({\color{gray}0.778 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.29 \mathrm{ms} \pm 27.4 \mathrm{μs}\left({\color{gray}0.666 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.09 \mathrm{ms} \pm 29.2 \mathrm{μs}\left({\color{gray}0.244 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.47 \mathrm{ms} \pm 23.9 \mathrm{μs}\left({\color{gray}-0.137 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$4.06 \mathrm{ms} \pm 25.7 \mathrm{μs}\left({\color{gray}-0.904 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.35 \mathrm{ms} \pm 26.3 \mathrm{μs}\left({\color{gray}0.270 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.38 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-0.467 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.99 \mathrm{ms} \pm 24.7 \mathrm{μs}\left({\color{gray}-2.206 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.53 \mathrm{ms} \pm 11.2 \mathrm{μs}\left({\color{gray}-0.329 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.44 \mathrm{ms} \pm 12.9 \mathrm{μs}\left({\color{gray}-0.760 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.51 \mathrm{ms} \pm 12.4 \mathrm{μs}\left({\color{gray}-0.393 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.80 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{gray}-0.040 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.60 \mathrm{ms} \pm 16.9 \mathrm{μs}\left({\color{gray}0.823 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.76 \mathrm{ms} \pm 14.2 \mathrm{μs}\left({\color{gray}-0.876 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.99 \mathrm{ms} \pm 19.9 \mathrm{μs}\left({\color{gray}-0.155 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.68 \mathrm{ms} \pm 15.1 \mathrm{μs}\left({\color{gray}0.629 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.91 \mathrm{ms} \pm 15.5 \mathrm{μs}\left({\color{gray}-0.654 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.34 \mathrm{ms} \pm 19.7 \mathrm{μs}\left({\color{gray}-0.952 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.89 \mathrm{ms} \pm 18.8 \mathrm{μs}\left({\color{gray}0.642 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.22 \mathrm{ms} \pm 25.0 \mathrm{μs}\left({\color{gray}1.18 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.27 \mathrm{ms} \pm 19.5 \mathrm{μs}\left({\color{gray}-0.080 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.89 \mathrm{ms} \pm 22.9 \mathrm{μs}\left({\color{gray}0.247 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.26 \mathrm{ms} \pm 17.1 \mathrm{μs}\left({\color{gray}-0.302 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$40.6 \mathrm{ms} \pm 254 \mathrm{μs}\left({\color{gray}-0.118 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$31.5 \mathrm{ms} \pm 168 \mathrm{μs}\left({\color{gray}-0.092 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$34.4 \mathrm{ms} \pm 202 \mathrm{μs}\left({\color{gray}0.336 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$30.2 \mathrm{ms} \pm 154 \mathrm{μs}\left({\color{gray}-0.484 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$40.3 \mathrm{ms} \pm 241 \mathrm{μs}\left({\color{gray}0.335 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$48.1 \mathrm{ms} \pm 262 \mathrm{μs}\left({\color{gray}0.302 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$38.3 \mathrm{ms} \pm 216 \mathrm{μs}\left({\color{gray}-1.729 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$87.3 \mathrm{ms} \pm 726 \mathrm{μs}\left({\color{gray}-0.646 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$32.8 \mathrm{ms} \pm 303 \mathrm{μs}\left({\color{gray}2.40 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$268 \mathrm{ms} \pm 968 \mathrm{μs}\left({\color{lightgreen}-11.108 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$10.2 \mathrm{ms} \pm 60.6 \mathrm{μs}\left({\color{gray}-0.030 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$10.3 \mathrm{ms} \pm 51.7 \mathrm{μs}\left({\color{gray}-1.208 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$10.3 \mathrm{ms} \pm 66.5 \mathrm{μs}\left({\color{gray}0.574 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$10.1 \mathrm{ms} \pm 65.7 \mathrm{μs}\left({\color{gray}-0.388 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$10.4 \mathrm{ms} \pm 51.2 \mathrm{μs}\left({\color{gray}0.302 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$10.1 \mathrm{ms} \pm 54.6 \mathrm{μs}\left({\color{gray}-0.874 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$10.2 \mathrm{ms} \pm 65.8 \mathrm{μs}\left({\color{gray}0.826 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$10.2 \mathrm{ms} \pm 57.5 \mathrm{μs}\left({\color{gray}0.379 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$10.2 \mathrm{ms} \pm 54.1 \mathrm{μs}\left({\color{gray}-0.358 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$10.2 \mathrm{ms} \pm 50.5 \mathrm{μs}\left({\color{gray}-0.422 \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 $$10.6 \mathrm{ms} \pm 60.5 \mathrm{μs}\left({\color{gray}-0.591 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$10.6 \mathrm{ms} \pm 69.8 \mathrm{μs}\left({\color{gray}-0.093 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$10.6 \mathrm{ms} \pm 60.0 \mathrm{μs}\left({\color{gray}0.237 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$10.7 \mathrm{ms} \pm 71.0 \mathrm{μs}\left({\color{gray}0.784 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$10.5 \mathrm{ms} \pm 74.8 \mathrm{μs}\left({\color{gray}-0.800 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$10.6 \mathrm{ms} \pm 50.9 \mathrm{μs}\left({\color{gray}-1.893 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$10.6 \mathrm{ms} \pm 61.8 \mathrm{μs}\left({\color{gray}0.337 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$10.5 \mathrm{ms} \pm 63.0 \mathrm{μs}\left({\color{gray}-0.055 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$10.7 \mathrm{ms} \pm 83.8 \mathrm{μs}\left({\color{gray}-0.537 \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 $$8.44 \mathrm{ms} \pm 56.5 \mathrm{μs}\left({\color{gray}0.704 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$54.8 \mathrm{ms} \pm 402 \mathrm{μs}\left({\color{lightgreen}-7.007 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$104 \mathrm{ms} \pm 576 \mathrm{μs}\left({\color{gray}-4.252 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$61.9 \mathrm{ms} \pm 541 \mathrm{μs}\left({\color{gray}-4.548 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$69.7 \mathrm{ms} \pm 391 \mathrm{μs}\left({\color{lightgreen}-8.330 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$79.0 \mathrm{ms} \pm 479 \mathrm{μs}\left({\color{lightgreen}-6.153 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$83.3 \mathrm{ms} \pm 454 \mathrm{μs}\left({\color{lightgreen}-6.494 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$44.1 \mathrm{ms} \pm 335 \mathrm{μs}\left({\color{gray}4.03 \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 $$70.8 \mathrm{ms} \pm 512 \mathrm{μs}\left({\color{gray}-4.100 \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 $$47.9 \mathrm{ms} \pm 254 \mathrm{μs}\left({\color{gray}-2.428 \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 $$57.2 \mathrm{ms} \pm 428 \mathrm{μs}\left({\color{gray}-4.614 \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 $$59.5 \mathrm{ms} \pm 362 \mathrm{μs}\left({\color{gray}-4.877 \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.9 \mathrm{ms} \pm 304 \mathrm{μs}\left({\color{gray}-3.039 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$128 \mathrm{ms} \pm 593 \mathrm{μs}\left({\color{red}8.79 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$139 \mathrm{ms} \pm 779 \mathrm{μs}\left({\color{red}6.41 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$17.8 \mathrm{ms} \pm 135 \mathrm{μs}\left({\color{gray}-0.136 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$562 \mathrm{ms} \pm 1.16 \mathrm{ms}\left({\color{red}8.11 \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* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps 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.

4 participants