Skip to content

refactor: fix determinism tests in manifest_hash_test - #815

Closed
wu21-web wants to merge 1 commit into
alibaba:mainfrom
wu21-web:patch-2
Closed

wu21-web wants to merge 1 commit into
alibaba:mainfrom
wu21-web:patch-2

Conversation

@wu21-web

@wu21-web wu21-web commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

READ:
#520 (comment)
#520 (comment)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

Related Issues

none

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review skipped: no items were selected.

@wu21-web wu21-web changed the title fix: remove inappropriate if statement tests in manifest_hash_test.go fix: invalid if statement tests in manifest_hash_test.go Aug 9, 2026
@lizhengfeng101

Copy link
Copy Markdown
Contributor

Hi @wu21-web, thanks for the contribution and for taking the time to look into this!

Your observation is technically correct — for a correctly implemented pure function, calling it twice with the same receiver will always return the same value, so the condition is always false.

However, we'd like to keep these determinism checks as regression guards. They protect against future changes that might accidentally introduce non-determinism (e.g., iterating over a map without sorting keys, inadvertently using timestamps, etc.). The cost of keeping them is essentially zero, but they provide a safety net if the underlying implementation ever changes.

These kinds of invariant tests are common in projects where correctness of hash/digest functions is critical — their value lies not in catching bugs today, but in catching regressions tomorrow.

Thanks again for the thoughtful review of our test code!

@wu21-web

wu21-web commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the explaination @lizhengfeng101 . I think the author meant this maybe:

a1 := New(baseArgs)
a2 := New(baseArgs)
if a1.runtimeConfigSHA256() != a2.runtimeConfigSHA256() {
    t.Fatal("runtimeConfigSHA256 is not deterministic")
}

and for L44-L46 it is the same idea
This would actually verify that two independently constructed but equivalent agents produce the same hash. the current version is dead code that can never run.

@wu21-web

Copy link
Copy Markdown
Contributor Author

changes.patch
I pushed a new fix to this branch, and here is a portable .patch file for you to review

@wu21-web wu21-web changed the title fix: invalid if statement tests in manifest_hash_test.go refactor: fix determinism tests in manifest_hash_test Aug 10, 2026
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