Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Schedule friendly format comments (e.g., # Friendly format: daily (scattered)) were appearing randomly in compiled workflows due to pointer address collisions across compilations.

Root Cause

The global scheduleFriendlyFormats map used frontmatter pointer addresses as keys via fmt.Sprintf("%p", frontmatter). When Go's memory allocator reused addresses, workflows retrieved formats from previous compilations:

// BAD: Global state with pointer-based keys
var scheduleFriendlyFormats = make(map[string]map[int]string)
friendlyFormatsKey := fmt.Sprintf("%p", frontmatter)
scheduleFriendlyFormats[friendlyFormatsKey] = formats

Changes

Move to per-compiler instance storage:

  • Added scheduleFriendlyFormats map[int]string field to Compiler struct
  • Reset c.scheduleFriendlyFormats = nil at compilation start
  • Removed global variable and pointer-based key logic
// GOOD: Per-compilation instance state
type Compiler struct {
    // ...
    scheduleFriendlyFormats map[int]string
}

func (c *Compiler) CompileWorkflowData(...) error {
    c.scheduleFriendlyFormats = nil  // Reset per compilation
    // ...
}

Added determinism test:

  • TestFriendlyFormatDeterminism validates no cross-compilation leakage
Original prompt

Investigate why this change happens random in compilation:

  # Friendly format: daily (scattered)

See https://github.com/githubnext/gh-aw/pull/11368/changes


💡 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.

Copilot AI and others added 2 commits January 22, 2026 18:34
Store schedule friendly formats in Compiler instance instead of global variable to prevent non-deterministic behavior across compilations

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 [WIP] Investigate random compilation change Fix non-deterministic schedule friendly format comments in compiled workflows Jan 22, 2026
Copilot AI requested a review from pelikhan January 22, 2026 18:43
@pelikhan pelikhan marked this pull request as ready for review January 22, 2026 19:20
@pelikhan pelikhan merged commit 0035eba into main Jan 22, 2026
49 checks passed
@pelikhan pelikhan deleted the copilot/investigate-compilation-issue branch January 22, 2026 19:26
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