Skip to content

fix(binary_tree): accept any value as a tree entry - #976

Merged
martin-henz merged 3 commits into
masterfrom
fix/binary-tree-any-entry
Sep 27, 2026
Merged

martin-henz merged 3 commits into
masterfrom
fix/binary-tree-any-entry

Conversation

@martin-henz

@martin-henz martin-henz commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Problem

from binary_tree import make_tree
make_tree(4, None, None)

fails with:

TypeError: Expected argument 0 to have type 'opaque', got 'int' or 'float'

make_tree declared its entry parameter as DataType.OPAQUE. In Conductor, that type means a handle to a host-side object, not "any value", so the host's argument check rejects numbers, strings, etc. entry declared its return type as OPAQUE for the same reason. Both evaluators also check return types, so entry(t) would have failed too. Both have been broken since the Conductor migration (#680).

Fix

  • make_tree: entry parameter OPAQUE → ANY
  • entry: return type OPAQUE → ANY

The branch/tree parameters stay LIST. py-slang and js-slang both let a Python/Source list (sent as DataType.ARRAY) through where LIST is declared.

Why tests didn't catch it

  • The unit tests wrapped every entry in handler.opaque_make(...), which is exactly the one case that worked. They now use plain numberValue(...).
  • The declared signatures live on the plugin class in index.ts. binary_tree (and matrix, repeat, midi, repl, pix_n_flix, sound) set "experimentalDecorators": false, and vitest can't parse the resulting TC39 decorators. So index.ts can't be imported in tests, and no signature test like the one csg/rune have is possible. Fixing that is out of scope here and worth a follow-up.

I checked all 215 signatures in the 12 Conductor bundles by reading the code, and found no other signature bugs of this kind.

Testing

  • yarn test in binary_tree: 19/19 pass
  • yarn tsc, yarn lint (one existing jsdoc warning), yarn build: clean

🤖 Generated with Claude Code

martin-henz and others added 2 commits September 27, 2026 10:29
make_tree declared its entry parameter as DataType.OPAQUE, so the host
rejected ordinary values: make_tree(4, None, None) failed with
"Expected argument 0 to have type 'opaque', got 'int' or 'float'".

- make_tree: entry and branches are now DataType.ANY. The branches were
  DataType.LIST, which rejects trees round-tripped through Python as
  DataType.ARRAY; make_tree_func already validates them with is_tree.
- entry: returns DataType.ANY instead of OPAQUE.
- entry/left_branch/right_branch: accept DataType.ANY, for the same
  ARRAY reason (assertNonEmptyTree does the real check).
- Tests used opaque_make for every entry, which hid the bug; they now
  use plain numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@martin-henz

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T03:02:07.019629Z a81836f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a81836f2a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Only the entry parameter of make_tree and the return type of entry were
wrong. py-slang and js-slang both accept a DataType.ARRAY where LIST is
declared, so the tree parameters did not need widening to ANY. This
restores LIST for them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@martin-henz
martin-henz merged commit bc3de44 into master Sep 27, 2026
12 checks passed
@martin-henz
martin-henz deleted the fix/binary-tree-any-entry branch September 27, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant