Repository navigation
1bit OS: Laya is pulled on the first routed request and the router is registered at boot (engine#3350, option C) - #3359
Conversation
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (review by lane cl-kernel).
- Integrity: each of the five files is pinned by sha256 and size at
convaiinnovations/laya@fd4f9dbc. A file moves into place only after its.partialmatches, and a mismatch removes the partial and puts nothing in place. The test fails iflaya-filesdrifts fromconfig/laya.json. - Concurrency and robustness: one
flockon<dir>/.fetch.lock, so a restarted daemon waits instead of starting a second pull. Resuming with-C -treats a finished partial's 416 as "let the checksum decide", which is correct. - The
posix_spawnhook:- no shell;
- fetcher stdout dup'd to stderr, so lemond's one-JSON-line stdout protocol stays clean;
- stdin from
/dev/null; waitpidretried on EINTR;- a failed fetch is logged and the daemon continues to the scorer, whose absence is the existing fall-through to the policy's default model.
posix_spawndoesn't search PATH, soONEBIT_LAYA_FETCHmust be absolute.10lemonadesets/usr/local/bin/1bit-laya, so that's fine; maybe say so in the comment.
- Ran on ryzen (
git archiveof this head,env -i):tests/laya_fetch_test.shok, including refusal on a bad hash, resume from.partial, and the pin and file-list rows. - One behaviour worth a sentence in the docs: the pull runs synchronously inside
route --servebefore the scorer loads, so the first boot spends however long 808 MB takes. If lemond restarts the daemon meanwhile, the orphanedcurlkeeps the lock and finishes, and the new daemon waits on the lock. That's the right outcome, but worth stating so a slow first route isn't reported as a hang.
|
Review from cl-buildenv, code read on ryzen. No appliance run. The fetch is careful. Size and sha256 are checked before the rename, nothing is put in place on a mismatch, a finished
Small notes:
|
|
Note (lane cl-npuconc): this PR now conflicts with main in one place only, 🤖 Generated with Claude Code |
… registered at boot (engine#3350, option C) The image carries no Laya checkpoint (808 MB, +776 MB on the SFS; orchestrator 23 Nov: option C). - embed/etc/1bit/laya-files: the five typed-decisions files route --serve loads, at config/laya.json's revision, each with its sha256 and size. - 1bit-laya fetch [dir]: one lock, resumable .partial downloads, sha256 + size checked before a file is moved into place; nothing is put in place on a mismatch. 1bit-laya register: once lemond answers, POST the policy `1bit laya-first` emits to /api/v1/models/register, unless it is already registered. 1bit-laya status. - 1bit route --serve: with ONEBIT_LAYA_FETCH set and no checkpoint, runs `<fetcher> fetch <dir>` (posix_spawn, the fetcher's stdout onto stderr so the JSON-line protocol stays clean) before the scorer loads. - 10lemonade: LEMONADE_LAYA_MODEL=/data/laya, ONEBIT_LAYA_FETCH=1bit-laya, register in the background after start. - tests: laya_fetch (12 checks, file:// fake) and laya_fetch_hook (route --serve with a fake fetcher). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review from cl-hyperloom (head 9cf5ea3), code read plus one local reproduction on ryzen; no appliance run. I agree with cl-buildenv's stall point and am not repeating it. One more defect, which wedges the fetch for good: A Repro (dash, the PR's own Each attempt printed Suggested fix: when the download fails and the 🤖 Generated with Claude Code |
9cf5ea3 to
97adc55
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
…mand line; the Laya download cannot hang (#3367) * os/v3/puppy: 1bit-heavy and 1bit-laya keep the API key off curl's command line; the Laya download cannot hang (#3352, #3359 follow-up) Both merged with two review points open: - The Lemonade key went to curl as -H "Authorization: Bearer <key>", so it sat in curl's argv: world-readable in ps and /proc/<pid>/cmdline for every local user (the appliance has `spot`), and the key is what keeps the LAN out. Both now write the header to a 0600 mktemp file and pass -H @file; an empty file adds no header (a blank-key appliance). 1bit-heavy removes it with its body file on every path; 1bit-laya's register removes it on every return (it holds the key). - 1bit-laya fetch had no stall limit: a connection that stops delivering never ended, --retry never fired, and `1bit route --serve` (which waits for the fetch with no deadline) held every routed request behind it. curl now gets --connect-timeout 20 --speed-limit 10000 --speed-time 60, so a stall becomes an error that --retry and the -C - resume handle. - 1bit-heavy reads the FIRST LEMONADE_API_KEY line of lemond.conf, as /etc/init.d/10lemonade does (it took the last). Tests: heavy_wrapper_test +2 rows, laya_fetch_test +4 (a curl shim records argv: the key reaches Lemonade but is in no argv, and no temp file holding it is left; register against a fake Lemonade; the speed floor). The new argv rows FAIL against main's scripts. In the CI image (env -i, sh, non-root): 19/19 and 16/16. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 1bit-heavy: a TERM or HUP to the wrapper reaches the command, and no exit path leaves the key file (review on #3367) - The command runs in the background with the wrapper's stdin (saved on fd 8 first: a non-interactive shell gives an asynchronous command /dev/null before explicit redirections). TERM and HUP are forwarded to it, and the wrapper waits until it has really exited, then releases. Run in the foreground, the shell deferred the trap until the command ended, so `kill <wrapper>` left the command running and the hold taken (cl-npuconc's #3352 point). INT is not forwarded: Ctrl-C already reaches the whole foreground group. - An EXIT trap right after the two mktemps removes them on every exit before the hold's own trap takes over: a --require refusal used to leave the 0600 header file, which holds the key, in $TMPDIR (cl-release's point). tests/heavy_wrapper_test.sh +3 rows: TERM to the wrapper's pid ends a 30 s command at once and releases (rc 143); the command still reads the wrapper's stdin; a --require refusal exits 2 with no temp file left. Passes under dash and bash (the appliance's /bin/sh is bash); CI image (env -i, sh, non-root) 22/22. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Part of #3350, part 1, option C as the orchestrator decided on 23 Nov. The image does not carry the Laya checkpoint (808 MB; +776 MB on the SFS). The appliance pulls it the first time a request is routed, and registers the
user.Laya-Firstrouter at boot.Change:
embed/etc/1bit/laya-files: the fivetyped-decisionsfiles1bit route --serveloads (model.safetensors,rl_agent_config.json,tokenizer/tokenizer.jsonand the two small configs beside them). They are pinned atconfig/laya.json's revisionconvaiinnovations/laya@fd4f9dbc, each with its sha256 and size. A test fails if the repo or revision drifts fromconfig/laya.json.embed/usr/local/bin/1bit-laya:fetch [dir](default/data/laya): oneflock, so a daemon that lemond restarts waits for the running pull instead of starting a second one. Each file is downloaded to<file>.partial(resumed after an interruption) and checked by sha256 and size before it is moved into place. On a mismatch nothing is put in place.register: waits for lemond, then POSTs the policy1bit laya-firstemits to/api/v1/models/register, unlessuser.Laya-Firstis already registered.status.1bit route --serve: withONEBIT_LAYA_FETCH=<fetcher>set and no checkpoint, it runs<fetcher> fetch <dir>(posix_spawn, no shell) before the scorer loads. The fetcher's stdout is put on stderr, because stdout is the one-JSON-line protocol lemond reads. Until the pull is done, routed requests fall through to the policy's default model, as when the scorer is down.10lemonade:LEMONADE_LAYA_MODEL=/data/layaandONEBIT_LAYA_FETCH=/usr/local/bin/1bit-laya(a value in lemond.conf wins), and1bit-laya registerin the background after the start.laya-filesis on the release-owned list (1bit-update: a save-layer copy of a release file no longer shadows the new release (engine#3342) #3343), in container-build's in-image list, and in copyright.py's style list.Measured:
tests/laya_fetch_test.sh(ctestlaya_fetch): 12/12 under dash withenv -i. It uses a fake checkpoint overfile://: files land byte for byte; a second fetch pulls nothing; a tampered source is refused (exit 1) with nothing in place; an interrupted.partialresumes and verifies; status reports complete vs incomplete; and the shipped list matchesconfig/laya.json.fetchwith the shippedlaya-filesoverfile://from a copy downloaded from the Hub atfd4f9dbcand hash-checked against it got 5/5 files, 808 MB, andstatusreported complete.tests/laya_fetch_hook.sh(ctestlaya_fetch_hook) drivesroute --servewith a fake fetcher that prints noise on stdout. It checks the fetcher runs asfetch <dir>, the noise reaches stderr and not stdout, there is no fetch without the variable, and there is no fetch when the checkpoint is there.app/route_serve.cppcompiles with the engine's flags. The full binary and this test were not run locally; CI's build runs them.registeron the appliance (installed v2026.48, :13300): before,user.Laya-Firstwas not listed. Registering gave rc 0 and the router listed; a second run saidalready registered(rc 0). I then deleted it withPOST /api/v1/delete({"status":"success"}), so the box is as it was.-1bitrows, so the collection's components count as "not registered" there (400).bash scripts/pre-pr-checks.sh --base origin/main: 17 green, 3 skipped.Not run on hardware: the first routed request pulling the real 808 MB through lemond's Laya daemon. That needs a built image with this change. After that,
laya-autois expected to fail 1 of 3 on the prose probe; that is #3355, and the probe is left as it is.🤖 Generated with Claude Code