Skip to content

Remove imports.if and migrate experiment-driven import usage to runtime imports - #38247

Merged
pelikhan merged 8 commits into
mainfrom
copilot/remove-support-for-imports
Jun 10, 2026
Merged

Remove imports.if and migrate experiment-driven import usage to runtime imports#38247
pelikhan merged 8 commits into
mainfrom
copilot/remove-support-for-imports

Conversation

CopilotAI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Conditional frontmatter imports were allowing experiment state to change imported setup and prompt material at runtime. This removes imports.if so imports remain security-stable, and moves the active experiment usage to body-level runtime imports instead.

  • Parser and schema

    • Remove if from imports / imports.aw schema variants.
    • Reject imports.if during parsing with a migration-oriented error pointing to {{#runtime-import? ...}}.
    • Drop import-processing paths that propagated import conditions into nested imports, step guards, and prompt assembly.
  • Prompt assembly

    • Simplify PromptImportEntry to ordered runtime/inlined import content only.
    • Remove prompt-time wrapping of imported content with generated {{#if ...}} blocks.
  • Workflow migration

    • Update daily-safe-output-optimizer to keep setup imports unconditional.
    • Split the old shared import into:
      • shared/aw-logs-24h-fetch-setup.md for setup-time behavior
      • shared/aw-logs-24h-fetch-prompt.md for prompt text
    • Gate only the prompt content with {{#if experiments...}} + {{#runtime-import? ...}} (optional form, not promoted to unconditional lock-file macros).
  • Docs and compatibility guidance

    • Document that conditional frontmatter imports are unsupported.
    • Point experiment-driven prompt variation to {{#runtime-import? ...}} (optional form) instead of the required form, so gated content is only injected when the condition is true at runtime.
    • Add a major changeset for the breaking frontmatter change.
# beforeimports:
- if: experiments.log_fetch_strategy == 'eager'uses: shared/aw-logs-24h-fetch.md# afterimports:
- uses: shared/aw-logs-24h-fetch-setup.md
{{#if experiments.log_fetch_strategy == "eager"}}
{{#runtime-import? shared/aw-logs-24h-fetch-prompt.md}}
{{else}}
Use the MCP tools directly for log collection.
{{/if}}

CopilotAIand others added 2 commits June 10, 2026 00:17
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review June 10, 2026 01:11
CopilotAI review requested due to automatic review settings June 10, 2026 01:11
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

CopilotAI 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

This PR removes support for conditional frontmatter imports (imports.if) to keep workflow setup/import graphs security-stable, and migrates experiment-driven prompt variation to runtime-import usage in the workflow body. It updates the parser/schema/compiler paths to drop condition propagation into prompt assembly and step injection, and adds documentation + a major changeset for the breaking change.

Changes:

  • Remove imports.if from schema/types and delete compiler/parser logic that wrapped imported prompt content or injected step-level if guards from import specs.
  • Add a migration-oriented parse error when imports.if is encountered and update docs to direct users toward runtime-import-based prompt variation.
  • Migrate daily-safe-output-optimizer by splitting the prior shared import into setup-only vs prompt-only files and gating prompt text via template conditionals.
Show a summary per file
FileDescription
pkg/workflow/compiler_yaml.goRemoves prompt-time {{#if ...}} wrapping for import entries and drops condition normalization used only for imports.if.
pkg/workflow/compiler_yaml_test.goRemoves unit test for the deleted condition-normalization helper.
pkg/parser/schemas/main_workflow_schema.jsonRemoves if from the imports/imports.aw object forms in the JSON schema.
pkg/parser/import_remote.goRemoves ifCondition from the import queue item struct.
pkg/parser/import_processor.goRemoves If from PromptImportEntry and ImportSpec to simplify ordered prompt import contributions.
pkg/parser/import_field_extractor.goRemoves conditional step-guard injection plumbing and simplifies prompt import tracking to runtime/inlined content only.
pkg/parser/import_field_extractor_test.goRemoves tests for step-level if injection behavior.
pkg/parser/import_bfs.goRejects import 'if' in import specs and removes if-condition conflict/propagation logic in BFS traversal.
pkg/parser/import_bfs_test.goUpdates tests to expect imports.if rejection and removes tests that depended on inherited/imported if behavior.
docs/src/content/docs/reference/imports.mdDocuments that conditional frontmatter imports are unsupported and suggests runtime-import gating.
.github/workflows/shared/aw-logs-24h-fetch-setup.mdNew shared workflow fragment containing only setup-time steps/tools for log prefetch.
.github/workflows/shared/aw-logs-24h-fetch-prompt.mdNew shared prompt-only markdown fragment for the log bundle instructions.
.github/workflows/daily-safe-output-optimizer.mdUpdates imports to keep setup unconditional and gates prompt text via {{#if experiments...}} + runtime import.
.github/workflows/daily-safe-output-optimizer.lock.ymlRegenerated compiled workflow reflecting the new import behavior.
.github/aw/syntax-tools-imports.mdUpdates internal syntax docs to state conditional frontmatter imports are unsupported.
.github/aw/experiments.mdAdds an experiments anti-pattern note discouraging conditional frontmatter imports.
.changeset/major-remove-imports-if.mdAdds a major changeset documenting the breaking change and migration guidance.

Copilot's findings

Tip

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

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

Comment thread.github/workflows/daily-safe-output-optimizer.md Outdated
Comment on lines +568 to 570
if _, hasIf := importItem["if"]; hasIf {
return nil, errors.New("import 'if' is no longer supported; use {{#if ...}}{{#runtime-import ...}}{{/if}} for experiment-specific prompt imports")
}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in commit d99a6e9 — updated the migration error message to recommend {{#if ...}}{{#runtime-import? ...}}{{/if}} (optional form, not promoted to unconditional lock-file macros) for experiment-specific prompt imports.

Comment on lines 333 to 337
{{#runtime-import .github/workflows/shared/otlp.md}}
{{#runtime-import .github/workflows/shared/reporting.md}}
{{#runtime-import .github/workflows/shared/aw-logs-24h-fetch-prompt.md}}
{{#runtime-import .github/workflows/shared/noop-reminder.md}}
{{#runtime-import .github/workflows/daily-safe-output-optimizer.md}}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in commit d99a6e9 — the source now uses {{#runtime-import?}} (optional form), so the lock file no longer contains an unconditional {{#runtime-import .github/workflows/shared/aw-logs-24h-fetch-prompt.md}} macro. The lock file has been regenerated.


`uses` is an alias for `path`; `with` is an alias for `inputs`.

Conditional frontmatter imports are not supported. If an experiment should vary shared prompt content, keep imports unconditional and gate `{{#runtime-import ...}}` inside your `{{#if experiments.<name> ...}}` block instead.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in commit d99a6e9 — updated the guidance to recommend {{#runtime-import? ...}} (optional form) for experiment-gated prompt imports, with a note that the optional form is not promoted to unconditional lock-file macros.

Comment thread.github/aw/syntax-tools-imports.md Outdated
- `env:` - Environment variables passed into the imported workflow context (object). Use when a shared workflow relies on environment variables that must be supplied by the importing workflow.
- `checkout:` - Ref (branch, tag, or SHA) to check out when processing this import (string). Overrides the default checkout for this specific import entry.

Conditional `imports:` entries are not supported. For experiment-specific prompt variants, keep the import unconditional and gate a `{{#runtime-import ...}}` block in the workflow body instead.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in commit d99a6e9 — updated the guidance to use {{#runtime-import? ...}} (optional form, not promoted to unconditional lock-file macros) for experiment-gated prompt imports.

Comment thread.github/aw/experiments.md Outdated
pelikhanand others added 3 commits June 9, 2026 18:33
- Switch daily-safe-output-optimizer.md to use the optional `?` form
so the prompt import is not promoted unconditionally to the lock file
- Update migration error message in import_bfs.go to point to `?` form
- Update docs (imports.md, syntax-tools-imports.md, experiments.md)
to recommend `{{#runtime-import? ...}}` for experiment-gated content
- Regenerate daily-safe-output-optimizer.lock.yml (removes the
unconditional aw-logs-24h-fetch-prompt.md macro)
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ts' into copilot/remove-support-for-imports
# Conflicts:
#	.github/aw/experiments.md
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

CopilotAIand others added 2 commits June 10, 2026 02:02
…s.if rejection
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…hConditionalImport
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

CopilotAI commented Jun 10, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot run pr-finisher skill

Done. Fixed the CI test failure in TestCompileWorkflowWithConditionalImport — updated it to expect rejection of imports.if rather than successful compilation of the removed feature (commit 6dc1c1f). The test now verifies either the schema validation error ("Unknown property: if") or the migration guard message ("import 'if' is no longer supported").

The TestHashConsistencyAcrossLockFiles parser failure in CI was transient — it passes locally with all 245 workflows verified.

All review threads from the prior session have replies; local validation (make agent-report-progress) passes.

@pelikhan
pelikhan merged commit 84ece23 into mainJun 10, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/remove-support-for-imports branch June 10, 2026 02:28
Sign up for freeto 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.

3 participants

@pelikhan