ReviewOS

home-lang/home

fix(ts): retain checked type metadata with compilation ownership

#488
Closed chris opened this 8 days ago ·
8 days ago

Found while implementing real cross-file type ownership for #480/#487 (tracker #416).

compileSource retains the HIR, type interner, and relation engine in Compilation, but destroys its stack-local Checker before returning. checkSourceFile points Engine.rest_signatures at Checker.rest_signatures. The returned engine therefore retains a pointer to destroyed checker state, and generic/signature metadata needed to interpret its retained TypeIds is discarded.

Move the checked declaration/signature metadata into an explicitly owned result before checker destruction, without reparsing or recreating shallow type shapes. Rebind the retained engine's rest metadata to stable result storage. Preserve type/generic maps, signature arity/rest/this metadata, predicates, overloads, and source-node provenance with the owning HIR. Keep transient flow caches out of the persistent result.

Add post-compilation relation queries and generic/predicate/metadata lifetime regressions, including independently owned compilations and cleanup. This is a prerequisite for cross-file typed resolution, not completion of #480/#487 and not grounds for benchmark readmission.

8 days ago

091f151 fixes the retained engine's dangling rest-signature reference and transfers core checked declaration/signature metadata into stable Compilation storage. The transfer rebinds the engine in the same operation, allocates no new type graphs, and retains owner-relative IDs with their HIR/interner. Post-compilation tests cover rest-tuple relations, constraints/defaults, return members, optional/this parameters, predicates, overloads, source nodes, and independent result lifetimes.

I reopened #488 after auditing the remaining semantic state. The core ownership boundary is implemented, but this is NOT yet a complete foreign-type context. NoInfer/this markers, readonly/pattern index metadata, tuple/array origins, and other interpretation/provenance tables still need systematic ownership coverage. Do not import types or readmit benchmarks by assuming the current subset is sufficient. #480/#487 remain open for actual linkage and readmission.

Final functional-source gates: 4,236 checker tests, 175 driver tests, 101 program tests, 69 CLI tests, and 25 harness/report tests pass. The default global audit still reports 14 Home failures in 132 checks; both graph workloads still fail the rejection gates. No timing or speed claim.

Documentation: https://github.com/home-lang/home/blob/97ab7d4e4/docs/docs/TS_PERFORMANCE.md#checked-type-ownership-and-assertion-returns-untimed . Local evidence: bench/vs_tsgo/results/type-ownership.DvClDP; final release SHA-256 2d1bd9e91307373ffe28b5f0af3f9efb11ea96039df3b2ad77c9540e60fee942.

8 days ago

Continuing the ownership boundary under #488 before cross-file linkage (#480/#487). The audit found that retained structural TypeIds still lose interpretation tables for NoInfer/ThisType, patterned/readonly indexes, tuple origins and symbolic spreads, generators, class visibility/nominal origins, and enums. Alias display names and concrete argument slices additionally borrow the diagnostic arena or source/program storage.

I am retaining these semantic tables with Compilation, moving allocator-owned containers intact and copying only borrowed leaf slices transactionally before checker destruction. The diagnostic arena, resolution guards, and temporary branch-flow state remain ephemeral. Tests will cover post-return metadata reads, independently owned results, nested-container cleanup, and failed capture leaving the source/destination unchanged. This is not yet cross-file ID remapping or benchmark readmission.

8 days ago

Completed the remaining ownership work in 304fd5d. Compilation now owns 113 checked metadata tables, including NoInfer/ThisType markers, index signatures, tuple origins/rest/symbolic layouts, generator slots, class visibility/nominal origins, enum provenance, and alias/signature metadata.

Allocator-owned containers move intact; six borrowed-leaf maps receive owned string/type-argument copies before any ownership mutation. The checker diagnostic arena is not retained. Exhaustive allocation-failure injection confirms rollback leaves checker/destination/engine binding unchanged. Driver tests query interpretation metadata after Checker destruction, nested class/enum metadata, and alias names/arguments after freeing caller-owned source. Independent-result and rest-signature tests continue to pass.

Validation: 4,237 checker, 178 driver, 101 program, 69 CLI tests; ReleaseFast build successful. Closing this metadata-lifetime issue does not complete owner-aware foreign-ID transfer, graph linkage, cross-file merging, cycles, or file-order behavior: #480/#487 remain open. All IDs still belong to their source HIR/interner.

Results and ownership categories: https://github.com/home-lang/home/blob/4e50814e7/docs/docs/TS_PERFORMANCE.md#semantic-metadata-ownership-and-tuple-admission-untimed . Local logs: bench/vs_tsgo/results/semantic-ownership.JD0NXP. Release SHA-256: 9e4957a5a17dab0ea15a7334ba09ac8044c6f2894101f180718ed190e314e99d.

Sign in to comment on this issue.