Skip to content

Publishing

Publishing

The default pipeline keeps writing the PR separate from changing the remote:

  1. pr-description is an agent phase. It inspects the committed work and writes only {{RUN_DIR}}/pr.md.
  2. publish is a driver phase. It verifies the clean, approved tree, pushes the configured branch, and creates or updates the pull request through the configured backend.

The description file starts with a one-line title, then a blank line, then a non-empty body. The shipped prompt asks for a body under 250 words:

Title: Add request tracing
Summarizes the implementation, validation, review outcome, and deliberate
out-of-scope work.

The description phase must not commit, push, or call a pull-request service. Changes to the run worktree’s status or HEAD, the run’s branch ref, or any tag ref stall the description phase. Changes to other refs generate a warning when the phase otherwise passes.

Publish safeguards

Before the driver changes a remote, it requires:

  • a clean worktree;
  • a current HEAD at the latest approved review SHA or the single scoped commit recorded by the evidence phase. In a multi-reviewer round, the approval comes from the completed aggregate verdict;
  • a passing gate receipt for that same SHA, dated before the approval.

A recorded repeated-blockers override from the repeated-blocker judge can stand in for the approval. The gate receipt is still required, and the run logs that it is publishing with unresolved review findings.

Then it runs the backend precheck, pushes with upstream tracking, and reads the remote branch SHA. If that SHA differs from the attested local head, the run stalls before any PR is created or updated. Rerunning the evidence phase can replace a previous evidence commit using a Git lease pinned to the recorded replacement SHA. The driver adds the recorded Evidence section to the body, updates or creates the branch’s PR, and looks it up once more.

The final PR must report the configured base branch, the attested head SHA, the draft state, a URL, and a numeric PR number. A missing or mismatched value stalls the run. A stalled publish phase stays incomplete, so --resume retries it with the existing run artifacts and commits intact.

GitHub backend

GitHub is the default, through the signed-in gh CLI. The precheck resolves the configured Git remote to a GitHub repository and runs gh auth status. Every PR lookup, creation, and update is bound to that repository with --repo, so a repository with several remotes still uses the configured remote. publish.draft defaults to true. Set it to false to create PRs that are ready for review.

export default {
remote: 'origin',
phases: ['implement', 'docs', 'gate', 'review', 'pr-description', 'publish'],
publish: { backend: 'github', draft: true },
};

You need network access and a signed-in gh. Run aloop doctor before a real run to check the local CLI prerequisites.

GitLab backend

Set publish.backend to 'gitlab' to use the bundled transport, which relies on the signed-in glab CLI:

publish: { backend: 'gitlab', draft: true }

The backend finds the GitLab host and full project path from the configured Git remote. It handles HTTPS, SSH, scp-style remotes, nested groups, and self-hosted instances with ports. The precheck runs glab auth status for that host. Publishing uses --repo https://<host>/<project>, so the configured remote picks the repository. The final merge request is checked against the target branch, approved head SHA, URL, IID, and draft state.

GitLab drafts use both the native draft flag and the Draft: title prefix. An existing Draft: or WIP: prefix isn’t duplicated. With publish.draft: false, either prefix is removed from the title and the update uses GitLab’s --ready option. glab must be installed and signed in. If it isn’t, the precheck fails before anything is pushed.

For a REST, MCP, or other GitLab client, import gitlabBackend and inject a transport. The transport works in GitLab’s own terms, and the backend maps merge requests to aloop’s verified pull-request shape:

MethodContext in, result out
checkAuth{ host }. Resolves or throws.
getMergeRequest{ host, project, branch }. Returns { iid, web_url, target_branch, sha, draft } (or legacy work_in_progress), or null.
createMergeRequest{ host, project, sourceBranch, targetBranch, title, description, descriptionFilePath, draft }
updateMergeRequest{ host, project, iid, branch, title, description, descriptionFilePath, draft }
listMergedRequestsOptional. { host, project, branch, base }. Returns merged MRs as { state, target_branch, sha }. Only aloop clean --branches calls it. Without it, that check keeps the branch.
import { gitlabBackend } from '@syntax-syllogism/aloop';
const myMcpTransport = {
checkAuth,
getMergeRequest,
createMergeRequest,
updateMergeRequest,
};
export default {
publish: { backend: gitlabBackend({ transport: myMcpTransport }), draft: true },
};

Custom backends

To use another service, set publish.backend to an object with all four required operations. The driver passes these contexts:

{
async precheck({ remote, branch, base }) {},
async view({ remote, branch, base }) {},
async create({ remote, branch, base, title, body, bodyFilePath, draft }) {},
async update({ remote, branch, base, title, body, bodyFilePath, draft }) {},
// Optional. Only `aloop clean --branches` calls it.
async mergedRequests({ remote, branch, base }) {},
}

view returns the existing PR, or null if there isn’t one. After create or update, the final view result must contain url, an integer number, baseRefName, headRefOid, and a boolean isDraft. They must match the configured base, the approved SHA, and the draft setting. bodyFilePath points to a temporary body-only file in the run directory, which the driver removes afterward. A backend can use either body or that path.

The view result includes state alongside url, number, baseRefName, headRefOid, and isDraft. The driver updates an existing request only when its state is OPEN. A closed or merged request on a reused branch leads to a new request, and the driver verifies that the resulting request is open. The bundled GitLab backend maps opened to OPEN.

The optional mergedRequests operation returns the merged requests whose head is branch and whose target is base, as an array of { state, baseRefName, headRefOid }. state must be 'MERGED', and headRefOid must be a full commit SHA. aloop clean --branches uses these to confirm squash merges. A backend without this operation keeps those branches and prints a warning. The publish phase doesn’t need it.

The publish result is kept in manifest.json on the publish phase: approvedSha, remoteSha, prUrl, and the verified pullRequest object. The URL also appears in the run report and in aloop status and aloop inspect --json.