Skip to content

fix(hy-check): treat atomic.pointer[T] and atomic.value as unproven per GUARANTEES row 11 (HYB-E3005) - #52

Merged
limitlessprojects merged 1 commit into
limitlessprojects:mainfrom
ocakciomursel-pixel:fix/atomic-pointer-unproven
Oct 14, 2026
Merged

limitlessprojects merged 1 commit into
limitlessprojects:mainfrom
ocakciomursel-pixel:fix/atomic-pointer-unproven

Conversation

@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor

Fixes #51
Participation in #5

Problem

GUARANTEES.md row 11 specifies that sync/atomic (atomic.Pointer[T], atomic.Value) is [TBD] until T sendability and linear store/swap discipline are defined, and states verbatim: "Until then: unproven -> rejected."

Currently, foreign_named_type in compiler/crates/hy-check/src/foreign.rs maps every atomic.* type (name.starts_with("atomic.")) to Class-2 TypeShape::Atomic (sendable across task and channel boundaries), and method_result returns Some(TypeShape::Primitive) for every atomic.* method call (p.load(), etc.). This allows &p (*atomic.pointer[holder] where holder wraps a map[string]int) or &v (*atomic.value) to cross task boundaries with 0 diagnostics (OK) and race on the shared map at runtime (fatal error: concurrent map writes).

Fix

  • compiler/crates/hy-check/src/foreign.rs:
    • Restrict Class-2 TypeShape::Atomic in foreign_named_type and method_result to the scalar atomic types (atomic.int32, atomic.int64, atomic.uint32, atomic.uint64, atomic.uintptr, atomic.bool).
    • Add is_unproven_atomic(name) so atomic.pointer[...] and atomic.value resolve to TypeShape::Unknown (fail-closed per O4.9 / GUARANTEES.md row 11).
  • compiler/crates/hy-check/src/sendability.rs:
    • When a value or pointer target at a concurrency boundary has an unproven atomic type (atomic.pointer[T] / atomic.value), emit HYB-E3005 (tier0_rule: "FC") with a specific note citing GUARANTEES.md row 11 and teaching the safe alternatives (channel, mutex-guarded type, or managed("...", "atomic") hatch).
  • compiler/crates/hy-check/src/lib.rs:
    • Add regression unit test fc_atomic_pointer_and_value_reject_e3005_row_11 verifying both atomic.pointer[holder] and atomic.value reject with HYB-E3005 while scalar atomic.int64 (atomic_and_const_immutable_spawn_args_accept) remains accepted.

Verification

  • cargo test --workspace: all unit, corpus (20/20), and differential integration tests pass (0 failures).
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings.
  • hyb check on all 10 examples/*.hy: 10/10 pass.

Prepared with AI assistance.

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.

Soundness: atomic.pointer[T] and atomic.value classified as sendable Class-2 Atomic, contradicting GUARANTEES row 11 (HYB-E3005)

2 participants