Skip to content

enhancement: self-host compositional set helpers in stdlib #59

Description

@vycdev2

Summary

Move the compositional set helpers set.is_empty, set.union, set.intersection, and set.difference from hardcoded checker/interpreter cases into exported compiler-shipped .jett source while preserving generic signatures, membership results, and iteration-derived result order. This is the first slice toward the required end state: every public set.* declaration is source-owned.

Source documentation

Target boundary

Every public set.* name and signature must ultimately be declared in compiler-shipped .jett source. Compositional helpers have real Jett bodies. Source declarations may delegate equality, storage, cardinality, iteration, and conversion to private trusted runtime kernels, but those kernels are implementation details rather than public compiler-owned APIs. The compiler must not retain hardcoded public set names or signatures as the final architecture; the current compiler-backed surface is transitional technical debt.

This issue is a bounded first extraction slice. Follow-up work remains required for public set.new, set.add, set.remove, set.contains, set.length, and set.to_list declarations that front the trusted kernels.

Current state and intended composition

The ten public set operations are currently compiler-backed: new, add, remove, contains, length, is_empty, to_list, union, intersection, and difference.

The language can express this first slice compositionally:

  • is_empty[T] compares the private/foundational cardinality result with zero.
  • union[T] starts with the left set and adds each right-side item through trusted storage/equality behavior.
  • intersection[T] and difference[T] iterate the left set and select items through trusted membership behavior.

The existing interpreter stores sets in insertion order. Source implementations preserve the current observable order when results are passed to set.to_list: union keeps left-side order before novel right-side items, while intersection and difference retain left-side order.

Scope

Includes:

  • Add the four exported generic declarations and real Jett bodies under compiler-shipped namespace set source.
  • Remove only those four redundant public checker signatures and interpreter bodies.
  • Preserve generic inference, explicit type arguments, membership behavior, deduplication, and current iteration-derived result order.
  • Add coverage proving normal builds and symbol/signature queries resolve the helpers from compiler-shipped set source.
  • Keep standard-library progress, design, architecture, and active extraction documentation aligned with the complete source-owned target.

Explicitly excludes:

  • Migrating set.new, set.add, set.remove, set.contains, set.length, or set.to_list in this slice.
  • Reimplementing equality, storage, cardinality, iteration, or conversion runtime behavior in Jett.
  • Defining a new language-level set ordering guarantee.
  • Changing set ownership, equality/hashability rules, generic inference, namespace/import rules, or the trusted stdlib-origin design tracked by design: define module imports and trusted stdlib origins #3.
  • HIR, MIR, native runtime, or code-generation work.

Acceptance criteria

  • Compiler-shipped stdlib source exports generic set.is_empty, set.union, set.intersection, and set.difference with their existing signatures and real Jett bodies.
  • Empty, disjoint, overlapping, duplicate-add, and result-order cases pass for inferred and explicit generic calls.
  • The four helpers no longer have hardcoded public signatures in jett_typecheck or Rust execution bodies in jett_comptime.
  • Equality, storage, cardinality, iteration, and conversion are reachable only through private trusted runtime kernels or transitional public source frontends.
  • Follow-up remains explicit for source-owned public new, add, remove, contains, length, and to_list declarations.
  • Project and dependency code still cannot reopen the builtin set namespace.
  • A focused query or loader regression identifies compiler-shipped set source as the definition location for at least one migrated helper.
  • Documentation states that all public set.* declarations become source-owned and identifies private trusted kernels as implementation details.
  • cargo fmt --check, cargo build, and cargo test -q pass.

Dependencies / open questions

Coordinate builtin-type namespace handling with PR #56 and issue #57 so string, list, and set use one narrow compiler-shipped rule rather than parallel special cases. This work must not broaden or resolve the module/import/trusted-origin policy in #3.

This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions