Language Option covers expected errors. Unrecoverable faults and some IO failures need a distinct path that does not conflate with Result channel semantics.
Contracts and edge cases
Platform spec article
Contracts and edge cases
Spec standingStandard
-
No Beskid stack unwinding across panic; traps end execution.
Context
Decision
Mechanism Use Option/ResultExpected failures (language-meta + corelib) panic/panic_strUnrecoverable faults, hard IO faults in v1 streams, allocation failures Unwind No Beskid stack unwinding across panics Outcome Runtime panics terminate the process (trap / abort) Builtin kind AbiReturnKind::NeverinBUILTIN_SPECSConsequences
Corelib must not catch panics for ordinary control flow. Fiber Detach panics still abort unless future domain recovery is specified.
Verification anchors
beskid_runtime::builtins::panic_io; e2e runtime cases. -
Lowering and corelib route IO through syscall_read/write, not embedded OS code.
Context
Scattering platform syscall sequences through codegen duplicates policy and breaks GC mutator rules at IO sites.
Decision
Rule Detail Builtins syscall_read,syscall_writeaccept fd + buffer (BeskidStrfor write)Implementation beskid_runtime::builtins::panic_io— Linux x86_64 direct syscalls in reference treeOther targets May use std::iofor fds 1/2 while preserving signaturesFront-end Must not embed OS-specific syscall sequences in lowering Corelib System.Input/Output/Errorwrap builtins with descriptorsGit anchor:
12ee673(split System I/O surfaces).Consequences
New platforms document stub vs native behavior without renaming symbols.
Verification anchors
panic_io.rs; console stream corelib tests. -
Scheduler run_blocking offloads host work without stalling other fibers.
Context
Blocking
read/writeon a fiber must not freeze the entire M:N scheduler or violate Phase A mutator rules on pool threads.Decision
Rule Detail Blocking path Enqueue host blocking work on syscall pool; park current fiber only Wake Resume fiber on scheduler thread when worker completes Pool workers Must not execute generated Beskid mutator code or allocate as mutators Pool worker tagging Each pool thread calls set_syscall_pool_worker()so the runtime can assert this rule (assert_mutator_allowed) and panic on accidental allocationAllocation Runtime object creation for results happens after resume on scheduler thread Console Producers Send bytes/events; consumers Receive on fibers Consequences
M6+ syscall integration is required for conformance on blocking builtins.
Verification anchors
Scheduler
run_blocking; fiber scheduler verification article.
- Contracts and edge cases MUST rules for panic divergence, syscall parameters, and backend neutrality.
- Design model Panic termination, syscall ownership, and runtime-mediated IO boundaries.
- Examples Panic from lowering, syscall_write status codes, and corelib IO scenarios.
- FAQ and troubleshooting Panic vs Option, syscall return codes, and fiber/blocking IO issues.
- Flow and algorithm Panic emission, syscall_write chunking, and blocking IO on fibers.
- Verification and traceability panic_io implementation paths, e2e runtime cases, and IO contract cross-tests.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
what-this-feature-specifies | yes | yes |
implementation-anchors | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Normative requirements
Section titled “Normative requirements”| ID | Requirement |
|---|---|
| IO-ABI-001 | panic and panic_str must not return to callers; lowering must treat sites as unreachable after call. |
| IO-ABI-002 | JIT and AOT must import the same syscall_read / syscall_write symbols from beskid_abi. |
| IO-ABI-003 | Non-Linux targets may implement syscalls via host shims but must preserve signatures and error sentinels. |
| IO-ABI-004 | syscall_write must accept fd as i64 and string as BeskidStr pointer per BUILTIN_SPECS. |
| IO-ABI-005 | Front-end/lowering must not emit raw OS syscall instructions for corelib IO. |
| IO-ABI-006 | User docs must not document internal mangled panic entrypoints; stable names are panic / panic_str. |
Builtin contracts
Section titled “Builtin contracts”| Builtin | Contract |
|---|---|
panic(msg_ptr, msg_len) | Diverging; UTF-8 bytes at msg_ptr for msg_len |
panic_str(handle) | Diverging; BeskidStr handle |
syscall_write(fd, str) | Returns bytes written or -1 |
syscall_read(fd, max) | Returns new BeskidStr handle |
Edge cases
Section titled “Edge cases”| Case | Behavior |
|---|---|
| Zero-length write | Returns 0 without syscall when possible |
| Invalid fd | Returns -1; corelib may panic on stdout/stderr |
| Partial write on pipe | Loop until complete or error (Linux path) |
| Panic during another panic | Process abort; no nested recovery |
| Redirected stdout | Still fd=1; TTY detection is corelib-only |