Skip to content

feat: persistent statics must be TransportSafe (#1421) - #1437

Merged
godofecht merged 2 commits into
cursor/request-persistent-domains-11adfrom
feat/1421-persistent-transport-safe
Oct 7, 2026
Merged

godofecht merged 2 commits into
cursor/request-persistent-domains-11adfrom
feat/1421-persistent-transport-safe

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Fixes #1421. Stacked on #1369 (base branch cursor/request-persistent-domains-11ad); merge #1369 first, then rebase this onto main and regenerate the bootstrap.

Decision implemented

From the owner's decision on #1421 (2026-10-07): a value stored in persistent must be TransportSafe (the trait from #1340). The checker rejects a non-TransportSafe value stored into a persistent location, naming the field or element that carries the reference. Values read back keep their type.

Change

  • compiler/src/type_id.flow: flowc_type_transport_blocker follows the existing TransportSafe walk and returns the innermost offending struct field or type node (-1 when safe).

  • compiler/src/sem_check.flow: a @lifetime(persistent) static whose declared type is not TransportSafe is an error. Checking the declaration covers every store into it.

    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
    persistent static 'names' must hold a TransportSafe value, but its element type is `string`, which refers to process memory and does not survive a restart
    
  • Fixtures: domain_application_escape_persistent becomes domain_persistent_pointer_static (its ptr static is now rejected at the declaration, before the LD1 escape); domain_persistent_string_array is new. tests/lang/test_lifetime_request_persistent.flow stores and reads back persistent i64 and [i32; 2] statics.

  • compiler/scripts/roundtrip.flow and gate_lib.flow: sem_check's separate-compilation deps gain type_id.

  • Docs: lifetime-request-persistent.md, lifetime-domains.md, and the follow-up line in docs/project/Questions.md.

Module statics today can only be primitives, fixed arrays of primitives, strings or pointers, so the struct-field path of the diagnostic has no reachable fixture yet; it is there for when struct statics land.

Proof

Both fixtures fail with the #1369 compiler (FAIL domain_persistent_pointer_static, FAIL domain_persistent_string_array) and pass here.

Gates (on the #1369 branch)

flowc selftest PASS; --regen fixed point; --verify PASS; typecheck_rules 146/0; parity_typecheck clean; test-lang pass; self_host_full ALL PASS; roundtrip ALL PASS (after the deps fix); doc_links clean.

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.
Fixed point at gen2; bootstrap_from_c.sh --verify passes.
@godofecht
godofecht merged commit 82bf008 into cursor/request-persistent-domains-11ad Oct 7, 2026
7 checks passed
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.
@godofecht

Copy link
Copy Markdown
Contributor Author

This PR was merged into the #1369 branch while stacked, so it never reached main on its own. Its source change landed on main in #1369 as 32401c7.

@godofecht
godofecht deleted the feat/1421-persistent-transport-safe branch October 12, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant