Skip to content

feat(ci): gate trusted pipeline environment provisioning by phase - #596

Open
agent-relay-code[bot] wants to merge 2 commits into
mainfrom
ci/trusted-pipeline-root
Open

agent-relay-code[bot] wants to merge 2 commits into
mainfrom
ci/trusted-pipeline-root

Conversation

@agent-relay-code

@agent-relay-code agent-relay-code Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Adds a manual-only Infra plan/apply path for the pinned github-trusted-pipeline-ci root. Plan identity, run attempt, workflow, phase, input version, commit and digest are verified before apply. The phase gate and target preflight run twice. The environment and sealed bindings require separate plans and protected credentials.

Offline verification: three fixture tests (including negative cases), existing hosted runner smoke suite and shell syntax checks. No workflow dispatch or infrastructure changes performed. Requires protected environment setup, private backend and sealed inputs. Code review only, held pending exact-head review and CI.


Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Adds a manual-only Infra plan/apply path for the pinned github-trusted-pipeline-ci root with phase-gated provisioning. Plan identity, run attempt, workflow, phase, input version, commit, and digest are verified before apply.

  • New trusted-pipeline-provision.yml workflow with separate plan/apply jobs, both restricted to main, using distinct protected environments.
  • trusted-pipeline-gate.py enforces an exact per-phase plan shape and values; trusted-pipeline-preflight.sh checks live target state before plan and apply.
  • session-pipeline-ci.sh gains trusted-environment and trusted-bindings targets; apply also requires independent review and no admin bypass.
  • Offline fixture tests cover positive and negative gate cases; existing hosted runner smoke suite and shell checks pass.

Migration

  • Requires separately configured protected environments, private backend, OIDC roles, and a scoped TARGET_REPOSITORY_TOKEN.
  • Plan and bindings phases must be run separately with sealed inputs; no workflow dispatch or infra changes performed.

Written for commit d06a084. Summary will update on new commits.

View guided diff Turn on auto-fix

@agent-relay-code agent-relay-code Bot added the merge-train:hold Do not merge without Khaliq's direct OK label Nov 28, 2026
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 892d2a15-4dec-4274-9494-481afc461a91

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking gap in tests for the new preflight and trusted plan/apply paths.RetriggerView in GreptileConfidence Score: 4/5

[Critical impact] The new apply route can set rules and credential bindings for the trusted pipeline.

The PR appears safe to merge, with a non-blocking gap in tests for the new preflight and trusted plan/apply paths.

FindingsFix All in CodexFindings

  1. P2 Trusted provisioning paths lack tests ▶
Fix with agent prompt
### Issue 1
scripts/hosted/tests/test_trusted_pipeline_gate.py:33-35
The new tests call `check()` directly, so they never exercise `trusted-pipeline-preflight.sh` or either trusted path through `session-pipeline-ci.sh`. The existing smoke suite does not cover these paths either. A broken preflight or a missing call to it could therefore pass CI.

Add offline tests for both phases covering successful plan/apply, failed API reads, existing binding names, weakened protections, and a changed public key.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds a manual, main-only workflow for provisioning the trusted GitHub environment in two separately reviewed phases.

  • Infra can provision the trusted pipeline in two reviewed phases.
  • Phase checks limit provisioning to the intended environment or bindings.

No blocking behavior issue was established. The new preflight and trusted plan/apply paths need offline test coverage.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Choose environment or bindings] --> B[Check protected Infra environment]
  B --> C[Read private inputs and check target]
  C --> D[Create plan and check phase]
  D --> E[Store plan and digest]
  E --> F[Independent apply approval]
  F --> G[Verify run, commit, inputs and digest]
  G --> H[Check target and phase again]
  H --> I[Apply saved plan once]
Loading

Reviews (1) · Last reviewed commit: "Run trusted phase gate fixtures in Terra..." · Reviewed by Greptile

Comment on lines +33 to +35
def test_phases(self):
check(fixture(), "trusted-environment")
check(fixture(True), "trusted-bindings")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Trusted provisioning paths lack tests

The new tests call check() directly, so they never exercise trusted-pipeline-preflight.sh or either trusted path through session-pipeline-ci.sh. The existing smoke suite does not cover these paths either. A broken preflight or a missing call to it could therefore pass CI.

Add offline tests for both phases covering successful plan/apply, failed API reads, existing binding names, weakened protections, and a changed public key.

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/hosted/tests/test_trusted_pipeline_gate.py
Line: 33-35

Comment:
**Trusted provisioning paths lack tests**

The new tests call `check()` directly, so they never exercise `trusted-pipeline-preflight.sh` or either trusted path through `session-pipeline-ci.sh`. The existing smoke suite does not cover these paths either. A broken preflight or a missing call to it could therefore pass CI.

Add offline tests for both phases covering successful plan/apply, failed API reads, existing binding names, weakened protections, and a changed public key.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Claude Code

@agent-relay-code

Copy link
Copy Markdown
Contributor Author

Infra repository maintainers: please designate a writer authorized to publish the repair to this branch, or identify the replacement PR. The inventory owner reports one conflict in terraform/scripts/check.sh at 075c938 and no branch changes. Please have the writer confirm acceptance, return the tested revision against current main, and address the remaining review thread before requesting fresh review. This is a source repair; the provisioning hold remains in effect.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-train:hold Do not merge without Khaliq's direct OK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants