0093:
Platform extension point: declarations, trusted compiled-in
natives, platform key
Status: Accepted (default; pending owner confirmation)
Amends ADR-0005 and ADR-0050.
Context
ADR-0005 makes platforms the source of effects, and ADR-0050
defines the built-in cli capability surface. M10
makes platforms an extension point without changing the language
grammar or claiming support for dynamically loaded native
code.
Decision
A platform is a package with
[plugin] kind = "platform" and a
platform.toml declaration. The declaration lists
capability types and their ceiling categories, the root type,
fields, methods (using the existing parameter and return shapes),
the native operation for each method, seeded types such as
CliError and Output, native headers, and
a [policy] table. Keyed tables are used for methods
(for example, [method."Stdout.println"]); no grammar
change is made.
In the trusted tier, each native operation name must resolve in a toolchain registry. C implementations are embedded headers and interpreter implementations are Rust match arms. Unknown native names are diagnostics. Consequently, out-of-tree platforms require toolchain support until FFI is available; loading C natives from a plugin directory would leave the interpreter without parity.
The root package may set
[package] platform = "name". Omission defaults to
"cli", including for manifest-less single files.
Dependencies may not name a different platform. Existing programs
therefore retain their platform without manifest edits.
Alternatives considered
- Declare capabilities in
.hnwith a newcapitem: rejected because it adds grammar. - Load C natives from plugin directories: rejected because the interpreter reference backend would have no corresponding implementation.
- Require every app to name its platform: rejected because it needlessly churns existing fixtures and programs.
Consequences
Platform declarations supply data while native behavior remains
explicitly trusted toolchain code. The cli platform
remains the default, and later platforms can reuse the same
declaration and validation boundary.