Skip to content

Build: manifest-driven C-library migrations — one generic pipeline engine, per-library specs as data #675

Closed

Description

@ehartford

Problem

Every migrated C library currently pays three times:

  1. A build/<lib>.w module (~500–900 lines) that is ~70% boilerplate — build/pcre2.w (874 lines) and build/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).
  2. ~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.
  3. 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 small prep code 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/-promote uniformly, plus an umbrella :migrations target. Adding a library = one ~30-line manifest + one list entry.

  • prep growth 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

Migration path (one logical change per step, each behind full gates)

  1. Extract shared utils + the generic engine from pcre2.w/zlib.w, behavior-preserving.
  2. Convert pcre2 and zlib to manifests; prove equivalence by their existing targets producing identical results (same generated trees, same gate verdicts).
  3. Delete the superseded per-library modules.
  4. 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.

Blocks: #673, #674.

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

  1. added a commit that references this issue on Jul 16, 2026
  2. added this to the post-v0.16.0 milestone on Jul 16, 2026
  3. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): done. The corpus registry is this design: one Corpus record 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions