Repository navigation
feat: stable type identity, schema IDs, and alignof (Part of #775) - #1340
Merged
Merged
Conversation
Expose type_family_id<T>(), type_schema_id<T>(), type_transport_safe<T>(), and alignof<T>() as compile-time builtins so libraries can stop assigning manual type keys. Family and schema IDs are target-independent FNV-1a 64 digests of a versioned canonical description; size and alignment stay the target ABI. Co-authored-by: Abhishek Shivakumar <[email protected]>
Co-authored-by: Abhishek Shivakumar <[email protected]>
Co-authored-by: Abhishek Shivakumar <[email protected]>
Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
marked this pull request as ready for review
October 4, 2026 18:49
compile_module cgen force-includes only listed dep headers, so the new type-identity helpers were undeclared. Emit type_id first, then -include it for cgen, and link it with the frontend objects. Co-authored-by: Abhishek Shivakumar <[email protected]>
Resolve bootstrap conflicts in favor of this branch, then keep main's cgen record-update elision and tests. type_id roundtrip wiring is unchanged. Co-authored-by: Abhishek Shivakumar <[email protected]>
Merged cgen now includes both type identity builtins and record-update copy elision. Rewrite the checked-in bootstrap C to that fixed point. Co-authored-by: Abhishek Shivakumar <[email protected]>
test_typecheck_overload_integration.flow imports typecheck.flow, whose new type-identity builtins changed the normalized MLIR digest. Refresh via parity_mlir.flow --record (also records newly accepted programs, including test_type_identity.flow). Co-authored-by: Abhishek Shivakumar <[email protected]>
Take this branch's bootstrap binary; keep main's SIMD cgen lowering and tests. type_id roundtrip wiring is unchanged. Bootstrap C will be regenerated next. Co-authored-by: Abhishek Shivakumar <[email protected]>
Merged cgen now includes type identity builtins and SIMD-aware loop lowering. Rewrite the checked-in bootstrap C to that fixed point. Co-authored-by: Abhishek Shivakumar <[email protected]>
7 of 8 tasks
#1339 added for_simd_carried and for_simd_hot_loops. Record their normalized MLIR via parity_mlir.flow --record. Co-authored-by: Abhishek Shivakumar <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
Rebased onto main (#1340). Bootstrap C now includes type identity, SIMD loop lowering, and FLOWC_PROFILE phase timers. Co-authored-by: Abhishek Shivakumar <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
Fixed-point C after rebasing onto type identity (#1340 / 0ee697b). bootstrap_from_c.sh --regen (FIXED POINT at gen3) then --verify PASS. Co-authored-by: Abhishek Shivakumar <[email protected]>
cursor Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
Rebased onto #1340 type identity (0ee697b). Bootstrap C is the fixed point of compiler/src including both type identity and the cross-module RT/lifetime summary slice. Co-authored-by: Abhishek Shivakumar <[email protected]>
This was referenced Oct 4, 2026
This was referenced Oct 5, 2026
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
* feat: persistent statics must be TransportSafe (#1421) Decided 2026-10-07: persistent outlives the process, so it may not hold a pointer, span, string or other reference into process memory. A @Lifetime(persistent) static whose declared type is not TransportSafe (#1340) is rejected, naming the field or element type that carries the reference: persistent static 'held' must hold a TransportSafe value, but its type is `ptr<i32>`, which refers to process memory and does not survive a restart flowc_type_transport_blocker in type_id.flow follows the existing TransportSafe walk and returns the innermost offending field or type. Checking the declaration covers every store into the static. domain_application_escape_persistent becomes domain_persistent_pointer_static (its ptr static is now rejected at the declaration); domain_persistent_string_array is new. The language test stores and reads back persistent i64 and [i32; 2] statics. * fix: regenerate bootstrap C after the persistent TransportSafe check Fixed point at gen2; bootstrap_from_c.sh --verify passes.
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
Decided 2026-10-07: persistent outlives the process, so it may not hold a pointer, span, string or other reference into process memory. A @Lifetime(persistent) static whose declared type is not TransportSafe (#1340) is rejected, naming the field or element type that carries the reference. flowc_type_transport_blocker in type_id.flow follows the existing TransportSafe walk and returns the innermost offending field or type. Checking the declaration covers every store into the static. domain_application_escape_persistent becomes domain_persistent_pointer_static; domain_persistent_string_array is new. The language test stores and reads back persistent i64 and [i32; 2] statics. From PR #1437, which was merged into the #1369 branch.
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
Decided 2026-10-07: persistent outlives the process, so it may not hold a pointer, span, string or other reference into process memory. A @Lifetime(persistent) static whose declared type is not TransportSafe (#1340) is rejected, naming the field or element type that carries the reference. flowc_type_transport_blocker in type_id.flow follows the existing TransportSafe walk and returns the innermost offending field or type. Checking the declaration covers every store into the static. domain_application_escape_persistent becomes domain_persistent_pointer_static; domain_persistent_string_array is new. The language test stores and reads back persistent i64 and [i32; 2] statics. From PR #1437, which was merged into the #1369 branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Part of #775.
First usable compiler surface for cross-target runtime schemas: libraries such as flow-audio can replace a manual endpoint
type_keywith compiler-derived identity, plus target size/alignment, without new syntax or runtime string reflection on the RT path.One scalar cannot be both semantic identity and an ABI certificate (a pointer-bearing struct matches on native64 and wasm32 as Flow but not as layout). This slice follows the three-level model from the issue:
type_family_id<T>() -> u64— nominal family for API identity / migration routingtype_schema_id<T>() -> u64— FNV-1a 64 of a versioned (v1;) target-independent public schema (field names/order, semantic field types, extents, enum variants, generic args)sizeof<T>()/alignof<T>() -> i64— target ABI layouttype_transport_safe<T>() -> bool— conservative TransportSafe: fixed-width scalars, fixed arrays, and structs of those; pointers/spans/strings/externs rejectedIDs are compile-time integer constants, independent of C/MLIR/Wasm lowering. The C backend emits
((uint64_t)0x…ULL); the MLIR backend emits the same constants.Overlap check
Overlap / dependency notes: No open PR covers #775. The retired Python reference lives at
archive/feat/775-type-identity. This is the Flow/flowc first slice, not the full member-table / schema-revision / native-vs-wasm layout parity work.Evidence
Baseline before this change:
sizeof<T>()existed (#952); there was no stable family/schema identity, no genericalignof<T>(), and no TransportSafe predicate. flow-audio still needs a hand-assignedtype_key.Targeted proof that exercises the changed behaviour:
flowcselftesttype_id_ok=1(hash determinism + parsed Point/Named/i32/ptr family/schema/transport)tests/lang/test_type_identity.flowfolds IDs to0x…ULLconstantstests/lang/test_type_identity.flowcovers identity stability, distinct types, field-order schema, sizeof/alignof, TransportSafetests/scripts/type_identity.flowcompiles the same public type in two declaration orders and checks field-order / field-type schema vs familyWhy that proof would detect the old failure or regression: the old compiler rejects the new builtins; a non-deterministic or lowering-dependent hash would fail the intra-compilation and cross-compilation ID comparisons; a TransportSafe that admitted pointers would fail the HasPtr/ptr cases; missing alignof would fail the Pair/Point layout checks.
Repository gate(s) run:
env -u FLOWC_IN -u FLOWC_OUT "$(./flow tool compiler/scripts/flowc_host.flow)"→flowc: PASSincludingtype_id_ok=1./compiler/scripts/bootstrap_from_c.sh --regen→ fixed point at gen2./compiler/scripts/bootstrap_from_c.sh --verify→ALL PASS bootstrap_from_c./flow test-lang→ all 262 language tests passed (includestest_type_identity.flowandtest_sizeof_generic.flow)./flow tool tests/scripts/type_identity.flow→ 3 passed (declaration order, field order vs family, field type vs schema)./flow tool compiler/scripts/fmt_check.flow --check→fmt gate OK./flow tool compiler/scripts/roundtrip.flowon1f6974cc→ALL PASSPATH=/tmp/nopy-mlir:$PATH ./flow tool compiler/scripts/parity_mlir.flowon4b9e2eba→parity_mlir: PASS(fixtures 23/23; corpus programs=2492 fail=0)./compiler/scripts/bootstrap_from_c.sh --verifyon4b9e2eba→ALL PASS bootstrap_from_cRoundtrip CI follow-up (
flowc self-host roundtripone1d331c8):compile_module cgenhost-emitscgen.flowalone and-includes only listed dep headers, soflowc_type_id_*/FLOWC_TID_*were undeclared. Wiredtype_idintocompile_module,self_emit_plan,frontend_modules(), and the g2 fixed-point list.Main catch-up after #1338 (
ad8e50c5copy elision): mergedorigin/main. Bootstrap regenerated;--verifypassed.parity_mlir CI follow-up on
472cf753:test_typecheck_overload_integration.flowimportstypecheck.flow, whose new type-identity builtins changed the normalized MLIR digest. Refreshed withparity_mlir.flow --record(official scheme).Main catch-up after #1339 (
b9ac6a1eportable C SIMD): mergedorigin/main.cgen.flowauto-merged (type identity + SIMD lowering). Bootstrap binary conflicted; regenerated to a gen2 fixed point.--recordadded digests forfor_simd_carried.flowandfor_simd_hot_loops.flow. type_id roundtrip wiring left intact. Not merged from this session.Generated/bootstrap state:
compiler/bootstrap/flowc_stage_a.cregenerated after the source edits, after merging copy elision, and after merging portable SIMD.Risk
Compatibility, performance, security, lifetime, backend, or release implications:
Additive builtins only. Existing
sizeof<T>()unchanged. Schema scheme is versioned (v1;) so a later digest can change without silently reusing keys. Full member description, schema revision attributes, and native64-vs-wasm32 layout certificates are left for later slices.docs/project/Questions.mdupdated if this needs a language-design decision.The three-level split was already decided on the issue; this PR implements that surface rather than inventing syntax.
Compatibility
docs/project/CHANGELOG.md.Agent handoff
Cloud agent implementing the first #775 slice. Do not merge from this session.