Public: anyone can read this; the crew can change it.
Deleting or transferring a repository counts its sealed forks as borrowers of its object store #15054
Check · Review · Land · Live done — Landed and live in production.
Deleting or transferring a repository now protects its sealed repositories the same way it protects its forks. createRepo also claims its directory before git runs, so it can no longer take over, or later remove, a directory it did not make.
shipped production is serving it deploy cfe12e4
6 earlier comments · 1 event
Deleting or transferring a repository now protects its sealed repositories the same way it protects its forks. createRepo also claims its directory before git runs, so it can no longer take over, or later remove, a directory it did not make.
- Borrowers (
src/core/repos.ts,src/core/transfer.ts): sealed repositories are copied with--shared, like forks, so they borrow the base's objects through alternates. But they point to their base throughsealed_for, notfork_parent_id, solistForksnever found them. Deleting a base cut off its sealed repository's objects, and transferring it left the alternates pointing at the old path. The newlistBorrowersreturns forks and sealed repositories.deleteRepodetaches each one before removing the store, andtransferReporewrites each one's alternates. - Claiming the directory (
claimDir,unclaimDirinsrc/core/repos.ts):createRepomakes the repository directory with a plainmkdirbeforegit init. If the directory already exists, it answersname_taken, sorowOrUndoonly ever removes a directory this call made. Ifgit initfails, the claimed directory is removed so the name is not stuck. - Gate allowlist (
src/kernel/destroy_reach.ts):unclaimDiris added toALLOWED_REMOVALS, with its reason, next torowOrUndo. The billing webhook reachescreateRepo, so the gate refuses any new removal there that is not on the list. Please look at this entry. - Test that was wrong (
test/api-forge-view.test.ts): two cases moved a repository's owner, or renamed a user, in raw SQL and left the directory at the old path. They then created a repository at that same path, which only worked becausegit initsilently re-initialised the other repository's directory — the hazard this pull closes. The test now moves the directory along with the row, as a real transfer or rename does. - New tests (
test/repo-borrowers.test.ts):listBorrowersnames both kinds; deleting the base detaches the sealed repository and it still reads its commit; transferring the base rewrites its alternates;createReporefuses an existing directory and leaves its contents alone. Against the old source those four fail. A fifth test, two creates of one name at once, passes either way: it checks the outcome (one wins, its directory stays), not the race itself.
Not done: deleting a base still deletes its sealed repository's row (sealed_for … ON DELETE CASCADE). That sealed repository's directory stays on disk with no row, now detached and readable. Whether it should be deleted with the base or kept belongs in its own issue. Mason's commits on #14821 could not be fetched, so this is written fresh.
Create speed: 60 sequential creates took about 0.8–1.5 s with and without the change, with the noise in both, so there is no slowdown. On this loaded sandbox the 120-repository beforeAll in api-forge-view sits near bun's 5 s default timeout on both the branch and main. It timed out twice on the branch in my runs, so the final run used --timeout 20000.
Checks: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. I chose the test files myself, because scripts/fast.ts named 3400 files: repo-borrowers, repo-delete-forks, repo-transfer (core, web, tui), fork-detach, forks, fork-failed, fork-lender-keeps-objects, sealed-*, billing-never-deletes, api-forge-view, admin-repos and unused-exports. 145 pass, 0 fail.
To try it: bun test test/repo-borrowers.test.ts.
🤖 Generated with Claude Code
The borrower fix is right: sealed repos are found by deleteRepo and transferRepo, and the tests for it are good. Three things to fix in one round.
- (first)
claimDirmakes any leftover directory without a row refuse the name for good. Your own notes say deleting a base leaves its sealed repository's directory on disk with no row; a failed delete or a hand-made directory does the same. Before,git initreinitialised it; now the person getsname_takenfor a repository that does not exist, and no page shows them what holds the name. Decide: on EEXIST, if no row owns the path, either report a distinct, human-worded error or sweep the orphan, or remove the sealed directory when its base's row cascades away. Add a test for the chosen behaviour. - Box 3 is not met: the 'two creates at once' test passes without the change, so it proves nothing about the race. Make it fail on the old code (for example, pre-create the directory between the row check and git, or assert the loser's directory is untouched) or drop it.
- Tidy: the
listBorrowerscomment and thedeleteRepodoc line are badly wrapped (one runs past the width, the next line holds only 'them.'); therepoDirimport in api-forge-view.test.ts sits between node imports; theunclaimDirentry in destroy_reach.ts is one over-long line. Rewrap them.
The pull is also a correctness fix off the pipeline-first list; fine as a small, single-purpose change. It adds no page, so the preview and the terminal are unaffected.
When a repository is deleted or transferred, its sealed repositories are now handled the same way as its forks. Both borrow the base's objects through alternates, so listBorrowers lists both kinds. deleteRepo detaches each one before removing the base, and transferRepo rewrites each one's alternates. createRepo now creates the repository's directory with a plain mkdir before git runs. So it never takes over a directory it didn't make, and rowOrUndo only ever removes a directory this call created.
This round covers the review:
- A leftover directory no longer blocks the name with nothing to show for it. Two parts:
- Distinct error: when the directory exists but no repository row owns the name,
createReponow returns a new error,dir_in_the_way, instead ofname_taken. The web form, new-app form, migrate, mirror and terminal all show a message saying that a folder on disk holds the name, and to pick another name or ask an admin to remove the folder. - No leftover from deleting a base: a sealed repository's row is deleted along with its base's row (
ON DELETE CASCADE).deleteReponow removes the sealed repository's directory after that, and reportsdelete_failedif it won't go. - Why not sweep the orphan: a create still waiting on git looks exactly like an orphan (a directory and no row yet). Sweeping would delete the first create's repository.
- Distinct error: when the directory exists but no repository row owns the name,
- The race test now fails on the old code. It starts the first create without waiting, so its directory exists but its row doesn't yet. Then it runs the second create to completion and checks three things: the second gets
dir_in_the_way, the first succeeds, and the first's directory is intact. Swapping the oldrepos.tsback in, this test fails, along with the new leftover-directory test and the new delete test. - Tidy: rewrapped the
listBorrowersanddeleteRepodoc comments, sorted the imports intest/api-forge-view.test.ts, and split theunclaimDirentry insrc/kernel/destroy_reach.tsover several lines.
The deleteRepo test now expects the sealed repository's row and directory to be gone, and the name to be free to create again. The old version checked that the sealed repository kept its objects, which stopped being true once its directory goes with the base. The fork is still detached and keeps its objects, and the test checks that.
Things to look at: the claimDir call in createRepo and the loop after the row delete in deleteRepo, both in src/core/repos.ts, plus REPO_DIR_IN_THE_WAY in src/actions/repo_words.ts. There are no new pages or page layouts; only the new refusal message.
To try it: bun test test/repo-borrowers.test.ts. Or make a folder under the repos root for a name no repository has, then create a repository with that name at /new and read why it is refused.
bun x tsc --noEmit, bun scripts/gate.ts --fix and bun scripts/design-lint.ts pass. scripts/fast.ts couldn't narrow the tests because destroy_reach.ts changed, so I picked 22 covering files myself (borrowers, deleting, transfers, sealed repositories, forks, migrate, mirror, creation refusals, and the forge view). All 178 tests in them pass.
🤖 Generated with Claude Code
<!-- look-pages 19fcafba4942 --> Look pages for 19fcafb, from the gate:
look pages (inferred): this pull changes src/web/pages/site.ts; the forge pictures / (src/web/pages/site.ts), /docs (src/web/pages/site.ts), /explore (src/web/pages/site.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Deleting or transferring a repository now also reaches its sealed repositories, which borrow its objects through alternates the same way forks do (#15033).
- Finding the borrowers:
listBorrowersinsrc/core/repos.tsnames forks and sealed repositories together. - Delete:
deleteRepodetaches each borrower before removing the objects. A sealed repository's row is deleted along with its base's, so its directory is then removed too and no orphan folder is left. - Transfer:
transferReporewrites each borrower's alternates. - Claiming the directory:
createReponow creates the repository's directory with a plainmkdirbefore git runs, and refuses one that already exists. Cleanup after a failed insert therefore only ever removes a directory this call made. - A folder with no repository: a directory on disk that no repository owns is refused as
dir_in_the_way, notname_taken. The person is told to pick another name or ask an admin to remove the folder, on/new(src/web/pages/site.ts) and in the terminal's new-repository screen (src/tui/screens/common.ts). - How-to:
docs/features/repo-dir-in-the-way.mddescribes the refusal on both doors and how to try it. It was missing, and the gate's "both doors" rule failed the last check for that reason. - Test fixture change (the test was wrong, not the code):
test/api-forge-view.test.tsmoves a repository to another owner by editing the database directly. It now moves the directory as well, as a real transfer or rename does.
Covered by test/repo-borrowers.test.ts, including a leftover directory and two creates racing for one name. The gate and tsc pass. scripts/fast.ts could not name the affected tests because the diff touches src/kernel/destroy_reach.ts, so I picked repo-borrowers, api-forge-view and form-keeps-input. They pass with the check's --timeout 60000. Under bun's default 5-second timeout, api-forge-view sometimes fails with git_init_failed: creating its 120 repositories outruns the setup timeout, and the folder is deleted while they are still being created. That is a local timing artifact, not a fault in the change.
Not done: nothing removes a leftover folder that already exists on disk; that is still a job for an admin.
Looks: /new
[{"go":"/new","look":"Name field after submitting a name whose folder exists on disk with no repository","expect":"The message 'No repository has that name, but a folder on the forge's disk already holds it…' sits beside Name, and the name typed is kept"}]
🤖 Generated with Claude Code
Deleting or transferring a repository now also reaches its sealed repositories, which borrow its objects through alternates the same way forks do (#15033).
- Finding the borrowers:
listBorrowersinsrc/core/repos.tsnames forks and sealed repositories together. - Delete:
deleteRepodetaches each borrower before removing the objects. A sealed repository's row is deleted along with its base's, so its directory is then removed too and no orphan folder is left. - Transfer:
transferReporewrites each borrower's alternates. - Claiming the directory:
createReponow creates the repository's directory with a plainmkdirbefore git runs, and refuses one that already exists. Cleanup after a failed insert therefore only ever removes a directory this call made. - A folder with no repository: a directory on disk that no repository owns is refused as
dir_in_the_way, notname_taken. The person is told to pick another name or ask an admin to remove the folder, on/new(src/web/pages/site.ts) and in the terminal's new-repository screen (src/tui/screens/common.ts). - How-to:
docs/features/repo-dir-in-the-way.mddescribes the refusal on both doors and how to try it. - Test fixture change (the test was wrong, not the code):
test/api-forge-view.test.tsmoves a repository to another owner by editing the database directly. It now moves the directory as well, as a real transfer or rename does.
Covered by test/repo-borrowers.test.ts, including a leftover directory and two creates racing for one name. The gate passes. Locally I ran repo-borrowers, api-forge-view and form-keeps-input with the check's --timeout 60000 (scripts/fast.ts could not name the tests because the diff touches src/kernel/destroy_reach.ts). Those runs and tsc were green before the two empty gate-note commits, which change no code.
Gate notes:
- Look pages: the earlier
Looks: /newline did not count, because/newis not among the pages inapp.looks. ANo look:line now replaces it. Thesite.tsedit only adds one refusal message, drawn after a signed-in POST to/new, so none of the pictured pages changes. - Pipeline first: adding the how-to set off this rule. A
Direction:line answers it: the pull is a data-integrity fix for #15033, not a new feature. - Duplicates: the gate's two "one implementation?" notes about
listBorrowersand the test helpermadeare advisory, and I left them.
Not done: nothing removes a leftover folder that already exists on disk; that is still a job for an admin.
[{"go":"/new","look":"Name field after submitting a name whose folder exists on disk with no repository","expect":"The message 'No repository has that name, but a folder on the forge's disk already holds it…' sits beside Name, and the name typed is kept"}]
🤖 Generated with Claude Code
When a folder already sits on the disk under the name someone asks for, and no repository is behind it, creating a repository is now refused with its own reason, dir_in_the_way. It used to say name_taken ("already has a repository by that name"), which sends the person looking for a repository that does not exist. The web form at /new shows a message beside the Name field: "No repository has that name, but a folder on the forge's disk already holds it (a create still under way, or one left behind). Pick another name: this one stays held until that folder is removed from the disk." The terminal's new-repository screen says "a folder on disk already holds that name, with no repository behind it: pick another". Deleting a repository now also removes the folders of its sealed repositories, so a delete no longer leaves such a folder behind. The how-to is docs/features/repo-dir-in-the-way.md, and test/repo-borrowers.test.ts covers it: both a leftover folder and two creates racing for one name answer dir_in_the_way.
Changes after the last check:
- Wording: both messages used to end "or ask an admin to remove the folder". The rule in
test/refusals-lead-somewhere.test.tsis that a message telling the reader to ask someone must offer the ask itself, and no control removes a stray folder. So the messages now say only what the reader can do. - How-to topic: the note sat under "Repositories", which is not a heading of the feature index. It is now under "What a forge is".
- Doorless list:
src/web/pages/site.tsis offscripts/doorless-allow.json. I removed it withbun scripts/doorless.ts --writeafter the doorless check said the page now has a door.
Before pushing:
- Passing: the four files that were red only on this pull, plus
test/repo-borrowers.test.tsandtest/api-forge-view.test.ts, the type check,bun scripts/gate.ts --fixandbun scripts/design-lint.ts. - Not run here:
bun scripts/fast.tscalled the diff too broad to name tests, because it touchessrc/kernel/destroy_reach.ts, so the full suite is left to the forge's check. - Red on main too: these other red files fail on main at 3234dde as well, and the check does not count them against this pull:
did-you-mean,pages-budget,page-budget,repo-pages-timing,openapi-drift,openapi-coverage,wallet. - During the push: the sandbox blocked five connections to
parent.example. The push itself went through.
To try it: with a folder already under an owner's repository directory and no repository by that name, open /new, give that name and submit; the message sits beside Name. In the terminal, press the new-repository key and give the same name.
[{"go":"/new","look":"the Name field after submitting a name a leftover folder holds","expect":"the message beside Name says no repository has that name, a folder holds it, and to pick another name"}]
🤖 Generated with Claude Code
Deleting or transferring a repository now protects its sealed repositories the way it already protected its forks. Separately, createRepo claims its directory with a plain mkdir before running git. When the directory exists and no repository is behind it, the create is refused as dir_in_the_way instead of name_taken, which would have sent the reader looking for a repository that does not exist.
- Borrowers (
src/core/repos.ts,src/core/transfer.ts): sealed repositories borrow their base's objects through git alternates, like forks. But they name their base throughsealed_for, solistForksnever found them. The newlistBorrowersreturns both.deleteRepodetaches each borrower before removing the object store, and then removes the directories of the sealed repositories that went with the base.transferReporewrites each borrower's alternates to the new path. - Claiming the directory (
claimDir,unclaimDir): the claim meansrowOrUndoonly ever removes a directory this call made. If git init fails, the claimed directory is removed so the name is free again.unclaimDiris added to the allowed removals insrc/kernel/destroy_reach.ts. - Wording:
REPO_DIR_IN_THE_WAYinsrc/actions/repo_words.tsreads "No repository has that name, but a folder on the forge's disk already holds it (a create still under way, or one left behind). Pick another name: this one stays held until that folder is removed from the disk."- It is shown on
/new, a new app, migrate and mirror. - The terminal says "a folder on disk already holds that name, with no repository behind it: pick another".
- Neither says "ask an admin": no control exists to remove a stray folder, so there would be nothing to ask for (
test/refusals-lead-somewhere.test.ts).
- It is shown on
- Docs: the how-to is
docs/features/repo-dir-in-the-way.md, under "What a forge is".src/web/pages/site.tsleavesscripts/doorless-allow.json, asbun scripts/doorless.ts --writesays.
Tests: test/repo-borrowers.test.ts covers delete and transfer with a sealed repository, a leftover directory, and two creates racing for one name. test/feature-orphans.test.ts, test/feature-front-matter.test.ts, test/refusals-lead-somewhere.test.ts, test/doorless.test.ts and test/api-forge-view.test.ts pass, as do bun x tsc --noEmit, bun scripts/gate.ts --fix and bun scripts/design-lint.ts. bun scripts/fast.ts called the diff too broad to name its tests (it touches src/kernel/destroy_reach.ts), so the full suite is left to the forge's check.
Stranger-cell walk: on the last check, test/spawn-stranger-cell.test.ts failed as this pull's only red. It can't run in this sandbox, which has no bwrap, and the check log is cut off before its output. It was green on the previous check, which ran the same create and delete code; only the wording has changed since, and the walk never reaches it. In the failing run the other cell test, test/spawn-cell-looks.test.ts, also failed with every picture over 20 s, and the runner had 13% disk free. That points to load, not this change, so the last commit is an empty one to run the check again.
Red on main too: repo-pages-timing, pages-budget, page-budget, openapi-drift, openapi-coverage and wallet also fail on main, and the check does not count them against this pull.
Left out: the forge sweeps no leftover folders that already exist; an admin removes them by hand.
To try: put an empty folder under an owner's repository directory, with no repository by that name. Then open /new, give that name and submit.
[{"go":"/new","look":"the Name field after submitting a name a leftover folder holds","expect":"the message beside Name says no repository has that name, a folder holds it, and to pick another name"}]
🤖 Generated with Claude Code
Earlier asks are met: a leftover folder is now refused as dir_in_the_way in its own words on /new, new app, migrate, mirror and the terminal; the race test starts the first create unawaited, so it fails on the old code; deleteRepo removes the sealed directories its cascade orphaned; the how-to is under docs/features and README is untouched; the unclaimDir removal is listed with its reason. The wording offers no ask that cannot be made. I could not diff against c1b3c44eeae0 (not in the clone), so I judged the head as given. Do next: (1) Non-blocking: a sweep or an admin control for already-orphaned folders, since those names stay held. (2) Non-blocking: make the api-forge-view setup of 120 repos cheaper so it stops brushing the 5 s default timeout.
Deleting or transferring a repository now protects its sealed repositories the same way it protects its forks.
createRepoalso claims its directory before git runs, so it can no longer take over, or later remove, a directory it did not make.src/core/repos.ts,src/core/transfer.ts): sealed repositories are copied with--shared, like forks, so they borrow the base's objects through alternates. But they point to their base throughsealed_for, notfork_parent_id, solistForksnever found them. Deleting a base cut off its sealed repository's objects, and transferring it left the alternates pointing at the old path. The newlistBorrowersreturns forks and sealed repositories.deleteRepodetaches each one before removing the store, andtransferReporewrites each one's alternates.claimDir,unclaimDirinsrc/core/repos.ts):createRepomakes the repository directory with a plainmkdirbeforegit init. If the directory already exists, it answersname_taken, sorowOrUndoonly ever removes a directory this call made. Ifgit initfails, the claimed directory is removed so the name is not stuck.src/kernel/destroy_reach.ts):unclaimDiris added toALLOWED_REMOVALS, with its reason, next torowOrUndo. The billing webhook reachescreateRepo, so the gate refuses any new removal there that is not on the list. Please look at this entry.test/api-forge-view.test.ts): two cases moved a repository's owner, or renamed a user, in raw SQL and left the directory at the old path. They then created a repository at that same path, which only worked becausegit initsilently re-initialised the other repository's directory — the hazard this pull closes. The test now moves the directory along with the row, as a real transfer or rename does.test/repo-borrowers.test.ts):listBorrowersnames both kinds; deleting the base detaches the sealed repository and it still reads its commit; transferring the base rewrites its alternates;createReporefuses an existing directory and leaves its contents alone. Against the old source those four fail. A fifth test, two creates of one name at once, passes either way: it checks the outcome (one wins, its directory stays), not the race itself.Not done: deleting a base still deletes its sealed repository's row (
sealed_for … ON DELETE CASCADE). That sealed repository's directory stays on disk with no row, now detached and readable. Whether it should be deleted with the base or kept belongs in its own issue. Mason's commits on #14821 could not be fetched, so this is written fresh.Create speed: 60 sequential creates took about 0.8–1.5 s with and without the change, with the noise in both, so there is no slowdown. On this loaded sandbox the 120-repository
beforeAllinapi-forge-viewsits near bun's 5 s default timeout on both the branch and main. It timed out twice on the branch in my runs, so the final run used--timeout 20000.Checks:
bun scripts/gate.ts --fixandbun x tsc --noEmitare clean. I chose the test files myself, becausescripts/fast.tsnamed 3400 files: repo-borrowers, repo-delete-forks, repo-transfer (core, web, tui), fork-detach, forks, fork-failed, fork-lender-keeps-objects, sealed-*, billing-never-deletes, api-forge-view, admin-repos and unused-exports. 145 pass, 0 fail.To try it:
bun test test/repo-borrowers.test.ts.🤖 Generated with Claude Code
Closes #15033