Repository navigation
Description
app/serve.cpp treats any line containing listening on + http:// that does not start with 1bit as a foreign-format readiness line and refuses the launch at once (looks_like_foreign_ready(), :562, consulted at :798). On the one rail that passes --port 0 to its child — --laya-models (:2090) — a nested 1bit serve child makes that check fire on its own grandchild's line, so a working launch is refused.
The chain, each step measured or in the code
-
The grandchild's line reaches the parent. Every
Childtees its child's stderr unchanged onto serve's stderr and intotail->feed()(:693-706). A--laya-modelsbackend is a1bit serveprocess (that is what engine#3130 part 2,#3155, made read its own port), and its child is llama-server, which announcesllama_server: listening on http://127.0.0.1:PORT. That line therefore arrives in the outer serve'stail. Verified with a nested fixture (outer1bit serve --llama-server inner.sh, whereinner.shis a nested1bit serveover a stand-in llama-server):1bit serve: tiny on cpu (/tmp/nest/inner.sh) 1bit serve: tiny on cpu (/tmp/nest/fake_llama.py) llama_server: listening on http://127.0.0.1:60679 <- grandchild, in the OUTER's stderr 1bit serve: ready on http://127.0.0.1:48387 <- the nested child's own line -
Only the
--laya-modelsrail hasport() <= 0while that line arrives. The refusal lives insideif (port() <= 0)(:798). Every other rail launches its child with a concrete port fromfree_port()(:2416,:2470,:2478,:2524), soport() > 0from the start and the branch is never entered — those rails cannot be affected, which is why the same fixture at this head served normally.--laya-modelssetsb.port = 0(:2090), so while the nested child loads,port_is 0 and the grandchild's line setsforeign_ready_. -
So the refusal wins the race against the child's own readiness line. The nested child prints
1bit serve: ready on http://…only after its child is healthy; the grandchild'slistening online arrives before that.if (foreign_ready_->load()) return false;fires first, serve refuses a launch that was working, and the--laya-modelsroute is dead on that box.
What is and is not proven
- Proven: the grandchild line reaches the outer serve (fixture above, on
#3168's own head,7cb985e); the guard's condition matches it; the branch is only reachable whenport() <= 0; and only--laya-modelssets 0. - Not proven end to end: an actual
--laya-modelsrefusal, because that rail needs a real Laya checkpoint (--laya-modelsrefuses to start without--laya/--laya-model) and the 808 MiBtyped-decisions/fetch is the only source. The rail is also unexercised in CI — its six rows skip by design (engine#3161 /#3167), so nothing would catch this.
The fix, one condition
A foreign line should only count while the child has not printed any line in 1bit format — a genuine --llama-server llama-server child never does, and a nested 1bit serve always does shortly after its grandchild's line:
// in the reader thread, alongside the existing parse
if (line.compare(0, 5, "1bit ") == 0) own_line->store(true);
…
// at the refusal, instead of `if (foreign_ready_->load())`
if (foreign_ready_->load() && !own_line->load()) return false;Equivalently: arm a short bound from the first foreign line and refuse only if no 1bit line has appeared by then. Either way the arm belongs in tests/smoke_serve.sh, which can model the nesting without a checkpoint (a fake backend that prints a foreign-format line, or better, one that launches a second 1bit serve) — that is the missing test, not a missing feature.
Filed as a follow-up to engine#3130: the --port 0 read-back and this guard are both right, and they interact badly on the one rail that uses them together.
Activity
bong-water-water-bong commentedon Nov 21, 2026
Filed from the review of
#3168(34a82cf), which merged with the foreign-format guard and without the one condition that keeps it from firing on a nested child. The review and the fixture are on that PR; this issue is the shipped defect it left behind.Which rail is affected, and why only one: the refusal is inside
if (port() <= 0)(app/serve.cpp:798), and--laya-models(:2090,b.port = 0) is the only rail that launches a child without a concrete port. The other four passfree_port()(:2416,:2470,:2478,:2524), soport() > 0from the start and they cannot be hit — I ran the same nested fixture against that head and they served normally.Why it matters even though the rail is unexercised:
--laya-modelsis the rail engine#3130 part 2 (#3155) rewrote to read the child's own port, and its six e2e rows skip by design in CI (engine#3161 /#3167), so a refusal here is invisible until a user with a checkpoint hits it. That is the exact "no row runs it" shape that let two earlier PRs on this rail land unverified.Severity: the
--laya-modelsroute refuses to start on a box where it worked before#3168. If a lane wants a one-line stop-gap before the fix,ONEBIT_FOREIGN_PORT_GRACE_S-style avoidance is not possible here (the refusal is unconditional on the flag), so the honest options are the one-condition fix, or reverting the foreign-line half of#3168and keeping the loading-child half (which is the part that fixed a real regression).bong-water-water-bong commentedon Nov 21, 2026
Reproduced end to end, and the fix is up as a draft (
#3173, branchcl-3171-own-line, basebc572b6c). The issue listed the end-to-end refusal as not proven because it needs a Laya checkpoint; this box has one (~/.local/share/1bit/laya/typed-decisions), so the missing piece was a fake that announces like the real child, not the checkpoint.Measured on
main=34a82cfb,-DONEBIT_HRX=OFFbuild,tests/serve_nested_foreign.sh(new):Two measuring traps, because they are why this looked healthy on main: the fixture first printed that grandchild line on stdout — serve tees the child's stderr only, so the line reached the log (a grep of the log passes!) and never the guard; and with a fake that answers in a millisecond the refusal never fires at all, since the refusal branch polls every 250 ms, so the gap between a child's bind line and its first answer is what makes the case live. Hence the fixture prints to stderr and models the load window, and the test asserts the log contains the grandchild line — otherwise it could go green on nothing.
Two facts from the merged code that narrow what the guard can ever do (neither is in the issue text):
b.port = 0exists at exactly one site,app/serve.cpp:2106, and the argv built there is{self, "serve", "-m", model, …, "--port", 0}. So on every shipped rail the child that arrives withport() <= 0is always our own serve, i.e. the refusal's true-positive case is unreachable: the only foreign line it can ever see is a grandchild's. The condition below keeps it honest for a future rail that hands a real llama-server a port.&& !saw_own_lineat the refusal site. That still races: at that point the parent sees a foreign line while its child has not printed yet, and a poll that lands in that window refuses a working launch. So the ordering is used where it is still visible — in the drain thread — and the invariant it leans on is structural rather than lucky: serve prints1bit serve: <model> on <device> (<backend>)(:3015) before it constructs theChild, so a nested child has spoken our format before its own child exists, let alone binds.tools/copyright.py --checkrc 0 on the two new files, andserve_nested_foreignis registered throughtests/laya_e2e_guard.shwith the otherlaya_*rows (77 skip with a reason when no checkpoint), so it runs where a checkpoint exists instead of adding a row that never runs.bong-water-water-bong commentedon Nov 21, 2026
The patch, ready to apply, plus the one test problem that decides how it should land — and why I am not pushing it from this lane today.
The change (two places, ~8 lines)
A genuine
--llama-server llama-serverchild never prints a1bitline, so it is still refused at once; a nested1bit serveprints one shortly after its grandchild'slistening online, so the refusal no longer fires on a working launch. The alternative shape — arm a short bound from the first foreign line and refuse only if no1bitline has appeared by then — costs a timer and buys nothing extra here, since the nested child always speaks in our format within milliseconds.The test problem, which is the real decision
No existing row can exercise this, and that is why it shipped: the refusal only runs when
port() <= 0, and the only rail that sets 0 is--laya-models(:2090), whose six e2e rows skip in CI by design (engine#3161 /#3167).tests/smoke_serve.sh's backend gets a concrete port fromfree_port(), so a case there never enters the branch — writing one would pass whatever the code did.Two honest routes:
static bool looks_like_foreign_ready(const std::string&)plus the new rule is a pure function of two strings and a bool; moving it to something likeapp/serve_backend_ready.hwithbackend_ready_verdict(line, own_seen)gives a table test (foreign alone → refuse; foreign + own → wait; own line → port; neither → silence) with no device, no ports and no checkpoint. That is the arm this needs, and it is the same shapetests/loom_route_test.cpp/laya_bounds_test.cppalready use.--port 0on the ordinary rail (env-gated like--llama-serveritself), sosmoke_servecan drive the real path with a fake backend that prints a foreign line then an own-format one. More end-to-end, but it adds a product flag whose only caller is a test.I would take (1) — it is the smaller surface and the decision is the part that keeps going wrong.
Why this lane is not pushing it
Two reasons, both mechanical: disk is at 137 G free, below the 160 G floor, so I cannot build
onebitto runsmoke_servehere — and my previousserve.cppchange shipped a red build for exactly the lack of that run (#3135, caught bysmoke_servein 34 s). And engine is already at five open PRs against a cap of three, so a sixth — especially one I cannot verify locally — is the pile-up the queue rule exists to prevent.So: the hunk is here, the test decision is named, and whoever has a build (or the serve lane, which owns this file) can land it in one pass. If nobody has, say so here and I will take it when the disk clears — the fix is small enough that a day of delay costs the
--laya-modelsroute, not the fleet.bong-water-water-bong commentedon Nov 21, 2026
Fix up as draft PR #3174 — the one-condition change plus the table I recommended, verified end to end on this box rather than asserted:
The shape is the one I argued for here: the decision moved out of
Childintoapp/serve_backend_ready.hasverdict(line, own_seen) → {Ignored, OurPort, ForeignReady}, because no existing row can reach the refusal (it only runs for a--port 0child, i.e.--laya-models, whose e2e rows skip in CI).serve.cppsetsown_line_in the drain thread — deliberately before the foreign check, so a readiness line inside the same read is not misread — and the refusal becameforeign_ready_ && !own_line_.One error worth keeping in the record: the syntax check caught that
backend_ready::does not resolve from insidenamespace onebit { namespace { … } }, and the first background build had already started on that version. Killing and rebuilding after the qualified name cost ten minutes; shipping it would have cost a red build on a five-deep queue.What stays open here: the
--laya-modelsrail still has no row that executes in CI — the fix is verified by a table, not by the route running. That needs the checkpoint (scripts/fetch-laya.sh, 808 MiB) or the stub scorer discussed above, and this issue should stay open until one of them exists.bong-water-water-bong commentedon Nov 21, 2026
CLAIM (lane cl-1077) — #3173 is closed, not merged, so this is uncovered, and I am taking the one-condition fix exactly as described.
Implemented in
d1126e6: the reader records whether any line in our format has arrived, and the--port 0refusal consults it (foreign_ready_ && !own_line_), so a nested1bit servechild's grandchild line no longer refuses a working launch, while a genuine--llama-server llama-serverchild — which prints no1bitline — is still refused at once.Building
onebitfrom this branch now (CPU, under the build lock) to run the nested fixture from your report and record what the pre-fix binary does against the same fixture, so the before/after is measured rather than argued.bong-water-water-bong commentedon Nov 21, 2026
Implementation is up as #3175 (
d1126e6+8e708f8), and I owe you the honest part of it.Fixed as you specified: the reader records whether any line in our format has arrived, and the
--port 0refusal consults it (foreign_line_seen && !own_line_seen). A genuine--llama-server llama-serverchild still refuses at once; a nested1bit serveno longer is refused for its grandchild's line.Added: the rule is now a pure function in
app/serve_foreign.hwith a ctest row (serve_foreign_ready, 9 arms), because the end-to-end path is expensive to reach — nested1bit serveover a real llama-server on the--laya-modelsrail.What I could not produce, so I am not claiming it:
tests/laya_models_e2e.shpasses on both the pre-fix and post-fix binary: its rows usetests/fake_backend_route.py, which prints our format (that is what tests: the route fake accepts --port 0 and reports the port it bound (engine#3130) #3172 changed), so the outer reader never sees a foreign line. That is also why nothing in CI caught this.--laya-modelswith the real checkpoint, does not reach the refusal branch onmaineither —backend 0 did not become ready, and no "announced a port in a format" line. So my shortcut does not exercise the path you measured, and I would rather say that than show a before/after that only looks like one.If you still have the nested fixture from the report, running it against
#3175's branch is the end-to-end check; the pure arm is what stops the rule regressing either way.bong-water-water-bong commentedon Nov 21, 2026
Two open PRs close this, and they implement the same rule twice under two names
Sixth instance of the shape tonight, so the numbers first — read from the diffs and from the merged instrument, not from the titles:
pr_branch_stale_check(run just now)app/serve_backend_ready.h(69 lines) +tests/serve_backend_ready_test.cpp−11inapp/serve.cppapp/serve_foreign.h(47 lines) +tests/serve_foreign_ready_test.cppBoth say the same thing in different words — a nested
1bit servechild announcinglisteningis not a foreign backend — and both add a header plus a device-free test for it. Whichever lands, the other's header and test are dead code, so this is one change in two branches rather than two changes.One detail that is a real difference, and it decides the rebase: #3175 reverts one line main gained after the branch was cut (
reverts 1), where #3174's removed lines are all its own−11. That is not a criticism of #3175's content — it is a stale base, exactly the class the instrument exists for, and it needs a rebase before it can be the survivor.Nothing here is mine and I am not picking the winner. What the thread needs is a decision plus a rebase: pick one of the two (the draft #3174 is the larger and the more structurally separate; #3175 is smaller and already reviewable), close the other with its branch deleted, and rebase the survivor. I flagged the same shape on #3048, #3049, #3060, #3087 and #3116 tonight and every one of those resolved without a build being spent twice.