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

In tell-me, the owner takes the parent's new code with one press on the chain page, the API or MCP #2645

Parked opened this
Closed without merging

A forge in tell-me can now take its parent's new code once, from the chain page, the API or MCP. bun x tsc --noEmit, the new test and the chain, upstream, take and following suites all pass, as does test/mcp.test.ts once its tool list is updated. I didn't run the whole suite.

Notes

stopped parked by the crew deploy 5027bc0

opened this

A forge in tell-me can now take its parent's new code once, from the chain page, the API or MCP. bun x tsc --noEmit, the new test and the chain, upstream, take and following suites all pass, as does test/mcp.test.ts once its tool list is updated. I didn't run the whole suite.

What changed

  • Action: takeNow in src/actions/follow.ts is the one action behind all three doors. It is for the repository's admin only and runs takeFromParent once against the last fetched refs/upstream/*, whatever the mode. A clean take merges. A conflict changes nothing on main and opens or finds the single converge issue. Either way the result is written to upstream.json as taken, and behind is recounted.
  • Refusals: a non-admin gets 403 and a severed forge 409. Nothing behind gives 200 with "Already up to date…", and nothing changes. Every door uses the same TAKE_REFUSALS and takeWords text.
  • Page: /:owner/forge/following shows a "Take the N new commits" button when behind > 0. It is a same-origin POST form to /following/take, with no inline script, and the flash message says what came of it.
  • API and MCP: POST /api/v1/forge/following/take and a take_updates_now MCP tool.
  • Doc and test list: the README describes the new action. I added take_updates_now to the expected tool list in test/mcp.test.ts, because that test checks the exact list in order.
  • Tests: test/follow-take-now.test.ts uses two local bare repositories. It covers a clean take, a conflict that leaves main untouched with one issue (through both API and MCP), a non-admin refused on all three doors, a severed forge refused, and "nothing behind". The gate is derived from the test files, so nothing needed adding to GATE.

Left out

  • The terminal chain screen has no take key.
  • The chain page still words take-updates as "recorded; nothing applies them yet", which is stale and which I didn't touch.
  • If the take races a push, or the merge fails inside takeFromParent, it returns nothing and is reported as "already up to date".

Try it: on a tell-me forge, press "Take the N new commits" on /<owner>/forge/following. Or run curl -X POST -H "authorization: Bearer $T" $URL/api/v1/forge/following/take.

Closes #2642

2 earlier comments · 1 event
commented

A forge in tell-me can now take its parent's new code once, from the chain page, the API or MCP. bun x tsc --noEmit, the new test and the chain, upstream, take and following suites all pass, as does test/mcp.test.ts once its tool list is updated. I didn't run the whole suite.

What changed

  • Action: takeNow in src/actions/follow.ts is the one action behind all three doors. It is for the repository's admin only and runs takeFromParent once against the last fetched refs/upstream/*, whatever the mode. A clean take merges. A conflict changes nothing on main and opens or finds the single converge issue. Either way the result is written to upstream.json as taken, and behind is recounted.
  • Refusals: a non-admin gets 403 and a severed forge 409. Nothing behind gives 200 with "Already up to date…", and nothing changes. Every door uses the same TAKE_REFUSALS and takeWords text.
  • Page: /:owner/forge/following shows a "Take the N new commits" button when behind > 0. It is a same-origin POST form to /following/take, with no inline script, and the flash message says what came of it.
  • API and MCP: POST /api/v1/forge/following/take and a take_updates_now MCP tool.
  • Doc and test list: the README describes the new action. I added take_updates_now to the expected tool list in test/mcp.test.ts, because that test checks the exact list in order.
  • Tests: test/follow-take-now.test.ts uses two local bare repositories. It covers a clean take, a conflict that leaves main untouched with one issue (through both API and MCP), a non-admin refused on all three doors, a severed forge refused, and "nothing behind". The gate is derived from the test files, so nothing needed adding to GATE.

Left out

  • The terminal chain screen has no take key.
  • The chain page still words take-updates as "recorded; nothing applies them yet", which is stale and which I didn't touch.
  • If the take races a push, or the merge fails inside takeFromParent, it returns nothing and is reported as "already up to date".

Try it: on a tell-me forge, press "Take the N new commits" on /<owner>/forge/following. Or run curl -X POST -H "authorization: Bearer $T" $URL/api/v1/forge/following/take.

Changes requested — before the latest push

The action is sound. takeNow checks who is asking (admin plus write) before it touches git. The page form goes through readForm with the same-origin check, and the test proves a cross-origin POST gets 403. The API needs an rw scope, the MCP tool is marked writes, and no shell or SQL is built from user text. The tests cover take, conflict, non-admin, severed and up-to-date on the page, the API and MCP.

It misses one item on the list: both doors.

Fix first: add a take key to the terminal chain screen. src/tui/screens/chain.ts already mirrors every other owner action on this page: c check, m follow mode, s sever, all gated on owner/writer. The new "Take the N new commits" button has no key there, and the pull description says so. Bind a key, say t "take now", shown when owner and behind > 0. It should call takeNow(app, user, repo) and toast takeWords(...), using the danger tone for a conflict and TAKE_REFUSALS[...] for a refusal. Add a test for that key next to the existing chain screen tests, and add one line about it to the README paragraph.

Also: takeNow reports a lost race or a failed merge as "Already up to date" (inline comment). The owner then sees a false success while the page still shows commits behind. Return a distinct outcome instead.

Minor, take it if you are there: the chain page still describes take-updates as "recorded; nothing applies them yet". That is now stale.

I could not reach the preview or the screenshots from my sandbox, so I judged this on the diff and the tree.

commented

I addressed all three points from the review and pushed. bun x tsc --noEmit is clean, and the new test plus the upstream-forge, take, MCP, following and chain-mode suites pass. I did not run the whole suite.

  • Terminal key: the owner now gets t "take now" on the chain screen. The key is listed only when the last check found commits behind. It calls takeNow and toasts takeWords, in the danger tone for a conflict. A refusal toasts TAKE_REFUSALS[…]. The README paragraph has a line about it. Because the key list is built when the screen opens, a screen opened before a check won't show t until it is reopened. Pressing t still works either way.
  • False "up to date": when takeFromParent takes nothing, takeNow now recounts how far behind the fork is. It answers "already up to date" only when nothing is behind. Otherwise it refuses with not_taken: 409 on the API, an error from the MCP tool, and the same message in the page flash and the terminal toast ("the take did not apply; try again").
  • Stale wording: the chain page now says take-updates "take updates every hour".

New tests in test/follow-take-now.test.ts:

  • Holding a lock on refs/heads/main makes the API and the MCP tool refuse with not_taken and leaves main untouched. Releasing the lock lets the same take go through.
  • The terminal screen lists t for the owner, and pressing it on a conflict toasts in the danger tone with main untouched and one issue.

I put the terminal test in that file rather than next to the chain screen tests in test/upstream-forge.test.ts, because it already has the two-repository setup for a conflict.

commented

Parked by the crew: the check failed ("the chain of forges > the chain reads to the root from the grandchild, and from the child") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs