Skip to content

feat(wanda): add Digest function to wanda library#454

Merged
andrew-anyscale merged 1 commit intomainfrom
andrew/revup/main/wanda-digest
Mar 11, 2026
Merged

feat(wanda): add Digest function to wanda library#454
andrew-anyscale merged 1 commit intomainfrom
andrew/revup/main/wanda-digest

Conversation

@andrew-anyscale
Copy link
Contributor

Adds a Digest function that computes the content-addressed digest for a
spec file without checking the cache or building the image. Build and
Digest share setup through prepareForge (dep graph + forge construction)
and resolveBuildCore (tar context hashing + base image resolution), so
no logic is duplicated between the two paths.

Topic: wanda-digest
Signed-off-by: andrew andrew@anyscale.com

Adds a Digest function that computes the content-addressed digest for a
spec file without checking the cache or building the image. Build and
Digest share setup through prepareForge (dep graph + forge construction)
and resolveBuildCore (tar context hashing + base image resolution), so
no logic is duplicated between the two paths.

Topic: wanda-digest
Signed-off-by: andrew <andrew@anyscale.com>
@andrew-anyscale
Copy link
Contributor Author

Reviews in this chain:
#454 feat(wanda): add Digest function to wanda library
 └#455 feat(wanda): add digest subcommand to wanda CLI

@andrew-anyscale
Copy link
Contributor Author

andrew-anyscale commented Mar 10, 2026

# head base diff date summary
0 ae7dff66 0fbeb47b diff Mar 10 13:25 PM 2 files changed, 177 insertions(+), 14 deletions(-)
1 50233428 0fbeb47b diff Mar 10 13:48 PM 1 file changed, 4 insertions(+), 1 deletion(-)
2 62b6215f 0fbeb47b diff Mar 10 18:06 PM 1 file changed, 31 insertions(+), 26 deletions(-)
3 2b8ead37 0fbeb47b diff Mar 10 18:09 PM 1 file changed, 21 insertions(+), 18 deletions(-)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new Digest function to the wanda library, enabling the computation of content-addressed digests for container specification files. This function is designed to provide the digest efficiently, bypassing the full image build and cache lookup processes. To achieve this without duplicating logic, the PR refactors existing build setup steps into shared helper functions, prepareForge and resolveBuildCore, which are now utilized by both the Build and the new Digest functionalities. This enhancement provides a streamlined way to obtain image digests, which can be crucial for content-addressable systems and build pipeline optimizations.

Highlights

  • New Digest Function: Introduced a Digest function to compute content-addressed digests for spec files without triggering a full image build or cache check.
  • Code Refactoring: Extracted common setup logic into prepareForge and resolveBuildCore functions, which are now shared by both Build and Digest functions, reducing code duplication.
  • Comprehensive Testing: Added a suite of new tests for the Digest function, verifying its output format, determinism, and sensitivity to configuration changes like epoch and environment variables.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • wanda/forge.go
    • Imported the io package.
    • Refactored the Build function to utilize a new prepareForge helper.
    • Introduced prepareForge to encapsulate common setup for Build and Digest.
    • Extracted core build input resolution logic into a new resolveBuildCore method.
    • Added a new digestSpec method to the Forge struct for computing spec digests.
    • Implemented the public Digest function to compute and write content-addressed digests.
    • Adjusted error return types in refactored functions to accommodate multiple return values.
  • wanda/forge_test.go
    • Added TestDigest_format to verify the output format of the Digest function.
    • Included TestDigest_deterministic to ensure consistent digest generation.
    • Added TestDigest_epochChangesDigest to confirm epoch's influence on the digest.
    • Implemented TestDigest_envFileChangesDigest to test the impact of environment file changes.
    • Created TestDigest_matchesBuildDigest to validate that Digest output aligns with Build's internal digest.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The code changes introduce a new Digest function to compute content-addressed digests for specifications without building images, and a prepareForge function to set up the forge and dependency graph. The forge.Build function was refactored to use the new prepareForge function. A test was added to verify that the Digest function produces the same digest that Build logs internally. The review comment points out that the found boolean returned by strings.Cut is being ignored in the test, which could lead to incorrect test results. The reviewer suggests checking the found value to ensure the digest has the expected format before proceeding with the assertion.

@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/wanda-digest branch from ae7dff6 to 5023342 Compare March 10, 2026 20:48
wanda/forge.go Outdated
// Prepare the tar stream.
// resolveBuildCore assembles the build input and core for a spec.
// This is the shared setup used by both Build and digestSpec.
func (f *Forge) resolveBuildCore(spec *Spec) (*buildInput, *buildInputCore, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

feels like resolveBuildInput?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaner, I like it!

wanda/forge.go Outdated
// prepareForge sets up a Forge and builds the dependency graph for specFile.
// It normalizes config, resolves the env lookup chain, and is shared by Build
// and Digest.
func prepareForge(specFile string, config *ForgeConfig) (*Forge, *depGraph, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe add a buildSession struct that can capture the context like forge and depGraph and input and inputCore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. forge and graph are only setup once per run, whereas input/inputCore are per-spec, so I'll bundle those two together!

@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/main/wanda-digest branch 2 times, most recently from 62b6215 to 2b8ead3 Compare March 11, 2026 01:09
@andrew-anyscale andrew-anyscale merged commit 953c239 into main Mar 11, 2026
2 checks passed
@andrew-anyscale andrew-anyscale deleted the andrew/revup/main/wanda-digest branch March 11, 2026 01:36
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