Skip to content

Merge imported cache configuration into compiled workflows - #78857

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-cache-frontmatter-dropping
Nov 18, 2026
Merged

pelikhan merged 3 commits into
mainfrom
copilot/fix-cache-frontmatter-dropping

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Imported cache: frontmatter was collected but never applied, so workflows silently omitted cache steps and could retain a read-only cache policy. This change wires imported cache entries into workflow compilation.

  • Merge semantics: Append imported entries in discovery order, followed by entries from the importing workflow.
  • Documentation: Add cache: to the supported import fields and describe its merge order.
# shared/cache.md
---
cache:
  key: probe-${{ runner.os }}-v1
  path:
    - ~/probe-dir
---
# imported workflow
---
imports:
  - shared/cache.md
---

The imported cache configuration now generates cache steps and informs the cache-write policy.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@pelikhan pelikhan changed the title [WIP] Fix imported cache frontmatter being dropped silently Merge imported cache configuration into compiled workflows Nov 18, 2026
Copilot stopped work on behalf of pelikhan due to an error November 18, 2026 00:27
@pelikhan
pelikhan marked this pull request as ready for review November 18, 2026 00:31
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 00:31
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.5K · ◷

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #78857 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 185 · ◷

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #78857 · copilot · gpt56 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.7K · ◷

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What this change does: Imported cache entries are combined with the main workflow cache. The compiled workflow then uses the combined configuration for cache steps and policy.

Should fix

  1. Reuse the existing JSON decoder, as noted inline.

Verdict: Ship.
Lean: -16 lines possible.

Generated by ✂️ Ponytail Reviewer for #78857 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 185
Comment /ponytail to run again

return nil
}

func decodeCacheConfig(source string) (any, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should fix 1: This repeats the single-value JSON decoding already in pkg/jsonutil/json.go; call jsonutil.UnmarshalString directly here and delete this helper so both callers share the same checks and there is less code to maintain.

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (>100 new lines in pkg/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/78857-merge-imported-cache-configuration.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff

  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered. Unverified claims are marked [TODO: verify].

  3. Commit the finalized ADR to docs/adr/ on your branch

  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-78857: Merge Imported Cache Configuration into Compiled Workflows (link unavailable: invalid HTTPS URL)

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 8.6K · ◷
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-a2da4e66-e3e8-4398-b4ea-707c3ba645c8","parents":[],"payload":{"id":"ldg-678b790e-e69d-4e4e-a5e2-1b48e4044785","operation":"append","value":{"finding_count":0,"head_sha":"bb498c2d05417341577056ca95a548880b5593c0","outcome":"aligned"}},"sha":"sha256:c3bf7cbb1796461c03940c2365bf14a93390b75bf24a3f271dd56bd7345cb0e7","timestamp":"2026-11-18T00:39:43.517Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-18T00:34:26Z
review_event: REQUEST_CHANGES
top_themes:
  - empty imported cache declarations cause compilation failure
files_reviewed:
  - pkg/workflow/cache_import_merge.go
  - pkg/workflow/cache_import_test.go
  - pkg/workflow/compiler_orchestrator_workflow.go
  - pkg/parser/import_extract_steps.go
  - pkg/workflow/cache_steps.go
comment_count: 1
History

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.5K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Found one blocking regression: imported workflows with an empty cache: declaration now fail compilation because JSON null is rejected instead of being ignored. Please handle null/empty imported cache configurations and add coverage.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again


func decodeCacheConfig(source string) (any, error) {
decoder := json.NewDecoder(strings.NewReader(source))
var config, trailing any

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

An imported workflow with an empty cache: key is serialized by appendCacheField as JSON null (it only filters {}). decodeCacheConfig returns a nil value and appendCacheConfig then errors, so adding this merge path turns previously ignored empty cache declarations into compilation failures. Treat nil/null as an empty configuration (and add a regression test) before appending.

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-c09e2042-c640-4aeb-8b87-c01189a396ff","parents":[],"payload":{"id":"ldg-6c709994-ce60-4beb-b02a-1ae93c9ddb86","operation":"append","value":{"finding_count":1,"head_sha":"bb498c2d05417341577056ca95a548880b5593c0","outcome":"findings"}},"sha":"sha256:fc8c6aa4c41fb1e83860b2f7b3d5c8486e95207e9561e563581d473969989e02","timestamp":"2026-11-18T00:41:32.698Z","type":"ledger_append","version":1}
History

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd (triage: bug_fix). Requesting changes for one correctness bug and one test gap.

📋 Key Themes & Highlights

Key Themes

  • Numeric cache values are corrupted on the imported path. decodeCacheConfig loses number precision, so upload-chunk-size: 8388608 compiles to 8.388608e+06. The main-workflow path renders it correctly. Use decoder.UseNumber(). I verified this locally.
  • Merge order is untested. The docs promise discovery order, then main entries, but the test only checks that the entries exist.
  • Nit: decodeCacheConfig duplicates jsonutil.UnmarshalString, which this package already uses for the same single-value check. Reusing it would keep the trailing-data handling in one place.

Positive Highlights

  • ✅ Merge is append-only and the main cache: replaces workflowData.Cache rather than duplicating it.
  • ✅ Empty and absent cache inputs are short-circuited.
  • ✅ Regression test covers the real bug (cache-mode: read no longer forced) and passes.
  • ✅ Docs updated in both the field list and the merge table.

Investigation was bounded to the diff and the cache/import call paths. I did not evaluate the buildInitialWorkflowData path beyond confirming it does not handle caches.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

}

func decodeCacheConfig(source string) (any, error) {
decoder := json.NewDecoder(strings.NewReader(source))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] Numeric imported cache values are corrupted. decodeCacheConfig uses default encoding/json decoding, which turns numbers into float64. So upload-chunk-size: 8388608 compiles to upload-chunk-size: 8.388608e+06, while the main-workflow path renders 8388608 correctly. Calling decoder.UseNumber() keeps the original literal. I confirmed this fix locally.

💡 Suggested change
decoder := json.NewDecoder(strings.NewReader(source))
decoder.UseNumber()

Also add upload-chunk-size: 8388608 to the test fixture and assert the rendered value.

@copilot please address this.

if !strings.Contains(lock, "key: probe-${{ runner.os }}-v1") {
t.Error("compiled workflow is missing the imported cache key")
}
if !strings.Contains(lock, "key: local-${{ runner.os }}-v1") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/tdd] The test does not check the merge order the docs now promise: imported entries in discovery order, then main workflow entries. The current order is correct, but nothing guards it, so a future change could silently reorder the steps.

💡 Suggested test

Assert that strings.Index(lock, "key: probe-") and strings.Index(lock, "key: local-") are both non-negative and that the probe index is smaller. Extend the fixture with a second imported file to cover discovery order between imports.

@copilot please address this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Imported chunk sizes are serialized in scientific notation and misparsed as 3 bytes, potentially making uploads impractical, while tests miss import-only behavior and cache ordering.

2 open issues
What changed in this PR

This PR wires imported cache: configuration into gh-aw compilation so shared dependency caches generate GitHub Actions steps and inform the agent job’s cache-write policy.

Changes:

  • Merge imported cache entries in discovery order, followed by local entries.
  • Add a compilation test covering imported and local caches together.
  • Document cache import support and merge ordering.
File Description
pkg/​workflow/​compiler_orchestrator_workflow.go Applies collected cache imports during workflow configuration merging.
pkg/​workflow/​cache_import_test.go Checks generated cache steps, keys, and cache-write policy.
pkg/​workflow/​cache_import_merge.go Decodes, combines, and renders imported and local cache configurations.
docs/​src/​content/​docs/​reference/​imports.md Documents supported cache imports and their merge order.

Review effort: Max (adaptive)

Comment on lines +41 to +42
decoder := json.NewDecoder(strings.NewReader(source))
var config, trailing any
Comment on lines +74 to +76
if strings.Contains(lock, "cache-mode: read") {
t.Error("agent job should not remain read-only when a dependency cache is configured")
}
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/cache_import_merge.go:40): address unresolved feedback - Review comment
  3. Review (pkg/workflow/cache_import_merge.go:42): address unresolved feedback - Review comment
  4. Review (pkg/workflow/cache_import_merge.go:41): address unresolved feedback - Review comment
  5. Review (pkg/workflow/cache_import_test.go:71): address unresolved feedback - Review comment
  6. Review (pkg/workflow/cache_import_merge.go:42): address unresolved feedback - Review comment
  7. Review (pkg/workflow/cache_import_test.go:76): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "09f28ebb1cd236a052300010b1393062a1e955e2",
  "kind": "requested",
  "schema_version": "1",
  "state": "ede1c50dc3c4fb53525d88f80cdc995541905823bd87dcf1cb4bc1418b12e778",
  "work": [
    "43d0897f9798d614a50cf53d69aaf3fa630f7de08101eece74ecf1be1543920e",
    "573b04aa7fc2a05d2eb706ce891333db2d231886fed3b3bc328f16c84b0f7360",
    "84e3d913e817c1ef66a878f2e751820f4bb5471e3729b2df7ba0ce0125693ed0",
    "85ac6b4dad1970279df7438373e6b8aa9ac94999a1ce8800b8335e39434adaa5",
    "a0c1b49f6134424d9ed514bb2ca32f690697fb21202f5b463b752b6b0f32aa49",
    "a8df0ed8c5c77c7e25ce136e98d44404598a32556a781bc23f6050bb48ecd733"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

@pelikhan
pelikhan merged commit 68df009 into main Nov 18, 2026
52 of 53 checks passed
@pelikhan
pelikhan deleted the copilot/fix-cache-frontmatter-dropping branch November 18, 2026 01:50
Copilot stopped work on behalf of gh-aw-bot due to an error November 18, 2026 01:50
Copilot AI requested a review from gh-aw-bot November 18, 2026 01:50
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.1

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.

Imported cache: frontmatter is silently dropped; agent job keeps cache-mode: read

4 participants