Skip to content

ci: resolve PR merge conflicts with a sandboxed Pi agent #7542

Description

@cv

Problem Statement

An open PR can conflict with main after either branch changes.
Maintainers must then update the PR branch and resolve the conflicts.
This work delays review and prevents CI from testing the merged files.

NemoClaw has no automation that resolves these conflicts.
The automation must treat all PR files and commands as untrusted.
It must not expose a model credential or GitHub credential to PR code.

Desired Behavior

A workflow must process an open PR when all these conditions are true:

  • The PR has the opt-in conflict-fixer label.
  • The head repository is NVIDIA/NemoClaw.
  • The base branch is main.
  • The exact PR SHA conflicts with the exact base SHA.
  • All conflicted files are supported text files.

The workflow must complete these actions:

  1. Run one Pi coding-agent task in an OpenShell sandbox.
  2. Let Pi read and edit the repository and run available local commands.
  3. Restrict Pi changes to the original conflicted files.
  4. Validate the result outside the sandbox.
  5. Create a verified merge commit with the PR SHA and base SHA as its parents.
  6. Update the PR branch without a force push.
  7. Let the branch update start the normal PR CI workflows.

For example, assume PR #123 conflicts with main in src/example.ts.
The workflow resolves only src/example.ts.
The workflow then pushes one merge commit if the PR SHA and base SHA are unchanged.

Constraints and Non-goals

  • Version 1 supports same-repository PRs only.
  • Version 1 requires an opt-in label.
  • Version 1 supports regular text files below a fixed size limit.
  • Version 1 does not support binary files, symlinks, or submodules.
  • Version 1 does not resolve conflicts in .github/**, .agents/**, CODEOWNERS, or security-policy files.
  • Pi must not fix review findings, refactor code, or update dependencies.
  • The sandbox must not contain a GitHub token.
  • The sandbox must use OpenShell inference routing instead of a model credential.
  • The publisher must not force-push or update a changed PR branch.
  • Fork PR support is not part of this work.
  • A custom sandbox image is not part of this work.
  • A separate comment bot, result schema, review ledger, and test-selection system are not part of this work.

Before implementation, maintainers must approve this product surface.
The decision must identify the owner, lifecycle, GitHub App, model, cost limit, and supported conflict types.

Implementation Idea

Add one workflow with three jobs and two privilege domains:

  1. discover finds eligible conflicts with read-only GitHub access.
  2. resolve runs Pi in OpenShell with read-only GitHub access.
  3. publish validates the result and updates the branch with a dedicated GitHub App.

The workflow should run after a PR head update and after a push to main.
The main trigger should inspect only open PRs with the opt-in label.

Pin the OpenShell version and the official Pi image digest.
Disable PR-provided Pi skills, extensions, prompt templates, and context files.
Allow write access only to the sandbox work directory.
Deny external network access except OpenShell inference routing.
Delete the sandbox after every result.

The resolver should return one bounded binary patch.
The publisher should recreate the same merge from the PR SHA and base SHA.
It should reject changes outside the original conflicted files.
It should also reject unresolved entries, malformed paths, and oversized output.

The publisher should create the two-parent commit through the GitHub API.
It must verify the bot signature before it updates the branch reference.
The reference update must be a fast-forward update.

Keep the implementation in one focused directory:

.github/workflows/pr-merge-conflict-fixer.yaml
tools/pr-merge-conflict-fixer/
  discover.mts
  resolve.mts
  publish.mts
  policy.yaml
test/
  pr-merge-conflict-fixer.test.ts
  pr-merge-conflict-fixer-workflow-boundary.test.ts

Acceptance Criteria

  • An eligible textual conflict produces one verified merge commit on the unchanged PR branch.
  • The merge commit has the expected PR SHA and base SHA as its parents.
  • The result changes only the original conflicted files.
  • A clean, unlabeled, fork, draft, or unsupported PR causes no branch change.
  • A changed PR SHA or base SHA causes no branch change.
  • A failed sandbox, failed validation, or denied GitHub update causes no branch change.
  • PR code cannot read the GitHub App credential or model credential.
  • PR code cannot access an external network endpoint.
  • The branch update starts the normal PR CI workflows.
  • Unit tests cover content conflicts, stale revisions, unsupported files, extra file changes, and malformed output.
  • Workflow-boundary tests cover permissions, trusted source code, pinned dependencies, artifact provenance, and sandbox cleanup.
  • A staging-repository test proves the GitHub App creates a verified commit and starts CI.
  • CONTRIBUTING.md explains the opt-in label, supported files, and failure behavior.
  • A documentation writer reviews the implementation and the contributor guidance.

Category

Feature

Checklist

  • I searched existing issues and this is not a duplicate.
  • I described the problem and desired behavior.

Metadata

Metadata

Assignees

Labels

CI/CDarea: ciCI workflows, checks, release automation, or GitHub ActionschoreBuild, CI, dependency, or tooling maintenance

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions