language: the design of foreign functions #84

Open
opened 2026-10-05 21:07:18 +00:00 by orion · 5 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)
Sign in to join this conversation.
No labels
loop
ready
No project
No assignees
1 participant
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.