Skip to content

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

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

FE-629: Fix HIR kernel compilation for conditional distributions#9028
ShiroKSH wants to merge 2 commits 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

Low Risk
Scoped to HIR JS emission for transition kernels; behavior change only affects previously failing conditional distribution patterns, with unit test coverage.

Overview
Fixes buffer-ABI kernel emission when a real attribute comes from a ternary whose branches are a literal number and a Distribution (previously this shape failed compilation or bailed).

The HIR emitter now represents those conditionals as a mixed value: one let plus if/else assigns either branch, and kernel writes use a runtime check—numbers go to outF64, distributions go through __sink("dist", …) only for the taken branch (inactive paths stay scalar, e.g. 0, with no extra dist sink). Invalid runtime values throw TypeError.

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

Reviewed by Cursor Bugbot for commit e6f77d2. 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

@kube kube left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM
Thanks!

@kube
kube enabled auto-merge July 21, 2026 20:00
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

3 participants