Skip to content

Restrict issue-investigation draft PRs to docs and test sources - #1925

Open
Elliot (theelliotm) wants to merge 3 commits into
mainfrom
user/emichlin/investigate-workflow-pr-scope
Open

Elliot (theelliotm) wants to merge 3 commits into
mainfrom
user/emichlin/investigate-workflow-pr-scope

Conversation

@theelliotm

@theelliotm Elliot (theelliotm) commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Narrows what the /investigate agentic workflow can change in its draft PRs, and stops those PRs from starting CI on their own.

  • Replace the broad allowed-files (docs/**, tests/**, sdk/node/tests/**, sdk/dotnet/Microsoft.Mxc.Sdk.Tests/**) with an explicit allowlist: Markdown under docs/ and tests/, JSON under tests/policy/ and tests/fixtures/, .ts under sdk/node/tests/, and .cs under sdk/dotnet/Microsoft.Mxc.Sdk.Tests/. Each scope lists both dir/*.ext and dir/**/*.ext, because gh-aw's matcher requires at least one subdirectory for **/.
  • Agent PRs can no longer change CI-run scripts (tests/scripts/**, tests/regression_tests/**/*.ps1), e2e configs read by those scripts (tests/configs/**, tests/examples/**), or build/package files (*.csproj, Directory.Build.*, package.json, package-lock.json, .npmrc, tsconfig.json, runner scripts).
  • Pin the PR push/creation token to GITHUB_TOKEN and set github-token-for-extra-empty-commit: ${{ '' }} so agent PRs never start CI through a PAT. gh-aw v0.81.6 has no none value; an empty token makes the runtime skip the extra commit. draft: true is unchanged.
  • Prompt and CONTRIBUTING.md list the narrower scope. CONTRIBUTING.md also says how to start CI: after review, close and reopen the PR or push a commit to it. The CI workflows use the default pull_request events, and marking the draft ready doesn't start them.
  • issue-triage.md has no PR or bash output; unchanged.
  • Lock regenerated with gh-aw v0.81.6 (the version in the existing header). Dependabot had bumped action pins in the lock after compilation, so a plain recompile downgrades them. The lock diff is the compiler's own delta (unchanged-source compile → new-source compile) applied with git merge-file, which keeps Dependabot's pins. Delta: allowlist and token in both safe-outputs configs, GH_AW_CI_TRIGGER_TOKEN removed from the secrets manifest, safe_outputs checkout/git token → GITHUB_TOKEN, hashes.

Limitations: allowed SDK test sources still run in CI when a maintainer starts it, so review the draft first. No suitable PR label exists.

🔗 References

  • Follow-up: CODEOWNERS has only * @microsoft/tessera-code-reviewers; consider a dedicated owner for tests/scripts/ and .github/workflows/.
  • Admin follow-up: confirm no repo- or org-level GH_AW_CI_TRIGGER_TOKEN or GH_AW_GITHUB_TOKEN secret exists (other workflow steps still fall back to GH_AW_GITHUB_TOKEN).

🔍 Validation

  • gh aw compile issue-investigation (v0.81.6): passed, 0 errors, 0 warnings. Recompiling the final source reproduces the compiler delta used in the lock exactly.
  • gh aw compile issue-investigation --no-emit --strict --validate: passed, 0 errors, 0 warnings.
  • git merge-file check: non-intended lock delta (new compile → committed lock) is identical to (unchanged-source compile → main lock), i.e. only Dependabot pins (60 lines).
  • actionlint -shellcheck= -pyflakes= .github/workflows/issue-investigation.lock.yml (v1.7.12): 3 findings (copilot-requests scope ×2, concurrency.queue), identical to main; no new findings.
  • Allowlist checked with gh-aw's globPatternToRegex (v0.85.1 runtime) against git ls-files: all 185 tracked files in the intended scopes match (including root-level files such as tests/policy/*.json), and nothing outside them matches. tests/scripts/*.sh, tests/configs/*.json, *.csproj, package.json, src/** and .github/workflows/* are rejected.
  • git ls-files --eol -m -o --exclude-standard: all changed files LF.
  • Not run: an end-to-end /investigate run (requires a maintainer comment on a live issue).

✅ Checklist

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required (workflow configuration change; no spec required)
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

  • Bug fix
  • Feature
  • Task

Elliot (theelliotm) and others added 2 commits December 3, 2026 14:11
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83e19dbb-1bf5-41ad-80f0-47fe416d8093
Copilot AI max review requested due to automatic review settings December 3, 2026 23:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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 Markdown allowlist permits changes to a PowerShell example executed by CI, allowing an apparently documentation-only PR to run agent-modified code when a maintainer starts checks.

2 open issues
What changed in this PR

Hardens MXC’s /investigate workflow by narrowing draft PR changes and deferring CI until maintainer action.

Changes:

  • Restrict edits to selected Markdown, JSON fixtures, and SDK test sources.
  • Use GITHUB_TOKEN for PR creation and disable the extra CI-triggering commit.
  • Document the restricted scope and manual CI steps.
File Description
CONTRIBUTING.md Explain scope restrictions and how maintainers start CI.
.github/​workflows/​issue-investigation.md Narrow the allowlist, pin tokens, and update agent guidance.
.github/​workflows/​issue-investigation.lock.yml Apply compiled restrictions and token settings while preserving action pins.

Review effort: Max

@theelliotm Elliot (theelliotm) self-assigned this Dec 4, 2026
Copilot AI max review requested due to automatic review settings December 5, 2026 00:00
@theelliotm
Elliot (theelliotm) marked this pull request as ready for review December 5, 2026 00:01
@theelliotm
Elliot (theelliotm) requested a review from a team as a code owner December 5, 2026 00:01

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 command guard accepts commented-out flags and empty quoted refs, allowing invalid commands to pass validation, while the new file and token restrictions lack CI-wired regression coverage.

2 open issues
2 resolved since last review

Review effort: Max

assert.equal(result.status, 0, result.stdout + result.stderr);
const args = JSON.parse(result.stdout);
const command = example[1].replace(/`\r?\n/g, " ").trim();
assert.ok(!/[\r\n;|&$`(){}<>]/.test(command), `expected one literal command: ${command}`);

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants