feat(MAPCO-11436): worker builds the branch, commit and PR in code - #10
Open
razbroc wants to merge 1 commit into
Open
feat(MAPCO-11436): worker builds the branch, commit and PR in code#10razbroc wants to merge 1 commit into
razbroc wants to merge 1 commit into
Conversation
MAPCO-11436. The worker derives the branch name and the conventional-commit
title in code from the Jira issue type and does the git and GitHub work itself.
The model never runs git, never sees a token and is never asked to follow the
naming rules.
Branches are agent/{type}/MAPCO-XXXXX-slug with the agent/ segment leftmost so
they stay greppable and can be protected later. Titles use the real type rather
than being flattened to chore:, so a merged feat: cuts a release — an
agent-authored feature is a feature. A Bug maps to fix:, not bug:, because bug
is absent from @map-colonies/commitlint-config's type-enum and would fail the
repo's own commit hook.
Pushing to master is rejected structurally: the default branch is refused as a
push target before a token is minted, and there is no force, delete, merge or
approve method to call. Verified against a real bare remote with hostile hooks.
`TokenProvider` has no implementation — per-run installation tokens need the
GitHub App from MAPCO-11428. Not wired into runCycle, and nothing clones yet.
|
🎫 Related Jira Issue: MAPCO-11436 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #9 — review that first, and this PR retargets as the stack merges.
The output the mechanism exists for. Once a verified diff is in the working tree, the worker itself commits it, pushes a branch and opens a PR.
This is worker code, not agent instructions. The model never runs git, never sees a token, and is never asked to follow the naming rules — the worker computes the branch name and the commit title from the Jira issue and writes them. These constraints are only real if code enforces them; a prompt that says "never push to master" enforces nothing.
Naming is derived, not requested
Branch is
agent/{type}/MAPCO-XXXXX-short-slug, with theagent/segment leftmost so agent branches stay greppable and can be protected against later. The slug comes from the feature title, not the repo prefix — a ticket summary is<repo-name>: <feature title>and only the part before the first colon is the repo name, soresolveRepo's existing split is reused rather than duplicated.Slugification is where this kind of code usually breaks, so it is tested against summaries that are pure punctuation, 400 characters long, unicode, already containing slashes, ending in a dot, and ending in
.lock.fix:, notbug:The ticket says the type is
feat,bugorchore.bugis not in@map-colonies/commitlint-config'stype-enum— I confirmed that against the installed package — so abug:subject would fail this repo's own commit hook. The mapping is therefore{ feat, bug → fix, chore }, and the ticket's wording predates checking the org config.Titles are not flattened to
chore:. Around 109 MapColonies repos run release-please, so a mergedfeat:will cut a release. That is accepted — an agent-authored feature is a feature.Verified rather than asserted: 101 generated commit messages (23 hostile summaries plus the full 78-case type × shape cross-product) were run through the real
commitlint --editagainst the org config. Zero failures, including emoji, Hebrew, Japanese, all-caps first words, trailing full stops andBREAKING CHANGE:subjects. The issue key sits in a trailing(KEY)reference because a leading key tripssubject-case.Pushing to master is structurally impossible
Not discouraged — impossible.
assertWritablerejects the default branch as a push target before a token is minted, andCliGithas no force, no delete, no merge and no approve method to call. Tested against a real bare remote with hostile hooks.The token never enters
argv: it goes through a git credential helper, and that is proven by handing the real snippet to the realgit credential fillrather than by string equality.Acceptance criteria
chore:(see thebug→fixnote)TokenProvider, but nothing implements it — App JWT signing plusPOST /app/installations/{id}/access_tokensneeds the GitHub App from MAPCO-11428.Known sharp edges
branchNameis deterministic per ticket andpushis a plain non-forcedrefs/heads/X:refs/heads/Xwith no fetch or rebase, so a ticket whose first attempt pushed and then failed atPOST /pullsgets rejected non-fast-forward on the second attempt and burns it. Confirmed against real git.git addargv, which is anE2BIGrisk on a clone whose test script leaves a large un-gitignored tree.maintainer_can_modify: truehas not been exercised against the live API for a same-repo head branch.git status --porcelainis parsed by byte offset — correct for the default format, wrong for a path containing a quote or newline. Fine for the emptiness check it feeds; don't build on it.Not wired in
publishPullRequesthas no caller. There is no clone step, noTokenProviderand no source ofGitIdentityto wire it with.Refs: MAPCO-11436