Weld
Weld is a deterministic projection and release-preparation tool for Elixir repositories.
Multi-project Elixir workspaces often split code across internal Mix projects for fast isolated testing, boundary enforcement, or optional extensions, while downstream consumers want a single ordinary Mix dependency or Hex package. Weld bridges that gap without turning generated output into a second hand-maintained source tree: it reads a repo-local manifest, resolves the workspace dependency graph, projects a standalone Mix project under .weld/, verifies that generated project with standard Mix commands, and prepares content-addressed release bundles and optional Git projection snapshots.
When To Use Weld
Use Weld when maintainers want to:
- develop in a multi-project Elixir workspace while publishing or sharing a cohesive Mix package
- merge selected workspace applications, configs, migrations, and tests into a single deployable or testable monolith project
- preserve an existing root or nested Mix project (
mode: :source_project) while producing portable full candidates, symlinked live development views, or immutable release bundles - publish durable generated-source snapshots on an orphan
projection/<package_name>branch without mixing generated files intomain
Consumers of a root Mix project, a generated projection, a projection/<package_name> branch, or a published Hex package use ordinary mix commands (path:, git:/github:, or Hex) and never need to install Weld.
Relationship To Ordinary Mix Workflows
- Main-tree source authority:
main(and the repository's normal Mix projects) remains the single source of truth for code, tests, formatting, and static analysis. - Maintainer-only tooling:
Weldruns only when maintainers inspect the workspace graph, project views, verify packaged artifacts, or prepare/track releases. Ordinarymix deps.get,mix compile, andmix testworkflows do not invokeWeld. - Isolated snapshot history:
mix weld.release.trackcommits preparedproject/trees onto an orphanprojection/<package_name>branch so downstream Git consumers can pin projected snapshots without coupling to workspace layout or pollutingmain.
Projection Modes And Lifecycle
Weld supports three artifact composition modes declared per artifact in the manifest:
| Mode | What the artifact builds |
|---|---|
:package_projection (default) |
Composes a selected Mix dependency closure under components/ and generates one Mix project. |
:monolith |
Merges selected sources, assets, migrations, configuration, and tests into a flat Mix project. |
:source_project |
Preserves the existing Mix project at one workspace root or subdirectory, including its own package metadata and compiler inputs. |
Every mode supports two projection kinds:
- Live (
mix weld.project --live) links source into.weld/live/<artifact>/for local Mix path consumers. In a package or source-project view, edits, additions, and deletions within existing linked directories are visible on the next build. A live monolith links individual files, so file additions, removals, or remaps require refresh. Each mode checks the metadata and inputs that determine its layout. Live views reject Hex build and publication tasks. - Full (
mix weld.project) writes a portable project of regular files to.weld/full/<artifact>/project/.mix weld.verifyandmix release.prepareverify full projects. A prepared release binds the verified project, docs, optional Hex tarball, lock, source revision, and toolchain beneath.weld/releases/<artifact>/<identity>/.
Installation For Maintainers
These examples target Weld 0.16.0. Resolve the Hex dependency once that version is published. Add it to the workspace mix.exs or to a dedicated maintainer project such as tools/maintainer/mix.exs.
def deps do
[
{:weld, "~> 0.16.0", only: [:dev, :test], runtime: false}
]
end
Initialize the repository's .weld/ directory and .gitignore rule before running clean-tree release preparation:
mix weld.setup
Core Commands
When [manifest_path] is omitted, Weld auto-discovers build_support/weld.exs, then build_support/weld_contract.exs, then a single packaging/weld/*.exs:
mix weld.setup
mix weld.inspect
mix weld.graph --format dot
mix weld.query deps runtime/local
mix weld.project
mix weld.project --live
mix weld.verify
mix weld.agents.verify
mix release.prepare
mix release.track
mix release.archive
mix weld.affected --task verify.all --base main --head HEAD
Pass an explicit manifest path (and --artifact <name> when a manifest defines multiple artifacts) when running from a nested maintainer project or a repo with multiple manifests.
Repository-Root .weld/ Layout
All Weld-managed state lives under <checkout_root>/.weld/, serialized by an exclusive checkout lock (.weld/.lock) and guarded by ownership markers (.owner):
.weld/
.owner # ownership marker ("weld-output/v1")
.lock/owner # active writer PID and node while mutating
live/<artifact>/ # symlinked live view
full/<artifact>/project/ # standalone full Mix project + provenance/lock
cache/<projection_id>/<toolchain>/ # warm Mix deps/ and build/ for verification
releases/<artifact>/
CURRENT # pointer to the latest verified <identity>
<identity>/ # immutable release.json, project/, docs/, *.tar
archive/<artifact>/<identity>/ # archived post-release bundle copy
staging/ # atomic staging directories during mutation
smoke/ # temporary consumer smoke-test projects
worktrees/ # temporary Git worktrees during release.track
Weld rejects symlinks along managed output roots, refuses to overwrite unmanaged directories, and preserves any legacy dist/ directories untouched for manual migration.
Compose Two Artifacts From One Workspace
Suppose core/engine owns the reusable engine and apps/console declares
{:engine, path: "../../core/engine"}. Add build_support/weld.exs in the
workspace root:
[
workspace: [root: "..", project_globs: ["core/*", "apps/*"]],
artifacts: [
engine_bundle: [
roots: ["core/engine"],
package: [name: "engine_bundle", otp_app: :engine_bundle, version: "0.1.0"]
],
console_bundle: [
roots: ["apps/console"],
package: [name: "console_bundle", otp_app: :console_bundle, version: "0.1.0"]
]
]
]
Weld follows the console's declared dependency and includes both projects in
console_bundle. engine_bundle includes only the engine. Use each artifact
as an alternative package, since both contain the engine's modules. If console
should depend on a separately released engine, declare an artifact-local
boundary as described in the manifest reference.
mix weld.setup build_support/weld.exs
mix weld.project build_support/weld.exs --artifact console_bundle --live
mix weld.project build_support/weld.exs --artifact console_bundle
mix weld.project build_support/weld.exs --artifact engine_bundle
In a sibling consumer, declare
{:console_bundle, path: "../workspace/.weld/live/console_bundle"}
and run mix deps.get and mix compile. Use the corresponding full project
for a portable copy and a prepared project for an immutable input. The
getting started guide covers artifact verification
and release preparation.
Verification And Release Lifecycle
mix weld.verify regenerates .weld/full/<artifact>/project/ and runs a mode-specific verification gate using isolated build/dependency caches under .weld/cache/:
- Package-projection and source-project modes:
mix deps.get,mix deps.compile,mix compile --warnings-as-errors --no-compile-deps,mix test,mix docs --warnings-as-errors, optional external smoke-app compilation,mix hex.build(whenverify.hex_buildistrue), andmix hex.publish --dry-run --yes(when bothhex_buildandhex_publisharetrue). - Monolith mode: per-selected-project
mix testbaseline,mix deps.get,mix compile --warnings-as-errors,mix test(enforcingtest_count >= baseline),mix docs --warnings-as-errors,mix hex.build(whenhex_buildistrue), andmix hex.publish --dry-run --yes(when bothhex_buildandhex_publisharetrue).
Set verify: [hex_build: false] for internal artifacts that intentionally use non-Hex Git dependencies, or verify: [hex_publish: false] to build a Hex tarball without running hex.publish --dry-run.
The standard release flow separates deterministic bundle preparation from credentialed publication:
- Run the source workspace's own test and quality gates on a clean Git working tree.
- Run
mix release.prepareto verify and write.weld/releases/<artifact>/<identity>/. - Optionally run
mix release.trackto update the orphanprojection/<package_name>branch (and optionally--tag/--push). - When publishing to Hex, run
mix hex.publishfrom the prepared bundle'sproject/directory. - Run
mix release.archiveto preserve the verified bundle under.weld/archive/<artifact>/<identity>/.
Prepared project/ trees and tracked Git projections retain weld.provenance.json and projection.lock.json for auditability; Hex tarballs omit projection.lock.json.
Guides
- Getting Started
- Workflow
- Source-Project Artifacts
- CLI Reference
- Manifest Reference
- Architecture
- Testing Strategy
- Release Process
- Consumer Repo Integration
License
This project is licensed under the MIT License. See LICENSE for details.