ThreadOne architecture — 0.6.1 Developer Preview

ThreadOne is an AOT, statically typed backend language under development. Version 0.6 adds Optional scalar/record values and typed JSON absence handling to the immutable records, bounded HTTP bodies and exact routes introduced in 0.5. Version 0.6.1 adds an optional Redis lookup that separates cache misses from failures. The cooperative executor was introduced in 0.4. The long-term language design is larger than the implemented subset. This release is not production ready.

What runs today

The compiler checks the supported language subset, emits Rust async functions, and compiles them through the Rust/LLVM backend into a native executable. Calls between ThreadOne functions and supported asynchronous built-ins are awaited in generated code. The application runs on a Tokio current_thread executor with a LocalSet; HTTP connections can progress while another handler waits for a timer or Redis response.

Networking uses readiness notifications. This release does not implement an io_uring backend, a compiler that emits machine code directly, or thread-per-core scaling. “One application thread” describes where application futures are polled. It does not promise that OS facilities, DNS resolution, native libraries or database monitoring never use helper threads.

type User:
  name: String
  email: String
  bio: String?

route POST "/users" (req):
  user = req.json(User) or return 400 "Invalid JSON"
  return 201 user

route GET "/health" (req):
  return 200 "ok"

This executable example validates and echoes a user. Persistence, email delivery and domain validation are separate work. Records have immutable scalar/nested-record fields, including Optional fields, and named constructors. Optional values use explicit some(value) or none; lazy or recovers from absence without treating it as false. The compiler rejects cyclic or excessive shapes; decoded strings are copied into the owning arena. No user-written lifetimes are needed for this restricted model.

sleep accepts 0–60000 milliseconds and returns a fallible Bool. yield_now() explicitly gives other ready tasks a turn. env(name) reads an environment value into the current arena and returns a fallible String. Redis ping, get/find, set with a TTL, and delete are also suspension points. These functions do not introduce public spawn/join syntax or user-defined task ownership yet.

Scheduling is cooperative. A long CPU loop that does not yield blocks other application work. A timer deadline cannot preempt that loop. Removing await from source does not remove suspension from program behavior: future shared-state and borrowing rules must account for calls that can yield.

HTTP and request memory

The typed API accepts Request and returns Response through serve_http(port, handler). Request exposes method, path without query, body and content_type. Route declarations lower to this API and synthesize a listener on port 8080. Routes match exact paths; HEAD falls back to GET, unknown paths return 404 and unsupported methods on known paths return 405 with Allow. The legacy serve(port, handler) remains a GET/HEAD text API receiving a String request target.

Typed JSON rejects unknown/duplicate fields, missing or null required fields, and incorrect types. Omitted or null Optional fields become none; encoding emits explicit null for absent fields. Parsing and encoding are bounded to 1 MiB, with a bounded serialization writer. Content-Length request bodies must be UTF-8; unsupported Transfer-Encoding returns 501 and Expect returns 417. HTTP/2, HTTP/3, WebSocket, chunked transfer and server-side TLS are not implemented. The runtime supports partial input/output, keep-alive and ordered pipelining; these tests do not amount to full HTTP conformance certification.

Each request owns an arena for immutable strings, including record fields. Its handler future may borrow from that arena across suspension points. The runtime drops the future before the arena on completion, timeout, recoverable panic or task cancellation, and copies the response into an output buffer before releasing arena memory. JSON decoding temporarily allocates owned values before copying strings into the arena. This is a concrete lifetime strategy for the current subset; it is not a proof for future mutable collections, escaped values or detached tasks.

Resource or behaviorCurrent implementation
Request string allocation budget8 MiB logical arena allocation
Request and response body limits1 MiB each
Header storage16 KiB, up to 64 parsed headers
Simultaneous accepted connectionsDefault 256; configurable bounded limit
Body deadlineDefault 10 seconds; THREADONE_BODY_TIMEOUT_MS, 100–60000 ms
Body timeoutHTTP 408 and connection close
Handler deadlineDefault 30 seconds; THREADONE_HANDLER_TIMEOUT_MS, 1–300000 ms
Handler timeoutHTTP 504 and connection close
Recoverable handler panicHTTP 500 and connection close
ShutdownStop accepting, drain existing work within a bound, then abort remaining tasks

Arena budgets do not bound total process RSS: task frames, socket buffers, JSON intermediates, driver allocations, TLS and output buffers are separate. Panic isolation does not recover from process-aborting failures such as stack exhaustion. Arena cleanup and resource destruction are not universally O(1).

Database boundary

Redis is the first database protocol exposed directly to .one programs. Its basic-key binding was exercised against an isolated Redis 8.4.8 instance in 0.4; the versioned validation report separates that historical evidence from current-release checks. PostgreSQL, MySQL/MariaDB, MongoDB and SQL Server adapters compile as experimental Rust libraries but do not yet have language bindings or verified real-server compatibility in this release. See Database support for the exact evidence and missing contracts.

Bindings copy returned text into the caller's arena. Records and Optional values now provide application data shapes, but SQL/document codecs, decimal, timestamp and byte-array types remain missing. redis_find(key) -> String?! distinguishes successful absence from read failure and returns present text in the caller's arena. Existing redis_get retains String! and reports a missing key as an error. Both read paths reject returned values over 1 MiB after decoding; this does not bound driver allocations or process RSS. Pool/transaction ownership and stable typed codecs are required before broader database APIs can stabilize.

Accepted direction and unfinished work

AreaDirectionRequired before stabilization
CompilationAOT through Rust/LLVM now; direct native backend is a later optionConformance, fuzzing, predictable diagnostics and reproducible artifacts
MemoryRequest arenas plus explicit ownership/promotion for longer-lived valuesEscape rules for collections, callbacks and tasks; cancellation/drop testing
Async languageImplicit suspension with compiler-generated state machinesDocumented effects, task scopes, cancellation and fairness; spawn/join remain pending
Linux I/OOptional io_uring completion backend with fallbackReal Linux kernel matrix, completion/buffer lifetime tests, measured benefit
Other platformsPortable runtime backendNative Windows/Linux/macOS test results and documented behavior parity
ScalingIndependent runtime per core with explicit messagesBounded message queues, ownership transfer, shutdown, affinity and ordering tests
Native primitivesMaintained protocol and cryptographic librariesExpand experimental typed HTTP/JSON APIs, specify TLS deployment, conformance and dependency maintenance

Why this model may help

One application thread reduces the need to coordinate simultaneous access to application state. Many independent I/O waits can share the executor without one OS thread per connection. Explicit ownership and bounded queues can make resource use easier to inspect. AOT avoids a runtime JIT, and this language subset does not use a tracing garbage collector.

These properties do not eliminate logical races between suspension points, deadlocks caused by waiting tasks, CPU contention or every form of allocation. They do not automatically make ThreadOne faster than Node.js, Bun, Go or Rust. Shared-nothing scaling and broader value semantics are design directions, not completed features.

Claims that require evidence

See Release gates for the work and evidence required before production use.