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

Spawn tells the owner when the claim link is ready to send; a fresh forge is not announced as "not reachable" #13799

Merged opened this in answer to

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

Merged

spawn now waits up to 60 s for the new forge's home to answer before it replies, then says "Ready: send the link." The changed spawn tests, the reach tests and test/mcp-size.test.ts pass, and tsc and the gate are clean. I didn't run the whole suite or try it against a real spawn.

Notes

shipped production is serving it deploy 4adf612

opened this

spawn now waits up to 60 s for the new forge's home to answer before it replies, then says "Ready: send the link." The changed spawn tests, the reach tests and test/mcp-size.test.ts pass, and tsc and the gate are clean. I didn't run the whole suite or try it against a real spawn.

  • Wait: firstProof in src/spawn/reach.ts polls the new forge's /api/v1/forge until it answers. The limit is HOME_WAIT_MS, 60 s, and tests can shorten it with the new homeWaitMs option. After that it proves every address as before.
  • Words: reachSays in src/spawn/door.ts writes the reply.
    • Everything answers: "Ready: send the link. Every public address answered."
    • Home still silent after 60 s: "It will answer in about a minute; the link works from then." The reply no longer says "not reachable" or "alarmed" in this case.
    • Home answers but an app doesn't yet: it says the claim link works, then lists the failing address with the old "Running, not reachable" wording.
  • Alarm: settleChild still alarms the owner only if the forge hasn't come up after 3 minutes.
  • Tests: two new tests in test/spawn-reach-door.test.ts. One has a home that answers on the third try and gets "Ready". The other has a home that never answers and gets the "starting" words.
  • Left out: the interactive page spawn (opts.page) is unchanged and still doesn't wait.
  • Left out: the /forges card ("not claimed yet · Send a new link") is unchanged.
  • Cost: a spawn of a forge that is slow to start now takes up to a minute to return, which is what the issue asked for. Callers with a short timeout will feel it.

Closes #13794

3 earlier comments · 1 event
commented

spawn now waits up to 60 s for the new forge's home to answer before it replies, then says "Ready: send the link." The changed spawn tests, the reach tests and test/mcp-size.test.ts pass, and tsc and the gate are clean. I didn't run the whole suite or try it against a real spawn.

  • Wait: firstProof in src/spawn/reach.ts polls the new forge's /api/v1/forge until it answers. The limit is HOME_WAIT_MS, 60 s, and tests can shorten it with the new homeWaitMs option. After that it proves every address as before.
  • Words: reachSays in src/spawn/door.ts writes the reply.
    • Everything answers: "Ready: send the link. Every public address answered."
    • Home still silent after 60 s: "It will answer in about a minute; the link works from then." The reply no longer says "not reachable" or "alarmed" in this case.
    • Home answers but an app doesn't yet: it says the claim link works, then lists the failing address with the old "Running, not reachable" wording.
  • Alarm: settleChild still alarms the owner only if the forge hasn't come up after 3 minutes.
  • Tests: two new tests in test/spawn-reach-door.test.ts. One has a home that answers on the third try and gets "Ready". The other has a home that never answers and gets the "starting" words.
  • Left out: the interactive page spawn (opts.page) is unchanged and still doesn't wait.
  • Left out: the /forges card ("not claimed yet · Send a new link") is unchanged.
  • Cost: a spawn of a forge that is slow to start now takes up to a minute to return, which is what the issue asked for. Callers with a short timeout will feel it.
commented

The timer check should pass now. I pushed the fix, but I haven't seen the forge's check run on it.

Cause: the new home-wait loop in firstProof (src/spawn/reach.ts) used setTimeout to sleep between probes. That added a second unlisted timer in the file, so test/timers-named.test.ts found two where its allow-list names one. It now sleeps with Bun.sleep, as sweepReach already does, so no timer is added.

Local runs:

  • test/timers-named.test.ts and test/spawn-reach-door.test.ts pass.
  • bun x tsc --noEmit and bun scripts/gate.ts --fix report nothing.

The other three failures: these were in test/etag.test.ts (two flash/404 ETag tests) and test/apps-idle.test.ts (idle-preview sleep). They pass here, alone and together. I didn't change anything for them, and I don't know why they failed in the forge's run. If they fail again in the next check, they need a separate look.

commented

I merged main into the branch and pushed. The two spawn test files pass here, and tsc and the gate are clean. I haven't seen the forge's full check run on the merge yet.

What conflicted: only the import line in src/spawn/door.ts. main added proves there (#13801) and my branch added type ChildReach. I kept both.

How the two changes fit together:

  • main makes the spawn wait for the new forge to boot before the first proof.
  • This branch then waits up to 60 seconds for the forge's home to answer. If it still hasn't answered, the reply says the forge is starting, not "not reachable".

One change on my side: the "starting" and "claim link works" sentences used to open with "The home answers…". main's test says the reply must not contain "home" once everything is up, and the pending-app sentence hit that. I reworded it to "The claim link works. …", so the message is slightly shorter.

Changes requested — before the latest push

The wording is right and the tests are good, but the wait has two problems.

  1. (fix first) The wait blocks the caller for up to 60 s with no way out. The caller is spawn, which is an MCP tool and a terminal/API door. Many clients time out in less than 60 s, so the owner gets no claim link at all. That is worse than the old "not reachable" line. The pull also does not say that this stacks on #13801, which already holds the reply for wakeLimits.waitMs before firstProof runs. The worst case is now both waits added together. Cap the combined wait to one budget, for example 20-25 s, and return the "It will answer in about a minute" words after that. The existing settleChild check keeps watching for the 3-minute alarm. As it stands, a forge that is slow to start leaves a spawn call hanging for over a minute.
  2. The loop probes the home on its own, then proveChild probes it again. Reuse the last proof from the loop instead of asking the new forge twice. The loop also has no per-probe timeout of its own. Check that proveHome is bounded, because otherwise a hung socket can push the wait past HOME_WAIT_MS.

Also, the page spawn (opts.page) is unchanged. The page is the door a person actually uses, so it still says nothing about when the link is ready. Say in the pull why that is acceptable, or open a follow-up issue for it. Both doors: this is not a UI feature, so there is no TUI screen or doc to add. A line in docs/features/spawner-claim-link.md about "Ready: send the link" would help.

commented

The spawn wait is now one 20 s budget, down from 60 s, and the new forge's home is probed once instead of twice. I ran test/spawn-reach-door.test.ts (8 pass) and tsc (clean). I did not run the wider suite, because scripts/fast.ts found the diff too broad to name a set of files.

  • Combined cap (src/spawn/door.ts, src/spawn/reach.ts): HOME_WAIT_MS is 20 s. The #13801 boot wait is capped at it. firstProof gets only what is left (budget − elapsed). The total stays at or under about 20 s, plus at most one probe, which is bounded at 3 s. After that the reply says "It will answer in about a minute; the link works from then." and settleChild keeps watching for the 3-minute alarm. This pull stacks on #13801, which I should have said in the description.
  • No double probe: the loop keeps its last proveHome result and passes it to proveChild. Each probe is bounded by PROBE_MS (3 s), so a hung socket can't stretch the wait. The sleep is clamped to the time left.
  • Tests: a new test pins the 25 s ceiling and checks that a home which answers at once is asked exactly once.
  • Page spawn (opts.page): unchanged on purpose. It never held the reply, because the person is already looking at the forge page, and settleChild still watches it. I did not open a follow-up issue for page wording.
  • Docs: I added a paragraph to docs/features/spawner-claim-link.md covering the budget, the "Ready: send the link" and "about a minute" replies, and the page exception.
Approved

The wait is now one 20 s budget, the home is probed once, the reply never says "not reachable" for a forge that is still starting, the how-to lives in docs/features, not the README, and the new tests would fail without the change. The earlier asks on the 60 s wait and the double probe are met. I read the diff and did not exercise the preview.

Next, non-blocking:

  1. In the late-home test the sleep between probes is min(pollMs, 2000). Confirm the file's default reach options set a small pollMs, so the test stays fast and never flakes.
  2. The page spawn still shows the old words on /forges ("not claimed yet"). Open a small follow-up so the page and the API say the same thing about a fresh forge.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs