Skip to content

Facade language: a borrowed resource handed out by an operation has no way to name its true origin (the parent connection), so it is invalidated by every mutating call on the child #2003

Closed

Description

@ehartford

Split from #1977 part (2) (wave-sema2). A facade operation like sqlite3_db_handle(stmt) hands out a BorrowedDatabase whose real origin is the statement's parent connection, but the only clauses are preserves param N / preserves domain D, which cover every view of an origin. Putting preserves param 0 on step would also keep column_text views alive across step — a use-after-free (SQLite documents they die there). So today let b = st.database().unwrap(); st.step(); b.changes() is refused. Not urgent: the real lib/facades/sqlite3.w has no sqlite3_db_handle item, so no live facade needs this yet.

Brief (wave-sema2 agent): Rust ties such a result to the parent lifetime (Iter<'a,T>::as_slice(&self) -> &'a [T], core/src/slice/iter.rs:135); Swift @lifetime(copy x) (experimental); Mojo returns ref[Self.origin] (dict.mojo:187). D51 §26/§38: a borrow "cannot outlive the named origin"; "unknown effect means invalidate"; preserves covers every view of that origin. Mission fit: one explicit clause on the borrowing operation naming its origin (e.g. returns borrow Database from parent of param 0) — stated once, never inferred (passes D51's 'what if this inference is wrong?') — beats a per-call preservation clause on every mutating call. Prediction: Eric rules the explicit-origin clause, his wording, ~65%. Needs Eric's ruling (D51 is his canon).

Activity

  1. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Eric's direction (2026-10-03): rule the explicit clause now. Revised draft words for the D51 facade chapter (need Eric's blessing of the words; this is his canon):

    An operation that hands out a borrow of its argument's parent states it: returns borrow T from parent T of param N. The parent is resolved through the argument resource's declared borrows clause; naming a parent the resource does not declare, or a type its parent does not have, is an error. The borrow lives as long as the parent's origin. Every operation through it is an operation on the parent's origin: it invalidates the parent's views exactly as the same call on the parent would.

    from parent Database of param 0 names the parent type, so a resource with several borrowed parents is unambiguous.

  2. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in 74e3001 (stack #2032; seed-driven battery GREEN on 2b9ad28, tree identical to main).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions