betterwithage commited on
Commit
86b3a4e
·
verified ·
1 Parent(s): 945cf91

chore(sync): mirror backend .py + Dockerfile to Space (hf-sync-backend)

Browse files

Automated backend sync from szl-holdings/a11oy main via hf-sync-backend.
Updated (differed from the Space): serve.py, szl_engine_status.py
Deleted (gone from the repo + Dockerfile COPY set): (none)

Keeps the Space-built backend (serve.py + the Dockerfile-COPY'd .py
modules) identical to GitHub main so the Space never rebuilds from a
stale backend, new endpoints don't 404 there, and orphaned modules
removed from the repo don't linger in the Space tree.

Files changed (2) hide show
  1. serve.py +23 -197
  2. szl_engine_status.py +2 -2
serve.py CHANGED
@@ -4673,6 +4673,25 @@ async def _a11oy_pr_llm_tiers_v2():
4673
  "honesty": "szl_brain unavailable; honest stub catalog returned.",
4674
  })
4675
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4676
  def _a11oy_sanitize_mesh(state: dict) -> dict:
4677
  """Rewrite internal mesh wire edges to generic a11oy capability names so no
4678
  internal service codenames or *.hf.space URLs are ever user-visible. The
@@ -4706,11 +4725,9 @@ def _a11oy_sanitize_mesh(state: dict) -> dict:
4706
  return o
4707
  return _clean(s)
4708
  except Exception:
4709
- return {
4710
- "wires": {"D": "live_in_process", "E": "live", "F": "live"},
4711
- "mesh_organs": ["a11oy", "Reasoning", "Policy / Safety", "Operator", "Receipts", "Knowledge"],
4712
- "doctrine": "v11",
4713
- }
4714
 
4715
 
4716
  @app.get("/api/a11oy/v1/mesh/state")
@@ -4718,18 +4735,7 @@ async def _a11oy_pr_mesh_state_v2():
4718
  """Mesh wire status (generic a11oy capability names). Doctrine v11."""
4719
  if _A11OY_WIRE_OK:
4720
  return JSONResponse(_a11oy_sanitize_mesh(_a11oy_pr_wire.mesh_status()))
4721
- return JSONResponse({
4722
- "wires": {"D": "live_in_process", "E": "live", "F": "live",
4723
- "G": "not_served_on_this_build", "H": "not_served_on_this_build"},
4724
- "mesh_organs": ["a11oy", "Reasoning", "Policy / Safety", "Operator", "Receipts", "Knowledge"],
4725
- "doctrine": "v11",
4726
- "declarations": 749, "axioms_unique": 14, "sorries_total": 163,
4727
- "experimental_scope": {"kernel_commit": "7885fd9", "lean": "v4.18.0", "declarations": 1304, "axioms_unique": 22, "theorems_ci_green": 36, "note": "CI-green, kernel-verified (Wave5-8 + agentic P1-P6 + airtight Λ + coder); NOT folded into the locked count of 8; Λ stays Conjecture 1"},
4728
- "honesty": "szl_wire unavailable; honest stub mesh state returned. "
4729
- "Wire D is in-process only (cross-Space broker NOT wired). "
4730
- "Wires G (brain-jack mesh) and H (lean-verify proxy) are NOT "
4731
- "served on this build (endpoints return 404); do not claim G/H live.",
4732
- })
4733
 
4734
  print("[a11oy] PARITY BLOCK v2 registered BEFORE proxy: /api/a11oy/v1/{lambda,honest,audit-log,brain,llm/tiers,mesh/state}", file=sys.stderr)
4735
  # ===========================================================================
@@ -9921,186 +9927,6 @@ except Exception as _ig_e:
9921
  print(f"[a11oy] betterwithage ingestion mount skipped ({_ig_e!r}); SPA + existing routes unaffected", file=sys.stderr)
9922
  # --- end betterwithage ingestion mount ---
9923
 
9924
- # ===========================================================================
9925
- # PARITY RESTORATION BLOCK (2026-06-02, Yachay CTO / Perplexity Computer Agent)
9926
- # Adds 6 missing routes per PARITY_GAP_MATRIX_2026-06-02_2050Z.md:
9927
- # /api/a11oy/v1/lambda — 13-axis Λ geometric-mean (Conjecture 1, NOT theorem)
9928
- # /api/a11oy/v1/honest — honest doctrine disclosure
9929
- # /api/a11oy/v1/audit-log — in-memory audit log ring buffer
9930
- # /api/a11oy/v1/brain — unified brain payload (szl_brain)
9931
- # /api/a11oy/v1/llm/tiers — 7-tier LLM router catalog
9932
- # /api/a11oy/v1/mesh/state — mesh wire status
9933
- # All registered BEFORE the /{full_path:path} SPA catch-all. ADDITIVE ONLY.
9934
- # Doctrine v11 LOCKED 749/14/163. Λ = Conjecture 1 (NOT a theorem). c7c0ba17.
9935
- # Signed-off-by: Yachay <yachay@szlholdings.ai>
9936
- # Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
9937
- # ===========================================================================
9938
- import collections as _pr_col
9939
- import threading as _pr_thr
9940
- import math as _pr_math
9941
-
9942
- _A11OY_AUDIT_LOCK = _pr_thr.Lock()
9943
- _A11OY_AUDIT_LOG: _pr_col.deque = _pr_col.deque(maxlen=200)
9944
-
9945
- # Import shared substrate (already loaded at module level in most cases)
9946
- try:
9947
- import szl_brain as _a11oy_pr_brain
9948
- _A11OY_BRAIN_OK = True
9949
- except Exception:
9950
- _A11OY_BRAIN_OK = False
9951
-
9952
- try:
9953
- import szl_wire as _a11oy_pr_wire
9954
- _A11OY_WIRE_OK = True
9955
- except Exception:
9956
- _A11OY_WIRE_OK = False
9957
-
9958
- _A11OY_AXIS_NAMES = [
9959
- "soundness", "calibration", "robustness", "provenance", "consent", "reversibility",
9960
- "transparency", "fairness", "containment", "attestation", "freshness", "authority", "auditability",
9961
- ]
9962
-
9963
- @app.get("/api/a11oy/v1/lambda")
9964
- async def _a11oy_pr_lambda():
9965
- """13-axis Λ geometric-mean. Λ = Conjecture 1 (NOT a theorem). Doctrine v11 LOCKED."""
9966
- axes = [0.92, 0.90, 0.95, 0.91, 0.94, 0.90, 0.92, 0.91, 0.93, 0.92, 0.93, 0.90, 0.92]
9967
- floor = 0.90
9968
- clamped = [min(1.0, max(1e-9, float(x))) for x in axes]
9969
- L = _pr_math.exp(sum(_pr_math.log(x) for x in clamped) / len(clamped))
9970
- return JSONResponse({
9971
- "trust_axes": 13,
9972
- "axes": [{"name": n, "score": s} for n, s in zip(_A11OY_AXIS_NAMES, axes)],
9973
- "lambda": round(L, 6), "lambda_floor": floor, "pass": L >= floor,
9974
- "aggregate": "geometric mean (yuyay_v3 canonical, 13-axis)",
9975
- "uniqueness": "Conjecture 1 — NOT a Theorem (open CAUCHY_ND sorry + missing symmetry axiom)",
9976
- "declarations": 749, "axioms_unique": 14, "axioms_raw": 15, "sorries_total": 163,
9977
- "experimental_scope": {"kernel_commit": "7885fd9", "lean": "v4.18.0", "declarations": 1304, "axioms_unique": 22, "theorems_ci_green": 36, "note": "CI-green, kernel-verified (Wave5-8 + agentic P1-P6 + airtight Λ + coder); NOT folded into the locked count of 8; Λ stays Conjecture 1"},
9978
- "policy_gates": 46, "anchor_formula_gates": 44,
9979
- "doctrine": "v11",
9980
- })
9981
-
9982
- @app.get("/api/a11oy/v1/honest")
9983
- async def _a11oy_pr_honest():
9984
- """Honest doctrine disclosure — parity with the sibling flagships. Doctrine v11."""
9985
- # ADDITIVE (Formulas → Ecosystem, 2026-06-03): this is the LAST-registered /honest
9986
- # (it wins ordering), so the formula + SLSA surface lives HERE too. HONEST STATUS
9987
- # (locked by .compliance/SLSA_LEVEL.md): the deployed a11oy image (uds-v0.2.0) is
9988
- # cosign-signed and publicly verifiable (Rekor logIndex 1710578865) — that is
9989
- # SLSA Build L1 honest. L2 (an isolated, attested build-service PROVENANCE for the
9990
- # deployed image, verifiable downstream) is roadmap via Wire D and NOT yet claimed;
9991
- # GHCR verification shows the cosign-signed image (L1) only, no verified provenance
9992
- # attestation tag on the image. L3 not claimed. Report exactly what Rekor confirms.
9993
- try:
9994
- _wired = [f["name"] for f in getattr(_a11oy_formulas, "_INDEX", [])]
9995
- except Exception:
9996
- _wired = []
9997
- return JSONResponse({
9998
- "doctrine": "v11",
9999
- "declarations": 749, "axioms_unique": 14, "axioms_raw": 15, "sorries_total": 163,
10000
- "experimental_scope": {"kernel_commit": "7885fd9", "lean": "v4.18.0", "declarations": 1304, "axioms_unique": 22, "theorems_ci_green": 36, "note": "CI-green, kernel-verified (Wave5-8 + agentic P1-P6 + airtight Λ + coder); NOT folded into the locked count of 8; Λ stays Conjecture 1"},
10001
- "sorries_baseline": 112, "sorries_putnam": 51, "trust_axes": 13,
10002
- "policy_gates": 46, "anchor_formula_gates": 44, "mcp_tools": 12,
10003
- "lambda_uniqueness": "Conjecture 1 — NOT a closed theorem (open CAUCHY_ND sorry + missing symmetry axiom)",
10004
- "slsa": "SLSA L1 honest; L2 .att emitted (not independently verified) · L3 roadmap. L1: cosign-signed image (verifiable via cosign verify). L2: signed SLSA build-provenance attestation (actions/attest-build-provenance@v2, Sigstore keyless Fulcio+Rekor), verifiable via `gh attestation verify` / `cosign verify-attestation --type slsaprovenance`. L3 not claimed. Not Iron Bank / FedRAMP / CMMC / ATO without roadmap.",
10005
- "slsa_evidence": {
10006
- "level": "L2",
10007
- "image_tag": "uds-v0.2.0",
10008
- "image_digest": "sha256:7473f3d9eb156b2911170d86d8834d1e8bd8deb06a2aff91c6904fef64ceed71",
10009
- "builder": "GitHub-hosted Actions (isolated build service, cosign keyless)",
10010
- "fulcio_issuer": "sigstore.dev (public-good)",
10011
- "rekor_log_index": 1710578865,
10012
- "verified_via": "cosign verify + live public Rekor inclusion for the image SIGNATURE + signed slsa.dev/provenance attestation (actions/attest-build-provenance@v2), verifiable via gh attestation verify / cosign verify-attestation --type slsaprovenance",
10013
- "l3_status": "NOT claimed (no hermetic, fully-isolated reproducible build attestation).",
10014
- },
10015
- "formulas_wired": _wired,
10016
- "formulas_count": len(_wired),
10017
- "formulas_status": globals().get("_a11oy_formulas_status", "unknown"),
10018
- "formulas_index": "/api/a11oy/v1/formulas/index",
10019
- "formulas_provenance": "thesis_v22.pdf §2 + real Lean theorem/obligation per module",
10020
- "formulas_honest_notes": [
10021
- "HNSW endpoint is an honest retrieval-tier delegate stub (the retrieval tier owns retrieval).",
10022
- "BLS returns an honest backend-availability flag; real aggregate-verify only when py_ecc present.",
10023
- ],
10024
- "role": "Brand Orchestration / gates",
10025
- "hatun_willay": True,
10026
- })
10027
-
10028
- @app.get("/api/a11oy/v1/audit-log")
10029
- async def _a11oy_pr_audit_log(limit: int = 50):
10030
- """In-memory audit log ring buffer — parity with the sibling flagships. Doctrine v11."""
10031
- limit = min(limit, 200)
10032
- with _A11OY_AUDIT_LOCK:
10033
- entries = list(_A11OY_AUDIT_LOG)[:limit]
10034
- return JSONResponse({
10035
- "entries": entries,
10036
- "total_buffered": len(_A11OY_AUDIT_LOG),
10037
- "limit": limit,
10038
- "doctrine": "v11",
10039
- "note": "In-memory ring buffer (maxlen=200). Resets on Space rebuild (honest disclosure).",
10040
- })
10041
-
10042
- @app.get("/api/a11oy/v1/brain")
10043
- async def _a11oy_pr_brain_route():
10044
- """Unified brain payload — a11oy brand-orchestration role. Doctrine v11 LOCKED."""
10045
- if _A11OY_BRAIN_OK:
10046
- return JSONResponse(_a11oy_pr_brain.brain_payload("a11oy"))
10047
- return JSONResponse({
10048
- "space": "a11oy", "doctrine": "v11",
10049
- "declarations": 749, "axioms_unique": 14, "sorries_total": 163,
10050
- "experimental_scope": {"kernel_commit": "7885fd9", "lean": "v4.18.0", "declarations": 1304, "axioms_unique": 22, "theorems_ci_green": 36, "note": "CI-green, kernel-verified (Wave5-8 + agentic P1-P6 + airtight Λ + coder); NOT folded into the locked count of 8; Λ stays Conjecture 1"},
10051
- "policy_gates": 46, "anchor_formula_gates": 44,
10052
- "role": "Brand Orchestration / gates",
10053
- "lambda_floor": 0.90,
10054
- "honesty": "szl_brain unavailable in this build; honest stub returned.",
10055
- })
10056
-
10057
- @app.get("/api/a11oy/v1/llm/tiers")
10058
- async def _a11oy_pr_llm_tiers():
10059
- """7-tier LLM router catalog — parity with the sibling flagships. Doctrine v11."""
10060
- if _A11OY_BRAIN_OK:
10061
- return JSONResponse({
10062
- "count": len(_a11oy_pr_brain.TIERS),
10063
- "tiers": _a11oy_pr_brain.TIERS,
10064
- "doctrine": "v11",
10065
- })
10066
- return JSONResponse({
10067
- "count": 7,
10068
- "tiers": [
10069
- {"tier": 1, "name": "haiku_3", "note": "fastest, cheapest"},
10070
- {"tier": 2, "name": "sonnet_3_5", "note": "balanced"},
10071
- {"tier": 3, "name": "opus_4_5", "note": "high-capability"},
10072
- {"tier": 4, "name": "r1", "note": "reasoning-grade"},
10073
- {"tier": 5, "name": "o3", "note": "frontier reasoning"},
10074
- {"tier": 6, "name": "gemini_2_flash", "note": "multimodal"},
10075
- {"tier": 7, "name": "sovereign_local", "note": "air-gap fallback"},
10076
- ],
10077
- "doctrine": "v11",
10078
- "honesty": "szl_brain unavailable; honest stub catalog returned.",
10079
- })
10080
-
10081
- @app.get("/api/a11oy/v1/mesh/state")
10082
- async def _a11oy_pr_mesh_state():
10083
- """Mesh wire status (generic a11oy capability names). Doctrine v11."""
10084
- if _A11OY_WIRE_OK:
10085
- return JSONResponse(_a11oy_sanitize_mesh(_a11oy_pr_wire.mesh_status()))
10086
- return JSONResponse({
10087
- "wires": {"D": "live_in_process", "E": "live", "F": "live",
10088
- "G": "not_served_on_this_build", "H": "not_served_on_this_build"},
10089
- "mesh_organs": ["a11oy", "Reasoning", "Policy / Safety", "Operator", "Receipts", "Knowledge"],
10090
- "doctrine": "v11",
10091
- "declarations": 749, "axioms_unique": 14, "sorries_total": 163,
10092
- "experimental_scope": {"kernel_commit": "7885fd9", "lean": "v4.18.0", "declarations": 1304, "axioms_unique": 22, "theorems_ci_green": 36, "note": "CI-green, kernel-verified (Wave5-8 + agentic P1-P6 + airtight Λ + coder); NOT folded into the locked count of 8; Λ stays Conjecture 1"},
10093
- "honesty": "szl_wire unavailable; honest stub mesh state returned. "
10094
- "Wire D is in-process only (cross-Space broker NOT wired). "
10095
- "Wires G (brain-jack mesh) and H (lean-verify proxy) are NOT "
10096
- "served on this build (endpoints return 404); do not claim G/H live.",
10097
- })
10098
-
10099
- print("[a11oy] PARITY BLOCK registered: /api/a11oy/v1/{lambda,honest,audit-log,brain,llm/tiers,mesh/state}", file=sys.stderr)
10100
- # ===========================================================================
10101
- # END PARITY RESTORATION BLOCK
10102
- # ===========================================================================
10103
-
10104
 
10105
  # P3 FIX: /api/health JSON probe (Upgrade Hammer — Doctrine v11 LOCKED 749/14/163)
10106
  @app.get("/api/health")
 
4673
  "honesty": "szl_brain unavailable; honest stub catalog returned.",
4674
  })
4675
 
4676
+ def _a11oy_mesh_honest_fallback(honesty=None) -> dict:
4677
+ """Honest mesh-state stub: D/E/F live in-process, G/H explicitly not_served.
4678
+ Shared by the szl_wire-unavailable branch and the sanitize crash path so the
4679
+ crash path never overclaims G/H as live (Doctrine v11 honest labels)."""
4680
+ return {
4681
+ "wires": {"D": "live_in_process", "E": "live", "F": "live",
4682
+ "G": "not_served_on_this_build", "H": "not_served_on_this_build"},
4683
+ "mesh_organs": ["a11oy", "Reasoning", "Policy / Safety", "Operator", "Receipts", "Knowledge"],
4684
+ "doctrine": "v11",
4685
+ "declarations": 749, "axioms_unique": 14, "sorries_total": 163,
4686
+ "experimental_scope": {"kernel_commit": "7885fd9", "lean": "v4.18.0", "declarations": 1304, "axioms_unique": 22, "theorems_ci_green": 36, "note": "CI-green, kernel-verified (Wave5-8 + agentic P1-P6 + airtight Λ + coder); NOT folded into the locked count of 8; Λ stays Conjecture 1"},
4687
+ "honesty": honesty or (
4688
+ "szl_wire unavailable; honest stub mesh state returned. "
4689
+ "Wire D is in-process only (cross-Space broker NOT wired). "
4690
+ "Wires G (brain-jack mesh) and H (lean-verify proxy) are NOT "
4691
+ "served on this build (endpoints return 404); do not claim G/H live."),
4692
+ }
4693
+
4694
+
4695
  def _a11oy_sanitize_mesh(state: dict) -> dict:
4696
  """Rewrite internal mesh wire edges to generic a11oy capability names so no
4697
  internal service codenames or *.hf.space URLs are ever user-visible. The
 
4725
  return o
4726
  return _clean(s)
4727
  except Exception:
4728
+ return _a11oy_mesh_honest_fallback(
4729
+ "mesh sanitize failed; honest stub returned — Wires G/H NOT served on "
4730
+ "this build (endpoints return 404); do not claim G/H live.")
 
 
4731
 
4732
 
4733
  @app.get("/api/a11oy/v1/mesh/state")
 
4735
  """Mesh wire status (generic a11oy capability names). Doctrine v11."""
4736
  if _A11OY_WIRE_OK:
4737
  return JSONResponse(_a11oy_sanitize_mesh(_a11oy_pr_wire.mesh_status()))
4738
+ return JSONResponse(_a11oy_mesh_honest_fallback())
 
 
 
 
 
 
 
 
 
 
 
4739
 
4740
  print("[a11oy] PARITY BLOCK v2 registered BEFORE proxy: /api/a11oy/v1/{lambda,honest,audit-log,brain,llm/tiers,mesh/state}", file=sys.stderr)
4741
  # ===========================================================================
 
9927
  print(f"[a11oy] betterwithage ingestion mount skipped ({_ig_e!r}); SPA + existing routes unaffected", file=sys.stderr)
9928
  # --- end betterwithage ingestion mount ---
9929
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9930
 
9931
  # P3 FIX: /api/health JSON probe (Upgrade Hammer — Doctrine v11 LOCKED 749/14/163)
9932
  @app.get("/api/health")
szl_engine_status.py CHANGED
@@ -15,7 +15,7 @@ read from:
15
  doctrine:{lambda:"Conjecture 1", locked:8, half_state:"forbidden"}
16
  }
17
 
18
- HONESTY (Doctrine v11/v12), enforced by construction:
19
  - NEVER fabricate a status. Every sub-probe runs with a timeout and degrades to
20
  {"reachable": false, "status": "unreachable", "error": ...}. A missing organ
21
  is reported as down — never bluffed green.
@@ -58,7 +58,7 @@ DOCTRINE: dict[str, Any] = {
58
  "lambda": "Conjecture 1", # the Λ-uniqueness killer formula is a CONJECTURE, said plainly
59
  "locked": 8, # the locked-8 round9 organ formulas, untouched
60
  "half_state": "forbidden", # claiming sovereign while a non-sovereign router served = forbidden
61
- "version": "v11/v12",
62
  }
63
 
64
  # ---------------------------------------------------------------------------
 
15
  doctrine:{lambda:"Conjecture 1", locked:8, half_state:"forbidden"}
16
  }
17
 
18
+ HONESTY (Doctrine v11), enforced by construction:
19
  - NEVER fabricate a status. Every sub-probe runs with a timeout and degrades to
20
  {"reachable": false, "status": "unreachable", "error": ...}. A missing organ
21
  is reported as down — never bluffed green.
 
58
  "lambda": "Conjecture 1", # the Λ-uniqueness killer formula is a CONJECTURE, said plainly
59
  "locked": 8, # the locked-8 round9 organ formulas, untouched
60
  "half_state": "forbidden", # claiming sovereign while a non-sovereign router served = forbidden
61
+ "version": "v11", # doctrine LOCK version — matches DOCTRINE="v11" (szl_be_hardening) and /honest
62
  }
63
 
64
  # ---------------------------------------------------------------------------