Skip to content

FE-1509: Add the notebook view's data model and layout foundations - #9406

Open
kube wants to merge 1 commit into
claude/fe-1541-resize-handlefrom
claude/fe-1509-notebook-analyses
Open

FE-1509: Add the notebook view's data model and layout foundations#9406
kube wants to merge 1 commit into
claude/fe-1541-resize-handlefrom
claude/fe-1509-notebook-analyses

Conversation

@kube

@kube kube commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

First data layer of the Notebook view stack, stacked on #9429: the pure projections the view renders from. No UI changes — nothing here is reachable until the next layer lands.

🔗 Related links

🔍 What does this change?

  • notebook-model: projects an SDCPN into a flat cell list and a single dependency-edge index covering all five entity kinds; both gutter directions derive from the same edges so they cannot disagree. Parameter usage is a word-boundary text match against transition and equation code.
  • notebook-order: topological cell ordering that inlines each type, equation and parameter just before its first user, without ever dropping a cell.
  • net-graph-layout: a cut-down Sugiyama layered layout (DFS cycle-breaking, longest-path layering, barycentre ordering) plus a focus mode that re-layers by hop distance from one node, with unreachable components keeping their own layered band.
  • The notebook layer's architecture-docs README.

The structural analyses (cycles, initial places) are deliberately not here — they arrive above the view in #9431/#9432 for separate review.

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
    • one patch changeset for the whole stack ships in the top PR

📜 Does this require a change to the docs?

The changes in this PR:

  • are in a state where docs changes are not yet required but will be
    • this is tracked in: the user-docs PR at the top of this stack

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

notebook-model.test.ts (cell projections, connection index, fuzzy match, dependent counts, net graph), notebook-order.test.ts (inlining, unused declarations, never dropping cells), net-graph-layout.test.ts (layering, cycle breaking, focus mode, edge geometry, determinism).

❓ How to test this?

  1. npx turbo run test:unit --filter @hashintel/petrinaut

@kube kube self-assigned this Aug 28, 2026
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 29, 2026 2:18pm
petrinaut Ready Ready Preview Aug 29, 2026 2:18pm
petrinaut-docs Ready Ready Preview Aug 29, 2026 2:18pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 29, 2026 2:18pm

Request Review

@github-actions github-actions Bot added 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 type/eng > backend Owned by the @backend team labels Aug 28, 2026
Comment thread libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts Outdated
Comment thread libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts Outdated
@semgrep-code-hashintel

Copy link
Copy Markdown

Semgrep found 1 detect-non-literal-regexp finding:

  • libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts

RegExp() called with a variableName function argument, this might allow an attacker to cause a Regular Expression Denial-of-Service (ReDoS) within your application as RegExP blocks the main thread. For this reason, it is recommended to use hardcoded regexes instead. If your regex is run on user-controlled input, consider performing input validation or use a regex checking/sanitization library such as https://www.npmjs.com/package/recheck to verify that the regex does not appear vulnerable to ReDoS.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/hashintel/hash/blob/37fa8fec26558cdaa52191e602ef3fc9894682eb/libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts#L197 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 197] variableName</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/hashintel/hash/blob/37fa8fec26558cdaa52191e602ef3fc9894682eb/libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts#L197 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 197] variableName</a>"]

            v3["<a href=https://github.com/hashintel/hash/blob/37fa8fec26558cdaa52191e602ef3fc9894682eb/libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts#L202 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 202] escapeRegExp</a>"]

            v4["<a href=https://github.com/hashintel/hash/blob/37fa8fec26558cdaa52191e602ef3fc9894682eb/libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts#L190 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 190] value</a>"]

            v5["<a href=https://github.com/hashintel/hash/blob/37fa8fec26558cdaa52191e602ef3fc9894682eb/libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts#L202 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 202] `</a>"]
        end
            v2 --> v3
            v3 --> v4
            v4 --> v5
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/hashintel/hash/blob/37fa8fec26558cdaa52191e602ef3fc9894682eb/libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts#L202 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 202] new RegExp(`\\b${escapeRegExp(variableName)}\\b`, &quot;u&quot;)</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading

Comment thread libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts Fixed
Comment thread libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts Fixed
Comment thread libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts Fixed
@kube
kube changed the base branch from main to cf/fe-1538-worksheet-focus-primitives August 28, 2026 18:34
@kube
kube force-pushed the claude/fe-1509-notebook-analyses branch from 37fa8fe to d32fadc Compare August 28, 2026 18:34
@kube
kube changed the base branch from cf/fe-1538-worksheet-focus-primitives to main August 28, 2026 18:35
@github-actions github-actions Bot added the area/apps > hash.design Affects the `hash.design` design site (app) label Aug 28, 2026
@kube
kube changed the base branch from main to cf/fe-1538-worksheet-focus-primitives August 28, 2026 18:36
@github-actions github-actions Bot removed the area/apps > hash.design Affects the `hash.design` design site (app) label Aug 28, 2026
@kube
kube changed the base branch from cf/fe-1538-worksheet-focus-primitives to claude/fe-1538-worksheet-mirror August 28, 2026 18:44
@kube
kube force-pushed the claude/fe-1509-notebook-analyses branch from d32fadc to 12bece8 Compare August 28, 2026 18:44
@kube
kube changed the base branch from claude/fe-1538-worksheet-mirror to main August 28, 2026 22:32
@github-actions github-actions Bot added the area/apps > hash.design Affects the `hash.design` design site (app) label Aug 28, 2026
@kube
kube force-pushed the claude/fe-1509-notebook-analyses branch from 12bece8 to 2321609 Compare August 28, 2026 22:34
@github-actions github-actions Bot removed the area/apps > hash.design Affects the `hash.design` design site (app) label Aug 28, 2026
@kube kube changed the title FE-1509: Add notebook structural analyses and a resize primitive FE-1509: Add the notebook view's structural analyses Aug 29, 2026
@kube
kube changed the base branch from main to claude/fe-1541-resize-handle August 29, 2026 01:38
@kube
kube force-pushed the claude/fe-1509-notebook-analyses branch from 2321609 to 48e4267 Compare August 29, 2026 01:38
@kube
kube force-pushed the claude/fe-1509-notebook-analyses branch from 48e4267 to e571362 Compare August 29, 2026 02:14
@github-actions github-actions Bot removed the type/eng > backend Owned by the @backend team label Aug 29, 2026
@kube kube changed the title FE-1509: Add the notebook view's structural analyses FE-1509: Add the notebook view's data model and layout foundations Aug 29, 2026
@kube
kube requested review from CiaranMn and YannisZa August 29, 2026 02:28
@kube
kube marked this pull request as ready for review August 29, 2026 02:28
@cursor

cursor Bot commented Aug 29, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
New, untested-in-prod modules under ui/views/Notebook with no app integration; behavior is covered by unit tests and does not alter existing editor or mutation paths.

Overview
Adds the pure data layer for the experimental Notebook view: no UI wiring yet, so nothing user-facing changes until follow-up PRs land.

notebook-model projects an active net into flat cells (all five entity kinds), a single dependency connection index (arcs, types, equations, word-boundary parameter references in code), token-flow buildNetGraph, neighbourhood splitting for cycles, dependent counts, and fuzzy name search for cell filtering.

notebook-order implements topological list ordering: places/transitions follow a supplied flow order (e.g. from the diagram), with types, equations, and parameters inlined once before their first user; unused or off-graph cells are appended, never dropped.

net-graph-layout lays out the whole-net graph from arcs only (ignores canvas x/y): DFS cycle breaking, longest-path layering, barycentre ordering, optional focus re-layering (upstream above, downstream below), SVG edgePath for forward drops and bowed return edges.

Includes architecture README and broad Vitest coverage for all three modules.

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

@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 e571362. Configure here.

Comment thread libs/@hashintel/petrinaut/src/ui/views/Notebook/notebook-model.ts
Pure, unit-tested projections of an SDCPN for the notebook view built
on top of them: the cell list and its dependency-edge index covering
all five entity kinds, topological cell ordering with declarations
inlined before their first user, and a cut-down Sugiyama layered
layout with a focus mode that re-layers by hop distance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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