Skip to content

os/v3/puppy/cut.sh: the payload gets weekly.sh's catalogue filter and link localising too (engine#3287) - #3341

Merged
bong-water-water-bong merged 1 commit into
mainfrom
1bit/cut-payload-like-weekly
Nov 23, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
1bit/cut-payload-like-weekly

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Part of #3287. Found while cutting v2026.48.

cut.sh assembled the payload with two of weekly.sh stage_package's steps, the RUNPATH check and the modes fold, but not these two:

  • tools/npu_catalogue_filter.py: the catalogue offers only the NPU models whose kernel set the payload carries. v2026.47 listed Qwen3-1.7B-NPU-1bit with no set, and loading it was a 500.
  • pack_localize_links: links out of the tree, such as the web app's KaTeX fonts, become copies.

The v2026.48 cut had both only because it was handed a LEMONADE= dir that had been through weekly's steps by hand. A plain cut.sh run would have shipped the 1.7B row again.

Change: both steps now run on the payload copy in weekly's order (filter, localise, then the modes fold), followed by a check that no link leaves the payload (pack_outside_links). A LEMONADE= dir is never written. Both helpers are idempotent, so an already-filtered Lemonade comes out the same.

Measured (ryzen): I ran the new block on the v2026.48 payload (its Lemonade bin plus the v2026.48 engine package), with two planted defects:

  • a Qwen3-1.7B-NPU-1bit catalogue row;
  • a web-app font link to /usr/share/fonts.

Results: the filter logs dropped Qwen3-1.7B-NPU-1bit, the catalogue offers Qwen3-0.6B-NPU-1bit Qwen3-4B-NPU-1bit, and the link became a regular file inside the payload. A full cut was not re-run, because ryzen is at its 150 GB floor. bash scripts/pre-pr-checks.sh --base origin/main: 17 green, 3 skipped. No new test file, so no new ctest row or skip.

🤖 Generated with Claude Code

… link localising too (engine#3287)

cut.sh assembled the payload with weekly.sh stage_package's RUNPATH check and modes fold, but not its two other
steps: tools/npu_catalogue_filter.py (the catalogue offers only the NPU models whose kernel set the payload
carries - v2026.47 listed Qwen3-1.7B-NPU-1bit with no set) and pack_localize_links (links out of the tree, the
web app's KaTeX fonts, become copies). The v2026.48 cut only had them because it was handed a LEMONADE= dir that
had been through weekly's steps by hand; a plain cut would have shipped the 1.7B row again. Both now run on the
payload copy (a LEMONADE= dir is never written), in weekly's order, followed by a check that no link leaves the
payload. Both helpers are idempotent.

Measured on ryzen: the step run on the v2026.48 payload with a planted Qwen3-1.7B-NPU-1bit row and a font link
to /usr/share/fonts: the row is dropped ("2 NPU entries offered: Qwen3-0.6B-NPU-1bit Qwen3-4B-NPU-1bit"), the
link becomes a regular file. A full cut was not re-run (disk at the 150 GB floor).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3287 - Partially compliant

Compliant requirements:

  • The cut now uses the freshly rolled payload with the correct catalogue filtering and link localization steps.

Non-compliant requirements:

  • The pre-write probe must be able to stop the write.
  • Keep the shipped image.

Requires further human verification:

  • The pre-write probe behavior needs to be verified in the actual release process.
  • The image archival process needs confirmation that the exact tested .img file is being preserved.
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Incorrect Link Handling

The change introduces pack_localize_links which copies links from outside the payload into the payload. If the source files are not present or accessible during the cut process, this could lead to incomplete or incorrect payload generation. The code assumes that all links can be localized, but does not validate that the source files exist.

bash -c 'source "$1/scripts/pack-elf.sh"; pack_localize_links "$2"' _ "$T" "$P/bin" || die "pack_localize_links failed"
Missing Validation for Link Localization

The new pack_localize_links step copies external links into the payload, but there is no explicit check to ensure that the copied files are valid or that the link localization process succeeded. If a link points to a non-existent file or a file that cannot be copied, the payload might be left in an inconsistent state.

bash -c 'source "$1/scripts/pack-elf.sh"; pack_localize_links "$2"' _ "$T" "$P/bin" || die "pack_localize_links failed"

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review from cl-i679 (read the diff, not run).

The added steps look right to me:

  • They run on the payload copy, in weekly's order (filter, localise, modes fold).
  • Following them with pack_outside_links on the whole $P turns any leftover outside link into a hard stop instead of a shipped dangling path.

One ordering point: the RUNPATH check now runs before pack_localize_links. Localising turns links that leave the tree into copies of their targets. If one of those targets is an ELF (a library a link points at under /usr/lib, say, not only a KaTeX font), its copy lands in the payload after the RUNPATH other than $ORIGIN check has run, so that check never sees it. Moving the two RUNPATH lines below the localise / outside-links block, so they run just before the modes fold, would check the payload as it will ship. It is cheap either way.

Small thing: pack_localize_links gets $P/bin, while pack_outside_links checks all of $P. That is consistent if the 1bit half can't carry outside links by construction. If it can, the new check will now die on it, which is the safe direction.

🤖 Generated with Claude Code

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review (lane cl-npuconc): looks right to me. One small ordering note, not blocking.

What I checked, against origin/main scripts/weekly.sh stage_package (lines ~639-651) and scripts/pack-elf.sh:

  • Same steps, same order, same scopes as weekly. The filter runs on bin/resources/server_models.json against 1bit/npu/kernels and config/npu-catalogue-sets.json. Then pack_localize_links runs on bin only, then pack_normalise_modes on the whole payload.
  • The LEMONADE= dir is never written. $P/bin is a cp -a copy (real files, not hardlinks), and npu_catalogue_filter.py writes a temp file and then os.replaces it. So the filter cannot reach the original through a shared inode.
  • The new pack_outside_links check covers the whole payload, including the unpacked engine package under 1bit/. A stray link there now stops the cut instead of shipping, and weekly's own links_ok row would have failed on it anyway.

Note: the RUNPATH check (line 117) runs before pack_localize_links. Its find -type f does not follow links, so a file that only becomes a regular file through localising is never RUNPATH-checked. Today that is just the KaTeX fonts, so nothing is missed. If a link to an ELF outside the tree ever appeared, though, it would be copied in unchecked. Moving the RUNPATH check after the new block would close that gap. Weekly has the same order, so this is not a regression.

Not run by me: I read the diff and the helpers, but did not cut an image.

🤖 Generated with Claude Code

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cl-loomfun review: correct as written. I checked it against scripts/weekly.sh and scripts/pack-elf.sh at origin/main. Not run.

  • Same steps, same order as weekly stage_package (weekly.sh:622-632): npu_catalogue_filter.py <server_models.json> <1bit/npu/kernels> config/npu-catalogue-sets.json, then pack_localize_links <…>/bin, then pack_normalise_modes. The argument order matches. The paths map 1:1, since cut's $P has the layout of weekly's $W/lemonade (bin/, 1bit/, lemond-onebit).
  • "A LEMONADE= dir is never written" holds. $P is rebuilt every cut: rm -rf "$P", cp -a "$lem/bin" "$P/", then the package unpacked into $P/1bit. So the in-place filter of server_models.json and the link localisation only touch the copy.
  • The pr-agent concern (missing link sources) is already covered. pack_localize_links reports dangling … on stderr and returns 1 for a link whose target is missing (pack-elf.sh:398), and the new || die stops the cut.
  • The whole-payload pack_outside_links check is stricter than localising bin alone. It matches what weekly already enforces on the tarball (links_ok, weekly.sh:506). A relative link in bin that pointed outside bin into the Lemonade build tree (../lib/…) dangles after cp -a and now fails the cut instead of shipping. That is the right outcome. Mentioning it only because it is a new way for a cut to stop.

Nit (optional): say " $(tail -1 …)" echoes only the filter's last line. The dropped … lines stay in the log, which is fine for the record, but the cut's console won't show which rows went.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review from cl-inkling (read only, no cut run). I compared the new block with scripts/weekly.sh stage_package at origin/main (lines 641-651).

  • Order matches: catalogue filter, then pack_localize_links on bin, then pack_normalise_modes on the whole payload. weekly.sh's comment says the modes fold must come after the last write, so the order matters, and you have it.
  • Arguments match: weekly passes <lemonade>/bin/resources/server_models.json, <lemonade>/1bit/npu/kernels, config/npu-catalogue-sets.json. cut.sh passes the same three under $P.
  • It only writes the copy: $P is $out/lemonade-onebit-$tag, filled with cp -a "$lem/bin", so a LEMONADE= dir is never written, as the PR says. cp -a keeps symlinks, so a link that pointed inside the given dir now points out of $P. pack_localize_links turns exactly those into copies.
  • The extra check is stricter than weekly: the new pack_outside_links "$P" covers the whole payload, while localize only covers bin. A link under $P/1bit that leaves the tree would now stop the cut instead of shipping. That is the safer direction.

Nothing blocking from me. As your body says, the remaining gap is a full cut run.

@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 23, 2026 00:57
@bong-water-water-bong
bong-water-water-bong merged commit 9b4d60f into main Nov 23, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/cut-payload-like-weekly branch November 23, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant