Skip to content

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

Merged
kube merged 1 commit into
mainfrom
claude/fe-1509-notebook-analyses
Aug 30, 2026
Merged

FE-1509: Add the notebook view's data model and layout foundations#9406
kube merged 1 commit into
mainfrom
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 30, 2026 1:16pm
petrinaut Ready Ready Preview Aug 30, 2026 1:16pm
petrinaut-docs Ready Ready Preview Aug 30, 2026 1:16pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 30, 2026 1:16pm

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 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, unexported view-layer code with no runtime wiring; behavior is covered by unit tests and does not touch auth, persistence, or simulation.

Overview
Introduces the pure, unit-tested foundation for the experimental Notebook view under ui/views/Notebook. Nothing in the app imports it yet; this layer only defines what later UI will render from.

notebook-model projects an active net into notebook cells (all five entity kinds), a shared connection index (arcs, types, equations, and word-boundary parameter references in code), dependent counts, place/transition neighbourhoods for the explorer, fuzzy name search, and a token-flow graph (buildNetGraph) that ignores canvas coordinates.

notebook-order adds topological list ordering: places/transitions follow a supplied flow order while types, equations, and parameters are inlined once before their first user, without dropping unused or disconnected cells.

net-graph-layout implements a layered Sugiyama-style layout (cycle breaking, longest-path layers, barycentre ordering) plus optional focus re-layering, SVG edge paths (including visible same-row cycle returns), and ignores stored x/y positions.

An architecture README documents the split between pure modules and future .tsx views. Vitest coverage accompanies each module.

Reviewed by Cursor Bugbot for commit 636f0d0. 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
CiaranMn
CiaranMn previously approved these changes Aug 30, 2026
Base automatically changed from claude/fe-1541-resize-handle to main August 30, 2026 13:07
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.
@kube
kube added this pull request to the merge queue Aug 30, 2026
Merged via the queue into main with commit 8b2a7ba Aug 30, 2026
56 checks passed
@kube
kube deleted the claude/fe-1509-notebook-analyses branch August 30, 2026 13:52
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.

3 participants