Skip to content

Lifetime domains and type reflection train: #1369, #1437, #1358, #1365 - #1369

Merged
godofecht merged 7 commits into
mainfrom
cursor/request-persistent-domains-11ad
Oct 7, 2026
Merged

godofecht merged 7 commits into
mainfrom
cursor/request-persistent-domains-11ad

Conversation

@godofecht

@godofecht godofecht commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Lane A train: #1369, #1437, #1358 and #1365, landed as one squash with one bootstrap regen.

Part of #679
Fixes #1421
Closes #684
Closes #775

What is in the train

  1. Lifetime domains and type reflection train: #1369, #1437, #1358, #1365 #1369 ([Flow 2.0 Epic] Ergonomic Memory Safety Architecture #679): request and persistent lifetime domains. The lattice is callback < frame < request < session < application < persistent. LD1 to LD4 apply to both. The [Flow 2.0] Domain-bound allocation tracking for arenas and heap regions #690 arena-domain check now uses FLOWC_RT_DOM_APPLICATION in place of a hard-coded 3.
  2. feat: persistent statics must be TransportSafe (#1421) #1437 (Lifetime domains: must values stored in persistent be TransportSafe? #1421): a @lifetime(persistent) static must have a TransportSafe type. feat: persistent statics must be TransportSafe (#1421) #1437 was stacked on Lifetime domains and type reflection train: #1369, #1437, #1358, #1365 #1369 and was merged into the Lifetime domains and type reflection train: #1369, #1437, #1358, #1365 #1369 branch at 16:21 UTC, so it never reached main. Its source changes are carried here as their own commit; its bootstrap commit is dropped.
  3. feat: sound lifetime domain propagation through struct fields (#684) #1358 ([Flow 2.0] Sound lifetime domain propagation through struct fields and collections #684): lifetime domains propagate through struct fields and collections; @lifetime(D) on a struct field and rule LD5 (accepted 2026-10-07 in docs/project/Questions.md).
  4. feat: member tables, schema revision, and native64/wasm32 layout certs (#775) #1365 (Expose stable type identity and reflection for cross-target runtime schemas #775): @schema_revision(N), type_member_count / type_member_table, and native64 / wasm32 size, align and layout certificates, registered as experimental in stability/surfaces.json (accepted 2026-10-07).

Test bookkeeping: @schema_revision is the 23rd attribute, so tests/scripts/doc_coverage.flow expects 23. Seven corpus programs that import compiler/src/parser.flow or the attribute table have new MLIR digests in compiler/fixtures/mlir/corpus.txt, recorded with parity_mlir --record; only those rows were taken.

Each PR's bootstrap commit was dropped. The bootstrap C was regenerated once, last, as its own commit (fixed point at gen2, bootstrap_from_c.sh --verify passes).

Conflicts resolved per hunk, keeping both sides: docs/language/spec-index.md (domain fields link plus main's MLIR value semantics link), compiler/src/type_id.flow (flowc_type_transport_blocker from #1421 next to the #775 exports), docs/LANGUAGE_SPEC.md (attribute placement text and table rows from both), docs/language/types.md, docs/project/CHANGELOG.md.

Gates (macOS arm64, on main 2001007; pushed rebased onto 068425f, which changes no compiler/src)

  • flowc selftest PASS; regen fixed point gen2; --verify PASS
  • typecheck_rules 166/0; parity_typecheck clean; parity_lowering PASS
  • test-lang 281/0; test-runtime 34/0; tests/cgen 142/0; parity_mlir PASS; test-scripts all pass
  • parse_coverage --check, fmt_check --check OK
  • self_host_full ALL PASS; roundtrip ALL PASS
  • tests/tools pass; script_refs, doc_links clean; type_identity 6/0; doc_coverage pass
  • tests/cli: jit_hello and test_mlir fail, the known local drift that main also has

Risk

Compiler front end only (type checker, attributes, type identity). Compact summary domain ranks shift by the two new domains, so any out-of-tree summary consumer must use the FLOWC_RT_DOM_* constants.

Copy link
Copy Markdown
Contributor Author

CI diagnosis: the new request / persistent source changes are present, but the checked-in generated state is stale. flowc self-host roundtrip reports bootstrap drift (compiler/bootstrap/flowc_stage_a.c != flowc emit of compiler/src), Tier-2/language tests therefore run a bootstrap that still only knows callback, frame, session, application, and MLIR parity has 6 stale corpus digests (test_attributes, test_parser_python_forms, test_parser_span_mutability, test_recognition_ssa, test_semantic_stack, test_typecheck_overload_integration). Regenerate/verify the bootstrap, then re-record the MLIR corpus (parity_mlir.flow --record) and rerun typecheck_rules; those are generated-state failures rather than evidence that the lifetime-domain implementation itself is wrong.

@godofecht

Copy link
Copy Markdown
Contributor Author

Design decision, 2026-10-07, decided by the project owner: accepted.

  • Lattice: callback < frame < request < session < application < persistent.
  • request may allocate and is not @rt_safe.
  • persistent is the outermost domain and outlives the process.

Follow-up opened as #1421: whether values stored in persistent must be TransportSafe (serialisable, no references into process memory).

This PR joins the merge queue. It still needs a rebase on current main and a bootstrap C regeneration in its own commit before merge. #1358 merges after it. Recorded in docs/project/Questions.md by #1422.

godofecht added a commit that referenced this pull request Oct 7, 2026
The project owner decided six open design questions on 2026-10-07:
orchestration starts as a std.orchestrate library (#723, #1393 closed),
request and persistent lifetime domains (#1369), @Lifetime on struct
fields with LD5 (#1358), last-use moves without a move keyword or COW
(#1354), the type reflection API at Experimental stability (#1365), and
the Linux release qualification policy (#1399).

Questions.md archives each one. The Flow 3.0 tracker records the
library-first rule for orchestration. Follow-up on persistent and
TransportSafe is #1421.
godofecht added a commit that referenced this pull request Oct 7, 2026
The project owner decided six open design questions on 2026-10-07:
orchestration starts as a std.orchestrate library (#723, #1393 closed),
request and persistent lifetime domains (#1369), @Lifetime on struct
fields with LD5 (#1358), last-use moves without a move keyword or COW
(#1354), the type reflection API at Experimental stability (#1365), and
the Linux release qualification policy (#1399).

Questions.md archives each one. The Flow 3.0 tracker records the
library-first rule for orchestration. Follow-up on persistent and
TransportSafe is #1421.
godofecht added a commit that referenced this pull request Oct 7, 2026
The project owner decided six open design questions on 2026-10-07:
orchestration starts as a std.orchestrate library (#723, #1393 closed),
request and persistent lifetime domains (#1369), @Lifetime on struct
fields with LD5 (#1358), last-use moves without a move keyword or COW
(#1354), the type reflection API at Experimental stability (#1365), and
the Linux release qualification policy (#1399).

Questions.md archives each one. The Flow 3.0 tracker records the
library-first rule for orchestration. Follow-up on persistent and
TransportSafe is #1421.
godofecht added a commit that referenced this pull request Oct 7, 2026
The lattice is callback < frame < request < session < application <
persistent, as accepted on 2026-10-07 (docs/project/Questions.md).
LD1-LD4 apply to both. request may allocate and is not @rt_safe.
persistent is the outermost domain: an application pointer may not be
stored in a persistent static, and an @Lifetime(application) function
may not call a persistent one. Compact summaries encode unannotated
callables as domain rank 6.

Rebased from PR #1369 onto current main; doc conflicts with region
inference (#1390) and the arena-domain rows (#690) kept both sides.
Whether persistent values must be TransportSafe is #1421.

The #690 arena-domain check hard-coded application as 3, which is
session once request is inserted; it now uses FLOWC_RT_DOM_APPLICATION
(domain_arena_ok_unannotated failed without this).
@godofecht
godofecht force-pushed the cursor/request-persistent-domains-11ad branch from 5f107a6 to 89827b6 Compare October 7, 2026 13:41
@godofecht

Copy link
Copy Markdown
Contributor Author

Prepared for merge on main e2205a79 (two commits: source fc1780dc, bootstrap regen 89827b62).

Gates on the rebased tree: flowc selftest PASS; --regen fixed point at gen2; --verify PASS; typecheck_rules 145/0; parity_typecheck clean; test-lang 275/0; test-runtime 35/0; tests/cgen 137/0; self_host_full ALL PASS; roundtrip ALL PASS; doc_links, doc_coverage, doc_examples --check-ledger clean; tests/cli 152/2 (jit_hello, test_mlir: golden drift on main).

godofecht added a commit that referenced this pull request Oct 7, 2026
LD1 now follows stores through struct fields, nested fields and array
elements of a static, so a shorter-lived reference parked inside
composite storage is an escape. @Lifetime(D) on a struct field is a
contract (rule LD5): the field may only hold D-domain or longer
references, wherever the instance lives. Accepted in the 2026-10-07
decision; merges after #1369.

Rebased from PR #1358 onto #1369 (request/persistent) and current main.
The assignment-check conflict with main keeps the local_storage guard on
"span outlives borrowed storage"; doc conflicts keep both sides.
godofecht added a commit that referenced this pull request Oct 7, 2026
The lattice is callback < frame < request < session < application <
persistent, as accepted on 2026-10-07 (docs/project/Questions.md).
LD1-LD4 apply to both. request may allocate and is not @rt_safe.
persistent is the outermost domain: an application pointer may not be
stored in a persistent static, and an @Lifetime(application) function
may not call a persistent one. Compact summaries encode unannotated
callables as domain rank 6.

Rebased from PR #1369 onto current main; doc conflicts with region
inference (#1390) and the arena-domain rows (#690) kept both sides.
Whether persistent values must be TransportSafe is #1421.

The #690 arena-domain check hard-coded application as 3, which is
session once request is inserted; it now uses FLOWC_RT_DOM_APPLICATION
(domain_arena_ok_unannotated failed without this).
@godofecht
godofecht force-pushed the cursor/request-persistent-domains-11ad branch from 82bf008 to b729c62 Compare October 7, 2026 17:57
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
LD1 now follows stores through struct fields, nested fields and array
elements of a static, so a shorter-lived reference parked inside
composite storage is an escape. @Lifetime(D) on a struct field is a
contract (rule LD5): the field may only hold D-domain or longer
references, wherever the instance lives. Accepted in the 2026-10-07
decision; merges after #1369.

Rebased from PR #1358 onto #1369 (request/persistent) and current main.
The assignment-check conflict with main keeps the local_storage guard on
"span outlives borrowed storage"; doc conflicts keep both sides.
@godofecht godofecht changed the title #679: implement request and persistent lifetime domains Lifetime domains and type reflection train: #1369, #1437, #1358, #1365 Oct 7, 2026
The lattice is callback < frame < request < session < application <
persistent, as accepted on 2026-10-07 (docs/project/Questions.md).
LD1-LD4 apply to both. request may allocate and is not @rt_safe.
persistent is the outermost domain: an application pointer may not be
stored in a persistent static, and an @Lifetime(application) function
may not call a persistent one. Compact summaries encode unannotated
callables as domain rank 6.

Rebased from PR #1369 onto current main; doc conflicts with region
inference (#1390) and the arena-domain rows (#690) kept both sides.
Whether persistent values must be TransportSafe is #1421.

The #690 arena-domain check hard-coded application as 3, which is
session once request is inserted; it now uses FLOWC_RT_DOM_APPLICATION
(domain_arena_ok_unannotated failed without this).
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.
LD1 now follows stores through struct fields, nested fields and array
elements of a static, so a shorter-lived reference parked inside
composite storage is an escape. @Lifetime(D) on a struct field is a
contract (rule LD5): the field may only hold D-domain or longer
references, wherever the instance lives. Accepted in the 2026-10-07
decision; merges after #1369.

Rebased from PR #1358 onto #1369 (request/persistent) and current main.
The assignment-check conflict with main keeps the local_storage guard on
"span outlives borrowed storage"; doc conflicts keep both sides.
#775)

The remaining slice of #775. @schema_revision(N) on structs, enums and
aliases feeds type_schema_id without changing type_family_id.
type_member_count<T>() and type_member_table<T>() expose the members.
type_sizeof_*, type_alignof_* and type_layout_* give native64 and wasm32
layout descriptors separately from the semantic IDs.

The names are public at Experimental stability per the 2026-10-07
decision; stability/surfaces.json gains a type-reflection surface.

Rebased from PR #1365 onto current main (CHANGELOG conflict kept both
sides).
@schema_revision (#775) is the 23rd attribute. Six corpus programs import compiler/src/parser.flow or attributes, whose MLIR changes with the train; their digests are re-recorded with parity_mlir --record, and only those six rows are taken.
…tion train

Fixed point at gen2; bootstrap_from_c.sh --verify passes.
@godofecht
godofecht force-pushed the cursor/request-persistent-domains-11ad branch from b729c62 to 64daee6 Compare October 7, 2026 23:09
@godofecht
godofecht enabled auto-merge October 7, 2026 23:09
@godofecht
godofecht added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit 32401c7 Oct 7, 2026
32 checks passed
@godofecht
godofecht deleted the cursor/request-persistent-domains-11ad branch October 12, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant