Skip to content

Default applications.moduleLoader to vm-current-context#1248

Open
kriszyp wants to merge 1 commit into
mainfrom
kris/vm-current-context-default-core
Open

Default applications.moduleLoader to vm-current-context#1248
kriszyp wants to merge 1 commit into
mainfrom
kris/vm-current-context-default-core

Conversation

@kriszyp

@kriszyp kriszyp commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

Flip the default applications.moduleLoader from vm to vm-current-context.

  • components/ApplicationScope.ts — fallback when the config param is unset is now vm-current-context.
  • static/defaultConfig.yaml — shipped default updated to match.

Purpose

Under vm mode each application gets its own context with separate JavaScript intrinsics (Object, Array, Promise, …). That is a recurring source of subtle cross-realm bugs — most commonly instanceof and other identity checks failing for values that cross the application/Harper boundary. vm-current-context runs the VM loader in Harper's own context, so intrinsics are shared, while still giving each application its own module cache and a scoped harper module (tagged logger, per-app config, etc.).

Application-specific values remain available exactly as before via import ... from 'harper' / require('harper') — only the realm changes, not the scoped-export mechanism.

Where to look

  • The behavioral surface is just the default; vm remains fully available for anyone who needs separate intrinsics or the SES-constrained fetch (which only applies in vm mode).
  • No loader code paths change — an earlier idea to inject scoped globals into the CJS wrapper was dropped because require('harper') already resolves to the scoped exports, and wrapper-param injection collides with the canonical const harper = require('harperdb') pattern.

Generated with assistance from Claude (Opus 4.7); reviewed by Kris.

Switch the default application module loader from `vm` to
`vm-current-context`. In current-context mode applications share JavaScript
intrinsics with Harper, which avoids the cross-realm compatibility problems
that a separate per-application context can cause (most commonly `instanceof`
and other identity checks failing for values that cross the app/Harper
boundary). Scope-specific values (`logger`, `config`, `server`, the `harper`
API) remain available via `import ... from 'harper'` / `require('harper')`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@gemini-code-assist

This comment has been minimized.

@claude

This comment has been minimized.

@kriszyp kriszyp marked this pull request as ready for review June 11, 2026 05:16
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

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