Skip to content

fix: don't materialize a callable leaf's built-in members as child endpoints - #307

Merged
Shinrai merged 2 commits into
nextfrom
fix/leaf-function-prototype-read
Aug 24, 2026
Merged

fix: don't materialize a callable leaf's built-in members as child endpoints#307
Shinrai merged 2 commits into
nextfrom
fix/leaf-function-prototype-read

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

👥 Contributors

…dpoints

The wrapper get trap resolved a property read to `impl[prop]` and, for any
function-valued result, wrapped it as a child endpoint and registered ownership.
On a callable leaf, that meant merely READING an inherited Function.prototype
member — `apply`, `call`, `bind`, `constructor` — (or the non-enumerable own
`prototype` slot) rewrote the leaf's loader record: it flipped from
kind "function" to "namespace" and grew a phantom child (`leaf.apply`, …). A
later leaves() or re-composition then surfaced Function.prototype.apply in place
of the leaf. `leaf.apply(thisArg, args)` — a common forwarding idiom — silently
corrupted the served surface (Reflect.apply was the only safe workaround).

The get trap now returns the function's own built-in members directly instead of
wrapping them: for a function impl, a property that is not a user-added
ENUMERABLE own property is returned as-is. Genuine enumerable own children of a
callable still materialize as endpoints. Covered in eager and lazy modes,
including a callable that carries a real user child.

Fixes #304
@cldmv-bot cldmv-bot Bot added ! fix → next v4 flow: fix contributor PR targeting the next integration branch area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure labels Aug 24, 2026
@Shinrai
Shinrai requested a lite review from Copilot August 24, 2026 12:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a UnifiedWrapper get-trap behavior where reading built-in callable members (e.g. apply/call/bind/constructor/prototype) on a callable leaf could incorrectly materialize them as child endpoints, mutating ownership records (turning a function leaf into a namespace) and creating “phantom” children.

Changes:

  • Adds a get-trap guard to return non-enumerable callable members directly instead of wrapping/materializing them as child endpoints.
  • Introduces a new Vitest regression suite covering eager and lazy modes, ensuring built-in callable members don’t mutate leaf records while real enumerable children still materialize.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/lib/handlers/unified-wrapper.mjs Adds a guard in the get trap to avoid wrapping callable built-in members as child endpoints.
tests/vitests/suites/unified-wrapper/leaf-function-prototype-read.test.vitest.mjs Adds regression coverage ensuring Function.prototype member reads don’t create phantom children and don’t mutate leaf kind/records.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib/handlers/unified-wrapper.mjs
Comment thread tests/vitests/suites/unified-wrapper/leaf-function-prototype-read.test.vitest.mjs Outdated
…port

Address Copilot review on #307: add an afterAll that removes the per-run temp
fixture dir under tmp/ (it was left behind on every run), and drop the unused
`dirname` import.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@Shinrai
Shinrai merged commit 3441eb5 into next Aug 24, 2026
25 checks passed
@cldmv-bot
cldmv-bot Bot deleted the fix/leaf-function-prototype-read branch August 24, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure ! fix → next v4 flow: fix contributor PR targeting the next integration branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants