fix!: isolate DSL class tags across addons - #67
Draft
GrapeBaBa wants to merge 3 commits into
Draft
Conversation
GrapeBaBa
force-pushed
the
fix/isolate-addon-type-tags
branch
from
July 28, 2026 01:32
9f761f5 to
cfd74ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
DSL class tags were derived only from
@typeName(T). Separate addons commonlyrooted at
mod.zigcan therefore both containmod.Counterand receive thesame
napi_type_tag. An exported function accepting*Countercould accept anobject from the other addon, pass
napi_check_object_type_tag, and reinterpretunrelated native memory as its own class.
The identity must also remain stable when the same compiled addon is loaded
from two paths. A process-local address isolates addons, but changes across
reloads and does not provide that stability.
Description
add
zapi.addAddonIdentityfor the final addon owner'sbuild.ziggenerate
zapi_addon_identityfrom the owner'sbuild.zig.zonpackage name,version, fingerprint, and the final compile-step name
derive each class tag as:
pass the generated identity through class registration, constructors,
methods, accessors, function arguments, and return-value materialization
require distinct logical addons in one package to use unique compile-step
names and separate root modules; aliases and installed copies retain the
identity embedded in the compiled artifact
require
.identity = @import("zapi_addon_identity")only when a DSL pathtouches classes; function-only modules may continue to use
js.exportModule(@This(), .{})expose
js.NoAddonIdentityfor low-level wrapper/conversion calls that cannotaccept or return DSL classes
document Zig 0.16 local development via
zig build --fork=/path/to/zapi,because
.pathdependencies do not expose the dependency'sbuild.zigadd behavioral coverage for cross-addon rejection and compatibility between
two loaded copies of one compiled addon
add a function-only addon compile fixture that instantiates
js.exportModule(@This(), .{})Breaking change
DSL addons that export or exchange
js.classvalues must:zapi.addAddonIdentityfor the final.nodecompile step in theirbuild.zig.identity = @import("zapi_addon_identity")tojs.exportModuleThe public low-level
wrapFunction,wrapClass,convertArg,convertReturn, andcallAndConvertAPIs now take a comptime identity type.Class-free callers pass
js.NoAddonIdentity. Low-levelnapi.module.registerusers and function-only
js.exportModuleusers are unchanged.Testing
pnpm buildpnpm test— 118 JS tests plus Zig tests passedzig build -Doptimize=ReleaseSafezig build -Dtarget=x86_64-linux-gnuzig build test:example_js_dsl -Doptimize=ReleaseSafezig build test:example_addon_isolation -Doptimize=ReleaseSafepnpm lint:jszig fmt --check ...zapi.addAddonIdentity