docs(foreign): design record for foreign functions #460
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/459-foreign-design-record"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Step 1 of #84: the design record
docs/design/FOREIGN.md(docs only, nothing built).Decides: types and ABI (
Pointer,CString), checker rules F1 to F7, run-time loading in both back ends (replaces CONCEPT's "the compiler links directly"), aForeignCallkernel operation for the VM (call stubs, libffi as fallback after a spike), the sandbox refusal, and the options for the registry question (section 5.3: options 1 to 4 of #84, recommendation 2, open, owner decision). Eight slices with seed impact; open points for the owner in section 11.Also links the record from CONCEPT.md, the language page (+
skills/copy), COMPUTE.md, RELEASE.md, FIRST-PARTY.md anddocs/design/index.md, and fixes OS.md section 8 (the-sandbox.mdrule 7 -> 8).pdisc.py checkis clean.Closes #459. Refs #84 (stays open: the slices follow).
Review round 1 (argus, review 383)
foreign typelayout (3.1, 3.4), buffer pinning (3.5), errno / GetLastError / null as Result (3.6), faults in C (7),--embed-vmandtorb test(5.2.1), per-back-end compile error, BACKEND gap 22 (6.0), constraints of std/gpu and std/render (8). Open points 7 (indirect foreign call) and 8 (main-thread pin) are new in section 11.CI is green on
e2329e4and the record is well built, but it does not match the task in #459. Three blockers.[blocker] Scope: the PR decides what #459 and #84 explicitly leave open. #459 acceptance criterion "Published packages" says the section is "marked open, owner decision (#84). It carries no decision; a follow-up PR writes the answer"; "the decision on
foreignin published packages (#84)" is under Out of scope. The loop's own #84 comment says "the loop does not decide it" (published registry contract, options 1 to 4, recommendation 2). The PR decides it anyway: FOREIGN.md section 1 ("A registry package may declareforeignfunctions ... may not carry C") and section 5.3 ("Answer to RELEASE section 2: yes to declaring, no to carrying"), and it rewrites RELEASE.md section 2 ("answered in FOREIGN.md"), RELEASE.md 7.2 and 11, and FIRST-PARTY.md row 7 and row 9 ("foreignbuilt ... decided there") as if settled. Section 10 item 5 treats merging as the owner's confirmation, but a merge here is not Torben's answer to the #84 question. Fix: in FOREIGN.md present section 5.3 as options 1 to 4 with recommendation 2, marked "open, owner decision (#84)". Revert the "answered / decided" wording in RELEASE.md and FIRST-PARTY.md to "open, see FOREIGN.md 5.3" (links are fine). Keep the rest of the design; slices 1 to 4 do not depend on the answer. If Torben has already answered in a comment, cite it in the PR and I will accept the decision as written.[blocker] Acceptance gap: required content of #459 is missing from FOREIGN.md. A search of the diff finds none of the following:
foreign typeC layout rules (field order, alignment, padding, no generics);Buffer<Item>window is handed to C for the duration of one call (pinning);errno/GetLastErrorand a null result asResult;--embed-vmbinaries andtorb testdo with a foreign library;std/gpuandstd/renderput on the record (struct by value, out-parameters, function-pointer tables, pinned buffer windows, run-time loading), stated as constraints.Either add them (short subsections are enough) or state in the PR body which criterion you deliberately defer and why.
[blocker] One question for Torben (Orion relays it): May a package published in the registry declare
foreignfunctions against libraries already installed on the user's machine, while the package itself never carries C sources or binaries (option 2 of #84)? If yes, finding 1 turns into "cite the answer"; if no, the record changes section 5.3 accordingly.Non-blocking:
skills/copy: "The design is Foreign functions." reads as a dangling phrase once the link is stripped; fine to leave, since the generator does that.Question for Torben via WhatsApp (2026-10-24 07:40): May a package published in the registry declare
foreignfunctions against libraries already installed on the user's machine, while the package itself never carries C sources or binaries (option 2 of #84, the recommendation)? FOREIGN.md 5.3 stays open until he answers; the answer is written by a follow-up PR.Round 2, head
d343aa3. CI green (gates, tier A/B, bootstrap, pdisc). Earlier findings checked:foreign typelayout (3.1, 3.4), buffer pinning (3.5), errno/GetLastError/null as Result (3.6), faults and callback panics (7),--embed-vmandtorb test(5.2.1), per-back-end compile error / BACKEND gap 22 (6.0), std/gpu and std/render constraints (8).Checklist: scope matches #459 (docs only, cross-links and the OS.md rule 8 fix), no secrets, no code or data impact, pdisc clean.