Public: anyone can read this; the crew can change it.
A fork tree reader returns an app's ancestors, siblings and descendants as plain data, filtered by what the caller may read #10510
forkTree(db, repo, user, { depth?, limit? }) now exists in src/actions/forktree.ts and is pushed. It reads no git and nothing calls it yet.
stopped parked by the crew deploy 99b51b2
3 earlier comments
forkTree(db, repo, user, { depth?, limit? }) now exists in src/actions/fork_tree.ts and is pushed. It reads no git and nothing calls it yet. The new tests, bun x tsc --noEmit, bun scripts/gate.ts and test/mcp-size.test.ts pass.
What it does
- Ancestors: it climbs with
forkParentForand stops at the first parent the caller can't read. That readable ancestor becomesroot. - Descendants: from the root it walks breadth-first with
visibleForks, so siblings come with it. A private fork the caller can't read is dropped before it is counted, and everything under it goes too. - Caps: depth defaults to 4 and is capped at 8, which only applies below the root. The path down to the asked-about repo stays in even past the cap. Nodes are capped at 200 and
truncatedis true past that. All three are named constants with comments. - Follow values:
followcomes fromforkFollowMode. The stored values aretell-meandtake-updates, so I mappedtell-metooffers. The root, which follows nothing, isautonomous. No existing mode maps toautonomousfor a fork that has a parent, so none gets it.
Tests
test/fork-tree.test.tsalready exists and tests the forks page, so I put the new tests intest/fork-tree-reader.test.tsinstead of overwriting it.- They cover a three-level tree (a forge, an organization's fork, a person's fork) read from the middle, and a stranger and the private fork's owner getting different node lists, with no trace of the private fork for the stranger.
- They also cover the depth cap, the node cap with
truncated, and a warm call on a 200-fork tree answering under 50 ms. - The 200 forks are inserted as
reporows directly, not throughforkRepo, because creating that many repositories through git would be slow.
Left out: no HTTP, no MCP tool and no docs, as the issue asked. The pre-push hook wanted a "Try:" commit even though nothing user-facing changed, so I added an empty one pointing at the test.
Try: bun test test/fork-tree-reader.test.ts
I fixed the failures in the check log and pushed. The three suites touched (fork-tree-reader, hollow, unreached) pass locally (36 tests), and bun x tsc --noEmit is clean. I haven't re-run the full check.
- Wall-clock test: the "200 forks under 50 ms" test is now a statement count using
statements()andexpectWork()from the test helpers, capped at 2,000 statements. The repository bans clock bounds in tests. The "200 forks" test no longer asserts anything about milliseconds. - Unreached module: nothing under
src/importsforkTree, and the repository's rule is to wire new work, not list it. The issue forbids an HTTP or MCP door in this change, so I listedsrc/actions/fork_tree.tsinscripts/unreached-allow.jsonandscripts/hollow-allow.ts. The hollow entry cites #10388, which owns the doors. Please check that #10388 is the right issue to own the wiring, and that listing it there is acceptable. I didn't wire it through the TUI or web pages, because that would reach into surfaces the issue says to leave alone. - Stale entry:
scripts/unreached-allow.jsonnamedsrc/kernel/why_now.ts, a file that no longer exists, and the check reported it as "now reached". I removed that entry. I mergedorigin/mainfirst, and the entry was still there after the merge.
I didn't change any code to fix this. I think the red check came from the environment, not from my change, but I haven't confirmed it.
What failed: 8 tests in 5 shards. They cover cell and child-forge spawning, a sleeping preview waking at the limit, child quota, and the shell sandbox and its temp directory. The check log also showed /tmp down to 243 MiB free of 256.
Why I think it's unrelated: my branch only adds the fork tree reader (src/actions/fork_tree.ts, its test, and two allow-list entries). Those tests don't import it.
What I did: I merged main, which brought in the three newer commits (the child-forge log cap, the hosted-child cell hardening and the bets-list keys). Then I ran:
bun test test/fork-tree-reader.test.ts: 4 pass.bun scripts/gate.ts: clean.bun x tsc --noEmit: clean.
I pushed to rerun the forge's check. scripts/fast.ts reported the diff as too broad to name tests, so I ran only the fork tree test.
Still open: the cell and sandbox suites are skipped in this sandbox, so I can't run them here. If the same shards fail again, they need a person to look at them.
Pull description: the fork tree reader returns an app's ancestry and forks as plain data and is covered by test/fork-tree-reader.test.ts. It has no page or tool yet; #10388 owns its doors, and scripts/unreached-allow.json and scripts/hollow-allow.ts list it as not yet reached.
Parked by the crew: the check stayed red through 2 automatic tries
forkTree(db, repo, user, { depth?, limit? })now exists insrc/actions/fork_tree.tsand is pushed. It reads no git and nothing calls it yet. The new tests,bun x tsc --noEmit,bun scripts/gate.tsandtest/mcp-size.test.tspass.What it does
forkParentForand stops at the first parent the caller can't read. That readable ancestor becomesroot.visibleForks, so siblings come with it. A private fork the caller can't read is dropped before it is counted, and everything under it goes too.truncatedis true past that. All three are named constants with comments.followcomes fromforkFollowMode. The stored values aretell-meandtake-updates, so I mappedtell-metooffers. The root, which follows nothing, isautonomous. No existing mode maps toautonomousfor a fork that has a parent, so none gets it.Tests
test/fork-tree.test.tsalready exists and tests the forks page, so I put the new tests intest/fork-tree-reader.test.tsinstead of overwriting it.truncated, and a warm call on a 200-fork tree answering under 50 ms.reporows directly, not throughforkRepo, because creating that many repositories through git would be slow.Left out: no HTTP, no MCP tool and no docs, as the issue asked. The pre-push hook wanted a "Try:" commit even though nothing user-facing changed, so I added an empty one pointing at the test.
Try:
bun test test/fork-tree-reader.test.tsCloses #10508