fix(release): make astrid-sys cargo-publishable (unblocks v0.7.0 workspace publish) - #49
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the astrid-sys build process to support both workspace builds (where the contracts/host submodule is present) and published builds (where the submodule is absent). It achieves this by checking for the presence of WIT files in the submodule path and conditionally skipping the staging step, relying instead on a committed copy of the WIT files in wit-staging/. A critical issue was identified in build.rs where returning early when WIT files are missing fails to register Cargo watches on the submodule directory and .gitmodules, which would prevent Cargo from detecting when the submodule is subsequently initialized.
Closes #48 `cargo publish -p astrid-sys` failed verifier compile because `build.rs` reads `../contracts/host/` (the unicity-astrid/wit workspace submodule) which isn't part of the .crate tarball. The `include = ["../contracts/host/**/*.wit", ...]` directive was meant to bundle it but cargo silently ignores `..` paths in include. Same class as astrid-runtime/astrid#763 (astrid-capsule wit) and #765 (astrid-cli apparmor). Cargo's include can't reach outside the crate dir; published crates must be self-contained. Fix: - Commit wit-staging/ to the crate (drop from .gitignore). 14 staged WIT files ship in the tarball. - build.rs becomes tolerant: if ../contracts/host/ doesn't exist OR contains no .wit files (uninitialised submodule), short-circuit and treat committed wit-staging/ as authoritative. - Cargo.toml include: drop ../contracts/host path, add wit-staging. Workspace builds: clean+re-stage from submodule, committed copy stays in lockstep. Published builds: short-circuit; wit_bindgen::generate! reads the committed copy directly. Verified: cargo publish -p astrid-sys --dry-run --allow-dirty packages and verifier-compiles cleanly. The downstream tier (astrid-sdk-macros, astrid-sdk) chains on top once astrid-sys lands on crates.io.
joshuajbouw
force-pushed
the
fix/publish-astrid-sys-wit-path
branch
from
May 25, 2026 22:34
5f79003 to
b74c3a1
Compare
Gemini #49 finding. The published-crate / uninitialised-submodule early-return registered `cargo:rerun-if-changed=wit-staging` but not the submodule path or `.gitmodules`. After a developer runs `git submodule update --init` on a fresh clone, Cargo wouldn't detect the newly-present WIT files and wouldn't rerun build.rs; the committed wit-staging would stay stale relative to the now- checked-out submodule. Now: register the same surface in both code paths (wit-staging, host_src, build.rs, .gitmodules) so a freshly-initialised submodule triggers a rebuild.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Closes #48
Summary
cargo publish -p astrid-sysfailed verifier compile becausebuild.rsreads../contracts/host/(the workspace WIT submodule) which isn't part of the.cratetarball. Theinclude = ["../contracts/host/**/*.wit", ...]directive can't reach outside the crate dir — same class of bug asunicity-astrid/astrid#763and#765.Blocks the v0.7.0 release of the entire SDK workspace (astrid-sys is the dep-graph root).
Changes
astrid-sys/.gitignore: dropwit-staging/entry. The staged WIT now ships in the crate.astrid-sys/build.rs: short-circuits when../contracts/host/doesn't exist OR contains no.witfiles (uninitialised submodule). Workspace builds clean+re-stage as before; published / consumer builds use the committedwit-staging/directly.astrid-sys/Cargo.toml:includedrops../contracts/host/**/*.wit(cargo can't honor..paths), addswit-staging/**/*.wit.wit-staging/: 15 files (root.witplaceholder + 13 per-domain WIT underdeps/astrid-*/).Test Plan
cargo check -p astrid-syscleancargo publish -p astrid-sys --dry-run --allow-dirtypackages + verifier-compiles cleanlycargo workspaces publish --from-gitresumes from astrid-sys after merge + re-tagRelease coordination
v0.7.0is already tagged butcargo workspaces publishfailed verifier on astrid-sys (the first crate in dep order). After this merges, force-updatev0.7.0to the merge commit, then retrycargo workspaces publish --from-git. No version bump — the published crate contents under 0.7.0 are functionally identical (Cargo.toml + build.rs + bundled WIT only).Checklist