Skip to content

fix: use frontmatter hash instead of mtime to determine compiled status in gh aw list#25364

Merged
pelikhan merged 4 commits intomainfrom
copilot/fix-gh-aw-list-compiled-false-positive
Apr 8, 2026
Merged

fix: use frontmatter hash instead of mtime to determine compiled status in gh aw list#25364
pelikhan merged 4 commits intomainfrom
copilot/fix-gh-aw-list-compiled-false-positive

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

gh aw list falsely reported Compiled: No after every git clone or git checkout because git writes .lock.yml before .md alphabetically, making the source file appear newer by a few nanoseconds.

Change

Replaced the mtime comparison in list_workflows_command.go with a content-based frontmatter hash check (matching the logic used by gh aw status), which compares the frontmatter_hash embedded in the lock file's metadata against a freshly computed hash of the source frontmatter.

// Before — unreliable after git checkout
if mdStat.ModTime().After(lockStat.ModTime()) {
    compiled = "No"
} else {
    compiled = "Yes"
}

// After — content-based, timestamp-independent
compiled = isCompiledUpToDateWithCache(file, lockFile, importCache)

A shared parser.ImportCache is created once before the loop and reused across all workflow iterations to avoid redundant allocations when listing many workflows.

Legacy lock files without a frontmatter_hash fall back to "Yes" to avoid false negatives.

Testing

Added TestRunListWorkflows_CompiledField which creates a temp workflow + lock file and asserts the JSON output reports compiled: Yes (matching hash), No (mismatched hash), and N/A (no lock file), directly validating the wiring in the list command.

@github-actions github-actions bot mentioned this pull request Apr 8, 2026
Fixes false positive 'Compiled: No' after git clone/checkout.
The mtime comparison was unreliable because git writes .lock.yml before
.md during checkout, making .md appear newer. Now uses the same
hash-based isCompiledUpToDate() check already used in status_command.go.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/089481e9-f9fd-4391-aaee-f644fe18cb13

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix gh aw list compiled false positive after git checkout fix: use frontmatter hash instead of mtime to determine compiled status in gh aw list Apr 8, 2026
Copilot AI requested a review from pelikhan April 8, 2026 18:47
@pelikhan pelikhan marked this pull request as ready for review April 8, 2026 18:48
Copilot AI review requested due to automatic review settings April 8, 2026 18:48
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

This PR fixes gh aw list incorrectly reporting workflows as not compiled after git clone/checkout by switching compiled-status detection from timestamp comparisons to a content-based frontmatter hash check (matching the logic used by gh aw status). It also updates several generated workflow lock files with safer shell quoting (and related regenerated metadata).

Changes:

  • Replace mtime-based compiled detection in gh aw list with isCompiledUpToDate (frontmatter-hash based).
  • Regenerate/adjust multiple .lock.yml workflows to consistently quote ${RUNNER_TEMP} script paths (and refresh generated prompt/config markers).
  • Update deep-report.lock.yml metadata and environment wiring as part of regeneration.
Show a summary per file
File Description
pkg/cli/list_workflows_command.go Uses hash-based isCompiledUpToDate to make compiled status stable across git operations.
.github/workflows/refactoring-cadence.lock.yml Quotes ${RUNNER_TEMP} script paths for safer execution; regenerated lock content.
.github/workflows/design-decision-gate.lock.yml Same quoting/regeneration updates in the lock workflow.
.github/workflows/deep-report.lock.yml Regenerated lock content (metadata hash/prompt markers) and updated env wiring.
.github/workflows/architecture-guardian.lock.yml Same quoting/regeneration updates in the lock workflow.
.github/workflows/approach-validator.lock.yml Same quoting/regeneration updates in the lock workflow.

Copilot's findings

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment on lines 163 to 165
if _, err := os.Stat(lockFile); err == nil {
// Check if up to date
mdStat, _ := os.Stat(file)
lockStat, _ := os.Stat(lockFile)
if mdStat.ModTime().After(lockStat.ModTime()) {
compiled = "No"
} else {
compiled = "Yes"
}
compiled = isCompiledUpToDate(file, lockFile)
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Calling isCompiledUpToDate here computes a frontmatter hash by re-reading/parsing the workflow file (and creating a new import cache) even though this loop already reads the same file content immediately afterward to extract frontmatter fields. If this command can list many workflows, consider refactoring to reuse the existing read content and/or a shared parser.ImportCache across iterations to avoid redundant IO/parsing.

Copilot uses AI. Check for mistakes.
Comment on lines 163 to 165
if _, err := os.Stat(lockFile); err == nil {
// Check if up to date
mdStat, _ := os.Stat(file)
lockStat, _ := os.Stat(lockFile)
if mdStat.ModTime().After(lockStat.ModTime()) {
compiled = "No"
} else {
compiled = "Yes"
}
compiled = isCompiledUpToDate(file, lockFile)
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Compiled status for gh aw list is now driven by isCompiledUpToDate. The hash comparison logic is unit-tested, but the list command tests currently only assert “no error” and don’t validate the compiled field. Consider adding a focused test that creates a temp workflow markdown + lock file and asserts the JSON output reports compiled: Yes/No as expected, to cover the wiring in this command.

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 8, 2026

@copilot review comments

… test

- Add isCompiledUpToDateWithCache to avoid creating a new ImportCache per
  workflow when listing many workflows
- Use the shared cache in list_workflows_command.go
- Add TestRunListWorkflows_CompiledField to verify Yes/No/N/A compiled output

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d0cb1fc-c323-4304-8a8e-69f93171f29a

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

Copilot AI commented Apr 8, 2026

@copilot review comments

Addressed both reviewer comments in 17e6554:

  1. Shared ImportCache: Added isCompiledUpToDateWithCache in status_command.go that accepts a *parser.ImportCache. The list command now creates one cache before the loop and passes it to each isCompiledUpToDateWithCache call, avoiding a new allocation per workflow.

  2. Compiled field test: Added TestRunListWorkflows_CompiledField in list_workflows_command_test.go that creates a temp workflow + lock file and verifies the JSON output reports compiled: Yes (matching hash), No (mismatched hash), and N/A (no lock file).

@pelikhan pelikhan merged commit 3b669e3 into main Apr 8, 2026
84 of 85 checks passed
@pelikhan pelikhan deleted the copilot/fix-gh-aw-list-compiled-false-positive branch April 8, 2026 19:32
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.

gh aw list: 'Compiled: No' false positive after git checkout due to mtime comparison

3 participants