v0.3 interop split author syntax from execution lowering; articles must not fork MUST tables.
FFI and extern — Verification and traceability
Platform spec article
FFI and extern — Verification and traceability
Spec standingStandard
-
Author-facing extern import rules live on this hub.
Context
Decision
This feature hub must own normative MUST/SHOULD contract text for foreign import. Sibling articles must not redefine hub requirements.
Consequences
Execution and tooling specs link here for
Externplacement and attribute shape.Verification anchors
/platform-spec/language-meta/interop/ffi-and-extern/;
compiler/crates/beskid_analysiscontract validation. -
Extern on non-contract declarations is E1510.
Context
Bulk C-style surfaces need stable contract blocks; module-level extern was exploratory.
Decision
Externmust apply only tocontractdeclarations in v0.3 Standard. The reference compiler must rejectExternon non-contract declarations (E1510).Consequences
Codegen collects
ExternImportfrom contract metadata; mod-level extern remains non-Standard.Verification anchors
compiler/crates/beskid_analysis/src/types/context/context.rs; extern attribute schema. -
Bulk import uses contract blocks with method signatures.
Context
Header-style
Externonmodwas considered for v0.3 but increases parser and ABI ambiguity.Decision
Externonmodis not part of v0.3 Standard. Authors must usecontractblocks with method signatures ending in;.Consequences
Future promotion requires a dedicated ADR and profile conformance tests.
Verification anchors
/platform-spec/language-meta/interop/ffi-and-extern/ v0.3 scope section.
-
Tier-1 user libraries use C profile; runtime builtins stay on Rust ABI.
Context
Mixing user
Externsymbols withBESKID_RUNTIME_ABI_VERSIONexports caused namespace and stability risk.Decision
Plane Rule User libraries C ABI profile + link-time binding Runtime embedding Rust ABI profile / frozen builtin table Separation User Externmust not mutate runtime builtin symbol namespaceConsequences
JIT registration and engine policy keep tables disjoint; see profile boundary map on hub.
Verification anchors
compiler/crates/beskid_abi; Rust ABI profile; C ABI profile. -
CLayout primitive structs are Proposed not v0.3.0 Standard.
Context
Arbitrary Beskid record
repr(C)needs layout rules beyond interop views.Decision
repr(C)on arbitrary Beskid types is out of scope for v0.3.0 Standard; CLayout primitive structs land in v0.3.1 (Proposed) per C layout types.Consequences
v0.3.0 Standard ships interop view types and link-time import first.
Verification anchors
- Contract import syntax How extern contracts declare foreign imports and map to symbols and call shapes.
- Extern attribute schema Normative Extern and per-method interop attributes for contract imports (v0.3).
- FFI and extern — Verification and traceability Conformance strategy for v0.3 FFI spec (fixtures, diagnostics, ignored runtime tests).
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Spec-first conformance
Section titled “Spec-first conformance”v0.3 FFI is normative in platform-spec before the reference compiler fully implements link-time binding, interop views, and export/callback registration.
Toolchains conform to this feature when:
- Parse and analysis fixtures accept valid v0.3 extern/export syntax and emit expected diagnostics for invalid forms.
- Codegen extraction tests record stable
ExternImport/ export metadata from fixtures (where implemented). - Runtime e2e tests for link-time foreign calls may be marked
#[ignore]with reasonv0.3 FFI impluntil the engine/CLI path lands.
Traceability matrix
Section titled “Traceability matrix”| Contract clause | Verification anchor |
|---|---|
Extern on contract only | beskid_tests analysis E1510 |
Abi:"C" + Library | beskid_tests extern validation pipeline |
| Interop view types | Type fixtures + lowering signature scan (validate_ffi_signature) |
| Link-time libraries | Manifest contract tests + future CLI import tests |
| Export / callbacks | Dedicated fixtures under export-and-callbacks hub |
Runtime ABI separation
Section titled “Runtime ABI separation”Tests for RUNTIME_EXPORT_SYMBOLS and BESKID_RUNTIME_ABI_VERSION remain under beskid_tests/src/abi/contracts.rs. User FFI layout versioning must not bump the runtime ABI version unless a runtime export symbol changes.
Maintainer rule
Section titled “Maintainer rule”Any behavior change in this area must update platform-spec text and add or adjust tests in the same change so the specification stays executable.