45451. Spec before code. No `.rs` files until `docs/SPEC.md` covers the work.1. Spec before code. No `.rs` files until `docs/SPEC.md` covers the work.
46462. AGENTS.md is the navigation index. `docs/SPEC.md` is the canonical project spec.2. AGENTS.md is the navigation index. `docs/SPEC.md` is the canonical project spec.
47-3. Every spec section answers: interfaces, types, errors, tests.
47+3. Every spec section answers: interfaces, data, errors, tests — as named
48+ shapes and behavior, not code. Exact only at boundaries others program
49+ against (files, wire formats, CLI, config, Lua SDK); code blocks are
50+ illustrative unless the section says otherwise.
48514. Open questions: stop and ask. No guessing.4. Open questions: stop and ask. No guessing.
2020- Shell scripts in repo root or scripts/- Shell scripts in repo root or scripts/
21-- Any build step that requires tools not installable via `cargo install`, except pinned nightly rustup components required by the `cargo-pup` architecture gate
21+- Any build step that requires tools not installable via `cargo install`, with two named exceptions: pinned nightly rustup components required by the `cargo-pup` architecture gate, and the `zig` toolchain required by `cargo-zigbuild` for release cross-builds (§8a)
233233| `cargo run -p xtask -- test` | Run all tests (delegates to `cargo nextest run`) | Every commit || `cargo run -p xtask -- test` | Run all tests (delegates to `cargo nextest run`) | Every commit |
234234| `cargo run -p xtask -- lint` | Clippy + rustfmt check | Every commit || `cargo run -p xtask -- lint` | Clippy + rustfmt check | Every commit |
235235| `cargo run -p xtask -- fmt` | Auto-format (delegates to `cargo fmt`) | On demand || `cargo run -p xtask -- fmt` | Auto-format (delegates to `cargo fmt`) | On demand |
236-| `cargo run -p xtask -- fetch-providers` | Fetch pi.dev + catwalk → `providers.json` | On demand |
236+| `cargo run -p xtask -- fetch-providers` | Fetch models.dev + catwalk → `providers.json` | On demand |
237237| `cargo run -p xtask -- doc-test` | Extract + run Lua code blocks from docs | CI || `cargo run -p xtask -- doc-test` | Extract + run Lua code blocks from docs | CI |
238238| `cargo run -p xtask -- verify-docs` | Completeness checks (every API documented) | CI || `cargo run -p xtask -- verify-docs` | Completeness checks (every API documented) | CI |
239239| `cargo run -p xtask -- doc-gen` | Generate man pages + docs bundle | Release || `cargo run -p xtask -- doc-gen` | Generate man pages + docs bundle | Release |
2929 keybindings, prompts, layouts, and feature UI are Lua plugins. keybindings, prompts, layouts, and feature UI are Lua plugins.
3030- **LLM is the only untrusted actor.** Local user, local plugins, local files,- **LLM is the only untrusted actor.** Local user, local plugins, local files,
3131 and Smith itself are trusted. and Smith itself are trusted.
32+- **Pi is Smith's philosophical ancestor, not a dependency.** Smith improves
33+ on pi's ideas with no data or format coupling to it.
34+- **Exact at boundaries, shapes inside.** This spec is exact where others
35+ program against it — files, wire formats, CLI, config, Lua SDK — and
36+ shape-level (named types, behavior, properties) for internal Rust. Code
37+ blocks are illustrative unless a section says otherwise.
329336Session files are plaintext length-prefixed CBOR sequences. Trace files areSession files are plaintext length-prefixed CBOR sequences. Trace files are
330337compressed deterministic replay logs. Secrets in sessions are plaintext aftercompressed deterministic replay logs. Secrets in sessions are plaintext after
331-local registration; the security boundary is the LLM, not the local user.
358356`smith` must not re-export `smith-core` types. Domain types are imported from`smith` must not re-export `smith-core` types. Domain types are imported from
513510`smith-core` owns pure business logic: agent loop, sessions, tools, hooks,`smith-core` owns pure business logic: agent loop, sessions, tools, hooks,
514511secret proxy, compaction, cost, trace, and replay. It depends only on `smith`.secret proxy, compaction, cost, trace, and replay. It depends only on `smith`.
650639- session discovery is keyed by canonical `{session-id}.session` filenames.- session discovery is keyed by canonical `{session-id}.session` filenames.
8648352. the checked-in `providers.json` (CI gate),2. the checked-in `providers.json` (CI gate),
8658363. provider tables passed to `smith.provider.register` at runtime (§9.10).3. provider tables passed to `smith.provider.register` at runtime (§9.10).
900879`api_key` (with its `env_var` name), `oauth`, and `organization` (org-scoped`api_key` (with its `env_var` name), `oauth`, and `organization` (org-scoped
901880key, e.g. OpenAI: api key + org ID). `AuthMethod` mirrors these three.key, e.g. OpenAI: api key + org ID). `AuthMethod` mirrors these three.
978957- capabilities are probed once per session at startup, with a 100ms timeout- capabilities are probed once per session at startup, with a 100ms timeout
979958 per probe; on timeout the capability is treated as absent (fail per probe; on timeout the capability is treated as absent (fail
12491230- Git installs strip the `.git` directory: an installed plugin is a pure file- Git installs strip the `.git` directory: an installed plugin is a pure file
12501231 snapshot, not a working clone. Updates go through reinstall. snapshot, not a working clone. Updates go through reinstall.
12881266**Descriptor.** An interface package exports a descriptor: a pure data table**Descriptor.** An interface package exports a descriptor: a pure data table
1289-with `name` (`<org>/<name>`), `generation` (integer), `functions` (map of
1290-function name → `{ params, returns }` with typed, optionally-optional named
1291-parameters), and `events` (list of bus topics, §9.18).
1267+with `name` (`<org>/<name>`), `generation` (integer — the interface's own
1268+version, distinct from the plugin API generation of §9.3 and the reload domain
1269+generation of §9.16), `functions` (map of function name → `{ params, returns }`
1270+with typed, optionally-optional named parameters), and `events` (list of bus
12941274implementations referencing external interfaces, and combined packages are allimplementations referencing external interfaces, and combined packages are all
13541334| `tool_execution_update`, `tool_result`, `tool_execution_end` | No | `tool_result` may modify the result || `tool_execution_update`, `tool_result`, `tool_execution_end` | No | `tool_result` may modify the result |
13551335| `input` | No | may intercept/transform/mark handled || `input` | No | may intercept/transform/mark handled |
1627+- The limit's domain is the plugin's own Lua state — one `mlua::Lua` per
1628+ plugin (matching the §9.16 domain model). Per-plugin limits in a shared Lua
1629+ state are not attributable and are not offered.
16491630- Enforcement is `Lua::set_memory_limit()`; under the locked vendored-LuaJIT- Enforcement is `Lua::set_memory_limit()`; under the locked vendored-LuaJIT
16501631 feature set this enforces exactly, and breach surfaces as a recoverable feature set this enforces exactly, and breach surfaces as a recoverable
16511632 memory error handled by the §9.17 error model. Targets where mlua reports memory error handled by the §9.17 error model. Targets where mlua reports
1652- memory control as unavailable must fail plugin-quota configuration loudly,
1633+ memory control as unavailable must fail heap-limit configuration loudly,
16531634 never enforce silently at zero; per-target enforcement is CI-verified. never enforce silently at zero; per-target enforcement is CI-verified.
1654-- The quota covers the plugin's Lua heap only, including host-created Lua
1655- values. Host-side Rust allocations held for a plugin are invisible to the
1656- quota and are bounded by domain teardown (§9.16) instead.
1635+- The limit covers the plugin's Lua heap only, including host-created Lua
1636+ values. Host-side Rust allocations held for a plugin are invisible to it
1637+ and are bounded by domain teardown (§9.16) instead.
16571638- After a plugin OOM, the preferred recovery is whole-domain replacement- After a plugin OOM, the preferred recovery is whole-domain replacement
16581639 (§9.16) rather than in-place retry. (§9.16) rather than in-place retry.
17381719 warmup; no stale callback from `D` may run after the swap. The plateau is warmup; no stale callback from `D` may run after the swap. The plateau is
17391720 the enforceable observable — an instantaneous RSS decrease per teardown is the enforceable observable — an instantaneous RSS decrease per teardown is
17401721 not required, since small freed heaps are legitimately retained by the not required, since small freed heaps are legitimately retained by the
1741- allocator for reuse (p11: ≤77KB growth over 80 cycles; a 31MB teardown
17441724**Rollback.** Reload is all-or-nothing. Either `D'` fully replaces `D`, or `D`**Rollback.** Reload is all-or-nothing. Either `D'` fully replaces `D`, or `D`
17451725remains and no partial state from `D'` survives. A failed reload never leaves theremains and no partial state from `D'` survives. A failed reload never leaves the
17501730old domain run to completion under `D`; their results are still delivered. Newold domain run to completion under `D`; their results are still delivered. New
17511731invocations after the swap use `D'`.invocations after the swap use `D'`.
17531739**Dependents.** Reloading `P` does not reload its dependents (§9.15). Dependents**Dependents.** Reloading `P` does not reload its dependents (§9.15). Dependents
17541740keep their handles to `P`'s registrations by stable name; the swap rebinds thosekeep their handles to `P`'s registrations by stable name; the swap rebinds those
17551741names to `D'`. A reload that removes a registration a dependent relies on surfacesnames to `D'`. A reload that removes a registration a dependent relies on surfaces
18311817losing the active session. Host reload follows the same contract shape as pluginlosing the active session. Host reload follows the same contract shape as plugin
18321818reload (§9.16): validate fully, swap atomically, roll back on failure.reload (§9.16): validate fully, swap atomically, roll back on failure.
19251906 The full method catalog is deferred: it is expected to mirror the Lua SDK The full method catalog is deferred: it is expected to mirror the Lua SDK
19261907 surface (§9.10), with mode-specific additions and omissions, rather than surface (§9.10), with mode-specific additions and omissions, rather than
19271908 define an independent API. define an independent API.
1960-1. Tool registry controls which tools the LLM can invoke.
1961-2. Secret proxy prevents real secrets from reaching LLM context.
1962-3. Restricted Lua runtime removes raw OS/file APIs.
1941+1. Tool registry (§6.10) controls which tools the LLM can invoke.
1942+2. Secret proxy (§6.7) prevents real secrets from reaching LLM context.
1943+3. Restricted Lua runtime (§5.5) removes raw OS/file APIs.
196319444. Users configure active tools; no confirmation-dialog security theater.4. Users configure active tools; no confirmation-dialog security theater.
20071983- **Session discovery is lazy and metadata-only.** Discovery reads session- **Session discovery is lazy and metadata-only.** Discovery reads session
2008- headers, never full bodies: O(session count), not O(corpus bytes). Fully
2009- loading a realistic corpus would cost ~0.7–1.2GiB resident.
1984+ headers, never full bodies: O(session count), not O(corpus bytes).
20101985- **Virtual scroll materializes at most viewport rows per frame.** Row- **Virtual scroll materializes at most viewport rows per frame.** Row
20111986 formatting stops at the visible window (lazy wrap); a single multi-MiB formatting stops at the visible window (lazy wrap); a single multi-MiB
20121987 message must not be fully formatted to render its visible slice. message must not be fully formatted to render its visible slice.
22422213Fixtures live under `tests/fixtures/` with plugins, sessions, configs, providers,Fixtures live under `tests/fixtures/` with plugins, sessions, configs, providers,