Repository navigation
Transfers and fleet: re-check authority mid-call, guard reopen and sweep races, keep links Link all didn't make - #2333
Merged
Merged
Conversation
…gest failures and sweeps A commit or chunk admitted with operate and projects reads the device again right before it claims the transfer or appends, after every await. A stale commit's digest failure claims only its own upload generation, and a begin waits while the sweep is still removing that id's files. Co-Authored-By: spade <bot@acehq.dev>
… queued write The mid-body test now begins a real transfer, shows the same slow chunk is taken when nothing narrows, and checks the target hadn't answered before Projects went. A new test narrows while an admitted chunk's write waits. Co-Authored-By: spade <bot@acehq.dev>
…estart The simulated crash now also drops the hand-over's receipt, and the test checks the thread stored the result's input after the restart, so a delivery that does nothing fails it. Co-Authored-By: spade <bot@acehq.dev>
…l waits Co-Authored-By: spade <bot@acehq.dev>
A successful receipt without a title, from another kind of command, no longer reads as the scope change done. Only another device's receipt is answered as forbidden; anything else is refused as invalid. Co-Authored-By: spade <bot@acehq.dev>
Redeeming a pairing replaces this machine's device on the other one, so a stale gap list could swap a link with Projects for an operate-only one. The link op takes keep: the linking machine refuses it as exists, right before redeeming, while a link to that machine is saved or being made. Link all sends it, cancels the unused pairing, and its toast counts only the links it made. Co-Authored-By: spade <bot@acehq.dev>
…own link Guards that a dialog opened from another machine's thread, after this window read its own links, lists that machine's links and Allow projects widens that machine's device there, never this window's. Co-Authored-By: spade <bot@acehq.dev>
…p, guarded sweeps Also moves the guard test's file holds into its hoisted block for lint, and types the transfer fixture's history option. Co-Authored-By: spade <bot@acehq.dev>
…holds Ids may contain dots, so x.ignored's code file was x's ignored payload, and a write, cancel or sweep of one could touch the other's file. Files now use the id's stem, with each dot as ~ (never in an id), so names are one-to-one and read back to their own transfer. Co-Authored-By: spade <bot@acehq.dev>
close() waited only for the removals running when it was called, so a sweep could start the next one during teardown. A sweep now stops once closing began, and close waits for every sweep as a whole. Co-Authored-By: spade <bot@acehq.dev>
A refused first chunk left an empty payload file behind, since the file was opened for append before the check. It is now checked before opening and again right before the write. Co-Authored-By: spade <bot@acehq.dev>
…re redeeming Every link now holds its machine from right before redeeming until it is saved or fails: a second link there is refused (busy, or exists for a gap fill), so a late answer never saves a credential already replaced. The 64-link limit counts links being made, so two new machines can't both redeem when only one can be saved. Co-Authored-By: spade <bot@acehq.dev>
… cancelled The fake fleet records what it was asked and answered. The test now checks the build server issued one pairing, this computer was asked to link with keep and answered exists, and that pairing was cancelled, so a Link all that skipped the attempt fails it. Co-Authored-By: spade <bot@acehq.dev>
…t a time Co-Authored-By: spade <bot@acehq.dev>
…pt old names Ids that differ only in case shared a payload file on a case-insensitive volume, so cancelling one removed the other's upload. Files are now named by the lowercase hex SHA-256 of the transfer id. On recovery, files an earlier build named after the id move to the hashed names, in pages of live rows (ADR 0170), and stray removal keeps every name a live row can own, worked out from the rows, so no live transfer's file is deleted. Co-Authored-By: spade <bot@acehq.dev>
…sing began A begin waiting for a swept id's files could resume after close() and insert a row. It now refuses as unavailable once closing has begun. The shutdown test also checks close() is still pending while a removal is held, so it fails without the join. Co-Authored-By: spade <bot@acehq.dev>
Projects revoked while the first chunk's file was opening left an empty payload file: the check right before the write refused, but the file was already there. A file the refused call created is now removed. Co-Authored-By: spade <bot@acehq.dev>
An ace from before keep drops the field unread, so a fill sent there replaced its link. A machine's links answer now says it honours keep. Before each fill, Link all reads the source machine's links again and skips a gap that is already linked, and it sends keep only to a machine that advertises it. Co-Authored-By: spade <bot@acehq.dev>
…e honoured Co-Authored-By: spade <bot@acehq.dev>
…l names incoming-files.ts now owns the hashed names and the old ones. The size cap, cancel, refusal and recovery tests build paths through it: before, they looked at names no longer written, so they passed with the payload still there. The recovery test now checks every old-named upload moved to its own name and resumes at its offset. Co-Authored-By: spade <bot@acehq.dev>
… names it With dots in ids, x.ignored.part is x's ignored files or x.ignored's code, and recovery visiting x first took it. Every live transfer's old names are now gathered first; a file moves only when exactly one live transfer's part names it. Any other stays, kept, and is logged. Co-Authored-By: spade <bot@acehq.dev>
Recovery decides which files to keep from the live rows, page by page, then removes the rest. A transfer begun meanwhile was not among them, so its acknowledged chunk was deleted. A begin now waits, right before its insert, until stray removal ends; chunks write only for rows that were already live, so they need no wait. The hold covers the live rows' pages and one directory listing. Co-Authored-By: spade <bot@acehq.dev>
…inking A Projects link another window made after the first read could still be replaced on an older ace. Link all now reads that machine's links again once the pairing is issued, right before the link request, and skips the gap (cancelling the pairing) on any link there. What remains is the one request's round trip, which only a machine that honours keep closes. Co-Authored-By: spade <bot@acehq.dev>
…r ace re-read Co-Authored-By: spade <bot@acehq.dev>
…have moved Renaming files from an earlier build's names could take another transfer's upload (an id equal to another's hash) and race a chunk. Nothing is renamed now. At recovery, a live transfer with a part only under its old name and none under its hashed name is cancelled with a reason, so its sender starts it again. A name any live transfer owns is never taken for an old one, and the old files go with the strays, decided per file against the live names. Co-Authored-By: spade <bot@acehq.dev>
An ace from before keep drops it unread, so a link it is sent could replace one it holds, however late it was checked. Link all now skips such a machine before issuing anything, and its toast says that machine needs ace updated before Link all can link it. The re-read before the link request is gone with the race it narrowed. Co-Authored-By: spade <bot@acehq.dev>
Co-Authored-By: spade <bot@acehq.dev>
arpan404
added a commit
that referenced
this pull request
Nov 20, 2026
Co-Authored-By: spade <bot@acehq.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes from the post-merge reviews of #2312 (Allow projects,
fleet.requestscope) and #2317 (transfers over every route). Seven findings are fixed and one is disputed. Finding 9 had no code bug, only a weak test, which is now replaced.Fixed
answerTransferpassesdeviceNowon toIncomingTransfers. That reads the device again (active,operate,projects) after every await and right before each state claim or write: the commit's import claim, all three digest-failure claims, a begin's insert, and inside a queued chunk right beforeappendAtwrites. TLS and relay share this path.transfer_corruptclaim is guarded by the upload generation it checked. A commit from before a full-bundle reopen decides nothing and leaves the new files alone,finalincluded.beginwith that id waits for the removal to finish, then inserts its row.close()also waits for running sweeps.linkop now takeskeep. The linking machine refuses it asexistsright before redeeming, if it already holds a link to that machine or is making one. Link all sendskeep, cancels the pairing it no longer needs, and its toast counts only the links it made ("Already linked" when it made none).invalidand changes nothing. Another device's receipt is still answered asforbidden.Disputed
MachineScope. That swaps in that machine's client and its ownQueryClient(machineCache), andusePrimaryMachine()reads the host identity through that client. SofleetKeys.links(own.id)already lives in a separate cache per source machine, and Allow projects sends the device id from that machine's own links. A new test intransfer-allow.test.tsxreads this window's links first, then opens the chooser from the build server's thread. It checks that only the build server's links show and that only the build server's device on the laptop gains Projects. It passes on main and fails when the scope's cache is shared and keyed by one id.Review rounds on this PR
Four reviews of this branch asked for more fixes. All of them are in, and the last round replaced two earlier fixes, as noted below.
First round
x.ignored's code file wasx's ignored payload. This round renamed files to avoid that; the second round replaced the scheme with hashing.busy, orexistsfor a gap fill). Links still being made count toward the 64-link limit, so nothing is redeemed that couldn't be saved.keepand its unused pairing was cancelled.Second round
Move-1,move-1) or in dots never share a file.keepunread, so a fill sent there replaced its link. A machine'slinksanswer now says whether it honourskeep(keep: true), and before each fill Link all reads the source's links again and skips a gap that is already linked. How Link all treats a daemon withoutkeepchanged again in the fourth round (below).close()is still pending while a removal is held.Third round
beginnow waits, right before its insert, until stray removal ends. Chunks only write for rows that were already live, so they need no wait.incoming-files.ts) names payload files. The size-cap, cancel, refusal and recovery tests build paths through it; before, they checked names no longer written. The recovery test checks every old-named upload moves to its own name and resumes at its offset.Fourth round
keepis never asked to link. Link all skips it before issuing any pairing, and the toast says that machine needs ace updated before Link all can link it. That removes the older-daemon race outright, along with the re-read added in the third round.Tests
Each new or changed test was run with its fix removed and failed, then passed with the fix:
transfers/incoming-guards.test.ts(new, now 12 tests)transfers/transfer-refusals.process.test.tstransfers/transfer-retention.process.test.tsmachines/relay-link.test.tsmachines/fleet-links.test.tsfleet-access.server.process.test.tssettings/fleet-page.test.tsxtransfers/transfer-allow.test.tsxAlso run: typecheck, lint, fmt:check and check:size. The full suite was not run.
ADR 0101 and 0192 are amended to match.