Add builds (2026-11-13)
Browse files- catalog/builds.jsonl +0 -0
- catalog/builds.parquet +2 -2
- tools/SHA256SUMS.txt +1 -1
- tools/lbc.py +130 -1
catalog/builds.jsonl
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
catalog/builds.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dcfb4576b48df1e4596bf37b8a2fb54e6e9e49fab91a3d76913f56d80ceffd64
|
| 3 |
+
size 40965
|
tools/SHA256SUMS.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
ffd81f779abce314c6d31cc485ca6c2fd657867a120eed68d567d494a8ccf04c lbc.py
|
tools/lbc.py
CHANGED
|
@@ -574,6 +574,134 @@ def cmd_unpack(a):
|
|
| 574 |
print(f"unpacked {seen} files from {used} of {len(man['shards'])} shards into {dest} (all sha256 verified)")
|
| 575 |
|
| 576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
# ---------------------------------------------------------------- fetch from Hugging Face
|
| 578 |
|
| 579 |
def _resolve(url, token):
|
|
@@ -789,6 +917,7 @@ def main():
|
|
| 789 |
p.add_argument("--level", type=int, default=19); p.add_argument("--exclude-setup-json", action="store_true")
|
| 790 |
u = sp.add_parser("unpack"); u.add_argument("staging_dir"); u.add_argument("package_dir"); u.add_argument("--shards")
|
| 791 |
c = sp.add_parser("check"); c.add_argument("staging_dir")
|
|
|
|
| 792 |
r = sp.add_parser("reindex"); r.add_argument("staging_dir"); r.add_argument("package_dir")
|
| 793 |
d = sp.add_parser("pkgdir"); d.add_argument("project_dir"); d.add_argument("name")
|
| 794 |
li = sp.add_parser("license"); li.add_argument("package_dir")
|
|
@@ -796,7 +925,7 @@ def main():
|
|
| 796 |
f.add_argument("--package", action="append"); f.add_argument("--namespace", default="MoteMath")
|
| 797 |
f.add_argument("--dry-run", action="store_true"); f.add_argument("--check", action="store_true")
|
| 798 |
a = ap.parse_args()
|
| 799 |
-
{"key": cmd_key, "pack": cmd_pack, "unpack": cmd_unpack, "check": cmd_check, "fetch": cmd_fetch, "reindex": cmd_reindex, "license": cmd_license, "pkgdir": lambda a: print(package_dir(os.path.abspath(a.project_dir), a.name))}[a.cmd](a)
|
| 800 |
|
| 801 |
|
| 802 |
if __name__ == "__main__":
|
|
|
|
| 574 |
print(f"unpacked {seen} files from {used} of {len(man['shards'])} shards into {dest} (all sha256 verified)")
|
| 575 |
|
| 576 |
|
| 577 |
+
# ---------------------------------------------------------------- strip (2026-11-12)
|
| 578 |
+
|
| 579 |
+
STRIP_DEFAULT = r"^\.lake/build/bin/"
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
def cmd_strip(a):
|
| 583 |
+
"""Remove files matching --pattern (default: everything under .lake/build/bin/, i.e. the executables and their
|
| 584 |
+
response, trace and hash files) from a staged build folder, in place, without rebuilding.
|
| 585 |
+
Only the frames that hold such files are rewritten; every other frame keeps its bytes, so the other shards keep
|
| 586 |
+
their hashes. frames.jsonl offsets, index.jsonl, the manifest (shard hashes, sizes, file counts) and SHA256SUMS.txt
|
| 587 |
+
are updated, and the manifest records what was removed under "stripped". The build key does not change: it is
|
| 588 |
+
computed from the toolchain, platform and dependency closure, not from the contents.
|
| 589 |
+
User decision 2026-11-12: strip native executables from the public builds; libraries (.so, .a, .o) stay because
|
| 590 |
+
Lake needs them for the packages' own library targets."""
|
| 591 |
+
d = os.path.abspath(a.staging_dir)
|
| 592 |
+
pat = re.compile(a.pattern or STRIP_DEFAULT)
|
| 593 |
+
man, idx = load(d)
|
| 594 |
+
gone = sorted(p for p in idx if pat.search(p))
|
| 595 |
+
if not gone:
|
| 596 |
+
print(json.dumps({"stripped": 0})); return
|
| 597 |
+
gone_set = set(gone)
|
| 598 |
+
if "module_frames" not in man.get("features", []):
|
| 599 |
+
# legacy build (one zstd stream per shard, packed before 2026-11-09): rewrite each affected shard whole
|
| 600 |
+
removed_bytes = 0
|
| 601 |
+
for s in man["shards"]:
|
| 602 |
+
if not any(idx[p]["shard"] == s["name"] for p in gone):
|
| 603 |
+
continue
|
| 604 |
+
sp = os.path.join(d, s["name"])
|
| 605 |
+
if sha256_file(sp) != s["sha256"]:
|
| 606 |
+
raise SystemExit(f"shard hash mismatch before strip: {s['name']}")
|
| 607 |
+
raw = subprocess.run(["zstd", "-d", "-q", "-c", sp], capture_output=True, check=True).stdout
|
| 608 |
+
buf, n = io.BytesIO(), 0
|
| 609 |
+
with tarfile.open(fileobj=io.BytesIO(raw), mode="r:") as tf, \
|
| 610 |
+
tarfile.open(fileobj=buf, mode="w", format=tarfile.GNU_FORMAT) as tw:
|
| 611 |
+
for m in tf.getmembers():
|
| 612 |
+
if m.name in gone_set:
|
| 613 |
+
removed_bytes += m.size; continue
|
| 614 |
+
data = tf.extractfile(m).read() if m.isreg() else b""
|
| 615 |
+
tw.addfile(deterministic_info(m.name, len(data), bool(m.mode & 0o111)), io.BytesIO(data))
|
| 616 |
+
n += 1
|
| 617 |
+
comp = compress_frame(buf.getvalue(), man.get("zstd_level", 19))
|
| 618 |
+
with open(sp + ".lbc-tmp", "wb") as f:
|
| 619 |
+
f.write(comp)
|
| 620 |
+
os.replace(sp + ".lbc-tmp", sp)
|
| 621 |
+
s.update(sha256=hashlib.sha256(comp).hexdigest(), bytes=len(comp), files=n)
|
| 622 |
+
if "bytes_uncompressed" in s:
|
| 623 |
+
s["bytes_uncompressed"] = len(buf.getvalue())
|
| 624 |
+
new_frames = None
|
| 625 |
+
else:
|
| 626 |
+
new_frames, removed_bytes = _strip_frames(d, man, idx, gone, gone_set)
|
| 627 |
+
_strip_finish(d, man, idx, gone, gone_set, new_frames, removed_bytes, pat)
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
def _strip_frames(d, man, idx, gone, gone_set):
|
| 631 |
+
frames = load_frames(os.path.join(d, "shards", "frames.jsonl"))
|
| 632 |
+
by_shard = {}
|
| 633 |
+
for fr in frames:
|
| 634 |
+
by_shard.setdefault(fr["shard"], []).append(fr)
|
| 635 |
+
new_frames, removed_bytes = [], 0
|
| 636 |
+
for s in man["shards"]:
|
| 637 |
+
frs = sorted(by_shard.get(s["name"], []), key=lambda f: f["offset"])
|
| 638 |
+
if not any(idx[p]["shard"] == s["name"] for p in gone):
|
| 639 |
+
new_frames += frs; continue
|
| 640 |
+
sp = os.path.join(d, s["name"])
|
| 641 |
+
if sha256_file(sp) != s["sha256"]:
|
| 642 |
+
raise SystemExit(f"shard hash mismatch before strip: {s['name']}")
|
| 643 |
+
blob = open(sp, "rb").read()
|
| 644 |
+
out, off, h, raw_total, nfiles = io.BytesIO(), 0, hashlib.sha256(), 0, 0
|
| 645 |
+
for fr in frs:
|
| 646 |
+
comp = blob[fr["offset"]:fr["offset"] + fr["length"]]
|
| 647 |
+
if hashlib.sha256(comp).hexdigest() != fr["sha256"]:
|
| 648 |
+
raise SystemExit(f"frame hash mismatch: {fr['shard']} {fr['offset']}")
|
| 649 |
+
raw = decompress_frame(comp)
|
| 650 |
+
keep_n = fr["files"]
|
| 651 |
+
with tarfile.open(fileobj=io.BytesIO(raw), mode="r:") as tf:
|
| 652 |
+
members = tf.getmembers()
|
| 653 |
+
if any(m.name in gone_set for m in members):
|
| 654 |
+
buf = io.BytesIO()
|
| 655 |
+
with tarfile.open(fileobj=buf, mode="w", format=tarfile.GNU_FORMAT) as tw:
|
| 656 |
+
keep_n = 0
|
| 657 |
+
for m in members:
|
| 658 |
+
if m.name in gone_set:
|
| 659 |
+
removed_bytes += m.size; continue
|
| 660 |
+
data = tf.extractfile(m).read() if m.isreg() else b""
|
| 661 |
+
tw.addfile(deterministic_info(m.name, len(data), bool(m.mode & 0o111)), io.BytesIO(data))
|
| 662 |
+
keep_n += 1
|
| 663 |
+
raw = buf.getvalue()
|
| 664 |
+
comp = compress_frame(raw, man.get("zstd_level", 19)) if keep_n else b""
|
| 665 |
+
if not comp:
|
| 666 |
+
continue # a frame that held only stripped files disappears
|
| 667 |
+
out.write(comp); h.update(comp)
|
| 668 |
+
new_frames.append(dict(fr, offset=off, length=len(comp), raw_length=len(raw), files=keep_n,
|
| 669 |
+
sha256=hashlib.sha256(comp).hexdigest()))
|
| 670 |
+
off += len(comp); raw_total += len(raw); nfiles += keep_n
|
| 671 |
+
tmp = sp + ".lbc-tmp"
|
| 672 |
+
with open(tmp, "wb") as f:
|
| 673 |
+
f.write(out.getvalue())
|
| 674 |
+
os.replace(tmp, sp)
|
| 675 |
+
s.update(sha256=h.hexdigest(), bytes=off, bytes_uncompressed=raw_total, files=nfiles)
|
| 676 |
+
return new_frames, removed_bytes
|
| 677 |
+
|
| 678 |
+
|
| 679 |
+
def _strip_finish(d, man, idx, gone, gone_set, new_frames, removed_bytes, pat):
|
| 680 |
+
index = [e for p, e in idx.items() if p not in gone_set]
|
| 681 |
+
if new_frames is not None:
|
| 682 |
+
with open(os.path.join(d, "shards", "frames.jsonl"), "w", encoding="utf-8", newline="\n") as f:
|
| 683 |
+
for e in new_frames:
|
| 684 |
+
f.write(json.dumps(e, separators=(",", ":")) + "\n")
|
| 685 |
+
man["frames"] = len(new_frames)
|
| 686 |
+
with open(os.path.join(d, "shards", "index.jsonl"), "w", encoding="utf-8", newline="\n") as f:
|
| 687 |
+
for e in index:
|
| 688 |
+
f.write(json.dumps(e, separators=(",", ":")) + "\n")
|
| 689 |
+
man["files"] = len(index)
|
| 690 |
+
man["bytes_uncompressed"] = sum(e["bytes"] for e in index)
|
| 691 |
+
man["bytes_compressed"] = sum(s["bytes"] for s in man["shards"])
|
| 692 |
+
man.setdefault("stripped", []).append({"at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
| 693 |
+
"pattern": pat.pattern, "files": gone, "bytes": removed_bytes,
|
| 694 |
+
"reason": "native executables are not redistributed (decision 2026-11-12)"})
|
| 695 |
+
man_bytes = json.dumps(man, indent=1).encode("utf-8")
|
| 696 |
+
write_sums(d, extra={"manifest.json": hashlib.sha256(man_bytes).hexdigest()})
|
| 697 |
+
tmp = os.path.join(d, "manifest.json.lbc-tmp")
|
| 698 |
+
with open(tmp, "wb") as f:
|
| 699 |
+
f.write(man_bytes)
|
| 700 |
+
os.replace(tmp, os.path.join(d, "manifest.json"))
|
| 701 |
+
print(json.dumps({"stripped": len(gone), "bytes": removed_bytes, "files_left": len(index),
|
| 702 |
+
"bytes_compressed": man["bytes_compressed"]}))
|
| 703 |
+
|
| 704 |
+
|
| 705 |
# ---------------------------------------------------------------- fetch from Hugging Face
|
| 706 |
|
| 707 |
def _resolve(url, token):
|
|
|
|
| 917 |
p.add_argument("--level", type=int, default=19); p.add_argument("--exclude-setup-json", action="store_true")
|
| 918 |
u = sp.add_parser("unpack"); u.add_argument("staging_dir"); u.add_argument("package_dir"); u.add_argument("--shards")
|
| 919 |
c = sp.add_parser("check"); c.add_argument("staging_dir")
|
| 920 |
+
st = sp.add_parser("strip"); st.add_argument("staging_dir"); st.add_argument("--pattern")
|
| 921 |
r = sp.add_parser("reindex"); r.add_argument("staging_dir"); r.add_argument("package_dir")
|
| 922 |
d = sp.add_parser("pkgdir"); d.add_argument("project_dir"); d.add_argument("name")
|
| 923 |
li = sp.add_parser("license"); li.add_argument("package_dir")
|
|
|
|
| 925 |
f.add_argument("--package", action="append"); f.add_argument("--namespace", default="MoteMath")
|
| 926 |
f.add_argument("--dry-run", action="store_true"); f.add_argument("--check", action="store_true")
|
| 927 |
a = ap.parse_args()
|
| 928 |
+
{"key": cmd_key, "pack": cmd_pack, "unpack": cmd_unpack, "check": cmd_check, "strip": cmd_strip, "fetch": cmd_fetch, "reindex": cmd_reindex, "license": cmd_license, "pkgdir": lambda a: print(package_dir(os.path.abspath(a.project_dir), a.name))}[a.cmd](a)
|
| 929 |
|
| 930 |
|
| 931 |
if __name__ == "__main__":
|