Parent: #134 Required by: #324 Related: #97, #144
Problem
Value stores JavaScript strings as *StringCell, but src/gc.zig currently treats every non-object value as an immediate primitive. Runtime StringCells and their byte storage are therefore arena-permanent and cannot participate in precise liveness or exact external-buffer finalization. That blocks #324 and leaves allocation-heavy string workloads outside the real heap lifecycle.
Scope
- Add an explicit heap-managed StringCell kind and distinguish static/intern-table/arena cells from collectible runtime cells without pointer guessing.
- Route fallible runtime string construction through the active context heap when GC is enabled, retaining the existing explicit arena mode where configured.
- Trace string-valued roots and edges everywhere
Valueis traced, including interpreter frames, environments, object slots/elements/accessors, promises, modules, workers, C-API handles, debugger state, temporary roots, and concurrent snapshots. - Finalize owned string bytes exactly once and provide a general external-owner finalizer record usable by #324; callbacks must run outside collector/internal object locks and remain safe under reentry.
- Preserve canonical WTF-8 content, equality/hash behavior, atom/intern ownership, static literals, sibling-realm sharing, and no-GIL memory ordering.
- Integrate the required cell-kind/finalizer support into
~/Code/Libraries/zig-gcas a separately committed dependency change only if the generic collector needs extension.
Acceptance
- Focused tests prove reachable strings survive repeated collections and unreachable strings release owned bytes/external owners exactly once.
- Cover empty/Latin-1/UTF-8/astral/lone-surrogate strings, concatenation/rope results, property keys, closures, promises, modules, C-API protection, temporary roots, explicit GC during callbacks, context teardown, and injected OOM.
- Stress high-churn strings in arena and GC modes; demonstrate bounded live bytes after collections and no regressions in equality or observable string semantics.
- Run leak/finalizer accounting and relevant no-GIL/TSan stress, including concurrent marking snapshots if enabled.
- Update GC design/status documentation and link completion evidence to #324, #97, #144, and #134.
- Accept one full CI matrix before closure.