Standard Library API Shape
This document defines the recommended API design shape for Beskid’s standard library.
Detailed module contracts live in docs/standard-library/.
14.1 Design goals
Section titled “14.1 Design goals”- Predictable naming and discoverability.
- Minimal surface area for MVP.
- Composable modules over monolithic APIs.
- Stable contracts that can be backed by interop dispatch internally.
14.2 Namespace layout
Section titled “14.2 Namespace layout”Recommended top-level modules:
Core(error handling, results, string primitives)Collections(array/list/map/set/queue/stack)Query(query contracts, operators, execution)System(IO, FS, Path, Time, Environment, Process)
For MVP, start with:
Core.StringCollections.ArrayQuerySystem.IO
Naming rule (drop Std prefix)
Section titled “Naming rule (drop Std prefix)”- Public APIs must not require a
Stdnamespace prefix. - Standard library modules are addressed directly by canonical module paths (
Core.String,Collections.Array,Query,System.IO, …). - Existing
Std.*spelling is considered legacy documentation form and should not appear in new docs/examples.
14.3 API style rules
Section titled “14.3 API style rules”Prefer verbs for operations
Section titled “Prefer verbs for operations”System.IO.PrintSystem.IO.PrintlnCore.String.Contains
Prefer nouns for types
Section titled “Prefer nouns for types”StringBuilderDurationPathInfo
Keep signatures explicit and small
Section titled “Keep signatures explicit and small”- Avoid hidden allocations in APIs that look cheap.
- Avoid broad
Any-style parameters.
14.4 Error handling policy
Section titled “14.4 Error handling policy”- Prefer total APIs where failure is impossible or exceptional.
- Use
Result-based forms for expected recoverable failures. - Canonical language-level
Resultsemantics live indocs/spec/error-handling.md. - Canonical stdlib
ResultAPI contracts live indocs/standard-library/Core/Results.md.
14.5 Runtime boundary policy
Section titled “14.5 Runtime boundary policy”- Public stdlib APIs remain stable while runtime internals evolve.
- Runtime ABI/syscall ownership and backend parity are defined in
docs/execution/runtime/syscalls-and-abi-boundary.md. - Language-level
Externsyntax and typing are defined indocs/spec/ffi-and-extern.md.
14.6 Versioning and compatibility
Section titled “14.6 Versioning and compatibility”stdAPI changes should be additive in minor releases.- Breaking rename/removal requires a migration note.
- New experimental modules should be prefixed or documented as unstable.
14.7 Canonical module contract sources
Section titled “14.7 Canonical module contract sources”Per-module API contracts are canonical in docs/standard-library/:
Core/Collections/Query/System/
14.8 Coupled feature references
Section titled “14.8 Coupled feature references”- Query protocol and operator contracts:
docs/standard-library/Query/. - Lambda/closure language semantics:
docs/spec/lambdas-and-closures.md. for inlanguage semantics:docs/spec/control-flow.md.