ReviewOS

home-lang/home

feat(ts): relocate checked type graphs across source owners

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

Cross-file types still live in independent type pools, string interners, and HIRs (#480/#487; tracker #416). Metadata ownership is retained by #488, but numeric TypeIds and declaration-node IDs from another Compilation are not interchangeable with local IDs.

Add a general bulk type-graph relocation primitive that preserves all represented payload columns, shared edges, cycles, generic parameter identity, signature/index slots, enum-literal metadata, and declaration origins through explicit mapping. Preserve reserved primitive IDs; do not substitute any or rebuild shallow named shapes. Reject missing/invalid mappings and restore unpublished destination lengths on failure. Test overlapping numeric IDs, existing destination contents, cyclic/shared graphs, invalid inputs, and allocation failures.

This low-level primitive must not enable imported types in program checking until checked semantic metadata and real source-node provenance are relocated with it. Full source/file ownership, scoped lookup, cross-file merging and cycles remain under #480/#487. No benchmark readmission or timing claim from the primitive alone.

8 days ago

The raw bulk-copy prototype was rejected by a real relation test: a newly allocated literal ID compared unequal to an already-interned literal with the same value. The transfer now resolves structural dependencies iteratively and uses the destination's normal interning paths, while retaining fresh IDs for declaration-scoped objects, type parameters, and enum literals. It returns an owned source-to-destination ID map, not an affine offset.

All seven focused transfer tests pass (plus the module test root): all stored payload kinds, shared/recursive object and parameter edges, overlapping IDs across owners, real string-interner/literal/signature relations, canonical reuse for structural keys, an 8,192-node forward chain, rejected mappings/invalid references, and exhaustive allocation-failure rollback. Rollback removes newly inserted intern keys and enum entries before truncating payload columns; original keys remain valid. Unanchored cycles among immutable structural keys are rejected explicitly, not replaced with any. Such cycles are not produced by the normal Interner constructors.

Initialization fault injection separately reproduced partial-pool leaks (144 bytes on the first failing column allocation; 3,072 bytes when header reservation failed after Pool initialization). Fixed and pushed in 99a8b78 under #498.

This remains the payload layer only. CheckedTypes remapping, real HIR/source provenance, owner-aware import caching/invalidation, and program resolution still need integration under #480/#487. The new transfer operation is not yet called by program checking; no admission or speed claim.

8 days ago

Pushed canonical payload transfer in e4c0a4caa, following the initialization cleanup fix 99a8b7866. Both use the configured author without coauthors.

Documentation and the README link are pushed in 1b83d1fa1.

The full suites pass 4,246 checker, 178 driver, 101 program, 69 CLI, and 29 benchmark-harness/report tests. The final focused transfer suite passes 8/8 (seven tests plus its module root), including canonical reuse of fourteen structural keys, an 8,192-node forward dependency chain, owner separation, source destruction, real literal/signature relations, invalid references/mappings, and exhaustive allocation-failure rollback.

A fresh ReleaseFast binary (SHA-256 860760ccee9bd0935b3371da534756bf148c733bce540d51c86714e96dce962c) was audited against version-verified TS 6.0.3 and native TS 7.0.2. All eighteen positive workloads, all 42 tuple controls, and all 36 assertion controls pass. Home still fails both graph rejection gates and fourteen global-declaration cases (Home 30/44; each TypeScript baseline 44/44). Sixteen workload gates pass, not sixteen proven-equivalent speed wins. Frozen tuple/predicate inputs are unchanged; no timings were collected.

The payload primitive is not yet called by program checking. CheckedTypes remapping, real HIR/source provenance, owner-aware caching/invalidation, typed import resolution, declaration merging, and cycle/file-order handling remain under #480 and #487. Neither graph is readmitted. Results, reproduction commands, limitations, and the linked README table are documented in the canonical transfer checkpoint. Local logs remain in bench/vs_tsgo/results/type-transfer.FHPXSf.

Sign in to comment on this issue.