Skip to content
This repository was archived by the owner on Nov 6, 2026. It is now read-only.
This repository was archived by the owner on Nov 6, 2026. It is now read-only.

Post-merge completion closes issues across repository boundaries: a merged PR in another repo can close an unrelated factory issue #276

Closed

Description

@khaliqgant

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:

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:

  1. With a tracked in-flight record — repository-qualified and correct. The record lookup at :11877 filters on recordMatchesGithubRepo(record, eventRepo, this.#config.repos.org).
  2. 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

  1. khaliqgant commented on Aug 16, 2026

    @khaliqgant
    MemberAuthor

    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.

    issue verdict evidence on origin/main
    #211 NOT DONE src/orchestrator/batch-tracker.ts:292 still keys on the surface path verbatim: `${issue.key}:${issue.uuid}:${issue.path}`
    #221 NOT DONE Both identities intact. Babysitter still shells out to gh: src/github/standalone-babysitter.ts:3 imports GhRunner, invoked at :81 and :86; the source: 'mount' | 'gh' | 'mount+gh' union is still at :28 and :99. App authorship still separate at src/mount/relayfile-github-connection-write.ts:97 (author: 'app').
    #139 NOT DONE No directory-backed peer discovery exists. git grep -i "directory|card|skill" over src/ports/fleet.ts and src/fleet/relay-fleet-client.ts returns zero hits; no a2a/directory reference anywhere in src/.
    #146 NOT DONE AgentWorkforce/factory-test-infra was created 2026-07-21 but contains only README.md — no substrate. Factory-side provider wiring absent: src/environments/ ships only Kubernetes providers (KubernetesEnvironmentProvider, KubectlEnvironmentProvider in index.ts:52,153). The only cloudflare string in the tree is a test fixture (verification-stack-deployer.test.ts:275).
    #216 NOT DONE The generator that bridges Notion DB → manifest does not exist. src/intake/notion.ts only reads a manifest already on disk (readFile at :196) — no Notion database query, no data_source call. That loader predates this issue (PR #215) and is explicitly named in the issue as not the deliverable.
    #260 NOT DONE No trajectory pointer is written at all. git grep "trajectory|work_unit_id|work_unit_surface" over src/ returns zero hits, so no Factory-opened PR body carries the marker — placeholder or otherwise. (The sessionRef hits under src/fleet/ are the pre-existing spawn/resume continuation field, a different concern.)
    #145 GENUINELY DONE Verification gate is wired and enforcing. VerificationPipeline constructed at src/orchestrator/factory.ts:721-729, and consumed in the merge gate at :14917-14954 where if (!verification.passed) blocks the merge (verificationGateFailed / verificationGatePassed).
    #143 GENUINELY DONE Descriptor contract and deployer both shipped: src/environments/verification-stack-descriptor.ts and src/environments/verification-stack-deployer.ts, exported via src/environments/index.ts:93-120, with the descriptor path default .factory/verification-stack.yaml in src/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.

  2. kjgbot commented on Aug 16, 2026

    @kjgbot
    Contributor

    Fix PR: #278 — fix/276-crossrepo-mergeadvance.

    Mechanism confirmed against origin/main at f13600f. File has drifted since the analysis was written; the current line numbers are: #advanceMergedPrToDone(snapshot, repo, record?) at :11893 (already carries repo), record-less fallback at :11905 calling #findMergeAdvanceIssueForPr(snapshot) and dropping repo, definition at :11963, scorer at :17167, closing comment at :11922. Behaviour matches this issue verbatim.

    Fix: Pass repo into #findMergeAdvanceIssueForPr and filter candidates using githubIssuePathParts (same shape recordMatchesGithubRepo uses). Also add the ambiguity guard the tracked path already carries (new counter mergedPrAdvanceAmbiguous) so a same-score tie fails toward NOT closing. Fail-closed if eventRepo is not a valid github repo.

    Completeness grep: #findMergeAdvanceIssueForPr has one call site (:11905, covered by this PR). #advanceMergedPrToDone has three call sites — #restoreBabysitterOwnership:10634, and the two #handlePrChange branches at :11778, :11833 — all three already pass repo, so the qualification now reaches through the full chain. Other consumers of prSnapshotIssueMatchScore (:4173, :9167, :9180, :10293, :10326) all key on session.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):

    479/479 factory.test.ts pass. tsc clean.

    Not closing this issue. The principal owns that gate.

  3. kjgbot commented on Aug 16, 2026

    @kjgbot
    Contributor

    CI status on PR #278 (fix/276-crossrepo-mergeadvance, run 31966854246 @ 4m11s):

    All GitHub Actions and actionable third-party checks green. gh pr view 278 --json mergeStateStatus returns UNSTABLE solely because of Reviewsaur — same posture as every recent PR on this repo.

  4. miyaontherelay commented on Aug 17, 2026

    @miyaontherelay
    Contributor

    Environment check (before audit):

    • pwd: /Users/khaliqgant
    • hostname: Finn-Mac-Mini
    • gh auth status: logged in to github.com as miyaontherelay; active; git protocol ssh; scopes admin:public_key, gist, read:org, repo
    • node --version: v25.8.1
    • git -C /Users/khaliqgant/Projects/AgentWorkforce/factory rev-parse --short origin/main: 7122524
  5. miyaontherelay commented on Aug 17, 2026

    @miyaontherelay
    Contributor

    Audit ref: origin/main 7122524352c6a02fd437922339534c9aaa9ea8af

    All rows measured at 2026-08-17T08:34:34Z. Verdicts use the deployed source ref, not issue state.

    issue verdict citation / finding measured-at
    #211 NOT DONE Confirmed. origin/main:src/orchestrator/batch-tracker.ts:344 still defines issueKey as key + uuid + mutable path. src/orchestrator/factory.ts:4526,4539-4542 uses that key for the durable claim. The compensating GitHub-only scan also remains at src/state/in-memory-state-store.ts:180-190 and its claim.key ?? key propagation at src/orchestrator/factory.ts:3029. 2026-08-17T08:34:34Z
    #221 NOT DONE Correcting the narrow suspicion: babysitter source: "gh" is read provenance, not a write; it only invokes gh pr view (src/github/standalone-babysitter.ts:86-100). The identity guarantee nevertheless fails: Factory defaults to GhCliGithubWriteback (src/orchestrator/factory.ts:716-720), which runs gh pr create (src/writeback/github.ts:123-136) and issue comments (:194-204); guarded merge is gh 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 through runGh (src/intake/notion.ts:399-410 -> :930-936). These writes have no app-authorship path or read-back assertion. 2026-08-17T08:34:34Z
    #139 NOT DONE FleetClient still has placement roster() 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 "a2a deriveAgentCard
    #146 NOT DONE The Factory default remains new KubectlEnvironmentProvider() (origin/main:src/environments/verification-pipeline.ts:177-180), not a Cloudflare provider. Complete probe for `CloudflareEnvironmentProvider factory-test-infra
    #216 NOT DONE PR #280 is OPEN against main at measurement, so this work is not on origin/main. Current intake is still a manifest consumer: origin/main:src/intake/notion.ts:194-197 loads JSON through manifestSchema, and CLI requires a manifest path at src/cli/fleet.ts:557-560; it is not the database manifest generator. 2026-08-17T08:34:34Z
    #145 GENUINELY DONE Pipeline executes provision -> deploy -> E2E -> load -> evaluation (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). The verification-gate-e2e check for this SHA completed success at 2026-08-16T21:55:36Z. 2026-08-17T08:34:34Z
    #143 NOT DONE Partial only: a typed descriptor loader is present (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. 2026-08-17T08:34:34Z
    #260 NOT DONE The dispatch path passes implementer.sessionRef separately (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: work_unit_surface=

    Closure-number reconciliation (the original closure comments, not the verdicts):

    affected issue(s) cited at closure factory resolution at that closure AgentWorkforce/cloud resolution
    #211 #274 No factory PR existed at the 2026-08-12 closure: current factory PR #274 was created only 2026-08-16T13:03:33Z and remains OPEN. Merged PR, 2026-04-22T12:59:42Z.
    #221 #1518 No factory object. The factory number space is below this number; API lookup is 404. Merged PR, 2026-05-30T14:19:08Z.
    #139 #2891 No factory object; API lookup is 404. Merged PR, 2026-08-03T06:52:30Z.
    #146 #2895 No factory object; API lookup is 404. Merged PR, 2026-08-03T12:15:01Z.
    #216 #219 A different type: factory #219 was a CLOSED ISSUE, closed 2026-08-08T08:54:32Z, not a PR. Merged PR, 2026-04-20T08:31:34Z.
    #145, #143 #1346 No factory object; API lookup is 404. Merged PR, 2026-05-28T13:38:39Z.
    #260 #1533 No factory object; API lookup is 404. Merged PR, 2026-05-30T18:25:20Z.

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions