Spaces:
Sleeping
Sleeping
Download deploy/hf/prepare_image.py from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 2.21 kB
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/deploy/hf/prepare_image.py
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/deploy/hf/prepare_image.py
-
curl -L -o prepare_image.py https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/deploy/hf/prepare_image.py
2.21 kB
| """Build-time Linux executor pin; runtime never approves or rewrites its image.""" | |
| import hashlib | |
| import json | |
| import gzip | |
| import sys | |
| from pathlib import Path | |
| ROOT=Path(__file__).resolve().parents[2];sys.path.insert(0,str(ROOT)) | |
| from src.modules.skill.domain.models import digest | |
| from src.adapters.sandbox.qemu import VM_LAUNCH_V8 | |
| def prepare_executor(root): | |
| image=root/'.local/tools/vm';control=root/'src/modules/execution/container' | |
| baseline=json.loads((root/'deploy/hf/base-vm-manifest.json').read_text()) | |
| if baseline.get('launch')!=VM_LAUNCH_V8:raise RuntimeError('UNAPPROVED_VM_LAUNCH') | |
| latest=control/'vm_worker_v7.py' | |
| use_latest=latest.is_file() and hashlib.sha256(latest.read_bytes()).hexdigest()==baseline['worker'] | |
| paths={'kernel':image/'kernel','rootfs':image/'rootfs.cpio.gz','worker':latest if use_latest else control/'vm_worker_v6.py','probe':control/'probe_v3.py'} | |
| for name,path in paths.items(): | |
| if hashlib.sha256(path.read_bytes()).hexdigest()!=baseline[name]:raise RuntimeError('UNAPPROVED_VM_INPUT') | |
| paths['qemu']=root/'.local/tools/qemu/qemu-system-x86_64.exe' | |
| manifest={name:hashlib.sha256(path.read_bytes()).hexdigest() for name,path in paths.items()} | |
| manifest['launch']=VM_LAUNCH_V8 | |
| (image/('manifest-v9.json' if use_latest else 'manifest-v8.json')).write_text(json.dumps(manifest,indent=2),encoding='utf-8') | |
| (image/'build-evidence.json').write_text(json.dumps({'backend':'qemu-tcg','platform':'linux-amd64','image':'zkcoding-qemu@sha256:'+digest(manifest), | |
| 'inputs':manifest,'runtime_repin':False},indent=2),encoding='utf-8') | |
| return manifest | |
| def main(): | |
| database=ROOT/'.local/platform/knowledge.sqlite' | |
| with gzip.open(database.with_suffix('.sqlite.gz'),'rb') as source,database.open('wb') as target: | |
| import shutil | |
| shutil.copyfileobj(source,target) | |
| expected=json.loads((ROOT/'deploy/hf/knowledge-manifest.json').read_text()) | |
| if hashlib.sha256(database.read_bytes()).hexdigest()!=expected['sha256']:raise RuntimeError('KNOWLEDGE_SNAPSHOT_MISMATCH') | |
| database.with_suffix('.sqlite.gz').unlink() | |
| prepare_executor(ROOT) | |
| if __name__=='__main__':main() | |