Spaces:
Running
Running
chore(sync): mirror backend .py + Dockerfile to Space (hf-sync-backend)
Browse filesAutomated backend sync from szl-holdings/a11oy main via hf-sync-backend.
Updated (differed from the Space): Dockerfile, src/a11oy/formulas/allodial.py, src/a11oy/formulas/allodial_gate.py, src/a11oy/formulas/entanglement.py, szl_dark_surfaces_register.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.
- Dockerfile +10 -0
- src/a11oy/formulas/allodial.py +239 -0
- src/a11oy/formulas/allodial_gate.py +201 -0
- src/a11oy/formulas/entanglement.py +184 -0
- szl_dark_surfaces_register.py +25 -5
Dockerfile
CHANGED
|
@@ -338,6 +338,16 @@ COPY src/a11oy/formulas/bloom_filter.py ./src/a11oy/formulas/bloom_filter.py
|
|
| 338 |
COPY src/a11oy/formulas/kalman.py ./src/a11oy/formulas/kalman.py
|
| 339 |
COPY src/a11oy/formulas/hnsw_retrieval.py ./src/a11oy/formulas/hnsw_retrieval.py
|
| 340 |
COPY src/a11oy/formulas/reidemeister.py ./src/a11oy/formulas/reidemeister.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
COPY src/a11oy/harvest/__init__.py ./src/a11oy/harvest/__init__.py
|
| 342 |
COPY src/a11oy/harvest/wasted_energy_harvest.py ./src/a11oy/harvest/wasted_energy_harvest.py
|
| 343 |
COPY src/a11oy/harvest/harvest_budget.py ./src/a11oy/harvest/harvest_budget.py
|
|
|
|
| 338 |
COPY src/a11oy/formulas/kalman.py ./src/a11oy/formulas/kalman.py
|
| 339 |
COPY src/a11oy/formulas/hnsw_retrieval.py ./src/a11oy/formulas/hnsw_retrieval.py
|
| 340 |
COPY src/a11oy/formulas/reidemeister.py ./src/a11oy/formulas/reidemeister.py
|
| 341 |
+
# FIX (formula/* 404 repair): a11oy_formula_endpoints.py imports a11oy.formulas.{allodial,
|
| 342 |
+
# allodial_gate, entanglement} alongside the formulas above, but these three were NEVER
|
| 343 |
+
# COPY'd into the image. The package import therefore raised at boot, register() returned
|
| 344 |
+
# "formulas-unavailable", and EVERY /api/a11oy/v1/formula/* route (sovereign, quorum, holevo,
|
| 345 |
+
# bloom, kalman, formulas/index, …) 404'd through the Node proxy. Per-file COPY (this
|
| 346 |
+
# Dockerfile never uses `COPY . .`). Mirrored byte-identical to the HF Space (hf-sync
|
| 347 |
+
# APP_FILES lockstep). EXPERIMENTAL frontier gates — Λ = Conjecture 1 (never a theorem).
|
| 348 |
+
COPY src/a11oy/formulas/allodial.py ./src/a11oy/formulas/allodial.py
|
| 349 |
+
COPY src/a11oy/formulas/allodial_gate.py ./src/a11oy/formulas/allodial_gate.py
|
| 350 |
+
COPY src/a11oy/formulas/entanglement.py ./src/a11oy/formulas/entanglement.py
|
| 351 |
COPY src/a11oy/harvest/__init__.py ./src/a11oy/harvest/__init__.py
|
| 352 |
COPY src/a11oy/harvest/wasted_energy_harvest.py ./src/a11oy/harvest/wasted_energy_harvest.py
|
| 353 |
COPY src/a11oy/harvest/harvest_budget.py ./src/a11oy/harvest/harvest_budget.py
|
src/a11oy/formulas/allodial.py
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
# © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173
|
| 4 |
+
"""Allodial order-theoretic sovereignty checks — EXPERIMENTAL backbone.
|
| 5 |
+
|
| 6 |
+
Mirrors the kernel-checked Lean declarations in ``Lutar/Allodial.lean`` (PR #229,
|
| 7 |
+
merge 783a38d0). These are PROPOSED engineering gates grounded in a 0-sorry,
|
| 8 |
+
no-new-axiom EXPERIMENTAL Lean backbone — NOT locked-8 theorems and NOT formal
|
| 9 |
+
Λ results. Callers must treat them as EXPERIMENTAL-tier.
|
| 10 |
+
|
| 11 |
+
Lean declarations mirrored (all EXPERIMENTAL, PR #229):
|
| 12 |
+
• allodial_dominates_all — allodial element dominates every control class
|
| 13 |
+
• allodial_iff_top — an element is allodial iff it equals ⊤
|
| 14 |
+
• feudal_has_overlord — a feudal (non-allodial) element always has a strict overlord
|
| 15 |
+
• galois_preserves_allodial — adjoint (Galois) embeddings cannot destroy the allodial position
|
| 16 |
+
• ni_low_independent_of_high — operator-protected low output is independent of the
|
| 17 |
+
overlord/high state (non-interference)
|
| 18 |
+
|
| 19 |
+
This is the formal grounding for the founder's central vision:
|
| 20 |
+
"allodial sovereign compute — no kill-switch, no one can switch it off."
|
| 21 |
+
Any element that is NOT ⊤ has an overlord; an element that IS ⊤ is provably free.
|
| 22 |
+
|
| 23 |
+
CITATION: Lutar/Allodial.lean (PR #229, merge 783a38d0)
|
| 24 |
+
LEAN_THEOREM: Lutar/Allodial.lean::allodial_dominates_all / galois_preserves_allodial / ni_low_independent_of_high (EXPERIMENTAL — PROPOSED gate, not a locked theorem)
|
| 25 |
+
"""
|
| 26 |
+
from __future__ import annotations
|
| 27 |
+
|
| 28 |
+
from typing import TypedDict, Any, Hashable
|
| 29 |
+
|
| 30 |
+
CITATION = "Lutar/Allodial.lean (PR #229, merge 783a38d0)"
|
| 31 |
+
LEAN_THEOREM = (
|
| 32 |
+
"Lutar/Allodial.lean::allodial_dominates_all / galois_preserves_allodial"
|
| 33 |
+
" / ni_low_independent_of_high"
|
| 34 |
+
" (EXPERIMENTAL — PROPOSED gate, not a locked theorem)"
|
| 35 |
+
)
|
| 36 |
+
_HONEST_NOTE = (
|
| 37 |
+
"EXPERIMENTAL-tier backbone: the Lean declarations are kernel-checked,"
|
| 38 |
+
" 0-sorry, no-new-axiom, but are PROPOSED engineering gates — NOT locked-8"
|
| 39 |
+
" theorems and NOT formal Λ results. This Python module is a faithful but"
|
| 40 |
+
" informal mirror of those proofs, not the proof itself."
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
# ---------------------------------------------------------------------------
|
| 44 |
+
# Core predicate functions
|
| 45 |
+
# ---------------------------------------------------------------------------
|
| 46 |
+
|
| 47 |
+
def is_allodial(elem: Hashable, top: Hashable) -> bool:
|
| 48 |
+
"""Return True iff ``elem`` equals the lattice top element ⊤.
|
| 49 |
+
|
| 50 |
+
Mirrors ``allodial_iff_top``: allodial ↔ elem = ⊤.
|
| 51 |
+
An element is allodial (sovereign, no overlord) if and only if it IS the top.
|
| 52 |
+
"""
|
| 53 |
+
return elem == top
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def dominates_all(
|
| 57 |
+
elem: Hashable,
|
| 58 |
+
elements: list[Hashable],
|
| 59 |
+
leq: list[tuple[Hashable, Hashable]],
|
| 60 |
+
) -> bool:
|
| 61 |
+
"""Return True iff ``elem`` is ≥ every other element in ``elements``.
|
| 62 |
+
|
| 63 |
+
Mirrors ``allodial_dominates_all``: if x is allodial (= ⊤) then ∀ y, y ≤ x.
|
| 64 |
+
``leq`` is the list of (a, b) pairs meaning a ≤ b in the partial order.
|
| 65 |
+
Reflexivity (x ≤ x) is assumed; it need not appear in ``leq``.
|
| 66 |
+
"""
|
| 67 |
+
leq_set: set[tuple[Hashable, Hashable]] = set(leq)
|
| 68 |
+
for y in elements:
|
| 69 |
+
if y == elem:
|
| 70 |
+
continue # reflexivity
|
| 71 |
+
if (y, elem) not in leq_set:
|
| 72 |
+
return False
|
| 73 |
+
return True
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def has_overlord(
|
| 77 |
+
elem: Hashable,
|
| 78 |
+
top: Hashable,
|
| 79 |
+
elements: list[Hashable],
|
| 80 |
+
leq: list[tuple[Hashable, Hashable]],
|
| 81 |
+
) -> bool:
|
| 82 |
+
"""Return True iff ``elem`` has a strict overlord (i.e. is NOT allodial).
|
| 83 |
+
|
| 84 |
+
Mirrors ``feudal_has_overlord``: ¬allodial(x) → ∃ y, x < y.
|
| 85 |
+
A strict overlord is an element y ≠ elem such that elem ≤ y.
|
| 86 |
+
If elem IS the top, there is no overlord (allodial), so returns False.
|
| 87 |
+
"""
|
| 88 |
+
if elem == top:
|
| 89 |
+
return False # allodial — no overlord
|
| 90 |
+
leq_set: set[tuple[Hashable, Hashable]] = set(leq)
|
| 91 |
+
for y in elements:
|
| 92 |
+
if y == elem:
|
| 93 |
+
continue
|
| 94 |
+
if (elem, y) in leq_set:
|
| 95 |
+
return True # found a strict overlord
|
| 96 |
+
return False
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def non_interference_check(
|
| 100 |
+
low_outputs_by_high_state: dict[Any, Any],
|
| 101 |
+
) -> dict:
|
| 102 |
+
"""Check whether the low-output is invariant across all high states.
|
| 103 |
+
|
| 104 |
+
Mirrors ``ni_low_independent_of_high``: the operator-protected low output
|
| 105 |
+
is independent of the overlord/high state.
|
| 106 |
+
|
| 107 |
+
``low_outputs_by_high_state`` maps each high-state label → the low output
|
| 108 |
+
value observed when the system is in that high state.
|
| 109 |
+
|
| 110 |
+
Returns a dict with:
|
| 111 |
+
value — True iff all low outputs are identical (non-interference holds)
|
| 112 |
+
invariant — same as value
|
| 113 |
+
unique_low_outputs — the set of distinct low output values seen
|
| 114 |
+
high_state_count — how many high states were checked
|
| 115 |
+
citation — canonical citation
|
| 116 |
+
lean_theorem — the Lean theorem tag
|
| 117 |
+
tier — "experimental"
|
| 118 |
+
honest_note — honesty annotation
|
| 119 |
+
"""
|
| 120 |
+
values = list(low_outputs_by_high_state.values())
|
| 121 |
+
unique = set(values) if values else set()
|
| 122 |
+
invariant = len(unique) <= 1
|
| 123 |
+
return {
|
| 124 |
+
"value": invariant,
|
| 125 |
+
"invariant": invariant,
|
| 126 |
+
"unique_low_outputs": sorted(str(v) for v in unique),
|
| 127 |
+
"high_state_count": len(low_outputs_by_high_state),
|
| 128 |
+
"citation": CITATION,
|
| 129 |
+
"lean_theorem": LEAN_THEOREM,
|
| 130 |
+
"tier": "experimental",
|
| 131 |
+
"honest_note": _HONEST_NOTE,
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class AllodialResult(TypedDict):
|
| 136 |
+
value: bool
|
| 137 |
+
is_allodial: bool
|
| 138 |
+
dominates_all: bool
|
| 139 |
+
has_overlord: bool
|
| 140 |
+
elem: str
|
| 141 |
+
top: str
|
| 142 |
+
citation: str
|
| 143 |
+
lean_theorem: str
|
| 144 |
+
tier: str
|
| 145 |
+
honest_note: str
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def allodial_check(
|
| 149 |
+
elem: Hashable,
|
| 150 |
+
top: Hashable,
|
| 151 |
+
elements: list[Hashable],
|
| 152 |
+
leq: list[tuple[Hashable, Hashable]],
|
| 153 |
+
) -> AllodialResult:
|
| 154 |
+
"""Full allodiality assessment for ``elem`` on the given finite control lattice.
|
| 155 |
+
|
| 156 |
+
Returns the HONEST schema with EXPERIMENTAL-tier annotation.
|
| 157 |
+
``value`` is True iff elem is allodial (= ⊤ and dominates all).
|
| 158 |
+
"""
|
| 159 |
+
ia = is_allodial(elem, top)
|
| 160 |
+
da = dominates_all(elem, elements, leq)
|
| 161 |
+
ho = has_overlord(elem, top, elements, leq)
|
| 162 |
+
verdict = ia and da and not ho
|
| 163 |
+
return AllodialResult(
|
| 164 |
+
value=verdict,
|
| 165 |
+
is_allodial=ia,
|
| 166 |
+
dominates_all=da,
|
| 167 |
+
has_overlord=ho,
|
| 168 |
+
elem=str(elem),
|
| 169 |
+
top=str(top),
|
| 170 |
+
citation=CITATION,
|
| 171 |
+
lean_theorem=LEAN_THEOREM,
|
| 172 |
+
tier="experimental",
|
| 173 |
+
honest_note=_HONEST_NOTE,
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
__all__ = [
|
| 178 |
+
"is_allodial",
|
| 179 |
+
"dominates_all",
|
| 180 |
+
"has_overlord",
|
| 181 |
+
"non_interference_check",
|
| 182 |
+
"allodial_check",
|
| 183 |
+
"CITATION",
|
| 184 |
+
"LEAN_THEOREM",
|
| 185 |
+
]
|
| 186 |
+
|
| 187 |
+
# Doctrine v11 LOCKED — 749/14/163 — c7c0ba17 · Λ = Conjecture 1 (NEVER a theorem)
|
| 188 |
+
# SLSA L1 honest. L2 build-provenance attestation = roadmap (Wire D) — not yet claimed. L3 not claimed.
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
if __name__ == "__main__":
|
| 192 |
+
# -----------------------------------------------------------------------
|
| 193 |
+
# Self-tests: 4-element lattice ⊥ < a < b < ⊤
|
| 194 |
+
# Elements: {bot, a, b, top}
|
| 195 |
+
# Partial order (non-reflexive pairs stored explicitly):
|
| 196 |
+
# bot≤a, bot≤b, bot≤top, a≤b, a≤top, b≤top
|
| 197 |
+
# -----------------------------------------------------------------------
|
| 198 |
+
elements = ["bot", "a", "b", "top"]
|
| 199 |
+
leq = [
|
| 200 |
+
("bot", "a"), ("bot", "b"), ("bot", "top"),
|
| 201 |
+
("a", "b"), ("a", "top"),
|
| 202 |
+
("b", "top"),
|
| 203 |
+
]
|
| 204 |
+
top = "top"
|
| 205 |
+
checks = 0
|
| 206 |
+
|
| 207 |
+
# 1. allodial_iff_top: top is allodial, others are not
|
| 208 |
+
assert is_allodial("top", top) is True, "top should be allodial"
|
| 209 |
+
assert is_allodial("a", top) is False, "'a' should not be allodial"
|
| 210 |
+
assert is_allodial("bot", top) is False, "'bot' should not be allodial"
|
| 211 |
+
checks += 3
|
| 212 |
+
|
| 213 |
+
# 2. dominates_all: top dominates everything; 'a' does NOT dominate 'b'
|
| 214 |
+
assert dominates_all("top", elements, leq) is True, "top must dominate all"
|
| 215 |
+
assert dominates_all("a", elements, leq) is False, "'a' must not dominate 'b' or 'top'"
|
| 216 |
+
checks += 2
|
| 217 |
+
|
| 218 |
+
# 3. has_overlord: non-top elements have an overlord; top does not
|
| 219 |
+
assert has_overlord("a", top, elements, leq) is True, "'a' has overlord 'b' (and 'top')"
|
| 220 |
+
assert has_overlord("bot", top, elements, leq) is True, "'bot' has overlords"
|
| 221 |
+
assert has_overlord("top", top, elements, leq) is False, "top has no overlord"
|
| 222 |
+
checks += 3
|
| 223 |
+
|
| 224 |
+
# 4. non_interference_check: invariant when low outputs are constant
|
| 225 |
+
ni_ok = non_interference_check({"high_a": "out_x", "high_b": "out_x", "high_c": "out_x"})
|
| 226 |
+
assert ni_ok["invariant"] is True, "constant low output must be non-interfering"
|
| 227 |
+
# FAILS when low outputs vary by high state
|
| 228 |
+
ni_fail = non_interference_check({"high_a": "out_x", "high_b": "out_y"})
|
| 229 |
+
assert ni_fail["invariant"] is False, "varying low output must flag interference"
|
| 230 |
+
checks += 2
|
| 231 |
+
|
| 232 |
+
# 5. Full allodial_check on the lattice
|
| 233 |
+
top_result = allodial_check("top", top, elements, leq)
|
| 234 |
+
assert top_result["value"] is True, "top must pass full allodial check"
|
| 235 |
+
a_result = allodial_check("a", top, elements, leq)
|
| 236 |
+
assert a_result["value"] is False, "'a' must fail full allodial check"
|
| 237 |
+
checks += 2
|
| 238 |
+
|
| 239 |
+
print(f"ok:true checks:{checks}")
|
src/a11oy/formulas/allodial_gate.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
# © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173
|
| 4 |
+
"""Sovereignty gate — EXPERIMENTAL, grounded in Allodial non-interference.
|
| 5 |
+
|
| 6 |
+
Operationalizes the half-state doctrine: a node is sovereign ONLY when a local
|
| 7 |
+
or owner-controlled node ACTUALLY serves requests. The critical failure mode —
|
| 8 |
+
the "half-state" — is when a banner claims sovereignty while request routing is
|
| 9 |
+
silently delegated to an external/third-party router. This is the ONLY
|
| 10 |
+
unacceptable outcome and is explicitly flagged.
|
| 11 |
+
|
| 12 |
+
Doctrine grounding:
|
| 13 |
+
The allodial non-interference theorem (``ni_low_independent_of_high`` in
|
| 14 |
+
``Lutar/Allodial.lean``, PR #229, merge 783a38d0) establishes that the
|
| 15 |
+
sovereign (low-security, user-visible) verdict must be INDEPENDENT of the
|
| 16 |
+
external (high-security, overlord) router's state. When routing is
|
| 17 |
+
externally delegated, the low output (sovereignty verdict) becomes a function
|
| 18 |
+
of the external router's state — violating non-interference and destroying the
|
| 19 |
+
allodial position.
|
| 20 |
+
|
| 21 |
+
The half-state is the lattice analogue of a feudal element claiming the allodial
|
| 22 |
+
position: the banner says ⊤ while the actual routing position is strictly below
|
| 23 |
+
⊤ (under an external overlord).
|
| 24 |
+
|
| 25 |
+
CITATION: Lutar/Allodial.lean (PR #229, merge 783a38d0) — ni_low_independent_of_high
|
| 26 |
+
LEAN_THEOREM: Lutar/Allodial.lean::ni_low_independent_of_high / allodial_iff_top (EXPERIMENTAL — PROPOSED gate, not a locked theorem)
|
| 27 |
+
"""
|
| 28 |
+
from __future__ import annotations
|
| 29 |
+
|
| 30 |
+
from typing import TypedDict
|
| 31 |
+
|
| 32 |
+
CITATION = "Lutar/Allodial.lean (PR #229, merge 783a38d0)"
|
| 33 |
+
LEAN_THEOREM = (
|
| 34 |
+
"Lutar/Allodial.lean::ni_low_independent_of_high / allodial_iff_top"
|
| 35 |
+
" (EXPERIMENTAL — PROPOSED gate, not a locked theorem)"
|
| 36 |
+
)
|
| 37 |
+
_HONEST_NOTE = (
|
| 38 |
+
"EXPERIMENTAL-tier backbone: the Lean non-interference declaration is"
|
| 39 |
+
" kernel-checked, 0-sorry, no-new-axiom, but is a PROPOSED engineering gate"
|
| 40 |
+
" — NOT a locked-8 theorem and NOT a formal Λ result. The half-state check"
|
| 41 |
+
" is a faithful but informal mirror of that proof, not the proof itself."
|
| 42 |
+
" The sovereignty verdict is ONLY true when a local/owned node actually serves;"
|
| 43 |
+
" any external routing delegation is the uniquely unacceptable half-state."
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class SovereignVerdictOut(TypedDict):
|
| 48 |
+
sovereign: bool
|
| 49 |
+
half_state: bool
|
| 50 |
+
served_by: str
|
| 51 |
+
base_url: str
|
| 52 |
+
local_node_serving: bool
|
| 53 |
+
reason: str
|
| 54 |
+
citation: str
|
| 55 |
+
lean_theorem: str
|
| 56 |
+
tier: str
|
| 57 |
+
honest_note: str
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def sovereign_verdict(
|
| 61 |
+
served_by: str,
|
| 62 |
+
base_url: str,
|
| 63 |
+
local_node_serving: bool,
|
| 64 |
+
) -> SovereignVerdictOut:
|
| 65 |
+
"""Compute the sovereignty verdict for a serving node.
|
| 66 |
+
|
| 67 |
+
Mirrors ``ni_low_independent_of_high``: the low-security (user-visible)
|
| 68 |
+
sovereignty output must be invariant of the external (overlord) router state.
|
| 69 |
+
When an external router intermediates, the output becomes router-state-dependent,
|
| 70 |
+
destroying the allodial position.
|
| 71 |
+
|
| 72 |
+
Parameters
|
| 73 |
+
----------
|
| 74 |
+
served_by : identifier of the serving entity (e.g. "local", "a11oy-node-0",
|
| 75 |
+
"external-router", "third-party-cdn", etc.)
|
| 76 |
+
base_url : the base URL at which this service is presented
|
| 77 |
+
local_node_serving : True iff a local/owner-controlled node is ACTUALLY serving
|
| 78 |
+
requests right now (not just claimed in a banner)
|
| 79 |
+
|
| 80 |
+
Returns
|
| 81 |
+
-------
|
| 82 |
+
SovereignVerdictOut with:
|
| 83 |
+
sovereign — True ONLY when local_node_serving is True
|
| 84 |
+
half_state — True when banner-sovereignty is claimed (via base_url or served_by)
|
| 85 |
+
but local_node_serving is False — the uniquely unacceptable outcome
|
| 86 |
+
reason — human-readable explanation
|
| 87 |
+
"""
|
| 88 |
+
# Determine whether the banner/branding implies a sovereignty claim.
|
| 89 |
+
# We treat any non-external served_by as an implicit sovereignty assertion.
|
| 90 |
+
external_keywords = {
|
| 91 |
+
"external", "router", "cdn", "proxy", "third-party", "thirdparty",
|
| 92 |
+
"cloudflare", "akamai", "fastly", "aws", "gcp", "azure",
|
| 93 |
+
}
|
| 94 |
+
served_by_lower = (served_by or "").lower()
|
| 95 |
+
banner_claims_sovereign = not any(kw in served_by_lower for kw in external_keywords)
|
| 96 |
+
|
| 97 |
+
if local_node_serving:
|
| 98 |
+
# Local node IS serving — allodial position is held.
|
| 99 |
+
# Non-interference is satisfied: the sovereignty verdict is independent
|
| 100 |
+
# of any external router's state because we are NOT routing through one.
|
| 101 |
+
return SovereignVerdictOut(
|
| 102 |
+
sovereign=True,
|
| 103 |
+
half_state=False,
|
| 104 |
+
served_by=served_by,
|
| 105 |
+
base_url=base_url,
|
| 106 |
+
local_node_serving=True,
|
| 107 |
+
reason=(
|
| 108 |
+
"Local/owned node is actively serving: allodial position held."
|
| 109 |
+
" The sovereignty verdict is independent of any external router"
|
| 110 |
+
" state (ni_low_independent_of_high satisfied)."
|
| 111 |
+
),
|
| 112 |
+
citation=CITATION,
|
| 113 |
+
lean_theorem=LEAN_THEOREM,
|
| 114 |
+
tier="experimental",
|
| 115 |
+
honest_note=_HONEST_NOTE,
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
# Local node is NOT serving.
|
| 119 |
+
if banner_claims_sovereign:
|
| 120 |
+
# HALF-STATE: banner claims sovereignty, but routing is externally delegated.
|
| 121 |
+
# This makes the sovereignty verdict (low output) a function of the external
|
| 122 |
+
# router's state — violating non-interference. UNIQUELY UNACCEPTABLE.
|
| 123 |
+
return SovereignVerdictOut(
|
| 124 |
+
sovereign=False,
|
| 125 |
+
half_state=True,
|
| 126 |
+
served_by=served_by,
|
| 127 |
+
base_url=base_url,
|
| 128 |
+
local_node_serving=False,
|
| 129 |
+
reason=(
|
| 130 |
+
"HALF-STATE DETECTED: the banner asserts sovereignty but routing is"
|
| 131 |
+
" delegated externally. The low (user-visible) sovereignty verdict"
|
| 132 |
+
" now depends on the external router's state — this violates"
|
| 133 |
+
" ni_low_independent_of_high and the allodial position is lost."
|
| 134 |
+
" This is the uniquely unacceptable outcome."
|
| 135 |
+
),
|
| 136 |
+
citation=CITATION,
|
| 137 |
+
lean_theorem=LEAN_THEOREM,
|
| 138 |
+
tier="experimental",
|
| 139 |
+
honest_note=_HONEST_NOTE,
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
# External router is explicit; no sovereignty claim made — honest non-sovereign state.
|
| 143 |
+
return SovereignVerdictOut(
|
| 144 |
+
sovereign=False,
|
| 145 |
+
half_state=False,
|
| 146 |
+
served_by=served_by,
|
| 147 |
+
base_url=base_url,
|
| 148 |
+
local_node_serving=False,
|
| 149 |
+
reason=(
|
| 150 |
+
"External routing acknowledged openly: no sovereignty claim made."
|
| 151 |
+
" Not allodial, but no half-state deception — this is honest."
|
| 152 |
+
),
|
| 153 |
+
citation=CITATION,
|
| 154 |
+
lean_theorem=LEAN_THEOREM,
|
| 155 |
+
tier="experimental",
|
| 156 |
+
honest_note=_HONEST_NOTE,
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
__all__ = ["sovereign_verdict", "CITATION", "LEAN_THEOREM"]
|
| 161 |
+
|
| 162 |
+
# Doctrine v11 LOCKED — 749/14/163 — c7c0ba17 · Λ = Conjecture 1 (NEVER a theorem)
|
| 163 |
+
# SLSA L1 honest. L2 build-provenance attestation = roadmap (Wire D) — not yet claimed. L3 not claimed.
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
if __name__ == "__main__":
|
| 167 |
+
# -----------------------------------------------------------------------
|
| 168 |
+
# Self-tests for the sovereignty gate
|
| 169 |
+
# -----------------------------------------------------------------------
|
| 170 |
+
checks = 0
|
| 171 |
+
|
| 172 |
+
# 1. local_node_serving=True → sovereign:true, half_state:false
|
| 173 |
+
r = sovereign_verdict("a11oy-node-0", "https://a11oy.net", True)
|
| 174 |
+
assert r["sovereign"] is True, "local serving must yield sovereign:true"
|
| 175 |
+
assert r["half_state"] is False, "local serving must not be a half-state"
|
| 176 |
+
checks += 2
|
| 177 |
+
|
| 178 |
+
# 2. Banner sovereign (non-external served_by) + local_node_serving=False → half_state:true, sovereign:false
|
| 179 |
+
r2 = sovereign_verdict("a11oy-node-0", "https://a11oy.net", False)
|
| 180 |
+
assert r2["sovereign"] is False, "external routing must yield sovereign:false"
|
| 181 |
+
assert r2["half_state"] is True, "banner+no-local-serving must be half_state:true"
|
| 182 |
+
checks += 2
|
| 183 |
+
|
| 184 |
+
# 3. Explicit external router + local_node_serving=False → sovereign:false, half_state:false (honest)
|
| 185 |
+
r3 = sovereign_verdict("external-router", "https://a11oy.net", False)
|
| 186 |
+
assert r3["sovereign"] is False, "explicit external must yield sovereign:false"
|
| 187 |
+
assert r3["half_state"] is False, "explicit external with no claim must not be half-state"
|
| 188 |
+
checks += 2
|
| 189 |
+
|
| 190 |
+
# 4. CDN variant: served_by contains "cloudflare", local_node_serving=False
|
| 191 |
+
r4 = sovereign_verdict("cloudflare-cdn", "https://a11oy.net", False)
|
| 192 |
+
assert r4["half_state"] is False, "known external CDN must not be half-state"
|
| 193 |
+
assert r4["sovereign"] is False, "CDN serving must yield sovereign:false"
|
| 194 |
+
checks += 2
|
| 195 |
+
|
| 196 |
+
# 5. Sovereignty is ONLY true when local_node_serving is True (tier/citation checks)
|
| 197 |
+
assert r["tier"] == "experimental", "must carry experimental tier"
|
| 198 |
+
assert "ni_low_independent_of_high" in r["lean_theorem"], "must reference non-interference theorem"
|
| 199 |
+
checks += 2
|
| 200 |
+
|
| 201 |
+
print(f"ok:true checks:{checks}")
|
src/a11oy/formulas/entanglement.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
# © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173
|
| 4 |
+
"""Coherence-decay entanglement-generating-capacity bound — EXPERIMENTAL backbone.
|
| 5 |
+
|
| 6 |
+
Mirrors the kernel-checked Lean declarations in ``Lutar/Entanglement.lean``
|
| 7 |
+
(PR #230, merge 3a7f222ed3bb). These are PROPOSED engineering gates grounded
|
| 8 |
+
in a 0-sorry, no-new-axiom EXPERIMENTAL Lean backbone — NOT locked-8 theorems
|
| 9 |
+
and NOT formal Λ results. This is a CAPACITY BOUND, not a claimed rate.
|
| 10 |
+
|
| 11 |
+
Lean declarations mirrored (all EXPERIMENTAL, PR #230):
|
| 12 |
+
• capBound C₀ γ t = C₀ · exp(−γ·t) — the capacity-bound formula
|
| 13 |
+
• capBound_nonneg — bound is ≥ 0 for non-negative inputs
|
| 14 |
+
• capBound_zero — bound = 0 when C₀ = 0
|
| 15 |
+
• capBound_antitone — bound is antitone (strictly decreasing) in t for γ > 0
|
| 16 |
+
• entanglement_decays_under_bound — entanglement-generating capacity stays ≤ capBound
|
| 17 |
+
|
| 18 |
+
Physical interpretation: as coherence decays exponentially at rate γ, the upper
|
| 19 |
+
bound on entanglement-generating capacity also decays. This is a CEILING, not a
|
| 20 |
+
guarantee of any specific entanglement rate.
|
| 21 |
+
|
| 22 |
+
CITATION: Lutar/Entanglement.lean (PR #230, merge 3a7f222ed3bb)
|
| 23 |
+
LEAN_THEOREM: Lutar/Entanglement.lean::capBound_antitone / entanglement_decays_under_bound (EXPERIMENTAL — PROPOSED gate, not a locked theorem)
|
| 24 |
+
"""
|
| 25 |
+
from __future__ import annotations
|
| 26 |
+
|
| 27 |
+
import math
|
| 28 |
+
from typing import TypedDict
|
| 29 |
+
|
| 30 |
+
CITATION = "Lutar/Entanglement.lean (PR #230, merge 3a7f222ed3bb)"
|
| 31 |
+
LEAN_THEOREM = (
|
| 32 |
+
"Lutar/Entanglement.lean::capBound_antitone"
|
| 33 |
+
" / entanglement_decays_under_bound"
|
| 34 |
+
" (EXPERIMENTAL — PROPOSED gate, not a locked theorem)"
|
| 35 |
+
)
|
| 36 |
+
_HONEST_NOTE = (
|
| 37 |
+
"EXPERIMENTAL-tier backbone: the Lean declarations are kernel-checked,"
|
| 38 |
+
" 0-sorry, no-new-axiom, but are PROPOSED engineering gates — NOT locked-8"
|
| 39 |
+
" theorems and NOT formal Λ results. This is a CAPACITY UPPER BOUND on"
|
| 40 |
+
" entanglement-generating capacity under coherence decay; it does not"
|
| 41 |
+
" guarantee any specific entanglement rate. The Python module is a"
|
| 42 |
+
" faithful but informal mirror of those proofs, not the proof itself."
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class CapBoundOut(TypedDict):
|
| 47 |
+
value: float
|
| 48 |
+
cap_bound: float
|
| 49 |
+
c0: float
|
| 50 |
+
gamma: float
|
| 51 |
+
t: float
|
| 52 |
+
nonneg: bool
|
| 53 |
+
antitone_check: bool
|
| 54 |
+
citation: str
|
| 55 |
+
lean_theorem: str
|
| 56 |
+
tier: str
|
| 57 |
+
honest_note: str
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def cap_bound(c0: float, gamma: float, t: float) -> float:
|
| 61 |
+
"""Coherence→entanglement-generating-capacity upper bound: C₀ · exp(−γ·t).
|
| 62 |
+
|
| 63 |
+
Mirrors ``capBound C₀ γ t`` in Lutar/Entanglement.lean.
|
| 64 |
+
|
| 65 |
+
Parameters
|
| 66 |
+
----------
|
| 67 |
+
c0 : initial capacity (≥ 0)
|
| 68 |
+
gamma : decay rate (≥ 0; γ=0 → constant bound)
|
| 69 |
+
t : time (≥ 0)
|
| 70 |
+
|
| 71 |
+
Returns the scalar bound value ≥ 0.
|
| 72 |
+
"""
|
| 73 |
+
if c0 < 0.0:
|
| 74 |
+
raise ValueError("c0 must be >= 0 (initial capacity is non-negative)")
|
| 75 |
+
if gamma < 0.0:
|
| 76 |
+
raise ValueError("gamma must be >= 0 (decay rate is non-negative)")
|
| 77 |
+
if t < 0.0:
|
| 78 |
+
raise ValueError("t must be >= 0 (time is non-negative)")
|
| 79 |
+
return c0 * math.exp(-gamma * t)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def cap_bound_nonneg(c0: float, gamma: float, t: float) -> bool:
|
| 83 |
+
"""Return True iff cap_bound(c0, gamma, t) >= 0.
|
| 84 |
+
|
| 85 |
+
Mirrors ``capBound_nonneg``. Always True for non-negative inputs (trivially
|
| 86 |
+
follows from exp being positive), but exposed as an explicit gate.
|
| 87 |
+
"""
|
| 88 |
+
return cap_bound(c0, gamma, t) >= 0.0
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def cap_bound_antitone(
|
| 92 |
+
c0: float, gamma: float, t1: float, t2: float
|
| 93 |
+
) -> bool:
|
| 94 |
+
"""Return True iff cap_bound is antitone: t1 < t2 → cap_bound(t1) ≥ cap_bound(t2).
|
| 95 |
+
|
| 96 |
+
Mirrors ``capBound_antitone``. For γ > 0 and t1 < t2 the bound strictly decreases.
|
| 97 |
+
For γ = 0 the bound is constant (weakly antitone, i.e. ≥ holds with equality).
|
| 98 |
+
"""
|
| 99 |
+
if t1 >= t2:
|
| 100 |
+
raise ValueError("antitone check requires t1 < t2")
|
| 101 |
+
return cap_bound(c0, gamma, t1) >= cap_bound(c0, gamma, t2) - 1e-15
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def entanglement_decays_under_bound(
|
| 105 |
+
c0: float, gamma: float, t: float, observed_capacity: float
|
| 106 |
+
) -> bool:
|
| 107 |
+
"""Return True iff observed_capacity ≤ cap_bound(c0, gamma, t).
|
| 108 |
+
|
| 109 |
+
Mirrors ``entanglement_decays_under_bound``: the actual entanglement-generating
|
| 110 |
+
capacity is bounded above by the exponential decay envelope. Use this as an
|
| 111 |
+
operational sanity gate on a measured or claimed capacity figure.
|
| 112 |
+
"""
|
| 113 |
+
return observed_capacity <= cap_bound(c0, gamma, t) + 1e-15
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def cap_bound_full(c0: float, gamma: float, t: float) -> CapBoundOut:
|
| 117 |
+
"""Full HONEST schema response for the capacity-bound endpoint."""
|
| 118 |
+
val = cap_bound(c0, gamma, t)
|
| 119 |
+
nonneg = val >= 0.0
|
| 120 |
+
# Antitone check: bound at t+1 should be <= bound at t (for t >= 0)
|
| 121 |
+
antitone = cap_bound_antitone(c0, gamma, t, t + 1.0) if gamma > 0.0 else True
|
| 122 |
+
return CapBoundOut(
|
| 123 |
+
value=val,
|
| 124 |
+
cap_bound=val,
|
| 125 |
+
c0=c0,
|
| 126 |
+
gamma=gamma,
|
| 127 |
+
t=t,
|
| 128 |
+
nonneg=nonneg,
|
| 129 |
+
antitone_check=antitone,
|
| 130 |
+
citation=CITATION,
|
| 131 |
+
lean_theorem=LEAN_THEOREM,
|
| 132 |
+
tier="experimental",
|
| 133 |
+
honest_note=_HONEST_NOTE,
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
__all__ = [
|
| 138 |
+
"cap_bound",
|
| 139 |
+
"cap_bound_nonneg",
|
| 140 |
+
"cap_bound_antitone",
|
| 141 |
+
"entanglement_decays_under_bound",
|
| 142 |
+
"cap_bound_full",
|
| 143 |
+
"CITATION",
|
| 144 |
+
"LEAN_THEOREM",
|
| 145 |
+
]
|
| 146 |
+
|
| 147 |
+
# Doctrine v11 LOCKED — 749/14/163 — c7c0ba17 · Λ = Conjecture 1 (NEVER a theorem)
|
| 148 |
+
# SLSA L1 honest. L2 build-provenance attestation = roadmap (Wire D) — not yet claimed. L3 not claimed.
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
if __name__ == "__main__":
|
| 152 |
+
# -----------------------------------------------------------------------
|
| 153 |
+
# Self-tests for cap_bound and derivative predicates
|
| 154 |
+
# -----------------------------------------------------------------------
|
| 155 |
+
checks = 0
|
| 156 |
+
|
| 157 |
+
# 1. cap_bound(C0, γ, 0) == C0 (mirrors capBound_nonneg + zero-time identity)
|
| 158 |
+
assert abs(cap_bound(2.5, 0.3, 0.0) - 2.5) < 1e-12, "cap_bound at t=0 must equal C0"
|
| 159 |
+
assert abs(cap_bound(0.0, 0.5, 10.0) - 0.0) < 1e-12, "cap_bound with C0=0 must be 0"
|
| 160 |
+
checks += 2
|
| 161 |
+
|
| 162 |
+
# 2. nonneg: always true for non-negative inputs
|
| 163 |
+
assert cap_bound_nonneg(1.0, 0.5, 5.0) is True, "bound must be non-negative"
|
| 164 |
+
assert cap_bound_nonneg(0.0, 0.0, 0.0) is True, "zero bound is non-negative"
|
| 165 |
+
checks += 2
|
| 166 |
+
|
| 167 |
+
# 3. antitone: bound at t+1 <= bound at t for γ > 0
|
| 168 |
+
assert cap_bound_antitone(1.0, 0.5, 0.0, 1.0) is True, "antitone: t=0 >= t=1"
|
| 169 |
+
assert cap_bound_antitone(3.0, 0.1, 2.0, 5.0) is True, "antitone: t=2 >= t=5"
|
| 170 |
+
checks += 2
|
| 171 |
+
|
| 172 |
+
# 4. entanglement_decays_under_bound
|
| 173 |
+
# Observed at the bound itself: must pass
|
| 174 |
+
cb = cap_bound(1.0, 0.5, 2.0)
|
| 175 |
+
assert entanglement_decays_under_bound(1.0, 0.5, 2.0, cb) is True, "at bound: ok"
|
| 176 |
+
# Observed above the bound: must fail
|
| 177 |
+
assert entanglement_decays_under_bound(1.0, 0.5, 2.0, cb + 0.1) is False, "above bound: fail"
|
| 178 |
+
checks += 2
|
| 179 |
+
|
| 180 |
+
# 5. Strict decay check: cap_bound(1, 1, 1) < cap_bound(1, 1, 0)
|
| 181 |
+
assert cap_bound(1.0, 1.0, 1.0) < cap_bound(1.0, 1.0, 0.0), "strictly decays for γ>0"
|
| 182 |
+
checks += 1
|
| 183 |
+
|
| 184 |
+
print(f"ok:true checks:{checks}")
|
szl_dark_surfaces_register.py
CHANGED
|
@@ -19,7 +19,8 @@ DARK SURFACES WIRED (route -> module -> register kind):
|
|
| 19 |
/api/<ns>/v1/formula/sovereign a11oy_formula_endpoints register(app, ns)
|
| 20 |
/api/<ns>/v1/energy/provenance szl_energy_provenance register(app, ns)
|
| 21 |
/api/<ns>/v1/heart/pulse szl_heart_blood register(app, ns)
|
| 22 |
-
/v1/ayni (+
|
|
|
|
| 23 |
/api/<ns>/v1/anatomy/loop szl_anatomy_loop register(app, ns) [#341]
|
| 24 |
|
| 25 |
ADDITIVE — never replaces a route, never edits another module. Registered BEFORE
|
|
@@ -99,22 +100,41 @@ def register(app: Any, ns: str = "a11oy") -> List[str]:
|
|
| 99 |
_stderr(line)
|
| 100 |
status.append(line)
|
| 101 |
|
| 102 |
-
# AYNI-OS is
|
| 103 |
-
# /v1/replay, /v1/tinkuy)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
try:
|
| 105 |
from ayni_os_serve import router as _ayni_router # type: ignore
|
| 106 |
included = False
|
| 107 |
include_router = getattr(app, "include_router", None)
|
| 108 |
if callable(include_router):
|
|
|
|
|
|
|
|
|
|
| 109 |
app.include_router(_ayni_router)
|
| 110 |
included = True
|
| 111 |
else:
|
| 112 |
-
# Bare Starlette fallback: splice the router's routes onto app.router
|
|
|
|
|
|
|
| 113 |
for _r in getattr(_ayni_router, "routes", []):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
app.router.routes.append(_r)
|
| 115 |
included = True
|
| 116 |
if included:
|
| 117 |
-
line = "[a11oy:dark] AYNI-OS mounted: /v1/ayni + /v1/replay + /v1/tinkuy"
|
| 118 |
_stderr(line)
|
| 119 |
status.append(line)
|
| 120 |
except Exception as exc: # additive: AYNI absent never blocks the other six
|
|
|
|
| 19 |
/api/<ns>/v1/formula/sovereign a11oy_formula_endpoints register(app, ns)
|
| 20 |
/api/<ns>/v1/energy/provenance szl_energy_provenance register(app, ns)
|
| 21 |
/api/<ns>/v1/heart/pulse szl_heart_blood register(app, ns)
|
| 22 |
+
/api/<ns>/v1/ayni (+ replay, ayni_os_serve include_router(prefix=/api/<ns>)
|
| 23 |
+
tinkuy; legacy bare /v1/ayni kept)
|
| 24 |
/api/<ns>/v1/anatomy/loop szl_anatomy_loop register(app, ns) [#341]
|
| 25 |
|
| 26 |
ADDITIVE — never replaces a route, never edits another module. Registered BEFORE
|
|
|
|
| 100 |
_stderr(line)
|
| 101 |
status.append(line)
|
| 102 |
|
| 103 |
+
# AYNI-OS is a self-contained APIRouter whose routes declare bare paths
|
| 104 |
+
# (/v1/ayni, /v1/replay, /v1/tinkuy). The DOCUMENTED, dashboard-facing contract
|
| 105 |
+
# is /api/<ns>/v1/ayni (the same /api/<ns>/v1/* shape every other dark surface
|
| 106 |
+
# uses); mounting the router WITHOUT a prefix left it at /v1/ayni, so the
|
| 107 |
+
# documented /api/<ns>/v1/ayni 404'd (it fell through to the Node proxy, which
|
| 108 |
+
# answered {"error":"not found","path":"/v1/ayni"}). FIX: include the router under
|
| 109 |
+
# prefix=/api/<ns> so the documented /api/<ns>/v1/ayni path resolves LOCALLY and
|
| 110 |
+
# wins ordering (registered here, before the SPA catch-all / Node proxy). We ALSO
|
| 111 |
+
# keep the legacy bare /v1/ayni mount for back-compat — purely additive, so any
|
| 112 |
+
# existing caller of the old path is never broken. NOT register(app, ns) — own
|
| 113 |
+
# try/except below so AYNI absent never blocks the other six surfaces.
|
| 114 |
try:
|
| 115 |
from ayni_os_serve import router as _ayni_router # type: ignore
|
| 116 |
included = False
|
| 117 |
include_router = getattr(app, "include_router", None)
|
| 118 |
if callable(include_router):
|
| 119 |
+
# Documented path: /api/<ns>/v1/ayni (+ /replay, /tinkuy). Resolves LOCALLY.
|
| 120 |
+
app.include_router(_ayni_router, prefix=f"/api/{ns}")
|
| 121 |
+
# Legacy path: bare /v1/ayni — additive back-compat, breaks no caller.
|
| 122 |
app.include_router(_ayni_router)
|
| 123 |
included = True
|
| 124 |
else:
|
| 125 |
+
# Bare Starlette fallback: splice the router's routes onto app.router at
|
| 126 |
+
# BOTH the documented /api/<ns> prefix and the legacy bare path.
|
| 127 |
+
from starlette.routing import Route as _Route
|
| 128 |
for _r in getattr(_ayni_router, "routes", []):
|
| 129 |
+
_path = getattr(_r, "path", None)
|
| 130 |
+
_ep = getattr(_r, "endpoint", None)
|
| 131 |
+
_methods = list(getattr(_r, "methods", []) or ["GET"])
|
| 132 |
+
if _path is not None and _ep is not None:
|
| 133 |
+
app.router.routes.append(_Route(f"/api/{ns}{_path}", _ep, methods=_methods))
|
| 134 |
app.router.routes.append(_r)
|
| 135 |
included = True
|
| 136 |
if included:
|
| 137 |
+
line = f"[a11oy:dark] AYNI-OS mounted: /api/{ns}/v1/ayni + /api/{ns}/v1/replay + /api/{ns}/v1/tinkuy (legacy /v1/ayni kept)"
|
| 138 |
_stderr(line)
|
| 139 |
status.append(line)
|
| 140 |
except Exception as exc: # additive: AYNI absent never blocks the other six
|