Skip to content

fix: template init was not using up-to-date dependencies#1008

Merged
ryardley merged 8 commits into
mainfrom
ry/fix-template-init-issues
Nov 13, 2025
Merged

fix: template init was not using up-to-date dependencies#1008
ryardley merged 8 commits into
mainfrom
ry/fix-template-init-issues

Conversation

@ryardley

@ryardley ryardley commented Nov 13, 2025

Copy link
Copy Markdown
Contributor
  • use monorepo dependencies for monorepo tests
  • use template specific dependencies for enclave init
  • overwrite Cargo.toml

Summary by CodeRabbit

  • New Features

    • Template downloads now display the commit hash in confirmation messages.
  • Tests

    • Refactored in-place file replacement tests with expanded coverage scenarios.
  • Chores

    • Template dependencies updated to use local paths instead of remote references, ensuring consistent dependency resolution for generated projects.

@vercel

vercel Bot commented Nov 13, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
crisp Ready Ready Preview Comment Nov 13, 2025 0:36am
enclave-docs Ready Ready Preview Comment Nov 13, 2025 0:36am

@coderabbitai

coderabbitai Bot commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes implement commit-hash-aware template initialization by extracting the template repository's git commit hash and using it to rewrite template dependencies to point to specific commits. Additionally, BFV parameter handling is abstracted through a new parameter-set type, and test coverage is expanded with table-driven tests.

Changes

Cohort / File(s) Summary
Test infrastructure expansion
crates/fs/src/fs.rs
Refactored single test_replace_in_place test into a table-driven test_replace_in_place_table test with a TestCase struct and two parameterized test scenarios.
Git commit hash extraction
crates/init/src/git.rs
Added new public async function get_commit_hash that retrieves the HEAD commit hash from a specified directory via git rev-parse.
Template initialization with commit tracking
crates/init/src/lib.rs
Enhanced template download flow to compute and capture git commit hash; introduced three new filters to rewrite Cargo.toml dependencies (e3-program-server, e3-bfv-helpers, e3-compute-provider) to use git URLs with commit-specific revisions.
Glob pattern handling
crates/init/src/copy.rs
Simplified glob pattern resolution by using filter.glob_pattern directly instead of constructing an absolute prefixed pattern.
Default template dependency declarations
templates/default/Cargo.toml
Switched three workspace dependencies from git+rev specification to local path-based references (pointing to ../../crates/).
BFV parameter abstraction
templates/default/program/src/lib.rs
Replaced direct tuple unpacking of INSECURE_SET_2048_1032193_1 with structured BfvParamSet and BfvParams abstractions; updated build_bfv_params_arc signature to accept explicit error variance parameter.

Sequence Diagram

sequenceDiagram
    participant User
    participant Init as init (lib.rs)
    participant Git as git.rs
    participant Copy as copy.rs
    participant Template as templates/*

    User->>Init: init_template()
    Init->>Copy: download_and_copy_template()
    Copy->>Template: copy files with local paths
    Init->>Git: get_commit_hash(TEMP_DIR)
    Git-->>Init: commit_hash
    Init->>Init: apply filters to rewrite deps<br/>(e3-program-server, etc.)<br/>with git+rev = commit_hash
    Init-->>User: "Template downloaded<br/>with commit hash '...'"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • crates/init/src/lib.rs: Review the new filter logic for dependency rewriting and ensure commit hash is correctly propagated and formatted in dependency declarations.
  • crates/init/src/copy.rs: Verify that simplified glob pattern handling maintains correct path resolution relative to the destination directory.
  • templates/default/program/src/lib.rs: Validate the BfvParamSet parameter extraction and the updated build_bfv_params_arc function call signature, ensuring error variance is correctly sourced.
  • Dependency coherence: Confirm that the cycle between local paths in template and runtime rewriting to git+rev is intentional and doesn't create conflicts.

Possibly related PRs

Suggested reviewers

  • ctrlc03
  • hmzakhalid
  • auryn-macmillan

Poem

🐰 Hop along, the template runs with care,
Commits now locked with hashes fair,
Parameters structured, clean and true,
Tests in tables—reusable new!
The enclave's path grows bright and clear,

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating template initialization to use up-to-date dependencies instead of stale references.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ry/fix-template-init-issues

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9e3590 and 5ca156e.

⛔ Files ignored due to path filters (1)
  • templates/default/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • crates/fs/src/fs.rs (1 hunks)
  • crates/init/src/copy.rs (1 hunks)
  • crates/init/src/git.rs (1 hunks)
  • crates/init/src/lib.rs (2 hunks)
  • templates/default/Cargo.toml (1 hunks)
  • templates/default/program/src/lib.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-08-25T10:28:56.174Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 657
File: Cargo.toml:32-34
Timestamp: 2025-08-25T10:28:56.174Z
Learning: The examples/CRISP directory has its own Cargo.toml workspace configuration with members like "server", "wasm-crypto", "program/core", "program/client", etc. The root workspace intentionally excludes "examples/CRISP/server", "examples/CRISP/program", and "examples/CRISP/wasm-crypto" to prevent double workspace membership, which is the correct approach for self-contained example workspaces.

Applied to files:

  • templates/default/Cargo.toml
  • crates/init/src/lib.rs
📚 Learning: 2024-10-22T02:36:01.448Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/data/Cargo.toml:0-0
Timestamp: 2024-10-22T02:36:01.448Z
Learning: In `packages/ciphernode/data/Cargo.toml`, `actix-rt` is only used in tests and should remain in `[dev-dependencies]`.

Applied to files:

  • templates/default/Cargo.toml
📚 Learning: 2024-10-08T19:45:18.209Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: packages/ciphernode/sortition/src/distance.rs:1-1
Timestamp: 2024-10-08T19:45:18.209Z
Learning: In `packages/ciphernode/core/src/events.rs`, the import statements use the correct and updated `alloy::primitives` module.

Applied to files:

  • templates/default/Cargo.toml
  • templates/default/program/src/lib.rs
📚 Learning: 2025-11-05T14:12:57.814Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 963
File: examples/CRISP/client/package.json:25-25
Timestamp: 2025-11-05T14:12:57.814Z
Learning: In the Enclave/CRISP codebase, `enclave-e3/sdk` and `crisp-e3/sdk` are different packages: `enclave-e3/sdk` is the general Enclave SDK, while `crisp-e3/sdk` is the CRISP-specific SDK. The CRISP client (`examples/CRISP/client`) intentionally depends on `enclave-e3/sdk`, not `crisp-e3/sdk`.

Applied to files:

  • templates/default/Cargo.toml
📚 Learning: 2024-10-28T12:00:09.010Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/enclave/src/commands/wallet/set.rs:17-23
Timestamp: 2024-10-28T12:00:09.010Z
Learning: In the `enclave` package of the `ciphernode` project, prefer using `println!` over logging macros like `error!` from the `tracing` crate for error output in CLI commands.

Applied to files:

  • templates/default/Cargo.toml
📚 Learning: 2025-05-07T15:18:20.056Z
Learnt from: 0xjei
Repo: gnosisguild/enclave PR: 388
File: packages/commons/src/bfv/mod.rs:38-48
Timestamp: 2025-05-07T15:18:20.056Z
Learning: The `build_bfv_params` and related functions in the commons BFV utilities intentionally use panic for error handling as a temporary solution. The team plans to refactor these to use proper Result-based error handling in the future.

Applied to files:

  • templates/default/program/src/lib.rs
📚 Learning: 2024-10-22T02:10:34.864Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:82-83
Timestamp: 2024-10-22T02:10:34.864Z
Learning: In the file `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs`, when reviewing test functions like `generate_pk_share`, minor performance optimizations (e.g., minimizing mutex locks) are not a priority.

Applied to files:

  • templates/default/program/src/lib.rs
📚 Learning: 2025-11-08T01:31:47.484Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 969
File: packages/enclave-sdk/src/enclave-sdk.ts:101-103
Timestamp: 2025-11-08T01:31:47.484Z
Learning: In packages/enclave-sdk/src/enclave-sdk.ts, the TRBFV protocol parameter setup is intentionally incomplete as of PR #969. The constructor sets BFV_THRESHOLD parameters for TRBFV, but the encryption methods (encryptNumber, encryptVector, encryptNumberAndGenInputs, encryptVectorAndGenInputs) intentionally only support BFV and will throw "Protocol not supported" for TRBFV until future implementation is completed.

Applied to files:

  • templates/default/program/src/lib.rs
📚 Learning: 2024-10-23T01:59:42.967Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:274-274
Timestamp: 2024-10-23T01:59:42.967Z
Learning: In the `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs` file and other test files within this project, hardcoding `CIPHERNODE_SECRET` is acceptable for testing purposes.

Applied to files:

  • templates/default/program/src/lib.rs
📚 Learning: 2024-10-08T19:45:18.209Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 133
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:137-139
Timestamp: 2024-10-08T19:45:18.209Z
Learning: In `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs`, using the same RNG instance `rng_test` for generating multiple key shares without advancing its state is acceptable.

Applied to files:

  • templates/default/program/src/lib.rs
🧬 Code graph analysis (2)
crates/init/src/lib.rs (2)
crates/init/src/git.rs (1)
  • get_commit_hash (138-158)
crates/init/src/copy.rs (1)
  • new (21-27)
templates/default/program/src/lib.rs (2)
crates/bfv-helpers/src/lib.rs (2)
  • build_bfv_params_arc (266-288)
  • encode_bfv_params (302-316)
crates/trbfv/src/trbfv_config.rs (1)
  • params (34-36)
🔇 Additional comments (6)
crates/fs/src/fs.rs (2)

299-307: Good refactoring to table-driven tests.

The introduction of a local TestCase struct and the table-driven test approach improves test maintainability and makes it easy to add new test scenarios.


327-352: Well-structured test execution loop.

The test execution properly isolates each test case with a fresh filesystem instance, uses unique file paths, and includes helpful assertion messages. The implementation follows Rust testing best practices.

crates/init/src/copy.rs (1)

48-48: LGTM!

The simplification to use filter.glob_pattern directly is correct. The test coverage at lines 94-229 validates that glob patterns like **/*/package.json properly match nested files under the destination path.

templates/default/Cargo.toml (1)

12-14: LGTM - Correct use of local paths for template development.

These local path dependencies enable testing the template within the monorepo. The init process (crates/init/src/lib.rs lines 120-134) will rewrite these to git URLs with specific commit hashes when users run enclave init.

templates/default/program/src/lib.rs (1)

29-30: LGTM - Improved parameter abstraction.

The refactor from tuple access to structured BfvParamSet improves type safety and readability. The signature change to build_bfv_params_arc correctly adds the error1_variance parameter, matching the implementation in crates/bfv-helpers/src/lib.rs:265-287.

Also applies to: 41-47

crates/init/src/git.rs (1)

138-158: LGTM - Well-implemented git commit hash retrieval.

The function correctly:

  • Uses git rev-parse HEAD to get the commit hash
  • Provides contextual error messages
  • Validates exit status before processing output
  • Trims the trailing newline from git's output

The implementation follows the same patterns as other git helper functions in this file.

Comment thread crates/fs/src/fs.rs
Comment thread crates/init/src/lib.rs

@ctrlc03 ctrlc03 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@ryardley ryardley merged commit b9c052f into main Nov 13, 2025
25 checks passed
@ctrlc03 ctrlc03 deleted the ry/fix-template-init-issues branch November 13, 2025 08:43
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.

2 participants