Skip to content

Add @quri/squiggle-relative-values and use it in Hub - #4174

Merged
OAGr merged 4 commits into
mainfrom
relative-values-package
Oct 19, 2026
Merged

OAGr merged 4 commits into
mainfrom
relative-values-package

Conversation

@OAGr

@OAGr OAGr commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Second of four PRs (merge after the CLI PR). Extracts Squiggle Hub's relative values views into a new package and makes Hub use it.

What

  • New @quri/squiggle-relative-values package: List, Grid and Plot views, definition schemas, ModelEvaluator with a pluggable pair cache and optional linker, and detection of relative values specs in Squiggle code ({items, fn} or {values} dicts). A /core entry point lets server code (Next.js server actions) import the evaluator without React. Examples, tests and Storybook stories.
  • Hub keeps its routes, server actions and Prisma pair cache, and renders the views through the package.

Fixes a Hub breakage from Jul 2024

856c623 switched ModelEvaluator to import "model" as model, which only exposes exported variables, so models with a plain top-level fn(a, b) = ... failed with "Dict property not found". The new evaluator reads the variable from the model's bindings, and hub: imports work again.

Verified locally

Ran Hub dev against a fresh Postgres, created a user, a model in the legacy fn(a, b) -> [distA, distB] form, a definition and an export, and checked the List, Grid and Plot tabs and Fill / Clear cache. Two bugs found during that check (a pair-chart error when an item's value is a plain number, and hub: imports fetched from production on local Hub) are fixed in the Studio PR, which sits on top of this.

🤖 Generated with Claude Code

OAGr and others added 4 commits October 19, 2026 05:32
Extract the relative values views (List, Grid, Plot), definition schemas
and ModelEvaluator from Squiggle Hub into a framework-agnostic package.

- ModelEvaluator evaluates the model directly and reads the variable from
  its bindings (non-exported variables work), accepts a pluggable
  RelativeValuesCache (in-memory by default) and an optional linker.
- relativeValuesSpecFromSqValue / findRelativeValuesExports recognize
  RV-shaped Squiggle dicts ({items, fn} or {values}).
- RelativeValuesDashboard / RelativeValuesSpecDashboard render the views
  with built-in tabs.
- Examples ported from the original relative-values app, with tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Server code (e.g. Next.js server actions) can import ModelEvaluator,
schemas and spec helpers from @quri/squiggle-relative-values/core
without pulling in React components. Component modules that use hooks
or context are marked with "use client".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hub keeps its routes, server actions and Prisma-backed pair cache, and
now renders the views and evaluates models via the shared package.

This also fixes relative values pages that broke in 856c623 (Jul
2024), when ModelEvaluator switched from setContinues to
`import "model" as model`: imports only expose exported variables, so
models with a plain top-level `fn(a, b) = ...` failed with "Dict
property not found". The new evaluator reads the variable from the
model's bindings. Hub imports (`import "hub:owner/slug"`) are
supported again via a linker that creates current SqModules.

Also removes a leftover 1s sleep in the relative values layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stories run the example .squiggle files and render a dashboard for each
relative values spec found (List/Grid/Plot), plus an invalid spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OAGr
OAGr requested a review from berekuk as a code owner October 19, 2026 15:55
@github-project-automation github-project-automation Bot moved this to 🆕 To prioritize in Overview Oct 19, 2026
@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
fermi-contest-2025-02 Ready Ready Preview Oct 19, 2026 3:59pm UTC
quri-hub Ready Ready Preview Oct 19, 2026 3:59pm UTC
quri-ui Ready Ready Preview Oct 19, 2026 3:59pm UTC
squiggle-components Ready Ready Preview Oct 19, 2026 3:59pm UTC
squiggle-website Ready Ready Preview Oct 19, 2026 3:59pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 07f647d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

This branch was successfully deployed

5 active deployments
Preview – quri-hub — 07f647d7 Deployed Oct 19, 2026 by vercel[bot]
Preview – squiggle-website — 07f647d7 Deployed Oct 19, 2026 by vercel[bot]
Preview – squiggle-components — 07f647d7 Deployed Oct 19, 2026 by vercel[bot]
Preview – fermi-contest-2025-02 — 07f647d7 Deployed Oct 19, 2026 by vercel[bot]
Preview – quri-ui — 07f647d7 Deployed Oct 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant