From 509a6c668aebf4735c69e31e56f771f15c42b581 Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:59:07 +0100 Subject: [PATCH] Add pinned Basalt 0.5.6 and isolated Inkling profile support --- basalt_runtime.py | 11 +- basalt_sources.json | 22 ++- basalt_worker.py | 19 ++- deploy/BASALT_NATIVE.md | 35 +++- docs/ATHENA_HANDOFF.md | 27 +++ docs/CURRENT_SYSTEM.md | 30 +++- .../basalt-056-inkling-2026-11-23/README.md | 160 ++++++++++++++++++ .../activation-result.json | 32 ++++ .../activation.py | 120 +++++++++++++ .../basalt-056-inkling-2026-11-23/after.json | 37 ++++ .../artifact-checks.json | 25 +++ .../basalt-056-inkling-2026-11-23/before.json | 37 ++++ .../build-result.json | 67 ++++++++ .../build_host.py | 81 +++++++++ .../check_artifacts_host.py | 43 +++++ .../check_cpu_host.py | 33 ++++ .../cpu-checks.json | 21 +++ .../final-acceptance.json | 58 +++++++ .../short_compare.py | 38 +++++ .../test_activation.py | 68 ++++++++ .../ui-activation-result.json | 20 +++ .../ui_activation.py | 50 ++++++ execution_setup.py | 6 +- test_basalt_inkling.py | 59 +++++++ test_inkling_presentation.py | 18 ++ 25 files changed, 1097 insertions(+), 20 deletions(-) create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/README.md create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/activation-result.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/activation.py create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/after.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/artifact-checks.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/before.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/build-result.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/build_host.py create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/check_artifacts_host.py create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/check_cpu_host.py create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/cpu-checks.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/final-acceptance.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/short_compare.py create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/test_activation.py create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/ui-activation-result.json create mode 100644 docs/maintenance/basalt-056-inkling-2026-11-23/ui_activation.py create mode 100644 test_basalt_inkling.py create mode 100644 test_inkling_presentation.py diff --git a/basalt_runtime.py b/basalt_runtime.py index 803d5b4..4757b59 100644 --- a/basalt_runtime.py +++ b/basalt_runtime.py @@ -13,10 +13,9 @@ COMMIT=RECIPE['code'] def validate_model(entry): source=entry.get('download_source') or entry - model=RECIPE['model'] - if any(source.get(k)!=model[k] for k in ('repo','revision','file')) or entry.get('sha256')!=model['sha256'] or entry.get('size')!=model['size']: - raise ValueError('Basalt benötigt das geprüfte vollständige Flash-Next GSQ-RCO IQ3_XXS-Paket mit fester Revision, Größe und SHA-256.') - return model + for model in (RECIPE['model'],*(RECIPE.get('additional_models') or {}).values()): + if all(source.get(k)==model[k] for k in ('repo','revision','file')) and all(entry.get(k)==model[k] for k in ('sha256','size')):return model + raise ValueError('Basalt benötigt ein geprüftes Modellpaket mit fester Revision, Größe und SHA-256.') def validate_projector(entry): source=entry.get('download_source') or entry;pin=RECIPE['vision'] @@ -38,9 +37,9 @@ class BasaltRuntime(LTXOriginalRuntime): features=dict(answer_now=installed,logprobs=installed,session_affinity=installed,documents=bool(installed and ready.get('pdf_version')=='7.0.1'),video=bool(vision and isinstance(video,dict) and video.get('available') is True)) return dict(installed=installed,revision=COMMIT,version=RECIPE['version'],job=dict(self.job) if self.job else None,required_disk_gib=6,model=dict(RECIPE['model']),gpu_policy='Text: eine SM120-GPU; Vision: separater SM86/SM120-Sidecar',context_per_slot=262144,max_slots=2,vision=vision,features=features,video=video) def prepared(self,entry): - validate_model(entry) + model=validate_model(entry) path=self.catalog.root/entry['id']/'model.basalt' - if not path.is_file() or path.stat().st_size!=RECIPE['model']['size']:raise ValueError('Basalt-Modellpaket fehlt oder ist unvollständig. Über die Modellbibliothek herunterladen.') + if not path.is_file() or path.stat().st_size!=model['size']:raise ValueError('Basalt-Modellpaket fehlt oder ist unvollständig. Über die Modellbibliothek herunterladen.') return path def download_model(self): model=RECIPE['model'];data=self.catalog.files(model['repo'],model['revision']);item=next((x for x in data['files'] if x['name']==model['file']),{}) diff --git a/basalt_sources.json b/basalt_sources.json index d8edad8..6329d96 100644 --- a/basalt_sources.json +++ b/basalt_sources.json @@ -1,10 +1,15 @@ { - "code": "2729e2288f59e01836ddd7fcc630810ada98995a", - "version": "0.3.3", + "code": "1e205ae87cc8e3c04e96db40fd505a75f44685ec", + "version": "0.5.6", "url": "https://github.com/jesdga95/basalt.git", "cuda": "13.0", - "architectures": [120], - "vision_architectures": [86, 120], + "architectures": [ + 120 + ], + "vision_architectures": [ + 86, + 120 + ], "tuning": { "conversation_cache_mib": 0, "conversation_cache_disk_mib": 16384, @@ -28,5 +33,14 @@ "file": "Qwen3.8-FN-GSQ-RCO-IQ3_XXS.basalt", "size": 79865545428, "sha256": "c20595c2dd1c444b465f916447b835c1f30189ba1286932427115dac7b365165" + }, + "additional_models": { + "inkling2": { + "repo": "jesdga/Inkling-2-Mini-Basalt", + "revision": "6c9fbf0730a6d2e8813a1b262c2ab3548cf0239e", + "file": "Inkling-2-Mini-NVFP4-MX8.basalt", + "size": 19606374189, + "sha256": "28ec70723feaa037942a02f55b9d5e898276f3e62a3b1fa083745f932a041b99" + } } } diff --git a/basalt_worker.py b/basalt_worker.py index 5a6b725..afa15a5 100644 --- a/basalt_worker.py +++ b/basalt_worker.py @@ -89,14 +89,19 @@ class BasaltWorker(StrataWorker): self.memory_plan.update(vision_gpu=vision,vision_index=card) return self.memory_plan @staticmethod - def configuration(p,model,port,reserve,vision_index=None)->dict[str,Any]: + def configuration(p,model,port,reserve,vision_index=None,model_family='qwen4exp')->dict[str,Any]: params=p['parameters'] + if model_family=='inkling2': + if params.get('vision_projector'):raise InferenceError('Inkling verwendet keinen Qwen-Vision-Projektor.') + return dict(version=2,server=dict(host='127.0.0.1',port=port,**{'image-remote-only':True}),models=[dict(model=str(model),alias=p['api_id'],gpu='0',parallel=params.get('slots',1),**{'slot-full-context':True,'vision':'off'})],engine={'max-context':params['context'],'kv':'fp8','vram-reserve-mib':reserve,'conversation-cache-mib':0,'conversation-cache-disk-mib':0}) if params.get('vision_projector') and type(vision_index) is not int:raise InferenceError('Vision-GPU-Index fehlt; kein stiller CPU-/GPU-Fallback.') return dict(version=2,server=dict(host='127.0.0.1',port=port,**{'image-remote-only':True}),models=[dict(model=str(model),alias=p['api_id'],gpu='0',parallel=params.get('slots',1),**{'slot-full-context':True,'vision':str(vision_index) if params.get('vision_projector') else 'off'})],engine={'max-context':params['context'],'kv':'int8','expert-cache':'auto','prefill':'auto','resident-experts':True,'vram-reserve-mib':reserve,'conversation-cache-mib':(RECIPE.get('tuning') or {}).get('conversation_cache_mib',0),'conversation-cache-disk-mib':(RECIPE.get('tuning') or {}).get('conversation_cache_disk_mib',0)}) @staticmethod - def server_command(python,source,config,key): + def server_command(python,source,config,key,model_family='qwen4exp'): # Upstream accepts API credentials only on CLI, never in a config file. - return [str(python),str(Path(__file__).with_name('basalt_serve.py')),'--deck-source',str(source),'--engine-bin',str(source/'bin/basalt'),'--config',str(config),'--api-key',key,'--expert-profile',str(profile_path(source.parent,RECIPE))] + command=[str(python),str(Path(__file__).with_name('basalt_serve.py')),'--deck-source',str(source),'--engine-bin',str(source/'bin/basalt'),'--config',str(config),'--api-key',key] + if model_family=='qwen4exp':command+=['--expert-profile',str(profile_path(source.parent,RECIPE))] + return command @staticmethod def verify_properties(props,params): if props.get('is_sleeping') is not False or props.get('total_slots')!=params.get('slots',1) or (props.get('default_generation_settings') or {}).get('n_ctx')!=params['context']: @@ -107,16 +112,18 @@ class BasaltWorker(StrataWorker): layout=cpu_partition.load(self.root.parent) if self.process and self.process.poll() is None and self.profile and (p['id'],p['revision'])==(self.profile['id'],self.profile['revision']) and layout==self.cpu_layout:return self.stop();self.plan(p,cancel);self.state='loading';self.phase='Basalt-Modell laden';self.error=None;self.cpu_layout=layout - params=p['parameters'];entry=self.catalog.entry(p['model_id']);validate_model(entry);model=self.runtime.prepared(entry);python,source=self.runtime.paths() + params=p['parameters'];entry=self.catalog.entry(p['model_id']);pin=validate_model(entry);model=self.runtime.prepared(entry);python,source=self.runtime.paths() + family='qwen4exp' if pin==RECIPE['model'] else 'inkling2' + if family=='inkling2':self.memory_plan.update(kv='fp8',kv_elastic=True,experts='gpu-with-cpu-spill',model_family=family) self.root.mkdir(parents=True,exist_ok=True,mode=0o700) with socket.socket() as sock:sock.bind(('127.0.0.1',0));self.port=sock.getsockname()[1] self.key=secrets.token_urlsafe(32);self.devices=list(params['gpu_devices']) - path=self.root/'worker.json';path.write_text(json.dumps(self.configuration(p,model,self.port,self.memory_plan['reserve_mib'][0],self.memory_plan.get('vision_index'))));path.chmod(0o600) + path=self.root/'worker.json';path.write_text(json.dumps(self.configuration(p,model,self.port,self.memory_plan['reserve_mib'][0],self.memory_plan.get('vision_index'),model_family=family)));path.chmod(0o600) for folder in ('home','tmp','cache','cache/cuda'):(self.root/folder).mkdir(parents=True,exist_ok=True,mode=0o700) env=dict(os.environ,CUDA_VISIBLE_DEVICES=','.join(self.devices),HOME=str(self.root/'home'),TMPDIR=str(self.root/'tmp'),XDG_CACHE_HOME=str(self.root/'cache'),CUDA_CACHE_PATH=str(self.root/'cache/cuda'),PYTHONUNBUFFERED='1',OMP_NUM_THREADS='1',OPENBLAS_NUM_THREADS='1') libs=self.runtime.root/'cuda';env['LD_LIBRARY_PATH']=str(libs/'lib64')+os.pathsep+str(libs/'lib')+os.pathsep+env.get('LD_LIBRARY_PATH','') self.profile=p;self.generation=uuid.uuid4().hex;self.backend_info={} - with (self.root/'server.log').open('w') as output:self.process=subprocess.Popen(cpu_partition.command(self.server_command(python,source,path,self.key),layout['strata'] if layout else None),cwd=source,env=env,stdout=output,stderr=subprocess.STDOUT,start_new_session=True) + with (self.root/'server.log').open('w') as output:self.process=subprocess.Popen(cpu_partition.command(self.server_command(python,source,path,self.key,model_family=family),layout['strata'] if layout else None),cwd=source,env=env,stdout=output,stderr=subprocess.STDOUT,start_new_session=True) try: deadline=time.monotonic()+600 while time.monotonic() Arbeitsspeicher ist ein schneller, flüchtiger Zwischenspeicher, während eine SSD dauerhaft Daten speichert, aber langsamer als RAM ist. + +Do not set `model.ollama_num_ctx` on this OpenAI-compatible Deck route: it adds +Ollama `options` that Deck correctly refuses. That failed pre-inference attempt +was removed; the supported matching `model.context_length` override works. +The new profile inherits a nonblocking dashboard-basic-auth configuration +warning; no new dashboard was started and no shared authentication changed. +Its CLI test used `--reasoning none --max-turns1 --run-budget90`; arbitrary +long user conversations and looping behavior remain unqualified. + +Final normal readback: Qwen ready0.5.6/two slots262144 each, original GPU TTS +profile `5b67537ab825493786861b278ae26cbe` and ASR +`129d5ea93fd34f1a9e5dcca7bcef5761` loaded, not warming; healthy app, +OOM=false/RestartCount0, active/waiting counters0. Original profile JSON is +byte-identical after removing the single new Inkling row; endpoint JSON is +byte-identical after removing only its added enabled ID. Audio/CPU/reasoning +policy hashes remain identical. Existing protected voice artifacts untouched. + +## Remaining boundaries + +- Native Mac/Desktop profile selection and a conversation in that client were + not exercised; profile registry, effective CLI/API configuration and actual + Hermes CLI inference were exercised. +- No Inkling quality/throughput benchmark, images, full64K input, simultaneous + full-context requests, long-agent run or new audio inference acceptance. +- No fresh-Debian or full encrypted-restore acceptance. The Hermes profile is + private NAS state and needs inclusion in its normal encrypted backup policy; + no off-host backup was performed here. +- Independent reviewer delegation was not available in this tool set. The + actual source diff, targeted/root tests, upstream fixtures, binary checks and + isolated/live acceptance are the evidence, not an independent-review claim. +- Qwen is restored now. A later Inkling request triggers the normal FIFO model + switch; simultaneous Qwen+Inkling GPU residency is neither promised nor tested. diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/activation-result.json b/docs/maintenance/basalt-056-inkling-2026-11-23/activation-result.json new file mode 100644 index 0000000..70d1a37 --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/activation-result.json @@ -0,0 +1,32 @@ +{ + "phase": "activated_model_restoration_pending", + "container_before": "78e4494721fddd1fde2b971de7f17b0f7b5db1b3e90fde045328cf6a7af66436", + "image_before": "sha256:21414d939a91d0aa997129cf4b30e67b84d95f01f80ee7071a328e074dc8eb72", + "tag_before": "athena-deck-standalone:cache-17e7017", + "started_before": "2026-11-23T10:44:10.552750441Z", + "image_after": "sha256:fc3cfb07b2b04fd5334cac67263a79b2dca802022b5b94539b1baaaa7bff516d", + "settings": { + "profiles.json": "9fb1ec281887f59ccd07273db41542a148be2098f7ec29b4b27f04f8c6552e32", + "endpoint.json": "98181e6b1d254f8507aee15e4135ebeaa7c409d6cca2edd030ff25b9f51b1a61", + "audio-policy.json": "54aa6b69e3449cdd0f7049f34d818504455662ebe41da88ed4cd99953db12344", + "cpu-partition.json": "836a97564094f95850c6fa0fd3776e164e7aeff2bf4bb8a61d43ea4182cfaaec", + "reasoning-budget.json": "4884a379adf2f888415041b81ef55a01a2c22ef7a41ca1554460f410bec5cf0c" + }, + "autostart": true, + "source_before": { + "basalt_sources.json": "047eaca3d7ee6da08f1414e3f783480ddfe7e3a61ebd466e05c11419dec87f3d", + "basalt_runtime.py": "e3078aa2a7aa2052a9ffcbcab056a4d134ed156e427ee2cef0679a91e935e701", + "basalt_worker.py": "20b1210d23c4ee1ae42870b20b2cce6c2ca353b760cee0ba0016d0e6a30a2bd6" + }, + "source_after": { + "basalt_sources.json": "965540ed137c49a96cf2e5cf46d47d6c40d5ff45089e2a6f5141e26b43e7bd0e", + "basalt_runtime.py": "1f03a042df156b23c8a417127f2b47b1392c24fcfad3cb4aa74522d52735d30e", + "basalt_worker.py": "ff11637d0d81b6da3921dd316f42b25f6fb6ccebdd7aca49dec9b505274f4c43" + }, + "prepared_at": 1795455235.4386098, + "model_weights_changed": false, + "drain_checked_at": 1795455283.468947, + "container_after": "2ce1468fadb349f7cc821d27947dde52d654855502cd3cd1b2718aa9a370b281", + "activated_at": 1795455329.127601, + "recovery": "Obsolete reference_models installer flag retired; both historic27B references absent and no retained profile uses them. No source guard weakened; generated Docker arguments unchanged by this flag." +} diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/activation.py b/docs/maintenance/basalt-056-inkling-2026-11-23/activation.py new file mode 100644 index 0000000..793318f --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/activation.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 +"""ATHENA HOST: explicitly authorized app/runtime promotion, normal drain first. + +Public source-only stdin bundle for prepare; fresh authenticated drain for apply. +Never executed merely by importing. Rollback artifacts stay in the same state root. +""" +import argparse +import hashlib +import importlib.util +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys +import time + +ROOT=Path('/opt/athena-deck-dev/basalt-056-activation-20261123') +CANDIDATE=Path('/opt/athena-deck-dev/basalt-056-candidate-1e205ae87cc8/runtime') +BASE=Path('/opt/athena-deck-dev/runtime');STATE=BASE/'state';SOURCE=Path('/opt/athena-deck-dev/source') +NEXT=STATE/'basalt-runtime.next-056-20261123';PREVIOUS=STATE/'basalt-runtime.previous-040-20261123' +IMAGE='athena-deck-standalone:basalt-056-20261123' +CODE='1e205ae87cc8e3c04e96db40fd505a75f44685ec' +FILES=('basalt_sources.json','basalt_runtime.py','basalt_worker.py') +SETTINGS=('profiles.json','endpoint.json','audio-policy.json','cpu-partition.json','reasoning-budget.json') +BLOCKED={'vpn','vpn.auth','OpenVPN-KIT','GluetunVPN'} + + +def run(*args,**kw):return subprocess.run(list(map(str,args)),check=True,**kw) +def info():return json.loads(subprocess.check_output(['docker','inspect','athena-deck-dev']))[0] +def sha(p): + with Path(p).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest() +def save(value): + p=ROOT/'activation.json';t=p.with_suffix('.tmp');t.write_text(json.dumps(value,indent=2)+'\n');t.chmod(0o600);t.replace(p) +def load():return json.loads((ROOT/'activation.json').read_text()) +def sandbox(d): + config=dict(d['Config']);config.pop('Image',None);config.pop('Hostname',None) + env=config.get('Env') or [];assert len({v.split('=',1)[0] for v in env})==len(env);config['Env']=sorted(env) + return dict(config=config,host=d['HostConfig']) +def ignore(parent,names):return [n for n in names if n in BLOCKED or n.endswith('.ovpn') or n.startswith('.env')] +def owner_tree(path): + for parent,dirs,files in os.walk(path,followlinks=False): + dirs[:]=[n for n in dirs if n not in BLOCKED];os.chown(parent,65534,65534) + for n in dirs+files: + if n not in BLOCKED and not n.endswith('.ovpn'):os.chown(Path(parent)/n,65534,65534,follow_symlinks=False) + + +def reference_preflight(base,config): + if config.get('reference_models'): + for name in ('Qwen3.8-27B-IQ4-MIX.gguf','Qwen3.8-27B-IQ4_XS-pure.gguf'): + path=base/'state/reference-models'/name + if not path.is_file() or not path.resolve().is_relative_to((base/'state/models').resolve()): + raise RuntimeError('Historisches Referenzmodell fehlt: vor der Wartung Installationsmanifest mit tatsächlich behaltenen Profilen abgleichen; keine Referenzprüfung umgehen.') + +def prepare(): + bundle=json.load(sys.stdin);assert set(bundle['files'])==set(FILES) + spec=importlib.util.spec_from_file_location('preflight_install',SOURCE/'deploy/install.py');assert spec and spec.loader + installer=importlib.util.module_from_spec(spec);spec.loader.exec_module(installer) + reference_preflight(BASE,installer.load_manifest(BASE)) + assert not ROOT.exists() and not NEXT.exists() and not PREVIOUS.exists() + current=info();assert current['State']['Running'] and current['Config']['User']=='65534:65534' + tag=current['Config']['Image'];assert subprocess.check_output(['docker','image','inspect','--format','{{.Id}}',tag],text=True).strip()==current['Image'] + marker=json.loads((CANDIDATE/'ready.json').read_text());assert marker['commit']==CODE and marker['version']=='0.5.6' + assert sha(CANDIDATE/'source/bin/basalt')==marker['binary_sha256'] and sha(CANDIDATE/'source/bin/basalt-vision')==marker['vision_binary_sha256'] + assert json.loads((STATE/'basalt-runtime/ready.json').read_text())['version']=='0.4.0' + assert shutil.disk_usage(STATE).free>2*1024**3 + ROOT.mkdir(mode=0o700);(ROOT/'image/app').mkdir(parents=True);(ROOT/'source-before').mkdir();(ROOT/'tmp').mkdir(mode=0o700);os.chown(ROOT/'tmp',65534,65534) + for n,text in bundle['files'].items(): + p=ROOT/'image/app'/n;p.parent.mkdir(parents=True,exist_ok=True);p.write_text(text);p.chmod(0o644) + old=SOURCE/n + if old.is_file(): + target=ROOT/'source-before'/n;target.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(old,target) + (ROOT/'image/Dockerfile').write_text('FROM '+tag+'\nUSER root\nCOPY app/ /app/\nUSER 65534:65534\n') + (ROOT/'image/.dockerignore').write_text('*\n!Dockerfile\n!app/\n!app/**\n') + with (ROOT/'image-build.log').open('w') as log:run('docker','build','--network','none','--pull=false','-t',IMAGE,ROOT/'image',stdout=log,stderr=subprocess.STDOUT,timeout=180) + probe="from pathlib import Path\nimport tempfile\nfrom server import Server\nwith tempfile.TemporaryDirectory() as tmp:\n s=Server(0,state_dir=Path(tmp));s.endpoint.close();s.video.close();s.dashboard.close();s.server_close()\nprint('Full isolated Server constructor passed')" + run('docker','run','--rm','--runtime','runc','--network','none','--read-only','--user','65534:65534','--memory','512m','--pids-limit','256','--cap-drop','ALL','-e','NVIDIA_VISIBLE_DEVICES=void','-e','DECK_REQUIRE_SETUP=0','-e','DECK_NETWORK_MODE=disabled','-e','TMPDIR=/test-tmp','--mount','type=bind,src='+str(ROOT/'tmp')+',dst=/test-tmp','--entrypoint','python3',IMAGE,'-B','-c',probe,timeout=45) + NEXT.mkdir(mode=0o700) + for name in ('venv','source','profiles'):shutil.copytree(CANDIDATE/name,NEXT/name,symlinks=True,ignore=ignore) + for name in ('ready.json','python-lock.txt'):shutil.copy2(CANDIDATE/name,NEXT/name) + for name in ('home','tmp','cache'):(NEXT/name).mkdir(mode=0o700) + (NEXT/'cuda').symlink_to('../'+PREVIOUS.name+'/cuda',target_is_directory=True);owner_tree(NEXT) + assert sha(NEXT/'source/bin/basalt')==marker['binary_sha256'] and sha(NEXT/'source/bin/basalt-vision')==marker['vision_binary_sha256'] + assert info()['Id']==current['Id'] and info()['State']['StartedAt']==current['State']['StartedAt'] + save(dict(phase='prepared',container_before=current['Id'],image_before=current['Image'],tag_before=tag,started_before=current['State']['StartedAt'],image_after=subprocess.check_output(['docker','image','inspect','--format','{{.Id}}',IMAGE],text=True).strip(),settings={n:sha(STATE/n) for n in SETTINGS},autostart=json.loads((STATE/'endpoint.json').read_text())['autostart'],source_before={n:sha(SOURCE/n) if (SOURCE/n).is_file() else None for n in FILES},source_after={n:sha(ROOT/'image/app'/n) for n in FILES},prepared_at=time.time(),model_weights_changed=False)) + print(json.dumps({'phase':'prepared','production_unchanged':True,'image':IMAGE,'runtime_staged':str(NEXT)}),flush=True) + + +def apply(): + drain=json.load(sys.stdin);assert drain['authenticated_status']==200 and drain['origin']=='http://192.168.1.212:8108' + assert 0<=time.time()-drain['checked_at']<60 and drain['state']=='stopped' + assert type(drain['active_requests']) is int and drain['active_requests']==0 + assert all(type(drain['scheduler'][k]) is int and drain['scheduler'][k]==0 for k in ('active_requests','waiting_requests','tts_waiting_requests','stt_waiting_requests')) + assert drain['scheduler']['switching'] is False + a=load();assert a['phase']=='prepared';current=info();assert current['Id']==a['container_before'] and current['Image']==a['image_before'];original=sandbox(current) + assert all(sha(STATE/n)==a['settings'][n] for n in SETTINGS if n!='endpoint.json') + assert all((sha(SOURCE/n) if (SOURCE/n).is_file() else None)==a['source_before'][n] for n in FILES) + assert all(sha(ROOT/'image/app'/n)==a['source_after'][n] for n in FILES) + assert not PREVIOUS.exists() and NEXT.is_dir() and not (STATE/'basalt-runtime').is_symlink() + save(dict(a,phase='applying',drain_checked_at=drain['checked_at'])) + run('docker','stop','--timeout','45','athena-deck-dev',stdout=subprocess.DEVNULL) + (STATE/'basalt-runtime').replace(PREVIOUS);NEXT.replace(STATE/'basalt-runtime') + assert (STATE/'basalt-runtime/cuda/bin/nvcc').is_file() + for n in FILES:shutil.copy2(ROOT/'image/app'/n,SOURCE/n) + endpoint=STATE/'endpoint.json';data=json.loads(endpoint.read_text());data['autostart']=a['autostart'];tmp=endpoint.with_suffix('.activation-tmp');tmp.write_text(json.dumps(data));tmp.chmod(0o600);os.chown(tmp,65534,65534);tmp.replace(endpoint) + assert sha(endpoint)==a['settings']['endpoint.json'],'Autostart restoration must be byte-exact' + spec=importlib.util.spec_from_file_location('deck_install',SOURCE/'deploy/install.py');assert spec and spec.loader;installer=importlib.util.module_from_spec(spec);spec.loader.exec_module(installer) + config=installer.load_manifest(BASE);assert config['image']==a['tag_before'];config.update(image=IMAGE,previous_image=a['tag_before']) + run('docker','rm','athena-deck-dev',stdout=subprocess.DEVNULL);installer.launch(config);installer.ready(config);installer.write_manifest(BASE,config) + deadline=time.monotonic()+100 + while info()['State'].get('Health',{}).get('Status')=='starting' and time.monotonic()=3500*1024,'Insufficient live headroom; do not unload Qwen' + assert shutil.disk_usage(ROOT.parent).free>=12*1024**3 + live=json.loads(subprocess.check_output(['docker','inspect','athena-deck-dev']))[0] + before=bundle['before'] + assert live['Image']==before['image'] and live['Id']==before['container_id'] and live['State']['StartedAt']==before['started'] + ROOT.mkdir(mode=0o700);os.chown(ROOT,65534,65534) + for folder in ('recipe','recipe/deploy','runtime','tmp'): + p=ROOT/folder;p.mkdir(mode=0o700);os.chown(p,65534,65534) + for name,text in bundle['files'].items(): + p=ROOT/'recipe'/name;p.write_text(text);p.chmod(0o600);os.chown(p,65534,65534) + marker=dict(owner='athena-deck',commit=COMMIT,image=before['image'],phase='prepared',started_at=time.time(),cpu_quota=1,memory_mib=2560,swap_allowed=False,nice=15,gpu_access=False,production_state_mount=False,borrowed_cuda_read_only=str(CUDA),source_hashes={n:hashlib.sha256(t.encode()).hexdigest() for n,t in bundle['files'].items()}) + def save(): + p=ROOT/'build-status.json';pending=p.with_suffix('.tmp');pending.write_text(json.dumps(marker,indent=2)+'\n');pending.replace(p) + cid=None;save() + try: + command=['docker','create','--pull=never','--name',NAME,'--label','athena-deck.build='+LABEL,'--runtime=runc','--network=bridge','--read-only','--user=65534:65534','--cpus=1','--memory=2560m','--memory-swap=2560m','--pids-limit=1024','--cap-drop=ALL','--security-opt=no-new-privileges', + '--mount',f'type=bind,src={ROOT}/recipe,dst=/recipe,readonly','--mount',f'type=bind,src={ROOT}/runtime,dst=/var/lib/deck/basalt-runtime','--mount',f'type=bind,src={ROOT}/tmp,dst=/tmp','--mount',f'type=bind,src={CUDA},dst=/toolchain,readonly', + '-e','HOME=/var/lib/deck/basalt-runtime/home','-e','TMPDIR=/tmp','-e','NVIDIA_VISIBLE_DEVICES=void','-e','CUDA_VISIBLE_DEVICES=','-e','OPENBLAS_NUM_THREADS=1','-e','OMP_NUM_THREADS=1','-e','PYTHONDONTWRITEBYTECODE=1','--entrypoint','nice',before['image'],'-n','15','python3','/recipe/deploy/install_basalt.py','--destination','/var/lib/deck/basalt-runtime','--nvcc','/toolchain/bin/nvcc'] + cid=subprocess.check_output(command,text=True).strip();marker.update(container_id=cid,phase='building');save();print(json.dumps(marker),flush=True) + with (ROOT/'build.log').open('w') as log: + client=subprocess.Popen(['docker','start','--attach',cid],stdout=log,stderr=subprocess.STDOUT) + while client.poll() is None: + time.sleep(10) + available=int(next(l.split()[1] for l in Path('/proc/meminfo').read_text().splitlines() if l.startswith('MemAvailable:'))) + if available<768*1024: + owned=json.loads(subprocess.check_output(['docker','inspect',cid]))[0] + assert owned['Config']['Labels'].get('athena-deck.build')==LABEL + subprocess.run(['docker','stop','--timeout','20',cid],check=True,stdout=subprocess.DEVNULL) + client.wait(timeout=30);raise RuntimeError('Owned builder stopped to protect production RAM headroom') + info=json.loads(subprocess.check_output(['docker','inspect',cid]))[0] + marker.update(client_exit=client.returncode,container_exit=info['State']['ExitCode'],oom_killed=info['State']['OOMKilled']) + assert client.returncode==0 and info['State']['ExitCode']==0,'Build failed; preserved build.log and status' + ready=json.loads((ROOT/'runtime/ready.json').read_text()) + assert ready['commit']==COMMIT and ready['version']=='0.5.6' and ready['inference_performed'] is False + assert ready['video']['available'] is True and ready['pdf_version']=='7.0.1' + marker.update(phase='built_no_model_test',ready=ready) + except BaseException as exc: + marker.update(phase='failed',error=type(exc).__name__+': '+str(exc));raise + finally: + if cid: + info=json.loads(subprocess.check_output(['docker','inspect',cid]))[0] + assert info['Config']['Labels'].get('athena-deck.build')==LABEL + if info['State']['Running']:subprocess.run(['docker','stop','--timeout','20',cid],check=True,stdout=subprocess.DEVNULL) + marker['owned_container_final_state']=json.loads(subprocess.check_output(['docker','inspect',cid]))[0]['State'] + subprocess.run(['docker','rm',cid],check=True,stdout=subprocess.DEVNULL);marker['owned_container_removed']=True + marker['finished_at']=time.time();save();print(json.dumps(marker),flush=True) + + +if __name__=='__main__':main() diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/check_artifacts_host.py b/docs/maintenance/basalt-056-inkling-2026-11-23/check_artifacts_host.py new file mode 100644 index 0000000..d05dc1f --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/check_artifacts_host.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +"""ATHENA HOST: verify candidate bytes/fatbins and loader/help, never inference.""" +import hashlib +import json +import os +from pathlib import Path +import re +import subprocess + +ROOT=Path('/opt/athena-deck-dev/basalt-056-candidate-1e205ae87cc8') +COMMIT='1e205ae87cc8e3c04e96db40fd505a75f44685ec' + +def main(): + build=json.loads((ROOT/'build-status.json').read_text());assert build['phase']=='built_no_model_test' and build['owned_container_removed'] is True + runtime=ROOT/'runtime';ready=json.loads((runtime/'ready.json').read_text());assert ready['commit']==COMMIT and ready['version']=='0.5.6' + source=runtime/'source';sha=lambda p:hashlib.file_digest(Path(p).open('rb'),'sha256').hexdigest() + actual=subprocess.check_output(['git','-c','safe.directory='+str(source),'-C',str(source),'rev-parse','HEAD'],text=True).strip();assert actual==COMMIT + assert not subprocess.check_output(['git','-c','safe.directory='+str(source),'-C',str(source),'status','--porcelain','--untracked-files=no'],text=True).strip() + obj=ROOT/'inspection-tools/cuobjdump' + if not obj.exists(): + import io,tarfile,urllib.request + url='https://developer.download.nvidia.com/compute/cuda/redist/cuda_cuobjdump/linux-x86_64/cuda_cuobjdump-linux-x86_64-13.0.39-archive.tar.xz' + with urllib.request.urlopen(url,timeout=30) as response:archive=response.read(244841) + assert len(archive)==244840 and hashlib.sha256(archive).hexdigest()=='2385804b0a628b98b3ed96a19c803143d5c2e2fcc5139f633450862cf7755d65' + with tarfile.open(fileobj=io.BytesIO(archive),mode='r:xz') as tar: + member=tar.getmember('cuda_cuobjdump-linux-x86_64-13.0.39-archive/bin/cuobjdump');assert member.isfile() + stream=tar.extractfile(member);assert stream is not None + with stream:binary=stream.read() + obj.parent.mkdir(mode=0o700);obj.write_bytes(binary);obj.chmod(0o700) + assert obj.is_file() + artifacts={} + for name,key,expected in [('basalt','binary_sha256',[120]),('basalt-vision','vision_binary_sha256',[86,120])]: + binary=source/'bin'/name;digest=sha(binary);assert digest==ready[key] + out=subprocess.check_output([obj,'--list-elf',binary],text=True) + arches=sorted({int(x) for x in re.findall(r'\.sm_(\d+)',out)});assert arches==expected,(name,arches) + artifacts[name]=dict(sha256=digest,bytes=binary.stat().st_size,actual_elf_architectures=arches) + cuda=Path(build['borrowed_cuda_read_only']);env=dict(os.environ,LD_LIBRARY_PATH=str(cuda/'lib64')+':'+str(cuda/'lib'),CUDA_VISIBLE_DEVICES='') + help_command=['docker','run','--rm','--pull=never','--runtime','runc','--network','none','--read-only','--user','65534:65534','--cap-drop','ALL','-e','NVIDIA_VISIBLE_DEVICES=void','-e','CUDA_VISIBLE_DEVICES=','-e','LD_LIBRARY_PATH=/toolchain/lib64:/toolchain/lib','--mount',f'type=bind,src={runtime},dst=/candidate,readonly','--mount',f'type=bind,src={cuda},dst=/toolchain,readonly','--entrypoint','/candidate/source/bin/basalt',build['image'],'--help'] + help_=subprocess.run(help_command,capture_output=True,text=True,timeout=30,check=True);assert 'basalt serve' in help_.stdout+help_.stderr + value=dict(success=True,commit=actual,version='0.5.6',artifacts=artifacts,cuobjdump_sha256=sha(obj),real_model_inference=False,gpu_access=False) + (ROOT/'artifact-check-result.json').write_text(json.dumps(value,indent=2)+'\n');print(json.dumps(value)) + +if __name__=='__main__':main() diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/check_cpu_host.py b/docs/maintenance/basalt-056-inkling-2026-11-23/check_cpu_host.py new file mode 100644 index 0000000..3b95a07 --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/check_cpu_host.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +"""ATHENA HOST: CPU-only interop and upstream fixtures, no model/GPU access.""" +import json +import os +from pathlib import Path +import subprocess +import sys + +ROOT=Path('/opt/athena-deck-dev/basalt-056-candidate-1e205ae87cc8') + +def main(): + bundle=json.load(sys.stdin);assert set(bundle)=={'files','image'} + check=ROOT/'cpu-check-2';assert not check.exists();check.mkdir(mode=0o700);os.chown(check,65534,65534) + for name,text in bundle['files'].items(): + assert name in ('basalt_serve.py','basalt_telemetry.py','check_telemetry_mock.py') + p=check/name;p.write_text(text);p.chmod(0o600);os.chown(p,65534,65534) + runtime='/var/lib/deck/basalt-runtime';python=runtime+'/venv/bin/python';source=runtime+'/source' + cmd=['docker','run','--rm','--name','athena-basalt056-cpu-check-2','--label','athena-deck.check=basalt056','--pull=never','--runtime','runc','--network','none','--read-only','--user','65534:65534','--cpus','1','--memory','768m','--memory-swap','768m','--pids-limit','256','--cap-drop','ALL','--security-opt','no-new-privileges','--mount',f'type=bind,src={ROOT}/runtime,dst={runtime},readonly','--mount',f'type=bind,src={check},dst=/check','-e','NVIDIA_VISIBLE_DEVICES=void','-e','CUDA_VISIBLE_DEVICES=','-e','PYTHONDONTWRITEBYTECODE=1','-e','PYTHONPATH=/check:/app','-e','TMPDIR=/check','--workdir',source,'--entrypoint',python,bundle['image']] + script="import subprocess,sys; subprocess.run([sys.executable,'/check/check_telemetry_mock.py','--python',sys.executable,'--source',"+repr(source)+",'--launcher','/check/basalt_serve.py'],check=True); subprocess.run([sys.executable,'-m','unittest','discover','-s','serve/tests','-p','test_*.py','-t','.'],check=True)" + try: + with (check/'stdout.log').open('w') as out,(check/'stderr.log').open('w') as err: + p=subprocess.run(cmd+['-B','-u','-c',script],stdout=out,stderr=err,text=True,timeout=1200) + except subprocess.TimeoutExpired: + leftover=subprocess.run(['docker','inspect','athena-basalt056-cpu-check-2'],capture_output=True,text=True) + if leftover.returncode==0: + owned=json.loads(leftover.stdout)[0];assert owned['Config']['Labels'].get('athena-deck.check')=='basalt056' + if owned['State']['Running']:subprocess.run(['docker','stop','--timeout','15','athena-basalt056-cpu-check-2'],check=True,capture_output=True) + raise + stdout=(check/'stdout.log').read_text();stderr=(check/'stderr.log').read_text() + result=dict(scope='candidate_python_real_upstream_cpu_fixtures',exit_code=p.returncode,real_model_inference=False,gpu_access=False,success=p.returncode==0) + (ROOT/'cpu-check-result.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps(result));print(stdout[-2000:]);print(stderr[-2500:]);return p.returncode + +if __name__=='__main__':raise SystemExit(main()) diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/cpu-checks.json b/docs/maintenance/basalt-056-inkling-2026-11-23/cpu-checks.json new file mode 100644 index 0000000..0b184f2 --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/cpu-checks.json @@ -0,0 +1,21 @@ +{ + "scope": "candidate_python_real_upstream_cpu_fixtures", + "exit_code": 0, + "success": true, + "tests": 1300, + "skipped": 16, + "seconds": 543.410, + "real_model_inference": false, + "gpu_access": false, + "sandbox_removed": true, + "prior_attempt": "Supervisor timeout360s; exact owned sandbox absence verified. Corrected successor used1200s budget and realtime log files.", + "nonfatal_fixture_warnings": ["ConnectionResetError in router traffic thread", "ResourceWarning for unclosed socket"], + "telemetry": { + "real_upstream_mock": true, + "auth_401": true, + "existing_chat_route": true, + "numeric_counters": true, + "content_free": true, + "slots": 1 + } +} diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/final-acceptance.json b/docs/maintenance/basalt-056-inkling-2026-11-23/final-acceptance.json new file mode 100644 index 0000000..083ab2a --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/final-acceptance.json @@ -0,0 +1,58 @@ +{ + "success": true, + "final_image": "sha256:803aadc28939e5d9598343105ea2c5d715dad5f6c7d27259ebc1e7c0fd494bf9", + "basalt_version": "0.5.6", + "original_qwen_restored": true, + "restore_only_answer": "BEREIT", + "qwen_slots": 2, + "qwen_context_per_slot": 262144, + "root_tests": {"tests":834,"success":true,"seconds":113.482}, + "maintenance_guard_tests": {"tests":11,"success":true}, + "inkling": { + "profile_id": "1919906bd7e24d90a5dfe92db7fc9ba5", + "revision": 2, + "api_id": "inkling-2-mini", + "enabled_at_endpoint": true, + "runnable": true, + "context_per_slot": 65536, + "slots": 1, + "vision": false, + "kv": "fp8", + "actual_ready_worker_observed": true, + "file_bytes": 19606374189, + "independently_rehashed_sha256": "28ec70723feaa037942a02f55b9d5e898276f3e62a3b1fa083745f932a041b99" + }, + "hermes": { + "profile": "inkling-test", + "registered": true, + "managed_credential_resolution": true, + "provider": "Athena", + "model": "inkling-2-mini", + "context_length": 65536, + "cli_toolsets": [], + "api_toolsets": [], + "mcp_count": 0, + "max_turns": 3, + "smart_approvals": true, + "secret_redaction": true, + "config_mode": "0600", + "soul_mode": "0600", + "owner": "99:100", + "real_cli_answer": "Arbeitsspeicher ist ein schneller, flüchtiger Zwischenspeicher, während eine SSD dauerhaft Daten speichert, aber langsamer als RAM ist.", + "test_flags": "--oneshot -Q --reasoning none --max-turns 1 --run-budget 90", + "native_mac_client_tested": false + }, + "protected_state": { + "original_profile_rows_unchanged": true, + "original_endpoint_settings_unchanged_except_additional_enabled_id": true, + "audio_cpu_reasoning_policy_hashes_unchanged": true, + "tts_profile_id": "5b67537ab825493786861b278ae26cbe", + "tts_loaded": true, + "stt_profile_id": "129d5ea93fd34f1a9e5dcca7bcef5761", + "stt_loaded": true, + "healthy": true, + "oom_killed": false, + "restart_count": 0 + }, + "not_tested": ["Inkling quality or speed benchmark", "full-context input", "images", "new audio inference", "fresh Debian full restore", "Mac native profile switch"] +} diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/short_compare.py b/docs/maintenance/basalt-056-inkling-2026-11-23/short_compare.py new file mode 100644 index 0000000..c7a3590 --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/short_compare.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +"""NAS profile: exactly one authorized short API sample per invocation.""" +import argparse +import hashlib +import importlib.util +import json +from pathlib import Path +import time +import urllib.request + +BASE='http://192.168.1.212:8120' + +def main(): + p=argparse.ArgumentParser();p.add_argument('--go',action='store_true');p.add_argument('--phase',required=True);p.add_argument('--expected-version',required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args() + if not a.go:p.error('Explicit short-test Go required') + if a.output.exists():p.error('Use a new output path; do not overwrite evidence') + transport=Path('/opt/data/profiles/athena-deck/workspace/Athena-Deck/docs/maintenance/basalt-candidate-2026-11-01/paired_transport.py') + spec=importlib.util.spec_from_file_location('athena_transport',transport);assert spec and spec.loader + m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);credential=m.key() + def req(path,body=None): + q=urllib.request.Request(BASE+path,data=json.dumps(body).encode() if body is not None else None,headers={'Authorization':'Bearer '+credential,'Content-Type':'application/json'}) + with urllib.request.urlopen(q,timeout=90) as r:return json.load(r) + props=req('/props?model=flash-next-basalt');assert props['basalt']['version']==a.expected_version + # Identical synthetic fresh input and fixed output cap, no production conversation. + text='Erkläre ausführlich auf Deutsch, warum ein Backup erst nach einer erfolgreichen Wiederherstellung verlässlich ist. Nutze die folgenden synthetischen Prüfpunkte als Kontext, nicht als wörtliche Ausgabe. Schreibe einen zusammenhängenden langen Text, keine Liste.\n' + text+='\n'.join(f'Prüfpunkt {i}: Dateiintegrität, Rechte, Abhängigkeiten und Wiederherstellung auf einem leeren Zielsystem kontrollieren.' for i in range(1,97)) + body=dict(model='flash-next-basalt',messages=[dict(role='user',content=text)],temperature=0,reasoning_effort='none',max_tokens=256,stream=False) + result=dict(phase=a.phase,version=a.expected_version,payload_sha256=hashlib.sha256(json.dumps(body,sort_keys=True).encode()).hexdigest(),started_at=time.time(),requests=1,scope='single_short_prefill_decode_not_a_benchmark_suite',success=False) + try: + start=time.monotonic();reply=req('/v1/chat/completions',body);result['elapsed_s']=time.monotonic()-start + result.update(usage=reply.get('usage'),timings=reply.get('timings'),finish_reason=reply['choices'][0].get('finish_reason'),answer=reply['choices'][0]['message'].get('content')) + assert isinstance(result['answer'],str) and result['answer'].strip() + after=req('/props?model=flash-next-basalt');assert after['basalt']['loaded'] is True and after['basalt']['version']==a.expected_version + result.update(success=True,loaded_version=after['basalt']['version'],slots=after['total_slots'],context_per_slot=after['default_generation_settings']['n_ctx']) + finally: + result['finished_at']=time.time();a.output.write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n');print(json.dumps(result,ensure_ascii=False)) + +if __name__=='__main__':main() diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/test_activation.py b/docs/maintenance/basalt-056-inkling-2026-11-23/test_activation.py new file mode 100644 index 0000000..53b9f57 --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/test_activation.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +"""NAS-only synthetic activation guard tests: no SSH, Docker or production reads.""" +import copy +import importlib.util +from pathlib import Path +from typing import Any +import unittest +from unittest.mock import patch + +SPEC=importlib.util.spec_from_file_location('basalt056_activation',Path(__file__).with_name('activation.py')) +assert SPEC and SPEC.loader +activation=importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(activation) + + +class ReferencePreflight(unittest.TestCase): + def test_missing_reference_fails_before_activation(self): + import tempfile + with tempfile.TemporaryDirectory() as tmp: + with self.assertRaisesRegex(RuntimeError,'Referenzmodell'): + activation.reference_preflight(Path(tmp),{'reference_models':True}) + activation.reference_preflight(Path(tmp),{'reference_models':False}) + +class DrainGuards(unittest.TestCase): + def setUp(self): + self.drain:dict[str,Any]=dict(authenticated_status=200,origin='http://192.168.1.212:8108',checked_at=95,state='stopped',active_requests=0,scheduler=dict(active_requests=0,waiting_requests=0,tts_waiting_requests=0,stt_waiting_requests=0,switching=False)) + + def reject(self,drain): + with patch.object(activation.json,'load',return_value=drain),patch.object(activation.time,'time',return_value=100),patch.object(activation,'load') as load,patch.object(activation,'info') as info,patch.object(activation,'run') as run: + with self.assertRaises((AssertionError,KeyError)):activation.apply() + load.assert_not_called();info.assert_not_called();run.assert_not_called() + + def test_unauthenticated(self): + self.drain['authenticated_status']=401;self.reject(self.drain) + + def test_wrong_origin(self): + self.drain['origin']='https://example.invalid';self.reject(self.drain) + + def test_stale_receipt(self): + self.drain['checked_at']=1;self.reject(self.drain) + + def test_not_stopped(self): + self.drain['state']='running';self.reject(self.drain) + + def test_active_http(self): + self.drain['active_requests']=1;self.reject(self.drain) + + def test_boolean_is_not_integer_zero(self): + self.drain['active_requests']=False;self.reject(self.drain) + + def test_each_active_or_waiting_counter(self): + for key in ('active_requests','waiting_requests','tts_waiting_requests','stt_waiting_requests'): + with self.subTest(key=key): + drain=copy.deepcopy(self.drain);drain['scheduler'][key]=1;self.reject(drain) + + def test_missing_counter_is_not_idle(self): + del self.drain['scheduler']['stt_waiting_requests'];self.reject(self.drain) + + def test_switching(self): + self.drain['scheduler']['switching']=True;self.reject(self.drain) + + def test_valid_receipt_only_reaches_next_precondition(self): + with patch.object(activation.json,'load',return_value=self.drain),patch.object(activation.time,'time',return_value=100),patch.object(activation,'load',side_effect=RuntimeError('synthetic next gate')),patch.object(activation,'run') as run: + with self.assertRaisesRegex(RuntimeError,'synthetic next gate'):activation.apply() + run.assert_not_called() + + +if __name__=='__main__':unittest.main() diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/ui-activation-result.json b/docs/maintenance/basalt-056-inkling-2026-11-23/ui-activation-result.json new file mode 100644 index 0000000..ed3d06c --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/ui-activation-result.json @@ -0,0 +1,20 @@ +{ + "phase": "activated", + "image_before": "sha256:fc3cfb07b2b04fd5334cac67263a79b2dca802022b5b94539b1baaaa7bff516d", + "tag_before": "athena-deck-standalone:basalt-056-20261123", + "container_before": "2ce1468fadb349f7cc821d27947dde52d654855502cd3cd1b2718aa9a370b281", + "sandbox": "c43eb3e62fbef5a45f0831b93501a4862d1f4dcf5fb063f92f0f3f7d10e01c30", + "source_before": "35c84e690001bbf977c9d83ac2a6e8e96e0d6e72dceee2e420f5d391b91a86d1", + "source_after": "4cabc400b70fb6a95fa8b7f32c71c33e8253891851b449994d759627988b3a69", + "settings": { + "profiles.json": "c1ca85c8bbeda92c321ad335771818889f0c28374f902b687fd9db0a26f2f4a7", + "endpoint.json": "98181e6b1d254f8507aee15e4135ebeaa7c409d6cca2edd030ff25b9f51b1a61", + "audio-policy.json": "54aa6b69e3449cdd0f7049f34d818504455662ebe41da88ed4cd99953db12344", + "cpu-partition.json": "836a97564094f95850c6fa0fd3776e164e7aeff2bf4bb8a61d43ea4182cfaaec", + "reasoning-budget.json": "4884a379adf2f888415041b81ef55a01a2c22ef7a41ca1554460f410bec5cf0c" + }, + "autostart": true, + "image_after": "sha256:803aadc28939e5d9598343105ea2c5d715dad5f6c7d27259ebc1e7c0fd494bf9", + "settings_unchanged": true, + "runtime_changed": false +} diff --git a/docs/maintenance/basalt-056-inkling-2026-11-23/ui_activation.py b/docs/maintenance/basalt-056-inkling-2026-11-23/ui_activation.py new file mode 100644 index 0000000..22754be --- /dev/null +++ b/docs/maintenance/basalt-056-inkling-2026-11-23/ui_activation.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +"""ATHENA HOST: same-task Inkling presentation overlay, no runtime replacement.""" +import hashlib +import importlib.util +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys +import time +ROOT=Path('/opt/athena-deck-dev/inkling-ui-20261123') +BASE=Path('/opt/athena-deck-dev/runtime');SOURCE=Path('/opt/athena-deck-dev/source') +IMAGE='athena-deck-standalone:basalt-056-inkling-20261123' +SETTINGS=('profiles.json','endpoint.json','audio-policy.json','cpu-partition.json','reasoning-budget.json') +def sha(path): + with Path(path).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest() +def info():return json.loads(subprocess.check_output(['docker','inspect','athena-deck-dev']))[0] +def sandbox(d): + c=dict(d['Config']);c.pop('Image',None);c.pop('Hostname',None);c['Env']=sorted(c.get('Env') or []) + return hashlib.sha256(json.dumps({'config':c,'host':d['HostConfig']},sort_keys=True).encode()).hexdigest() +def run(*args,**kw):return subprocess.run(list(map(str,args)),check=True,**kw) +def main(): + b=json.load(sys.stdin);assert b['go'] is True + spec=importlib.util.spec_from_file_location('installer',SOURCE/'deploy/install.py');assert spec and spec.loader + installer=importlib.util.module_from_spec(spec);spec.loader.exec_module(installer) + cfg=installer.load_manifest(BASE);assert cfg.get('reference_models') is False + if b['phase']=='prepare': + assert set(b['files'])=={'execution_setup.py'} and not ROOT.exists() + d=info();assert d['State']['Running'];tag=d['Config']['Image'];assert subprocess.check_output(['docker','image','inspect','--format','{{.Id}}',tag],text=True).strip()==d['Image'] + ROOT.mkdir(mode=0o700);(ROOT/'image/app').mkdir(parents=True);(ROOT/'tmp').mkdir(mode=0o700);os.chown(ROOT/'tmp',65534,65534) + for n,t in b['files'].items():(ROOT/'image/app'/n).write_text(t);(ROOT/'image/app'/n).chmod(0o644) + (ROOT/'image/Dockerfile').write_text('FROM '+tag+'\nUSER root\nCOPY app/ /app/\nUSER 65534:65534\n') + run('docker','build','--network','none','--pull=false','-t',IMAGE,ROOT/'image',stdout=subprocess.DEVNULL) + probe="from pathlib import Path;import tempfile;from server import Server\nwith tempfile.TemporaryDirectory() as tmp:\n s=Server(0,state_dir=Path(tmp));s.endpoint.close();s.video.close();s.dashboard.close();s.server_close()\nprint('Isolated Server passed')" + run('docker','run','--rm','--runtime','runc','--network','none','--read-only','--user','65534:65534','--cap-drop','ALL','-e','NVIDIA_VISIBLE_DEVICES=void','-e','DECK_REQUIRE_SETUP=0','-e','DECK_NETWORK_MODE=disabled','-e','TMPDIR=/test-tmp','--mount',f'type=bind,src={ROOT}/tmp,dst=/test-tmp','--entrypoint','python3',IMAGE,'-B','-c',probe,timeout=45) + a=dict(phase='prepared',image_before=d['Image'],tag_before=tag,container_before=d['Id'],sandbox=sandbox(d),source_before=sha(SOURCE/'execution_setup.py'),source_after=sha(ROOT/'image/app/execution_setup.py'),settings={n:sha(BASE/'state'/n) for n in SETTINGS},autostart=json.loads((BASE/'state/endpoint.json').read_text())['autostart']) + (ROOT/'receipt.json').write_text(json.dumps(a,indent=2));print(json.dumps({'phase':'prepared','image':IMAGE,'runtime_changed':False}));return + assert b['phase']=='apply';d=b['drain'];assert d['authenticated_status']==200 and d['origin']=='http://192.168.1.212:8108' and 0<=time.time()-d['checked_at']<60 and d['state']=='stopped' + assert type(d['active_requests']) is int and d['active_requests']==0 and d['scheduler']['switching'] is False + assert all(type(d['scheduler'][k]) is int and d['scheduler'][k]==0 for k in ('active_requests','waiting_requests','tts_waiting_requests','stt_waiting_requests')) + a=json.loads((ROOT/'receipt.json').read_text());live=info();assert a['phase']=='prepared' and live['Id']==a['container_before'] and live['Image']==a['image_before'] + assert sha(SOURCE/'execution_setup.py')==a['source_before'] and all(sha(BASE/'state'/n)==v for n,v in a['settings'].items() if n!='endpoint.json') + run('docker','stop','--timeout','45','athena-deck-dev',stdout=subprocess.DEVNULL) + shutil.copy2(ROOT/'image/app/execution_setup.py',SOURCE/'execution_setup.py') + ep=BASE/'state/endpoint.json';data=json.loads(ep.read_text());data['autostart']=a['autostart'];tmp=ep.with_suffix('.ui-tmp');tmp.write_text(json.dumps(data));tmp.chmod(0o600);os.chown(tmp,65534,65534);tmp.replace(ep);assert sha(ep)==a['settings']['endpoint.json'] + cfg.update(image=IMAGE,previous_image=a['tag_before']);run('docker','rm','athena-deck-dev',stdout=subprocess.DEVNULL);installer.launch(cfg);installer.ready(cfg);installer.write_manifest(BASE,cfg) + new=info();assert sandbox(new)==a['sandbox'] and all(sha(BASE/'state'/n)==v for n,v in a['settings'].items()) + a.update(phase='activated',image_after=new['Image'],settings_unchanged=True,runtime_changed=False);(ROOT/'receipt.json').write_text(json.dumps(a,indent=2));print(json.dumps(a)) +if __name__=='__main__':main() diff --git a/execution_setup.py b/execution_setup.py index 010fbb9..62fa548 100644 --- a/execution_setup.py +++ b/execution_setup.py @@ -119,14 +119,16 @@ def _assess_candidates(model, installed, profile=None): if result['state']=='component':return result if model.get('kind')=='chat' and model.get('file','').lower().endswith('.basalt'): from basalt_runtime import RECIPE - source=model.get('download_source') or model;pin=RECIPE['model'] - if any(source.get(k)!=pin[k] for k in ('repo','revision','file')) or any(k in model and model[k]!=pin[k] for k in ('sha256','size')): + source=model.get('download_source') or model + pin=next((p for p in (RECIPE['model'],*(RECIPE.get('additional_models') or {}).values()) if all(source.get(k)==p[k] for k in ('repo','revision','file')) and all(k not in model or model[k]==p[k] for k in ('sha256','size'))),None) + if pin is None: result.update(message='Basalt ist angebunden, aber dieses Paket ist nicht das geprüfte feste IQ3_XXS-Rezept. Kein automatischer Start mit llama.cpp.',candidate_message='Unter Basalt das geprüfte vollständige Paket einrichten.') return result ready=bool(installed.get('basalt')) result.update(family='Flash-Next GSQ-RCO IQ3_XXS',evidence='Fest gepinntes Basalt-Modellpaket; vollständige Größe und SHA-256 beim Download',runtime='Basalt',route='#basalt-runtime',installed=ready,state='setup' if ready else 'runtime_missing',label='Basalt · Text',components=[],message='Eine SM120-GPU und RAM-Experten, bis zwei vollständige Kontext-Slots. Tokenizer und MTP sind im Paket enthalten; keine separaten GGUF-Shards oder Projektor-Zuordnungen. TTS/Vision werden nicht umgestellt.') result['candidates']=[dict(id='basalt',label='Basalt',installed=ready,route='#basalt-runtime',installation_available=True,evidence=result['evidence'])] result.update(label='Basalt · Text und optional Vision',message='Text auf einer SM120-GPU mit RAM-Experten und bis zwei vollständigen Kontext-Slots. Optionaler Vision-Sidecar auf separater SM86/SM120-GPU (RTX 3060), mit festem BF16-Projektor. Tokenizer, MTP und identischer Projektor im Paket; keine GGUF-Shards. TTS wird nicht verändert.') + if pin!=RECIPE['model']:result.update(family='Inkling 2 Mini',label='Basalt · Inkling Text',message='Inkling 2 Mini auf einer SM120-GPU mit FP8-Kontextcache und automatischer CPU-Expertenauslagerung. Das erste Testprofil ist text-only und verwendet keinen Qwen-Projektor. Kontext und Slots folgen dem gespeicherten Profil.') if profile:result.update(state='ready' if profile.get('runnable') else 'profile_incomplete',blockers=profile.get('blockers',[])) return result kind=model.get('kind');repo=model.get('repo','').lower();name=model.get('file','').lower() diff --git a/test_basalt_inkling.py b/test_basalt_inkling.py new file mode 100644 index 0000000..8afa0d9 --- /dev/null +++ b/test_basalt_inkling.py @@ -0,0 +1,59 @@ +"""Synthetic pinned Inkling contract, no GPU or model requests.""" +import copy +import tempfile +import unittest +from pathlib import Path +from unittest.mock import Mock +from basalt_runtime import RECIPE, BasaltRuntime, validate_model + +INKLING = dict(repo='jesdga/Inkling-2-Mini-Basalt',revision='6c9fbf0730a6d2e8813a1b262c2ab3548cf0239e',file='Inkling-2-Mini-NVFP4-MX8.basalt',size=19606374189,sha256='28ec70723feaa037942a02f55b9d5e898276f3e62a3b1fa083745f932a041b99') + +class InklingTests(unittest.TestCase): + def test_pinned_inkling_is_accepted_without_weakening_identity(self): + self.assertEqual(validate_model(INKLING),RECIPE['additional_models']['inkling2']) + for key,value in [('repo','other/model'),('revision','0'*40),('size',1),('sha256','0'*64),('file','other.basalt')]: + with self.subTest(key=key),self.assertRaises(ValueError):validate_model({**INKLING,key:value}) + validate_model(RECIPE['model']) + + def test_prepared_checks_the_selected_pack_size(self): + with tempfile.TemporaryDirectory() as tmp: + catalog=Mock(root=Path(tmp)/'models');entry={**INKLING,'id':'a'*64} + path=catalog.root/entry['id']/'model.basalt';path.parent.mkdir(parents=True) + with path.open('wb') as f:f.truncate(INKLING['size']) + self.assertEqual(BasaltRuntime(Path(tmp)/'runtime',catalog).prepared(entry),path) + path.write_bytes(b'bad') + with self.assertRaises(ValueError):BasaltRuntime(Path(tmp)/'runtime',catalog).prepared(entry) + + def test_inkling_configuration_does_not_inherit_qwen_flags(self): + from basalt_worker import BasaltWorker + p=dict(api_id='inkling-2-mini',parameters=dict(context=32768,slots=1)) + c=BasaltWorker.configuration(p,Path('/model.basalt'),12345,700,model_family='inkling2') + self.assertEqual(c['engine']['kv'],'fp8') + self.assertEqual(c['engine']['max-context'],32768) + self.assertEqual(c['models'][0]['vision'],'off') + for flag in ('resident-experts','expert-cache','prefill'): + self.assertNotIn(flag,c['engine']) + cmd=BasaltWorker.server_command(Path('/python'),Path('/source'),Path('/worker.json'),'synthetic',model_family='inkling2') + self.assertNotIn('--expert-profile',cmd) + + def test_saved_inkling_identity_reaches_worker_config_and_command(self): + import json + from unittest.mock import patch + from basalt_worker import BasaltWorker + with tempfile.TemporaryDirectory() as tmp: + catalog=Mock();catalog.entry.return_value={**INKLING,'id':'a'*64} + runtime=Mock();runtime.paths.return_value=(Path('/python'),Path('/source'));runtime.prepared.return_value=Path('/model.basalt');runtime.root=Path(tmp)/'runtime' + w=BasaltWorker(Path(tmp)/'worker',catalog,runtime) + p=dict(id='synthetic',revision=1,api_id='inkling-2-mini',model_id='a'*64,parameters=dict(context=32768,slots=1,gpu_devices=['synthetic-gpu'])) + def plan(*args):w.memory_plan={'reserve_mib':[700]} + response=Mock();response.__enter__=Mock(return_value=response);response.__exit__=Mock(return_value=False) + props=dict(is_sleeping=False,total_slots=1,default_generation_settings={'n_ctx':32768},basalt=dict(version=RECIPE['version'],capabilities=[])) + with patch.object(w,'plan',side_effect=plan),patch('basalt_worker.cpu_partition.load',return_value=None),patch('basalt_worker.subprocess.Popen') as popen,patch('basalt_worker.urllib.request.urlopen',return_value=response),patch('basalt_worker.json.load',return_value=props): + popen.return_value.poll.return_value=None + w.ensure(p) + cfg=json.loads((w.root/'worker.json').read_text()) + self.assertEqual(cfg['engine']['kv'],'fp8') + self.assertNotIn('--expert-profile',popen.call_args.args[0]) + self.assertEqual(w.memory_plan['kv'],'fp8') + +if __name__=='__main__':unittest.main() diff --git a/test_inkling_presentation.py b/test_inkling_presentation.py new file mode 100644 index 0000000..f842402 --- /dev/null +++ b/test_inkling_presentation.py @@ -0,0 +1,18 @@ +"""CPU-only recognition of the strictly pinned additional Basalt model.""" +import unittest +from basalt_runtime import RECIPE +from execution_setup import _assess_candidates + +class InklingPresentation(unittest.TestCase): + def test_inkling_is_a_basalt_candidate_not_an_unknown_qwen_pack(self): + m={**RECIPE['additional_models']['inkling2'],'kind':'chat','role':'model','profile_eligible':True} + r=_assess_candidates(m,{'basalt':True},{'runnable':True,'blockers':[]}) + self.assertEqual(r['family'],'Inkling 2 Mini') + self.assertEqual(r['runtime'],'Basalt') + self.assertEqual(r['candidates'][0]['id'],'basalt') + self.assertNotIn('Sidecar',r['message']) + self.assertNotIn('RTX 3060',r['message']) + wrong=_assess_candidates({**m,'sha256':'0'*64},{'basalt':True}) + self.assertEqual(wrong['candidates'],[]) + +if __name__=='__main__':unittest.main()