Record authorized Basalt 0.3.3 activation and restored Qwen readiness

This commit is contained in:
Mikei386 committed 2026-11-13 14:27:24 +01:00
1 parent 34e711721a
commit 78b9d52d5f
6 files changed
+304 -36

No files matched your search

+23 -3
View File
@@ -5,7 +5,27 @@ curated project handoff, not imported chat history. Read applicable `AGENTS.md`,
then the current source and relevant linked documentation; verify live state
again before changing anything. Historical notes do not override current facts.
## Basalt 0.3.3 staged: new runtime and Deck media/control integration
## Basalt 0.3.3 activated after explicit Go · 13 November, 13:20 UTC
Michael requested immediate activation, then completed normal management login.
Fresh authenticated zero active/waiting chat/TTS/STT counters and switching=false
preceded the ordinary endpoint stop. Overlay of16 frozen source files from
`34e711721a5238f763e4eab62a0eaf1f93cbc75b` passed a full isolated Server startup.
App image `sha256:a4108ac04613cc4c9790660171544ede858da09a7d1fcc422676405bb49d8bf7`
and the verified0.3.3 runtime activated together; healthy, same container sandbox,
all5 protected settings hashes unchanged. Original Qwen restored by one normal
API request: real BEREIT answer, request ID, loaded0.3.3, one slot/context262144.
New actual text-process hash matches the0.3.3 build. No benchmark or video/audio
test series; broad model/media/answer-now/audio and native full-restore gates open.
Old image/runtime retained. **Do not remove**
`state/basalt-runtime.previous-030-34e7117`: the active runtime's CUDA13 symlink
still points to its immutable toolkit. Fresh native restore uses the fixed
toolkit recipe instead. Restart invalidated the old management session; model
operation is restored, another login is only for GUI/admin operations.
[Actual activation receipt and limits](maintenance/basalt-033-staged-2026-11-13/activation-result.json).
## Basalt 0.3.3 preparation before activation
Maintained recipe now pins `2729e2288f59e01836ddd7fcc630810ada98995a` /
0.3.3, with the same v2 model/config and existing expert/cache policy. Own bounded
@@ -22,8 +42,8 @@ timed out after emitting all successful gates and hit an auto/manual-remove race
owned sandbox absence verified, helper fixed with5 local regressions, not rerun.
Both the successful checks and failed controller closure are recorded. These are
not real0.3.3 inference, NVDEC or a fresh native Debian/full-restore acceptance.
No0.3.3 production activation or new-model benchmark has been authorized here.
The last verified production remains healthy0.3.0/original model/allCPU/one slot,
During preparation no0.3.3 activation or new-model benchmark was authorized.
The protected preparation baseline was healthy0.3.0/original model/allCPU/one slot,
same image/start/protected settings. Keep that pair for rollback, preserve Qwen
and audio; future app/runtime activation needs a separate Go and normal drain.
[Build, contracts, checks, execution environments and open gates](maintenance/basalt-033-staged-2026-11-13/README.md).
+19 -15
View File
@@ -1,20 +1,24 @@
## Basalt 0.3.3 prepared; production 0.3.0 deliberately unchanged
## Basalt 0.3.3 active · 13 November 2026, 13:20 UTC
The new recipe/runtime candidate and Deck source support bounded documents and
video, capabilities/logprobs, principal-scoped request/session IDs and answer-now,
including testchat controls. TextSM120 and visionSM86/SM120 built and independently
inspected; pypdf7.0.1/FFmpeg6 ABI, 827 Root tests and 11/11 browser-mock gates passed.
The exact-index suite passed. Pinned-upstream CPU-mock:1102 tests,6skips,no failures.
All8 feature gates passed before the hostcontroller's timeout/auto-remove race;
own container absent, helper fixed and5 local unit tests passed. This failed
controller closure is retained separately, not hidden by the successful tests.
Explicit activation Go and normal management login, ordinary authenticated drain
with fresh zero active/waiting counters. App image
`sha256:a4108ac04613cc4c9790660171544ede858da09a7d1fcc422676405bb49d8bf7`
contains16 frozen source files from `34e7117`; complete isolated Server startup
passed before activation. Runtime0.3.3 adopted with textSM120/visionSM86+120,
pypdf7.0.1 and FFmpeg6 ABI. Actual new text-process binary hash matches the build.
No production image/runtime activation, weight download, profile change, service
restart or real0.3.3 inference. The running Basalt0.3.0/original Qwen/allCPU/one-slot
pair and existing audio remain the protected baseline and rollback. New app-code
activation and model/NVDEC/audio acceptance need a separate Go and ordinary
authenticated drain. Fresh Debian/systemd/full encrypted restore still unproven.
[Prepared artifact, contracts, native recipe and acceptance limits](maintenance/basalt-033-staged-2026-11-13/README.md).
Original Qwen is resident and answered BEREIT through the normal API, with a
request ID and loaded0.3.3 properties; one slot/context262144. Same model,
profiles, endpoint/audio/CPU/reasoning settings (all5 file hashes), same container
sandbox. New bounded media/logprobs/session/answer-now/testchat code is installed;
not a fresh real-video/answer-now/audio or performance acceptance. No weight
download, quantization or profile change. Fresh Debian/full encrypted restore open.
Old0.3.0 image/runtime retained for separately authorized rollback. Preserve
`state/basalt-runtime.previous-030-34e7117`: active CUDA13 symlink depends on it.
The fixed native recipe reconstructs its own toolkit on a fresh host. Restart
invalidated the management login; model API is restored, GUI may need re-login.
[Activation, build/contract checks and remaining limits](maintenance/basalt-033-staged-2026-11-13/README.md).
## 9.11.2026 · Basalt all-CPU/one-slot configuration active
@@ -1,13 +1,37 @@
# Basalt 0.3.3: Laufzeitkandidat und Deck-Funktionen
## Ergebnis und klare Betriebsgrenze
## Aktiviert nach separatem Go · 13. November 2026, 13:20 UTC
Der Auftrag umfasst **bauen und in Deck implementieren**, nicht das ungefragte
Umschalten des laufenden Dienstes. Basalt0.3.3 wurde isoliert gebaut; die neuen
Deck-API-/Testchatfunktionen liegen im Quellcode. **Die Produktion bleibt beim
bisherigen Basalt0.3.0, demselben Modell und der all-CPU-/Ein-Slot-Konfiguration.**
Michael forderte die Umstellung und bestätigte anschließend die reguläre
Verwaltungsanmeldung. Frische authentifizierte Integer-Nullen für laufende und
wartende Chat-/TTS-/STT-Arbeit sowie `switching=false` vor dem normalen Stop.
App-Overlay aus16 eingefrorenen Dateien von `34e7117` vollständig isoliert
gestartet, dann App/Runtime gemeinsam aktiviert; gleiche Container-Sandbox,
gesund, alle5 geschützten Einstellungsdateien unverändert. Qwen wieder resident:
**eine echte BEREIT-Antwort**, Request-ID und `/props` mit geladenem0.3.3,
**ein Slot/262144 Kontext**. Reale Prozessbinärhashes entsprechen dem Build.
Kein Benchmark und keine erneute Medien-/Audio-Testserie.
[Aktivierungsbeleg](activation-result.json), [Athena-Operatorhelfer](activation.py).
Der Helfer läuft nur auf Athena mit explizitem `--go`; `prepare` bekommt einen
Source-only-Bundle, `apply` frische normale Drain-Metadaten. Keine Adminumgehung.
Die erste Stop-Antwort ging im Browsertransport verloren; vor jeder weiteren
Aktion wurde der tatsächlich gestoppte Zielzustand gelesen, nicht blind wiederholt.
Altes Image und `state/basalt-runtime.previous-030-34e7117` sind erhalten.
**Nicht entfernen:** Die aktive CUDA13-Verknüpfung zeigt auf dessen Toolkit.
Native Neuinstallation/Restore verwenden das feste eigene Toolkit-Rezept.
Der App-Neustart beendet die alte Websitzung; eine neue Anmeldung betrifft nur
GUI/Adminaktionen, nicht die inzwischen wieder funktionierende Modell-API.
## Vorbereitungsphase vor der Aktivierung
Der erste Auftrag umfasste **bauen und in Deck implementieren**, nicht das
ungefragte Umschalten des Dienstes. Basalt0.3.3 wurde zunächst isoliert gebaut;
während dieser Phase blieb die Produktion bei Basalt0.3.0, demselben Modell und
der all-CPU-/Ein-Slot-Konfiguration. Die spätere autorisierte Aktivierung steht oben.
Kein echter Modellstart, GPU-Inferenzlauf, Benchmark, neues TTS-Profil oder
Produktions-/Container-/Gatewayneustart gehört zu dieser Vorbereitung.
Produktions-/Container-/Gatewayneustart gehörte zu dieser Vorbereitung.
- Upstream: [Basalt v0.3.3](https://github.com/jesdga95/basalt/releases/tag/v0.3.3).
- Source-Pin: `2729e2288f59e01836ddd7fcc630810ada98995a`.
@@ -144,12 +168,13 @@ Prompts oder Zugangsdaten in den Ergebnisbeleg geschrieben.
## Aktivierung, Rückfall und ausdrücklich offene Gates
**Dieses Ergebnis ist keine Aktivierungserlaubnis.** Eine spätere Übernahme
braucht Michaels separates Go, normale Management-Anmeldung, frischen Nachweis
**Die Vorbereitung war keine Aktivierungserlaubnis.** Die oben dokumentierte
Übernahme erhielt später Michaels separates Go; weitere Umstellungen brauchen
ein neues Go, normale Management-Anmeldung, frischen Nachweis
für aktive **und wartende** Arbeit sowie ein abgestimmtes Audiofenster. Stop
kann auch Audio entladen. App-Code und passendes Runtime-Rezept müssen zusammen
umgestellt werden; ein bloßes Worker-Neuladen installiert diese Python-/UI-
Änderungen nicht. Noch kein neues produktives App-Image aus diesem Stand aktiviert.
Änderungen nicht. Das oben benannte App-Image ist inzwischen aktiviert.
Altes Basalt0.3.0-App-/Runtime-Paar, dieselben Gewichte und Ein-Slot-/CPU-
Konfiguration bleiben der Rückfall. Kein stilles Wechseln auf Strata, Lamina,
@@ -157,8 +182,8 @@ ein anderes Modell oder eine andere Quantisierung. Das heutige private Toolkit
muss nativ aus dem festen Rezept rekonstruierbar sein; die geliehene CUDA-Quelle
des Kandidaten ist kein verstecktes dauerhaftes Restore-Erfordernis.
**Nicht abgenommen:** echte0.3.3-Modell-/NVDEC-Inferenz und Audio-Koexistenz,
Geschwindigkeitsgewinn, volle262144 Token oder Last-/Dauertest, produktive UI,
**Nicht abgenommen:** breite0.3.3-Modell-/Dokument-/Answer-now-/NVDEC- und Audiotests,
Geschwindigkeitsgewinn, volle262144 Token oder Last-/Dauertest, neue produktive UI-Bedienung,
Mac-Client sowie frisches Debian/systemd mit vollständigem verschlüsseltem
Restore. Der Basisinstaller bleibt der dokumentierte offene Produktumfang;
Container- und Dateiprüfungen ersetzen ihn nicht.
@@ -0,0 +1,98 @@
{
"authorization": "Michael explicitly requested activation and then confirmed normal management login",
"source_commit": "34e711721a5238f763e4eab62a0eaf1f93cbc75b",
"activated_at_utc": "2026-11-13T13:20:22.424281+00:00",
"host": {
"phase": "activated_and_qwen_restored",
"container_before": "788723c2fc2f4cae707147d1d339294546bce9ec6011c0fa16dbb2a13ad10976",
"image_before": "sha256:0a358dd687a415faf26cea2d73160654fb9b2e56ad68c7013bef52bc166fed33",
"tag_before": "athena-deck-standalone:basalt-030-turbo",
"started_before": "2026-11-09T16:02:55.751847414Z",
"image_after": "sha256:a4108ac04613cc4c9790660171544ede858da09a7d1fcc422676405bb49d8bf7",
"settings": {
"profiles.json": "2d7602a18d08b0916ebd6ed794ff1246d9766aab02e26047e862602233bb775c",
"endpoint.json": "98181e6b1d254f8507aee15e4135ebeaa7c409d6cca2edd030ff25b9f51b1a61",
"audio-policy.json": "f48dedea718968c00c0647ca90c1402bdabac9ce600dbeddc495817680527a3f",
"cpu-partition.json": "836a97564094f95850c6fa0fd3776e164e7aeff2bf4bb8a61d43ea4182cfaaec",
"reasoning-budget.json": "4884a379adf2f888415041b81ef55a01a2c22ef7a41ca1554460f410bec5cf0c"
},
"autostart": true,
"source_before": {
"api_compat.py": "307f97b33dce3c9187c16c449cc3beff81c4dd26209392c16597f0c1e7747111",
"basalt_runtime.py": "cf09ab7447b6e48cb67a164b1264534aef32d6a6209b0b87dec6551051270af9",
"basalt_serve.py": "03863add9614e9cc480171a45945a660ac49a21d12d8f33059971bb9e71776cb",
"basalt_sources.json": "f42c6a51c5d1755a3a5917650a387bf8ae967e5c421402f49556eb5bab9c5194",
"basalt_tuning.py": "f2585dab9581ce8c8b3712c4ee9f9a98d5b58d41ce11f9f8ab5b17f429e0dfdf",
"basalt_worker.py": "e24f11643d9ce7b1870ad8830b595b55e752b7ad1ecf3ae67b4b0e0d2514f2e1",
"chat-test-ui.js": "b70ea28089e1cca29f9d796d63238581de8e7bbd0e4f4ef9b301e95478d68d45",
"chat_control.py": null,
"chat_media.py": null,
"chat_test.py": "4da96d1bef004f0c0f062a877ae33b0bc01940f20f1174c882b2ed6f7c566079",
"deploy/install.py": "9283b986918ebfd670a3d43c6bc68ab33374229d3b9b764c913d3db0eb0aad34",
"deploy/install_basalt.py": "23d8ffeef9d97f5630b0bce8648a3f41c98170c2a774cee2e7908627387f7a6e",
"endpoint.py": "c3b3e7bf9e1a83c9f4d227695bafba061093d739ca1251ad1d6f4a0a8149585a",
"responses_compat.py": "f16020e60155471673e2f1c24430ef6ae96334062b480a97edd58c1f8e691543",
"server.py": "6a9c1cad0c03031ee4f09af2f98a7ec4a310b268d3ef7064b8392979d9cabf02",
"strata_worker.py": "3d2265124c1c19246e6269c0d695efb343730255af376a2a8bf18005ebf55fda"
},
"source_after": {
"api_compat.py": "729eef3614688fb06ef2f64409c31be7672c0f92fa66c84887e3262c75341cae",
"basalt_runtime.py": "e3078aa2a7aa2052a9ffcbcab056a4d134ed156e427ee2cef0679a91e935e701",
"basalt_serve.py": "03863add9614e9cc480171a45945a660ac49a21d12d8f33059971bb9e71776cb",
"basalt_sources.json": "e2c0ca28dce89aea30b7ba0be4d05641687938fe9b08e485830c4635bb1ae30f",
"basalt_tuning.py": "f2585dab9581ce8c8b3712c4ee9f9a98d5b58d41ce11f9f8ab5b17f429e0dfdf",
"basalt_worker.py": "0df07b59c85136bacaf95a87095867796f1d124a8df895d3a92406dc4057e9b7",
"chat-test-ui.js": "cb299f33c527535ebdbd9f404506f32ca1b47fd4d0a4a1cba815a7c32cd7773b",
"chat_control.py": "5efad2c742ba893e22d926fe38cfe31c16eb0e35b1accd2556899ad348bc7923",
"chat_media.py": "7d3e6954cd6f4140a97b3991edeb266c5cac19cb781cb9927647c0f21992c06c",
"chat_test.py": "02754ae25f8f7e6ad14785f7e2102dbb818f4a5a118abf13b47bfbba779325ab",
"deploy/install.py": "e342ddfdf9fa77492c568342e68024e5864e09e68ab3c77b5ca61390b3f99ad5",
"deploy/install_basalt.py": "7e81efe44224707c5b3b5417382381113b263bf6532060f8c80b4e1eed4748e5",
"endpoint.py": "22614fce51e306a3e312485fbb103863ca702dfa6361280d84beb4f4fa091684",
"responses_compat.py": "08e2fdaeb5b1b670a390dc8f2330ebc0825410d0b17d911e9c9f3f602366640f",
"server.py": "c73206dbac9ff21cdfb266b67d678a5e4aec79fa92ffbb918f8273df5c01478b",
"strata_worker.py": "b20b274c97c34641f2c2a0837207a3e6d371098ee5c74f084ce053039b76db3b"
},
"prepared_at": 1794575802.8311844,
"model_weights_changed": false,
"activated_at": 1794576022.4242811,
"container_after": "e81775cc39405d8e15404a913c42d5ad4ce159fd9f03eddf68f9f6394ce9abe2",
"settings_unchanged": true,
"model_readiness": "Confirmed by one normal API completion, receipt kept separately",
"final_checked_at": 1794576193.0664594,
"text_workers": [
{
"pid": 149531,
"gpu_uuid": "GPU-8ad38c6c-5a01-9d8e-1dfa-ed662ad78fbe",
"binary_hash_matches": true
}
],
"healthy": true,
"source_hashes_match": true,
"legacy_runtime_retained": true,
"cuda_dependency": "../basalt-runtime.previous-030-34e7117/cuda"
},
"readiness": {
"phase": "activated_and_original_qwen_ready",
"version": "0.3.3",
"loaded": true,
"slots": 1,
"context_per_slot": 262144,
"readiness_answer_confirmed": true,
"request_id_received": true,
"capabilities": [
"answer_now",
"logprobs",
"documents",
"video"
],
"inference_requests_sent": 1,
"benchmark": false,
"media_audio_acceptance_run": false,
"finished_at": 1794576127.109771
},
"real_video_or_audio_acceptance": false,
"benchmark": false,
"native_debian_full_restore": false,
"management_session_invalidated_by_restart": true
}
@@ -0,0 +1,110 @@
#!/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-033-activation-34e7117')
CANDIDATE=Path('/opt/athena-deck-dev/basalt-033-candidate-2729e2288f59/runtime')
BASE=Path('/opt/athena-deck-dev/runtime');STATE=BASE/'state';SOURCE=Path('/opt/athena-deck-dev/source')
NEXT=STATE/'basalt-runtime.next-033-34e7117';PREVIOUS=STATE/'basalt-runtime.previous-030-34e7117'
IMAGE='athena-deck-standalone:basalt-033-34e7117'
CODE='2729e2288f59e01836ddd7fcc630810ada98995a'
FILES=('api_compat.py','basalt_runtime.py','basalt_serve.py','basalt_sources.json','basalt_tuning.py','basalt_worker.py','chat-test-ui.js','chat_control.py','chat_media.py','chat_test.py','deploy/install.py','deploy/install_basalt.py','endpoint.py','responses_compat.py','server.py','strata_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 prepare():
bundle=json.load(sys.stdin);assert set(bundle['files'])==set(FILES)
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.3.3'
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.3.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','--time','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()<deadline:time.sleep(1)
live=info();assert live['State']['Health']['Status']=='healthy' and live['Image']==a['image_after']
assert sandbox(live)==original,'Container sandbox differs; no automatic second restart'
assert all(sha(SOURCE/n)==a['source_after'][n] for n in FILES) and all(sha(STATE/n)==a['settings'][n] for n in SETTINGS)
save(dict(a,phase='activated_model_restoration_pending',activated_at=time.time(),container_after=live['Id'],settings_unchanged=True,model_weights_changed=False))
print(json.dumps({'phase':'activated_model_restoration_pending','healthy':True,'version':'0.3.3','settings_unchanged':True,'image':live['Image']}),flush=True)
if __name__=='__main__':
p=argparse.ArgumentParser();p.add_argument('phase',choices=('prepare','apply'));p.add_argument('--go',action='store_true');args=p.parse_args();assert args.go,'Explicit activation Go required';globals()[args.phase]()