Move stdlib out of spec — clean spec/library boundary

spec/ now contains only the language definition (5 files):
  evaluator.sx, parser.sx, primitives.sx, render.sx, special-forms.sx

lib/ contains code written IN the language (8 files):
  stdlib.sx, types.sx, freeze.sx, content.sx,
  bytecode.sx, compiler.sx, vm.sx, callcc.sx

Test files follow source: spec/tests/ for core language tests,
lib/tests/ for library tests (continuations, freeze, types, vm).

Updated all consumers:
- JS/Python/OCaml bootstrappers: added lib/ to source search paths
- OCaml bridge: spec_dir for parser/render, lib_dir for compiler/freeze
- JS test runner: scans spec/tests/ (always) + lib/tests/ (--full)
- OCaml test runner: scans spec/tests/, lib tests via explicit request
- Docker dev mounts: added ./lib:/app/lib:ro

Tests: 1041 JS standard, 1322 JS full, 1101 OCaml — all pass

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 23:18:30 +00:00
parent 50871780a3
commit f3f70cc00b
26 changed files with 109 additions and 64 deletions

View File

@@ -1174,18 +1174,20 @@ let cli_load_files env files =
let cli_mode mode =
let env = make_server_env () in
(* Load spec + adapter files for aser modes *)
let base = try Sys.getenv "SX_SPEC_DIR" with Not_found -> "spec" in
let spec_base = try Sys.getenv "SX_SPEC_DIR" with Not_found -> "spec" in
let lib_base = try Sys.getenv "SX_LIB_DIR" with Not_found -> "lib" in
let web_base = try Sys.getenv "SX_WEB_DIR" with Not_found -> "web" in
let spec_files = [
Filename.concat base "parser.sx";
Filename.concat base "render.sx";
let render_files = [
Filename.concat spec_base "parser.sx";
Filename.concat spec_base "render.sx";
Filename.concat web_base "adapter-html.sx";
Filename.concat web_base "adapter-sx.sx";
Filename.concat web_base "web-forms.sx";
] in
(* Load spec files for all CLI modes that need rendering *)
(* Load spec + adapter files for rendering CLI modes *)
(if mode = "aser" || mode = "aser-slot" || mode = "render" then
cli_load_files env spec_files);
cli_load_files env render_files);
ignore lib_base; (* available for --load paths *)
(* Load any files passed via --load *)
let load_files = ref [] in
let args = Array.to_list Sys.argv in
@@ -1256,13 +1258,14 @@ let cli_mode mode =
let test_mode () =
let env = make_server_env () in
(* Load full spec + adapter stack *)
let base = try Sys.getenv "SX_SPEC_DIR" with Not_found -> "spec" in
(* Load spec + lib + adapter stack *)
let spec_base = try Sys.getenv "SX_SPEC_DIR" with Not_found -> "spec" in
let lib_base = try Sys.getenv "SX_LIB_DIR" with Not_found -> "lib" in
let web_base = try Sys.getenv "SX_WEB_DIR" with Not_found -> "web" in
let files = [
Filename.concat base "parser.sx";
Filename.concat base "render.sx";
Filename.concat base "compiler.sx";
Filename.concat spec_base "parser.sx";
Filename.concat spec_base "render.sx";
Filename.concat lib_base "compiler.sx";
Filename.concat web_base "signals.sx";
Filename.concat web_base "adapter-html.sx";
Filename.concat web_base "adapter-sx.sx";