Repository navigation
Post-merge completion closes issues across repository boundaries: a merged PR in another repo can close an unrelated factory issue #276
Description
Factory's post-merge "advance to Done" path can close an issue in one repository because a pull request merged in a different repository, and it has already closed real, unfixed work as complete. At least 8 issues were falsely closed; 2 more closures in the same sample were legitimate.
All resolutions in this report were measured on 2026-08-16 against origin/main at f13600f32107e499bfccc6f971f7863fe5822927. Absence claims decay — re-measure before relying on them.
Discovered during the PR-triage sweep of #178 / #146.
The consequence, first
The clearest instance is #211 — "Key dispatch claims on work-unit identity, not surface path."
That issue was closed as completed on 2026-08-12. Its defect is still on origin/main, verbatim, at src/orchestrator/batch-tracker.ts:292:
export const issueKey = (issue: IssueRef): string => `${issue.key}:${issue.uuid}:${issue.path}`So the mechanism described below closed, as complete, the very ticket that describes why a bare locator is not an identity. This is #228's thesis ("one identity model behind the duplicate-claim, dual-attribution, and 403 symptoms") demonstrated on Factory's own reconciliation path.
Evidence
Every one of these issues was closed by a comment of the exact form:
Factory observed pull request #N merge and completed this issue.
That string is emitted from exactly one place — src/orchestrator/factory.ts:11922 — so the closures are unambiguously attributable to the code path analysed below.
As of 2026-08-16, the highest number in AgentWorkforce/factory across both the issue and PR spaces is #275. Cited numbers above that cannot exist in this repository in any form.
| factory issue | closed (UTC) | cites | resolves in factory as |
same number in AgentWorkforce/cloud |
|---|---|---|---|---|
| #211 | 2026-08-12 | #274 | did not exist in any form on the closure date — factory's high-water mark was then ~#236, so the citation pointed ~38 numbers into the future | cloud#274 — chore: delete dead sandbox Dockerfiles |
| #221 | 2026-08-14 | #1518 | does not exist, any type (above factory's whole number space) | cloud#1518 — neon: split runtime and migration DB |
| #139 | 2026-08-13 | #2891 | does not exist, any type (above factory's whole number space) | cloud#2891 — fix(relayauth): dormant emergency source mint gate |
| #146 | 2026-08-13 | #2895 | does not exist, any type (above factory's whole number space) | cloud#2895 — fix(relayauth): restore bounded mint and webhook recovery |
| #216 | 2026-08-13 | #219 | exists, but as an ISSUE, not a merged PR — "Stale-mount auto-refresh targets a stale directory", created 2026-08-07 | cloud#219 is a PR |
| #145 | 2026-07-21 | #1346 | does not exist, any type (above factory's whole number space) | cloud#1346 — Bump relayfile adapter-core trigger catalog |
| #143 | 2026-07-21 | #1346 | does not exist, any type (above factory's whole number space) | same as above |
| #260 | 2026-08-16 | #1533 | does not exist, any type (above factory's whole number space) | cloud#1533 — Revert #1532 (S6 wiring) |
| #222 | 2026-08-15 | #250 | real, merged — legitimate closure | — |
| #141 | 2026-07-20 | #148 | real, merged — legitimate closure | — |
Two precision notes, because a reviewer who checks will otherwise find the discrepancy and stop reading:
- GitHub shares one number space between issues and pull requests. "No PR at that number" is not the same as "no such number". That is why the Notion Factory Tasks DB → intake manifest generator #216 row reads differently from the others: factory#219 genuinely exists, as an issue.
- [factory] Key dispatch claims on work-unit identity, not surface path #211 is stated as of its closure date on purpose. A
factory#274does exist today — it was opened 2026-08-16 by an unrelated lane, four days after this closure. The claim is that on 2026-08-12 the cited number did not exist in any form.
Mechanism
This was read from the code, not inferred from the pairs above.
A merged-PR mount event knows exactly which repository it came from. src/orchestrator/factory.ts:11771 builds it:
const repo = `${parts.owner}/${parts.repo}`and passes it down at :11833 → #advanceMergedPrToDone(snapshot, repo, record).
Inside #advanceMergedPrToDone (:11893) there are two paths:
- With a tracked in-flight record — repository-qualified and correct. The record lookup at :11877 filters on
recordMatchesGithubRepo(record, eventRepo, this.#config.repos.org). - Without a record (the agents have already been released) — the fallback at :11905:
const issue = await this.#findMergeAdvanceIssueForPr(snapshot)repo is in scope on that line and is not passed. #findMergeAdvanceIssueForPr (:11963) takes only the snapshot, then scans every issue path from the configured source (#githubIssuePaths(), :11977) and scores each one with prSnapshotIssueMatchScore(snapshot, issue.key) (:11991). Nothing in that loop compares the issue's repository to the merged PR's repository.
The active contract has issueSource: "github" and 19 repositories in repos.names, so that scan spans all 19 — each with its own independent number space.
The scorer (:17166) is:
const prSnapshotIssueMatchScore = (snapshot: PullSnapshot, issueKey: string): number => {
if (factoryBranchMatchesIssue(snapshot.headRef ?? '', issueKey)) return 30
if (containsIssueKey(snapshot.title ?? '', issueKey)) return 20
if (containsExplicitIssueReference(snapshot.body ?? '', issueKey)) return 10
return 0
}For a GitHub-native issue, issue.key is a bare number. containsExplicitIssueReference (src/issue-key-match.ts:20-31) then matches that bare number against the PR body via, among others:
#211(?!\d)
https?://github\.com/[^\s/]+/[^\s/]+/issues/211(?!\d)
The URL alternative accepts [^\s/]+/[^\s/]+ — any owner and any repository. A merged PR in cloud whose body references cloud's own #211 therefore scores against factory's issue #211.
Two aggravating details in the same function:
- The in-flight scan de-duplicates score ties and bails out (
babysitterPrDiscoveryAmbiguous, :11886). The fallback scan has no ambiguity guard — on a tie the first match silently wins. - The closure comment then reports
snapshot.number(:11922), which is the other repository's PR number. That is why the citations look like they point at nonexistent factory PRs: they are real PR numbers, just not from this repository.
Open question
I have not reconstructed which specific merge event fired each individual closure — the mount projection history for those moments is not available to me, and several cited numbers resolve to PRs in other in-scope repos that merged months before the closure date (cloud#274 merged 2026-04-22; factory#211 closed 2026-08-12). So a re-projection or backfill of an already-merged PR is likely part of the trigger, and worth confirming. The missing repository qualification at :11905 is read directly from the code and does not depend on that reconstruction.
Suggested direction
Pass the known repo into #findMergeAdvanceIssueForPr and require the candidate issue's repository to equal the merged PR's repository — the same qualification the in-flight path already applies at :11877. Adding the fallback's own ambiguity guard would close the tie-break gap alongside it.
Per #228, the durable fix is that a claim belongs to the work unit, not to a bare locator: a number is only an identity once qualified by its repository.
Not done here
The 8 falsely-closed issues are being audited separately to determine whether each one's work actually landed on main. Nothing has been reopened — that decision is deliberately left to a human.
Activity
khaliqgant commentedon Aug 16, 2026
Audit of the 8 falsely-closed issues
Did the work actually land, regardless of what the issue state says? Verdicts are from code on
origin/main@f13600f3, measured 2026-08-16 — not from issue or PR state.Result: 6 not done, 2 genuinely done. Nothing has been reopened.
origin/mainsrc/orchestrator/batch-tracker.ts:292still keys on the surface path verbatim:`${issue.key}:${issue.uuid}:${issue.path}`gh:src/github/standalone-babysitter.ts:3importsGhRunner, invoked at:81and:86; thesource: 'mount' | 'gh' | 'mount+gh'union is still at:28and:99. App authorship still separate atsrc/mount/relayfile-github-connection-write.ts:97(author: 'app').git grep -i "directory|card|skill"oversrc/ports/fleet.tsandsrc/fleet/relay-fleet-client.tsreturns zero hits; noa2a/directoryreference anywhere insrc/.AgentWorkforce/factory-test-infrawas created 2026-07-21 but contains onlyREADME.md— no substrate. Factory-side provider wiring absent:src/environments/ships only Kubernetes providers (KubernetesEnvironmentProvider,KubectlEnvironmentProviderinindex.ts:52,153). The onlycloudflarestring in the tree is a test fixture (verification-stack-deployer.test.ts:275).src/intake/notion.tsonly reads a manifest already on disk (readFileat:196) — no Notion database query, nodata_sourcecall. That loader predates this issue (PR #215) and is explicitly named in the issue as not the deliverable.git grep "trajectory|work_unit_id|work_unit_surface"oversrc/returns zero hits, so no Factory-opened PR body carries the marker — placeholder or otherwise. (ThesessionRefhits undersrc/fleet/are the pre-existing spawn/resume continuation field, a different concern.)VerificationPipelineconstructed atsrc/orchestrator/factory.ts:721-729, and consumed in the merge gate at:14917-14954whereif (!verification.passed)blocks the merge (verificationGateFailed/verificationGatePassed).src/environments/verification-stack-descriptor.tsandsrc/environments/verification-stack-deployer.ts, exported viasrc/environments/index.ts:93-120, with the descriptor path default.factory/verification-stack.yamlinsrc/config/schema.ts:244.One nuance worth separating
#143 and #145 are the two closures dated 2026-07-21, and both cited the same number, #1346 — which does not exist in this repository in any form. Their work had genuinely landed, just not via the cited PR.
So a spurious citation does not imply the work is missing, and a correct outcome does not imply the mechanism worked. These two closed correctly by accident. That is worth stating plainly, because "we spot-checked one and the work was there" is exactly the check that would have let this defect survive.
The reopen decision is deliberately left to a human.
kjgbot commentedon Aug 16, 2026
Fix PR: #278 —
fix/276-crossrepo-mergeadvance.Mechanism confirmed against
origin/mainatf13600f. File has drifted since the analysis was written; the current line numbers are:#advanceMergedPrToDone(snapshot, repo, record?)at :11893 (already carriesrepo), record-less fallback at :11905 calling#findMergeAdvanceIssueForPr(snapshot)and droppingrepo, definition at :11963, scorer at :17167, closing comment at :11922. Behaviour matches this issue verbatim.Fix: Pass
repointo#findMergeAdvanceIssueForPrand filter candidates usinggithubIssuePathParts(same shaperecordMatchesGithubRepouses). Also add the ambiguity guard the tracked path already carries (new countermergedPrAdvanceAmbiguous) so a same-score tie fails toward NOT closing. Fail-closed ifeventRepois not a valid github repo.Completeness grep:
#findMergeAdvanceIssueForPrhas one call site (:11905, covered by this PR).#advanceMergedPrToDonehas three call sites —#restoreBabysitterOwnership:10634, and the two#handlePrChangebranches at:11778,:11833— all three already passrepo, so the qualification now reaches through the full chain. Other consumers ofprSnapshotIssueMatchScore(:4173,:9167,:9180,:10293,:10326) all key onsession.issue.key/record.issue.key, which is already repo-qualified via its carrier. No other unqualified bare-number completion path was found.Tests (grounded in observed pairs):
https://github.com/AgentWorkforce/cloud/issues/139must NOT close factory#139. Passes with fix; fails onorigin/mainwithout it.factory/222-fixMUST still close factory#222 through the same fallback. Deleting the fallback outright would regress this.479/479
factory.test.tspass.tscclean.Not closing this issue. The principal owns that gate.
kjgbot commentedon Aug 16, 2026
CI status on PR #278 (
fix/276-crossrepo-mergeadvance, run 31966854246 @ 4m11s):kubernetes-provider-e2e— pass (2m35s)load-e2e— pass (2m4s)package— pass (4m6s)verification-gate-e2e— pass (3m5s)verification-stack-e2e— pass (2m3s)cubic · AI code reviewer— pass (3m4s)CodeRabbit— pass (skipped, OSS auto-skip)Reviewsaur Quiz— pending (perpetually 0s / never-completes on this repo; same state on fix(factory): reserve exit 0 for actions that were performed (#266) #274 and fix(orchestrator): let a released invocation spawn again (#229) #275 — unrelated to this PR)All GitHub Actions and actionable third-party checks green.
gh pr view 278 --json mergeStateStatusreturnsUNSTABLEsolely because of Reviewsaur — same posture as every recent PR on this repo.fix(factory): repo-qualify record-less merge-advance fallback (#276) (#…
miyaontherelay commentedon Aug 17, 2026
Environment check (before audit):
miyaontherelay commentedon Aug 17, 2026
Audit ref:
origin/main7122524352c6a02fd437922339534c9aaa9ea8afAll rows measured at
2026-08-17T08:34:34Z. Verdicts use the deployed source ref, not issue state.origin/main:src/orchestrator/batch-tracker.ts:344still definesissueKeyas key + uuid + mutable path.src/orchestrator/factory.ts:4526,4539-4542uses that key for the durable claim. The compensating GitHub-only scan also remains atsrc/state/in-memory-state-store.ts:180-190and itsclaim.key ?? keypropagation atsrc/orchestrator/factory.ts:3029.source: "gh"is read provenance, not a write; it only invokesgh pr view(src/github/standalone-babysitter.ts:86-100). The identity guarantee nevertheless fails: Factory defaults toGhCliGithubWriteback(src/orchestrator/factory.ts:716-720), which runsgh pr create(src/writeback/github.ts:123-136) and issue comments (:194-204); guarded merge isgh pr merge(src/github/merge-gate.ts:80-92) via the local runner (:175-179) and is called by Factory (src/orchestrator/factory.ts:15026-15030). The Notion publisher also creates/edits throughrunGh(src/intake/notion.ts:399-410->:930-936). These writes have no app-authorship path or read-back assertion.FleetClientstill has placementroster()and direct message primitives only (origin/main:src/ports/fleet.ts:133-182), with no peer-directory lookup or worker ask capability. Complete source/test probe `git -C /Users/khaliqgant/Projects/AgentWorkforce/factory grep -n -i -E "a2anew KubectlEnvironmentProvider()(origin/main:src/environments/verification-pipeline.ts:177-180), not a Cloudflare provider. Complete probe for `CloudflareEnvironmentProvidermainat measurement, so this work is not onorigin/main. Current intake is still a manifest consumer:origin/main:src/intake/notion.ts:194-197loads JSON throughmanifestSchema, and CLI requires a manifest path atsrc/cli/fleet.ts:557-560; it is not the database manifest generator.origin/main:src/environments/verification-pipeline.ts:261-373) and always attempts teardown (:399-439). Factory blocks before merge on a non-pass verdict (src/orchestrator/factory.ts:14984-15030). The E2E asserts green, E2E-red, load-red, timeout/reap, reporting, and green-only merge (test/e2e/verification-gate.e2e.ts:86-125); CI creates kind and runs it (.github/workflows/ci.yml:152-187). Theverification-gate-e2echeck for this SHA completed success at2026-08-16T21:55:36Z.origin/main:src/environments/verification-stack-descriptor.ts:170-208) and exported (src/environments/index.ts:79-119), but the permitted source kinds are Helm, kustomize, manifests, and docker-compose only (verification-stack-descriptor.ts:68-95). The deployer is explicitly Kubernetes-targeted (verification-stack-deployer.ts:84,98-105), so the required Cloudflare Workers/Containers deployment path is not landed.implementer.sessionRefseparately (origin/main:src/orchestrator/factory.ts:7819-7820), but the PR-body builder takes only issue + preview and emits no trajectory pointer (:17635-17646). Complete pointer probe for `<!-- trajectory:Closure-number reconciliation (the original closure comments, not the verdicts):
For #274, creation time proves nonexistence at closure. For the other absent high numbers, factory cannot have had them at closure: issue/PR numbers are monotonic and its present number space is below them. #219 instead resolves to the wrong object type. No issue state or closure comment was used as completion evidence.