Repository navigation
Factory: Guard trunk conflicts, file follow-ups for partial PRs, and keep worktrees in the checkout - #1115
Merged
Conversation
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.
What it does
A full
/factory runover the queue (twenty jobs) stopped or went wrong in several places. This branch fixes them:factory/worktrees/in the checkout that runs the factory.job pushrefuses a branch that conflicts withtrunkand names the files, andjob cireports a conflicting PR asCI: FAILwith the reason.Related to #<issue>, and merging it files the parts intake left out as newfactoryissues.job body <job> <file>replaces the body of the job's own PR, so a builder never runsgh pr edit.job queuewarns when the main checkout's agents or/factoryskill differ from this checkout's.holdrow names what is ahead of it.Rationale
Each item is something the run hit:
<name>-factory/<job-id>), so every builder was refused its first edit.pull_requestchecks on a PR that conflicts with its base. After another Pages PR merged, a factory PR passed all five reviews and then waited ten minutes for checks that could not start;CI: NONEwould have sent a fixable job to a maintainer.Closes, so merging it would have closed an issue with work left in it and nothing queued for the rest.gh pr editsits behind the operator's permission prompt, so a builder that updated its PR body in a later round stopped the run until someone answered..claude/agents/and the skill from the main checkout while the scripts run from the session's checkout. This run started with the previous day's agents stepping the new scripts.For conflicts, failing the gate was the other option. It costs a round and still spawns no fix, while refusing the push lets the builder merge
trunkinside the round it is already in.Implementation
All in
factory/bin/jobunless noted.docs/software-factory.mdcovers each change.Conflicts. One helper answers both commands:
cmd_pushdies on a non-empty list.cmd_ciasks GitHub formergeableon each poll and writesCI: FAILat once when no check has reported and the PR isCONFLICTING. That keeps the normal path: a red CI is a failed round, and the builder readsci.md.Follow-ups. Intake writes a
## Follow-upssection (### <title>plus a few sentences each) when it setsRESCOPED: yes. On→ merged, when the PR'sclosingIssuesReferenceslacks the job's issue,file_followups()creates one issue per entry with the queue label, up tomax_followups(new infactory/config.json, default 5). It records each infollowups.jsonas it goes, so a failedgh issue createstops the move and a retry files only what is missing. The umbrella issue gets one comment naming them and leaves the queue.own_issues()readsRelated to #<n>from the PR's first line, so another checkout still sees the issue as taken.Refs #<n>, which the open factory PRs carry, reads the same.job body. For an issue job inbuildonly. It refuses a file outside the worktree, a PR whose head is not the job's branch, and a body that does not open withCloses #<issue>orRelated to #<issue>. The Screenshots block and the Playground preview block are copied from the live body when the new one leaves them out.Worktrees.
WORKTREES = FACTORY / "worktrees";sync()adopts a job whose worktree was moved there.factory/trunk.shandfactory/seed.shuse the same folder,.gitignoreignores it, andphpcs.xml.distexcludes it so hostphpcsdoes not walk every job's copy of the plugin.Gate.
factory/checks.shsets anEXITtrap that stops the tests stack it started.Testing instructions
From a Claude Code worktree of this branch, with the main checkout on
trunk:factory/bin/job queue. Stderr names the agent files that differ from the main checkout's; stdout lists the queue as before. After the main checkout pulls this branch, the warning is gone.factory/trunk.sh, thenls factory/worktrees/:trunkis there, andgit statusshows nothing new.vendor/bin/phpcs -nwith job worktrees present finishes in about the time it takes without them.What the run itself showed on this code:
trunk:job ciwroteCI: FAILwith the reason in under a minute, the builder mergedtrunk,job pushaccepted the result, and CI went green.factorylabel, commented on Full product audit, Part 2: 11 bugs in settings, sharing, navigation, and large-data behavior #560 and took it out of the queue.Not exercised on a live job:
job pushrefusing a conflicting branch (only the passing path ran), andjob bodycalled by a builder. I checkedjob body, the merged transition and the review transitions against a stubbedghon throwaway jobs; those scripts are not part of this branch.