1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//! # sim-nest -- the SIM umbrella crate (imported as `sim`)
//!
//! Published on crates.io as **`sim-nest`** (the bare name `sim` is taken), but the
//! library import identifier is `sim`. Add it as `sim-nest = "0.1"` (or, to make the
//! rename explicit, `sim = { package = "sim-nest", version = "0.1" }`) and write
//! `use sim::...` throughout; the `#[sim::sim_lib]` / `#[sim::sim_fn]` proc-macros
//! resolve against it unchanged. Note: `use sim_nest::...` will NOT resolve -- the
//! crate's library name is `sim`, so import `sim`, not `sim_nest`.
//!
//! SIM is an expandable Rust runtime built around a small protocol kernel plus
//! a large set of loadable libraries. The kernel defines contracts; libraries
//! provide behavior. The data flow is:
//!
//! ```text
//! tokens -> checked forms -> objects -> checked calls -> objects -> encoded forms
//! ```
//!
//! SIM is a Rust runtime with multiple codec surfaces. Lisp is one codec, not
//! the system identity. Everything above the kernel is a lib: syntax, codecs,
//! classes, functions, number domains, checkers, evaluators, wasm adapters,
//! loaders, and even the standard language surface. The standard distribution
//! is just a set of libs loaded by default.
//!
//! ## Umbrella role
//!
//! This crate (`sim`) is the umbrella and entry point of the SIM constellation.
//! The implementation crates live in sibling repositories; this crate
//! aggregates them through optional dependencies and a feature map, re-exports
//! them under stable module aliases (`sim::kernel`, `sim::shape`,
//! `sim::codec`, the `sim::codec_*`, `sim::lib_*`, `sim::table_*`, and
//! `sim::list_*` families), and ships the core runtime installer plus the
//! authoring helpers (`functions`, `classes`, `macros`, `shapes`, and
//! `runtime`, available with the `shape` feature). The default feature set is
//! `core`, `codec-lisp`, and
//! `numbers-f64`; the canonical, current feature map is this crate's
//! `Cargo.toml`.
//!
//! ## Kernel boundary
//!
//! The central discipline is keeping the kernel small. The kernel may define
//! identity and transport types (`Symbol`, `Expr`, `Value`, `Origin`, `Ref`,
//! `Datum`, errors, stable ids), coordination types (`Cx`, `Registry`, `Lib`,
//! `Linker`, `ExportRecord`, capabilities, claim/fact and handle stores, Card
//! records, operation specs, event/effect ledgers, control policy, rank
//! metadata), the object/callable/class/shape/factory/eval-policy/
//! macro-expander behavior contracts, shape match and binding result types, and
//! the ABI frame and manifest transport shapes. The kernel must not define
//! concrete Lisp/JSON/Algol parsing, concrete number domains or arithmetic,
//! concrete help/test/browse implementations, wasm guest behavior above the ABI
//! transport, or remote transport and agent-product policy. New metadata is
//! modeled as open `ExportRecord`-style data rather than new closed kernel
//! enums. Concrete behavior is added as a lib through `Lib`, `Linker`, and
//! `ExportRecord`.
//!
//! ## Load-bearing concepts
//!
//! - **`Shape`** is one shared engine for parsing, checking, binding, dispatch,
//! macro syntax, codec grammar, lambda locals, and overload selection. It is
//! a first-class kernel protocol (object-accessible via `as_shape`, callable
//! as a matcher); concrete shape behavior lives in `sim-shape` and other libs.
//! - **Codecs are first-class runtime objects**, split into independent
//! decoders and encoders; encoders know their output position. General-purpose
//! expression codecs are total over the shared `Expr` graph and round-trip
//! every expression semantically; domain codecs round-trip only their domain
//! and fail closed outside it.
//! - **`realize` and `EvalFabric`** are the location-transparent distributed
//! evaluation surface. Server and agent code targets these, never a
//! transport-specific API. Evaluation strategy itself is an injectable
//! `EvalPolicy` (eager, lazy, need, hybrid, no-op).
//! - **Capability gating** makes power explicit: read-eval, native dynamic
//! loading, and host effects (file, network, clock, random, process) are
//! capabilities a host grants. **Read-construct** is the narrower
//! capability-gated path that backs Lisp `#(...)` literals; it is distinct
//! from broad **read-eval**, which evaluates during decode and is disabled by
//! default for untrusted input.
//! - **Number domains, lists, and tables are pluggable libs**, not kernel
//! behavior; codecs delegate numeric literals to the active domains by parse
//! priority.
//! - **Wasm** is a first-class runtime target and the portable plugin ABI.
//!
//! ## Embedding
//!
//! `runtime::install_core_runtime` (with the `shape` feature) is the entry
//! point for embedding SIM.
//! Build a `Cx` with an eval policy and a factory, install the core runtime,
//! then install codecs and behavior libs through their `install_*` helpers or
//! directly through `Lib` and `Linker`:
//!
//! ```ignore
//! use std::sync::Arc;
//! use sim::kernel::{Cx, DefaultFactory, EagerPolicy};
//! use sim::runtime::install_core_runtime;
//!
//! let mut cx = Cx::new(Arc::new(EagerPolicy), Arc::new(DefaultFactory));
//! install_core_runtime(&mut cx);
//! // install codecs and libs, then cx.eval_expr(...).
//! ```
//!
//! `install_core_runtime` loads the core runtime through the lib registry and
//! installs the default number domain(s) for the enabled `numbers-*` features.
extern crate self as sim;
pub use *;
pub use *;
pub use *;
const _: bool = true;
pub use *;
pub use ;
/// Native class authoring helpers: a `Class` implementation plus the lib
/// wrapper that registers a host-defined class, its constructor, and members.
/// Stable hashing of lib manifests, shapes, and codecs for compatibility
/// checks across versions of the constellation.
/// Function authoring helpers built on the shared `Shape` engine: overload
/// cases, native function objects, and member-table construction.
/// Lib loaders for the supported source formats (host, Lisp source, binary
/// pack, native dynamic library, and wasm) plus the standard loader registry.
/// Macro authoring and expansion: the `LispMacro` contract, macro objects, the
/// registry-backed expander, and shape constructors for macro syntax.
/// End-to-end music rendering stack that lowers a score to MIDI and renders it
/// to PCM audio through the sound libs.
/// Core runtime installer and the embedding entry point that wires classes,
/// shapes, functions, and the default number domains into a `Cx`.
/// Shape authoring helpers: documented and value-backed shape wrappers plus
/// shape registration and checking utilities.
pub use *;
// The macros' native_export output emits `::sim::codec_binary::{decode_frame,
// encode_frame}`, so the feature that enables the macros must also expose that
// module. `proc-macros` pulls `codec-binary`; this contract asserts it, so a future
// edit that drops it fails to compile instead of shipping macros that cannot expand.
compile_error!;
pub use sim_wasm_abi as wasm_abi;