Skip to content

FE-1745: Let Brunch draft Ledger-derived experiments - #9762

Draft
kostandinang wants to merge 43 commits into
mainfrom
kostandin/fe-1745-ledger-derived-experiment
Draft

kostandinang wants to merge 43 commits into
mainfrom
kostandin/fe-1745-ledger-derived-experiment

Conversation

@kostandinang

@kostandinang kostandinang commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

🌟 What is the purpose of this PR?

Mission 8 (FE-1745) makes experiment drafting part of normal Brunch modelling. Using the settled Ledger and current Petrinaut model—not keywords such as “experiment” or “optimize”—Brunch detects when an operational decision is testable, drafts an experiment, and displays it as Drafted — not run. The experiment starts only when the user presses Run, then follows Petrinaut’s existing runExperiment path, including records, progress, the “N active” indicator, and Simulate → Experiments.

When complete, this PR establishes:

  • a proactive, Ledger-derived proposal;
  • Petrinaut-owned validation against the live model without execution; and
  • one user-started run through the existing execution path.

It does not claim constraint enforcement, proposal persistence, experiment credibility, or consumer handoff (Mission 11). The first demo is intentionally constraint-free and says so.

The branch authority is libs/@hashintel/brunch-agent/MISSION.md. Lu’s Mission 8 draft is the planning record from which this cut was taken and remains the home for deferred work.

Proactive trigger behaviour

Readiness requires both Ledger meaning and model executability.

The Ledger must state the decision, objective and direction, tunable quantity with a user-provided range and unit, operating regime, and horizon. The model must contain the corresponding saved scenario, an integer- or real-typed scenario parameter, and a saved objective metric.

Model structure alone never triggers a proposal or supplies its objective. Brunch never invents bounds, units, or thresholds. It proposes once when readiness is first reached or the meaningful configuration changes; declined or completed proposals are not repeated unchanged.

When prerequisites are missing, Brunch constructs supported scenarios and metrics through new mutate_petrinaut_net operations or asks the smallest focused question. Restrictions that the current request cannot carry are recorded under unsupported and disclosed before Run is offered; optional observed metrics are labelled reported, not enforced. A load-bearing hard restriction blocks Run rather than being silently dropped.

Demo flow (support-desk staffing)

  1. User: “Help me model our support operation. We need to decide how many agents to schedule while keeping waiting times low at peak.”
  2. Brunch elicits and settles the Ledger: 2–8 agents, average waiting time as the objective, peak demand as the regime, and a two-hour horizon.
  3. Brunch constructs the net, a saved Peak demand scenario with an integer activeAgents parameter, and a saved average-waiting-time metric.
  4. Brunch drafts an experiment that varies agents from 2–8 and minimizes average waiting time. The card shows Drafted — not run · not saved with the document, with Run and Dismiss actions, while Brunch’s turn continues.
  5. The user presses Run. The top bar shows “1 active,” Simulate → Experiments updates live, and the indicator clears when the completed result remains available.

Ownership and dependencies

🔗 Related links

🚫 Blocked by

🔍 What does this change?

  • Cuts Mission 8 into this branch’s live MISSION.md, including Status, Imperative, Throughline, Proof, Constraints, Fog-line, Stop, and Deferred.
  • Exports prepareExperiment from @hashintel/petrinaut/react with a patch changeset.

🏗️ Agent notes

Delivery proceeds in work packages, each with an oracle defined in MISSION.md:

  • WP-A — scenario and metric operations: add/update/remove scenarios and metrics across mutate-petrinet.ts, mutation-record.ts, and the website executor, with per-operation tests and a loopback case.
  • WP-B — guidance: add experiment-readiness guidance to the SDCPN modelling skill, prompt, and workpiece template, covered by the packaging test.
  • WP-C — drafting tool: add draft_petrinaut_experiment with { experiment, declarations, basis, unsupported }, wire it through the Brunch and website catalogues, and cover it with schema fixtures and yarn test:native-schema.
  • WP-D — widget: prepare without execution; auto-submit status, summary, and diagnostics; supersede earlier proposals; re-prepare and diff before Run; then call experimentHost.runExperiment. Oracles cover no execution, replacement, user-started execution, and stale proposals.
  • WP-E — demo: add the support-desk case under evaluations/cases/support-desk-staffing/ and record one agent-browser run.

At the branch point, prepareExperiment was private to run-experiment.ts. None of Chris’s open PRs (#9664, #9723, #9724, #9725, #9728, #9729) touched that file, the required react/index.ts export, Petrinaut’s experiment schemas, or the relevant Brunch integration files.

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:

  • are in a state where docs changes are not yet required but will be
    • tracked in FE-1745: update Petrinaut’s ai-assistant.md if WP-D makes the Brunch panel behaviour user-facing

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

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • PetrinautExperimentRequest does not carry constraints or a constraint policy; prepareExperiment currently supplies constraints: [] and constraintPolicy: null. This PR does not change that. Restrictions are reported as unsupported, never as enforced.
  • Proposals are session-only and do not survive reload; the widget states this explicitly.

🐾 Next steps

  • Deliver WP-A through WP-E incrementally on this PR.
  • Leave constraint carriage, the Inventory avoid-state example, design E, and drawer prefill in the Mission 8 draft for a later cut.

🛡 What tests cover this?

  • Current: @hashintel/petrinaut typecheck with the new export (turbo run lint:tsc --filter @hashintel/petrinaut; 8/8 tasks successful).
  • Planned: the per-work-package oracles listed under MISSION.md → Proof obligations.

❓ How to test this?

  1. Check out the branch and run yarn install.
  2. Run npx turbo run lint:tsc --filter @hashintel/petrinaut.
  3. Confirm that import { prepareExperiment } from "@hashintel/petrinaut/react" resolves.
  4. Read libs/@hashintel/brunch-agent/MISSION.md for the live contract.

📹 Demo

Loom

lunelson and others added 22 commits September 16, 2026 16:32
Consolidate the experiment-configuration planning that was spread across the Mission 7d archive, the future spine and the Mission 11 draft into one draft, `docs/mission-drafts/8-experiment-configuration-from-the-ledger.md`, taking the freed Mission 8 number. The draft records the Petrinaut experiment terrain as read at HEAD, the Ledger-condition to experiment-destination correspondence table, the design assessment (Brunch drafts a session proposal prepared by Petrinaut's own `prepareExperiment`, the user presses Run; a thin document-entity design stays an upstream option), the upstream delta list for Petrinaut, the Brunch-side prerequisite of scenario and metric operations in `mutate_petrinaut_net`, and an implementer's entry for the handoff.

Point the spine and the Mission 9, 10 and 11 drafts at the new home, rename the spine's deployment follow-on heading to "Hosted deployment successor" now that the Mission 8 number is reused, and record the read-only dev/prod persistence audit (SQLite locally, Postgres deployed) in the spine and the worked-example draft.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0aab3-72bb-71dc-8a77-a984b3617b9c
Co-authored-by: Amp <amp@ampcode.com>
@vercel

vercel Bot commented Sep 16, 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 Sep 16, 2026 11:47pm UTC
3 Skipped Deployments
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 16, 2026 11:47pm UTC
petrinaut Skipped Skipped Sep 16, 2026 11:47pm UTC
petrinaut-docs Skipped Skipped Sep 16, 2026 11:47pm UTC

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 labels Sep 16, 2026
@CLAassistant

CLAassistant commented Sep 16, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ kostandinang
❌ ampagent
You have signed the CLA already but the status is still pending? Let us recheck it.

ampagent and others added 9 commits September 16, 2026 22:24
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
Co-authored-by: Kostandin Angjellari <ka@hash.ai>
@kostandinang
kostandinang force-pushed the kostandin/fe-1745-ledger-derived-experiment branch from 9d831dd to 9ba7047 Compare September 16, 2026 21:25
Block unsupported restrictions by default, bind confirmation to the reviewed model, and preserve draft lifecycle across remounts without sharing it across editors. Correct reporting and budget disclosures, repair Ledger-preserving integration fixtures, and address formatting and lint failures.

Co-authored-by: Kostandin Angjellari <ka@hash.ai>
lunelson and others added 5 commits September 17, 2026 00:06
…nto cursor/resolve-fe-1745-pr-conflicts

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	apps/brunch-agent/test/integration/workpiece-revisions.integration.ts
#	apps/petrinaut-website/src/main/app/local-storage-demo/live-pending-tool.integration.test.ts
#	libs/@hashintel/brunch-agent/MISSION.md
Co-authored-by: Cursor <cursoragent@cursor.com>
…nto cursor/resolve-fe-1745-pr-conflicts

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	libs/@hashintel/brunch-agent/MISSION.md
Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
vercel Bot temporarily deployed to Preview – petrinaut September 16, 2026 23:38 Inactive
@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs September 16, 2026 23:38 Inactive
Base automatically changed from ln/fe-1573-mission-7e-express to main September 17, 2026 06:38
@github-actions github-actions Bot added the area/deps Relates to third-party dependencies (area) label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

4 participants