Skip to content

Fixtures the D71 sweep and the §18.1 fallout did not reach: 48 xs[i] sites, 189 explicit std imports (#1239, #1955) - #1970

Merged
ehartford merged 2 commits into
fix-gen-dir-guardfrom
fix-latent-sites
Oct 2, 2026
Merged

ehartford merged 2 commits into
fix-gen-dir-guardfrom
fix-latent-sites

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Layer 7 of stack #1969: the latent sites the batch's fixture sweep found that the battery did not exercise. (a) 48 Vec.get sites in 24 files rewritten to xs[i] by tools/migrate_vec_get.w to a fixpoint; the two fixtures whose subject IS get untouched; three hand edits stated in the commit. (b) 189 use lines across 172 roots (mostly test/d_acceptance) by tools/insert_std_uses.w to a fixpoint; four compile_errors fixtures lose an unrelated second error and keep their pinned one. Re-sweep of 4,417 roots with the fresh stage1: zero has no 'get' and zero requires an explicit import outside the five subject fixtures. Gate green.

Spec note (no change made): §18.2 tier 5 makes bare std names legal with no use; the compiler is non-compliant in the strict direction (D29 import-gate scaffolding, #750/#752), and the std-tier walk-through in module_visible_no_prelude is neither tier 3 nor tier 5 — an implementation leftover of the class #1955 closed for user modules. The explicit imports are correct under either state.

Eric Hartford added 2 commits October 2, 2026 15:14
…1239)

A stage1 `check` over every With root under test/, examples/, tools/, uat/
and lib/std found 24 fixtures (compile_errors and the parked d_acceptance
corpus) still calling Vec.get; the battery never compiled them because
their expected error, or a missing-import error, fired first. Sites were
selected by the compiler's own "Vec has no 'get'" diagnostic and rewritten
with tools/migrate_vec_get.w, looped to a fixpoint.

Every compile_errors fixture still raises the error its header pins; the
two whose subject IS the retired `get` (err_issue64_*_vec_get_bad_index_type)
are untouched. behav_branch_temp_drop_not_taken_path.w's clone helper reads
an element view, so it pushes `v[i].clone()` (D27: element access
observes). Two legacy `i as i64` index casts are dropped where the index is
already i32.
The same sweep found 172 roots (166 in test/d_acceptance, behav_box_drop,
behav_pointer_view_null and four compile_errors fixtures) that resolved
HashMap, print_i32, int_to_string, Task, Box and friends only through the
std-tier import walk — a `use std.process` reaching std.collections for
them. Each now carries the exact `use` line the compiler's "requires an
explicit import (§18.1); add: use …" diagnostic names, inserted by
tools/insert_std_uses.w --apply looped to a fixpoint. The four
compile_errors fixtures lose a second, unrelated error and keep the one
their header pins; the three fixtures whose subject is the import gate
itself (err_1362_*, err_1955_*) are untouched.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on stack top 7bdd704 (seed-driven, with run tools/battery.w, stack #1972 = #1966 → #1956 → #1961 → #1968 → #1959 → #1971 → #1970, on main 30f89aa): gate rc=0 wall=489s, battery-checks rc=0 wall=379s — fixpoint, drop and move audits, every corpus. Earlier reds on this stack were (a) #1239/#1955 fallout in fixtures the sweeps did not compile, fixed in-layer and in #1970, and (b) a stage2≠stage3 'self-miscompile' that turned out to be cross-worktree contamination through a shared out/gen symlink, root-caused with lldb and guarded in #1971; the bisect-reverted commit was innocent and is restored. Run from a worktree with its own out/gen.

@ehartford
ehartford marked this pull request as ready for review October 2, 2026 22:30
@ehartford
ehartford merged commit 3a419cd into main Oct 2, 2026
ehartford pushed a commit that referenced this pull request Oct 3, 2026
…lve it (`:d-acceptance-tests`), import-free as D29 keeps it; the debug-alloc lane checks expect-stdout exactly (#1865)

test/d_acceptance (D29, #750): the import-free originals of the behavior
tests the §18.1 scaffolding gave explicit `use` lines, forked "not
overwriting" into a suite quarantined until D activation (#752)
un-quarantines it as the activation test. No lane compiled it, so it rotted
silently, and #1970 then inserted 183 explicit std imports into 166 of its
files (a mechanical §18.1 sweep that did not know the corpus's purpose),
which would make the activation test vacuous.

- The 183 `use` lines #1970 inserted are removed (exactly those lines; the
  eight files whose originals carried a `use std.` keep it). #1970's D71
  `xs[i]` respellings stay: a ruling moved that spelling.
- Respellings later rulings gave the behavior originals, mirrored into the
  forks: D32 field moves (behav_drop_tuple_field_extract,
  behav_mut_self_vec_owner_receiver: explicit `move` from a `var` base;
  behav_rc_arc_basic: `.clone()`), §4.2.6 narrowing (duck_method_ok:
  `-> i64`). Each now equals its behavior original minus imports.
- Deleted: behav_byvalue_view_escape_{nested,tail}. They pin the retired
  D5 share-place reading (a consuming T as the caller's place, escaping
  views valid); 2fdfbb9 (#718) turned their behavior originals into the
  negative fixtures err_consuming_param_{,nested_}view_escape.w.
- `:d-acceptance-tests` (in `:test`; build/acceptance.w): a copy under
  out/d-acceptance/corpus gains exactly the `use` lines the compiler's
  unique-match fix-it names, applied by tools/insert_std_uses.w (the tool
  the scaffolding used) to a fixpoint, and every file then runs under the
  exact-stdout runner. The tree's corpus stays import-free; at activation
  the fix-it step goes.

Census before (installed compiler, `check` per file): 14 of 181 red — 4
needing only `write`'s import (the fix-it's job), 3 D32, 2 retired D5,
1 §4.2.6, 4 issue59/61 fixtures whose helper modules live in
test/behavior/lib (the lane copies it beside the corpus).

tools/debug_drop.w `check` now also compares the program's stdout, from
the run under the debug allocator, with the fixture's `//! expect-stdout:`
lines: every line, in order, once each (#1855's runner rule). Failing
first: with one expected line changed, and with one dropped, the old
tool passes both (`debug-alloc lane: ok`); the new one fails each naming
the first difference. All 145 fixtures pass it. The tool also drops the
internal with_exec_*/with_fs_* externs (#901) for std.process
run_to_files and std.fs; its per-process capture paths are #2004's (PR #2005).

The lane's first run then named 11 more forks #1855 (c4a2863) had left
stale: it rewrote their behavior originals' expectation headers for the
exact-stdout rule (`expect-run-output:` -> `expect-stdout:` lines, subset
lists completed, a stray "\n" that printed a blank line dropped), and the
forks still pinned the old text. Each is re-derived as its behavior
original minus the scaffolding's `use` lines (a `use` the fork carried is
kept). `:d-acceptance-tests`: 179 files ok.
ehartford pushed a commit that referenced this pull request Oct 3, 2026
…lve it (`:d-acceptance-tests`), import-free as D29 keeps it; the debug-alloc lane checks expect-stdout exactly (#1865)

test/d_acceptance (D29, #750): the import-free originals of the behavior
tests the §18.1 scaffolding gave explicit `use` lines, forked "not
overwriting" into a suite quarantined until D activation (#752)
un-quarantines it as the activation test. No lane compiled it, so it rotted
silently, and #1970 then inserted 183 explicit std imports into 166 of its
files (a mechanical §18.1 sweep that did not know the corpus's purpose),
which would make the activation test vacuous.

- The 183 `use` lines #1970 inserted are removed (exactly those lines; the
  eight files whose originals carried a `use std.` keep it). #1970's D71
  `xs[i]` respellings stay: a ruling moved that spelling.
- Respellings later rulings gave the behavior originals, mirrored into the
  forks: D32 field moves (behav_drop_tuple_field_extract,
  behav_mut_self_vec_owner_receiver: explicit `move` from a `var` base;
  behav_rc_arc_basic: `.clone()`), §4.2.6 narrowing (duck_method_ok:
  `-> i64`). Each now equals its behavior original minus imports.
- Deleted: behav_byvalue_view_escape_{nested,tail}. They pin the retired
  D5 share-place reading (a consuming T as the caller's place, escaping
  views valid); 2fdfbb9 (#718) turned their behavior originals into the
  negative fixtures err_consuming_param_{,nested_}view_escape.w.
- `:d-acceptance-tests` (in `:test`; build/acceptance.w): a copy under
  out/d-acceptance/corpus gains exactly the `use` lines the compiler's
  unique-match fix-it names, applied by tools/insert_std_uses.w (the tool
  the scaffolding used) to a fixpoint, and every file then runs under the
  exact-stdout runner. The tree's corpus stays import-free; at activation
  the fix-it step goes.

Census before (installed compiler, `check` per file): 14 of 181 red — 4
needing only `write`'s import (the fix-it's job), 3 D32, 2 retired D5,
1 §4.2.6, 4 issue59/61 fixtures whose helper modules live in
test/behavior/lib (the lane copies it beside the corpus).

tools/debug_drop.w `check` now also compares the program's stdout, from
the run under the debug allocator, with the fixture's `//! expect-stdout:`
lines: every line, in order, once each (#1855's runner rule). Failing
first: with one expected line changed, and with one dropped, the old
tool passes both (`debug-alloc lane: ok`); the new one fails each naming
the first difference. All 145 fixtures pass it. The tool also drops the
internal with_exec_*/with_fs_* externs (#901) for std.process
run_to_files and std.fs; its per-process capture paths are #2004's (PR #2005).

The lane's first run then named 11 more forks #1855 (c4a2863) had left
stale: it rewrote their behavior originals' expectation headers for the
exact-stdout rule (`expect-run-output:` -> `expect-stdout:` lines, subset
lists completed, a stray "\n" that printed a blank line dropped), and the
forks still pinned the old text. Each is re-derived as its behavior
original minus the scaffolding's `use` lines (a `use` the fork carried is
kept). `:d-acceptance-tests`: 179 files ok.
ehartford pushed a commit that referenced this pull request Oct 3, 2026
…lve it (`:d-acceptance-tests`), import-free as D29 keeps it; the debug-alloc lane checks expect-stdout exactly (#1865)

test/d_acceptance (D29, #750): the import-free originals of the behavior
tests the §18.1 scaffolding gave explicit `use` lines, forked "not
overwriting" into a suite quarantined until D activation (#752)
un-quarantines it as the activation test. No lane compiled it, so it rotted
silently, and #1970 then inserted 183 explicit std imports into 166 of its
files (a mechanical §18.1 sweep that did not know the corpus's purpose),
which would make the activation test vacuous.

- The 183 `use` lines #1970 inserted are removed (exactly those lines; the
  eight files whose originals carried a `use std.` keep it). #1970's D71
  `xs[i]` respellings stay: a ruling moved that spelling.
- Respellings later rulings gave the behavior originals, mirrored into the
  forks: D32 field moves (behav_drop_tuple_field_extract,
  behav_mut_self_vec_owner_receiver: explicit `move` from a `var` base;
  behav_rc_arc_basic: `.clone()`), §4.2.6 narrowing (duck_method_ok:
  `-> i64`). Each now equals its behavior original minus imports.
- Deleted: behav_byvalue_view_escape_{nested,tail}. They pin the retired
  D5 share-place reading (a consuming T as the caller's place, escaping
  views valid); 2fdfbb9 (#718) turned their behavior originals into the
  negative fixtures err_consuming_param_{,nested_}view_escape.w.
- `:d-acceptance-tests` (in `:test`; build/acceptance.w): a copy under
  out/d-acceptance/corpus gains exactly the `use` lines the compiler's
  unique-match fix-it names, applied by tools/insert_std_uses.w (the tool
  the scaffolding used) to a fixpoint, and every file then runs under the
  exact-stdout runner. The tree's corpus stays import-free; at activation
  the fix-it step goes.

Census before (installed compiler, `check` per file): 14 of 181 red — 4
needing only `write`'s import (the fix-it's job), 3 D32, 2 retired D5,
1 §4.2.6, 4 issue59/61 fixtures whose helper modules live in
test/behavior/lib (the lane copies it beside the corpus).

tools/debug_drop.w `check` now also compares the program's stdout, from
the run under the debug allocator, with the fixture's `//! expect-stdout:`
lines: every line, in order, once each (#1855's runner rule). Failing
first: with one expected line changed, and with one dropped, the old
tool passes both (`debug-alloc lane: ok`); the new one fails each naming
the first difference. All 145 fixtures pass it. The tool also drops the
internal with_exec_*/with_fs_* externs (#901) for std.process
run_to_files and std.fs; its per-process capture paths are #2004's (PR #2005).

The lane's first run then named 11 more forks #1855 (c4a2863) had left
stale: it rewrote their behavior originals' expectation headers for the
exact-stdout rule (`expect-run-output:` -> `expect-stdout:` lines, subset
lists completed, a stray "\n" that printed a blank line dropped), and the
forks still pinned the old text. Each is re-derived as its behavior
original minus the scaffolding's `use` lines (a `use` the fork carried is
kept). `:d-acceptance-tests`: 179 files ok.
ehartford added a commit that referenced this pull request Oct 3, 2026
…ty (#1899 #1906 #1905 #1865 #1835 #1888 #1900 #1998 #2000) (#2008)

* Build: a machine-wide build store under ~/.local/with-build-cache serves compiler-producing actions across worktrees (#1899)

A green belongs to the sources, not to the worktree (D49/D50); so does a
built artifact. Once an action that names its compiler (stage compiles,
runtime and bridge objects, .wo bundles, producer stamps) has run, its
declared outputs, state record and effect log are published under
$WITH_BUILD_CACHE_DIR (default ~/.local/with-build-cache; "none"
disables it), keyed on the local signature (the producing seed or stage
compiler, the action code, the compiler sources, with.toml), the content
of every declared input, the compiler= binary's identity and the driver's
own digest, so nothing is served across seeds or drivers. A worktree whose
freshness check misses restores the entry into its own out/ and
re-verifies it with the same check: a hit is exactly a fresh target, or
it is discarded and the target runs. The store keeps the 96
least-recently-used entries (WITH_BUILD_CACHE_KEEP).

What made a key worktree-specific, each found by a second worktree that
missed: directory fingerprints and the compiler-source hash named files
absolutely, and so did the action-code hash (the module closure's paths),
now all root-relative; records and effect logs are stored with <root> and
the restore re-pins the record's effects hash to the localized log; and
stage1 declared the seed-built out/bin/with-sha256 binary as an input,
whose bytes differ per worktree (its debug map names the worktree in
N_SO/N_OSO, so LC_UUID and the code signature differ) — stage1 now keys
on tools/with-sha256.w, what that binary is made from (the dep still
orders the build).

Proof (two fresh worktrees on one commit, a stage1 of this tree driving,
one store): the second `:dev` restored 25 entries, stage1 included, none
failed verification; with one byte changed in src/Lexer.w, stage1 was not
restored and rebuilt. Not yet seconds: 39 targets outside the store's
scope still run per worktree (SDK and sysroot packing, the empty
placeholder objects), and the pinned seed carries none of this until the
next seed, so seed-driven batteries see it then. The test verdicts and
build runners were already machine-wide (#1909, #1929).

* Build: the action runner links against a runtime root the driver names, of the driver's own generation (#1906)

Cause: the scheduler compiled the runner as soon as
prepare-bootstrap-link-root had completed in the run, executed or fresh,
and linked it under WITH_OUT_DIR, so the link probed out/lib first. The
prepare's freshness says nothing about out/lib: the stage chain re-creates
it (tree generation) after the prepare last ran, and a seed whose Link.w
lacked the per-candidate generation check (nightly-20260927, before
030293c) linked the tree's runtime into its runner: rt_compat_setenv_str
read an address as a length.

Reproduced on the pinned seed (c95ae12, which carries 030293c) in a
fresh worktree: out/lib a stage1 runtime set (.producer 91b9f004...),
out/bootstrap-lib the seed's (22a6c48c...), prepare fresh, runner store
empty: the runner compiled and ran. That seed's link skips the foreign
candidate, so the crash does not recur under it; the safety lived only in
the link's probe, and the driver still decided on the prepare's
freshness. The tool that should have refused stayed silent.

Fix: build_runner_link_root picks the first complete runtime directory of
the driver's generation (out/bootstrap-lib for the seed, out/lib for a
tree compiler) and the runner compile names it as WITH_RUNTIME_ROOT,
which Link.w refuses outright when its .producer is another generation
and never trades for a probed directory. The runner is compiled when such
a root exists, or when the prepare is done and the project has no runtime
directory at all (it links from the embedded runtime, as before); a
project whose only runtime is foreign says so instead of linking.

* Build: `--no-deps` runs an action in the native runner when a link root of the driver's generation exists, and refuses naming the dep when none does (#1835)

Cause: with --no-deps, prepare-bootstrap-link-root is not in the graph,
so the scheduler fell back to "no runtime directory belongs to another
generation". After a full build out/lib is the tree's generation, so
under the pinned seed that was false, the runner was never compiled, and
the action evaluated in the seed's comptime evaluator, which predates
7aed70f (generic calls without type arguments read Sema's
specialization) and failed after the smoke itself passed.

Failing first, pinned seed, fresh worktree, out/lib foreign, out/bootstrap-lib
the seed's own (.producer 22a6c48c...): `:embedded-clang-resource-source`
linked the runner and ran in 0.1 s; the same target with --no-deps
compiled no runner and ran 25.8 s in the comptime evaluator.

Fix: the runner decision is build_runner_link_root's (#1906): --no-deps
uses the seed's out/bootstrap-lib like any other run. When no root of the
driver's generation exists, --no-deps refuses, naming
prepare-bootstrap-link-root as the dependency it skipped, instead of
silently changing evaluators; a full run says once that actions evaluate
at comptime until the prepare builds the root.

* deps/seed: release discovery searches every page and says why it found nothing (#1888)

Cause: seed_release_from_api read one page of
`/releases?per_page=10` and returned "" for a miss. Every nightly
seed and SDK publish adds a release on top, so a platform's newest SDK
falls off that page within days: when #1888 was filed the darwin-aarch64
SDK (nightly-sdk-20260928-3ae5c9ec0b31) sat under more than ten newer
releases; today it is 9th, and the windows-aarch64 SDK is 17th, so
unpinned `:deps` on that host fails now. The miss said nothing about
whether the request failed, the response was malformed, or no release
carried the asset, and the response file was deleted.

Fix: the lookup walks the pages (100 releases each, at most 10 pages),
newest first, and reads the body as one text (each release's assets
follow its tag_name; an asset matches only as an exact quoted name, so
the .sha256 sidecar and a release body never do). It returns the tag or
the reason, keeps each response at out/tmp/seed-download/releases-<n>.json,
and both callers' errors name that reason.

Evidence (the real function through a temporary probe target, pinned
seed, reverted): windows-aarch64 -> nightly-20260907-34132069721-1-8a729db8d01f
(17th, beyond the old page); darwin-aarch64 -> nightly-sdk-20260928-3ae5c9ec0b31;
an absent asset -> "none of the 89 newest releases of withlang-dev/with
carries it (responses kept under out/tmp/seed-download)".

* test: the D acceptance corpus runs as the std fallback tier will resolve it (`:d-acceptance-tests`), import-free as D29 keeps it; the debug-alloc lane checks expect-stdout exactly (#1865)

test/d_acceptance (D29, #750): the import-free originals of the behavior
tests the §18.1 scaffolding gave explicit `use` lines, forked "not
overwriting" into a suite quarantined until D activation (#752)
un-quarantines it as the activation test. No lane compiled it, so it rotted
silently, and #1970 then inserted 183 explicit std imports into 166 of its
files (a mechanical §18.1 sweep that did not know the corpus's purpose),
which would make the activation test vacuous.

- The 183 `use` lines #1970 inserted are removed (exactly those lines; the
  eight files whose originals carried a `use std.` keep it). #1970's D71
  `xs[i]` respellings stay: a ruling moved that spelling.
- Respellings later rulings gave the behavior originals, mirrored into the
  forks: D32 field moves (behav_drop_tuple_field_extract,
  behav_mut_self_vec_owner_receiver: explicit `move` from a `var` base;
  behav_rc_arc_basic: `.clone()`), §4.2.6 narrowing (duck_method_ok:
  `-> i64`). Each now equals its behavior original minus imports.
- Deleted: behav_byvalue_view_escape_{nested,tail}. They pin the retired
  D5 share-place reading (a consuming T as the caller's place, escaping
  views valid); 2fdfbb9 (#718) turned their behavior originals into the
  negative fixtures err_consuming_param_{,nested_}view_escape.w.
- `:d-acceptance-tests` (in `:test`; build/acceptance.w): a copy under
  out/d-acceptance/corpus gains exactly the `use` lines the compiler's
  unique-match fix-it names, applied by tools/insert_std_uses.w (the tool
  the scaffolding used) to a fixpoint, and every file then runs under the
  exact-stdout runner. The tree's corpus stays import-free; at activation
  the fix-it step goes.

Census before (installed compiler, `check` per file): 14 of 181 red — 4
needing only `write`'s import (the fix-it's job), 3 D32, 2 retired D5,
1 §4.2.6, 4 issue59/61 fixtures whose helper modules live in
test/behavior/lib (the lane copies it beside the corpus).

tools/debug_drop.w `check` now also compares the program's stdout, from
the run under the debug allocator, with the fixture's `//! expect-stdout:`
lines: every line, in order, once each (#1855's runner rule). Failing
first: with one expected line changed, and with one dropped, the old
tool passes both (`debug-alloc lane: ok`); the new one fails each naming
the first difference. All 145 fixtures pass it. The tool also drops the
internal with_exec_*/with_fs_* externs (#901) for std.process
run_to_files and std.fs; its per-process capture paths are #2004's (PR #2005).

The lane's first run then named 11 more forks #1855 (c4a2863) had left
stale: it rewrote their behavior originals' expectation headers for the
exact-stdout rule (`expect-run-output:` -> `expect-stdout:` lines, subset
lists completed, a stray "\n" that printed a blank line dropped), and the
forks still pinned the old text. Each is re-derived as its behavior
original minus the scaffolding's `use` lines (a `use` the fork carried is
kept). `:d-acceptance-tests`: 179 files ok.

* Corpora are their migrator's output again, and `:corpus-drift-check` (in the gate) fails when they are not (#1905)

Cause: the checked-in corpora are generated (build/corpora.w: promotion
copies the migration; never hand-edited), but nothing compared them with
what this tree's migrator produces: the battery compiles the checked-in
output, and `<stem>-check-generated` runs only on a deliberate
re-migration. Two migrator changes landed without a re-promotion and the
drift was silent:
- D75 (173d8aa): a variadic definition spells `va_start()`; pcre2test.w
  and zl/gzwrite.w still called the retired with_va_start/with_va_end.
- #1933 (bfa0201): the migrator's own helpers take `__with_`-prefixed
  parameters, so a C global named `c` no longer makes them a refused
  shadow; every corpus's defs.w still had `c`.
(c_algorithms/binary_heap.w no longer differs.)

`<stem>-drift-check` (one per corpus, grouped as `corpus-drift-check` and
added to the gate's fixed list) runs the corpus's own stage, migrate and
finish hooks and writes its bundle root into a scratch tree — the migrate
action's steps, now shared as corpus_generate — with this tree's release
compiler as the migrator: an action carrying `migrator=<path>` runs
`<path> migrate` with exactly the workspace's option set
(corpus_migrate_argv), so the CLI and the workspace call
migrate_c_directory over the same settings. It then compares every
module byte for byte and fails naming each one that differs, is missing
or is extra, with the re-promotion command.

Failing first (`src/main build :corpus-drift-check` before the
re-promotion): pcre2 2 modules (defs.w, pcre2test.w), zlib 2 (defs.w,
gzwrite.w), c_algorithms 1 (defs.w), tommyds 1 (defs.w). Every hunk was
read: all are the two rules above, none changes behavior.

Re-promoted from the migrator's fresh output (exactly the six modules;
every corpus keeps its module count). After: corpus-drift-check green
("pcre2: 35 modules are the migrator's output", zlib 22, c_algorithms
24, tommyds 16); wo-drift, pcre2-wo-test, c-algorithms-test and
tommyds-test green over the re-promoted corpora.

* with get: a source build gets a CMake package config for every requirement, written from its recorded metadata as Conan's CMakeDeps would (#1900)

Cause: conan_install_from_source passes the installed requirements to
CMake only through CMAKE_PREFIX_PATH. A Conan Center binary package
carries no `<name>Config.cmake` (glfw/3.4's lib/cmake holds only
conan-official-glfw-targets.cmake): Conan's CMakeDeps generator writes it
at install time, and `with get` did not. So raylib/6.0, configured with
USE_EXTERNAL_GLFW=ON, failed at find_package(glfw3 3.4) whenever raylib
built from source while glfw came as a binary; every recipe that finds a
requirement by find_package(<Config>) has the same failure. (Under
`--from-source` the requirement is itself built from source and installs
its own config, which is why that path worked.)

Failing first (installed `with`, macOS arm64, fresh spiral project):
`WITH_GET_CMAKE_RAYLIB=SUPPORT_MODULE_RAUDIO=ON with get c.raylib` ->
glfw binary 71dfbca4fd16, then "Could not find a package configuration
file provided by "glfw3" (requested version 3.4)", rc 1.

Fix: for each resolved requirement without a config of its own,
`<file>Config.cmake` declares the recipe's target (cmake_file_name /
cmake_target_name read from the requirement's recipe, else CMakeDeps'
defaults: the package name, <name>::<name>) as an INTERFACE IMPORTED
target over the libraries, include directories, defines and link options
recorded in metadata.json, its requirements folded in; two-token Apple
flags stay one SHELL: option. `<file>ConfigVersion.cmake` answers the
version request (SameMajorVersion, CMakeDeps' default; a non-numeric
version such as "system" answers none). CMake finds it by -D<file>_DIR.
One metadata reader: ProjectConfig's, now public. No per-package table.

After (stage1 of this tree, same command): "-- Using external GLFW",
raylib/6.0 configures, builds and installs libraylib.a against the glfw
binary; the bundled rglfw is not compiled.

* stdlib-complexity times CPU, not the wall: std.libc cpu_time_ns over a with_libc seam, one body per backend; a quadratic control keeps the 6x bound honest (#1998)

Cause: test/complexity/stdlib.w timed each row with now_ns(), wall time.
On a loaded machine contention reads as super-linear growth, so a linear
row failed its 6x bound (#1998: trie 6.4x at load 36) and blocked a
battery for reasons unrelated to the change.

Failing first (the pre-change harness, ambient load ~50 from other
builds): 3 of 5 runs red, two on linear rows far outside the bound —
binary-heap 23x (0.43 ms -> 10.1 ms), trie 12x.

Fix: the harness times CPU — user + system of this process and of every
child it has reaped, so the stdin rows (whose work is a child process)
still count their work and nothing else on the machine does.
- std.libc cpu_time_ns(): a With function over the with_libc_cpu_time_ns
  seam in rt/rt_core.w (the category std.libc's rule names; POSIX
  getrusage itself may not be exported, and C's clock() leaves children
  out and on the UCRT counts wall time). rt_cpu_time_ns, one body per
  backend: getrusage(RUSAGE_SELF) + getrusage(RUSAGE_CHILDREN) on darwin
  and linux (each with its timeval layout); GetProcessTimes on Windows,
  each child's kernel + user time summed at every reap site as
  RUSAGE_CHILDREN does (GetProcessTimes gets its win32 facade row); 0 on
  wasm, which the harness's positive-duration assertion refuses.
- The harness declares the seam itself for now: importing std.libc into
  this file trips a Sema internal error in std/collections/sorted_vec.w
  (#2000, filed with the repro); it switches to `use std.libc.cpu_time_ns`
  when that is fixed.
- The 6x bound is kept. A `quadratic-control` row (each step scans all
  prior pushes) must miss it, or the run fails: the clock still sees
  super-linear growth on every run, not only in this commit's evidence.

After: `:stdlib-complexity` green; under 36 CPU hogs (load 49-60) the
harness passed 5 of 5 runs, every linear row inside the bound
(binary-heap ~4.6x, trie ~4x), the five XFAIL rows unchanged, and
quadratic-control outside it every time (16.5x in the lane run).
Every backend type-checks (`with check --no-prelude rt/<backend>.w`);
only darwin is run here.

* Sema: a generic instance is found by identity, never by the memo's absence; a comptime evaluation no longer duplicates Option[V] (#2000)

Cause (lldb + WITH_TRACE_INST on the reduced harness): the first check of
SortedVec[i32].index_of joined its `if` at Option[i32] (tid 1079). A
comptime evaluation (a `[x; N]` count; std.libc's import was only what
put one in the harness's order) runs on prepare_comptime_eval_copy, which
empties generic_inst_cache and writes the Sema back. preregister_mir_types
then read the memo's absence as "no Option[V] for HashMap[i32, i32] yet"
(Sema.w, `if not self.generic_inst_cache.contains(opt_key)`) and added a
second Option[i32] (tid 2225) under the same key. The re-check before MIR
lowering resolved `Option[i32]` through the memo to 2225 and met the
decision recorded at 1079: "conflicting contextual join decisions for one
expression". The same raw-memo read sat in SemaCheck's index-expression
instance lookup and MirLower.resolve_index_generic_inst, which also
trusted a bare hash hit as a type.

Fix: instance identity has one owner, find_generic_inst_type /
ensure_generic_inst_type (verify the memo hit, else scan); every
VecIter[T] / Option[V] / Vec[str] / VecIter[str] preregistration, the
index-expression lookup and the MirLower lookup go through it. The
internal error now names both decisions (sig, expected and final types
with their ids), so the next one says which types disagree.

Failing first: test/behavior/behav_2000_generic_inst_identity_after_comptime_eval.w
(a generic method joining at Option[i32], a `[0; 4]`, a HashMap[i32, i32])
reported the internal error on the unfixed stage1; it passes now, as do
the reduced harness and test/complexity/stdlib.w, which drops its #1998
workaround and imports std.libc.cpu_time_ns (harness run: all rows pass,
quadratic control outside the bound, rc 0).

* Build: the build store serves every cacheable target whose outputs are the same in every worktree; a second worktree's :dev is 9.7s, not 269s (#1899)

c558ec8 restored the 25 actions that name a compiler; a second worktree on
the same commit still ran 39 targets (268.7s :dev, release driver). Measured
in two fresh worktrees on one commit (driver = WITH = this tree's release
binary, as the next seed will be), what re-ran and why:

- Every runner action in a fresh worktree fell back to comptime evaluation
  (3.4s per empty placeholder, 38s compiler-no-c-export): the driver named
  out/bootstrap-lib as the runner's root because its rt_core.o matched the
  embedded one byte for byte, before bootstrap-runtime-producer had written
  its .producer, and Link.w then refused that named root for lacking one.
  One question, two answers: build_runner_link_root now asks the link's own
  test for a named root (link_stage_named_runtime_root_is_this_generation),
  and a runner already built for the key, here or in the machine-wide
  runner store, is used without any root (it links nothing).
- The store took only actions naming `compiler=`. It now takes every
  cacheable target (the local freshness contract: compiles, actions,
  generated sources, packs, placeholder objects) whose outputs and write
  scopes lie under out/, minus the always-run targets. The key hashes the
  signature with the worktree's root spelled <root> (an `llvm-prefix=<root>/
  .deps/...` arg is one argument everywhere); a restore re-pins the record's
  sig lines to this worktree's spelling, then verifies as before.
- An output that names its worktree is never stored, and the build says so
  ("[cache] X: not stored: ... names this worktree"): publishing it would
  hand another worktree this one's paths.
- darwin-sysroot depended on sysroot-zig-source, which extracts 279MB into
  .deps/src (outside out/, so no restore brings it) on every fresh worktree.
  It now fetches the pinned Zig source and libc++ ABI list into its own
  scratch and declares the tree every darwin link reads
  (out/gen/darwin-sysroot) as an output; pack and tree are byte-identical
  to the .deps-built ones.
- An embed target's assembly named its blobs by absolute path; it names
  them from the root (`.incbin "out/bootstrap-lib/rt_core.o"`) and the
  assembler reads a copy whose operands are resolved against the root.
- A restore forgets only the restored outputs' fingerprints, not the memo
  (src/ was re-hashed per stage-target restore).
- The store keeps 512 entries (a :dev publishes ~60, mostly small).

Numbers (same commit, fresh worktrees A then B, one store):
  before: A 342.2s, B 268.7s (39 ran), no-op 1.6s
  after:  A 334.5s, B 9.7s (59 restored, 4 ran), no-op 1.8s
B's 9.7s: ~4s evaluating build.w in a worktree with no graph cache (a
cached-graph run with every output deleted is 5.6s), ~1s hashing ~250MB of
restored outputs to verify them, the rest the four targets below.
Changed input (C: B's commit + one line in src/Lexer.w): 63.1s; ran stage1,
compiler-no-c-export and the two runtime-producer stamps (the targets whose
signature covers src/), restored the other 55.

Not storable, each named by the build when it runs:
- bootstrap-/stage1-llvm-link-metadata: llvm_link.rsp is an lld response
  file listing the SDK archives by absolute path (0.0s each; nothing stored
  keys on it);
- with-sha256: an Executable the driver compiles in-process, whose debug
  map names the worktree (no file-prefix map outside the stage actions);
- sdk-clang-main: adds clang's driver archive to the SDK in .deps, outside
  out/ (0.0s when present).

Failing first: test/behavior/behav_1899_build_store_serves_any_target.w
(an action naming no compiler is served to a second root; a changed input
misses; a root-naming output is not stored; a rooted arg is portable; an
embed's assembly carries no root) fails on the previous tree at the first
restore, passes now.

* Corpora: re-promote pcre2, zlib, c_algorithms and tommyds from this tree's migrator (#1905)

The drift check this stack adds found all four checked-in corpora stale
against the migrator on main: #1838 stopped emitting `-> Unit` on void C
functions and lowers a pure `(void)x` discard to nothing, and the D39
write contracts now print each function's `writes` clause. Nothing
re-promoted after those landed. Regenerated with
`WITH=out/release/bin/with out/release/bin/with build :<stem>-promote`,
each gated on the corpus's own tests (all four rc=0).

* Build: --no-deps refuses for a missing runner root only when it skipped the prepare that builds it (#1835)

The selfhost case build-w-evaluator-seed (`build :seed --no-deps` over a
foreign-generation out/lib) failed in the battery on c78e242 with
"--no-deps: ... `prepare-bootstrap-link-root` (a dependency of 'seed')
builds them and --no-deps skipped it". `seed` has no dependencies: the
refusal (src/main.w build_runner_explain_no_root, reached from the runner
check in run_build_graph) keyed on the --no-deps flag alone, so it named a
dependency that does not exist and refused a run that skipped nothing. The
same build without --no-deps evaluates at comptime and says so. It passed
on runs where the machine-wide runner store already held a runner for the
graph's key (build_runner_built), which links nothing and so never reached
the refusal.

run_build_command now computes what --no-deps skipped: the selected
target's full closure (build_graph_filter_target) containing
prepare-bootstrap-link-root. Only then does the run refuse; otherwise the
driver says actions evaluate in its comptime evaluator, as a full run does.

Verified with stage1 on a project with a foreign out/lib marker and an
empty runner store: `:x --no-deps` (x depends on the prepare) refuses
naming it; `:y --no-deps` (no dependency) evaluates at comptime; this
tree's `:seed --no-deps` prints "is the pinned seed" under the evaluator.

* Build: the build store never serves an action made from other reads; an entry is checked before it touches the outputs; WITH_BUILD_NO_EARLY_CUTOFF holds for the store (#1899)

The battery on c78e242 failed the four binary-read fixtures and
behav_build_early_cutoff, and cli-selfhost-build-w-tests on a second run.

Root cause (src/BuildGraphCache.w build_cache_store_key): the store key
hashes the signature, the driver, the compiler and the content of the
DECLARED inputs. An action's reads through ToolFs were recorded nowhere,
so the key and the record were the same for every project whose build.w
was the same, whatever the action read. binary_read_cases' action declares
no input and copies `input.bin`; its four kinds (missing, directory,
empty, binary) share one key. With an empty store, in one run: the empty
case published, and the binary case was served the empty output (fails at
binary_read_cases.w:39). Across runs the directory case was served a
success ("rc=0, expected a failure mentioning copy_file", store entry
9e5316c668ea, whose state has no in:/dep: line at all). The same gap holds
for the local state, which only hid behind each case's fresh root.

Fix: what an action reads through ToolFs is an input of its result.
- lib/std/build.w ToolFs.record_read (native runner) and
  ComptimeEvaluator.record_read_effect (evaluator, --strict-effects and the
  fallback) record every path an action reads, probes and listings
  included, outside its own write scope; build(ctx)'s reads (no write scope,
  or graph reconstruction with writes suppressed) are not the action's. The
  runner keeps one file per path beside its effect log (constant time per
  read); the driver reads them back (main.w build_runner_read_effects) and
  clears them before each run.
- build_cache_record turns `read` effects into `dep:` lines, fingerprinted
  like a compile's tracked inputs, so the local freshness check and a
  restored record both go stale when a read path's bytes, kind or absence
  differ.
- build_cache_store_restore checks the stored record's in:/dep:/env: lines
  against this worktree (build_cache_store_record_mismatch) BEFORE it
  replaces any output; an entry made from other reads is refused ("does not
  apply") and the target runs. It used to copy the outputs first and verify
  after, so a refused entry had already overwritten what was on disk.
- Failed actions were never stored (build_cache_record is reached only on
  success, in the runner, pool and evaluator paths), and still are not.

behav_build_early_cutoff:67: with WITH_BUILD_NO_EARLY_CUTOFF=1 `gen` ran,
and `use` (dependency rebuilt) was restored from the store entry step 3 had
published for the same input bytes. The escape hatch means "a dependency
ran, so rebuild"; main.w build_graph_early_cutoff_enabled now gates the
store restore of a target whose dependency ran, as it gates the cutoff.

Tests assert what their builds ran, and the machine-wide store serves a
target another run built from the same inputs (an action that prints,
served, prints nothing: the selfhost evaluator_print case failed that way
on a second run with the same compiler). The p7 harness gives each test
process a store of its own, emptied on first use; the selfhost cwd helpers
give each case one under the action's output; a test or case that names
WITH_BUILD_CACHE_DIR keeps it. These stores still serve within a test, so
the binary-read fixtures keep exercising the refusal. The selfhost
evaluator cases also get an empty runner store: a runner built for the same
graph links nothing and so ran `:seed` natively despite the foreign out/lib
marker, while the test's only check was the absence of "runner compiled";
they now also require the driver to say actions evaluate at comptime.

Failing first: test/behavior/behav_1899_build_store_undeclared_read.w (two
projects, one shared store, the same build.w reading different undeclared
bytes; a directory there must fail without its output being replaced; the
same bytes must be served; runner and evaluator) fails on c78e242's
release ("served another project's output: alpha"), passes on stage1. The
four binary-read fixtures, behav_build_early_cutoff and
behav_1899_build_store_serves_any_target pass on stage1.

---------

Co-authored-by: Eric Hartford <[email protected]>
@ehartford
ehartford deleted the fix-latent-sites branch October 4, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant