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
Check · Review · Land · Live done — Landed and live in production.
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.
shipped production is serving it deploy 59903fa
2 earlier comments · 2 events
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). Apushevent is emitted withfollowedset. Before this,HEAD..refs/upstream/HEADfailed on an unborn branch,behindstayed 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.shat 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 isstartUpstreamWatch'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.
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.
- A refused host is reported as unresolved.
vettedEnvreturns MIRROR_REFUSED when the gate refuses the host, butruncollapses every failure tounresolvedand 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. populateEmptyignores the follow mode. Atell-mefork is meant to be told, not changed, yet this writes the parent's tip into its default branch. Gate it onlink.mode === "take-updates", and add a test that a tell-me fork stays unborn.- 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
pushevent was emitted withfollowed, and nothing covers a fork that already has a branch staying untouched. Both are claimed behaviour. Theas { ok: true ... }cast is also noise: assert ok, then read the value. - 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 --fixdo 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.
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.
populateEmptyruns only whenlink.mode === "take-updates". Atell-mefork with no branch stays unborn.- I reverted the rewrap of the "Remember the tip before the card" comment.
scripts/gate.tsonly notes the long line and does not require the rewrap.
Tests (test/spawn-upstream.test.ts)
- The unresolved-name test restores
parent.jsonin afinally. - The empty
take-updatesfork now checks the new branch tip and that exactly onepushevent was emitted withfollowed: "root/forge". - A new test shows a
tell-mefork with no branch stays unborn. - A new test shows a fork that already has a branch is left alone:
populateEmptyreturns false, the ref doesn't move, and no event is emitted. This callspopulateEmptydirectly. Atake-updatesfork with a branch is moved bytakeFromParent, which is intended and outside this change. - The
as { ok: true … }cast is gone: the tests assertok, 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.
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.
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
behindandparentTipvalues are kept either way. - Empty forks: a
take-updatesfork with no branch takes the parent's tip as its default branch on the first successful fetch. It also emits apushevent markedfollowed. Atell-mefork 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-updatesfork gets a branch, and exactly onepushevent withfollowed: "root/forge"is emitted. - A
tell-mefork 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.jsonback in afinally. - A refused parent host is recorded as refused, and the earlier
behindandparentTipare 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
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.
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
tscis clean. I did not run the rest of the suite.scripts/fast.tssaid the diff was too broad to name tests, and the forge's check will run them on push.What changed (
src/spawn/upstream.ts)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.populateEmpty). Apushevent is emitted withfollowedset. Before this,HEAD..refs/upstream/HEADfailed on an unborn branch,behindstayed null, and "take updates" never ran. The fork is never moved if it already has a branch.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
forge.open-platform.shat 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.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 isstartUpstreamWatch's.Try it: on a child forge with an empty
<org>/forge, open/<org>/forge/followingorGET /api/v1/repos/<org>/forge/followingafter the next upstream check.upstream.parentTipshould be filled anderrorempty.Closes #13716