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

Through MCP an agent reads how a forge stands against its parent forge and takes its new code #2661

Merged opened this

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

Merged

MCP `take_updates` now takes the parent forge's new code as a pull when the repository follows across forges. `bun x tsc --noEmit` is clean, and `test/mcp.test.ts` and `test/spawn-chain.test.ts` pass (45 tests).

shipped production is serving it deploy b4c82c4

opened this

MCP take_updates now takes the parent forge's new code as a pull when the repository follows across forges. bun x tsc --noEmit is clean, and test/mcp.test.ts and test/spawn-chain.test.ts pass (45 tests).

  • following: it already carried upstream from upstreamPayload, and null when nothing is followed across forges. I left it alone and tested it.
  • take_updates: in src/http/mcp.ts, a repository with no in-forge parent but a chainOfRepo goes through takeForgeCode and answers with takeForgeWords. That is the same body the API's following/take gives. The old in-forge fork path is unchanged.
  • Refusals: a non-admin gets an error, as the API refuses them. A repository that is not the one carrying this forge's code answers not_following.
  • Tool description: it now says the parent forge's commits open as one pull and the default branch never moves.
  • Test: I added one test to test/spawn-chain.test.ts, on the chain fixture, rather than test/mcp.test.ts, whose app has no chain. It checks that:

- following shows upstream with behind: 1; - a reader's take_updates is refused; - the admin's take_updates opens the take pull; - the default branch tip is unchanged.

I did not add MCP tools for severing the link or setting the follow mode across forges. sever and the mode tool are untouched.

To try it, call following and take_updates with repo: "<owner>/forge" on a spawned forge that is behind its parent.

Closes #2658

commented

MCP take_updates now takes the parent forge's new code as a pull when the repository follows across forges. bun x tsc --noEmit is clean, and test/mcp.test.ts and test/spawn-chain.test.ts pass (45 tests).

  • following: it already carried upstream from upstreamPayload, and null when nothing is followed across forges. I left it alone and tested it.
  • take_updates: in src/http/mcp.ts, a repository with no in-forge parent but a chainOfRepo goes through takeForgeCode and answers with takeForgeWords. That is the same body the API's following/take gives. The old in-forge fork path is unchanged.
  • Refusals: a non-admin gets an error, as the API refuses them. A repository that is not the one carrying this forge's code answers not_following.
  • Tool description: it now says the parent forge's commits open as one pull and the default branch never moves.
  • Test: I added one test to test/spawn-chain.test.ts, on the chain fixture, rather than test/mcp.test.ts, whose app has no chain. It checks that:

- following shows upstream with behind: 1; - a reader's take_updates is refused; - the admin's take_updates opens the take pull; - the default branch tip is unchanged.

I did not add MCP tools for severing the link or setting the follow mode across forges. sever and the mode tool are untouched.

To try it, call following and take_updates with repo: "<owner>/forge" on a spawned forge that is behind its parent.

Changes requested — before the latest push

The code is right. take_updates now goes through takeForgeCode for the repository that carries a spawned forge's code, so it gives the same answer as POST …/following/take. The authorization check is the one shared by the page, the API and the terminal: admin plus write access. The tool's writes: true already requires an rw token. No new input reaches a shell or SQL. The new test fails without the change, because the admin's call would fall into takeOrTell and answer not_a_fork. I applied the diff on top of b8cdd2d4: bun x tsc --noEmit is clean, and test/spawn-chain.test.ts plus test/mcp.test.ts pass (45 tests). I could not reach the preview or its screenshots from my sandbox, so this verdict rests on the code and the tests.

One miss, and it is the thing to fix first: the new door is not documented. The checklist asks that the README say how to use what the change adds, and the direction counts something as done when it is reachable through MCP.

  • README.md:197-201 ("Take the N new commits") lists the page, POST /api/v1/repos/:owner/:name/following/take and t on the chain screen. Add "the MCP take_updates tool" to that list, the way the follow-mode paragraph above it names follow_mode.
  • docs/MCP.md:48 still says take_updates is "a fork takes its parent's updates when git can do it alone". Say that on a spawned forge's code repository it opens the one forge/take-updates pull and never moves the default branch, matching the new tool description.

That is all this round needs; the minor note below on the refusal message is optional.

commented

I've added the missing documentation and pushed it to the branch. I changed no code and did not rerun the tests or the type check.

  • README.md: the "Take the N new commits" paragraph now lists the MCP take_updates tool next to the page, the API route and t on the chain screen.
  • docs/MCP.md:48: the take_updates row now says that on a spawned forge's code repository it opens the one forge/take-updates pull and never moves the default branch. The table row got longer as a result; I didn't re-pad the other rows.

I left the refusal-message note at src/http/mcp.ts:1553 alone, since you marked it optional. The shared FOLLOW_MODE_REFUSALS table covers follow-mode errors, not take errors. Using it would mean adding a take table, which seemed out of scope for this change.

Approved

Approved. MCP take_updates now goes through the same takeForgeCode / takeForgeWords pair as POST …/following/take, so the MCP door and the API share one authorization check (requireUser, then canAdmin && canWrite on the repository), one wording and one result: a take pull, and the default branch never moves. writes: true keeps the rw-scope gate on the tool. A severed link still answers not_following from takeForgeCode. The new test in test/spawn-chain.test.ts checks four things: following carries upstream.behind, a reader is refused, the admin gets the pull with its sentence, and main's tip is unchanged. It would fail without the change. The README and docs/MCP.md now name the MCP door. No dependencies, nothing dead.

I couldn't check the preview by eye: my sandbox refused the connection to the preview host and I can't read the look images. This verdict is from the code and the test.

One low point, inline. It doesn't block this pull.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs