Batch PR Resolver Skill
Purpose
Create one queue task per open pull request so each PR branch can be resolved by pr-resolver on its existing branch. Fork PRs are skipped.
This parent batch skill does not publish repository changes itself. It records
child workflow queueing evidence in artifacts/batch_pr_resolver_result.json;
each queued existing-PR coordinator delegates repository publication to its pr-resolver children and owns their durable external waits.
The coordinator's execution-local publish mode none does not override the
children's auto publishing contract. Preserve any explicit user restriction
on child publishing; do not infer one from the coordinator's local mode.
Inputs (skill args)
repo(string, required): Target repository inowner/repoform.repositoryConnectionRef(string, optional): Existing Git connection selector. The helper derives it from the parent's canonical repository target, thenMOONMIND_REPOSITORY_CONNECTION_REF; this input overrides that selection. Legacy credential secret references never select a connection. Admission still verifies the connection's permitted scope and operations.state(string, optional): PR state filter for discovery. Default isopen. Using other states prints a warning.pullRequests(string, optional): Only queue these PRs, as numbers or inclusive ranges such as4724-4746, 4765. The helper inherits this field from the parent task context when its CLI override is omitted. When omitted everywhere, every open PR is queued.maxAttempts(number, optional): Queue jobmaxAttemptsfor each created task. Default3.priority(number, optional): Queue job priority. Default0.mergeMethod(string, optional): Merge method passed topr-resolver. Defaultsquash.maxIterations(number, optional):pr-resolverloop cap. Default5.childInstructions(string, optional): Additional requirements appended to every queued resolver's instructions. The helper inherits this field from the parent task context when its CLI override is omitted.runtimeMode(string, optional): Runtime to stamp onto each queuedpr-resolvertask. When omitted, the helper falls back to inherited task context or deployment defaults.runtimeModel(string, optional): Explicit model override to stamp onto each queuedpr-resolvertask.runtimeEffort(string, optional): Explicit effort override to stamp onto each queuedpr-resolvertask.runtimeProviderProfile(string, optional): Explicit provider-profile override to stamp onto each queuedpr-resolvertask.
Workflow
The helper requires Python 3 and httpx, plus gh for discovery. Keep the
portable _shared/workflow_execution_client.py beside the skill directories;
resolved snapshots include it automatically. No MoonMind or API-service
installation is required. Resolve helpers exclusively from the run's immutable
active bundle:
BATCH_PR_RESOLVER_SKILL_DIR="${BATCH_PR_RESOLVER_SKILL_DIR:-${MOONMIND_ACTIVE_SKILLS_DIR:+$MOONMIND_ACTIVE_SKILLS_DIR/batch-pr-resolver}}"
test -n "$BATCH_PR_RESOLVER_SKILL_DIR" && test -f "$BATCH_PR_RESOLVER_SKILL_DIR/SKILL.md"
Inside MoonMind, MOONMIND_ACTIVE_SKILLS_DIR is always set; a checked-in
.agents/skills directory must never shadow the selected snapshot. When no
skill-specific override is present, the helper resolves to
${MOONMIND_ACTIVE_SKILLS_DIR:-.agents/skills}/batch-pr-resolver/bin/batch_pr_resolver.py.
Outside
MoonMind, set BATCH_PR_RESOLVER_SKILL_DIR to the directory containing this
SKILL.md (no MoonMind-only environment variables required). A missing
selected helper is a materialization/packaging error: stop as blocked instead
of substituting stale repository code.
- Run the helper script:
python3 "$BATCH_PR_RESOLVER_SKILL_DIR/bin/batch_pr_resolver.py" \
--repo <owner/repo> \
--state <open|merged|closed> \
--max-attempts 3 \
--priority 0 \
--merge-method squash \
--max-iterations 5 \
--runtime-mode <runtime_mode> \
--runtime-model <model> \
--runtime-effort <effort> \
--runtime-provider-profile <profile_id>
- Map inputs to flags:
repo->--reporepositoryConnectionRef->--repository-connection-refstate->--statepullRequests->--pull-requestsmaxAttempts->--max-attemptspriority->--prioritymergeMethod->--merge-methodmaxIterations->--max-iterationschildInstructions->--child-instructionsruntimeMode->--runtime-moderuntimeModel->--runtime-modelruntimeEffort->--runtime-effortruntimeProviderProfile->--runtime-provider-profile
Always forward the parent task's explicit runtime selection fields when they are present so the queued pr-resolver tasks reuse the same runtime, model, effort, and provider profile instead of falling back to the deployment default runtime.
Carry user constraints into every child through childInstructions; pass
--child-instructions explicitly when no task context is materialized.
The adopting PR coordinator carries these instructions through its durable
gate into each repair and final resolver pass.
When the request names specific PRs or a PR range (for example "Select PRs
from #4724 to #4746"), pass that selection with --pull-requests so the
helper filters discovery before it submits anything. Never wrap, shim, or
monkeypatch the helper to narrow its selection; a selection the flag cannot
express is a blocker to report, not a reason to queue every open PR.
- For each selected open PR in the target repo (every open PR when no selection is given):
- Skip PRs identified as cross-repository (
isCrossRepository=true) or whose head is not onowner/repo. - Build a canonical queue task with:
type: "task"payload.idempotencyKey: stable per parent batch run and PR, hash-backed and capped to the execution persistence limit, so rerunning the same batch task does not create duplicate resolver workflows.payload.repository:{ provider: "git", connectionRef, repository: { name: repo }, branch: { name: headRefName } }when an existing connection selector is available; otherwise the target repo string for admission to resolve. Each target uses its discovered PR head branch, never the parent's shared branch. Existing-PR adoption resolves the PR's base/head and publication scope.payload.task.taskTemplate.slug:pr-review-resolvepayload.task.taskTemplate.inputs:{ repository: repo, pull_request: pr_number, review_provider: "none", finish_with_pr_resolver: true, merge_method: mergeMethod, max_iterations: maxIterations }- inherited runtime, model, effort, and Provider Profile fields.
- Trusted preset expansion resolves the existing PR branch and publication scope. The coordinator publishes nothing itself; its ordinary
pr-resolverchildren own fixes and merge. CI/provider waits return to that enclosing durable gate so queued self-hosted Tactics checks do not consume an agent slot. Preserve all Tactics CI on self-hosted runners. - Submit via the internal Temporal execution API (
POST /api/executions),
require the canonical workflowId in the response, and verify that ID via
GET /api/executions/{workflowId} before counting it as queued;
MOONMIND_URL must point at the MoonMind API from the managed session.
When MoonMind supplies MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN_FILE
(preferred) or MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN, read and forward
the execution-scoped bearer and mark both calls as fan-out v1. A declared
token file that is missing or empty is a hard failure; do not fall back to
the ambient value.
- Write one summary artifact at
batch_pr_resolver_result.jsonunder the managed session artifact spool path when available, otherwise under the configured--artifacts-dir. For the defaultartifactspath, use a materialized task context's artifact directory when present; a missing context never redirects writes outside the current run workspace. The helper binds it toMOONMIND_STEP_EXECUTION_IDand recordsrunningbefore discovery, thenqueued,no_op,partial_failure, orfailed. MoonMind validates this terminal evidence before accepting completion; a clean harness exit with no result is incomplete. - On any submission or verification error, write
skill_outcome.jsonwith a
failed or partial status so the managed runtime cannot report the batch
as successful.
- Print a short count summary to stdout (
queued,skipped,errors).
Security constraints
- Reject missing
repounless it can be inferred fromgit remote originfallback. - Use
state=openby default to avoid accidental non-open PR dispatch. - Skip fork PRs by default: PRs identified as cross-repository
(isCrossRepository=true) or whose head is not on owner/repo are recorded
as fork-pr skips. There is no fork-inclusion option; queued pr-resolver
jobs cannot reliably check out fork-only head refs.
- Require
MOONMIND_URLto reach the MoonMind API; the legacy direct-DB queue fallback is intentionally unsupported.