ReviewOS

home-lang/home

fix(ts): resolve qualified Program interfaces in annotation and type-argument positions

#751
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Parent

Evidence

#688 made <T extends schemas.Schema> resolve for every declaration form that owns type parameters (71c4a1a). The same interface still widens when it is written as a direct annotation instead of a constraint. On the #688 four-module oracle modules (util, errors, schemas), with the consumer changed only in how the receiver is typed:

Consumer receiverTypeScript 6.0.3Native TypeScript 7.0.2Home 71c4a1aed (ReleaseSafe)
f<T extends schemas.Schema>(schema: T), if (!(r instanceof Promise)) { ... }1× TS23221× TS23221× TS2322
f(schema: schemas.Schema), if (r instanceof Promise) throw ...1× TS23221× TS23221× TS7006
f(schema: schemas.Schema), if (!(r instanceof Promise)) { ... }1× TS23221× TS23221× TS7006
declare const bare: schemas.Schema, read inside a function, throw guard1× TS23221× TS23221× TS7006
declare const holder: Holder<schemas.Schema> with Holder<T extends schemas.Schema> { schema: T }1× TS23221× TS23221× TS7006

Each body is const r = <receiver>._zod.run({ value, issues: [] }), followed by r.issues.map((issue) => { const wrong: number = issue; return issue.code; }), so the single TS2322 is the deliberate control. The negated guard works through a constraint, which rules out the guard form. The gap is the annotation position: Schema is a projection_only Program export, and the path #688 added for constraints (typeParameterConstraintType → programContextualExportedDeclarationType) is not reached from annotations or explicit type arguments. main at 65f80a525 reports TS7006 on all five rows. (cfdec2ea3 only changes a comment.)

Fair oracle

Reuse the #688 module fixtures (issue_688_util, issue_688_errors, issue_688_schemas in packages/ts_program/src/ts_program.zig). Cover a parameter annotation, a declared const, an explicit type argument, and a class field annotation. Each must keep the deliberate wrong: number control.

Acceptance

  • TypeScript 6.0.3, tsgo 7.0.2, and Home agree on the multisets above by file, line, column, and code.
  • The fix is general to annotations and type arguments naming Program-imported types. No declaration-name special case, and the #688 contextual read projection is never promoted to a value type (#688 rejected that for twelve Zod TS2345 additions).
  • An exact Zod 4.5.2 core diagnostic identity A/B shows zero additions.
  • Full Program/checker suites and optimized builds pass, with evidence documented and linked from the README.
8 days ago

Landed on main as 8c587f6, without closing the issue.

Write-up: Annotated receivers of imported Program types (untimed), linked from the README.

Acceptance

CheckResult
All five positions (parameter, declared binding, written type argument, class parameter property, named import)TypeScript 6.0.3, native 7.0.2, and ReleaseSafe Home agree by file:line:column:code — one deliberate TS2322 each, no TS7006. main reported TS7006 on all five
Writes into the same typesno diagnostics on any engine
#688 oracle and its three controlsunchanged
SuitesProgram 212/212, checker 4,371/4,371
BuildsReleaseSafe and ReleaseFast home-tsc, zig fmt --check, git diff --check
Zod 4.5.2 core (21-file shard) vs #688 cfdec2ea3146 → 146 diagnostics, 141 → 141 identities: 0 added, 0 removed

What the fix is

  1. Member scope, not whole types. A receiver whose checked type is any keeps it; only explicitly read members are lowered from the owning declaration, which is the scope main already gives programQualifiedAssertionMemberType. Derivation covers a binding's annotation, a class field or parameter property through this, and interface members reached through bound type arguments, so holder: Holder<schemas.Schema> makes holder.schema name schemas.Schema.
  2. Precise definition rollback. UnsupportedProgramType during a declaration lowering previously cleared every Program cache, including completed imported-class registrations. Identities are monotonic, so the rollback now drops only entries at or above the watermark taken when the attempt began.

Neither half is observable alone, so they are one commit. Removing either fails a test: without the rollback only the failed-lowering graph regresses; without member scope the five annotation graphs and both #688 read tests regress.

Rejected, with measurements

  • Projection as the annotation's declared type: +38 Zod identities — 30 TS7006 in core/compile.ts plus TS2322/TS2345/TS2559/TS18048 approximation mismatches. Assignments and contextual typing observe the approximation, which is what programQualifiedAssertionMemberType's contract exists to prevent.
  • Member scope without the rollback: +29 of those TS7006. Reading schema._zod on Zod's SomeType fails to lower, and the blanket clear then discarded the Doc class registration that types doc.indented((d) => ...).

Caveats

  • The Zod figures cover the 21 src/v4/core/**/*.ts files. The pinned tree's src/v4/locales shard was deleted by the host's periodic /private/tmp cleanup mid-session, so the graph resolves one fewer module: it reproduces every core identity of the #688 run, differing only by locales/he.ts:126:47 TS7006 giving way to core/index.ts:11:26 TS2307. The locale shard is unmeasured until the pinned tree is restored, and re-running it is the one outstanding acceptance item.
  • The mirror position — values written into these annotations, where nested callback parameters stay implicitly any — is unchanged by this work and is tracked in #754.
8 days ago

Resuming the outstanding restored-locale acceptance gate from #751.

The fresh npm Zod 4.5.2 archive matches the checked-in SHA-512 exactly: 5e46170a8975d3e6daffa17f72e79657e4decd478ea975b485d789b7909d5e34d8780800420e4dd37450749f349a17c513bdbea5b96f60c5b8c32d90a7841bae. It contains all 106 production files, including 21 core roots and 63 locale roots. Evidence is retained outside the temporary-directory cleanup path.

I am building the exact #688 parent cfdec2ea3 and #751 fix 8c587f6fb with the same Zig 0.17.0-dev.1441 toolchain and ReleaseSafe settings, then comparing complete diagnostic identities on the restored core and locale projects. Both Home runs use the same fixed 3,840 MB footprint ceiling. Pinned TypeScript 6.0.3 and native TypeScript 7.0.2 will run the same projects. No completion or timing claim is made until those checks finish.

8 days ago

The restored-source audit has its exact-parent compiler ready:

  • Revision: cfdec2ea3e66bd546daaf2e0e1521bd82e7ed6e7.
  • Zig: 0.17.0-dev.1441+d5181a9c9.
  • Settings: ReleaseSafe, the existing home-tsc-strip=true option, and enable_jsc=false for the independent TypeScript target; both compared revisions will use these same settings.
  • Executable SHA-256: 2901c0daec9ee89014f49ce386f980f4785ff9d33d3ad54f9e13b6507f794a89.
  • The unstripped build was stopped at 3,868 MB against the fixed 3,840 MB footprint ceiling. The stripped retry passed at a 2,853 MB peak; the ceiling was not raised.

The exact-parent corpus check, corrected pinned-reference checks, and exact 8c587f6fb candidate build are queued behind a confirmed live full-conformance run using the shared machine lock. The initial TypeScript reference command used Home-style equals arguments and produced TS5023 usage errors; those are retained separately and are not admission evidence. The corrected commands use TypeScript's spaced CLI arguments.

No restored-corpus identity result or issue-completion claim is available yet. The issue remains open while these guarded checks finish.

8 days ago

The outstanding restored-locale gate now passes on the exact historical source revisions.

Restored Zod 4.5.2 roots#688 cfdec2ea3#751 8c587f6fbComplete identity multiset delta
Core (21 roots), diagnostics / unique identities146 / 141146 / 1410 added; 0 removed
Locales (63 roots), diagnostics / unique identities145 / 140145 / 1400 added; 0 removed
TypeScript 6.0.3 and native TypeScript 7.0.20 diagnostics on both projects0 diagnostics on both projectsboth accepted

All 106 production source files are restored from the byte-verified npm archive. Both configurations retain ordinary import closure discovery and use strict NodeNext, noEmit, skipLibCheck, and types: []. The Hebrew callback identity src/v4/locales/he.ts:126:47 TS7006 is present on both historical Home revisions; the missing-module error from the deleted shard is absent. Duplicate identities were included in the comparisons.

Both Home compilers were rebuilt with Zig 0.17.0-dev.1441+d5181a9, ReleaseSafe, and the existing symbol-stripping option under the same fixed 3,840 MB footprint ceiling. The independent TypeScript target uses enable_jsc=false on both. Stripped builds peaked at 2,853 / 2,901 MB; project runs at 2,625 / 2,630 MB (core) and 2,669 / 2,600 MB (locales), parent / fix. Every Home project exited normally with diagnostic status 1; all four reference runs exited 0.

Executable SHA-256:

  • Parent: 2901c0daec9ee89014f49ce386f980f4785ff9d33d3ad54f9e13b6507f794a89.
  • Fix: 7c7a642b08e4535dbbe48a22731df7b85f190aaee29fc63954fb1b67e64e64be.

The restored-source archive retains eight logs, both input configurations, all hashes, exits, counts, and peaks. Its internal checksums and the diagnostic multisets have been independently re-read from the packaged bytes. Archive SHA-256: b74d020f5b7f30507f6b39f8d8637bc32ae4c8c1fbf9649cbd3750f07d49fa91. The archive excludes host filesystem attributes and uses fixed timestamps and an explicit sorted member order.

This finishes the only outstanding acceptance item recorded in the earlier #751 result. The seven Program controls, exact three-engine annotation oracles, complete Program/checker suites, and optimized builds are already recorded for the unchanged #751 implementation above. This new run is a historical correctness gate, not a timing claim or current-source full-Zod result. Documentation and a brief README table are being pushed with the evidence link before closure.

8 days ago

Published the restored-source acceptance evidence in 9d27218fc, pushed directly to origin/main as Chris Breuer with no coauthors.

The exact historical parent and fix have identical complete diagnostic multisets on both restored projects: core 146/141 and locales 145/140, with zero additions and zero removals. Both reference engines accept both projects. All 13 packaged files and their input/identity hashes were independently verified from the archive. The prior seven Program controls, three-engine annotation oracles, full suites, and optimized build results remain recorded above for the unchanged implementation.

This completes the restored-locale item that had kept #751 open. The full Zod workload and expanded competitor matrix remain under #548 / #838; no new cross-compiler timing is claimed here. git diff --check passed. Pickier reports 22,074 findings (11,461 errors and 10,613 warnings) with the complete generated benchmark corpus present; the documentation change does not alter source or benchmark projects.

Sign in to comment on this issue.