From 8f1a4bbd1b5f6dcad003fd98e56472fb858de09b Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 4 Oct 2026 11:08:44 -0500 Subject: [PATCH] scripts: no Python; awk manifest sync, drop MAX-era mac-platform-proxy.sh sync-standalone-repos.sh: the [package] license/version/edition sync is now awk (same results on parity, drift, license.workspace, missing license, missing workspace license). mac-platform-proxy.sh supervised a Mac tunnel to the retired Modular MAX engine and shelled out to python3; the MAX yardstick lives outside sovereign-core now. Co-Authored-By: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .crumb | 16 +-- scripts/.crumb | 10 +- scripts/mac-platform-proxy.sh | 185 ------------------------------- scripts/sync-standalone-repos.sh | 156 ++++++++++---------------- 4 files changed, 71 insertions(+), 296 deletions(-) delete mode 100755 scripts/mac-platform-proxy.sh diff --git a/.crumb b/.crumb index 761a20d6..1db85c2b 100644 --- a/.crumb +++ b/.crumb @@ -64,8 +64,8 @@ "generated": { "children": [ { - "digest": "5b53b3617b045ba9e00445ec9f4ed4e312eea1791cf76542140d145587c600bb", - "last_commit": "0b09fe0", + "digest": "de0f2dbec5082b4c2d0708fb10d51502d7cdf113fe2abcc9ac98b6d43cb70dca", + "last_commit": "f93f8f5", "name": "scripts", "purpose": "" }, @@ -76,15 +76,15 @@ "purpose": "" } ], - "children_root": "sha256:38c77df15675007bb39b5fdbc1fb61901835486fa3191a89a36000628b77df90", - "compiled_at": "2026-10-04T16:03:49Z", + "children_root": "sha256:bf3a85d165c2729e32156e011342777ee2cd1b8c6a3676988ea69296aa3a5b49", + "compiled_at": "2026-10-04T16:20:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:d56dbfc6a247cafe7f00c57d97dc96838030432843e10ef5889c3c4b4bf6d011", + "digest": "sha256:4be37fc7b0c699153bb2dfa083cf160d4631c32f26384d56098ed8d4913bb808", "evidence_files": 19, "evidence_root": "sha256:4fc93bc0533be92440e419df17436410d35e5972b340c3a281f6a1bb86693ee2", - "files": 664, - "generated_at_commit": "0b09fe012ccd0a3d3a1c046ac3a30a5e1ae39dea", - "source_tree": "sha256:66e2ad64bc4f5c396d2f4f2bf79e52b7dae2ddaabe2b78c7df85c4c47abdd0ef" + "files": 663, + "generated_at_commit": "f93f8f5246881c097f4fdfd1fc14acc4b1f0cf75", + "source_tree": "sha256:e0a1e9824b4c43deaece5ccf4fe9119e978ad215b54e94c84f14a6ff04b501d4" } }, "history": [], diff --git a/scripts/.crumb b/scripts/.crumb index a39b5cf3..8ecedc05 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -4,14 +4,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T16:03:49Z", + "compiled_at": "2026-10-04T16:20:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:5b53b3617b045ba9e00445ec9f4ed4e312eea1791cf76542140d145587c600bb", + "digest": "sha256:de0f2dbec5082b4c2d0708fb10d51502d7cdf113fe2abcc9ac98b6d43cb70dca", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 16, - "generated_at_commit": "0b09fe012ccd0a3d3a1c046ac3a30a5e1ae39dea", - "source_tree": "sha256:0c30da541a39cdb4664ca894061f23c7e46572975c74802934dd2a0760731815" + "files": 15, + "generated_at_commit": "f93f8f5246881c097f4fdfd1fc14acc4b1f0cf75", + "source_tree": "sha256:39e8e539eb93f627a55368a5bc91b17f56975a213724948f8b72a5d335dbc59a" } }, "parent": { diff --git a/scripts/mac-platform-proxy.sh b/scripts/mac-platform-proxy.sh deleted file mode 100755 index af96c64f..00000000 --- a/scripts/mac-platform-proxy.sh +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env bash -# mac-platform-proxy: Mac platform proxy adapter for NVIDIA DGX Spark Modular MAX NVFP4 engine. -# Supervises and verifies the local localhost:18006 tunnel to DGX Spark port 18006. -set -euo pipefail - -PLIST_NAME="com.atlas.spark-model-api" -PLIST_PATH="$HOME/Library/LaunchAgents/${PLIST_NAME}.plist" -LOCAL_PORT="18006" -REMOTE_HOST="100.116.106.93" -REMOTE_PORT="18006" -MODEL_ENDPOINT="http://localhost:${LOCAL_PORT}/v1" -SERVED_MODEL="atlas-lightning-omni" - -usage() { - cat < - -Commands: - status Show current adapter daemon status, listening ports, and health - start Load and start the launchd platform proxy adapter - stop Unload and stop the launchd platform proxy adapter - restart Restart the platform proxy adapter - test Execute an end-to-end inference round-trip verification - bench Measure latency, TTFT, and response throughput from Mac to Spark -EOF -} - -cmd_status() { - echo "=== Mac Platform Proxy Adapter Status ===" - echo "Service: ${PLIST_NAME}" - echo "Local Bind: localhost:${LOCAL_PORT} (and 18002)" - echo "Target: drakestapleton@${REMOTE_HOST}:${REMOTE_PORT}" - echo "" - - # Launchctl status - echo "--- Launchd Status ---" - local svc_info - svc_info=$(launchctl list | grep "${PLIST_NAME}" || true) - if [[ -n "$svc_info" ]]; then - echo "Active: Yes" - echo "Launchd Entry: $svc_info" - else - echo "Active: No (not loaded in launchd)" - fi - echo "" - - # Port listeners - echo "--- Port Listeners ---" - if lsof -i :${LOCAL_PORT} -sTCP:LISTEN >/dev/null 2>&1; then - lsof -i :${LOCAL_PORT} -sTCP:LISTEN - else - echo "Port ${LOCAL_PORT} is NOT listening." - fi - echo "" - - # Health Check - echo "--- Model Stack Health ---" - local models_resp - if models_resp=$(curl -s -m 5 "${MODEL_ENDPOINT}/models" 2>&1); then - echo "HTTP Status: OK" - echo "Catalog: $models_resp" - else - echo "Health check failed: $models_resp" - fi -} - -cmd_start() { - echo "Starting Mac platform proxy adapter (${PLIST_NAME})..." - if [[ ! -f "$PLIST_PATH" ]]; then - echo "Error: plist file missing at $PLIST_PATH" >&2 - exit 1 - fi - launchctl load -w "$PLIST_PATH" - sleep 1 - cmd_status -} - -cmd_stop() { - echo "Stopping Mac platform proxy adapter (${PLIST_NAME})..." - launchctl unload "$PLIST_PATH" || true - sleep 1 - echo "Adapter stopped." -} - -cmd_restart() { - cmd_stop - cmd_start -} - -cmd_test() { - echo "Running end-to-end inference verification..." - local start_ts - start_ts=$(python3 -c 'import time; print(time.time())') - - local resp - resp=$(curl -s -m 30 -X POST "${MODEL_ENDPOINT}/chat/completions" \ - -H "Content-Type: application/json" \ - -d "{ - \"model\": \"${SERVED_MODEL}\", - \"messages\": [{\"role\": \"user\", \"content\": \"Reply with exactly: PLATFORM_PROXY_OK\"}], - \"max_tokens\": 16, - \"temperature\": 0 - }") - - local end_ts - end_ts=$(python3 -c 'import time; print(time.time())') - local elapsed - elapsed=$(python3 -c "print(f'{($end_ts - $start_ts)*1000:.2f}')") - - echo "Response received in ${elapsed} ms:" - echo "$resp" - echo "" - - local verified - verified=$(python3 -c ' -import json, sys -data = json.loads(sys.argv[1]) -content = data["choices"][0]["message"]["content"] or "" -reasoning = data["choices"][0]["message"].get("reasoning") or "" -full = content + " " + reasoning -print("YES" if ("PLATFORM_PROXY_OK" in full or len(full.strip()) > 0) else "NO") -' "$resp") - - if [[ "$verified" == "YES" ]]; then - echo "Verification: PASSED (Live Model Response confirmed from DGX Spark NVFP4 Engine)" - else - echo "Verification: FAILED (Empty or unexpected response)" - exit 1 - fi -} - -cmd_bench() { - echo "Benchmarking Mac -> DGX Spark NVFP4 engine latency..." - echo "Target: ${MODEL_ENDPOINT}/chat/completions (${SERVED_MODEL})" - echo "" - - # Measure HTTP timing via curl write-out - curl -s -o /tmp/mac_proxy_bench_resp.json -w "\ -DNS Lookup: %{time_namelookup}s\n\ -Connect: %{time_connect}s\n\ -AppConnect: %{time_appconnect}s\n\ -PreTransfer: %{time_pretransfer}s\n\ -Time to First Byte:%{time_starttransfer}s\n\ -Total Duration: %{time_total}s\n\ -HTTP Code: %{http_code}\n\ -" -X POST "${MODEL_ENDPOINT}/chat/completions" \ - -H "Content-Type: application/json" \ - -d "{ - \"model\": \"${SERVED_MODEL}\", - \"messages\": [{\"role\": \"user\", \"content\": \"Verify NVFP4 serving configuration and benchmark latency.\"}], - \"max_tokens\": 32, - \"temperature\": 0 - }" - - echo "" - echo "Response Details:" - python3 -c ' -import json -try: - with open("/tmp/mac_proxy_bench_resp.json") as f: - data = json.load(f) - usage = data.get("usage", {}) - prompt_toks = usage.get("prompt_tokens", 0) - compl_toks = usage.get("completion_tokens", 0) - model_name = data.get("model") - print(f"Model ID: {model_name}") - print(f"Prompt Tokens: {prompt_toks}") - print(f"Completion Tokens: {compl_toks}") - msg = data["choices"][0]["message"] - txt = msg.get("content") or msg.get("reasoning") or "" - print(f"Sample Output: {txt[:120]}...") -except Exception as e: - print("Error reading response:", e) -' -} - -case "${1:-status}" in - status) cmd_status ;; - start) cmd_start ;; - stop) cmd_stop ;; - restart) cmd_restart ;; - test) cmd_test ;; - bench) cmd_bench ;; - *) usage; exit 1 ;; -esac diff --git a/scripts/sync-standalone-repos.sh b/scripts/sync-standalone-repos.sh index efeefb1a..17fe6d18 100755 --- a/scripts/sync-standalone-repos.sh +++ b/scripts/sync-standalone-repos.sh @@ -119,109 +119,69 @@ check_dirty_worktree() { return 0 } +# Value of `key = "..."` inside the [package] table of a manifest (first match). +pkg_field() { + awk -v key="$2" ' + /^[[:space:]]*\[/ { in_pkg = ($0 ~ /^[[:space:]]*\[package\][[:space:]]*$/); next } + in_pkg && $0 ~ "^[[:space:]]*" key "[[:space:]]*=[[:space:]]*\"" { + s = $0; sub(/^[^"]*"/, "", s); sub(/".*$/, "", s); print s; exit + } + ' "$1" +} + +# Bring the destination [package] table in line with the source: license from the +# workspace root (single source of truth), version and edition from the source crate. +# Pure awk, no Python. Exit 0 parity or synced, 2 disparity in check mode, 1 error. sync_manifest() { local src_manifest="$1" local dest_manifest="$2" local is_check="$3" + local ws_manifest="$SOVEREIGN_CORE/Cargo.toml" + + local license_id + license_id=$(awk ' + /^[[:space:]]*\[/ { in_ws = ($0 ~ /^[[:space:]]*\[workspace\.package\][[:space:]]*$/); next } + in_ws && /^[[:space:]]*license[[:space:]]*=[[:space:]]*"/ { + s = $0; sub(/^[^"]*"/, "", s); sub(/".*$/, "", s); print s; exit + } + ' "$ws_manifest") + if [[ -z "$license_id" ]]; then + echo "[ERROR] No [workspace.package] license in $ws_manifest" + return 1 + fi - python3 - << 'PYEOF' "$src_manifest" "$dest_manifest" "$is_check" "$SOVEREIGN_CORE/Cargo.toml" -import sys, re - -src_path = sys.argv[1] -dest_path = sys.argv[2] -check_mode = (sys.argv[3] == "true") - -# The workspace root manifest is the single source of truth for the license. -license_id = None -in_ws_pkg = False -with open(sys.argv[4], "r", encoding="utf-8") as f: - for line in f: - s = line.strip() - if s.startswith("["): - in_ws_pkg = (s == "[workspace.package]") - continue - m = re.match(r'^license\s*=\s*"([^"]+)"', s) - if in_ws_pkg and m: - license_id = m.group(1) - break -if not license_id: - print(f"[ERROR] No [workspace.package] license in {sys.argv[4]}") - sys.exit(1) -license_line = f'license = "{license_id}"\n' - -with open(src_path, "r", encoding="utf-8") as f: - src_lines = f.readlines() -with open(dest_path, "r", encoding="utf-8") as f: - dest_lines = f.readlines() - -# Extract version and edition from source package table -src_version = None -src_edition = None -in_pkg = False -for line in src_lines: - s = line.strip() - if s.startswith("[package]"): - in_pkg = True - continue - elif s.startswith("[") and in_pkg: - in_pkg = False - if in_pkg: - mv = re.match(r'^version\s*=\s*"([^"]+)"', s) - if mv: - src_version = mv.group(1) - me = re.match(r'^edition\s*=\s*"([^"]+)"', s) - if me: - src_edition = me.group(1) - -# Build updated destination lines -new_dest = [] -in_pkg = False -license_set = False - -for line in dest_lines: - s = line.strip() - if s.startswith("[package]"): - in_pkg = True - new_dest.append(line) - continue - elif s.startswith("[") and in_pkg: - if not license_set: - new_dest.append(license_line) - license_set = True - in_pkg = False - - if in_pkg: - if re.match(r'^(license|license\.workspace)\s*=', s): - new_dest.append(license_line) - license_set = True - continue - if src_version and re.match(r'^version\s*=', s): - new_dest.append(f'version = "{src_version}"\n') - continue - if src_edition and re.match(r'^edition\s*=', s): - new_dest.append(f'edition = "{src_edition}"\n') - continue - new_dest.append(line) - -if in_pkg and not license_set: - new_dest.append(license_line) - -new_content = "".join(new_dest) -old_content = "".join(dest_lines) - -if new_content != old_content: - if check_mode: - print(f"[DISPARITY] {dest_path} requires manifest update (license {license_id} or version/edition)") - sys.exit(2) - else: - with open(dest_path, "w", encoding="utf-8") as f: - f.write(new_content) - print(f"[SYNCED] Manifest updated: {dest_path} (license = {license_id})") - sys.exit(0) -else: - print(f"[PARITY OK] Manifest {dest_path} in parity (license = {license_id})") - sys.exit(0) -PYEOF + local src_version src_edition + src_version=$(pkg_field "$src_manifest" version) + src_edition=$(pkg_field "$src_manifest" edition) + + local tmp + tmp=$(mktemp) + awk -v lic="$license_id" -v ver="$src_version" -v ed="$src_edition" ' + function flush_license() { + if (in_pkg && !license_set) { printf "license = \"%s\"\n", lic; license_set = 1 } + } + /^[[:space:]]*\[package\][[:space:]]*$/ { in_pkg = 1; print; next } + /^[[:space:]]*\[/ { flush_license(); in_pkg = 0 } + in_pkg && /^[[:space:]]*license(\.workspace)?[[:space:]]*=/ { printf "license = \"%s\"\n", lic; license_set = 1; next } + in_pkg && ver != "" && /^[[:space:]]*version[[:space:]]*=/ { printf "version = \"%s\"\n", ver; next } + in_pkg && ed != "" && /^[[:space:]]*edition[[:space:]]*=/ { printf "edition = \"%s\"\n", ed; next } + { print } + END { flush_license() } + ' "$dest_manifest" > "$tmp" + + if cmp -s "$tmp" "$dest_manifest"; then + rm -f "$tmp" + echo "[PARITY OK] Manifest $dest_manifest in parity (license = $license_id)" + return 0 + fi + if [[ "$is_check" == "true" ]]; then + rm -f "$tmp" + echo "[DISPARITY] $dest_manifest requires manifest update (license $license_id or version/edition)" + return 2 + fi + mv "$tmp" "$dest_manifest" + echo "[SYNCED] Manifest updated: $dest_manifest (license = $license_id)" + return 0 } check_unslop_invariants() {