betterwithage Claude Opus 4.7 commited on
Commit
5f86b19
·
verified ·
1 Parent(s): 201785a

deploy(hf): sync szl-holdings/a11oy@23dc4d86bd92055e5f202a01e1dc84bcacf49332 derived COPY set

Browse files

Reusable Dockerfile-COPY-derived deploy from szl-holdings/a11oy 23dc4d86bd92055e5f202a01e1dc84bcacf49332.
Files: 1207 Pruned: 0
Derived from Dockerfile COPY sources (NO hand-maintained allowlist).

Signed-off-by: SZL Holdings <noreply@szlholdings.ai>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Files changed (1) hide show
  1. szl_hub.py +166 -1
szl_hub.py CHANGED
@@ -29,11 +29,14 @@ SLSA L1 honest; Khipu/cosign signature = DSSE-PLACEHOLDER (never faked). NO BAND
29
  from __future__ import annotations
30
 
31
  import hashlib
 
32
  import json
 
 
33
  import time
34
  from datetime import datetime, timezone
35
  from pathlib import Path
36
- from typing import Any
37
 
38
  from fastapi import FastAPI
39
  from fastapi.responses import FileResponse, JSONResponse
@@ -209,6 +212,152 @@ GAP_REPORT = {
209
  "locked": LOCKED,
210
  }
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
  def register(app: FastAPI) -> None:
214
  """Register hub HTML tabs + JSON endpoints. Call BEFORE the SPA catch-all.
@@ -331,3 +480,19 @@ def register(app: FastAPI) -> None:
331
  @app.get("/api/a11oy/v1/hub/gap-report")
332
  async def hub_gap_report() -> JSONResponse:
333
  return _json(GAP_REPORT, "gap-report")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  from __future__ import annotations
30
 
31
  import hashlib
32
+ import importlib
33
  import json
34
+ import os
35
+ import sys
36
  import time
37
  from datetime import datetime, timezone
38
  from pathlib import Path
39
+ from typing import Any, Dict, List, Optional, Tuple
40
 
41
  from fastapi import FastAPI
42
  from fastapi.responses import FileResponse, JSONResponse
 
212
  "locked": LOCKED,
213
  }
214
 
215
+ KERNEL_DOCTRINE = {
216
+ "version": "v11",
217
+ "lambda": "Conjecture 1",
218
+ "locked_proven": 8,
219
+ "joblib": "QUARANTINED",
220
+ "pickle": "QUARANTINED",
221
+ }
222
+
223
+ ESTATE: Tuple[Dict[str, str], ...] = (
224
+ {"key": "szl-kernels", "module": "szl_kernels", "hub_id": "SZLHOLDINGS/szl-kernels", "probe": "selfcheck"},
225
+ {"key": "szl-governed-norm", "module": "szl_governed_norm", "hub_id": "SZLHOLDINGS/szl-governed-norm", "probe": "selfcheck"},
226
+ {"key": "szl-lambda-gate", "module": "szl_lambda_gate", "hub_id": "SZLHOLDINGS/szl-lambda-gate", "probe": "selfcheck"},
227
+ {"key": "governed-inference-meter", "module": "governed_inference_meter", "hub_id": "SZLHOLDINGS/governed-inference-meter", "probe": "selfcheck"},
228
+ {"key": "szl-receipt-attn", "module": "szl_receipt_attn", "hub_id": "SZLHOLDINGS/szl-receipt-attn", "probe": "selfcheck"},
229
+ {"key": "szl-maskmod", "module": "szl_maskmod", "hub_id": "SZLHOLDINGS/szl-maskmod", "probe": "selfcheck"},
230
+ {"key": "szl-block-kv", "module": "szl_block_kv", "hub_id": "SZLHOLDINGS/szl-block-kv", "probe": "selfcheck"},
231
+ {"key": "YARQA-ATTN", "module": "yarqa_attn", "hub_id": "SZLHOLDINGS/YARQA-ATTN", "probe": "selfcheck"},
232
+ {"key": "szl-ouroboros", "module": "szl_ouroboros", "hub_id": "SZLHOLDINGS/szl-ouroboros", "probe": "selfcheck"},
233
+ {"key": "szl-invariants", "module": "szl_invariants", "hub_id": "SZLHOLDINGS/szl-invariants", "probe": "selfcheck"},
234
+ {"key": "szl-formulas", "module": "szl_formulas", "hub_id": "SZLHOLDINGS/szl-formulas", "probe": "selfcheck"},
235
+ {"key": "szl-blocked", "module": "szl_blocked", "hub_id": "SZLHOLDINGS/szl-blocked", "probe": "selfcheck"},
236
+ {"key": "szl-govsign", "module": "szl_govsign", "hub_id": "SZLHOLDINGS/szl-govsign", "probe": "selfcheck"},
237
+ {"key": "szl-provctl", "module": "szl_provctl", "hub_id": "SZLHOLDINGS/szl-provctl", "probe": "selfcheck"},
238
+ {"key": "szl-nemo", "module": "szl_nemo", "hub_id": "SZLHOLDINGS/szl-nemo", "probe": "rule_check"},
239
+ {"key": "szl-serve", "module": "szl_serve", "hub_id": "SZLHOLDINGS/szl-serve", "probe": "selfcheck"},
240
+ )
241
+
242
+
243
+ def list_estate() -> List[Dict[str, str]]:
244
+ return [dict(e) for e in ESTATE]
245
+
246
+
247
+ def cuda_status() -> Dict[str, Any]:
248
+ try:
249
+ import torch # type: ignore
250
+
251
+ if bool(torch.cuda.is_available()):
252
+ try:
253
+ name = str(torch.cuda.get_device_name(0))
254
+ except Exception:
255
+ name = "cuda:0"
256
+ return {"status": "LIVE", "device": name}
257
+ except Exception as exc:
258
+ return {
259
+ "status": "UNAVAILABLE",
260
+ "reason": f"{type(exc).__name__}: {exc}",
261
+ "note": "GPU kernels stay ROADMAP; no fake CUDA",
262
+ }
263
+ return {
264
+ "status": "UNAVAILABLE",
265
+ "reason": "torch.cuda.is_available() is False",
266
+ "note": "GPU kernels stay ROADMAP; no fake CUDA",
267
+ }
268
+
269
+
270
+ def _kernel_extend_sys_path() -> None:
271
+ extra = os.environ.get("SZL_KERNEL_PATHS", "")
272
+ if not extra:
273
+ return
274
+ for raw in extra.split(os.pathsep):
275
+ path = raw.strip()
276
+ if path and path not in sys.path:
277
+ sys.path.insert(0, path)
278
+
279
+
280
+ def _kernel_summarize(result: Any) -> Any:
281
+ if result is None or isinstance(result, (str, int, float, bool)):
282
+ return result
283
+ if isinstance(result, tuple) and len(result) == 2 and isinstance(result[0], bool):
284
+ ok, violated = result
285
+ return {"ok": ok, "violated": list(violated) if violated is not None else []}
286
+ if isinstance(result, dict):
287
+ out: Dict[str, Any] = {}
288
+ for key in ("ok", "version", "label", "path", "lambda", "note"):
289
+ if key in result:
290
+ out[key] = result[key]
291
+ if "ok" not in out and "arithmetic_ok" in result:
292
+ out["ok"] = bool(result["arithmetic_ok"])
293
+ return out or {"keys": sorted(result.keys())[:12]}
294
+ return type(result).__name__
295
+
296
+
297
+ def _kernel_call_probe(mod: Any, probe: str) -> Any:
298
+ if probe == "rule_check":
299
+ return getattr(mod, "rule_check")(
300
+ "hello", "this is MEASURED software, not a score"
301
+ )
302
+ fn = getattr(mod, probe, None)
303
+ if fn is None:
304
+ raise AttributeError(f"{getattr(mod, '__name__', '?')} has no {probe}()")
305
+ return fn()
306
+
307
+
308
+ def probe_member(entry: Dict[str, str]) -> Dict[str, Any]:
309
+ rec = dict(entry)
310
+ rec["joblib"] = "QUARANTINED"
311
+ rec["pickle"] = "QUARANTINED"
312
+ try:
313
+ mod = importlib.import_module(entry["module"])
314
+ except Exception as exc:
315
+ rec.update(
316
+ {
317
+ "status": "UNAVAILABLE",
318
+ "called": False,
319
+ "reason": f"{type(exc).__name__}: {exc}",
320
+ }
321
+ )
322
+ return rec
323
+ try:
324
+ result = _kernel_call_probe(mod, entry["probe"])
325
+ rec.update(
326
+ {
327
+ "status": "LIVE",
328
+ "via": f"{entry['module']}.{entry['probe']}",
329
+ "called": True,
330
+ "probe_result": _kernel_summarize(result),
331
+ }
332
+ )
333
+ return rec
334
+ except Exception as exc:
335
+ rec.update(
336
+ {
337
+ "status": "UNAVAILABLE",
338
+ "called": True,
339
+ "reason": f"{type(exc).__name__}: {exc}",
340
+ }
341
+ )
342
+ return rec
343
+
344
+
345
+ def probe_estate() -> Dict[str, Any]:
346
+ _kernel_extend_sys_path()
347
+ kernels = [probe_member(dict(e)) for e in ESTATE]
348
+ live = sum(1 for k in kernels if k.get("status") == "LIVE")
349
+ return {
350
+ "ok": True,
351
+ "live": live,
352
+ "enumerated": len(kernels),
353
+ "cuda": cuda_status(),
354
+ "doctrine": KERNEL_DOCTRINE,
355
+ "joblib": "QUARANTINED",
356
+ "pickle": "QUARANTINED",
357
+ "lambda": "Conjecture 1 (advisory)",
358
+ "kernels": kernels,
359
+ }
360
+
361
 
362
  def register(app: FastAPI) -> None:
363
  """Register hub HTML tabs + JSON endpoints. Call BEFORE the SPA catch-all.
 
480
  @app.get("/api/a11oy/v1/hub/gap-report")
481
  async def hub_gap_report() -> JSONResponse:
482
  return _json(GAP_REPORT, "gap-report")
483
+
484
+ @app.get("/api/a11oy/v1/kernel-estate", include_in_schema=False)
485
+ async def hub_kernel_estate() -> JSONResponse:
486
+ return JSONResponse(probe_estate())
487
+
488
+ @app.get("/api/a11oy/v1/kernel-estate/{key}", include_in_schema=False)
489
+ async def hub_kernel_estate_one(key: str) -> JSONResponse:
490
+ entry: Optional[Dict[str, str]] = next(
491
+ (dict(e) for e in ESTATE if e["key"] == key), None
492
+ )
493
+ if entry is None:
494
+ return JSONResponse(
495
+ {"status": "UNAVAILABLE", "reason": f"unknown kernel {key!r}"},
496
+ status_code=404,
497
+ )
498
+ return JSONResponse(probe_member(entry))