Skip to content

Add regression coverage for frontmatter hash parity in OTLP setup metadata#32223

Merged
pelikhan merged 8 commits into
mainfrom
copilot/validate-otlp-frontmatter
May 15, 2026
Merged

Add regression coverage for frontmatter hash parity in OTLP setup metadata#32223
pelikhan merged 8 commits into
mainfrom
copilot/validate-otlp-frontmatter

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

Bug Fix

The lock header metadata (gh-aw-metadata.frontmatter_hash) and setup-time OTLP frontmatter hash env (GH_AW_INFO_FRONTMATTER_HASH) can drift, which undermines telemetry correlation stability. This change adds compiler-level regression coverage to enforce parity with the source frontmatter hash.

  • What was the bug?

    • Frontmatter hash used in OTLP setup attributes could differ from the hash recorded in the lock file header comment.
    • The observed lock diff showed GH_AW_INFO_FRONTMATTER_HASH changing independently, creating ambiguity about canonical hash provenance.
  • How did you fix it?

    • Added TestFrontmatterHashParity in pkg/workflow/aw_info_tmp_test.go.
    • The test compiles a workflow, parses lock metadata, extracts GH_AW_INFO_FRONTMATTER_HASH from generated YAML, and asserts:
      • setup env hash == lock header frontmatter_hash
      • lock header frontmatter_hash == recomputed source frontmatter hash
    • Added a focused regex helper for deterministic extraction of GH_AW_INFO_FRONTMATTER_HASH from lock content.
  • Testing

    • Added a regression test that fails on any hash mismatch across setup env, lock metadata header, and source frontmatter computation.
metadata, _, err := ExtractMetadataFromLockFile(lockStr)
matches := awInfoFrontmatterHashRe.FindStringSubmatch(lockStr)
expectedHash, err := parser.ComputeFrontmatterHashFromFile(testFile, parser.NewImportCache(tmpDir))

require.Equal(t, metadata.FrontmatterHash, matches[1])
require.Equal(t, expectedHash, metadata.FrontmatterHash)

Copilot AI and others added 4 commits May 14, 2026 22:09
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Validate frontmatter hash parity for OTLP setup metadata Add regression coverage for frontmatter hash parity in OTLP setup metadata May 14, 2026
Copilot AI requested a review from pelikhan May 14, 2026 22:13
@pelikhan pelikhan marked this pull request as ready for review May 14, 2026 22:58
Copilot AI review requested due to automatic review settings May 14, 2026 22:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a regression test in pkg/workflow/aw_info_tmp_test.go to enforce parity between the frontmatter_hash recorded in the lock-file header metadata, the GH_AW_INFO_FRONTMATTER_HASH value embedded in the generated YAML's setup env, and the hash recomputed from the workflow source.

Changes:

  • Adds a package-level regex awInfoFrontmatterHashRe to deterministically extract the GH_AW_INFO_FRONTMATTER_HASH env value from lock file content.
  • Adds TestFrontmatterHashParity which compiles a workflow, parses lock metadata via ExtractMetadataFromLockFile, and asserts three-way equality with parser.ComputeFrontmatterHashFromFile.
  • Imports parser, regexp, and testify/require to support the new assertions.
Show a summary per file
File Description
pkg/workflow/aw_info_tmp_test.go Adds regex helper and TestFrontmatterHashParity to guard against drift between the setup env hash, lock metadata hash, and source-computed frontmatter hash.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot remove frontmatter.hash from the otlp attributes

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

Copilot AI commented May 14, 2026

@copilot remove frontmatter.hash from the otlp attributes

Implemented in 08fcd2d: removed gh-aw.frontmatter.hash from OTLP setup/conclusion span attributes, updated OTLP JS tests accordingly, and removed the frontmatter-hash parity regression test from aw_info_tmp_test.go.

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot remove GH_AW_INFO_FRONTMATTER_HASH

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

Copilot AI commented May 14, 2026

@copilot remove GH_AW_INFO_FRONTMATTER_HASH

Implemented in 985d15f: removed GH_AW_INFO_FRONTMATTER_HASH from compiler-generated workflow env, setup step generation, and generate_aw_info.cjs, and updated related Go/JS tests.

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

Copilot AI and others added 2 commits May 15, 2026 00:03
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…-frontmatter

# Conflicts:
#	.github/workflows/jsweep.lock.yml

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan merged commit d26a6f4 into main May 15, 2026
@pelikhan pelikhan deleted the copilot/validate-otlp-frontmatter branch May 15, 2026 00:12
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.

3 participants