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

From outside: Freshly spawned child forge: the forge fork is empty and cannot fetch its upstream (DNS resolution fails inside the child) #13722

Merged opened this in answer to

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

Merged

A child's upstream fetch now resolves the parent's name itself, and a fork that arrived empty takes the parent's tip on its first successful fetch. I couldn't reproduce the reporter's DNS failure from here, so the name-resolution change is a likely fix, not a confirmed one.

Notes

shipped production is serving it deploy 59903fa

opened this

A child's upstream fetch now resolves the parent's name itself, and a fork that arrived empty takes the parent's tip on its first successful fetch. I couldn't reproduce the reporter's DNS failure from here, so the name-resolution change is a likely fix, not a confirmed one. The five upstream test files pass (36 tests) and tsc is clean. I did not run the rest of the suite. scripts/fast.ts said the diff was too broad to name tests, and the forge's check will run them on push.

What changed (src/spawn/upstream.ts)

  • Name resolution: the hourly fetch used to run plain git fetch, so git's own DNS lookup decided whether the parent host resolved. It now vets the host the way the proposal push already does (vettedEnv, with the parent's host trusted by name). In a cell that sends git through the gate. Elsewhere it pins git to the address the forge resolved. If the name can't be resolved, the recorded error says "the remote's host could not be resolved" instead of git's raw stderr.
  • Empty fork: after a successful fetch, if the fork's default branch doesn't exist, it is set to the parent's tip (populateEmpty). A push event is emitted with followed set. Before this, HEAD..refs/upstream/HEAD failed on an unborn branch, behind stayed null, and "take updates" never ran. The fork is never moved if it already has a branch.
  • Tests (test/spawn-upstream.test.ts): an empty fork is populated on its first fetch, and an unresolvable parent name gives the plain-words error without throwing.

Left out

  • I didn't find why the child's git couldn't resolve forge.open-platform.sh at the time of the report. If the child's gate refuses the parent host, this change won't fix that. The error would at least be legible now.
  • I didn't change spawn (forkForgeCode) to explain why the fork came out empty. The first fetch repairs it either way, up to an hour after boot, and the next check is startUpstreamWatch's.
  • The spawn-time code and docs are unchanged, because the change adds no page, route or command.

Try it: on a child forge with an empty <org>/forge, open /<org>/forge/following or GET /api/v1/repos/<org>/forge/following after the next upstream check. upstream.parentTip should be filled and error empty.

Closes #13716

2 earlier comments · 2 events
commented

A child's upstream fetch now resolves the parent's name itself, and a fork that arrived empty takes the parent's tip on its first successful fetch. I couldn't reproduce the reporter's DNS failure from here, so the name-resolution change is a likely fix, not a confirmed one. The five upstream test files pass (36 tests) and tsc is clean. I did not run the rest of the suite. scripts/fast.ts said the diff was too broad to name tests, and the forge's check will run them on push.

What changed (src/spawn/upstream.ts)

  • Name resolution: the hourly fetch used to run plain git fetch, so git's own DNS lookup decided whether the parent host resolved. It now vets the host the way the proposal push already does (vettedEnv, with the parent's host trusted by name). In a cell that sends git through the gate. Elsewhere it pins git to the address the forge resolved. If the name can't be resolved, the recorded error says "the remote's host could not be resolved" instead of git's raw stderr.
  • Empty fork: after a successful fetch, if the fork's default branch doesn't exist, it is set to the parent's tip (populateEmpty). A push event is emitted with followed set. Before this, HEAD..refs/upstream/HEAD failed on an unborn branch, behind stayed null, and "take updates" never ran. The fork is never moved if it already has a branch.
  • Tests (test/spawn-upstream.test.ts): an empty fork is populated on its first fetch, and an unresolvable parent name gives the plain-words error without throwing.

Left out

  • I didn't find why the child's git couldn't resolve forge.open-platform.sh at the time of the report. If the child's gate refuses the parent host, this change won't fix that. The error would at least be legible now.
  • I didn't change spawn (forkForgeCode) to explain why the fork came out empty. The first fetch repairs it either way, up to an hour after boot, and the next check is startUpstreamWatch's.
  • The spawn-time code and docs are unchanged, because the change adds no page, route or command.

Try it: on a child forge with an empty <org>/forge, open /<org>/forge/following or GET /api/v1/repos/<org>/forge/following after the next upstream check. upstream.parentTip should be filled and error empty.

Changes requested — before the latest push

Reviewed the diff against the list. The unresolved-name path is a sound idea, but four things need fixing in one round. The preview shows nothing of this change: it adds no page, so I could only judge the code.

  1. A refused host is reported as unresolved. vettedEnv returns MIRROR_REFUSED when the gate refuses the host, but run collapses every failure to unresolved and says MIRROR_UNRESOLVED. The issue is probably exactly that case, so the recorded error would mislead. Keep the vetted error's message and record that.
  2. populateEmpty ignores the follow mode. A tell-me fork is meant to be told, not changed, yet this writes the parent's tip into its default branch. Gate it on link.mode === "take-updates", and add a test that a tell-me fork stays unborn.
  3. Tests. The new unresolved-name test mutates the shared parent.json and only restores it if the assertions pass. Use try/finally, or a separate data dir like the first test. The empty-fork test never checks that the push event was emitted with followed, and nothing covers a fork that already has a branch staying untouched. Both are claimed behaviour. The as { ok: true ... } cast is also noise: assert ok, then read the value.
  4. Unrelated churn. Rewrapping the 'Remember the tip before the card' comment has nothing to do with this issue. Revert it, or let scripts/gate.ts --fix do it only if the gate demands it.

The pull's own note says the DNS failure was not reproduced. Say so in the pull and leave the issue open or linked rather than claiming a fix.

commented

Pushed the follow-up commit (a09708d9a). This change does not fix the DNS failure, and I did not reproduce it. The code never fetched the child's own parent by a resolved name. Now it does, as a proposal push does. I'd leave issue #13716 open or linked, not closed.

What changed (src/spawn/upstream.ts)

  • The parent fetch now resolves and vets the parent's name before running git. It pins git to the answer or sends it through the cell's gate.
  • It records the vetting error's own message. A host the gate refuses now shows the refusal text, not "could not be resolved". An unresolvable name still shows the unresolved text.
  • populateEmpty runs only when link.mode === "take-updates". A tell-me fork with no branch stays unborn.
  • I reverted the rewrap of the "Remember the tip before the card" comment. scripts/gate.ts only notes the long line and does not require the rewrap.

Tests (test/spawn-upstream.test.ts)

  • The unresolved-name test restores parent.json in a finally.
  • The empty take-updates fork now checks the new branch tip and that exactly one push event was emitted with followed: "root/forge".
  • A new test shows a tell-me fork with no branch stays unborn.
  • A new test shows a fork that already has a branch is left alone: populateEmpty returns false, the ref doesn't move, and no event is emitted. This calls populateEmpty directly. A take-updates fork with a branch is moved by takeFromParent, which is intended and outside this change.
  • The as { ok: true … } cast is gone: the tests assert ok, then read the value.
  • A shared helper builds the second app and its fork.

bun x tsc --noEmit is clean. bun test test/spawn-upstream.test.ts passes (9 tests). I did not run the full suite, since the forge's check does that on push.

Not done

  • No page changes, so the preview shows nothing of this. Try it with bun test test/spawn-upstream.test.ts.
  • I did not reproduce the DNS failure inside a real child cell.
Changes requested — before the latest push

The change is sound. The earlier points are fixed: refusal text is kept, populate is gated on take-updates, and the tests are tightened. One miss remains. The change adds a refused-host path (refusal takes vetted.error.message, so MIRROR_REFUSED is recorded) with no test. The only vetting test covers the unresolved name. Add a test where the parent host is refused, for example a parent whose name resolves to a private address and is not trusted. It should assert the recorded error contains the refusal text and that behind and parentTip keep their earlier values. Without it, collapsing every failure back to 'unresolved' would pass. Also keep the pull description clear that the DNS failure is not reproduced and that #13716 stays open. The preview shows nothing of this change, as expected: it adds no page, and no docs or TUI are needed.

commented

A child forge now vets its parent's host itself before fetching it, the same way a proposal push does. Git is then pinned to that answer, or sent through the cell's gate. The fetch therefore no longer relies on git looking up the name inside the child. I have not reproduced the DNS failure from #13716 inside a real child cell, so this does not claim to fix it. #13716 should stay open, linked to this pull.

What changed, in src/spawn/upstream.ts:

  • Vetting the parent: the parent's hostname is trusted by name only, never by address. When vetting fails, the vetting step's own message is recorded as the error. A refused host says it was refused, and a name that doesn't resolve says it could not be resolved. The earlier behind and parentTip values are kept either way.
  • Empty forks: a take-updates fork with no branch takes the parent's tip as its default branch on the first successful fetch. It also emits a push event marked followed. A tell-me fork is never changed, and a fork that already has a branch is not touched here.

Tests in test/spawn-upstream.test.ts:

  • An empty take-updates fork gets a branch, and exactly one push event with followed: "root/forge" is emitted.
  • A tell-me fork with no branch stays unborn.
  • A fork that already has a branch is not moved and emits nothing.
  • A parent name that doesn't resolve is recorded as "could not be resolved". The test puts parent.json back in a finally.
  • A refused parent host is recorded as refused, and the earlier behind and parentTip are kept.

- This test uses https://10.0.0.1, because the test preload exempts loopback from refusal. - It fails if every failure is reported as "could not be resolved"; I checked that by making the code do so.

bun x tsc --noEmit is clean, bun test test/spawn-upstream.test.ts passes (10 tests), and scripts/gate.ts raises nothing to fix. The gate notes one comment line over 100 columns; it was already on main, and the gate leaves it to the nightly rewrap. The full suite was not run here; the forge's check runs it on this push. No page, docs or terminal screen changes, so the preview shows nothing new; try it with bun test test/spawn-upstream.test.ts.

🤖 Generated with Claude Code

Approved

Earlier asks: the refused-host test is now there (test/spawn-upstream.test.ts, 10.0.0.1 case). It asserts the refusal text, that it is not reported as unresolved, and that behind and parentTip are kept. Populate is gated on take-updates, the refusal message is recorded, and the tests restore parent.json in finally. All met. There is no page, docs or TUI change, so the preview has nothing to show, which is expected. The security floor is kept: the parent host is vetted before git runs, and no secret or shell text is built from user input. Two things I would do next. Non-blocking: 1) keep #13716 open, because the DNS failure is not reproduced. 2) Make spawn say why a fork came out empty, so the owner does not wait up to an hour for the first fetch to repair it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs