repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

Move the lint wall into workspace lints, and settle Android's status (#98)

c3a6afe484d9462e23ab5ab9471ae12f9acac1fe

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

Fixes the findings from #97 and #98's review, and the unresolved ones
from #96.

## The lint wall was one target-stanza away from switching itself off

A `[target.<triple>].rustflags` key **replaces** `[build].rustflags`
rather than merging with it. Android needs a link flag of its own —
vendored LuaJIT cannot resolve `__clear_cache` without compiler-rt
builtins, since Bionic does not carry them — so adding that stanza
silently disabled every `-D warning`, clippy deny and `missing_docs`
**for a target that now blocks releases**. Code failing the zero-warning
invariant everywhere else would have passed there.

My first fix repeated the whole wall in both stanzas. That works and
leaves two lists to drift apart, so it is not the fix.

**`[workspace.lints]` does not have the problem.** Lint tables are
per-crate, independent of target flags, and scoped to workspace crates
instead of leaking `-D warnings` into dependencies. The wall moves
there, every crate inherits it with `[lints] workspace = true`, and
`.cargo/config.toml` keeps only what cannot be expressed as a lint: the
Android link flag and the sparse registry protocol.

**Verified on the real workspace**, not argued: `cargo build`, `cargo
clippy --workspace --all-targets --all-features` and `cargo fmt --check`
are green; an injected `unwrap()` fails the build; and a scratch
workspace confirmed the denial still fires with a `[target.*]` stanza
present.

## The spec loses its verbatim TOML with it

Which lints are denied is policy and stays. How a config file spells
them is mechanism and does not belong in a specification (CLAUDE.md rule
3). §3.2 in both documents now states the rule, the denied set, and
*why* the wall cannot live in `rustflags` — no config listing to drift
from the tree.

## Android's status, settled in three places

`docs/SPEC.md` §14 said required, `PROJECT-INVARIANTS` §8a said "not a
release artifact target", and SPEC §17.10 said "not a release target".
Per the owner's decision Android **ships**: all three now agree, the
invariant matrix gains the riscv64 and FreeBSD rows §14 grew, and it
records that a target in one table and absent from the other is drift.

## Also here

The merged workspace shipped without the `[profile.release]` block both
documents define verbatim — release builds would have used Cargo
defaults: fat debug info, unwinding panics, no LTO. Added. `msrv =
"1.85"` leaves `.clippy.toml`, which `PROJECT-INVARIANTS` §3.2 forbids
in as many words ("No msrv key").

Codex's claim that §2.3 requires a `[workspace.dependencies]` registry
is a **false positive** — the spec defines no such block.

## Surface touched

`Cargo.toml` (workspace lints + release profile), seven crate manifests,
`.cargo/config.toml`, `.clippy.toml`, `docs/SPEC.md` §3.2/§14/§17.10,
`docs/PROJECT-INVARIANTS.md` §3.2/§8a.

## If this ages badly

If a lint proves unexpressible in `[workspace.lints]` and must return to
`rustflags`, it has to go into **every** target stanza, not just
`[build]` — that is the trap this removes, and the spec now says so.

https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB

---------

Co-authored-by: Claude <noreply@anthropic.com>

Changed files (12)

+130 / −101 text lines

Diff layout

.cargo/config.toml

Modified

+9 / −31 text lines

1[build]
2rustflags = [
3 # Zero warnings policy
4 "-D", "warnings",
5
6 # Core lint groups
7 "-D", "clippy::all",
8 "-D", "clippy::pedantic",
9 "-W", "clippy::nursery",
10 "-D", "clippy::suspicious",
11 "-D", "clippy::complexity",
12 "-D", "clippy::perf",
13 "-D", "clippy::style",
14 "-D", "clippy::correctness",
16 # Restriction lints — prohibited patterns
17 "-D", "clippy::unwrap_used",
18 "-D", "clippy::expect_used",
19 "-D", "clippy::panic",
20 "-D", "clippy::todo",
21 "-D", "clippy::unimplemented",
22 "-D", "clippy::print_stdout",
23 "-D", "clippy::print_stderr",
25 # Documentation lints
26 "-D", "missing_docs",
27 "-D", "rustdoc::missing_crate_level_docs",
28 "-D", "rustdoc::broken_intra_doc_links",
29 "-W", "rustdoc::invalid_html_tags",
30 "-W", "rustdoc::bare_urls",
31]
1# Lints are NOT here — they live in Cargo.toml's [workspace.lints], because a
2# [target.*] rustflags key replaces [build].rustflags instead of merging, which
3# silently disabled the whole wall for any target with its own stanza.
4# Only flags that cannot be expressed as lints belong in this file.
336[registries.crates-io]
347protocol = "sparse"
8
9# Bionic carries no compiler-rt builtins, so vendored LuaJIT cannot link
10# __clear_cache without them. Safe as a target stanza now: it shadows no lints.
11[target.aarch64-linux-android]
12rustflags = ["-C", "link-args=-lclang_rt.builtins-aarch64-android"]

.clippy.toml

Modified

+0 / −7 text lines

1111# -----------------------------------------------------------------------------
1212# TUI event routing naturally hits this. Review functions >20 during review.
1313cognitive-complexity-threshold = 25
15# -----------------------------------------------------------------------------
16# MSRV
17# -----------------------------------------------------------------------------
18# Align with workspace rust-version. Clippy suggests modern idioms
19# only if they're available on the MSRV.
20msrv = "1.85"

Cargo.toml

Modified

+44 / −0 text lines

1414edition = "2024"
1515version = "0.1.0"
1616license = "Apache-2.0"
18# The lint wall. It lives here, not in .cargo/config.toml rustflags, because a
19# [target.*] rustflags key REPLACES [build].rustflags rather than merging — so a
20# per-target stanza silently disabled every lint below for that target alone.
21# Cargo lint tables are per-crate and target-independent, and they apply only to
22# workspace crates rather than leaking -D warnings into dependencies.
23[workspace.lints.rust]
24warnings = "deny"
25missing_docs = "deny"
27[workspace.lints.clippy]
28all = { level = "deny", priority = -1 }
29pedantic = { level = "deny", priority = -1 }
30nursery = { level = "warn", priority = -1 }
31suspicious = { level = "deny", priority = -1 }
32complexity = { level = "deny", priority = -1 }
33perf = { level = "deny", priority = -1 }
34style = { level = "deny", priority = -1 }
35correctness = { level = "deny", priority = -1 }
36unwrap_used = "deny"
37expect_used = "deny"
38panic = "deny"
39todo = "deny"
40unimplemented = "deny"
41print_stdout = "deny"
42print_stderr = "deny"
44[workspace.lints.rustdoc]
45missing_crate_level_docs = "deny"
46broken_intra_doc_links = "deny"
47invalid_html_tags = "warn"
48bare_urls = "warn"
50# Mandated verbatim by SPEC §3 and PROJECT-INVARIANTS §8a. No debug info in
51# release builds; debug symbols come only from the default dev profile.
52[profile.release]
53opt-level = 3
54lto = "thin"
55codegen-units = 1
56strip = "symbols"
57panic = "abort"
59[profile.release.package."*"]
60opt-level = 3

docs/PROJECT-INVARIANTS.md

Modified

+33 / −34 text lines

103103**Invariant:** All workspace crates compile with zero warnings. No exceptions for shipped code.
105#### Configuration Files
105#### Where lints live
107**`[workspace.lints]` in the workspace root, inherited by every crate via
108`[lints] workspace = true` — never `rustflags`.** A `[target.<triple>].rustflags`
109key *replaces* `[build].rustflags` instead of merging, so a target carrying any
110flag of its own would build with the whole wall switched off; Android needs
111exactly such a flag (§8a). Lint tables are per-crate and target-independent, and
112apply only to workspace crates rather than leaking denials into dependencies.
114Denied: the clippy **all / pedantic / suspicious / complexity / perf / style /
115correctness** groups; **`unwrap_used`, `expect_used`, `panic`, `todo`,
116`unimplemented`, `print_stdout`, `print_stderr`**; **`missing_docs`,
117`rustdoc::missing_crate_level_docs`, `rustdoc::broken_intra_doc_links`**. Warned:
118`clippy::nursery`, `rustdoc::invalid_html_tags`, `rustdoc::bare_urls`.
120`.cargo/config.toml` carries only what cannot be a lint — the Android link flag
121and the sparse registry protocol.
107123```toml
108# .cargo/config.toml
109[build]
110rustflags = [
111 "-D", "warnings",
112 "-D", "clippy::unwrap_used",
113 "-D", "clippy::expect_used",
114 "-D", "clippy::panic",
115 "-D", "clippy::todo",
116 "-D", "clippy::unimplemented",
117 "-D", "clippy::print_stdout",
118 "-D", "clippy::print_stderr",
119 "-D", "missing_docs",
120 "-D", "rustdoc::missing_crate_level_docs",
121 "-D", "rustdoc::broken_intra_doc_links",
122 "-W", "rustdoc::invalid_html_tags",
123 "-W", "rustdoc::bare_urls",
124]
126[registries.crates-io]
127protocol = "sparse"
129# Required for vendored LuaJIT on Android/Termux ARM64.
130[target.aarch64-linux-android]
131rustflags = ["-C", "link-args=-lclang_rt.builtins-aarch64-android"]
132```
134```toml
135# .clippy.toml — project-wide lint configuration
136# NOTE: clippy.toml only supports configuration VALUES.
137# Lint enablement/disablement is in .cargo/config.toml rustflags.
124# .clippy.toml — configuration VALUES only; enablement lives in [workspace.lints]
139125cognitive-complexity-threshold = 25
140126# No msrv key: lint policy follows latest stable Rust.
141127```
217203cargo doc --workspace --no-deps
218204```
220**Lint flags (in .cargo/config.toml rustflags):**
206**Doc lints (in `[workspace.lints]`, §3.2):**
221207```rust
222208-D missing_docs
223209-D rustdoc::missing_crate_level_docs
399385| Linux ARM64 (glibc) | `aarch64-unknown-linux-gnu` | Tier 1 | Required |
400386| Linux x86_64 (musl) | `x86_64-unknown-linux-musl` | Tier 2 | Required (static) |
401387| Linux ARM64 (musl) | `aarch64-unknown-linux-musl` | Tier 2 | Required (static) |
388| Android ARM64 (Bionic) | `aarch64-linux-android` | Tier 2 | Required |
389| Linux riscv64 (glibc) | `riscv64gc-unknown-linux-gnu` | Tier 2 | Best-effort |
390| Linux riscv64 (musl) | `riscv64gc-unknown-linux-musl` | Tier 2 | Best-effort |
391| FreeBSD x86_64 | `x86_64-unknown-freebsd` | Tier 2 | Best-effort |
402392| OpenBSD x86_64 | `x86_64-unknown-openbsd` | Tier 3 | Best-effort |
404**Development environment note:** Android/Termux on `aarch64-linux-android` is a supported development environment, not a release artifact target. Vendored LuaJIT requires compiler-rt builtins linked for `__clear_cache`; see `.cargo/config.toml`.
394**Android is a shipping platform, not only a development one** (owner decision,
3952026-07-25). Android/Termux on `aarch64-linux-android` is both the environment smith
396is developed in *and* a required release artifact: a terminal-first coding agent is
397used on a phone, not merely built for one. It is a third libc — **Bionic**, beside
398glibc and musl — which is why it gets its own row rather than a Linux variant.
399Bionic does not carry the compiler-rt builtins Rust expects, so vendored LuaJIT
400fails to link `__clear_cache` unless they are linked explicitly; that flag lives in
401`.cargo/config.toml` and is normative for this target, not a local workaround. This
402table and `docs/SPEC.md` §14 must agree — a target listed in one and absent from the
403other is drift.
406405### Artifact Format

docs/SPEC.md

Modified

+23 / −29 text lines

278278 product code to nightly.
279279- Pup failure blocks commit, PR, and release.
281### 3.2 Rust Flags
281### 3.2 Lints
283`.cargo/config.toml`:
283**Zero warnings.** A warning is an error; nothing merges or releases with one
284(PROJECT-INVARIANTS §3).
285```toml
286[build]
287rustflags = [
288 "-D", "warnings",
289 "-D", "clippy::unwrap_used",
290 "-D", "clippy::expect_used",
291 "-D", "clippy::panic",
292 "-D", "clippy::todo",
293 "-D", "clippy::unimplemented",
294 "-D", "clippy::print_stdout",
295 "-D", "clippy::print_stderr",
296 "-D", "missing_docs",
297 "-D", "rustdoc::missing_crate_level_docs",
298 "-D", "rustdoc::broken_intra_doc_links",
299 "-W", "rustdoc::invalid_html_tags",
300 "-W", "rustdoc::bare_urls",
301]
286Denied for every workspace crate: the `clippy` **all / pedantic / suspicious /
287complexity / perf / style / correctness** groups; the restriction lints
288**`unwrap_used`, `expect_used`, `panic`, `todo`, `unimplemented`,
289`print_stdout`, `print_stderr`**; and the documentation lints **`missing_docs`,
290`rustdoc::missing_crate_level_docs`, `rustdoc::broken_intra_doc_links`**.
291Warned, not denied: `clippy::nursery`, `rustdoc::invalid_html_tags`,
292`rustdoc::bare_urls`. Escape hatches follow §3.3.
303[registries.crates-io]
304protocol = "sparse"
306[target.aarch64-linux-android]
307rustflags = ["-C", "link-args=-lclang_rt.builtins-aarch64-android"]
308```
294**Enforcement is uniform across targets.** The wall applies identically to every
295target in the §14 matrix; no per-target build configuration may weaken it. This is
296a requirement, not a preference — the obvious encoding (global compiler flags) has
297the property that a target needing any flag of its own silently loses every lint,
298and a required release target needs exactly that. Whatever mechanism carries the
299wall must therefore be immune to per-target override, and must not impose smith's
300denials on third-party dependencies. `PROJECT-INVARIANTS` §3.2 records the
301encoding that satisfies this.
310303Every library crate has:
28472840PROJECT-INVARIANTS §5 and `docs/plans/AGENTIC-DEVELOPMENT.md`. This section
28482841defines Smith's test artifacts, not who is allowed to run or merge them.
2850Android/Termux (`aarch64-linux-android`) is a supported development
2851environment, not a release target (§14): CI keeps a validation lane that
2852smoke-builds vendored LuaJIT and syntastica for it; breakage there blocks
2853source-compatibility fixes, not artifact publishing.
2843Android/Termux (`aarch64-linux-android`) is both the environment smith is
2844developed in and a **required release target** (§14): CI keeps a validation lane
2845that smoke-builds vendored LuaJIT and syntastica for it, and because the artifact
2846ships, breakage there blocks publishing like any other required target — not only
2847source-compatibility fixes.
28552849## 18. Prototype Policy

smith-ai/Cargo.toml

Modified

+3 / −0 text lines

77[lib]
88path = "src/lib.rs"
9
10[lints]
11workspace = true

smith-cli/Cargo.toml

Modified

+3 / −0 text lines

77[[bin]]
88name = "smith"
99path = "src/main.rs"
11[lints]
12workspace = true

smith-core/Cargo.toml

Modified

+3 / −0 text lines

77[lib]
88path = "src/lib.rs"
9
10[lints]
11workspace = true

smith-harness/Cargo.toml

Modified

+3 / −0 text lines

77[lib]
88path = "src/lib.rs"
9
10[lints]
11workspace = true

smith-tui/Cargo.toml

Modified

+3 / −0 text lines

77[lib]
88path = "src/lib.rs"
9
10[lints]
11workspace = true

smith/Cargo.toml

Modified

+3 / −0 text lines

77[lib]
88path = "src/lib.rs"
9
10[lints]
11workspace = true

xtask/Cargo.toml

Modified

+3 / −0 text lines

77[[bin]]
88name = "xtask"
99path = "src/main.rs"
11[lints]
12workspace = true