Downstream: zig-utils/zig-js#426
Embedders can currently observe only afterSweep; a nursery collector regression cannot distinguish preparation/whitening, root+graph tracing, sweep/finalization, and the post-sweep hook without patching the generic heap or embedding a clock in zig-gc. The generic collector should expose semantic phase boundaries while leaving timing and storage entirely to an opt-in binding.
Acceptance
- Define stable full/minor collection phase boundary values for prepare/trace/sweep/post-sweep transitions.
- Invoke an optional binding hook at the exact boundaries without changing collector ordering, locks, barriers, or failure behavior.
- Compile the hook away for bindings that do not declare it; zig-gc must not own a clock or counter.
- Cover full and nursery ordering, empty/no-op nursery collection, force-full fallback, and after-sweep ordering in focused tests.
- Pass the full normal and suppression-free TSan suites.
- Document the opt-in binding contract concisely and update the zig-js dependency consumer.