Skip to content

FE-2396: Prototype an expression language and editor for metrics and temporal constraints - #10672

Draft
kube wants to merge 9 commits into
cf/fe-1814-metrics-in-entities-and-editfrom
cf/fe-2396-expression-language-and-editor-prototype
Draft

kube wants to merge 9 commits into
cf/fe-1814-metrics-in-entities-and-editfrom
cf/fe-2396-expression-language-and-editor-prototype

Conversation

@kube

@kube kube commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Warning

File format change
Net takes an optional constraints list, and code can read metrics.
Existing files load unchanged.
A build without this PR drops the list without a warning, and does not compile code that reads metrics.

Warning

Stored settings change
Stored user settings take two keys, expressionField and anthropicApiKey.
Settings stored without them load with both at their defaults.
A build without this PR reads neither key.

Summary

Before this PR, a metric is a TypeScript function body, a model holds no constraints, and no code reads the value of a metric.

This PR adds an expression language for metrics and constraints, and a field to write it in. A metric reads SUM(FILTER(Queue, .urgent), .wait) and a constraint ALWAYS(Infected < 500, 0, 50). The field draws names as chips and calls as frames, completes while typing, and shows the value or the first error. Constraints are saved with the model and listed in the Entities pane. Lambdas and kernels read a metric as metrics.backlog.

File format

Net takes an optional constraints list, written after metrics and before scenarios. A constraint has an id, an expression, an optional description and an optional dialect. A metric written as an expression keeps the text in comment lines that open its code.

Example and loading: existing files load unchanged, a build without this PR drops constraints
 metrics:
   - id: infected_fraction
     description: Share of the population currently infected.
     code: |-
       …
+  - id: twice_infected
+    code: |-
+      // expression: Infected.count * 2
+      return (state.places["Infected"].count * 2);
+constraints:
+  - id: outbreak_stays_small
+    description: Never more than 500 infected in the first 50 time units.
+    expression: ALWAYS(Infected.count < 500, 0, 50)
 scenarios:
  • Existing files load unchanged

    Saving one again writes the bytes a build without this PR writes.

  • A build without this PR drops constraints without a warning

    The file loads, and version stays 1.

  • A metric written as an expression compiles in a build without this PR

    Its code is the TypeScript body the expression lowers to, under the comment lines.

  • Code that reads metrics does not compile in a build without this PR

    The file loads, and compiling fails with Unknown identifier `metrics`.
    Measured on a lambda, and on an expression that reads a metric written in TypeScript.

  • A dialect other than formula or fluent is rejected

    Invalid SDCPN file: constraints.0.dialect: Invalid option: expected one of "formula"|"fluent"

  • A constraint ID in the wrong case, or one the net has, loads

    The ID check reports it as an error.

Stored settings

petrinaut:user-settings in localStorage takes two keys. expressionField is one of classic, inline, block and slots.

 {
   …
+  "expressionField": "classic",
+  "anthropicApiKey": ""
 }
Loading: defaults where the keys are absent, both left in storage by a build without this PR
  • Settings stored without the keys load

    expressionField is classic and anthropicApiKey is empty, and the next save writes both.

  • A build without this PR reads neither key

    Both are in storage after it saves.

Links

More docs: metric reads, the Labs settings, the buffer ABI

Changes

Language: one grammar in two written styles, checked against the net, lowered to TypeScript
  • Expression language in Core

    analyzeExpression tokenizes, parses, checks and lowers a text.
    It answers the tree, each name with what it stands for, the diagnostics, the type and the formatted text.

  • Two written styles read into one tree

    Formula writes SUM(FILTER(Queue, .urgent), .wait).
    Fluent writes Queue.filter(.urgent).sum(.wait).
    convertExpressionText writes a text of one style in the other.

  • Three types: a number, a condition, a list of tokens

    A metric is one number that reads one instant.
    A constraint is a condition.

  • A place stands for the list of its tokens

    Where a number is needed a list is how many tokens it holds: Infected / Population.
    .count after a list says the same.
    FILTER, SUM, AVERAGE, MIN, MAX, MEDIAN, PERCENTILE and REDUCE work on a list.

  • SUM, AVERAGE, MIN and MAX given a list are read by the next argument

    MAX(Queue, .wait) reads the token and is over the tokens of Queue.
    MAX(Queue, Served) reads none and is the larger of two counts.

  • ALWAYS, EVENTUALLY and UNTIL read a whole run
  • let name = value in body names a value
  • A metric lowers to a TypeScript metric body

    Each function on a list lowers to one loop.
    A metric it reads is written out in that body.

  • A constraint lowers to a ConstraintProgram

    Atoms are comparisons with a margin, under a formula of not, and, or, implies, always, eventually and until.

  • Parsing goes on past an error

    A missing operand becomes a missing node.
    A diagnostic is incomplete where more typing can make the text valid.

  • assistExpression asks a language model for an expression

    Each answer goes through the check, and one that fails goes back with its diagnostics.
    It holds no model and no key: the caller gives the function that reaches one.

Model and simulation: constraints saved with the net, metrics read from code
  • Net takes constraints

    ModelConstraint has id, description, expression and dialect.
    Actions addConstraint, updateConstraint and removeConstraint edit the list.

  • A constraint has a snake_case ID among the IDs of the root net

    constraint joins EntityIdKind and the selection vocabulary.

  • A rename rewrites the expressions that read the ID

    renameInExpression writes each metric and constraint again with the new name.

  • metrics.<id> reads a metric in a lambda, a kernel and a TypeScript metric

    Differential equations and transitions inside a component read none.

  • Each metric read is bound once, where the reader starts

    A metric that reads itself, straight or through others, is an error.

  • Stepped, Monte Carlo and event-driven runs give the value at the instant a transition is evaluated
  • A metric keeps its expression in its code

    Comment lines hold the text, and the lowered body follows.
    An expression that does not check keeps the body of the last one that did.

  • Net-wide check reports metrics and constraints that do not check

    Diagnostics lists them under their ID, and none stops a run.

  • Import of an older file carries its new IDs into expressions
Editor: an expression field with chips, frames and completion, in four versions
  • Expression field on CodeMirror

    A name of the model is a chip, and a function call is a frame in the colour of its kind.
    Completion, an argument hint, error marks, and a row under the field with the value or the first error.

  • Four versions of the field, chosen in a menu above it

    First version, A with breaks between arguments, B laid out by the formatter, C edited on the tree.
    User settings > Labs > Metrics and constraints > Expression field makes the same choice.

  • Formula and Fluent switch above the field

    Switching rewrites the text in the other style.

  • Constraints group in the Entities pane

    Add from the group header, delete from the row menu or with the Delete key.
    Properties panel has ID, Description and Condition.

  • Metrics are written as expressions

    In the properties panel and in the metric drawer of Simulate.

  • A metric written in TypeScript is read-only

    Its ID, description and code show, and it can be deleted.

  • Sparkles button asks Claude for an expression from a request in words

    Shown once User settings > Labs > Metrics and constraints > Anthropic API key holds a key.
    Only an expression that passes the check replaces the text.

  • Leaving the field formats the text
Brunch and website: the assistant creates, updates and removes constraints
  • Three tools: petrinaut_create_constraint, petrinaut_update_constraint and petrinaut_remove_constraint

    Each maps to the Core action that adds, updates or removes a constraint.

  • Tool summaries and the approval prompt name the constraint a call touches
  • constraint joins the kinds a query and a Ledger address name

Known issues

  • No run is judged against a constraint

    A constraint is checked as it is typed and saved with the model.
    Nothing compiles its ConstraintProgram.

  • Four versions of the field ship side by side

    One setting chooses the version for the whole editor, to compare them on one model.

  • A metric written in TypeScript cannot be edited

    Changing one means deleting it and writing an expression.

  • A net whose transitions read metrics runs on the CPU
  • Anthropic API key is stored in the browser with the other settings

    The page sends it to the Anthropic API with the request, the expression and the names of the net.

More: components, percentiles, version C, a guide screenshot
  • Transitions inside a component read no metrics
  • A percentile costs the square of the number of tokens

    The metric surface has no sort, so it is found by counting.

  • Version C has no sparkles button
  • Guide screenshot of the full editor predates the Constraints group

Test coverage

Core tests: language, assistant loop, metric reads, IDs, file checks
  • expression.test.ts:

    Grammar, names, types, lists of tokens, the fluent style, lowering, runs, named values, a metric's code, stale bodies and the layout over lines.

  • assist.test.ts:

    assistExpression, assistInstructions and canAssist.

  • link-metrics.test.ts:

    Metrics read by ID, and metrics read by a transition.

  • entity-ids.test.ts, check-entity-ids.test.ts, migrate-legacy-entity-ids.test.ts:

    A constraint among the IDs of the root net, and expressions after a rename and after an import.

  • actions.test.ts:

    A constraint takes an ID of the root net, and a rename reaches its expression.

  • checker.test.ts:

    Metrics a lambda reads are typed, and each metric and constraint that does not check is reported.

  • language-client.test.ts:

    Errors of a metric or a constraint are left out of the count that stops a run.

  • artifacts.test.ts, surface-context.test.ts, generate-virtual-files.test.ts:

    Existing cases, with place counts in emitted programs and metrics on the surfaces.

Editor tests and checks by hand: drawer, version C, preview walk, loading between two builds
  • metric-drawer.test.tsx:

    Create from an ID and an expression, ID refusal, save with the metrics that read it, rename, and a read-only TypeScript metric.

  • use-petrinaut-mutations.test.tsx:

    A metric and a constraint are added to the document whichever net is open.

  • history.test.ts, operations.test.ts:

    History and tree edits of version C.

  • hash-agent-mounting.test.ts:

    constraint among the kinds the mounted tools take.

  • Headless walk of the preview:

    Add a constraint, type a condition, refusal of a taken ID, a metric with its value on the initial marking, and a read-only TypeScript metric, with no console error.

  • Two builds of Core, this head and its base:

    Every loading and compiling claim under File format and Stored settings.

How to test

Metric: an expression with its value under the field
  • Entities > Metrics > +

    Expect a metric_1 row and an Expression field

  • Type Infected * 2

    Expect Infected as a chip, and = 20 on the initial marking under the field

  • Type .count after Infected

    Expect Infected and .count as one pill, and the same value

  • Select infected_fraction

    Expect ID, Description and Code shown, none editable

Constraint: a condition over a run, and an ID the net has
  • Entities > Constraints > +

    Expect a constraint_1 row and a Condition field

  • Type ALWAYS(Infected < 500, 0, 50)

    Expect a frame around the call, and Judged over a run. Reads 50 time units ahead. under the field

  • Type infected_fraction in ID, press Tab

    Expect an error under ID and the row unchanged

Versions and metric reads: the version menu, and a rate that reads a metric
  • Version menu above a field > A, B, then C

    Expect the same expression in another layout each time

  • Menu > User settings > Labs > Metrics and constraints

    Expect Expression field on the version chosen last

  • Select Infection, set its rate code to return metrics.infected_fraction + 1;

    Expect no error marker in the editor

@kube
kube added this pull request to stack #10673 December 1, 2026 01:42
@vercel

vercel Bot commented Dec 1, 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 4, 2026 1:10am UTC
petrinaut Ready Ready Preview Dec 4, 2026 1:10am UTC
petrinaut-docs Ready Ready Preview Dec 4, 2026 1:10am UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Dec 4, 2026 1:10am UTC

Request Review

@kube kube self-assigned this Dec 1, 2026
@kube kube changed the title cf/fe 2396 expression language and editor prototype FE-2396: Prototype an expression language and editor for metrics and temporal constraints Dec 1, 2026
Comment on lines +111 to +113
tookLetters ||= wordCharacter.test(
transaction.startState.sliceDoc(from, to),
);

@semgrep-code-hashintel semgrep-code-hashintel Bot Dec 1, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium severity issue identified in your code:

Ensure that the regex used to compare with user supplied input is safe from regular expression denial of service.

🎈 Fixed in commit 956e8ed 🎈

Comment on lines +58 to +61
const assistant = anthropicAssistant(
anthropicApiKey,
"Add an Anthropic API key in Settings, under Labs, to have Claude write the expression.",
);

@semgrep-code-hashintel semgrep-code-hashintel Bot Dec 1, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High severity issue identified in your code:

A hardcoded API Key is identified. Store it properly in an environment variable.

🌟 Fixed in commit 157aa08 🌟

Comment on lines +397 to +400
anthropicAssistant(
apiKey,
"Type an Anthropic API key under Assistant, on the left, to have Claude write the expression.",
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High severity issue identified in your code:
A hardcoded API Key is identified. Store it properly in an environment variable.

To resolve this comment:

🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by node_api_key.

You can view more details about this finding in the Semgrep AppSec Platform.

@kube kube changed the title FE-2396: Prototype an expression language and editor for metrics and temporal constraints FE-2396: Add an expression language and field for metrics and temporal constraints Dec 1, 2026
@kube kube changed the title FE-2396: Add an expression language and field for metrics and temporal constraints FE-2396: Prototype an expression language and editor for metrics and temporal constraints Dec 1, 2026
@github-actions github-actions Bot added 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) type/eng > frontend Owned by the @frontend team area/apps area/apps > hash.design Affects the `hash.design` design site (app) labels Dec 1, 2026
Comment on lines +230 to +233
anthropicAssistant(
apiKey,
"Type an Anthropic API key under Assistant, on the left, to have Claude write the expression.",
);
Comment on lines +69 to +71
tookLetters ||= wordCharacter.test(
transaction.startState.sliceDoc(from, to),
);
kube added 2 commits December 3, 2026 20:07
One language for both, in a formula style and a fluent style: a tokenizer, a parser, a check that reports each error with a fix where it has one, a formatter, an evaluator over a state or a run, and the form a metric is stored in. A loop asks a model for an expression and feeds the check back until one passes; core holds no model and no key.
A CodeMirror field for a metric or a constraint: names of the model as chips, function calls as lightly coloured frames, completion, an argument hint, and the value or the first error under the field. A sparkles button turns the field into a request that Claude answers through the Anthropic SDK, and only an expression that passes the check replaces the text. Stories cover both styles, constraints and the assistant with a scripted model.
kube added 5 commits December 3, 2026 20:17
With Metric expressions on in Labs, the metric properties panel shows the expression field in place of the code editor for a metric written as an expression. An Anthropic API key in the same section lets the field be asked in words. Off by default; the user guide describes both.
Language: a fluent call at the end of the text no longer throws; a named condition in a constraint, a double minus and a negative percentile share lower to what they evaluate to; metrics that read metrics are checked and evaluated in linear time; converting between styles keeps the meaning of a let used as a list and refuses a name the other style would capture; the innermost binding of a name wins; a line terminator in the text cannot end the comment a metric stores it in. The assistant loop makes no call once stopped, reports an empty reply as a failed attempt, and leaves names it cannot write out of its instructions.

Field: the text stays visible when the field turns read-only under an open request; completion keeps names with an underscore; a change from outside is not written back, is not undoable from the field, and leaving an untouched field changes nothing; the error row is linked to the text for assistive technology; switching Metric expressions off forgets the API key.

The CodeMirror extensions are split by concern, the function table and the lowering share their tables with evaluation, unused exports are gone, and the stories keep one per behaviour.
…nly authoring

Constraints become entities of the model, written in the expression
language: `SDCPN.constraints`, add/update/remove actions, a `constraint`
selection kind, a Constraints group in the Entities pane and a properties
panel. This changes the file format: a net gains an optional `constraints`
list.

`metrics.<name>` reads a model metric in TypeScript metrics, lambdas and
kernels. It lowers to a `metricRef` node, and `hir/link-metrics.ts` binds
each metric read once at the top of the reader, with cycle detection.
Lambdas and kernels take the frame's place counts and offsets, so the
stepped, Monte Carlo and event-driven engines give the value at the
instant a transition is evaluated. Differential equations and transitions
of a component read none.

Metrics and constraints are written as expressions only, in the properties
panel and in the Simulate view's metric drawer. A metric written in
TypeScript, from a model saved before, is shown read-only and can be
deleted. An expression can read such a metric by name.

The net-wide check reports metrics and constraints that do not check.
Their errors never stop a run.

The expression field has four versions, chosen by the `expressionField`
user setting that replaces the Labs flag: the first one, text that breaks
between arguments, text laid out by the formatter, and slots on the tree.
Every version undoes and redoes. The named-token function form and the
Storybook model editors are removed.
… editor

The constraint panel edits the id through the rename engine, the metric
drawer's test and the mutation test move to ids, Brunch and the website
label a renamed constraint, and the guide says ID where it said name.
Comment on lines +12 to +15
return anthropicAssistant(
anthropicApiKey,
"Add an Anthropic API key in Settings, under Labs, to have Claude write the expression.",
);
The flag was a `let` set inside the mapping callback, which TypeScript narrows to its initial value at the read, so lint reported the condition as always falsy. It is now read off the mapped list.
A list of tokens written where a number is needed is how many tokens it
holds, in the check, in evaluation and in lowering, so `Infected / Population`
needs no `.count`. `.count` stays valid and gives the same body.

SUM, AVERAGE, MIN and MAX given a list are over its tokens where the next
argument reads the token, and take numbers otherwise: `MAX(Queue, Served)`
is the larger of two counts. The check decides, and evaluation and lowering
read its answer, so `evaluateExpression` takes the checked names in place of
the references. A method that reads no token is an error, because the same
tree written as a function would mean something else.
@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 $$29.4 \mathrm{ms} \pm 366 \mathrm{μs}\left({\color{red}5.43 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.55 \mathrm{ms} \pm 33.6 \mathrm{μs}\left({\color{gray}0.974 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1002 $$13.7 \mathrm{ms} \pm 147 \mathrm{μs}\left({\color{red}8.37 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$160 \mathrm{ms} \pm 2.25 \mathrm{ms}\left({\color{red}17.5 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$15.3 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{gray}3.32 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1527 $$26.5 \mathrm{ms} \pm 385 \mathrm{μs}\left({\color{red}6.31 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$29.7 \mathrm{ms} \pm 245 \mathrm{μs}\left({\color{gray}1.47 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.81 \mathrm{ms} \pm 34.2 \mathrm{μs}\left({\color{gray}-0.644 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$14.8 \mathrm{ms} \pm 188 \mathrm{μs}\left({\color{gray}3.99 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.98 \mathrm{ms} \pm 42.3 \mathrm{μs}\left({\color{gray}1.95 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.10 \mathrm{ms} \pm 29.0 \mathrm{μs}\left({\color{gray}1.03 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 52 $$3.48 \mathrm{ms} \pm 27.9 \mathrm{μs}\left({\color{gray}0.826 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.40 \mathrm{ms} \pm 40.0 \mathrm{μs}\left({\color{gray}-0.092 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.69 \mathrm{ms} \pm 35.4 \mathrm{μs}\left({\color{gray}1.81 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 108 $$4.39 \mathrm{ms} \pm 44.6 \mathrm{μs}\left({\color{gray}3.92 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.77 \mathrm{ms} \pm 41.5 \mathrm{μs}\left({\color{gray}-1.347 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.59 \mathrm{ms} \pm 29.5 \mathrm{μs}\left({\color{gray}0.243 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.43 \mathrm{ms} \pm 48.4 \mathrm{μs}\left({\color{gray}1.91 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.83 \mathrm{ms} \pm 28.0 \mathrm{μs}\left({\color{gray}0.194 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.82 \mathrm{ms} \pm 28.8 \mathrm{μs}\left({\color{gray}3.97 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 2 $$2.84 \mathrm{ms} \pm 26.8 \mathrm{μs}\left({\color{gray}0.071 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$3.15 \mathrm{ms} \pm 29.3 \mathrm{μs}\left({\color{gray}0.299 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.04 \mathrm{ms} \pm 28.6 \mathrm{μs}\left({\color{gray}3.91 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$3.19 \mathrm{ms} \pm 28.4 \mathrm{μs}\left({\color{gray}-1.965 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.19 \mathrm{ms} \pm 27.9 \mathrm{μs}\left({\color{gray}0.248 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.91 \mathrm{ms} \pm 24.5 \mathrm{μs}\left({\color{gray}0.608 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 26 $$3.05 \mathrm{ms} \pm 25.0 \mathrm{μs}\left({\color{gray}-1.017 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.66 \mathrm{ms} \pm 40.9 \mathrm{μs}\left({\color{gray}-2.283 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.17 \mathrm{ms} \pm 26.7 \mathrm{μs}\left({\color{gray}0.933 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 27 $$3.46 \mathrm{ms} \pm 28.5 \mathrm{μs}\left({\color{gray}-0.348 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.60 \mathrm{ms} \pm 33.8 \mathrm{μs}\left({\color{gray}1.43 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.12 \mathrm{ms} \pm 21.7 \mathrm{μs}\left({\color{gray}0.050 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.52 \mathrm{ms} \pm 34.1 \mathrm{μs}\left({\color{gray}1.38 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$36.7 \mathrm{ms} \pm 492 \mathrm{μs}\left({\color{gray}0.839 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$76.3 \mathrm{ms} \pm 678 \mathrm{μs}\left({\color{gray}-2.968 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$41.1 \mathrm{ms} \pm 311 \mathrm{μs}\left({\color{gray}-0.844 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$43.9 \mathrm{ms} \pm 359 \mathrm{μs}\left({\color{gray}0.017 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$51.2 \mathrm{ms} \pm 445 \mathrm{μs}\left({\color{gray}1.20 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$38.1 \mathrm{ms} \pm 269 \mathrm{μs}\left({\color{gray}0.825 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$428 \mathrm{ms} \pm 1.87 \mathrm{ms}\left({\color{gray}-1.323 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$123 \mathrm{ms} \pm 830 \mathrm{μs}\left({\color{gray}4.29 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$86.4 \mathrm{ms} \pm 679 \mathrm{μs}\left({\color{gray}-0.755 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$418 \mathrm{ms} \pm 2.73 \mathrm{ms}\left({\color{red}18.0 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$12.5 \mathrm{ms} \pm 172 \mathrm{μs}\left({\color{gray}3.55 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$12.5 \mathrm{ms} \pm 134 \mathrm{μs}\left({\color{gray}1.91 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$12.9 \mathrm{ms} \pm 165 \mathrm{μs}\left({\color{red}5.30 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$12.5 \mathrm{ms} \pm 133 \mathrm{μs}\left({\color{gray}2.88 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$12.6 \mathrm{ms} \pm 153 \mathrm{μs}\left({\color{gray}4.88 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$12.5 \mathrm{ms} \pm 135 \mathrm{μs}\left({\color{red}5.34 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$12.2 \mathrm{ms} \pm 114 \mathrm{μs}\left({\color{gray}1.66 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$12.3 \mathrm{ms} \pm 133 \mathrm{μs}\left({\color{gray}2.55 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$12.4 \mathrm{ms} \pm 160 \mathrm{μs}\left({\color{gray}3.47 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$12.4 \mathrm{ms} \pm 101 \mathrm{μs}\left({\color{gray}0.490 \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 $$14.3 \mathrm{ms} \pm 129 \mathrm{μs}\left({\color{gray}1.86 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$14.3 \mathrm{ms} \pm 134 \mathrm{μs}\left({\color{gray}2.78 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$14.3 \mathrm{ms} \pm 139 \mathrm{μs}\left({\color{gray}4.36 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$14.2 \mathrm{ms} \pm 110 \mathrm{μs}\left({\color{gray}2.26 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$14.2 \mathrm{ms} \pm 108 \mathrm{μs}\left({\color{gray}1.96 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$14.4 \mathrm{ms} \pm 126 \mathrm{μs}\left({\color{red}5.28 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$14.3 \mathrm{ms} \pm 114 \mathrm{μs}\left({\color{gray}1.59 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$14.2 \mathrm{ms} \pm 142 \mathrm{μs}\left({\color{gray}-0.507 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$14.2 \mathrm{ms} \pm 114 \mathrm{μs}\left({\color{gray}3.61 \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.32 \mathrm{ms} \pm 63.2 \mathrm{μs}\left({\color{gray}1.81 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$57.5 \mathrm{ms} \pm 587 \mathrm{μs}\left({\color{gray}-0.027 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$112 \mathrm{ms} \pm 813 \mathrm{μs}\left({\color{gray}-0.456 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$65.3 \mathrm{ms} \pm 753 \mathrm{μs}\left({\color{gray}1.07 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$74.7 \mathrm{ms} \pm 660 \mathrm{μs}\left({\color{gray}0.186 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$83.2 \mathrm{ms} \pm 764 \mathrm{μs}\left({\color{gray}1.11 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$90.7 \mathrm{ms} \pm 739 \mathrm{μs}\left({\color{gray}-0.555 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$55.2 \mathrm{ms} \pm 410 \mathrm{μs}\left({\color{gray}0.460 \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 $$84.9 \mathrm{ms} \pm 664 \mathrm{μs}\left({\color{gray}0.923 \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 $$62.9 \mathrm{ms} \pm 621 \mathrm{μs}\left({\color{gray}2.07 \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 $$71.6 \mathrm{ms} \pm 547 \mathrm{μs}\left({\color{gray}1.87 \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 $$75.4 \mathrm{ms} \pm 706 \mathrm{μs}\left({\color{gray}1.65 \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 $$74.0 \mathrm{ms} \pm 671 \mathrm{μs}\left({\color{gray}-1.120 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$126 \mathrm{ms} \pm 921 \mathrm{μs}\left({\color{gray}0.369 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$139 \mathrm{ms} \pm 899 \mathrm{μs}\left({\color{gray}1.22 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$33.5 \mathrm{ms} \pm 429 \mathrm{μs}\left({\color{gray}3.87 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$521 \mathrm{ms} \pm 1.55 \mathrm{ms}\left({\color{gray}-4.262 \mathrm{\%}}\right) $$ Flame Graph

This branch had an error being deployed

1 failed (outdated) and 4 active (1 outdated) deployments
Preview – hash — 04660580 Deployed Dec 4, 2026 by vercel[bot]
Preview – petrinaut-docs — 04660580 Deployed Dec 4, 2026 by vercel[bot]
Preview – petrinaut — 04660580 Deployed Dec 4, 2026 by vercel[bot]
Preview – hashdotdesign-tokens — 157aa086 Deployed Dec 2, 2026 by vercel[bot]
pull-request — d161ed26 Deployed Dec 1, 2026 by kube via Sourcemaps (@apps/hash-ai-worker-ts) #46718
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash.design Affects the `hash.design` design site (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) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants