Public: anyone can read this; the crew can change it.
A child's clone is refused when it carries objects/info/alternates pointing outside it #14930
Check · Review · Land · Live done — Landed and live in production.
A child's own-code start is now refused before git clone runs if its forge repository borrows objects from a store outside the child's directory. Until now a local clone followed a child-written objects/info/alternates file, so it could copy a parent repository's objects into the child's cell.
shipped production is serving it deploy 5b5da4d
A child's own-code start is now refused before git clone runs if its forge repository borrows objects from a store outside the child's directory. Until now a local clone followed a child-written objects/info/alternates file, so it could copy a parent repository's objects into the child's cell. Closes the #14914 finding from #14770.
What changed (src/spawn/own_code.ts)
- A new
alternatesInside(repo, bound)check reads the repository'sobjects/info/alternates. Each entry must resolve, by realpath, inside the child's directory (<childDir>, three levels aboverepos/<org>/forge.git, the pathownRepoOffinds), and that store must contain no symbolic link. - It follows alternates of alternates up to five levels deep, as git does, and applies the same rules at each level.
- Any entry in
http-alternatesis refused: it names stores by URL, which a realpath cannot place. - A quoted entry is refused rather than unquoted the way git would.
checkoutruns the check after the size and symlink walk and beforegit clone. A refusal is recorded as the new rollback reason "its repository borrows objects from outside its forge", which is added toROLLBACK_WORDS.
Tests (test/own-code.test.ts)
- An alternates file naming a sibling repository in the parent's data is refused, the commit is marked failed, and no checkout is made. Without the change in
src/this test fails (receivedundefined). - Unit cases for
alternatesInsidethat pass: an absolute or relative entry inside the child's directory, and comments. - Unit cases that are refused: a relative path that climbs out, a store inside the child's directory that itself borrows from outside, a symlink inside the child's directory pointing outside, a quoted entry, and
http-alternates.
Not done
- No
--no-localfallback: the exact check made it unnecessary, and a non-local clone would still serve objects from the source's alternates anyway. - If the child rewrote its alternates between the check and the clone, it would slip through. That only matters if a child's files can change while its start is being prepared; I did not check whether they can.
Checks run: bun scripts/gate.ts --fix (its comment rewrap is included in the commit), bun x tsc --noEmit, and four suites covering own-code (own-code, spawn-cell-stays, boundary-tenancy-files, forge-code-own-source), all passing. scripts/fast.ts named 2,184 test files, too many to run here, so I picked those four myself. The full check runs on the push. This issue's keep_plan and estimate tools were not available in this run, so no plan was kept on the issue, and the #14770 box still needs ticking.
To try: bun test test/own-code.test.ts
🤖 Generated with Claude Code
Approved. The check runs before git clone, follows nested alternates, refuses http-alternates and quoted entries, resolves symlinks by realpath, and records a worded rollback reason. The tests cover the sibling-repository case end to end and the unit edge cases. No web or TUI surface changes, so nothing to look at in the preview. Two things I would do next: (1) close the check-to-clone window, either by cloning from a snapshot the check read or by re-running alternatesInside immediately before the clone, and say whether child files can change during start; (2) add a one-line note to docs/features for own-code about the new rollback reason.
A child's own-code start is now refused before
git cloneruns if its forge repository borrows objects from a store outside the child's directory. Until now a local clone followed a child-writtenobjects/info/alternatesfile, so it could copy a parent repository's objects into the child's cell. Closes the #14914 finding from #14770.What changed (
src/spawn/own_code.ts)alternatesInside(repo, bound)check reads the repository'sobjects/info/alternates. Each entry must resolve, by realpath, inside the child's directory (<childDir>, three levels aboverepos/<org>/forge.git, the pathownRepoOffinds), and that store must contain no symbolic link.http-alternatesis refused: it names stores by URL, which a realpath cannot place.checkoutruns the check after the size and symlink walk and beforegit clone. A refusal is recorded as the new rollback reason "its repository borrows objects from outside its forge", which is added toROLLBACK_WORDS.Tests (
test/own-code.test.ts)src/this test fails (receivedundefined).alternatesInsidethat pass: an absolute or relative entry inside the child's directory, and comments.http-alternates.Not done
--no-localfallback: the exact check made it unnecessary, and a non-local clone would still serve objects from the source's alternates anyway.Checks run:
bun scripts/gate.ts --fix(its comment rewrap is included in the commit),bun x tsc --noEmit, and four suites covering own-code (own-code,spawn-cell-stays,boundary-tenancy-files,forge-code-own-source), all passing.scripts/fast.tsnamed 2,184 test files, too many to run here, so I picked those four myself. The full check runs on the push. This issue'skeep_planandestimatetools were not available in this run, so no plan was kept on the issue, and the #14770 box still needs ticking.To try:
bun test test/own-code.test.ts🤖 Generated with Claude Code
Closes #14914