Kofun language specification draft
This directory separates normative language contracts from the smaller executable bootstrap implementation.
-
grammar.ebnfstates what the Stage 2 checkpoint accepts (#943), and its header names itKofun Stage 0 grammar, draft 0.2-bootstrap. It is smaller than the language, not larger: there are no productions fortrait,enum,import,pub,effect,macro, ormatch. A full-language grammar is part of the "complete specification" deliverable measured indocs/ROADMAP.md§M4. The file carries its own draft number, which moves with the accepted grammar rather than with the specification version recorded at the end of this document. -
semantics.mdrecords the semantic contract that every executable backend must preserve for the constructs it accepts. -
backend-differential-contract.mddefines exact cross-backend observations and unsupported-feature accounting. -
roadmap-31-34/defines executable acceptance gates for generics, compiler fixed points, native Stage 1, and the language server. -
syntax/FOUNDATIONS_AND_CONTROL.mdspecifies issues 35 through 47 and links each claim to explicit bootstrap capability evidence. -
syntax/EXPRESSIONS_AND_LITERALS.mdspecifies issues 48 through 59 without treating planned syntax as implemented behavior. -
bool-match-exhaustiveness.mdis the executable Stage 2 checkpoint for issue #30 over the finiteBool = { true, false }constructor set in statement and value position. It does not claim the general ADT exhaustiveness algorithm. -
enum-match-exhaustiveness.mdgeneralizes that finite-set coverage to named concrete enums whose constructors carry zero or oneIntpayload for issues #30 and #782, without claiming generics, wider payloads, or a general type checker. Both documents are read bytests/conformance/syntax/issues_35_47/, which is their executable gate. -
parser/TOKEN_SPANS.mddefines the current Stage 2 byte-span prototype and the work still required for a lossless parser. -
modules/package-roots.mddefines deterministic manifest and anonymous single-file package roots and the versionedPackageIdPayloadcontract. -
modules/source-file-mapping.mdselects explicit manifest-source module headers and defines versionedFileId/ModuleIdidentity inputs. -
modules/namespaces.mdassigns declarations to the stable value, type, module, and meta namespaces and fixes deterministic lookup and collisions. -
modules/module-identity.mdfixes production IDs, canonical compiled- interface bytes, and separate public, internal, and target ABI digests. -
modules/visibility.mddefines default-private declarations, package-scopedinternal, intentionalpub, restricted ancestor visibility, and the identity-only access decision implemented by the focused conformance gate. -
modules/re-exports.mdselects explicitpub import/pub fromforwarding, preserves target identities, and rejects every visibility-widening edge. -
tooling/typed-sidecar.mddefines the non-authoritative canonical JSON artifact for complete and explicitly status-marked partial semantic facts. -
typed-sidecar/contains its JSON Schema, canonical examples, semantic validator, negative corpus, replacement model, and executable gate. -
../tooling/typed-sidecar/implements the bounded, recursively immutable tooling codec and stale-safe atomic replacement without granting authority. -
records-v1.mdselectstype Name = { ... }declarations with labelled call-formName(field: value)construction, fixes nominal identity, immutable fields, whole-record moves, and untagged declaration-order layout, and namestests/conformance/records/as its executable gate. -
result-propagation-v1.mdselects postfix?onResult[T, E]as the one initial sequencing sugar, monomorphic toResultand desugaring after type resolution to thematch-and-early-return core. Accepted as DD-036. Stage 2 parses?and implements refusals 1–3 (E2S189–E2S191: non-Result operand, optional operand,?on a pipeline stage), gated bytests/conformance/result-propagation/; positive lowering and the non-Result function refusal are pending in #1250. -
c11-command-io-v1.mdfixes the bounded C11 command-I/O surface for issue #1665: operands asText(at most 256, 255 bytes each,argv[0]observable), standard input and standard error as bounded host-boundary operations, the 65,536-byte ceiling kept for the singleread_filewith a new bounded chunk operation past it, and anIntstatus for a failed operation. Its gates aretask command-operands(#1666) andtask bytes-read-stream(#1667). -
stage2-include-v1.mddefines the bounded top-levelinclude "NAME"form by which a Stage 2 unit reuses a declared, digested block instead of a build-time extraction, the committed manifest that names and pins each target by SHA-256, and the refusals that keep the read non-ambient. It is the replacement #1668 question 1 asked for; it is design-only andE2S02still refuses it until the implementation lands. -
decimal-error-v1.mdrecords the source-level answers RFC-0015 names but does not define forkofun.fixed-decimal/v1:DecimalErroris an opaque nominal value with aD00xcode accessor reserved forFixedin v1, the clone form isFixed.clone(value)withread, and the format form isDecimal.format(value, display_scale). It is listed in RFC-0015'snormative_spec, andspec/native-toolchain-v1/contract.jsonwithmodel.mjsassert every answer undertask fixed-decimal-profile. -
type-level-programming-v1.mddefines the Type-only, named, structurally terminating type-function profile, its fixed reduction/display budgets, and the requirement that type-level features ship with inspectable traces. No compiler implements the profile, andtask type-reduction-tracegates the trace contract rather than any reducer. V1 rejects Turing-complete type computation as a language goal; #1130 is the open request to supersede that row with a fuel-bounded v2, so the rejection is the current accepted answer and not a closed question. -
effects/validation-accumulation.mddefines the accumulating validation contract for issue #742: three result states, independent combination that collects every issue in deterministic source order, dependent sequencing whose continuation never runs without an input value, pure v1 branches, an opaqueIssues[E], and an O(N) issue-accumulation bound. The design is accepted and its five open questions are decided; no library or compiler implements it, and its named gate does not exist yet. -
concurrency/scoped-parallelism-v1.mdfixes the v1 spawn/join ownership contract for issue #555: the threepar/spawn/joinsource forms, the second-class scope token and affine task handles, semantic liveness from spawn to join,read/edit/takecapture exclusivity, the closed set of place-disjointness proofs, scope-exit drain with deterministic panic and cancellation precedence, and six required diagnostic classes. Its bounded executable model, fixtures, andconcurrency/scoped-parallelism-v1/check.share gated bytask scoped-parallelism. The document is a normative input to proposedRFC-0003, whose review closes 2026-08-16; no parser, ownership checker, scheduler, or backend implements it, so passing the gate is evidence about the contract only. -
concurrency/scoped-captures-v1.md, its three closed JSON schemas, pure normalization model, canonical fixture, KSE2 frame goldens, and mutation checker freeze the analysis-onlykofun-scope-hir/v2representation for scoped task identities, checked places, explicit unknowns, and strongest-mode captures.task concurrency-capture-contractholds identity preimages, links, phase/order, bounds, privacy, typed-sidecar v2captures[], and the exact v1 contract bytes. It does not change the 46-row selfhost profile, acceptpar, or claim compiler, codec, runtime, or backend implementation. -
concurrency/schedule-trace-v1.mdis the accepted deterministic testing contract for issue #736: stable scope/task identities, the canonicalkofun.schedule-trace/v1andkofun.schedule-witness/v1bytes, FIFO, seeded, replay, and bounded exhaustive policies over one task model, and the strict rejection codes that refuse a stale or drifted trace. Its model and thetests/concurrency/schedule-replay/corpus are gated bytask schedule-trace. It supplies reproduction evidence for the scoped contract above; neither model is authority for the other, and Kofun has no production scheduler. -
type-reduction-trace/kofun.type-reduction-trace.v1.schema.json, its alias, type-function, and failure vectors inexamples/, andtype-reduction-trace/check.shdefine the executablekofun.type-reduction-trace/v1validation gate. No active compiler emits this trace yet. -
law-evidence-v2.schema.jsondefines the accepted targetkofun.law-evidence/v2artifact, including purpose-separated cache/evidence identities, ground law/implementation/model inputs, standard-v1 resource caps, computed assurance, and canonical counterexamples. No active compiler emits it yet. -
law-evidence.schema.jsondefines the historicalkofun.law-evidence/v1prototype artifact. It remains available only for explicit identification and migration; it is not an active compiler, optimizer, cache, or release contract and must never be interpreted as v2. -
benchmark-report-v1.md, its closed JSON Schema, bounded pure model, three canonical positive reports, digest-pinned negative byte transformations, and comparison vectors define the executablekofun.bench-report/v1profile.task benchmark-report-specpreserves the accepted 100-sample ceiling with a 64+36 Stage 2 mapping and fixes canonical bytes, availability, errors, typed non-success output outcomes that never expose partial report bytes as success, and caller-threshold comparison. It is contract evidence, not a production model, codec, runner, counter provider, or capability claim. -
aggregate-layout-v1.md, itsaggregate-layout-v1/reference computer, target files, golden vectors, andaggregate-layout-v1/check.shdefine the accepted target-parameterized byte layout forText,List, flat records, and flat ADT variants onx86_64-linuxandwasm32. It is a layout contract only; no backend lowers to it yet, and the shipped nativei64headers are compared against it rather than governed by it. -
wasm-host-abi-v1.md, itswasm-host-abi-v1/reference host, boundary document, recomputed vectors, instantiation fixtures, andwasm-host-abi-v1/check.shdefine the acceptedkofun-wasm-host-abi-v1boundary: one ABI version, the import allowlist with exact wasm signatures, the required exports, and theText/Listrepresentation derived from thewasm32layout target. It is the input contract for wasm32Text/Listlowering; no backend emits it yet, and it does not describe WASI or a supported-engine matrix. -
wasm-host-profile-v1.mdandwasm-host-profile-v1/check.shdecide how a build reaches that contract: the host ABI is part of the target name, so--target wasm32keeps the bounded numeric binding and--target wasm32-hostabi1is reserved forkofun-wasm-host-abi-v1. It records the legacy binding as supported rather than deprecated, names the native x86-64 semantic oracle and the v1 byte-layout oracle the lowering will be measured against, and states how a host tells the two bindings apart on the module bytes before instantiation. It decides activation only: no wasm bytes change, no capability row moves, and no backend emits the profile yet. -
wasi-command-profile-v1.md, its closed import/capability vocabulary, reference model, canonical vectors, refusal mutations, and Node-executed fixture inwasi-command-profile-v1/define the accepted implementation input for the reservedwasm32-wasi-command1target. The profile is a boundedwasi_snapshot_preview1core-module subset with explicit authority, borrowed guest-pointer lifetimes, read-only preopens, and no ambient access. It is not a language RFC or a capability claim: the shipped CLI still refuses the target and no backend emits it.
Design-only material in docs/ is not normative until it is promoted here
with conformance evidence. The specification is versioned independently from
the implementation; the current draft is 0.3-bootstrap.