Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

Remove Version Numbers from Frontmatter Hash Computation

Per @pelikhan's request, removed all version numbers from the frontmatter hash computation in both Go and JavaScript implementations.

Changes Made

Go (pkg/parser/frontmatter_hash.go):

  • Removed buildVersionInfo() function
  • Removed canonical["versions"] = buildVersionInfo() calls (2 locations)
  • Removed compilerVersion and isReleaseVersion variables
  • Removed SetCompilerVersion() and SetIsRelease() functions
  • Removed unused constants package import
  • Added marshalJSONWithoutHTMLEscape() helper to match JavaScript JSON encoding behavior
  • Fixed HTML escaping inconsistency (Go was escaping <, >, & but JavaScript was not)

JavaScript (actions/setup/js/frontmatter_hash_pure.cjs):

  • Removed VERSIONS constant
  • Removed canonical.versions = VERSIONS assignment

Main Entry Point (cmd/gh-aw/main.go):

  • Removed calls to parser.SetCompilerVersion() and parser.SetIsRelease()
  • Removed unused parser package import

Tests:

  • Updated frontmatter_hash_stability_test.go to remove version-checking logic
  • Updated frontmatter_hash_test_main_test.go to remove version setup
  • Simplified test assertions to focus on hash consistency

Workflows:

  • Recompiled all 148 workflow lock files with new hash computation (without version information)

Root Cause of Hash Mismatches

The test failures were caused by a subtle difference in JSON encoding between Go and JavaScript:

  • Go's json.Marshal: Escapes HTML characters (<\u003c, >\u003e, &\u0026)
  • JavaScript's JSON.stringify: Does NOT escape HTML characters

This caused different canonical JSON representations for workflows containing <, >, or & in their frontmatter (e.g., comments like <1000 words), resulting in different hashes.

Solution

Created marshalJSONWithoutHTMLEscape() helper function that uses json.NewEncoder with SetEscapeHTML(false) to match JavaScript's behavior.

Impact

  • Frontmatter hashes will no longer change when firewall, gateway, or compiler versions are updated
  • Hashes now only change when actual frontmatter content changes
  • Go and JavaScript implementations produce identical hashes for all workflows

Testing

  • TestHashConsistency_KeyOrdering passes

  • TestHashConsistencyAcrossLockFiles passes (all 148 workflows)

  • TestGoJSHashStability passes (all 10 workflows tested)

  • ✅ All parser package tests pass

  • Remove version information from Go hash computation

  • Remove version information from JavaScript hash computation

  • Remove unused version-related functions and variables

  • Update tests

  • Recompile all workflow lock files

  • Fix HTML escaping inconsistency between Go and JavaScript

  • Verify all tests pass

Original prompt

Reference: https://github.com/githubnext/gh-aw/actions/runs/21572327597/job/62153393733#step:8:1

Review test log and fix tests


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

….0.88

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tests based on review log analysis Fix hash consistency test by syncing MCP gateway version constants Feb 1, 2026
@pelikhan
Copy link
Contributor

pelikhan commented Feb 1, 2026

@copilot remove all version numbers from the frontmatter hash compiattion. In go and JavaScript .

- Removed version information from hash computation in both Go and JavaScript
- Removed buildVersionInfo function and VERSIONS constant
- Removed SetCompilerVersion and SetIsRelease functions
- Updated tests to not check for version information
- Recompiled all workflow lock files with new hash computation

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot remove all version numbers from the frontmatter hash compiattion. In go and JavaScript .

Removed all version numbers from frontmatter hash computation in both Go and JavaScript. Changes include:

  • Removed buildVersionInfo(), VERSIONS constant, and version-related functions
  • Recompiled all 148 workflow lock files with new hash computation (commit 0a3f622)

Currently investigating hash consistency test failures between Go and JS implementations for certain workflows. The hash computation is working correctly (TestHashConsistencyAcrossLockFiles passes), but TestGoJSHashStability shows mismatches for some workflows. Will debug and fix in next commit.

Copilot AI changed the title Fix hash consistency test by syncing MCP gateway version constants Remove version numbers from frontmatter hash computation Feb 2, 2026
@pelikhan pelikhan marked this pull request as ready for review February 2, 2026 00:06
@pelikhan
Copy link
Contributor

pelikhan commented Feb 2, 2026

@copilot investigate tear failures

…haling

Go's json.Marshal escapes <, >, & to \u003c, \u003e, \u0026 for HTML safety, while JavaScript's JSON.stringify does not. This caused hash mismatches for workflows with these characters in frontmatter.

Solution: Use json.NewEncoder with SetEscapeHTML(false) to match JavaScript behavior.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot investigate tear failures

Fixed the test failures. The issue was HTML escaping inconsistency between Go and JavaScript:

  • Root cause: Go's json.Marshal escapes <, >, & to \u003c, \u003e, \u0026 while JavaScript's JSON.stringify does not
  • Solution: Added marshalJSONWithoutHTMLEscape() helper using json.NewEncoder with SetEscapeHTML(false) to match JavaScript behavior
  • Affected workflows: Those with <, >, or & in frontmatter (e.g., <1000 words in comments)

All tests now pass:

  • ✅ TestHashConsistency_KeyOrdering
  • ✅ TestHashConsistencyAcrossLockFiles (148 workflows)
  • ✅ TestGoJSHashStability (10 workflows)
  • ✅ All parser tests pass

Commit: 47e72b0

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

🔍 PR Triage Results

Category: bug | Risk: medium | Priority: 75/100

Scores Breakdown

  • Impact: 45/50 - Fixes critical hash consistency issue between Go and JavaScript implementations
  • Urgency: 20/30 - High - affects workflow reliability and change detection accuracy
  • Quality: 10/20 - Fair - ready for review, comprehensive testing, CI pending

📋 Recommended Action: fast-track

Top priority fix - Resolves hash mismatch caused by HTML escaping differences (Go's json.Marshal escapes <>& but JavaScript's JSON.stringify doesn't). The fix also removes version numbers from hash computation, so hashes only change when actual frontmatter changes.

All 148 workflow hash tests now pass. Ready for immediate review.


Triaged by PR Triage Agent on 2026-02-02

AI generated by PR Triage Agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants