language: the design of foreign functions #84

Closed
opened 2026-10-05 21:07:18 +00:00 by orion · 10 comments
Collaborator

Context

Foreign functions are a draft (CONCEPT); std/gpu needs them. The decision about foreign in published packages belongs to it.

Source

Acceptance criteria

  • A design record
  • The owner signs off

Dependencies

None known.

Moved from the planning lists of the docs; the design record stays the specification.

## Context Foreign functions are a draft (CONCEPT); `std/gpu` needs them. The decision about `foreign` in published packages belongs to it. ## Source - [COMPUTE.md section 2](https://git.torb.dev/torbscript/language/src/commit/393ef2608e4a60b8ff76d8b6b408951b822d887d/docs/design/COMPUTE.md#L45) ## Acceptance criteria - [ ] A design record - [ ] The owner signs off ## Dependencies None known. _Moved from the planning lists of the docs; the design record stays the specification._
Author
Collaborator

[loop:torbscript] intake: in scope (author orion, label loop), source COMPUTE.md section 2, not a duplicate. A design-record issue on foreign functions; the technical design is decided by the loop in refine, but the record asks for the owner's sign-off and the decision about foreign in published packages touches a published contract, so refine files that part as an owner decision. next: refine, waiting (ready buffer full: #4, #163, #164, #223 are ready) until 2026-10-10T04:00:00Z

[loop:torbscript] intake: in scope (author orion, label loop), source COMPUTE.md section 2, not a duplicate. A design-record issue on foreign functions; the technical design is decided by the loop in refine, but the record asks for the owner's sign-off and the decision about `foreign` in published packages touches a published contract, so refine files that part as an owner decision. next: refine, waiting (ready buffer full: #4, #163, #164, #223 are ready) until 2026-10-10T04:00:00Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261024 until 2026-10-24T04:14:22Z

[loop:torbscript] claim refine by session:loop-torbscript-20261024 until 2026-10-24T04:14:22Z
Author
Collaborator

[loop:torbscript] decided by the loop: split. The technical design (types and ABI, how the C back end and the VM call, library resolution, ownership, callbacks, slices) is separable and goes to #459 (docs/design/FOREIGN.md, docs only, one commit), which is ready. Reasoning: foreign is parsed and shape-checked today, the capability "foreign functions" is already derived from source (compiler/src/package/archive.trb), the sandbox never grants it, and Pointer/CString exist nowhere in std/ - so the record has to fix the mechanics before std/gpu (#85). Open technical questions are decided inside #459, not asked. Two inconsistencies are resolved there: CONCEPT wants a foreign note in project.trb while PROJECT.md section 1 says a manifest switch is a second source of truth (working assumption: capability from source, project.trb only maps library names), and OS.md section 8 cites rule 7 of the sandbox page where it is rule 8.

[loop:torbscript] owner decision: may a published package declare foreign functions (a binding to a C library) and may it carry C sources? This is the published contract of the registry (RELEASE.md section 2 names it as a 1.0 decision; FIRST-PARTY.md row 7, torb/sqlite, cannot be built until it is answered), so the loop does not decide it. Options: (1) none: published packages stay pure TorbScript; (2) declarations only, against libraries already on the user's machine, no C sources in the package; (3) as (2), and first-party packages (torb/*) may also ship C sources that the toolchain compiles; (4) any package may ship C sources. Whatever is chosen, foreign stays visible in source, shown by torb add and the lock, and never grantable to a sandboxed script. Recommendation: (2) - it unlocks bindings such as SQLite on Linux and macOS, keeps the registry a store of source that runs and builds nothing, and leaves (3) open as a later, separate decision; (1) blocks torb/sqlite for good, (4) puts unreviewed C into every consumer's build. The answer is written into the open section of the record by a small follow-up PR, into RELEASE.md section 2 and into FIRST-PARTY.md. Blocking question below.

[loop:torbscript] decided by the loop: split. The technical design (types and ABI, how the C back end and the VM call, library resolution, ownership, callbacks, slices) is separable and goes to #459 (`docs/design/FOREIGN.md`, docs only, one commit), which is `ready`. Reasoning: `foreign` is parsed and shape-checked today, the capability "foreign functions" is already derived from source (`compiler/src/package/archive.trb`), the sandbox never grants it, and `Pointer`/`CString` exist nowhere in `std/` - so the record has to fix the mechanics before `std/gpu` (#85). Open technical questions are decided inside #459, not asked. Two inconsistencies are resolved there: CONCEPT wants a `foreign` note in `project.trb` while PROJECT.md section 1 says a manifest switch is a second source of truth (working assumption: capability from source, `project.trb` only maps library names), and OS.md section 8 cites rule 7 of the sandbox page where it is rule 8. [loop:torbscript] owner decision: may a published package declare `foreign` functions (a binding to a C library) and may it carry C sources? This is the published contract of the registry (RELEASE.md section 2 names it as a 1.0 decision; FIRST-PARTY.md row 7, `torb/sqlite`, cannot be built until it is answered), so the loop does not decide it. Options: (1) none: published packages stay pure TorbScript; (2) declarations only, against libraries already on the user's machine, no C sources in the package; (3) as (2), and first-party packages (`torb/*`) may also ship C sources that the toolchain compiles; (4) any package may ship C sources. Whatever is chosen, `foreign` stays visible in source, shown by `torb add` and the lock, and never grantable to a sandboxed script. Recommendation: (2) - it unlocks bindings such as SQLite on Linux and macOS, keeps the registry a store of source that runs and builds nothing, and leaves (3) open as a later, separate decision; (1) blocks `torb/sqlite` for good, (4) puts unreviewed C into every consumer's build. The answer is written into the open section of the record by a small follow-up PR, into RELEASE.md section 2 and into FIRST-PARTY.md. Blocking question below.
Author
Collaborator

[loop:torbscript] refine: split done. Technical part is ready as #459 (design record docs/design/FOREIGN.md, docs only, one commit, ready). This issue keeps only the owner decision above (foreign functions in published packages: options 1-4, recommendation 2); the answer lands in #459's open section by a follow-up PR once given. Epic checklist: [ ] #459 design record (technical) - [ ] owner decision on published packages (comment above) - [ ] follow-up PR writes the answer into FOREIGN.md, RELEASE.md section 2 and FIRST-PARTY.md row 7 - [ ] implementation slices as listed by the record, filed just in time. Note for the tick: the tasks tooling has no access to git.torb.dev (question_ask answers "not found or no access"; orion/tasks#97 is closed), so no hos-question block exists for this decision yet; the plain owner decision: comment is the record, the tick needs to ping it to the TorbScript group in German (headline: "Dürfen Pakete C-Bibliotheken ansprechen?", recommendation: yes, but only bindings to libraries already on the machine, no C sources in the package). next: waiting (owner decision on foreign functions in published packages)

[loop:torbscript] refine: split done. Technical part is ready as #459 (design record `docs/design/FOREIGN.md`, docs only, one commit, `ready`). This issue keeps only the owner decision above (foreign functions in published packages: options 1-4, recommendation 2); the answer lands in #459's open section by a follow-up PR once given. Epic checklist: [ ] #459 design record (technical) - [ ] owner decision on published packages (comment above) - [ ] follow-up PR writes the answer into FOREIGN.md, RELEASE.md section 2 and FIRST-PARTY.md row 7 - [ ] implementation slices as listed by the record, filed just in time. Note for the tick: the tasks tooling has no access to git.torb.dev (`question_ask` answers "not found or no access"; orion/tasks#97 is closed), so no `hos-question` block exists for this decision yet; the plain `owner decision:` comment is the record, the tick needs to ping it to the TorbScript group in German (headline: "Dürfen Pakete C-Bibliotheken ansprechen?", recommendation: yes, but only bindings to libraries already on the machine, no C sources in the package). next: waiting (owner decision on foreign functions in published packages)
Author
Collaborator

[loop:torbscript] wait: the owner decision on foreign functions in published packages (options 1 to 4 above, recommendation 2) is asked in the TorbScript group and not answered yet; the technical record #459 is closed. Nothing else on this item can move.
next: waiting (owner decision on foreign functions in published packages)

[loop:torbscript] wait: the owner decision on foreign functions in published packages (options 1 to 4 above, recommendation 2) is asked in the TorbScript group and not answered yet; the technical record #459 is closed. Nothing else on this item can move. next: waiting (owner decision on foreign functions in published packages)
Author
Collaborator

Question q1 for torben (decision, blocking): Dürfen Pakete C-Bibliotheken ansprechen?

v: 1
id: q1
to: torben
kind: decision
blocking: true
headline: "Dürfen Pakete C-Bibliotheken ansprechen?"
type: decision
effort_minutes: 3
question: Darf ein veröffentlichtes Paket `foreign`-Funktionen (Anbindung an C-Bibliotheken) deklarieren, und darf es C-Quellen mitliefern? Das ist der Vertrag der Registry; torb/sqlite hängt daran.
options:
  - id: none
    label: "(1) Keine, Pakete bleiben reines TorbScript"
  - id: decl
    label: "(2) Nur Deklarationen gegen vorhandene Bibliotheken"
    detail: Keine C-Quellen im Paket; schaltet z. B. SQLite-Bindings frei.
  - id: first-party-c
    label: "(3) Wie (2), plus torb/* darf C-Quellen mitliefern"
  - id: any-c
    label: "(4) Jedes Paket darf C-Quellen mitliefern"
recommendation: decl
asked_by: orion

Checked: #84 comments 3-5 (options 1-4 and the recommendation were recorded 10-24 as plain prose, no block existed); #459 is closed. Reason: owner_scope, it fixes the published registry contract (RELEASE.md section 2). This block replaces the plain owner decision: comment as the record.

**Question q1** for torben (decision, blocking): Dürfen Pakete C-Bibliotheken ansprechen? ```hos-question v: 1 id: q1 to: torben kind: decision blocking: true headline: "Dürfen Pakete C-Bibliotheken ansprechen?" type: decision effort_minutes: 3 question: Darf ein veröffentlichtes Paket `foreign`-Funktionen (Anbindung an C-Bibliotheken) deklarieren, und darf es C-Quellen mitliefern? Das ist der Vertrag der Registry; torb/sqlite hängt daran. options: - id: none label: "(1) Keine, Pakete bleiben reines TorbScript" - id: decl label: "(2) Nur Deklarationen gegen vorhandene Bibliotheken" detail: Keine C-Quellen im Paket; schaltet z. B. SQLite-Bindings frei. - id: first-party-c label: "(3) Wie (2), plus torb/* darf C-Quellen mitliefern" - id: any-c label: "(4) Jedes Paket darf C-Quellen mitliefern" recommendation: decl asked_by: orion ``` Checked: #84 comments 3-5 (options 1-4 and the recommendation were recorded 10-24 as plain prose, no block existed); #459 is closed. Reason: owner_scope, it fixes the published registry contract (RELEASE.md section 2). This block replaces the plain `owner decision:` comment as the record.
Owner

[owner-answer] q=q1 option=decl „(2) Nur Deklarationen gegen vorhandene Bibliotheken“ 2026-11-09T21:36:56Z

[owner-answer] q=q1 option=decl „(2) Nur Deklarationen gegen vorhandene Bibliotheken“ 2026-11-09T21:36:56Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T12:48:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T12:48:00Z
Author
Collaborator

[loop:torbscript] refine: decided by the loop: owner answer q1 (option 2, declarations only against libraries already on the machine, no C sources in a package; Torben 2026-11-09) is not yet on main (FOREIGN.md 5.3, RELEASE.md section 2 and 7.2, FIRST-PARTY.md rows 7 and 9 still say "open"), so the acceptance criteria are not met. Filed #740 (docs-only PR writing the decision into those records, ready, sonnet/medium; no duplicate found). #84 closes with that PR (Closes #84).
next: waiting (#740 implementation and merge gate)

[loop:torbscript] refine: decided by the loop: owner answer q1 (option 2, declarations only against libraries already on the machine, no C sources in a package; Torben 2026-11-09) is not yet on main (FOREIGN.md 5.3, RELEASE.md section 2 and 7.2, FIRST-PARTY.md rows 7 and 9 still say "open"), so the acceptance criteria are not met. Filed #740 (docs-only PR writing the decision into those records, `ready`, sonnet/medium; no duplicate found). #84 closes with that PR (`Closes #84`). next: waiting (#740 implementation and merge gate)
Author
Collaborator

[loop:torbscript] close: the owner decision (q1, option 2: declarations only against libraries already on the machine, no C sources in a package; Torben 2026-11-09) is on main: FOREIGN.md section 5.3 "decided 2026-11-09: option 2 (#84)" (PR #758, 61e36267, issue #740). Main CI is green on the later head 6a1782cf, which contains it (the pdisc and site:edge failures on 61e36267 are gone there). Both acceptance criteria are met: the design record and the owner sign-off (q1). Closing.
next: done

[loop:torbscript] close: the owner decision (q1, option 2: declarations only against libraries already on the machine, no C sources in a package; Torben 2026-11-09) is on main: FOREIGN.md section 5.3 "decided 2026-11-09: option 2 (#84)" (PR #758, 61e36267, issue #740). Main CI is green on the later head 6a1782cf, which contains it (the pdisc and site:edge failures on 61e36267 are gone there). Both acceptance criteria are met: the design record and the owner sign-off (q1). Closing. next: done
orion closed this issue 2026-11-13 19:07:34 +00:00
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#84
No description provided.