Skip to content

PROD-58888: support jarvis-emitter v3 (meaco 2.0.0) - #1

Merged
erezmce merged 7 commits into
masterfrom
PROD-58888-jarvis-emitter-v3-support
May 17, 2026
Merged

PROD-58888: support jarvis-emitter v3 (meaco 2.0.0)#1
erezmce merged 7 commits into
masterfrom
PROD-58888-jarvis-emitter-v3-support

Conversation

@greg3d

@greg3d greg3d commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Major bump: meaco 1.0.32.0.0.
  • dependencies."jarvis-emitter" ^2.0.4^3.0.2 (caret — future 3.x picked up automatically).
  • Add a duck-type fallback in the JarvisEmitter detection branch in index.js so coroutines correctly await JarvisEmitter subclasses (e.g. gen2's NPPHandler) and tolerate cases where two jarvis-emitter copies coexist in the resolved tree (instanceof fails across duplicate class identities).
  • Guard the detection branch against null-prototype yields (Object.create(null)).
  • Add three regression specs covering the duck-type fallback and the null-prototype guard.

Why a major bump

Bumping jarvis-emitter from ^2.0.4 to ^3.0.2 is a transitive major upgrade. Per semver it can't ride a meaco minor — every meaco@^1 consumer would silently get a different jarvis-emitter major on their next install. So this PR releases as meaco@2.0.0.

In the mceSystems ecosystem this is also the honest framing: every internal consumer (mce/gen3, mce-2nd-gen/gen2, libijs, mce-aura-agent) is migrating to jarvis-emitter@3 in lockstep with this release.

Context — PROD-58888

The gen3 framework was upgraded to jarvis-emitter@3.0.2 while meaco@1.0.4 still pinned "jarvis-emitter": "^2.0.4". npm couldn't satisfy meaco's range from the hoisted v3 and nested a separate v2 copy under meaco/node_modules/jarvis-emitter. Two JarvisEmitter class objects coexisted at runtime; instanceof JarvisEmitter returned false for v3 instances created elsewhere (e.g. gen2's NPPHandler extends JarvisEmitter) → meaco's detection at index.js:37 fell through → yielded NPPHandler returned unresolved → device sessions closed ~1 s after connect.

Two complementary fixes in this PR:

  1. Range — moving meaco to ^3.0.2 lets npm satisfy meaco's range from the framework's hoisted v3, so no nested duplicate is created.
  2. Defensive — the duck-type fallback (typeof promise.done === "function" && typeof promise.callDone === "function") keeps meaco robust if a future major mismatch slips through (e.g. a JarvisEmitter subclass with a different constructor.name). The null-prototype guard prevents TypeError on Object.create(null) yields.

Merge / release order

This PR is #1 of 5 across repos for PROD-58888:

  1. meaco ← this PR
  2. publish meaco@2.0.0 to npm
  3. mce (gen3) PR — bumps meaco to ^2.0.0
  4. libijs PR + mce-aura-agent PR
  5. mce-2nd-gen PR — bumps jarvis-emitter + meaco (regenerate lockfiles at install time against published meaco@2.0.0)

Test plan

  • npm test9/9 mocha specs pass (6 original + 3 new for duck-type detection and null-proto guard)
  • Clean npm install resolves a single jarvis-emitter@3.0.2
  • Smoke against framework once published

Bump jarvis-emitter peer to ^3.0.2 and bump meaco to 1.1.0.

Add a duck-type fallback in the JarvisEmitter detection branch in
index.js so coroutines correctly await JarvisEmitter subclasses (e.g.
NPPHandler) and tolerate cases where two jarvis-emitter copies coexist
in the resolved module tree — `instanceof JarvisEmitter` returns false
across duplicate copies because the class identities differ.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 17, 2026 10:20
@greg3d greg3d self-assigned this May 17, 2026

Copilot AI 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.

Pull request overview

Updates meaco to support jarvis-emitter@3.x and improves coroutine yield detection so JarvisEmitter-like objects (including subclasses and scenarios with duplicate installed copies) are awaited correctly.

Changes:

  • Bump meaco version to 1.1.0 and update jarvis-emitter dependency range to ^3.0.2.
  • Extend the JarvisEmitter detection branch in index.js with a duck-typing fallback (done/callDone).

Reviewed changes

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

File Description
package.json Version bump + widen jarvis-emitter dependency range to v3.
index.js Add duck-typed JarvisEmitter detection to handle subclasses / duplicate installs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread index.js Outdated
Comment thread index.js Outdated
Comment thread package.json
greg3d and others added 2 commits May 17, 2026 13:32
Address PR review:

- Guard the JarvisEmitter detection branch with
  `typeof promise === "object" && promise.constructor` before reading
  `.constructor.name`, so a null-prototype yield (e.g. Object.create(null))
  falls through to callDone instead of throwing TypeError.

- Add three mocha specs covering the duck-type fallback that this PR
  introduced:
  1. Yielding an emitter-like object that fails both
     `instanceof JarvisEmitter` and `constructor.name === "JarvisEmitter"` —
     the gen2/NPPHandler scenario where two jarvis-emitter copies coexist.
  2. Error path on the same emitter-like object — verifies the error
     registerer is wired up correctly on duck-typed objects.
  3. Null-prototype yield falls through cleanly to callDone instead of
     crashing the coroutine runner.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per PR review, the packaging intent is that consumers provide the
JarvisEmitter implementation — meaco both returns JarvisEmitter
instances and checks `instanceof JarvisEmitter` against the consumer's
copy. Listing it as a regular dependency invited nested duplicate
copies (the root cause of PROD-58888 itself: meaco@1.0.4's
"jarvis-emitter": "^2.0.4" forced a nested v2 alongside the framework's
hoisted v3).

Move to peerDependencies (npm 7+ enforces a single shared copy across
the tree) and add to devDependencies so the mocha suite can install
its own copy for local testing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

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

Comment thread package.json Outdated
Comment thread package.json
Comment thread test/test.js Outdated
greg3d and others added 2 commits May 17, 2026 13:42
Keep jarvis-emitter under dependencies — matches meaco@1.0.x packaging
and is invisible to existing consumers (who all declare jarvis-emitter
directly anyway). Peer-dep semantics would risk install-time
warnings/regressions on older npm without adding meaningful protection,
since the duck-type fallback added in this PR already handles the
duplicate-class-identity case at runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

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

@nirhen nirhen 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.

Semver concern on the version bump — see inline comment on package.json.

Comment thread package.json
greg3d and others added 2 commits May 17, 2026 17:23
Per review (nirhen): bumping the range from ^2.0.4 to ^3.0.2 under a
meaco minor bump (1.0.3 -> 1.1.0) silently forces every meaco@^1
consumer onto a transitive major upgrade. Per semver this would
require meaco@2.0.0.

The duck-type fallback added in this PR already handles both v2 and v3
emitter shapes at runtime (.done/.error/.catch/.callDone are unchanged
across majors). Accepting both ranges lets npm dedupe to whatever the
consumer's tree already has, avoiding the two-copies-in-tree scenario
this PR was written to fix for one caller — and not reproducing it for
every other consumer who happens to be on v2.

Verified by running the mocha suite (9/9) against both
jarvis-emitter@2.1.4 and @3.0.2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per review (nirhen): widening the jarvis-emitter range under a minor
bump silently forces a transitive major upgrade on every meaco@^1
consumer. The correct semver move is to release this as meaco@2.0.0
with jarvis-emitter pinned to ^3.0.2 (caret — future 3.x patches and
minors are picked up automatically without further meaco bumps).

In the mceSystems ecosystem this is also the more honest call: every
internal consumer (mce/gen3, mce-2nd-gen/gen2, libijs, mce-aura-agent)
is migrating to jarvis-emitter@3 in lockstep with this release. No
consumer is staying on v2, so the OR-range was hedging against a
population that doesn't exist here.

The duck-type fallback and null-prototype guard added earlier in this
PR remain — they protect against subclass detection (e.g. NPPHandler)
and any future duplicate-copy scenario regardless of version pin.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@greg3d greg3d changed the title PROD-58888: support jarvis-emitter v3 (meaco 1.1.0) PROD-58888: support jarvis-emitter v3 (meaco 2.0.0) May 17, 2026
@greg3d
greg3d requested review from Copilot and nirhen May 17, 2026 14:45

Copilot AI 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.

Pull request overview

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

@erezmce
erezmce merged commit 0fdaf1c into master May 17, 2026
4 checks passed
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.

4 participants