Skip to content

fix(ci): mint self-mutation token from a workflow pinned to main (2/2) - #868

Open
darccio wants to merge 1 commit into
dario.castane/infallible-tharp-ba69a7from
dario.castane/self-mutation-wiring
Open

fix(ci): mint self-mutation token from a workflow pinned to main (2/2)#868
darccio wants to merge 1 commit into
dario.castane/infallible-tharp-ba69a7from
dario.castane/self-mutation-wiring

Conversation

@darccio

@darccio darccio commented Aug 3, 2026

Copy link
Copy Markdown
Member

Step 2 of 2. Stacked on #866do not merge until #866 lands on main.

Why this depends on #866

validate.yml now calls .github/workflows/self-mutation.yml via uses: DataDog/orchestrion/.github/workflows/self-mutation.yml@main. That @main reference is resolved by GitHub against the actual tip of main in this repo — not against this PR's base branch, not against the merge commit being tested. Until #866 merges, main doesn't have that file, so this PR's own CI will fail to load (the same zero-jobs, instant-failure symptom documented on #866: run 30830039834). That's expected, not a regression — stacking this PR on #866's branch only makes the diff clean for review; it doesn't change how @main resolves.

Once #866 merges, this PR's base will auto-retarget to main and its CI should go green.

What this does

Test plan

Completes the fix started in #866, restoring the self-mutation job that
has been permission-denied on every pull request since #846.

#846 constrained the dd-octo-sts policy to
validate.yml@refs/heads/main, which is unsatisfiable: for pull_request
events GitHub runs workflows from the PR merge ref, so job_workflow_ref
is always validate.yml@refs/pull/<N>/merge. Relaxing the policy to accept
merge refs would reintroduce what #846 set out to prevent, since a pull
request can rewrite validate.yml and mint the contents: write token from
its own code.

Instead, validate.yml now calls the self-mutation workflow added in #866,
pinned at @main. job_workflow_ref resolves to the *called* reusable
workflow, so the claim becomes self-mutation.yml@refs/heads/main -- a ref
no pull request can influence -- and the policy asserts that.

The same-repo/maintainer_can_modify guard moved into the called workflow
so it lives in trusted code, and the workflow takes no inputs: the push
target is derived from the pull_request event context so an untrusted
caller cannot redirect it.

ratchet:exclude and an allowlist entry are required because this one
reference is intentionally a branch ref rather than a SHA.
@darccio
darccio requested a review from a team as a code owner August 3, 2026 16:10
@darccio darccio added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Aug 3, 2026
@darccio

darccio commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 0cd417a3ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos conventional-commit/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant