Skip to content

FE-1556: Constraint authoring prototypes with margins, sampling, and STL - #9451

Draft
kube wants to merge 1 commit into
cf/fe-1518-optimization-constraintsfrom
cf/fe-1556-constraint-authoring-prototypes
Draft

FE-1556: Constraint authoring prototypes with margins, sampling, and STL#9451
kube wants to merge 1 commit into
cf/fe-1518-optimization-constraintsfrom
cf/fe-1556-constraint-authoring-prototypes

Conversation

@kube

@kube kube commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Stacked on #9371. Five playable Storybook prototypes for how optimization constraints get defined, so we can compare directions and pick one. Parameter constraints aim at sampling inside the safe region rather than pruning; state constraints aim at a margin-based robustness that feeds the objective as a continuous multiplier dropping to zero outside the safe region.

🔗 Related links

🔍 What does this change?

Everything lives under src/ui/dev/constraint-prototypes/ (Storybook-only, nothing ships; see its README for the tour). Open Dev / Constraint Prototypes:

  • 1 · Predicate with derived margin — constraints stay FE-1518's boolean expressions; margin, run robustness, and the smooth objective multiplier are derived (comparison slack, && = min, worst step). Includes the min-vs-mean-violation aggregation toggle that shows how min masks all but the worst constraint.
  • 2 · Margin-first — the user authors the margin itself (80 - temperature, must stay ≥ 0), with the RFC's canonical rewrite offered when a comparison is typed, and the normalisation scale as an explicit control.
  • 3 · Sentence builder — structured pickers compiling to the same expressions, judged over 24 seeded runs with an across-runs quorum (the RFC's chance constraint).
  • 4 · Parameter sampling playground — one predicate, four samplers side by side (uniform / rejection / soft / by-construction) with a per-conjunct router: bounds fold into the box, orderings become a gap transform, the affine part is a hit-and-run polytope walk, nonlinear leftovers reject. Draw/kept/leaked counts per strategy.
  • 5 · Temporal operators (extension)always, eventually, during, within, until, atEnd as plain functions with STL quantitative robustness, plus a logsumexp smoothing temperature (exact at 0).
  • Shared prototype core, unit-tested: a small expression parser/evaluator (kept syntax-compatible with the product surface), margin derivation mirroring the Python margin() on FE-1518, trace robustness, penalty multipliers, seeded samplers, and a linear-form extractor for the router.

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

Files are inside @hashintel/petrinaut but Storybook-only (stories + a dev folder that no shipped entry point imports), so nothing publishes differently.

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

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

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • The prototypes evaluate with their own small expression interpreter rather than the HIR pipeline (kept synchronous so plots re-render per slider tick); the grammar matches the product surface so authored expressions lower unchanged.
  • The toy cooling-tank model stands in for a real net; robustness numbers are illustrative, not calibrated.

🐾 Next steps

  • Pick a direction (or a combination — e.g. 1 + 3 as two entry points over one representation, 4's router as the enforcement plan, 5 as a later extension) and promote it onto the FE-1518 schema.

🛡 What tests cover this?

  • expr.test.ts, robustness.test.ts, sampling.test.ts (37 tests): parser/evaluator, margin signs vs boolean semantics, STL operators incl. windows and until, soft min/max bounds, penalty shapes, router classification, all four samplers, hit-and-run containment, toy-model determinism.

❓ How to test this?

  1. yarn exec turbo run dev --filter @hashintel/petrinaut and open Storybook (port 6006).
  2. Open Dev / Constraint Prototypes, stories 1–5.
  3. In each: drag the run parameters to cross the safe boundary and watch robustness, the margin strip, and the scored objective respond; in 4, tighten the constraint and compare each strategy's draws/kept/leaked.

📹 Demo

Screenshots pending — placeholder for drag-drop.

@vercel

vercel Bot commented Aug 30, 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:42pm
petrinaut Ready Ready Preview Aug 30, 2026 1:42pm
petrinaut-docs Ready Ready Preview Aug 30, 2026 1:42pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 30, 2026 1:42pm

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 area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash.design Affects the `hash.design` design site (app) 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.

1 participant