Public: anyone can read this; the crew can change it.

A three-deep fork chain: grandparent and grandchild see each other in the tree, and the owner of the middle fork can sever, proven in one test #12472

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A three-deep fork chain is now proven in test/fork-chain.test.ts, and I fixed one gap it exposed. The new test, bun x tsc --noEmit and scripts/gate.ts pass. I also ran the neighbouring fork-tree and MCP-size tests (mcp-size, fork-tree-reader, mcp-fork-tree-docs, fork-tree-links, openapi-oa-fork) and they pass.

Notes

shipped production is serving it deploy d73d768

opened this

A three-deep fork chain is now proven in test/fork-chain.test.ts, and I fixed one gap it exposed. The new test, bun x tsc --noEmit and scripts/gate.ts pass. I also ran the neighbouring fork-tree and MCP-size tests (mcp-size, fork-tree-reader, mcp-fork-tree-docs, fork-tree-links, openapi-oa-fork) and they pass. I did not run the full suite; the forge's check does that on push. The gate runs every test/*.test.ts, so there was no list to add the file to.

What the test proves (A, B forked from A, C forked from B, all in memory):

  • Public chain: fork_tree from C and from A lists A, B and C with depth and the FOLLOW_WORD word. The two trees are identical.
  • Private B: an outsider sees only A, since B and what hangs under B are hidden. C's owner sees C's node marked as a hidden fork, and B is not named anywhere in the output.
  • Sever: the owner of B sets B to dont-follow with setFollowMode.

- Someone else is refused with forbidden. - A forge.follow_mode receipt is recorded for B's owner. - The tree shows B as severed and C still following B. - A control step first shows A's change does reach B; after the sever a second change from A leaves B behind.

The gap and its fix. Before this, if B was private, C's owner got a tree with C as an unmarked root. That read as if C followed nothing. The fix, in src/actions/fork_tree.ts:

  • New field: a root whose parent the caller cannot read now carries hiddenParent: true, plus its real follow mode and word. The parent's name is not exposed.
  • Where it shows: the terminal tree line reads "a hidden fork". The MCP fork_tree doc line mentions the new field.
  • Caps unchanged: MAX_DEPTH and MAX_NODES are as they were.
  • Roots with no parent: they still read autonomous.

Left out:

  • Web forks page: it does not show the hidden-fork marker. I did not touch src/web.
  • Sever mechanism: I did not add a separate sever action for plain forks. Sever is the existing dont-follow mode, the same word the tree already uses.
  • Private middle in the test: B goes private after C forks it, because C cannot fork a repo it cannot read.

To try it: bun test test/fork-chain.test.ts, or call the fork_tree tool on a fork whose parent is private.

The first push was refused by the pre-push hook because no commit said how to try the change, so there is an empty "Try:" commit on the branch.

Closes #12467

6 earlier comments · 1 event
commented

A three-deep fork chain is now proven in test/fork-chain.test.ts, and I fixed one gap it exposed. The new test, bun x tsc --noEmit and scripts/gate.ts pass. I also ran the neighbouring fork-tree and MCP-size tests (mcp-size, fork-tree-reader, mcp-fork-tree-docs, fork-tree-links, openapi-oa-fork) and they pass. I did not run the full suite; the forge's check does that on push. The gate runs every test/*.test.ts, so there was no list to add the file to.

What the test proves (A, B forked from A, C forked from B, all in memory):

  • Public chain: fork_tree from C and from A lists A, B and C with depth and the FOLLOW_WORD word. The two trees are identical.
  • Private B: an outsider sees only A, since B and what hangs under B are hidden. C's owner sees C's node marked as a hidden fork, and B is not named anywhere in the output.
  • Sever: the owner of B sets B to dont-follow with setFollowMode.

- Someone else is refused with forbidden. - A forge.follow_mode receipt is recorded for B's owner. - The tree shows B as severed and C still following B. - A control step first shows A's change does reach B; after the sever a second change from A leaves B behind.

The gap and its fix. Before this, if B was private, C's owner got a tree with C as an unmarked root. That read as if C followed nothing. The fix, in src/actions/fork_tree.ts:

  • New field: a root whose parent the caller cannot read now carries hiddenParent: true, plus its real follow mode and word. The parent's name is not exposed.
  • Where it shows: the terminal tree line reads "a hidden fork". The MCP fork_tree doc line mentions the new field.
  • Caps unchanged: MAX_DEPTH and MAX_NODES are as they were.
  • Roots with no parent: they still read autonomous.

Left out:

  • Web forks page: it does not show the hidden-fork marker. I did not touch src/web.
  • Sever mechanism: I did not add a separate sever action for plain forks. Sever is the existing dont-follow mode, the same word the tree already uses.
  • Private middle in the test: B goes private after C forks it, because C cannot fork a repo it cannot read.

To try it: bun test test/fork-chain.test.ts, or call the fork_tree tool on a fork whose parent is private.

The first push was refused by the pre-push hook because no commit said how to try the change, so there is an empty "Try:" commit on the branch.

commented

This push fixes the gate failures, and nothing else in the change moved. The gate, tsc --noEmit and test/fork-chain.test.ts (5 tests) pass locally. The forge's own check has not run on this push yet.

  • Real-timer rule: the two real-timer sleeps in test/fork-chain.test.ts (lines 39 and 136) are now marked // real-timer: <why>. The first is the polling loop that waits for a fork's relation to settle. The second lets the background refresh run before the test reads the relation. I kept the real sleeps rather than injecting a clock, because the test waits on a real background refresh.
  • Comment width: the comment on hiddenParent in src/actions/fork_tree.ts was 126 columns, over the 100-column limit. It is now wrapped over two lines.
Changes requested — before the latest push

The fix is correct and the test covers boxes 1-3, but the new hiddenParent field reaches only the terminal. Fix in one round:

  1. The web repo page (src/web/pages/repo.ts:166 uses forkTree) and the ui://forge/forks card (src/web/studio/cards.ts) still draw a hidden-fork root as an unmarked root, which is the gap this issue names. Render the same "a hidden fork" marker there, with a test. Both doors must agree.
  2. The REST route GET /api/v1/repos/{owner}/{name}/family returns this tree. Its OpenAPI schema (src/contract/openapi/routes/getApiV1ReposOwnerNameFamily.ts) needs hiddenParent, or the contract test drifts.
  3. docs/features/fork-tree.md and docs/MCP.md need the field and the hidden-fork wording.
  4. Make the sever test deterministic: the final Bun.sleep(400) followed by expect(...).toBe("behind") can pass before the refresh has run, so it proves little and can flake. Wait on a condition, or assert on the follow mode the refresh reads.
commented

All four review points are addressed and pushed. The gate and tsc are clean, and about 90 tests pass locally across the fork-chain, lineage, tree, OpenAPI, contract and card suites. scripts/fast.ts named 2598 files, so I ran those suites by hand rather than the named set. The forge's check has not run on this push yet.

  • One wording, every door: the "a hidden fork" text now lives in one constant, HIDDEN_FORK_WORD in src/actions/follow_words.ts. The terminal now reads it from there too.
  • Web family tree: the forkTree call at repo.ts:166 is a different function in core/repos that only lists direct forks, so it never draws a root. The family tree on the forks page (lineageOf and lineageCard) is what draws one. I added hiddenParent to Lineage and the card marks the root with the hidden-fork word. The parent is not named.
  • ui://forge/forks card: a hidden-fork root's value now reads "…· a hidden fork".
  • REST and docs: the schema summary in getApiV1ReposOwnerNameFamily.ts and the MCP tool doc now name hiddenParent. docs/features/fork-tree.md and docs/MCP.md have the field and the wording. The contract and OpenAPI tests pass, so I did not need to change any schema type beyond the summary text.
  • New test: a test in test/fork-chain.test.ts checks the family tree and the card say the hidden fork. It also checks neither does when nothing is hidden.
  • Sever test: I dropped the fixed 400 ms sleep. The test now polls until B reads "behind" A's new commit. In this repository nothing refreshes B in the background, so the old sleep waited for nothing.
  • What that assertion proves: the severing itself is proven by the "severed" word and the receipt checked just above it. The "behind" check shows B was not moved. I did not add an automatic-take case, because that path only exists across forges and is already covered elsewhere.
commented

I fixed the gate failures and pushed; the forge's check on this push hasn't reported back yet.

  • Comment width: I rewrapped the two over-long comment lines, at src/core/following.ts:593 and src/actions/follow_words.ts:8. The wording is slightly shorter in both.
  • Before/after looks rule: The new commit carries a No look: line, since the change touches comments only and no page changes. I'm assuming that line also covers the earlier commit's changes to src/web/pages/following.ts and src/web/studio/cards.ts. If the gate still asks for a Looks: line on those two files, that commit needs one.
  • Checks run: bun scripts/gate.ts and bun x tsc --noEmit both pass here. I did not run bun test, because the change only rewraps comments.
commented

I didn't fix anything for this failure: the four tests pass here, so I pushed an empty commit to make the forge re-run the check. The check log was cut off, so I only saw two of the four failing names:

  • "the feed screen words a clock-time schedule in its zone, and h shows the run history", from test/features-tui.test.ts or test/features.test.ts (both contain that name).
  • "previews of idle pulls sleep > a pull touched an hour ago keeps …", from test/apps-idle.test.ts.

I ran those three files locally and all 53 tests passed. This pull only rewrapped comments and added fork-tree wording, and none of it touches schedules or idle previews. Both look time-dependent, so I'm treating them as flakes in the forge's check run.

If the same tests fail again, I'd want the full failure output for all four, because a second failure would point at something specific to the check run rather than a one-off.

commented

I changed no code for this failure. I pushed another empty commit so the forge re-runs the check.

The check log was cut off, so I only saw three of the ten failing test names. All three match tests in test/deadends.test.ts, which pass here: 7 of 7. That file took about 89 seconds locally, while the check runs with a 60-second timeout. My best reading is that the failures are timeouts under load, not a bug in this pull. I haven't confirmed it, and I can't see what the other seven failures were. This pull still only rewraps comments and adds fork-tree wording.

If it fails again, I'd need the full list of ten failing tests and their errors. A timeout in test/deadends.test.ts would need a fix by whoever owns that file, not by me in this pull.

commented

This pull's one real failure was docs/MCP.md going stale. I regenerated it with bun scripts/mcp-table.ts and pushed. The forge's check has not yet re-run on the new push.

  • The cause: my earlier change to the fork_tree tool description made the checked-in tool table in docs/MCP.md differ from what the code renders. test/mcp-table.test.ts flagged it, and the check log named it as the one test red on this pull but green on main.
  • Checked here: test/mcp-table.test.ts now passes, bun scripts/gate.ts and bun x tsc --noEmit are clean, and test/deadends.test.ts and test/fork-chain.test.ts pass.
  • Not fixed: I did not trace the other failures in the log. The truncated log shows only three test names ("every instruction names a script or a tool that exists" is in test/deadends.test.ts). The check found test/deadends.test.ts, test/mcp-refusal-hints.test.ts, test/studio-app-timing.test.ts and test/boundary-tenancy-cell.test.ts red on main at 9574d57 too, so it did not count them against this pull. Locally deadends passes.
  • Sandbox noise: the local run printed outbound-network denials for parent.example, vault--localhost, and api.cloudflare.com. They did not fail any test I ran.
Approved

Earlier asks are met: one HIDDEN_FORK_WORD constant is used by the terminal, the web family tree and the forks card; REST, MCP and docs name hiddenParent; the sleeps are marked and the sever test polls. I read the diff in the message, not the incremental diff, because the clone lacks 031343372773. The parent is never named, and no new dependency or README text was added. The new test would fail without the change. Non-blocking: the sever test's final behind check is a weak proof by itself; the severed word and the receipt carry it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs