Skip to content

FE-629: Fix HIR kernel compilation for conditional distributions#9028

Open
ShiroKSH wants to merge 1 commit into
hashintel:mainfrom
ShiroKSH:fix/hir-conditional-kernel-output
Open

FE-629: Fix HIR kernel compilation for conditional distributions#9028
ShiroKSH wants to merge 1 commit into
hashintel:mainfrom
ShiroKSH:fix/hir-conditional-kernel-output

Conversation

@ShiroKSH

Copy link
Copy Markdown

What is the purpose of this PR?

Fix buffer-ABI compilation of real transition-kernel attributes whose conditional branches produce a number and a Distribution.

Related links

Blocked by

  • None

What does this change?

  • Materializes mixed scalar/distribution conditionals once.
  • Writes a numeric branch directly and sends only the selected distribution to the seeded RNG sink.
  • Adds regression coverage for both branches and a patch changeset for @hashintel/petrinaut-core.

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 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

  • None

Next steps

  • None

What tests cover this?

  • HIR unit tests cover the selected distribution sink path and scalar write path.
  • TypeScript and ESLint checks pass for @hashintel/petrinaut-core.

How to test this?

  1. Run yarn workspace @hashintel/petrinaut-core test:unit --run src/hir/emit-buffer-js.test.ts.
  2. Confirm the conditional distribution test passes and emits one distribution sink call for the active token while writing zero for the inactive token.

Demo

Not applicable.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@ShiroKSH is attempting to deploy a commit to the HASH Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes stochastic kernel emission and RNG sink ordering for conditional real outputs; scope is narrow and covered by a targeted unit test, but incorrect dispatch would affect simulation sampling correctness.

Overview
Fixes buffer-ABI compilation when a real transition-kernel attribute uses a conditional whose branches are a number and a Distribution (previously this shape bailed and failed to compile).

The HIR emitter introduces a mixed value kind: conditionals where both sides are scalar, distribution, or mixed are materialized once with an if/else, and kernel output codegen dispatches at runtime—numbers go to outF64, distribution objects go to __sink("dist", …), with a TypeError if the value is neither. That keeps the seeded RNG stream aligned with the branch actually taken (inactive arms that return 0 do not register a distribution sink).

Adds a regression test in emit-buffer-js.test.ts and a patch changeset for @hashintel/petrinaut-core.

Reviewed by Cursor Bugbot for commit 3abe377. Bugbot is set up for automated code reviews on this repo. Configure here.

@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 Jul 14, 2026
@ShiroKSH ShiroKSH changed the title Fix HIR kernel compilation for conditional distributions FE-629: Fix HIR kernel compilation for conditional distributions Jul 14, 2026
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.

Fix HIR kernel compilation for conditional distributions

2 participants