Skip to content

feat(merge,assess): open PRs on origin whose files overlap the work are merge-order members — add them to the existing overlap checks #1454

Closed

Description

@admarble

Epic: graph-2026-10-freeze-b Tier: judgment Execution: sequant_run

Problem

Sequant's overlap checks only see work it knows about. src/lib/merge-check/overlap-detection.ts compares the feature branches passed to sequant merge. src/lib/assess-collision-detect.ts compares file paths named in issue bodies. Neither looks at open PRs on origin that came from another session, another machine, Dependabot or a human. A peer PR that touches the same files merges in the middle of the run, and the issue's PR goes CONFLICTING. Sometimes the conflict is a semantic one that a textual rebase replays wrongly.

Field evidence:

Proposal

Add open PRs on origin as a source in the existing overlap machinery. Don't build a new checker. Changed files come from the platform layer (GitHubProvider owns gh). The intersection logic is reused.

  • sequant merge --check reports open PRs that are not in the batch but whose changed files intersect the batch's changed files, as a separate finding class ("external PR overlap"). It is a warning and does not block.
  • assess-collision-detect.ts gains a function that turns open-PR file lists into the existing ⚠ #N Modifies <path> (overlaps #M); land sequentially line format, with PRs written as PR #M.

Freeze scoping (graph doc D-8, 2026-10-16): /assess builds its collision inputs in skill prose (assess/SKILL.md Step 5 calls the pure functions in assess-collision-detect.ts). Feeding open-PR data in needs a skill edit, which the freeze blocks. So this issue ships the assess-collision-detect.ts function and its tests, and /assess starts calling it in the same post-freeze change that wires /exec and /merger. sequant merge --check is CLI code and is fully in scope.

Acceptance Criteria

  • AC-1: sequant merge --check reports each open PR on origin whose changed files intersect the batch's changed files, excluding PRs whose head branch is in the batch, as one "external PR overlap" finding naming the PR number, head branch and shared paths, at warning severity; the exit code is unchanged by these findings alone. Evidence: a merge-check unit test with a stubbed provider asserting the finding text and the unchanged exit code, mutation-verified by removing the in-batch exclusion.
  • AC-2: Open-PR file lists come from one new GitHubProvider method, and no new gh spawn exists outside src/lib/workflow/platforms/. Evidence: a provider-stubbed test covering no open PRs, a PR with disjoint files (no finding), a PR with one shared path (one finding) and an in-batch PR (excluded), mutation-verified by making the method return every PR's files as shared, plus git diff origin/main -- src ':!src/lib/workflow/platforms' | grep -E '^\+.*"pr", *"(list|view)"' printing nothing.
  • AC-3: assess-collision-detect.ts exports a function that, given an issue → paths map and open-PR file lists, returns one ⚠ #N Modifies <path> (overlaps PR #M); land sequentially line per overlapping PR and none for a disjoint PR. Evidence: a test in src/lib/__tests__/assess-collision-detect.test.ts asserting the exact line for one overlapping PR and no line for a disjoint one, mutation-verified by dropping the intersection.
  • AC-4: When gh is unavailable or the PR list call fails, sequant merge --check prints exactly one line saying the open-PR overlap check was skipped and why, and otherwise behaves as today. Evidence: a test with a failing provider asserting the single skip line and an unchanged exit code.

Prior fixes / producers

May touch

src/lib/merge-check/ (overlap-detection.ts, types.ts, report.ts, index.ts), src/lib/assess-collision-detect.ts, src/lib/workflow/platforms/github.ts, src/lib/workflow/platforms/platform-provider.ts, their tests, docs/reference/merge-command.md, CHANGELOG.md.

Non-Goals

  • Any edit to .claude/skills/, templates/skills/ or plugin/ (plugin freeze). The /assess, /exec and /merger prose that calls these checks is a follow-up after the freeze lifts (D-8).
  • No line-level conflict classification for external PRs. A file-level intersection is enough to warn.
  • No blocking. The owner decides merge order.
  • GitLab and Azure DevOps providers (Platform abstraction: GitLab and Azure DevOps support #375). The new method is GitHub-only; other providers return "not supported", which counts as a skip (AC-4).

Origin

Lesson from the ai-devtools-weekly cloudgate graph, recorded in ~/.claude/skills/graph-run/SKILL.md Step 1 on 2026-10-14. Related memory: spec conflict prediction is unreliable (#760). Companion #1455 edits skills and stays out of this graph.

Activity

  1. added
    enhancement
    graph-2026-10-freeze-b
    on Oct 16, 2026
  2. added 2 commits that reference this issue on Oct 16, 2026
  3. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Runner context (graph-2026-10-freeze-b, wave 2)

    Wave 1 merged on 2026-10-16. main is at 9f1fb3f and includes #1440, #1396, #1305, #1325, #1405 and #1409. These notes are for both the exec phase and the qa phase:

  4. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (4 ACs, 3 directories)

    AC Quality Check

    The linter flags nothing (4/4 pass). It misses three things that matter:

    • AC-1 and AC-4 parse as manual. Their Evidence: clauses name tests ("a merge-check unit test…", "a test with a failing provider…"), but the parser files them as manual, so /qa §6h/§6i checks them less strictly. Exec should still ship them as unit tests with mutation markers.
    • AC-2's grep guard is vacuous and also too weak. It prints nothing on today's main, and prettier puts "pr", and "list" on separate lines, so a new spawn outside platforms/ would get past it too. The stubbed-provider test does the real gating. QA should back the grep with git diff origin/main -- src ':!src/lib/workflow/platforms' | grep -E '^\+.*(spawnSync|execSync|execFile)\(\s*"gh"'.
    • AC-2's mutation names the wrong spot. "Make the method return every PR's files as shared": the provider method returns file lists, and the intersection happens in the shared helper (Phase 1). Mutate the helper (for example, treat every PR file as shared), not the provider.

    Scope Assessment

    Non-Goals: present (no skill, template or plugin edits; no line-level classification; no blocking; GitHub only).

    Metric Value Status
    Feature count 1 (one new overlap source, two consumers) ✅
    AC items 4 ✅
    Directory spread 3 (merge-check/, workflow/platforms/, src/lib) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: External PR overlap finding, warning only, exit code unchanged

    Verification: Unit Test
    Scenario: Given batch branches A and B and a stub that returns PR #900 (head other, shares src/x.ts) and PR #901 (head = A's branch) → When the external check runs and the report is built → Then there is exactly one warning naming PR #900, other and src/x.ts, nothing for #901, and getExitCode(batchVerdict) matches the run without the check.
    Assumptions: "Unchanged" works if the new CheckResult has passed: true and no branchResults. computeBatchVerdict only escalates on !passed or a branch WARN/FAIL (report.ts:57).

    AC-2: One provider method, no stray gh spawn

    Verification: Unit Test (+ grep guard)
    Scenario: The stub returns [], a disjoint PR, a PR with one shared path, and an in-batch PR → the results are no finding, no finding, one finding, excluded.
    Assumptions: gh pr list --state open --json number,headRefName,files --limit 100 works (checked on this repo). gh caps files at 100 per PR, so a larger PR could be under-reported. Note that in the doc; it is not a fix target.

    AC-3: assess-collision-detect.ts formats open-PR overlaps

    Verification: Unit Test
    Scenario: Given {1454 → {src/a.ts}} and PRs #77: [src/a.ts] and #78: [src/b.ts] → Then the output is exactly ⚠ #1454 Modifies src/a.ts (overlaps PR #77); land sequentially, with nothing for #78.

    AC-4: Skip line when gh is unavailable or fails

    Verification: Unit Test
    Scenario: The stub throws (gh missing, auth error or non-zero exit) → Then the check yields exactly one info finding, Open-PR overlap check skipped: <reason>, and the exit code is unchanged.
    Assumptions: The "line" is a report finding, not a separate console.* call. That way --json stays valid JSON and markdown output still shows one bullet.


    Implementation Plan

    Phase 1: Source and intersection

    1. In src/lib/workflow/platforms/github.ts, add listOpenPRFilesSync(limit = 100): OpenPRFiles[] ({ number, headRefName, files: string[] }). It goes through runGhOrThrow so failures throw. The existing getStatusCheckRollupSync swallows errors to [], which would make AC-4 impossible. Export the type from platforms/index.ts. Leave the PlatformProvider interface alone: only GitHub exists, and the "not supported" case from the Non-Goals is the same throw → skip path.
    2. Add the pure helper src/lib/open-pr-overlap.ts: findOpenPrOverlaps(workPaths: Map<number, Iterable<string>>, prs, excludeHeads: Set<string>) → { key, prNumber, headRefName, sharedPaths[] }[]. Both consumers use it, so the intersection exists once.

    Phase 2: Merge consumer

    1. In merge-check/overlap-detection.ts, add runExternalPrOverlap(branches, source: { listOpenPRFilesSync(): OpenPRFiles[] }) → CheckResult with name "external-pr-overlap", always passed: true, and empty branchResults. It aggregates per PR across the batch, so each PR gets one finding: PR #M (<head>) shares <paths> with this batch. With no overlap it adds one info line (same convention as overlap-detection). If the call throws, it adds the single skip info line. Exclusion is by headRefName ∈ branches.map(b => b.branch).
    2. In merge-check/index.ts, add "external-pr-overlap" to the phase-1 list in getChecksToRun and pass the existing ghProvider. Update the expectations in merge-check-extended.test.ts.

    Phase 3: Assess consumer, tests, docs

    1. In assess-collision-detect.ts, add formatOpenPrCollisionWarnings(issuePaths, prs), which calls the helper and returns lines in the AC-3 format. /assess wiring waits until after the freeze (D-8).
    2. Tests: extend merge-check-extended.test.ts (AC-1/2/4) and src/lib/__tests__/assess-collision-detect.test.ts (AC-3). Add a parse test for listOpenPRFilesSync in platforms/github.test.ts. Run only these files with npx vitest run <file>, never npm test (runner note).
    3. Update docs/reference/merge-command.md (new finding class, warning only, skip line, 100-file cap), add a CHANGELOG.md Unreleased entry, and add ADR-0016 (see Design Review Q2).

    Design Review

    1. Where does this belong? The platform layer fetches. A neutral src/lib/open-pr-overlap.ts intersects. merge-check and assess-collision-detect each format.
    2. Simplest correct approach? A separate external-pr-overlap CheckResult with passed: true. Rejected: (a) folding external PRs into runOverlapDetection, which would make them branch WARNs, move the batch verdict to NEEDS_ATTENTION and break AC-1's exit-code clause; (b) a second gh fetcher per consumer, which AC-2 forbids; (c) putting the intersection inside assess-collision-detect.ts and importing it from merge-check, which couples the CLI to the assess module. The plan picks between designs, so the exec PR includes ADR-0016 (docs/adr/0016-…, shape per docs/adr/README.md).
    3. Pattern and re-patch count: This follows the existing file → owners map in runOverlapDetection and detectFileCollisions. overlap-detection.ts hasn't changed since feat(run): Add batch-level integration QA — sequant merge --check #313. assess-collision-detect.ts fixes (fix: parseDependencies matches prose mentions and silently reorders runs #767, fix(assess): path extraction counts cited paths as modification targets, producing phantom collisions #769) were for body-path extraction, which this doesn't touch. No recurring class.
    4. Senior challenge: "Why not use the PR's own diff against origin/main?" Because the PR head may not be fetched locally, and gh already returns the file list. "Why throw instead of []?" An empty list means "no peers", and a failure has to be distinguishable from that (AC-4).
    5. Producers/consumers: Overlap-finding producers are overlap-detection.ts (batch) and assess-collision-detect.ts (bodies). This adds one new source (listOpenPRFilesSync) and one shared intersection, and each consumer formats. There is one fetcher and one intersection, so no parity test is needed.

    Feature Quality Planning


    Open Questions

    1. Per-PR or per-file findings? I recommend one finding per PR (AC-1 says "one … finding naming the PR number, head branch and shared paths"). If that's wrong, the cost is only noisier output.
    2. Skip line severity? I recommend info. A warning would read as an overlap. Either way the exit code is unaffected.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: The scope is narrow and every AC's Evidence: already names the exact test and mutation, so testgen stubs would only duplicate them (overriding the default "feature with unit-test ACs → testgen"). Not UI work and not security-sensitive.

    Label Review

    Current: enhancement, graph-2026-10-freeze-b
    Recommended: + planned
    Quality Loop: won't auto-enable (SCOPE_OK).

  5. added
    planned
    on Oct 16, 2026
  6. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 3/4 met

    Gaps:

    • AC-4 requires exactly one skip line, but gh auth failures produce a two-line skip message because gh stderr is embedded verbatim
    • AC-4 test does not cover a multi-line provider error, which is the real gh auth-failure shape
    • External PR overlap warns on near-universal files, so nearly every open PR is flagged
    • Gate-test AC-1 lacks a recorded mutation marker
  7. added a commit that references this issue on Oct 16, 2026
  8. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    QA Verdict: NEEDS_VERIFICATION

    AC coverage: 4/4 met

    Gaps:

    Suggestions:

    Needs human review:

    • Required CI check test still running; re-run QA after it reports
  9. added a commit that references this issue on Oct 16, 2026
  10. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Runner verification (graph-run, wave 2): NEEDS_VERIFICATION discharged.

    QA's re-run held back only for the test check, which was still running. On head e39da4015 every check passed: test, canary, typecheck, validate-skills, validate-plugin, node-floor-guard, tautology-advisory and Gitleaks.

    What the runner ran in the worktree:

    Follow-up ledger: the skill wiring is filed as #1459 (post-freeze, D-8). No other open items.

  11. added a commit that references this issue on Oct 16, 2026
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

    enhancementgraph-2026-10-freeze-bplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions