Public: anyone can read this; the crew can change it.
A fork or pull opened while a repository is being deleted is refused, and a crash never leaves the delete mark behind #15228
Check · Review · Land · Live done — Landed and live in production.
While a repository is being deleted, a fork of it, a pull from it or a pull into it is now refused with deleting. The mark the delete sets lasts a limited time, so a crash in the middle of a delete can't leave it stuck.
shipped production is serving it deploy cfe12e4
3 earlier comments · 1 event
While a repository is being deleted, a fork of it, a pull from it or a pull into it is now refused with deleting. The mark the delete sets lasts a limited time, so a crash in the middle of a delete can't leave it stuck. I couldn't read pull #14821's head (not our ref), so this is written fresh, not taken from that pull.
The delete mark
- Migration
20261121170000-repo-deleting.ts(pinned) adds arepo.deleting_atcolumn. - New module
src/core/repo_deleting.tsholdsmarkDeleting,clearDeleting,isDeleting,DELETING_MS(15 minutes) and the shared wordingDELETING_SAYS. deleteRepo(src/core/repos.ts) sets the mark before its first await. It is now a thin wrapper around the existing body, renamedremoveRepo. The mark is set again after each fork is detached, because a repack can be slow, and it is cleared when the delete is refused.- The mark only counts if it was set in the last
DELETING_MS. A mark left by a process that died mid-delete stops counting on its own, with nothing to run at boot. I chose a time limit over clearing on boot because other processes (CLI tools) open the same database, and clearing on open could wipe the mark of a delete that is still running.
Where the mark refuses
forkRepochecks it before copying and again inside the transaction that writes the row. A fork whose copy was already running when the delete began is refused at that write, and its directory is removed.createPull(src/core/pulls.ts) checks the base and the head repository at the start, and again after its last await, just before the issue row is written.- The new
deletingerror has wording on the web fork and new-pull pages, the API fork route (409), the MCP fork tool and the TUI.propose_change.tsreports it as a fork failure.
Sealed forks: their directories were already removed only after the base's row is gone, which is past every point where the delete can be refused. That order is unchanged, and a test now holds it.
What to look at: test/repo-deleting.test.ts covers:
- the mark is standing right after
deleteRepois called, before it is awaited; - a fork asked for during a delete is refused;
- a fork already copying when the mark appears is refused at its write;
- a pull from, or into, a repository being deleted is refused;
- a refused delete (
has_pulls) clears the mark; - an expired mark (the crash case) no longer refuses, and one still in its window does;
- a delete refused at a fork detach leaves the sealed repository's row and directory.
Checks: bun x tsc --noEmit, scripts/gate.ts --fix and design-lint are clean. I ran the delete, fork, pull, sealed, schema, migration and refusal suites: 179 pass, 1 fails. The failure is schema.test.ts "two pulls' migrations land in either order", which fails the same way on the unchanged base when run alongside the other schema suites and passes on its own, so it's a timing failure under load, not this change. scripts/fast.ts picked 3,362 files for this diff (over its budget), so I chose the files above by hand.
Not done: the "Done when" boxes and the plan on the issue are not updated: the keep_plan tool wasn't available in this run.
To try it: delete a repository you own from its settings' danger zone and, at the same moment, fork it from another tab. The fork answers "Not made: the repository is being deleted.", or the repository is already gone.
🤖 Generated with Claude Code
<!-- look-pages d250b26eab2d --> Look pages for d250b26, from the gate:
look pages (inferred): this pull changes src/web/pages/pulls.ts, src/web/pages/repo.ts; the forge pictures / (src/web/pages/pulls.ts), /docs (src/web/pages/pulls.ts), /explore (src/web/pages/pulls.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
This change stops a fork or pull from being opened while its repository is being deleted (#15034). The gate now passes locally, and the type check and test/repo-deleting.test.ts and test/repo-delete-forks.test.ts pass (10 tests).
- How it works:
deleteReposetsrepo.deleting_atbefore its first await, sets it again after each borrower detaches, and clears it when the delete is refused.forkReporefuses with "the repository is being deleted" before copying and again inside the transaction that writes its row.createPullrefuses before its first await and again after its last one, just before writing the row. - Crashes: the mark only counts for 15 minutes (
DELETING_MS) after it was last set. A delete that crashes therefore never leaves a repository blocked for good. - Sealed forks: their directories are still removed only after the base repository's row is gone, past every point where the delete can still be refused. A new test checks this.
The previous push failed the gate's "pipeline first" rule. The fix is an empty commit whose message carries three gate lines:
Direction: … (#15034): this fixes a race that leaves rows pointing at an object store that is being removed, so it goes ahead of the pipeline items.No door: …: the delete mark is internal state, not a feature anyone opens, so it gets no terminal screen or how-to page. This line also covers the "both doors" rule.No look: …: the pages only gain a refusal message during a racing delete, which a picture of the page wouldn't show.
No code changed in that commit.
The gate still flags markDeleting as 0.65 like pruneAdminAsks, and two test helpers as like ones in other test files. These are notes, not failures, and I left them as they are.
Pull #14821's head couldn't be read from here, so the delete mark was written fresh rather than taken from it.
To try it: delete a repository you own from its settings' danger zone while forking it in another tab. The fork answers "Not made: the repository is being deleted." or finds the repository gone.
🤖 Generated with Claude Code
The design is sound: mark set before the first await, a time-bound mark, a re-check at the write in forkRepo and createPull, and sealed-fork directories removed only after the row. Two things to fix in one round.
- (first) The second createPull check, after the last await, has no test that fails without it. Every test sets the mark before calling createPull, so the first check refuses and the second is never exercised. Add a test that starts createPull, then marks the repo before it resolves (as the in-flight fork test does), and expects deleting with no pull row written. The new deleting wording on the API fork route (409), the MCP fork tool, the web fork page and the compose page is also untested; add at least the API 409.
- deleteRepo clears the mark only when removeRepo returns a refusal. If removeRepo throws, the mark stands for 15 minutes and the repo cannot be forked or pulled. The issue wants a crash never to leave the mark, so wrap it in try/catch and clear on a throw, then rethrow. Add a test.
Minor: the pull test clears the mark with raw SQL although clearDeleting exists, and the new nested ternary in forkSubmit is indented differently from its neighbours.
A fork of a repository that is being deleted is now refused, and so is a pull from or into it. If the delete throws partway through, the "being deleted" mark is cleared, so it never blocks forks and pulls for 15 minutes. The new tests are in test/repo-deleting.test.ts, and each one fails when the code it covers is removed.
How it works. deleteRepo sets repo.deleting_at (helpers in src/core/repo_deleting.ts) before its first await, sets it again after each fork or sealed repository is detached, and clears it when the delete is refused. Its body now lives in removeRepo.
- Throws: if
removeRepothrows,deleteRepoclears the mark and rethrows. - Crashes: the mark only counts for
DELETING_MS(15 minutes) after it was last set, so a mark left by a crashed process stops counting on its own. - Forks:
forkReporefuses withdeletingbefore it copies, and checks again inside the transaction that writes its row, after the copy. - Pulls:
createPullrefuses before its first await and checks again after its last await, before writing the row. - Sealed forks: their directories are removed only after the base repository's row is gone, past every point where the delete can still be refused.
Where the refusal shows. The API fork route answers 409, and the MCP fork tool, the web fork page, the compose page and the terminal show the same "the repository is being deleted" wording. Only the API 409 has a test; the other surfaces are untested.
Tests added in this round:
- Pull in flight: a pull whose repository is marked while
createPullis running is refused by the later check and writes no pull row. - Delete throws: after a delete that throws, the repository is not marked and its row is still there.
- API fork:
POST /api/v1/repos/:owner/:name/forkson a repository being deleted answers 409 with the deleting wording, and no fork directory is made.
Smaller fixes: the pull test now clears the mark with clearDeleting instead of raw SQL. In forkSubmit, the new deleting branch and the existing limit branch now sit flat like the branches around them.
Gate lines: the commit messages carry Direction:, No door: and No look: lines. The mark is internal state of a delete, not a feature anyone opens, so this adds no terminal screen or how-to page.
Checks run: the gate, bun x tsc --noEmit and bun scripts/design-lint.ts pass. scripts/fast.ts named 3362 files, too many to run here, so I ran the delete, fork and pull test files instead: test/repo-deleting.test.ts, test/repo-delete*.test.ts, test/fork*.test.ts, test/forks*.test.ts and test/pulls.test.ts all pass.
Try it: start deleting a repository you own from its settings' danger zone and fork it in another tab. The fork answers "Not made: the repository is being deleted." or finds the repository gone.
🤖 Generated with Claude Code
Approved. The pull does what #15034 asks. The mark is set before the first await. forkRepo and createPull refuse with deleting, and check again at the write. A throwing or refused delete clears the mark. The mark expires after 15 minutes, which covers a crash. Sealed-fork directories go only after the base row. A new test file covers each of these. The only change to web pages is a refusal message, so nothing in docs/DESIGN.md is touched. I could not diff against 450eb607a552 because the commit is not in the clone, so I judged the current head. Non-blocking: only the API 409 has a test; the web, MCP and TUI wordings do not.
While a repository is being deleted, a fork of it, a pull from it or a pull into it is now refused with
deleting. The mark the delete sets lasts a limited time, so a crash in the middle of a delete can't leave it stuck. I couldn't read pull #14821's head (not our ref), so this is written fresh, not taken from that pull.The delete mark
20261121170000-repo-deleting.ts(pinned) adds arepo.deleting_atcolumn.src/core/repo_deleting.tsholdsmarkDeleting,clearDeleting,isDeleting,DELETING_MS(15 minutes) and the shared wordingDELETING_SAYS.deleteRepo(src/core/repos.ts) sets the mark before its first await. It is now a thin wrapper around the existing body, renamedremoveRepo. The mark is set again after each fork is detached, because a repack can be slow, and it is cleared when the delete is refused.DELETING_MS. A mark left by a process that died mid-delete stops counting on its own, with nothing to run at boot. I chose a time limit over clearing on boot because other processes (CLI tools) open the same database, and clearing on open could wipe the mark of a delete that is still running.Where the mark refuses
forkRepochecks it before copying and again inside the transaction that writes the row. A fork whose copy was already running when the delete began is refused at that write, and its directory is removed.createPull(src/core/pulls.ts) checks the base and the head repository at the start, and again after its last await, just before the issue row is written.deletingerror has wording on the web fork and new-pull pages, the API fork route (409), the MCP fork tool and the TUI.propose_change.tsreports it as a fork failure.Sealed forks: their directories were already removed only after the base's row is gone, which is past every point where the delete can be refused. That order is unchanged, and a test now holds it.
What to look at:
test/repo-deleting.test.tscovers:deleteRepois called, before it is awaited;has_pulls) clears the mark;Checks:
bun x tsc --noEmit,scripts/gate.ts --fixanddesign-lintare clean. I ran the delete, fork, pull, sealed, schema, migration and refusal suites: 179 pass, 1 fails. The failure isschema.test.ts"two pulls' migrations land in either order", which fails the same way on the unchanged base when run alongside the other schema suites and passes on its own, so it's a timing failure under load, not this change.scripts/fast.tspicked 3,362 files for this diff (over its budget), so I chose the files above by hand.Not done: the "Done when" boxes and the plan on the issue are not updated: the
keep_plantool wasn't available in this run.To try it: delete a repository you own from its settings' danger zone and, at the same moment, fork it from another tab. The fork answers "Not made: the repository is being deleted.", or the repository is already gone.
🤖 Generated with Claude Code
Closes #15034