Objective
Reorder step emission in the compiler so that `cache-memory` and `repo-memory` restore steps run before the user's frontmatter `steps:` block in the compiled agent job. This allows deterministic `steps:` code to read memory without requiring an LLM turn.
Context
Issue #43924 identifies that all three memory stores are currently materialized after custom user steps run. In `pkg/workflow/compiler_yaml_main_job.go`, the function `generateRuntimeAndWorkspaceSetupSteps` calls `emitCustomSteps` (line 227) before `generateCacheMemorySteps` (line 235) and `generateRepoMemorySteps` (line 239).
This means a frontmatter `steps:` block reads empty `/tmp/gh-aw/cache-memory/` and `/tmp/gh-aw/repo-memory/` directories, forcing authors to duplicate state via raw `actions/cache`.
Implementation Plan
Implementation Plan
Files to Modify
- `pkg/workflow/compiler_yaml_main_job.go` — move `generateCacheMemorySteps` and `generateRepoMemorySteps` calls to before `emitCustomSteps`
- `pkg/workflow/compiler_yaml_main_job_test.go` (or new test file) — add tests verifying restore steps precede custom steps in generated YAML
Approach
- In `generateRuntimeAndWorkspaceSetupSteps`, move the `generateCacheMemorySteps(yaml, data)` and `generateRepoMemorySteps(yaml, data)` calls so they emit before the `c.emitCustomSteps(...)` call.
- Verify the DIFC proxy is already running by this point (it is — `generateStartDIFCProxyStep` runs before both custom steps and memory steps already), so memory restore steps can safely use `gh` if needed.
- Confirm that `generateCacheMemorySteps` / `generateRepoMemorySteps` have no dependencies on state set by custom steps (e.g., environment variables, checked-out code).
- Update or add tests in `pkg/workflow/cache_memory_syntax_test.go` and related files to assert the ordering of restore steps vs. custom steps in the generated YAML.
Expected step order after change
- Create gh-aw temp directory
- Configure gh CLI for GitHub Enterprise
- Start DIFC proxy (if applicable)
- cache-memory restore steps ← moved up
- repo-memory clone steps ← moved up
- User custom `steps:` block
- (rest of agent job...)
Acceptance Criteria
Generated by 📋 Plan Command · 79.6 AIC · ⌖ 11.7 AIC · ⊞ 4.7K · ◷
Comment /plan to run again
Objective
Reorder step emission in the compiler so that `cache-memory` and `repo-memory` restore steps run before the user's frontmatter `steps:` block in the compiled agent job. This allows deterministic `steps:` code to read memory without requiring an LLM turn.
Context
Issue #43924 identifies that all three memory stores are currently materialized after custom user steps run. In `pkg/workflow/compiler_yaml_main_job.go`, the function `generateRuntimeAndWorkspaceSetupSteps` calls `emitCustomSteps` (line 227) before `generateCacheMemorySteps` (line 235) and `generateRepoMemorySteps` (line 239).
This means a frontmatter `steps:` block reads empty `/tmp/gh-aw/cache-memory/` and `/tmp/gh-aw/repo-memory/` directories, forcing authors to duplicate state via raw `actions/cache`.
Implementation Plan
Implementation Plan
Files to Modify
Approach
Expected step order after change
Acceptance Criteria