memento / pull request check

Which open pull requests change the same files?

claude/login #7 codex/auth #5 src/auth.py

Paste one workflow file into your repository. On every pull request it names the other open pull requests that change the same files, and marks each file where a reviewer looks: in the diff. Nothing to install, no account with us; it only reads pull requests.

1. Save it as .github/workflows/memento-prcheck.yml

Commit it to your default branch. Every pull request opened or updated after that is checked.

# memento prcheck: names the other open pull
# requests that change the same files.
# Reads pull requests only; writes nothing.
# https://overflow.games/memento/prcheck/
# FAIL_ON_OVERLAP: "true" turns the mark red.
name: memento prcheck
on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
permissions:
  pull-requests: read
jobs:
  prcheck:
    runs-on: ubuntu-latest
    env:
      FAIL_ON_OVERLAP: "false"
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            const CAP = 50;
            const {owner, repo} = context.repo;
            const me = context.payload.pull_request;
            const files = async n => (await github.paginate(github.rest.pulls.listFiles,
              {owner, repo, pull_number: n, per_page: 100})).map(f => f.filename);
            const mine = new Set(await files(me.number));
            const others = (await github.paginate(github.rest.pulls.list,
              {owner, repo, state: 'open', per_page: 100})).filter(p => p.number !== me.number);
            const hits = [];
            for (const p of others.slice(0, CAP)) {
              const shared = (await files(p.number)).filter(f => mine.has(f));
              if (shared.length) hits.push({p, shared});
            }
            for (const {p, shared} of hits) for (const f of shared)
              core.warning(`#${p.number} (${p.head.ref}) also changes ${f}`, {file: f, title: 'memento prcheck'});
            const lines = hits.map(({p, shared}) => `- [#${p.number}](${p.html_url}) ${p.head.ref}: ` +
              shared.map(f => '`' + f + '`').join(', '));
            if (others.length > CAP) lines.push(`\n(read ${CAP} of ${others.length} other open pull requests)`);
            if (!lines.length) return;
            if (hits.length) lines.unshift(`### ${hits.length} other open pull request${hits.length > 1 ? 's change' : ' changes'} the same files\n`);
            lines.push('\nSeveral agents on one repository? memento Team tells a session who holds a file before it edits: ' +
              'https://overflow.games/memento/?ref=prcheck');
            await core.summary.addRaw(lines.join('\n') + '\n').write();
            if (hits.length && process.env.FAIL_ON_OVERLAP === 'true')
              core.setFailed(`${hits.length} other open pull request${hits.length > 1 ? 's change' : ' changes'} the same files: ` +
                hits.map(h => '#' + h.p.number).join(', '));

2. What a reviewer sees

A warning on the shared file in Files changed, and the list in the check's summary:

memento prcheck
#5 (codex/auth) also changes src/auth.py

1 other open pull request changes the same files
- #5 codex/auth: src/auth.py

No other pull request on the same files: the check passes and writes nothing. Set FAIL_ON_OVERLAP: "true" to make a collision red instead of a warning.

Why at the pull request

Two agents on separate branches never see each other's edits. Each pull request looks clean on its own; the collision shows up when the second one merges, as a conflict or, worse, as a quiet overwrite of the first agent's change. The check moves that moment to when the second pull request opens, while both authors can still split the work.

It reads at most 50 other open pull requests per run, through the token GitHub gives the workflow. For the history: grade your git log for files two sessions wrote within the hour, or set up one worktree per agent.

The check finds a collision after both agents did the work. memento Team stops it before: a session claims a path before it edits, and the next one is told who holds it. 10 USD per agent a month. Pre-order memento Team