Skip to content

Replace build-script path sharing with a stable build-support boundary (#49) - #96

Draft
leynos wants to merge 1 commit into
mainfrom
issue-49-replace-build-script-path-sharing-with-a-stable-build-support-boundary
Draft

Replace build-script path sharing with a stable build-support boundary (#49)#96
leynos wants to merge 1 commit into
mainfrom
issue-49-replace-build-script-path-sharing-with-a-stable-build-support-boundary

Conversation

@leynos

@leynos leynos commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

This branch replaces #[path] source sharing between the root build script and library tests with the workspace-internal theoremc-build-support crate. It gives build discovery, suite generation, and generated Cargo metadata a stable Cargo dependency boundary without expanding the public theoremc API.

Closes #49.

Review walkthrough

Validation

  • make check-fmt: passed.
  • make typecheck: passed.
  • make lint: passed.
  • make test: passed (647/647 nextest tests and doctests).
  • make markdownlint: passed.
  • make nixie: passed.
  • coderabbit review --agent: completed with 0 findings.

References

Summary by Sourcery

Replace path-based build-script source sharing with a stable internal build-support crate for theorem build integration.

Enhancements:

  • Introduce the internal theoremc-build-support crate as a stable Cargo boundary for theorem discovery, suite generation, and build metadata.
  • Reduce the root build script to a thin adapter that emits Cargo configuration and rerun metadata without expanding the public theoremc API.
  • Update fixture-based behavioral tests to exercise build support through a path dependency rather than copied source modules.

Build:

  • Move build-time discovery and suite-generation dependencies into the new workspace build-support crate and register it as the root build dependency.

Documentation:

  • Document the build-support crate boundary and updated contribution guidance for build-time functionality.

Tests:

  • Keep build discovery and suite-generation unit tests with the build-support crate and adapt Cargo fixture tests to validate the dependency boundary.

Move theorem discovery, suite generation, and build preparation into the
workspace-internal `theoremc-build-support` crate. The root build script and
fixture crates now consume that crate through Cargo dependencies, rather than
compiling root source files via `#[path]`.

Keep Cargo metadata emission in the root build-script adapter, so the support
library remains suitable for the workspace's strict lint policy. Update
maintainer guidance to define the internal ownership and reuse policy.
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Warning

Your free Security trial is over. An organization admin can activate billing to continue.


Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Replaces fragile source-file sharing between the root build script and tests with the workspace-internal theoremc-build-support crate, centralizing discovery, suite generation, and typed build results while keeping build.rs as a minimal Cargo-protocol adapter and updating fixture coverage and developer documentation.

Sequence diagram for build-script preparation through Cargo metadata

sequenceDiagram
    participant Cargo
    participant BuildScript as RootBuildScript
    participant Support as TheoremcBuildSupport
    participant Filesystem

    Cargo->>BuildScript: provide CARGO_MANIFEST_DIR and OUT_DIR
    BuildScript->>Support: prepare_build_script()
    Support->>Support: discover_theorem_inputs(manifest_dir)
    Support->>Filesystem: write_theorem_suite(out_dir, discovery)
    Filesystem-->>Support: generated suite written
    Support-->>BuildScript: BuildScriptOutput
    BuildScript->>Cargo: emit theoremc_has_theorems when has_theorems()
    BuildScript->>Cargo: emit rerun_paths()
Loading

File-Level Changes

Change Details Files
Introduces a workspace-internal build-support crate that owns theorem discovery, suite generation, and typed build-script orchestration.
  • Moves discovery and suite modules into the new crate and makes their integration API public within that boundary.
  • Adds BuildScriptOutput and structured BuildScriptError handling for Cargo environment, filesystem, discovery, and generation failures.
  • Preserves deterministic theorem ordering, generated output behavior, and Cargo rerun metadata.
Cargo.toml
Cargo.lock
crates/theoremc-build-support/Cargo.toml
crates/theoremc-build-support/src/lib.rs
crates/theoremc-build-support/src/build_script.rs
crates/theoremc-build-support/src/discovery.rs
crates/theoremc-build-support/src/suite.rs
Reduces the root build script to a thin adapter over the stable build-support dependency boundary.
  • Replaces #[path] module inclusion and direct dependency usage with prepare_build_script().
  • Emits the theorem cfg flag and rerun directives from the typed build result.
  • Removes test-only build-support modules from the root library.
build.rs
src/lib.rs
Updates behavioral fixtures and tests to exercise build support through a Cargo path dependency rather than copied source sharing.
  • Copies the build-support crate structure into temporary fixture crates.
  • Changes fixture manifests to depend on theoremc-build-support instead of duplicating its transitive dependencies.
  • Retains coverage for rerun behavior, empty and populated theorem trees, deterministic generation, and path normalization.
tests/common/fixture_crate.rs
tests/build_discovery_bdd.rs
tests/build_suite_bdd.rs
tests/theorem_file_macro_bdd/fixture_crate.rs
Documents the new internal build-support architecture and maintenance workflow.
  • Revises the build-script walkthrough and layer table to identify the new crate.
  • Explicitly prohibits #[path] sharing and specifies normal dependency-based integration.
  • Adds guidance for extending build-time discovery or generation with unit and Cargo behavioral tests.
docs/developers-guide.md

Assessment against linked issues

Issue Objective Addressed Explanation
#49 Replace build.rs and root-test source sharing via #[path] with a stable internal build-support crate or equivalent boundary for theorem discovery and suite generation.
#49 Update build scripts and behavioral/root tests to consume and validate the new build-support boundary while preserving discovery, suite generation, Cargo rerun metadata, and generated wiring behavior.
#49 Update maintainer documentation to describe the new build-support ownership boundary and reuse policy.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

Replace build-script path sharing with a stable build support boundary

1 participant