| @@ -1,6 +1,21 @@ |
| 1 | 1 | # Code health audit (issue #62) |
| 2 | 2 | |
| 3 | | −> **Status.** This audit was written against `main` at `f2b02b7`, before the v1 feature stack (packages, FFI callbacks and bindgen, multi-parameter traits, HKT, derives, arrays, bigint, HTTP limits, `defer`, multi-shot) landed. Line numbers refer to that commit. Each finding's checkbox is ticked as the cleanliness PRs land; a finding or part of one that is deliberately not done carries a note saying why. Each finding a PR worked on carries a **Status** line saying what it did, per PR. PR 2 (core, Perceus, codegen) was checked against the v1 base after PR 1: generated C is byte-identical for every program of `tests/run`, `tests/stress`, `tests/bench` and `examples/http_demo` (one and three translation units), and `tilc core` prints the same Core, except for the intended changes its H1 and L3 entries name. |
| 3 | +> **Status.** This audit was written against `main` at `f2b02b7`, before the v1 feature stack (packages, FFI callbacks and bindgen, multi-parameter traits, HKT, derives, arrays, bigint, HTTP limits, `defer`, multi-shot) landed. Line numbers refer to that commit. Each finding's checkbox is ticked as the cleanliness PRs land; a finding or part of one that is deliberately not done carries a note saying why. Each finding a PR worked on carries a **Status** line saying what it did, per PR. PR 2 (core, Perceus, codegen) was checked against the v1 base after PR 1: generated C is byte-identical for every program of `tests/run`, `tests/stress`, `tests/bench` and `examples/http_demo` (one and three translation units), and `tilc core` prints the same Core, except for the intended changes its H1 and L3 entries name. PR 4 (driver, LSP, std, scripts) was checked against the base after PR 3, with the old and new `tilc` side by side: `check`, `core` and `build` (`TILC_C_UNITS=3`) print and generate the same thing (224 outputs, 56 C files) for every program of `tests/run`, `tests/stress`, `tests/bench` and both example programs, and `test` (interpreted and native) prints the same results for the four packages in the repository; the exceptions are the intended changes its M5, L1 and L4 entries name. |
| 4 | + |
| 5 | +## After the four cleanliness PRs (issue #62) |
| 6 | + |
| 7 | +**What they did.** Every High and Medium finding is done, each part either fixed or left with a reason below. |
| 8 | +- **One source of truth where the code had several:** one table of the runtime's externs, checked against std, the interpreter, `tilrt` and `tilrt.h` (H1); one crate of pure kernels and constants shared by the runtime, the interpreter and codegen (M3); one resolved table of the std items the back ends know, with a test of every constructor tag they build (M4); typed attributes, with diagnostics instead of crashes (H2); one decision of what a path names, for every command and the language server (M5). |
| 9 | +- **Layering:** codegen no longer depends on `tilc_db`; the C build is `tilc_build`, which depends on the packages crate, `tilc_package`, not on the front end (M1); the interpreter is its own crate (M2). |
| 10 | +- **Size:** four of the five files over 1,200 lines, and the driver's `main.rs` (one module per command), are split along their sections, verbatim (M6; PR 4 for `main.rs`); one test kit and one pipeline instead of seven copies (M8). |
| 11 | +- **Outside the audit, in PR 4:** `--offline` and `--locked` reach the package resolver as a value, not through a global `OnceLock`; `scripts/lib.sh` holds what `bench.sh`, `bench-compile.sh` and `stress.sh` repeated (the results table, the `//>` extraction), and `ci.sh` names its repeated `cargo run -p tilc` and sanitizer settings. |
| 12 | +- **Tests:** HTTP framing has unit and end-to-end tests of its rejecting paths (H3); every diagnostic code is asserted; the unifier and decision trees have direct tests; Perceus is verified on every debug build (M9). |
| 13 | +- **Docs:** `runtime-abi.md` is the current ABI plus its history, and every ADR section has one status, which the index lists (M10). |
| 14 | +- **Behaviour:** preserved, generated C byte-identical, except where an entry says otherwise: the bugs fixed (the module a path names in M5, a crashing native test passing `@should_panic` in L4, `random.int`'s bias in M3, N4), and diagnostics that replace crashes (H2) or silence (the language server's E0801, M5). |
| 15 | + |
| 16 | +**Left, deliberately** (each entry says why): engineering review of the `unsafe` boundary and the leak counter's inlining (M7); `tilrt/src/sched.rs` unsplit while its revisions are under review (M6); constructor tags written as numbers, now guarded by a test (M4); `tilc_core::entry`, `runnable` and `tilc_perceus::verify` returning `String` (L4); the interpreter's scheduler `request` as one `match` (M6). |
| 17 | + |
| 18 | +**Open findings** (below): N1 (`@derive(module.Trait)` does not parse), N2 (trait method bodies ignored; needs a language decision), N3 (match compilation repeats tests; needs review), N5 (the language server never reloads a package), N6 (`tilc check` skips `test/`), N7 (`tilc test` runs the dependencies' tests). Each changes behaviour, so none is in these PRs. |
| 4 | 19 | |
| 5 | 20 | Audit of `main` at `f2b02b7` (2026-10-09). It covers the compiler crates, `runtime/tilrt`, `runtime/tilcayo-ffi`, `std/`, `scripts/` and the test harnesses. Every finding was checked against the code. Two findings (H2, M5) were reproduced by running `tilc` on small programs, written outside the repository. |
| 6 | 21 | |
| @@ -105,6 +120,7 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 105 | 120 | - **End to end:** `crates/tilc/tests/cli.rs` `http_rejects_malformed_requests` (fixture `tests/fixtures/http/malformed.til`) sends conflicting and non-decimal lengths, both framings (400), `Transfer-Encoding: gzip, chunked` (501), whitespace before a colon, an invalid, an unterminated and an oversized chunk (400), and a chunk over the body limit (413), each with a request pipelined behind it. Each gets exactly one error response, the connection closes, and the pipelined request is never served; agreeing duplicate lengths are served. Nothing leaks. The 413 by `Content-Length` and by summed chunks stays in `http_body_limit_and_write_timeout`. |
| 106 | 121 | - **More broadly:** `tilrt` has 34 `#[test]`s (18 on the v1 base, 9 at the audit), and `tilrt-prims` 7. New: `int::parse`, small ints read without a heap, `utf8_error`, the hash values (pinned in `tilrt-prims` to what `tilc run` prints), and the lists and tuples `tl_string_split` and `tl_string_parse_int` build (a test actor, leak oracle). `url_decode`, `html_escape`, `split` and the rejection sampling are tested in `tilrt-prims` (PR 2). |
| 107 | 122 | - Found on the way: N4. |
| 123 | + - **Status (PR 4):** nothing left. PR 3's `http_rejects_malformed_requests` covers `std/http.til`'s 400 and 501 answers, the part of H3 in `std`. |
| 108 | 124 | |
| 109 | 125 | ### Medium |
| 110 | 126 | |
| @@ -119,7 +135,9 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 119 | 135 | - `driver.rs` moved, unchanged, to a new crate, `tilc_build`, rather than into the `tilc` binary: the native tests need it too, and a binary crate is not a library. `tilc_build` depends on `tilc_db` (for `NativeDep`) and `toml`. |
| 120 | 136 | - `Timings`, which codegen also records into, moved from `tilc_db` to `tilc_span`, the leaf every compiler crate shares. |
| 121 | 137 | - Codegen now depends on `tilc_core`, `tilc_perceus`, `tilc_span` and `tilrt-prims` only. Through `tilc_core` it still reaches `tilc_hir` and `tilc_types` (see M2). |
| 122 | | − - **Not done, deliberately:** the FNV-1a in `tilc_build` (and the one in `tilc_db/src/package/git.rs`) stay. They name cache entries and need only be stable; they are not the language's hash, and sharing four lines would tie the build to the runtime's kernels. |
| 138 | + - **Not done, deliberately:** the FNV-1a in `tilc_build` (and the one in `tilc_db/src/package/git.rs`, now `tilc_package/src/git.rs`) stay. They name cache entries and need only be stable; they are not the language's hash, and sharing four lines would tie the build to the runtime's kernels. |
| 139 | + |
| 140 | + - **Status (PR 4, done):** what was left is that `tilc_build` depended on `tilc_db`, and through it on the whole front end, for the manifest's `NativeDep`. Manifests, the lockfile, the git cache, resolution and `find_package_root` moved, unchanged, from `tilc_db` to a leaf crate, `tilc_package` (serde and toml only). `tilc_build` depends on it, `tilc_span` and `toml`; `tilc_db` loads the modules of the packages `tilc_package` resolves. No compiler crate below the driver depends on the front end without needing it. |
| 123 | 141 | |
| 124 | 142 | - [x] **M2. `tilc_core` mixes the IR, lowering and the interpreter.** Size **M**, PR **(2)**. |
| 125 | 143 | - **The paths:** `crates/tilc_core/src` holds `ir.rs` (411 lines), `lower.rs` (2,002), `interp.rs` (929) and `sched.rs` (586). |
| @@ -177,7 +195,7 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 177 | 195 | - **Not done, deliberately:** the runtime and the interpreter still write those tags as numbers. With the test, reordering a constructor fails instead of silently breaking a back end; generating the numbers would add machinery for types that do not change. Lowering still finds `std/html`'s constructors by name (`html_ctor`): lowering is where names become tags. The `ref` operations are told apart by name (`get`) within the `St` effect. |
| 178 | 196 | - **Status (PR 3, runtime part, done):** the runtime writes each tag in fewer places. `tl_string_split`, `tl_string_parse_int` and `tl_os_env` build their lists and tuples with `values::list` and `values::cell` (L2), `process::data` uses `values::cell`, and `http.rs` names `Head`'s and `Chunk`'s tags. Unit tests check the tags and fields of the values these externs return; `docs/runtime-abi.md` lists the constructors the runtime builds. |
| 179 | 197 | |
| 180 | | −- [ ] **M5. Which module a path denotes is decided in four places, and one of them is wrong.** Size **S**, PR **(4)**. |
| 198 | +- [x] **M5. Which module a path denotes is decided in four places, and one of them is wrong.** Size **S**, PR **(4)**. |
| 181 | 199 | - **The four places:** |
| 182 | 200 | - `crates/tilc/src/main.rs:142` `add_target`; |
| 183 | 201 | - `main.rs:336-354`, inside `test`; |
| @@ -188,6 +206,12 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 188 | 206 | - **The fix:** |
| 189 | 207 | - Add `Db::add_target(path) -> Result<Target, LoadError>` in `tilc_db`. It loads the package or the file, and returns the module(s) the path names, from its place under `src/` or `test/`. The driver subcommands and the LSP all use it. |
| 190 | 208 | - Make manifest errors diagnostics pointing into `tilcayo.toml`, so the CLI and the LSP both report them. |
| 209 | + - **Status (PR 4, done):** |
| 210 | + - **One decision:** `tilc_package::Target::of(path)`, with its rules in a table in `target.rs`: a directory in a package names the package; a file under `src/` or `test/` names that module of its package (which is loaded whole); any other file is a module of its own. It is not `Db::add_target`: deciding needs no database and works on paths that do not exist yet (an editor's new buffer), and the driver and the server load differently (the driver resolves with `--offline`/`--locked` and prints lockfile changes; the server never fetches nor writes). The module a file names is the one `Db::module_of_file` says it was loaded as, so the rule naming a package's modules stays in one place too. |
| 211 | + - **The driver** loads every path through `load::load`, used by `check`, and by `compile`, which `run`, `build`, `core` and `test` share. The package is resolved once per command; `build` resolved it a second time for its native dependencies (which keep absolute paths). |
| 212 | + - **The bug is fixed:** `tilc test src/util.til` runs `util`'s tests. Test: `cli.rs` `test_runs_the_module_a_file_names`. By the same rule, intended changes: `tilc run src/util.til` runs `util`'s `main` (it ran the package's); a file under `test/` loads its package and its tests (so `tilc check test/x.til` resolves its imports, and `tilc test test/x.til` runs that module's tests only, not the whole package's); a file inside a package directory but outside `src/` and `test/` is standalone for every command (`build` used to give it the package's native dependencies and name). |
| 213 | + - **The language server** opens files through `Target::of` too: a file under `test/` loads its package (it used to stand alone, so its imports failed). `Db::load_package` reports what goes wrong as a diagnostic, `E0801`, in the manifest at fault, at the entry concerned, and still loads the package's own modules. Test: `tilc_lsp/tests/server.rs` `reports_manifest_errors_and_loads_tests`. |
| 214 | + - **Not done, deliberately:** the command line prints manifest errors as before (`error: <path>: <message>`), not as rendered diagnostics. They stop the command before any checking, the message already names the file, and TOML's own errors already show the line with a caret. Found on the way: N5. |
| 191 | 215 | |
| 192 | 216 | - [x] **M6. Oversized files and functions.** Size **M**, PRs **(1)**, **(2)** and **(3)** (mechanical moves along existing section comments). |
| 193 | 217 | - `tilc_core/src/lower.rs` (2,002 lines). Its `// ----` sections are already in place, so the split is mechanical: |
| @@ -242,7 +266,7 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 242 | 266 | - **`stats::MINE` stays inline.** Out of line, it cost 12% on `tests/bench/floats.til` and 2–3% on `lists` and `dict` (interleaved runs). Disassembling the release `libtilrt.a` shows no function that both reaches a thread-local and calls something that suspends (only `sched::worker`, which runs on the scheduler thread's own stack). Nothing guarantees this across compiler versions or inlining changes; if it broke, an allocation after a migration would update another thread's count (a wrong leak-oracle total) or, if that thread never allocated, register into its thread-local slot (a data race). |
| 243 | 267 | - **For engineering review:** (a) whether relying on today's inlining for `MINE` is acceptable, or the oracle should pay the call, or count per actor through `ctx->rt` (which would make `tl_alloc` read its context, and the helpers above `unsafe`); (b) the `Fiber` argument as a whole. |
| 244 | 268 | |
| 245 | | −- [ ] **M8. The test harnesses duplicate the pipeline and the expectation format.** Size **S**, PRs **(2)** and **(4)**. |
| 269 | +- [x] **M8. The test harnesses duplicate the pipeline and the expectation format.** Size **S**, PRs **(2)** and **(4)**. |
| 246 | 270 | - **The pipeline** (analyse → errors → `lower` → `entry`) is copied 7 times: |
| 247 | 271 | - `tilc/src/main.rs:235,360`; |
| 248 | 272 | - `tilc_core/tests/run.rs:28-38` and `lowering.rs:33`; |
| @@ -255,6 +279,7 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 255 | 279 | - Remove `NOT_YET`. |
| 256 | 280 | - Document the `//>` format once, in `tests/README.md`, which the scripts point to. |
| 257 | 281 | - **Status (PR 2, done; PR 4 open):** `crates/tilc_testkit` (a dev-dependency) has `compile`, `compile_file`, `Compiled::entry`, `run_programs`, `Expectations::parse` and `build_runtime`. The interpreter, native, `#line`, never-unwinds, externs, Perceus, lowering and evidence harnesses use it; `NOT_YET` and its handling are gone. `tests/README.md` documents the format, and `scripts/stress.sh` and `bench.sh` point to it. Left for PR 4: the two copies of the pipeline in `tilc/src/main.rs`. |
| 282 | + - **Status (PR 4, done):** `tilc test` loaded, analysed and lowered by itself; it now goes through `compile`, like `run`, `build` and `core`, which returns a `Compiled` (database, analysis, Core, and what the path named). The driver does not use `tilc_testkit`: that is a dev-dependency, and the driver reports diagnostics and resolves packages, which the test kit does not. `bench.sh` and `stress.sh` share their `//>` extraction in `scripts/lib.sh`. |
| 258 | 283 | |
| 259 | 284 | - [x] **M9. Smaller test gaps.** Size **S** each, PRs **(1)** and **(2)**. |
| 260 | 285 | - **Diagnostic codes:** 6 of the 51 are never asserted by any test: `E0109`, `E0112`, `E0211`, `E0212`, `E0405` (orphan impls) and `E0411`. Add `tests/ui` cases. |
| @@ -269,7 +294,7 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 269 | 294 | - `tilc_core/tests/lowering.rs` snapshots the decision trees of or-patterns (of constructors with and without fields), nested constructors in a tuple, `Int`, `String` and `Float` literals, and list patterns with a guard and an `as` binding (see N3). |
| 270 | 295 | - `generate_units` runs `tilc_perceus::verify` after Perceus when the compiler is built with debug assertions, inside the `perceus` phase. Every native test and every debug build now checks the counts of what it compiles; release builds do not pay for it. |
| 271 | 296 | |
| 272 | | −- [ ] **M10. `runtime-abi.md`, the ADR statuses and module docs contradict themselves.** Size **M**, PR **(3)** for the runtime docs, PR **(4)** for the ADR index. |
| 297 | +- [x] **M10. `runtime-abi.md`, the ADR statuses and module docs contradict themselves.** Size **M**, PR **(3)** for the runtime docs, PR **(4)** for the ADR index. |
| 273 | 298 | - **`docs/runtime-abi.md` reads as an append-only log**, so a reader cannot tell the current ABI from the superseded ones: |
| 274 | 299 | - Revision 1 says unwinding is table-driven, with `-fexceptions` and `_Unwind_ForcedUnwind` (`:179-183`). "Unwinding (part 2)" (`:201-204`) and the code (`emit.rs:649`) use yield checks. |
| 275 | 300 | - `:217` says the threads "share one round-robin queue"; `:230` says (correctly) that each thread has a FIFO queue. |
| @@ -289,13 +314,18 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 289 | 314 | - The `sched.rs` module doc no longer describes one shared round-robin queue, and names all five revisions of ADR 0004. |
| 290 | 315 | - `tilrt.h` says which functions C bindings use (the rest is for generated code), and loses its "M0: single scheduler thread" and "opaque in ABI v0" notes. Comment changes only; PR 2 added the missing prototypes (H1). |
| 291 | 316 | - The ADRs' contradictory statuses are PR 4's; `runtime-abi.md` points at them instead of restating them. |
| 317 | + - **Status (PR 4, ADRs, done):** |
| 318 | + - Every ADR section has one status. The Revision 1 of ADRs 0001–0004 now says what their headers say: accepted with the ADR (issue #2). Sections written after that review that pointed at the closed #2, or at no issue (ADR 0004's M6 part 5 and part 6, ADR 0005's Revision 1, ADR 0010, ADR 0003's Revision 2), point at #44. |
| 319 | + - `docs/adr/README.md`: the "awaiting review" sentence, a run-on list that missed ADRs 0012 and 0014 and ADR 0005's Revision 1, is a list by ADR, matching the status lines; the table says which accepted ADRs have proposed sections. |
| 320 | + - ADR 0006 says its planned query API (`parse(file)`, `interface(module)`, `check_item(item)`) was not built. |
| 292 | 321 | |
| 293 | 322 | ### Low |
| 294 | 323 | |
| 295 | | −- [ ] **L1. Stale user-facing text.** Size **S**, PRs **(4)** and **(2)**. |
| 324 | +- [x] **L1. Stale user-facing text.** Size **S**, PRs **(4)** and **(2)**. |
| 296 | 325 | - The `tilc run --native` help says "(M5: programs without `ctl`, `final ctl` or actors)" (`tilc/src/main.rs:39-40`). Everything compiles natively now. |
| 297 | 326 | - The `tilc_lsp` crate doc (`lib.rs:3-5`) lists 6 features. The server implements 10: references, formatting, inlay hints and semantic tokens are missing from the list. |
| 298 | 327 | - **Status (PR 2):** the back end's stale milestone note is gone (`tilc_core/src/ir.rs` said C codegen was to come). The two items above are PR 4's. |
| 328 | + - **Status (PR 4, done):** the `run --native` help, the driver's crate doc ("through C, M5") and the language server's crate doc (all ten features, and how packages load) are current. Also: the help of `run`, `build` and `test` says what a path names (M5); `tilc_lsp`'s Cargo description promised hover "in later milestones"; the README called `std` "prelude so far". `docs/reference/language.md` and ADR 0020 say what M5 changed. |
| 299 | 329 | - [x] **L2. Small dead code and internal duplication.** Size **S**, PRs **(2)** and **(3)**. |
| 300 | 330 | - **Unused or redundant code:** |
| 301 | 331 | - `check_supported` has an unused `_reachable` parameter (`tilc_codegen_c/src/lib.rs:168`); |
| @@ -307,11 +337,16 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 307 | 337 | - **Status (PR 3, done):** `prims::text_of` is gone (`values::text`), the two `fn string` are one `values::string`, and `tl_string_split`, `tl_os_env` and `tl_string_parse_int` use `values::list` and `values::cell`. |
| 308 | 338 | - [x] **L3. A hand-copied ABI constant with no compile-time check.** Size **S**, PR **(2)**. `XARGS = 26` is in `emit.rs:14` ("must match"), `abi.rs:92` and `tilrt.h:119`. The Rust and C sides are asserted against each other; codegen is not. The fix: emit `_Static_assert(TL_XARGS == 26, …)` in the generated prelude. |
| 309 | 339 | - **Status (PR 2, done):** every generated C file asserts `TL_XARGS == 26` (from codegen's `XARGS`) right after the prelude. A mismatch is a C compile error. This is the one change to every generated file. |
| 310 | | −- [ ] **L4. Stringly-typed errors in crate APIs.** Size **S**, PR **(4)**. |
| 340 | +- [x] **L4. Stringly-typed errors in crate APIs.** Size **S**, PR **(4)**. |
| 311 | 341 | - `tilc_core::entry` and `runnable` (`lib.rs:27`), `manifest::{load, parse, closure}` and `tilc_perceus::verify` all return `Result<_, String>`. |
| 312 | 342 | - Native test failures are forced into `interp::RtError::Panic` (`main.rs:456-475`). |
| 313 | 343 | - Add typed errors when a second consumer appears. For manifests, do it now (M5). |
| 314 | | −- [ ] **L5. `tilc test --native` leaves `$TMPDIR/tilc-test-<pid>/` behind** (`main.rs:442-446`). `run_native` cleans up after itself (`:316`). Size **S**, PR **(4)**. |
| 344 | + - **Status (PR 4, done for manifests and tests; the rest left deliberately):** |
| 345 | + - `manifest::load` and `parse` return a `ManifestError` (the manifest's path, the byte span of the entry at fault, a message), and `tilc_package::resolve` an `Error` (`Manifest`, or `Other` for the lockfile, git and conflicting requirements). Both print what the `String` did, so the command line is unchanged (checked on broken manifests with `check`, `run`, `test` and `build`); the language server turns them into diagnostics (M5). There is no `closure` any more (resolution replaced it). |
| 346 | + - **Native test results** are no longer forced into `RtError::Panic`. Both back ends report an `Ended` (returned, panicked, failed) and one verdict decides. Fixed with it: a native test that crashed, or whose process could not start, counted as a panic, and passed `@should_panic` (whose fragment is empty without an argument). Such a failure is no longer printed with "panic: ". Test: `only_a_panic_satisfies_should_panic`. |
| 347 | + - **Not done, deliberately:** `tilc_core::entry`, `runnable` and `tilc_perceus::verify` still return `String`. Every consumer prints the message and stops; none matches on the reason, so an enum would add variants without a reader. |
| 348 | +- [x] **L5. `tilc test --native` leaves `$TMPDIR/tilc-test-<pid>/` behind** (`main.rs:442-446`). `run_native` cleans up after itself (`:316`). Size **S**, PR **(4)**. |
| 349 | + - **Status (PR 4, done):** on the v1 base both removed their directory after a successful build only; a failed build (a C compiler error, a missing runtime) left `tilc-run-<pid>` or `tilc-test-<pid>` behind. A `TempDir` guard removes it on every way out. Checked with `TILC_CC=false`: the old binary left both directories, the new one none. |
| 315 | 350 | |
| 316 | 351 | --- |
| 317 | 352 | |
| @@ -332,6 +367,16 @@ The reference interpreter duplicates the runtime's semantics on purpose: it is t |
| 332 | 367 | - **The fix:** trim only spaces and tabs (`trim_ascii` would also do), and add the case to the unit tests and to `http_rejects_malformed_requests`. Left as is because it rejects requests that are served today. |
| 333 | 368 | - **Status: fixed** right after the runtime PR, as its own commit: `decimal_length` trims only spaces and tabs, and the unit test covers a no-break space (and checks that httparse already rejects a form feed or a vertical tab). A deliberate behaviour change: such requests now get 400. |
| 334 | 369 | |
| 370 | +- [ ] **N5. The language server loads a package once.** Size **S**, needs a small design (file watching). |
| 371 | + - It loads a package, its tests and its dependencies when the first of its files is opened, and never again. Editing `tilcayo.toml`, adding or deleting a module on disk, or fetching a missing dependency with a command-line build takes effect only after a restart; until then, a fixed manifest's `E0801` stays published. (A new, unsaved `src/lib.til` is also named `lib`, not after the package, until then.) |
| 372 | + - **The fix:** register for `workspace/didChangeWatchedFiles` on `tilcayo.toml`, `tilcayo.lock` and `*.til`, and rebuild the package's part of the `Db` when one changes. Not done here: it is a feature, not a cleanup. |
| 373 | +- [ ] **N6. `tilc check` does not check a package's `test/`.** Size **S**, PR: a behaviour change. |
| 374 | + - `tilc check` loads `src/` only, so a test module with a type error passes `check` and fails `tilc test` (reproduced: `pub fn broken() -> Int { "no" }` under `test/`). The language server, since M5, does check `test/`, as ADR 0001's Revision 1 says ("Test functions are type-checked with everything else, so the LSP sees them"). |
| 375 | + - **The fix:** load the tests in `check` (`load(…, tests: true, …)`). Left as is because it reports errors in programs that `check` accepts today. |
| 376 | +- [ ] **N7. `tilc test` runs the dependencies' inline tests too.** Size **S**, PR: a behaviour change, needs a decision. |
| 377 | + - For a package directory it runs the tests of every module outside `std`, which includes its dependencies' modules (reproduced: a path dependency's `@test` in its `src/lib.til` runs with the package's). No package in the repository has inline tests in a dependency, so nothing shows it today. |
| 378 | + - **The fix:** run the tests of the root package's modules only (those `Db::load_resolved` names without a dependency prefix), and decide whether a flag runs the dependencies'. Left as is: it changes which tests run. |
| 379 | + |
| 335 | 380 | ## Deliberate choices, not defects |
| 336 | 381 | |
| 337 | 382 | - **The reference interpreter and its scheduler** (`tilc_interp`; `tilc_core/src/interp.rs` and `sched.rs` when audited) re-implement what `tilrt` does. They are the oracle: `tilc_codegen_c/tests/native.rs` runs every `tests/run` program natively with `TILC_THREADS=1`, and requires the same `//>` output and zero live blocks. Keep them. Share only the pure leaf helpers (M3). |