Stdlib Roadmap
Comprehensive plan for bringing lib/ to stdlib quality. Based on an audit of all ~90 packages (2026-03-20).
Quality bar
A stdlib-quality package must have all of:
init.luaentry point — the package isrequire("lib.foo")-ablepackage.pathguard —if not package.path:find(...)at the top- Tests —
foo_test.luawith meaningful coverage nil, errerror convention — at all public boundaries;error()only for programmer errors (invariant violations)- Type annotations — crescent-style
--:/--::, not LuaLS@param - No unresolved external deps — no
require("dep.*")unless the dep is also inlib/(or declared in a manifest) - Snake_case naming — already 100% consistent, just maintain it
Currently: 3 packages meet the bar (cr, http, websocket — partially). 0 are fully compliant.
Current state
What works
- Naming: snake_case everywhere, no exceptions
- Module pattern:
local M = {}/return Muniversally - Namespaces:
lib/hash/,lib/format/,lib/encode/established
What doesn't
| Problem | Scope |
|---|---|
No init.lua | 44 of ~90 packages |
| No tests | ~82 of ~90 |
| No path guard | ~87 of ~90 |
| No type annotations | ~90 of ~90 |
| Mixed error conventions | ~34 packages |
dep.* coupling | 10 packages |
Package triage
Tier A — stdlib core (keep, invest)
Packages that belong in a general-purpose stdlib. Bring to quality bar.
Already namespaced:
hash/sha256,hash/sha1— need parity tests, type annotationsformat/json(lunajson),format/cbor,format/toml— toml is new, others need testsencode/base64,encode/urlencode,encode/utf8— need type annotations
System:
path— has tests, needs path guard + annotationsfs— no init.lua, needs proper entry pointenv— tiny, needs teststime— needs tests, annotationsget_cwd— merge intofsorpath
Network:
http— most mature, has tests; submodules need auditwebsocket— has tests, good shapedns— no init.lua, needs entry pointtls— needs tests
Data:
merge— has tests, tinypretty_print— useful utility, needs testsmimetype— no init.lua, solid data tables
Concurrency:
epoll— foundational, needs testsasync— needs tests, design reviewinotify— needs teststimerfd— needs tests
FFI infrastructure:
ljsocket— foundational for network stack, needs testsdynamic_library— needs testsffi_unload— tiny utility
Functional programming:
fp/— 21 subpackages: typeclasses (Mappable, Applicable, Chainable, Foldable, Traversable, Semigroup, Monoid, etc.), data types (Maybe, Either, Fn), optics (lens, prism, iso, traversal), ADT constructors. Designed to stress-test the typechecker's HKT and constraint support — seedocs/fp-design.mdanddocs/typeclass-design.md. 18 test files, 402 assertions. Needs rootinit.luaand crescent-style type annotations.
Missing (to build):
process— subprocess spawn/pipes/waitsignal— POSIX signal handlingiter— combinator utilitiesformat/msgpack— common serialization formathash/hmac— HMAC constructionrand— CSPRNG via/dev/urandomorgetrandom(2)
Tier B — domain libraries (keep, lower priority)
Useful for specific domains but not general-purpose stdlib.
sqlite— has tests, error convention needs fixing (error() → nil,err)cmark— CommonMark, dep.* couplingqrencode— QR codes, large but standaloneargon2— password hashing, needs testshtml— HTML buildermarkdown— no init.luaimap,irc,dns— protocol implementationscparser— C header parsing (used by typechecker)
Tier C — application-specific (move out or archive)
Not stdlib material. Either move to a separate repo or archive.
glua— OpenGL bindings, vendoredlovr— VR framework bindingsgame— game-specific3d— emptydiscord— Discord clientactivitypub,activitystreams— federation protocolswayland,wlroots,xlib,xft,xkbcommon,x11_keysym— desktop/WMpulseaudio,soloud— audioglb— 3D model formattextbar,text_world,gmcp— application-specifictree_sitter— external bindingljltk— third-party Lua parsermock— large mock librarymyowtype— unclear purposetodo— stubs (jpeg, png, xcb, soloud)lsif,lsp— language tooling (separate from lib/type/static/lsp.lua)codetree— code analysiswebview— native webview bindinglua2js,js— transpilerui— UI framework
Tier D — merge or delete
null— 7 lines, merge into a core utils module or inlineweakref— 12 lines, samememory— 25 lines, sameoauth— 0 lines (empty file)htaccess— 36 lines, Apache-specificmake— 44 lines, build tool fragmentbase— 40 lines, number base conversionit_eval,it_fn— point-free expression builders, superseded bylib/iterfunctional— no init.lua, superseded bylib/fp+lib/iterlil— 10 lines, wrapper
Priority order
Phase 1 — Foundation (immediate) ✓ done 2026-03-20
- ✓ Add
init.luato all Tier A packages that lack one (fs, dns, mimetype) - ✓ Add path guard to all Tier A packages (~23 packages)
- ✓ Error convention sweep —
dynamic_libraryfixed; others already correct
Phase 2 — Test coverage (partial, 2026-03-20)
Done:
- ✓
epoll— 22 assertions - ✓
timerfd— 18 assertions - ✓
time— 7 assertions - ✓
env— skips gracefully (needs compiled .so) - ✓
fs— 26 assertions - ✓
mimetype— 32 assertions - ✓ Hash parity (sha1/sha256) — 67 assertions
Remaining (need network/system state, harder to test in isolation):
ljsocket— everything network depends on ittls— HTTPS depends on itdns— name resolutioninotify— file watching
Phase 3 — Missing packages ✓ done 2026-03-20
- ✓
process— subprocess spawn/exec via POSIX FFI (873463b) - ✓
iter— combinator utilities, 21 functions (committed) - ✓
rand— CSPRNG via getrandom(2) + /dev/urandom (306aa1b) - ✓
hash/hmac— HMAC construction, RFC test vectors (25918c3) - ✓
format/msgpack— pure Lua encode/decode (21a86b1) - ✓
signal— POSIX signal handling via FFI (9b50ede)
Phase 4 — Cleanup (partial, 2026-03-20)
- ✓ Archive Tier C/D packages — 46 moved to archive/ (1f84ced); fp/ restored to lib/ (Tier A — typechecker stress test, not application-specific)
- Resolve
dep.*coupling in Tier A/B packages - Type annotations across all Tier A packages
Phase 5 — Namespace expansion
As packages accumulate, evaluate whether new namespaces are needed:
lib/net/— if protocol count grows beyond http/websocket/dns/tlslib/sys/— if system primitives grow beyond fs/process/signal/envlib/crypto/— if crypto grows beyond hash/ (key derivation, AEAD, etc.)
Conventions (reference)
Detailed in docs/stdlib-design.md:
- Iterator protocol: Lua's built-in triple; closures are degenerate case
- Error convention:
nil, errat boundaries - Concurrency: sans-I/O, injectable scheduler
- Layering: pure-data layer under every I/O module
- Namespacing: when 2+ of noise/shared-interface/parent-value apply