Skip to content

Honor imported engine secret allowlists in strict mode - #75382

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-strict-mode-env-vars
Nov 7, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/fix-strict-mode-env-vars

Conversation

Copilot AI commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Strict mode checked engine.env before imported engines were registered, rejecting secrets under keys declared in behaviors.supported-env-var-keys.

  • Validation order: Defer engine.env checks until imports resolve; keep top-level env checks early.
  • Compatibility: Preserve model context for fallback-provider allowlists, avoid duplicate warnings, and retain source-positioned errors for undeclared keys.
  • Regression coverage: Cover declared and undeclared keys, top-level secrets, warning counts, and fallback models.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix strict mode behavior for imported engine's supported env var keys Honor imported engine secret allowlists in strict mode Nov 6, 2026
Copilot AI requested a review from pelikhan November 6, 2026 09:17
@pelikhan
pelikhan marked this pull request as ready for review November 6, 2026 14:00
Copilot AI adaptive review requested due to automatic review settings November 6, 2026 14:00
@github-actions

github-actions Bot commented Nov 6, 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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 6, 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.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~1 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

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.

Generated from Ponytail Reviewer · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #75382

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

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.

Generated from PR Specification Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #75382

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Warning

The push_to_pull_request_branch operation failed: Cannot verify branch protection rules for "copilot/fix-strict-mode-env-vars": Resource not accessible by integration - https://docs.github.com/rest/branches/branch-protection\#get-branch-protection. Reading classic branch protection requires a GitHub App installation token or fine-grained PAT with Administration: read repository permission; GITHUB_TOKEN cannot provide this permission. Push blocked to prevent accidental writes to protected branches.. The code changes were not applied.

🏗️ Design Decision Gate — ADR Required

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

📄 Draft ADR committed: docs/adr/75382-defer-engine-env-validation-until-imports-resolve.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.

  2. Complete the missing sections with any context the PR evidence does not capture and refine the rationale and alternatives.

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

  4. Reference the ADR in this PR body by adding:

    ADR: ADR-75382: Defer Engine Environment Secret Validation Until Imports Resolve (link unavailable: invalid HTTPS URL)

The gate will re-run after the ADR is linked and verify that the implementation matches the decision.

🔎 Evidence used

The pre-fetched gate summary reports 109 added lines in the default business-logic directories and no implementation label. The PR changes pkg/workflow/compiler_orchestrator_workflow.go, pkg/workflow/strict_mode_env_validation.go, and pkg/workflow/env_secrets_validation_test.go to defer imported-engine engine.env validation until imports and model mappings are resolved while preserving early top-level env validation.

📋 Michael Nygard ADR format

A complete ADR must contain Context, Decision, Alternatives Considered, and Consequences, with positive and negative trade-offs.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: gpt56 max · ~2 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷
Comment /review to run again

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-06T14:04:02Z
review_event: COMMENT
top_themes:
  - test isolation: captureStderr does not restore os.Stderr when require exits early
files_reviewed:
  - pkg/workflow/compiler_orchestrator_workflow.go
  - pkg/workflow/env_secrets_validation_test.go
  - pkg/workflow/strict_mode_env_validation.go
comment_count: 1

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.6K · ◷
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.

Reviewed the changed validation flow and regression tests. One medium test-isolation issue should be addressed: assertion failures inside captureStderr can skip restoration of os.Stderr and contaminate later tests.

Highlights
  • Imported-engine validation is deferred appropriately while top-level env remains checked early.
  • The added coverage exercises allowlisted and undeclared engine environment keys.
  • Please make stderr restoration unconditional in the test path.

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

Say hello.
`, tt.strict, tt.key, tt.topLevelEnv)
require.NoError(t, os.WriteFile(path, []byte(content), 0600))
stderr := captureStderr(func() {

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.

This require inside captureStderr can terminate the test goroutine before the helper restores os.Stderr, leaving the process pointed at a closed pipe and corrupting output for subsequent tests.

💡 Restore stderr even on assertion failure

require.ErrorContains and require.NoError call runtime.Goexit on failure, so the helper's post-callback restoration is skipped. Move assertions outside the capture callback, use the t-aware helper that defers restoration, or update the shared helper to restore os.Stderr with defer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 313b98c: the capture callback only records compilation results. All assertions now run after captureStderr has restored stderr; file and string regression cases pass.

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

Strict workflows accept imported engine secrets with firewall versions below v0.25.3, where missing environment-exclusion support leaves those secrets visible to the agent container.

1 open issue
What changed in this PR

Fixes strict-mode validation so imported engines can use secrets under their declared environment-variable allowlists, addressing #75272.

Changes:

  • Defers engine.env validation until imported engines are registered.
  • Keeps top-level environment checks early, avoids duplicate warnings, and preserves positioned errors.
  • Adds regression coverage for declared and undeclared keys, warning counts, and fallback-model context.
File Description
pkg/​workflow/​strict_mode_env_validation.go Separates engine environment validation and defers it for imports.
pkg/​workflow/​env_secrets_validation_test.go Adds imported-engine and fallback-model regression tests.
pkg/​workflow/​compiler_orchestrator_workflow.go Runs deferred validation after imports resolve and formats errors with source positions.

Review effort: Balanced (auto)

if err := c.withEffectiveStrictMode(ctx.frontmatter.Frontmatter, func() error {
return c.validateEnvSecretsWithModels(ctx.frontmatter.Frontmatter, ctx.workflowData.ModelMappings)
// Top-level env was already checked before imports were merged.
return c.validateEngineEnvSecretsWithModels(ctx.frontmatter.Frontmatter, ctx.workflowData.ModelMappings)

@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, /tdd, and /codebase-design. Requesting changes because the new early return opens a strict-mode bypass on the string-compile path.

📋 Key Themes & Highlights

Key Themes

  • Strict-mode bypass (blocking): ParseWorkflowString never runs the deferred engine.env check, so an undeclared secret on an imported engine passes under strict: true. Reproduced with a probe test.
  • Test hygiene: require.* inside captureStderr can leave os.Stderr redirected on failure (confirmed with a probe).
  • Brittle assertion: the hardcoded :7:1: ties the test to fixture layout.
  • Coverage gap: no test exercises the string-API path, and I could not confirm the new tests fail on the base commit.

Positive Highlights

  • ✅ The import-aware split of validateEnvSecretsWithModels into validateEngineEnvSecretsWithModels is a clean seam.
  • ✅ The new branch is commented to explain why the early check is deferred.
  • ✅ Targeted tests pass and gofmt is clean.

@copilot please address the review comments above.

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

}

func (c *Compiler) validateEarlyEnvSecrets(frontmatter map[string]any) error {
if frontmatterDeclaresImports(frontmatter) {

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] Strict-mode bypass on the string-compile path. The new early return skips engine.env secret validation for imported engines, and that check only runs from validateWorkflowBuildContext. ParseWorkflowString in compiler_string_api.go calls setupWorkflowBuildContext but never calls validateWorkflowBuildContext, so an undeclared engine.env secret passes with err=nil under strict: true. I reproduced this with a temporary probe test. It errors correctly once this early-return branch is removed.

💡 Suggested fix

Run the deferred engine.env check on the string path too. The simplest option is to call validateEngineEnvSecretsWithModels from validateStringWorkflowData, or from a shared step that both paths call. Then add a regression test that uses ParseWorkflowString with an imported engine that declares an undeclared secret in engine.env under strict mode.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 313b98c: deferred validation now runs from shared setupWorkflowBuildContext, covering both parsing APIs after imports resolve. Regression tests verify ParseWorkflowString itself rejects undeclared secrets, accepts declared keys, and emits non-strict warnings once.

Say hello.
`, tt.strict, tt.key, tt.topLevelEnv)
require.NoError(t, os.WriteFile(path, []byte(content), 0600))
stderr := captureStderr(func() {

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] captureStderr restores os.Stderr only after its callback returns, and require.* calls t.FailNow(), which exits the goroutine. A failing assertion here leaves stderr redirected for the rest of the test binary. I confirmed this with a probe. Use assert.* inside the closure, or move the assertions outside the capture.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 313b98c: moved every assertion outside the stderr-capture callback, so fatal assertions cannot interrupt stderr restoration.

err := NewCompiler().CompileWorkflow(path)
if tt.wantSection != "" {
require.ErrorContains(t, err, "strict mode: secrets detected in '"+tt.wantSection+"' section")
assert.Contains(t, err.Error(), path+":7:1:")

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.

[/codebase-design] Hardcoding path+":7:1:" ties this test to the line layout of the fixture YAML. It also points at the engine: line rather than env:, which is a pre-existing location quirk this PR does not need to fix. Assert on the section name (already covered by wantSection) and drop the line assertion, or derive the expected line from findFrontmatterFieldLine.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 313b98c: removed the hardcoded :7:1: assertion while retaining the section-specific error assertions for both file and string parsing.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

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/env_secrets_validation_test.go:64): This require inside captureStderr can terminate the test goroutine before the helper restores os.Stderr, leaving the process pointed at a closed pipe and corrupting output for subsequent tests. - Honor imported engine secret allowlists in strict mode #75382 (comment)
  3. Review (pkg/workflow/strict_mode_env_validation.go:34): [/diagnosing-bugs] Strict-mode bypass on the string-compile path. The new early return skips engine.env secret validation for imported engines, and that check only runs from validateWorkflowBuildContext. ParseWorkflowString in compiler_string_api.go calls setupWorkflowBuildContext but never calls validateWorkflowBuildContext, so an undeclared engine.env secret passes with err=nil under strict: true. I reproduced this with a temporary probe test. It errors correctly once this early-return branch is removed. - Honor imported engine secret allowlists in strict mode #75382 (comment)
  4. Review (pkg/workflow/env_secrets_validation_test.go:64): [/tdd] captureStderr restores os.Stderr only after its callback returns, and require.* calls t.FailNow(), which exits the goroutine. A failing assertion here leaves stderr redirected for the rest of the test binary. I confirmed this with a probe. Use assert.* inside the closure, or move the assertions outside the capture. - Honor imported engine secret allowlists in strict mode #75382 (comment)
  5. Review (pkg/workflow/env_secrets_validation_test.go:68): [/codebase-design] Hardcoding path+":7:1:" ties this test to the line layout of the fixture YAML. It also points at the engine: line rather than env:, which is a pre-existing location quirk this PR does not need to fix. Assert on the section name (already covered by wantSection) and drop the line assertion, or derive the expected line from findFrontmatterFieldLine. - Honor imported engine secret allowlists in strict mode #75382 (comment)
  6. Fix failing check safe_outputs (FAILURE): https://github.com/github/gh-aw/actions/runs/42230089155/job/127937116643.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 82fde01
Sous-chef requested-work: 73f75a1f84d47ab3a898de9abfb4e211eae736fa70791d0cfc9a6212f5ab09cd a546330ab509d9b1c41c574894424b771c808fd3db267bde78d77be46e7a1cc5 a6eb67fba1e6958d4ade39c734143f6140aab331b68d253aab379d34497cc5dd c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e e862a0fe1cf6cd2836f9d8a18413aa4f25a2e51e2d1280c79e7b590fa0d0da94
Sous-chef requested-state: f6853d06b5a0b924c6951c89fc94f8473d7ed200cb25466070b6b2de3efb1ae3

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~11 AIC · ⌖ ~10 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Assignment running:

  1. Update this branch with latest main using make merge-main, resolving conflicts while preserving the intended changes.
  2. Move fatal assertions outside captureStderr.
  3. Fix deferred imported-engine secret validation on the string-compile path and add regression coverage.
  4. Address the duplicate stderr-restoration feedback.
  5. Remove the hardcoded fixture-line assertion.
  6. Investigate the failing safe_outputs check.

I’ll reply to and resolve addressed review threads where supported, without merging the PR or triggering CI.

Sous-chef requested-head: 82fde01
Sous-chef requested-work: 73f75a1f84d47ab3a898de9abfb4e211eae736fa70791d0cfc9a6212f5ab09cd a546330ab509d9b1c41c574894424b771c808fd3db267bde78d77be46e7a1cc5 a6eb67fba1e6958d4ade39c734143f6140aab331b68d253aab379d34497cc5dd c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e e862a0fe1cf6cd2836f9d8a18413aa4f25a2e51e2d1280c79e7b590fa0d0da94
Sous-chef requested-state: f6853d06b5a0b924c6951c89fc94f8473d7ed200cb25466070b6b2de3efb1ae3

…de-env-vars

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI requested a review from gh-aw-bot November 6, 2026 15:02
@pelikhan
pelikhan merged commit d60cd7c into main Nov 7, 2026
82 checks passed
@pelikhan
pelikhan deleted the copilot/fix-strict-mode-env-vars branch November 7, 2026 04:39
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

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.

Strict mode ignores an imported engine's supported-env-var-keys for engine.env secrets

4 participants