Repository navigation
factory: the factory on this Mac opens at once, whatever old jobs and GitHub do - #2101
Merged
Merged
Conversation
… and GitHub do Root cause: on resume the app ran the clean-up of old PR jobs before the local factory served. On the owner's floor one old PR job (#1796) had its worktree in a folder named by an earlier release (CodeAF-1796, not codeaf-1796), so `git branch -D` was refused as "used by worktree" and the clean-up failed the same way at every launch. The resume error was dropped, the row kept the last launch's dead port, and every read went there: "isn't answering". No gh call was involved in that failure. - The server comes up first; the clean-up runs behind it under the host (close waits for it), skips a job a live worker holds, keeps a job it cannot clean for the next launch, and never fails the start. - Discard finds the job's worktree by the branch it holds inside the work root, so a folder named by an earlier release is removed too. - Who the person is comes from what GitHub last said (github-link.json on the floor, a login, never a token), asked again behind the reads with backoff; connecting GitHub again forgets it. - gh's token answer is cached for a minute and asked behind the reads; the gh call is bounded by WaitDelay, since a child holding gh's output open made the 3 s timeout a minute. - A pipeline read never waits on the forge longer than 300 ms: the last file, else the checkout's, while the forge is asked behind; the loader's lock is no longer held across a network call.
…ns still do Review follow-ups: - A PR job the clean-up cannot forget keeps its lease and its history; only forgotten jobs lose them (a kept job lost its history before). - Pipeline reads wait on the forge again for actions (start, edit, merge); only reads marked ShowOnly (the queue's and a card's recipes) wait at most FirstWait, and a cold one answers the checkout's file with no problem. - CODEOWNERS reads (queue, job card) never hold their lock over the forge and wait at most FirstWait for a repository not read yet. - One single-flight helper (behind) and one bound (FirstWait, 150 ms) for the pipeline and owners reads; gh and the person's link use the same bound. - gh that hangs keeps its last token; the person GitHub last named is kept in memory, an answer of nobody keeps them, and an ask out when the person connects GitHub again is dropped. - The standalone `codeaf factory serve` forgets old PR jobs behind the service too.
A start or edit joined a view's ask that was out for a forge that did not answer, and waited its whole 30 s; an action reads under its own context.
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.
Summary
Opening the app could leave the factory on this Mac answering "isn't answering yet" at every launch. The factory now opens right away from what is on disk. Housekeeping and GitHub run in the background behind it.
Root cause: when the app resumed, it cleaned up old PR jobs before the local factory started serving. In the affected data, one old PR job's worktree was in a folder named by an earlier release (
CodeAF-1796). The current release looks forcodeaf-1796. Because the worktree still used the branch,git branch -Dwas refused ("used by worktree"), and the clean-up failed the same way at every launch. That error was dropped. The saved row then kept the previous launch's port, so every read went to a dead address. No gh call was involved in this failure.While reproducing it, I found a second cause of the same symptom: with gh signed in but hanging, or with a network that swallows requests, list, queue and job reads each waited on GitHub until they hit their time budget.
Actions such as start, edit and merge still wait for GitHub's current pipeline file. Only reads that just show data are bounded.
Evidence
The app engine was driven over its stdio wire with
factory.list, thenfactory.queue, thenfactory.job.A copy of the affected floor (349 jobs, 51 old PR jobs, saved row on a dead port, gh configured and hanging, on a case-insensitive filesystem):
factory.listtook 3.0 s and returnedunreachableat the dead port.factory.queuereturned "the local factory is not running for this app". The row was unchanged, and 51 PR jobs were left.factory.listtook 0.57 s and returnedokat a fresh port.factory.queuetook 0.19 s and returned 298 jobs. The row was rewritten. The clean-up finished in the background and left 0 PR jobs.A real repository, after setup through gh. Each case is a relaunch.
unreachable/ 20 s "not answering"ok/ 0.03 s, 6 jobs / okunreachable/ 20 s "not answering"ok/ 0.04 s / okTests. Each one was red before the fix and green after it:
TestTheFactoryOpensAtOnceWhatEverHousekeepingAndGitHubDo: a stalled, failing clean-up, a hanging gh and a stale port. List and queue answer in under 1 s, the row moves to a new address, and the jobs are there. Before: 16 s, then "not running".TestTheFactoryOpensAtOnceWhenGitHubDoesNotAnswer: GitHub never answers. The factory opens in under 1 s, still names the last person, and GitHub is asked again in the background. Before: 45 s, then "not answering".TestDiscardFindsTheJobsWorktreeUnderAnEarlierName: reproduces the exactused by worktreeerror, which is now fixed.TestAPRJobThatCannotBeForgottenIsKeptWholeAndTheRestGo: a held job keeps its record and history, and the other jobs are removed.TestAPipelineReadNeverWaitsOnASilentForge,TestCodeOwnersNeverHoldAReadOnASilentForge,TestAHangingGHNeverHoldsTheReadsThatAskForTheToken: before, these hung or took 4 s; now each finishes in under 1 s.I did not run
make pr-ready. These checks were run on this branch:go test -race ./internal/factory/githubpasses../cmd/codeaffactory tests pass.TestPublishCommitsPushesAndOpensThePullRequestWithTheTrailerfails on the base branch too../cmd/codeaffactory run passes in full.build-check,vetandfmt-checkpass.test-lawsfails on the base branch in the same places: comment, lock-defer, session complexity and taxonomy. This branch adds no new law failures.Merge Danger
Door: two-way
The only new on-disk file is
github-link.jsonon the floor. It holds a login, never a token. The clean-up still deletes the same things, but now only for jobs it can actually clean.Blast Radius: factory
🤖 Generated with Claude Code