Skip to content

Fix dangling determine-automatic-lockdown step reference in static enclave sink-visibility policy - #60338

Merged
lpcox merged 9 commits into
mainfrom
copilot/fix-static-enclave-write-sink-references
Sep 11, 2026
Merged

Fix dangling determine-automatic-lockdown step reference in static enclave sink-visibility policy#60338
lpcox merged 9 commits into
mainfrom
copilot/fix-static-enclave-write-sink-references

Conversation

Copilot AI commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

When tools.github: false is combined with a static GitHub enclave and safe-outputs, the compiler emitted GH_AW_SINK_VISIBILITY: ${{ steps.determine-automatic-lockdown.outputs.visibility }} even though the determine-automatic-lockdown step was never generated (it only synthesized GitHub tool access for the enclave identity, not the primary agent). The dangling reference expanded to an empty string, which MCP Gateway rejects as an invalid sink-visibility value, blocking the agent and enclave from starting.

Root cause

collectMCPEnvironmentVariables gated GH_AW_SINK_VISIBILITY on a locally synthesized "GitHub tool enabled" map (toolsWithEnclaveGitHubIssues) used to render the enclave-scoped GitHub backend, instead of the authoritative githubLockdownDetectionStepEnabled(workflowData) predicate that actually controls whether the step is generated.

Changes

  • Step generation (compiler_github_mcp_steps.go): githubLockdownDetectionStepEnabled now also returns true when staticEnclaveWriteSinkGuardPolicy(data) != nil, so the lockdown step is generated whenever a static enclave's write-sink policy needs the target visibility — even with the primary agent's GitHub tool disabled.
  • Env var emission (mcp_environment.go): GH_AW_SINK_VISIBILITY and the primary GitHub guard-policy vars (GITHUB_MCP_GUARD_MIN_INTEGRITY/REPOS) are now gated on the same githubLockdownDetectionStepEnabled predicate, eliminating the drift between "step exists" and "step output referenced."
  • Shared predicate (mcp_github_config.go): extracted githubBackendIsEnclaveOnly (static or dynamic enclave-only delegation) to a single helper, reused by both the env var logic and githubGuardPoliciesFromStep, so enclave-only backends consistently derive their guard/write-sink policy from the enclave declaration rather than step outputs.
  • Regression coverage (enclave_github_proxy_test.go): added TestCompileStaticEnclaveOnlyGitHubDisabledSinkVisibility reproducing the exact reported frontmatter, plus a generic assertNoDanglingStepOutputReferences invariant that scans the compiled lock file for any steps.<id>.outputs.* reference and verifies the referenced step id was actually emitted — catching this class of bug generically, not just for this one field.
# now compiles without a dangling step reference
tools:
  github: false
enclaves:
  - repos:
      - repo: org/private-repo
        sensitivity: confidential
safe-outputs:
  add-comment:
    max: 1

Copilot AI and others added 7 commits September 11, 2026 22:27
…e sink-visibility

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…clusions

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…rtifact

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
… gen/reference in sync

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…test

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…bBackendIsEnclaveOnly

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing lockdown step in static enclave write-sink references Fix dangling determine-automatic-lockdown step reference in static enclave sink-visibility policy Sep 11, 2026
Copilot AI requested a review from lpcox September 11, 2026 22:56
@lpcox
lpcox marked this pull request as ready for review September 11, 2026 23:02
Copilot AI balanced review requested due to automatic review settings September 11, 2026 23:02

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

The new invariant can miss dangling references when a matching step ID exists in another job.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes static enclave-only workflows that referenced a nonexistent lockdown step output.

Changes:

  • Aligns lockdown-step generation with sink-visibility emission.
  • Centralizes enclave-only backend detection.
  • Adds regression coverage and a dangling-reference invariant.
File summaries
File Description
pkg/workflow/compiler_github_mcp_steps.go Generates the lockdown step when static enclave sink visibility requires it.
pkg/workflow/mcp_environment.go Gates guard and visibility variables using shared predicates.
pkg/workflow/mcp_github_config.go Adds shared enclave-only backend detection.
pkg/workflow/enclave_github_proxy_test.go Adds regression tests and the workflow-reference invariant.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +419 to +425
emittedIDs := make(map[string]bool)
for _, match := range stepIDPattern.FindAllStringSubmatch(lock, -1) {
emittedIDs[match[1]] = true
}
for _, match := range stepOutputRefPattern.FindAllStringSubmatch(lock, -1) {
stepID := match[1]
assert.True(t, emittedIDs[stepID], "reference %q has no corresponding emitted step id %q", match[0], stepID)
@lpcox

lpcox commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in 336af10: assertNoDanglingStepOutputReferences now validates steps.<id>.outputs.* references per job and requires step-field references to point to earlier steps in that same job. Targeted workflow tests and final validation passed.

@lpcox
lpcox merged commit 5429ed8 into main Sep 11, 2026
32 checks passed
@lpcox
lpcox deleted the copilot/fix-static-enclave-write-sink-references branch September 11, 2026 23:39
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.

Static enclave write-sink references missing lockdown step when tools.github is false

3 participants