Parent: #140
Profiles: #163, #164
Roadmap: #134
Dependency: #414
Pinned consumer: oven-sh/bun@4982b91e3702094330f3be3883354c52b8c01323
Pinned implementation reference: src/jsc/bindings/ZigGlobalObject.cpp
Implement the private global-object creation, test-isolation replacement, and exit teardown as one ownership-complete lifecycle slice. These symbols must create and retire real zig-js realms; they must not be aliases, inert shims, or ordinary-object factories.
Acceptance:
- Implement
Zig__GlobalObject__create(*anyopaque, i32, bool, bool, ?*anyopaque) *JSGlobalObjectas a standalone VM plus exposed realm, preserving the pinned context identifier, mini/full heap choice, eval-mode flag, worker flag, and console metadata. - Implement
Zig__GlobalObject__createForTestIsolation(old_global, console)as a new same-VM realm that preserves the script-execution-context identity and relevant embedder metadata while retiring the old realm from future lookup/use. - Implement consuming, idempotent
Zig__GlobalObject__destructOnExit: stop work, retire identifiers, clear module/job/embedding roots, collect when supported, and release the owned VM/realm without double-free or stale lookup. - Define explicit null, foreign, already-retired, retained-reference, sibling-realm, and wrong-thread behavior rather than relying on accidental C-API ownership.
- Cover metadata preservation, realm identity/prototypes, module-registry isolation, queued-work teardown, external-owner finalization, precise-GC collection, and concurrent lookup retirement. Precise collection is tracked by #414.
- Add independently compiled Home and Bun ABI fixtures plus focused Debug, ReleaseSafe, and TSan evidence.
- Pin an exact source/semantic contract, promote all three symbols in both inventories with zero unclassified entries, and update ABI docs/README without changing unrelated benchmark scores.
- Reconcile exact
mainCI before closure.