Repository navigation
Description
Problem
Every migrated C library currently pays three times:
- A
build/<lib>.wmodule (~500–900 lines) that is ~70% boilerplate —build/pcre2.w(874 lines) andbuild/zlib.w(476 lines) each carry privately-prefixed copies of the same path utilities (join,dirname,basename,abs,safe_label,scratch_dir,fail,remove_tree_if_exists,compile_binary, …) and structurally identical action bodies (reference/migrate/build/test/check-generated/promote). - ~60–100 lines of imperative registration in build.w — nine hand-chained
target_new().input().arg().dep().write_scope()blocks for pcre2, six for zlib. - Scattered knobs: SHA as a module const, URL as a
.arg()in build.w, exclude lists as positional target args, "expected ≥ 30 files" as an inline magic number. Nothing structurally forces the pipelines to enforce the same policy gates — they can drift silently.
Two libraries ≈ 1,500 lines. docs/feature_plans/libs.md plans ~49 engines; the current pattern extrapolates to ~35–40k lines of copy-pasted build code, with every future policy improvement needing to land N times. #673 (lexbor) and #674 (llhttp) are blocked on this so they land as manifest entries, not as build modules three and four.
Design
One record, one engine, one loop.
-
MigrationSpec— a plain With record per library (With is the config language: comptime-checked, and it can carry the one thing pure data cannot — a smallprepcode hook):pub fn pcre2_migration -> MigrationSpec: MigrationSpec { name: "pcre2", release: "pcre2-10.47", url: "https://github.com/PCRE2Project/pcre2/releases/download/...", sha256: "c08ae238...", source_subdir: "src", exclude_sources: ["pcre2demo.c", "pcre2grep.c", ...], min_generated_files: 30, std_dir: "lib/std/re", prep: pcre2_prepare_reference_tree, // the ONLY per-library code engine_test: EngineTest.Script("RunTest", ...), uat_fixture: "build/release_uat_fixtures/pcre2_main.w", } -
build/migration.w— one generic engine implementing the canonical actions (fetch + SHA verify + extract, prep, migrate, compile-as-is build, engine tests, check-generated, promote), all parameterized by the spec. Policy gates live here once — compile-as-is, the no-@[c_export]scan, min-file-count — so every library enforces them by construction. -
build.w — one loop
for spec in migration_specs(): register_migration_targets(out, spec)generating<name>-reference/-migrate/-build/-test/-promoteuniformly, plus an umbrella:migrationstarget. Adding a library = one ~30-line manifest + one list entry. -
prepgrowth is a governance signal: per-library staging beyond a config header is a smell that the fix belongs in the migrator (generic), mirroring the no-per-project-special-cases doctrine at the build layer.
Shared infrastructure riding along
- Extract the duplicated path utils into one build util module now; long-term they are
std.path(libstd-spec sequencing item Type resolution corruption when single source file exceeds ~14K lines #1 — this refactor is its first customer). - One fetch path with a content-addressed archive cache keyed by SHA256 (reference stage = cache lookup, fetch on miss) — converges with with get shells out to host curl/wget — must be runtime-native fetch #623/Restore hermetic with-get gate coverage and add a content-addressed cache #624 hermetic
with get. - The manifest list becomes the canonical migration registry cross-referencing libs.md's engine plan (auditable: what is migrated, at which pinned version).
Migration path (one logical change per step, each behind full gates)
- Extract shared utils + the generic engine from pcre2.w/zlib.w, behavior-preserving.
- Convert pcre2 and zlib to manifests; prove equivalence by their existing targets producing identical results (same generated trees, same gate verdicts).
- Delete the superseded per-library modules.
- Migrate lexbor as a registered corpus: HTML engine + functionality-named facade #673 (lexbor) and Migrate llhttp as a registered corpus: HTTP/1.x parse engine + std.http.parse_* facade #674 (llhttp) then start as manifest entries on day one.
Expected effect at plan scale
~800 lines of engine + ~30 lines per library, versus ~780 average per library today; policy strengthened in one place forever.
Completion gate (maintainer ruling 2026-07-16)
Retrofitting both pcre2 and zlib onto the new manifest-driven pipeline is in scope for this issue, and the issue is complete only when both work end to end on it: for each of pcre2 and zlib, the manifest-driven <name>-reference → -migrate → -build → -test → -check-generated → -promote chain runs green, produces results equivalent to the current hand-rolled targets (same generated trees, same gate verdicts, engine test suites passing), and the superseded build/pcre2.w/build/zlib.w pipeline code is deleted. No parallel old/new wiring may remain at close.
Activity
Docs: record migration campaign queue (#675 -> #673/#674) in handoff
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): done. The corpus registry is this design: oneCorpusrecord per library (build/corpora.w, the registry;build/corpus.w, the generic pipeline: fetch, extract, prepare, migrate, check, promote, the drift lane and the bundle), landed in f050a9f ("build: the corpus registry — one declaration per corpus, one generic pipeline, build.w iterates"). Six corpora run through it today.