Skip to content

FE-1162: Add Petrinaut optimization backend - #9040

Merged
kube merged 29 commits into
mainfrom
codex/petrinaut-optimization-ui
Jul 18, 2026
Merged

FE-1162: Add Petrinaut optimization backend#9040
kube merged 29 commits into
mainfrom
codex/petrinaut-optimization-ui

Conversation

@kube

@kube kube commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Add the backend flow for running scenario-parameter optimization through Petrinaut Optimizer and HASH NodeAPI. The contract supports one scenario, one objective metric, and a flat set of fixed or optimized parameters.

🔍 What does this change?

Project / package Purpose
@apps/hash-api Adds authenticated capability and optimization routes, request limits, cancellation, and SSE-to-NDJSON streaming.
@apps/petrinaut-opt Adds the FastAPI/Optuna service that drives Petrinaut CLI over stdio and publishes OpenAPI.
@hashintel/petrinaut-cli Adds optimization-manifest loading, search-space description, and trial evaluation over JSON Lines.
@hashintel/petrinaut-core Defines and validates optimization manifests/events and safely executes scenario-based trials.
@local/petrinaut-optimizer-client (new) Provides generated API types plus shared optimizer HTTP and stream decoding.
@local/repo-chores Excludes uv virtual environments from workspace license scanning.
Workspace metadata Adds the Petrinaut Core patch changeset and dependency lockfile updates.

The PR also includes CLI integration documentation and a reproducible supply-chain optimization manifest.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)

📜 Does this require a change to the docs?

The changes in this PR:

  • require changes to docs which are made as part of this PR

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

The changes in this PR:

  • affected the execution graph, and the turbo.json files have been updated to reflect this

⚠️ Known issues

  • Disconnecting the client cancels the upstream optimization.
  • Optimization is limited to one objective metric and a flat scenario-parameter search space.
  • Petrinaut scenarios contain user-authored JavaScript and require production isolation.

🐾 Next steps

  • Connect the HASH frontend to the NodeAPI optimization stream.

🛡 What tests cover this?

  • HASH API route, validation, cancellation, heartbeat, and stream-adaptation tests
  • Petrinaut Core manifest, scenario, and execution tests
  • Petrinaut CLI protocol and optimization tests
  • Shared client decoding, transport, and generated-contract drift tests
  • Petrinaut Optimizer API, CLI bridge, study, and status tests

❓ How to test this?

  1. Build Petrinaut CLI and the Petrinaut Optimizer image.
  2. Run the optimizer on port 4004.
  3. Configure NodeAPI with HASH_PETRINAUT_OPT_HOST and HASH_PETRINAUT_OPT_PORT.
  4. Verify the authenticated capabilities route, then POST an optimization manifest to /api/petrinaut-optimizer/optimize and inspect the progressive NDJSON response.

@vercel

vercel Bot commented Jul 15, 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 Jul 18, 2026 1:48am
hashdotdesign-tokens Ignored Ignored Preview Jul 18, 2026 1:48am
petrinaut Skipped Skipped Comment Jul 18, 2026 1:48am

@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 area/apps labels Jul 15, 2026
@vercel
vercel Bot temporarily deployed to Preview – petrinaut July 15, 2026 23:20 Inactive
@kube
kube force-pushed the codex/petrinaut-optimizer-endpoint branch from a6599a8 to d031e87 Compare July 16, 2026 00:06
@kube
kube force-pushed the codex/petrinaut-optimization-ui branch from 0820a43 to 77c2d96 Compare July 16, 2026 00:06
@vercel
vercel Bot temporarily deployed to Preview – petrinaut July 16, 2026 00:17 Inactive
@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) type/eng > backend Owned by the @backend team area/tests New or updated tests labels Jul 16, 2026
@kube kube changed the title FE-1162: Add Petrinaut optimization UI FE-1162: Add Petrinaut optimization workflow Jul 16, 2026
Comment thread .changeset/fresh-optimizers-stream.md Outdated
@kube
kube force-pushed the codex/petrinaut-optimizer-endpoint branch 2 times, most recently from 5a24666 to 5094e3b Compare July 16, 2026 09:46
@kube
kube force-pushed the codex/petrinaut-optimization-ui branch from e246e59 to d868b29 Compare July 16, 2026 09:47
@github-actions github-actions Bot removed the area/tests New or updated tests label Jul 16, 2026
Comment thread apps/hash-api/src/petrinaut-optimizer/setup-petrinaut-optimizer-handler.ts Outdated
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/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) area/tests New or updated tests type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team type/legal Owned by the @legal team

Development

Successfully merging this pull request may close these issues.

5 participants