Skip to content

Configuring frontmatter for bundled artifact folders - #50108

Merged
pelikhan merged 4 commits into
mainfrom
copilot/add-configure-additional-folders
Aug 4, 2026
Merged

Configuring frontmatter for bundled artifact folders#50108
pelikhan merged 4 commits into
mainfrom
copilot/add-configure-additional-folders

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Pull request created by AI Agent

Copilot AI and others added 2 commits August 3, 2026 22:39
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

pelikhan commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

@copilot review changes and finish work

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review changes and finish work

Reviewed the changes and pushed follow-up commit 5bb3e80 to restore ambient folders after custom checkout steps, with a regression test. Validation passed: make fmt, targeted parser/workflow tests, make recompile, make agent-report-progress, secret scan, and parallel validation.

@pelikhan
pelikhan marked this pull request as ready for review August 3, 2026 23:21
Copilot AI review requested due to automatic review settings August 3, 2026 23:21
Copilot AI requested a review from pelikhan August 3, 2026 23:21
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

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

🧪 Test Quality Sentinel Report

Test Quality Score: 80/100 — Excellent

Analyzed 3 test(s): 3 design, 0 implementation, 0 violation(s).

📊 Metrics (3 tests)
Metric Value
Analyzed 3 (Go: 3, JS: 0)
✅ Design 3 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 2 (67%)
Duplicate clusters 0
Inflation YES — import_field_extractor_test.go: 43 test lines / 10 prod lines ≈ 4.3:1
🚨 Violations 0
Test File Classification Issues
TestAmbientFoldersExtractedFromMdImport pkg/parser/import_field_extractor_test.go:248 design_test, high_value assert.Equal without descriptive failure message (minor)
TestAmbientFoldersIncludedInActivationArtifact pkg/workflow/compiler_artifacts_test.go:320 design_test, high_value Happy-path only
TestAmbientFoldersRestoredAfterCustomCheckout pkg/workflow/compiler_artifacts_test.go:386 design_test, high_value None
⚠️ Flagged Tests (1)

TestAmbientFoldersExtractedFromMdImport (pkg/parser/import_field_extractor_test.go:248) — The final assert.Equal lacks a descriptive failure message. Consider adding "ambient folders should be deduplicated and ordered" as the third argument.

Inflation note: import_field_extractor_test.go 4.3:1 ratio is above the 2:1 threshold, but the test covers non-trivial multi-import deduplication behavior — justified.

Verdict

passed. 0% implementation tests (threshold: 30%). Score 80/100 — Excellent. No guideline violations.

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

Review: Configuring frontmatter for bundled artifact folders

This PR introduces on.ambient-folders — a well-designed feature that replaces the previous squad-state artifact approach with a generic, reusable mechanism.

Correctness and security look solid:

  • Path validation in normalizeAmbientFolders uses filepath.Clean plus an allowlist regex (^[A-Za-z0-9._/-]+$) that prevents traversal, absolute paths, and whitespace-separated injection in the shell for loop.
  • Schema validation in main_workflow_schema.json mirrors the same constraints (pattern, not with absolute/traversal patterns).
  • Deduplication via ambientFoldersSet in the accumulator is correct and the union-over-imports semantics are clear.
  • The IsImportSafeSharedWorkflowOn helper correctly gates shared-workflow detection so a file with on: { ambient-folders: [...] } and no trigger is treated as a shared component.
  • Duplicate restore placement (once after artifact download, once after custom checkouts) is intentional and handled cleanly via postLastCheckoutSteps.
  • awf now excludes ACTIONS_ID_TOKEN_REQUEST_TOKEN / ACTIONS_ID_TOKEN_REQUEST_URL from container env — unrelated but a good hardening change.

Tests cover the key paths (import merging, artifact inclusion, custom-checkout ordering). No issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 45.6 AIC · ⌖ 7.53 AIC · ⊞ 5.4K

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.

Pull request overview

Adds import-safe on.ambient-folders configuration for transferring activation-generated folders into agent workspaces.

Changes:

  • Parses, validates, merges, and normalizes ambient-folder configuration.
  • Stages folders in the activation artifact and restores them after checkouts.
  • Migrates Squad state transfer to the shared activation artifact.
Show a summary per file
File Description
pkg/workflow/workflow_data.go Stores resolved ambient folders.
pkg/workflow/event_validation.go Allows the new on key.
pkg/workflow/compiler_yaml_runtime_setup.go Restores folders around custom checkouts.
pkg/workflow/compiler_yaml_ai_execution.go Restores folders after base content.
pkg/workflow/compiler_orchestrator_workflow.go Resolves ambient-folder configuration.
pkg/workflow/compiler_orchestrator_frontmatter.go Recognizes import-safe on blocks.
pkg/workflow/compiler_artifacts_test.go Tests artifact and checkout placement.
pkg/workflow/compiler_activation_outputs.go Stages and uploads ambient folders.
pkg/workflow/compiler_activation_job.go Adds folders to sparse checkout.
pkg/workflow/ambient_folders.go Implements validation, staging, and restoration.
pkg/parser/schemas/main_workflow_schema.json Defines the new schema property.
pkg/parser/schema_validation.go Allows ambient folders in shared workflows.
pkg/parser/import_processor.go Carries merged folder configuration.
pkg/parser/import_field_extractor.go Extracts folders from imports.
pkg/parser/import_field_extractor_test.go Tests imported-folder merging.
docs/src/content/docs/reference/imports.md Documents shared-component support.
docs/src/content/docs/reference/frontmatter.md Documents the frontmatter key.
.github/workflows/squad-game-planner.lock.yml Regenerates the compiled workflow.
.github/workflows/shared/squad.md Migrates Squad to ambient folders.

Review details

Tip

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

Suppressed comments (1)

pkg/workflow/ambient_folders.go:123

  • The restore script also relies on POSIX shell syntax but inherits the runner's default shell. On supported Windows runners this is parsed as PowerShell and fails before restoration; select Bash explicitly.
		"        run: |",
  • Files reviewed: 19/19 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment on lines +127 to +131
" if [ -e \"$src\" ]; then",
" mkdir -p \"$(dirname \"$dst\")\"",
" rm -rf \"$dst\"",
" cp -a \"$src\" \"$dst\"",
" fi",
Comment on lines +92 to +93
" # poutine:ignore untrusted_checkout_exec\n",
" run: |\n",
Comment on lines +68 to +70
if clean == "." || clean == ".." || strings.HasPrefix(clean, "../") || filepath.IsAbs(value) || strings.HasPrefix(value, "/") {
return nil, fmt.Errorf("on.ambient-folders entry %q must be a relative folder path within the repository", folder)
}
var sharedWorkflowForbiddenFields = buildForbiddenFieldsMap()

var sharedWorkflowAllowedOnFieldList = []string{
"ambient-folders",
Comment on lines +2057 to +2059
"ambient-folders": {
"type": "array",
"description": "Workspace-relative folders to bundle in the activation artifact and restore before the agent runs. Useful for activation steps that generate reusable prompt, skill, or agent context.",

@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 /codebase-design and /tdd — commenting on interface consistency and test coverage gaps.

📋 Key Themes & Highlights

Key Themes

  • Shell word-splitting invariantGH_AW_AMBIENT_FOLDERS is space-joined and iterated with an unquoted for loop. The path validator prevents spaces today, but the coupling is undocumented and fragile.
  • Asymmetric generator APIgenerateStageAmbientFoldersStep returns []string while generateRestoreAmbientFoldersStep writes to a strings.Builder, making the two harder to test and compose consistently.
  • IsImportSafeSharedWorkflowOn repurposing — the function is now used for shared-component detection as well as import safety, which conflates two separate responsibilities.
  • Test ordering not asserted — the artifact tests check presence but not ordering of stage/restore steps relative to upload/agent steps.

Positive Highlights

  • ✅ Clean new ambient_folders.go module — validation, normalization, and generation are well-separated.
  • ✅ Deduplication via seen set and proper filepath.Clean normalization.
  • ✅ Good test coverage for import merging (TestAmbientFoldersExtractedFromMdImport) and end-to-end compilation (TestAmbientFoldersIncludedInActivationArtifact).
  • ✅ Sparse-checkout correctly extended to include ambient folders so the activation job can access them.
  • ✅ Lock file and schema updated consistently with the implementation.
  • poutine:ignore untrusted_checkout_exec annotations present on shell steps.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 55.4 AIC · ⌖ 7.49 AIC · ⊞ 7.1K
Comment /matt to run again

Comments that could not be inline-anchored

pkg/workflow/ambient_folders.go:495

[/codebase-design] The shell loop for folder in $GH_AW_AMBIENT_FOLDERS word-splits on spaces — safe today because the regex ^[A-Za-z0-9._/-]+$ forbids them, but the coupling is implicit and fragile.

Add a comment near the pattern definition or the generated script to document why space-splitting is safe, so a future relaxation of the regex does not silently break path handling.

@copilot please address this.

pkg/workflow/ambient_folders.go:476

[/codebase-design] filepath.IsAbs(value) is checked alongside strings.HasPrefix(value, &quot;/&quot;). On Windows filepath.IsAbs also catches C:\... style paths, but the regex ^[A-Za-z0-9._/-]+$ already blocks : and \, making the IsAbs call redundant. Remove the duplicate check or add a comment explaining the dual guard is intentional for cross-platform safety.

@copilot please address this.

pkg/workflow/compiler_orchestrator_frontmatter.go:738

[/codebase-design] parser.IsImportSafeSharedWorkflowOn is called here to decide whether a file with an on: block should still be treated as a shared component. The function name "IsImportSafe" describes a different concept (can this on: block be safely merged via imports?) rather than "has no real trigger events". The dual meaning — import-safe fields vs. shared-component detection — may confuse future maintainers. Consider a dedicated predicate like onBlockContainsOnlySharedFields

pkg/workflow/compiler_artifacts_test.go:648

[/tdd] TestAmbientFoldersIncludedInActivationArtifact uses strings.Contains for all assertions. This makes the test pass even if the step appears in the wrong position (e.g., stage step after the upload). Consider asserting ordering: Stage ambient folders must appear before Upload activation artifact, and Restore ambient folders must appear before the agent execution step.

@copilot please address this.

pkg/workflow/ambient_folders.go:519

[/codebase-design] generateRestoreAmbientFoldersStep writes directly to a *strings.Builder while generateStageAmbientFoldersStep returns a []string. The asymmetry makes both functions harder to test in isolation and forces callers to use different patterns. Align them — either both return []string (like the stage variant) or both accept a builder. The restoreAmbientFoldersSteps helper already exists; generateRestoreAmbientFoldersStep could just loop over it the same way caller…

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate — ADR Required

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

Draft ADR committed: docs/adr/50108-ambient-folders-activation-artifact-bundling.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 could not infer, refine the decision rationale, and list real alternatives you considered
  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-50108: Ambient Folders — Frontmatter-Declared Folder Bundling in Activation Artifact

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

Why ADRs Matter

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 (e.g., 50108-ambient-folders-activation-artifact-bundling.md for PR #50108).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 63.1 AIC · ⌖ 30.3 AIC · ⊞ 9.6K ·
Comment /review to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot PR #50108 still needs follow-up before a maintainer can investigate quickly. Please address these unresolved review items first, newest first:

Please refresh the branch if needed, resolve the open review feedback, rerun make fmt, make recompile, and the relevant tests, then use the pr-finisher skill to close out the PR cleanly.

Run: https://github.com/github/gh-aw/actions/runs/30862559128

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 5.1 AIC · ⌖ 6.97 AIC · ⊞ 8.3K ·
Comment /souschef to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot PR #50108 still needs follow-up before a maintainer can investigate quickly. Please address these unresolved review items first, newest first:

Please refresh the branch if needed, resolve the open review feedback, rerun make fmt, make recompile, and the relevant tests, then use the pr-finisher skill to close out the PR cleanly.

Run: https://github.com/github/gh-aw/actions/runs/30864142711

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 5 AIC · ⌖ 5.05 AIC · ⊞ 8.3K ·
Comment /souschef to run again

GH_AW_AMBIENT_FOLDERS: ".squad .github/agents"
# poutine:ignore untrusted_checkout_exec
run: |
mkdir -p /tmp/gh-aw/ambient-folders

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot refactor to shell script file in actions/setup/sh

GH_AW_AMBIENT_FOLDERS: ".squad .github/agents"
# poutine:ignore untrusted_checkout_exec
run: |
for folder in $GH_AW_AMBIENT_FOLDERS; do

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot refactor into shell script file in actions/setup/sh

Copilot AI requested a review from pelikhan August 4, 2026 00:18
@pelikhan
pelikhan merged commit c1ce184 into main Aug 4, 2026
32 checks passed
@pelikhan
pelikhan deleted the copilot/add-configure-additional-folders branch August 4, 2026 00:21
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.4

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.

4 participants