A single Console IO type obscures direction and syscall descriptors.
Contracts and edge cases
Platform spec article
Contracts and edge cases
Spec standingStandard
-
stdin/stdout/stderr use separate System modules.
Context
Decision
Rule Detail Modules System.Input,System.Output,System.ErrorForbidden Monolithic console IO type for standard streams Consequences
Each module binds one
StandardStreamdescriptor; cross-stream APIs stay separate.Verification anchors
packages/runtime/src/System/Input.bd,Output.bd,Error.bd. -
Syscall write failures panic; reads surface Result.
Context
v1 write helpers are infallible at the type level; read paths need explicit error handling.
Decision
Rule Detail Write Write/WriteLinemust panic onWriteWithfailureRead Read/ReadLinereturnResult<string, SyscallError>Consequences
Diagnostics for write failures use fixed panic strings; callers cannot catch write errors in Beskid v1.
Verification anchors
Corelib stream tests; syscall integration in
beskid_runtime. -
WriteLine appends a single LF byte sequence.
Context
Cross-platform hosts may translate line endings below the Beskid API.
Decision
Rule Detail Ending WriteLinemust append\nonlyWindows Host/platform layer may translate later without API change Consequences
Authors see consistent Beskid source semantics; CRLF is not encoded in corelib strings.
Verification anchors
Output.bd/Error.bdtests; platform IO docs.
- Contracts and edge cases MUST rules for standard stream reads, writes, and error handling.
- Design model Stream module boundaries and syscall descriptor model for standard I/O.
- Examples Standard stream read and write usage patterns.
- Flow and algorithm Read and write algorithms for standard stream helpers.
- Verification and traceability Runtime syscall and corelib anchors for standard stream I/O.
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).
Purpose
Section titled “Purpose”Document contracts and edge cases for the Console Io Streams feature: role-specific normative detail beyond the feature hub.
Canonical references
Section titled “Canonical references”- Feature hub: Console Io Streams
- Sibling articles in this bundle (design model, contracts, flow, examples, verification)
Detailed behavior
Section titled “Detailed behavior”Normative requirements
Section titled “Normative requirements”| ID | Requirement |
|---|---|
| IO-001 | System.Input.Read and ReadLine must target stdin only via Descriptor::Standard(Stdin). |
| IO-002 | System.Output.Write / WriteLine must target stdout only; System.Error must target stderr only. |
| IO-003 | WriteLine(text) must perform Write(text) then Write("\n") as two syscall writes (or equivalent atomic policy documented in runtime). |
| IO-004 | Write helpers must panic with a stable message when WriteWith returns an error (System.Output.Write failed / stderr variant). |
| IO-005 | Read helpers must not panic on EOF; they return Result with an empty or partial string per syscall contract. |
| IO-006 | Modules must not interpret ANSI sequences; validation of escape syntax is the responsibility of ANSI escape model. |
Function contracts
Section titled “Function contracts”| Function | Behavior |
|---|---|
Input.Read() | Read up to default byte limit from stdin |
Input.ReadLine() | Read until \n or EOF; line without trailing newline |
Output.Write(text) | Write UTF-8 bytes to stdout, no newline |
Output.WriteLine(text) | Write(text) + Write("\n") |
Error.Write / WriteLine | Same as output, descriptor stderr |
Edge cases
Section titled “Edge cases”- Redirected stdout: Still writable; TTY detection happens only in Console capabilities, not in
System.Output. - Binary data:
stringis UTF-8 text; writing invalid UTF-8 is undefined at the language level—console APIs assume valid strings. - Large writes: Syscall layer may chunk; stream helpers do not expose partial-write
Resultin v1. - Concurrent fibers: Multiple fibers writing stdout may interleave bytes; line-safe logging is the caller’s responsibility (channels or mutex).
Verification
Section titled “Verification”See the verification and traceability article in this bundle and compiler/corelib/beskid_corelib/tests/corelib_tests/src/console/.
Related topics
Section titled “Related topics”- Parent feature hub and Terminal and console area