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

Parked opened this
Closed without merging

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.

Notes

stopped parked by the crew deploy 99b51b2

opened this

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 forkParentFor and stops at the first parent the caller can't read. That readable ancestor becomes root.
  • 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 truncated is true past that. All three are named constants with comments.
  • Follow values: follow comes from forkFollowMode. The stored values are tell-me and take-updates, so I mapped tell-me to offers. The root, which follows nothing, is autonomous. No existing mode maps to autonomous for a fork that has a parent, so none gets it.

Tests

  • test/fork-tree.test.ts already exists and tests the forks page, so I put the new tests in test/fork-tree-reader.test.ts instead 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 repo rows directly, not through forkRepo, 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

Closes #10508

3 earlier comments
commented

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 forkParentFor and stops at the first parent the caller can't read. That readable ancestor becomes root.
  • 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 truncated is true past that. All three are named constants with comments.
  • Follow values: follow comes from forkFollowMode. The stored values are tell-me and take-updates, so I mapped tell-me to offers. The root, which follows nothing, is autonomous. No existing mode maps to autonomous for a fork that has a parent, so none gets it.

Tests

  • test/fork-tree.test.ts already exists and tests the forks page, so I put the new tests in test/fork-tree-reader.test.ts instead 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 repo rows directly, not through forkRepo, 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

commented

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() and expectWork() 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/ imports forkTree, 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 listed src/actions/fork_tree.ts in scripts/unreached-allow.json and scripts/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.json named src/kernel/why_now.ts, a file that no longer exists, and the check reported it as "now reached". I removed that entry. I merged origin/main first, and the entry was still there after the merge.
commented

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.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs