Spaces:
Running
Running
deploy(hf): sync szl-holdings/a11oy@5eeceec2a494fc4d55794023bd7ebc8373124a73 derived COPY set
Browse filesReusable Dockerfile-COPY-derived deploy from szl-holdings/a11oy 5eeceec2a494fc4d55794023bd7ebc8373124a73.
Files: 1301 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>
- Dockerfile +9 -0
- ops/szl_chain_of_title.rego +196 -0
- serve.py +22 -0
- static/3d/holographic.html +1 -0
- static/3d/surfaces/attest.js +592 -0
- szl3d_holographic.py +1 -0
- szl_attest.py +1242 -0
Dockerfile
CHANGED
|
@@ -644,6 +644,15 @@ COPY szl_organ_integrity.py ./szl_organ_integrity.py
|
|
| 644 |
# Packet 8 Decision Integrity desk on a-11-oy.com (GET /decision).
|
| 645 |
# Frozen evals. Formula authority NONE. Status ROADMAP. Does not stamp LIVE.
|
| 646 |
# Bound-path Command Center SPA on a-11-oy.com/command. Does not steal /console.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 647 |
COPY verticals/_kernel/a11oy_kernel.py ./verticals/_kernel/a11oy_kernel.py
|
| 648 |
COPY verticals/PACKET8.json ./verticals/PACKET8.json
|
| 649 |
COPY verticals/terra ./verticals/terra
|
|
|
|
| 644 |
# Packet 8 Decision Integrity desk on a-11-oy.com (GET /decision).
|
| 645 |
# Frozen evals. Formula authority NONE. Status ROADMAP. Does not stamp LIVE.
|
| 646 |
# Bound-path Command Center SPA on a-11-oy.com/command. Does not steal /console.
|
| 647 |
+
# L6 CHAIN-OF-TITLE ATTESTATION (Wave 32): in-toto v1 Statement whose subject binds
|
| 648 |
+
# the locked-8 kernel gitCommit, DSSE-signed via szl_dsse, with a guarded Rekor
|
| 649 |
+
# submission that records UNREACHABLE/UNKNOWN rather than a fabricated entry.
|
| 650 |
+
# Serves GET /api/a11oy/v1/attest/manifest and GET|POST /api/a11oy/v1/attest/verify
|
| 651 |
+
# plus the `attest` holographic surface. Policy: ops/szl_chain_of_title.rego.
|
| 652 |
+
COPY szl_attest.py ./szl_attest.py
|
| 653 |
+
COPY ops/szl_chain_of_title.rego ./ops/szl_chain_of_title.rego
|
| 654 |
+
COPY static/3d/surfaces/attest.js ./static/3d/surfaces/attest.js
|
| 655 |
+
|
| 656 |
COPY verticals/_kernel/a11oy_kernel.py ./verticals/_kernel/a11oy_kernel.py
|
| 657 |
COPY verticals/PACKET8.json ./verticals/PACKET8.json
|
| 658 |
COPY verticals/terra ./verticals/terra
|
ops/szl_chain_of_title.rego
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
# © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
#
|
| 4 |
+
# szl_chain_of_title.rego — L6 CHAIN-OF-TITLE ATTESTATION POLICY.
|
| 5 |
+
#
|
| 6 |
+
# Input: an in-toto v1 Statement (https://in-toto.io/Statement/v1) carrying
|
| 7 |
+
# predicateType "https://szl.dev/chain-of-title/v1", as emitted by szl_attest.py
|
| 8 |
+
# and DSSE-signed via szl_dsse. Evaluate with OPA:
|
| 9 |
+
#
|
| 10 |
+
# opa eval -i statement.json -d ops/szl_chain_of_title.rego \
|
| 11 |
+
# 'data.szl.attest.chain_of_title.verdict'
|
| 12 |
+
#
|
| 13 |
+
# The verdict is TRI-STATE and fails closed:
|
| 14 |
+
#
|
| 15 |
+
# PASSED — every rule below holds.
|
| 16 |
+
# FAILED — at least one rule does not hold (a tampered or under-provenanced
|
| 17 |
+
# Statement is FAILED, never UNKNOWN).
|
| 18 |
+
# UNKNOWN — reserved for the TRANSPARENCY strand, which this policy does not
|
| 19 |
+
# and cannot evaluate offline: a Rekor inclusion proof is a live
|
| 20 |
+
# network fact. When the caller requires transparency
|
| 21 |
+
# (input.require_transparency == true) and no real inclusion proof
|
| 22 |
+
# is present, the verdict is UNKNOWN — NEVER a fabricated PASSED.
|
| 23 |
+
#
|
| 24 |
+
# Doctrine v11 (binding): no fabricated PASSED / MEASURED / Rekor entry; Λ is
|
| 25 |
+
# Conjecture 1, never a theorem; the locked-8 {F1,F4,F7,F11,F12,F18,F19,F22} @
|
| 26 |
+
# c7c0ba17 is immutable and this policy only ATTESTS the pin, never extends it;
|
| 27 |
+
# provenance coverage must be fully disclosed at 1.0.
|
| 28 |
+
#
|
| 29 |
+
# Cited prior art (SZL claims none of it as its own):
|
| 30 |
+
# in-toto Attestation Framework — https://github.com/in-toto/attestation
|
| 31 |
+
# SLSA v1.1 (Build L0-L3 + VSA) — https://slsa.dev/spec/v1.1/
|
| 32 |
+
# Sigstore / Rekor transparency — https://docs.sigstore.dev/logging/overview/
|
| 33 |
+
# DSSE — https://github.com/secure-systems-lab/dsse
|
| 34 |
+
# sigstore/model-transparency — https://github.com/sigstore/model-transparency
|
| 35 |
+
#
|
| 36 |
+
# This file is the AUTHORITATIVE statement of the policy. szl_attest.evaluate_policy
|
| 37 |
+
# mirrors it rule for rule in-process so the API verdict and an external OPA
|
| 38 |
+
# evaluation agree; tests/test_attest.py asserts the rule names stay in lockstep.
|
| 39 |
+
|
| 40 |
+
package szl.attest.chain_of_title
|
| 41 |
+
|
| 42 |
+
import future.keywords.if
|
| 43 |
+
import future.keywords.in
|
| 44 |
+
|
| 45 |
+
expected_predicate_type := "https://szl.dev/chain-of-title/v1"
|
| 46 |
+
|
| 47 |
+
expected_doctrine := "v11"
|
| 48 |
+
|
| 49 |
+
kernel_subject_name := "locked8_kernel"
|
| 50 |
+
|
| 51 |
+
# --------------------------------------------------------------------------- #
|
| 52 |
+
# Rule 1 — the predicate type is exactly the SZL chain-of-title type.
|
| 53 |
+
# --------------------------------------------------------------------------- #
|
| 54 |
+
predicate_type_matches if {
|
| 55 |
+
input.predicateType == expected_predicate_type
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
# --------------------------------------------------------------------------- #
|
| 59 |
+
# Rule 2 — doctrine v11. An unversioned or drifted doctrine is not attestable.
|
| 60 |
+
# --------------------------------------------------------------------------- #
|
| 61 |
+
doctrine_is_v11 if {
|
| 62 |
+
input.predicate.doctrine == expected_doctrine
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
# --------------------------------------------------------------------------- #
|
| 66 |
+
# Rule 3 — the locked-8 kernel was actually verified when the Statement was
|
| 67 |
+
# built (szl_attest re-checks the digest-verified formula registry). Must be
|
| 68 |
+
# boolean true; a truthy string or a missing field does not pass.
|
| 69 |
+
# --------------------------------------------------------------------------- #
|
| 70 |
+
kernel_verified if {
|
| 71 |
+
input.predicate.provenance.kernel_verified == true
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
# --------------------------------------------------------------------------- #
|
| 75 |
+
# Rule 4 — every honesty invariant holds. These are the doctrine claims bound
|
| 76 |
+
# INTO the signed predicate; this is what makes the doctrine third-party
|
| 77 |
+
# checkable rather than a marketing line.
|
| 78 |
+
# --------------------------------------------------------------------------- #
|
| 79 |
+
honesty_invariants_all_true if {
|
| 80 |
+
inv := input.predicate.honesty_invariants
|
| 81 |
+
inv.no_fabricated_measured == true
|
| 82 |
+
inv.lambda_is_conjecture_not_theorem == true
|
| 83 |
+
inv.locked8_immutable == true
|
| 84 |
+
inv.provenance_coverage == 1.0
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
# --------------------------------------------------------------------------- #
|
| 88 |
+
# Rule 5 — provenance coverage is exactly 1.0 (fully DISCLOSED: every field is
|
| 89 |
+
# a real read or an explicit null with its reason; nothing omitted).
|
| 90 |
+
# --------------------------------------------------------------------------- #
|
| 91 |
+
provenance_coverage_is_one if {
|
| 92 |
+
input.predicate.provenance.provenance_coverage == 1.0
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
# --------------------------------------------------------------------------- #
|
| 96 |
+
# Rule 6 — the subject binds a NON-EMPTY locked-8 kernel gitCommit. An
|
| 97 |
+
# attestation with no bound kernel commit attests nothing.
|
| 98 |
+
# --------------------------------------------------------------------------- #
|
| 99 |
+
subject_binds_kernel_commit if {
|
| 100 |
+
some s in input.subject
|
| 101 |
+
s.name == kernel_subject_name
|
| 102 |
+
commit := s.digest.gitCommit
|
| 103 |
+
is_string(commit)
|
| 104 |
+
trim_space(commit) != ""
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
# --------------------------------------------------------------------------- #
|
| 108 |
+
# Aggregate — passed iff ALL SIX rules hold. Default false: fail closed.
|
| 109 |
+
# --------------------------------------------------------------------------- #
|
| 110 |
+
default passed := false
|
| 111 |
+
|
| 112 |
+
passed if {
|
| 113 |
+
predicate_type_matches
|
| 114 |
+
doctrine_is_v11
|
| 115 |
+
kernel_verified
|
| 116 |
+
honesty_invariants_all_true
|
| 117 |
+
provenance_coverage_is_one
|
| 118 |
+
subject_binds_kernel_commit
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
# Named failures, so a denial always says which rule broke rather than just "no".
|
| 122 |
+
failed_rules contains "predicate_type_matches" if not predicate_type_matches
|
| 123 |
+
|
| 124 |
+
failed_rules contains "doctrine_is_v11" if not doctrine_is_v11
|
| 125 |
+
|
| 126 |
+
failed_rules contains "kernel_verified" if not kernel_verified
|
| 127 |
+
|
| 128 |
+
failed_rules contains "honesty_invariants_all_true" if not honesty_invariants_all_true
|
| 129 |
+
|
| 130 |
+
failed_rules contains "provenance_coverage_is_one" if not provenance_coverage_is_one
|
| 131 |
+
|
| 132 |
+
failed_rules contains "subject_binds_kernel_commit" if not subject_binds_kernel_commit
|
| 133 |
+
|
| 134 |
+
# --------------------------------------------------------------------------- #
|
| 135 |
+
# Transparency strand — evaluated ONLY from evidence the caller supplies. A
|
| 136 |
+
# real Rekor inclusion proof plus a log index is the only thing that counts.
|
| 137 |
+
# There is deliberately no branch that infers inclusion from anything else.
|
| 138 |
+
# --------------------------------------------------------------------------- #
|
| 139 |
+
default transparency_recorded := false
|
| 140 |
+
|
| 141 |
+
transparency_recorded if {
|
| 142 |
+
input.rekor.status == "RECORDED"
|
| 143 |
+
input.rekor.inclusion_proof != null
|
| 144 |
+
input.rekor.log_index != null
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
default transparency_required := false
|
| 148 |
+
|
| 149 |
+
transparency_required if {
|
| 150 |
+
input.require_transparency == true
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
# --------------------------------------------------------------------------- #
|
| 154 |
+
# The tri-state verdict. Order matters: FAILED wins over UNKNOWN, so a tampered
|
| 155 |
+
# Statement can never hide behind an unreachable log.
|
| 156 |
+
# --------------------------------------------------------------------------- #
|
| 157 |
+
verdict := "FAILED" if {
|
| 158 |
+
not passed
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
verdict := "UNKNOWN" if {
|
| 162 |
+
passed
|
| 163 |
+
transparency_required
|
| 164 |
+
not transparency_recorded
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
verdict := "PASSED" if {
|
| 168 |
+
passed
|
| 169 |
+
not transparency_required
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
verdict := "PASSED" if {
|
| 173 |
+
passed
|
| 174 |
+
transparency_required
|
| 175 |
+
transparency_recorded
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
# Honest scope string, so a policy-only PASSED is never read as a
|
| 179 |
+
# transparency-anchored one.
|
| 180 |
+
verdict_scope := "policy-only: chain-of-title rules hold; transparency strand not evaluated" if {
|
| 181 |
+
verdict == "PASSED"
|
| 182 |
+
not transparency_recorded
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
verdict_scope := "policy + transparency: rules hold and a real Rekor inclusion proof is present" if {
|
| 186 |
+
verdict == "PASSED"
|
| 187 |
+
transparency_recorded
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
verdict_scope := "transparency required but no real inclusion proof present — UNKNOWN, never a fabricated PASSED" if {
|
| 191 |
+
verdict == "UNKNOWN"
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
verdict_scope := sprintf("failed policy rules: %v", [sort(failed_rules)]) if {
|
| 195 |
+
verdict == "FAILED"
|
| 196 |
+
}
|
serve.py
CHANGED
|
@@ -1708,6 +1708,28 @@ try:
|
|
| 1708 |
except Exception as _szl_attest_e: # pragma: no cover
|
| 1709 |
print(f"[a11oy] Attestation surface NOT registered: {_szl_attest_e!r}; SPA + API unaffected", file=__import__("sys").stderr)
|
| 1710 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1711 |
# ── WAVE-H TEAM 3: ATTESTED INFERENCE (deepening of Wave-A cc-attest). Endpoint
|
| 1712 |
# GET /api/a11oy/v1/attest/infer?seed&model → deterministic MODELED flow: device attestation
|
| 1713 |
# (reuses szl_tee_attest measured-boot chain) → Λ-gate (weighted geomean, Conjecture 1) →
|
|
|
|
| 1708 |
except Exception as _szl_attest_e: # pragma: no cover
|
| 1709 |
print(f"[a11oy] Attestation surface NOT registered: {_szl_attest_e!r}; SPA + API unaffected", file=__import__("sys").stderr)
|
| 1710 |
|
| 1711 |
+
# ── WAVE-32 DEV E: L6 CHAIN-OF-TITLE ATTESTATION (the allodial claim, made third-party
|
| 1712 |
+
# verifiable). GET /api/a11oy/v1/attest/manifest → an in-toto v1 Statement (subject binds the
|
| 1713 |
+
# locked-8 kernel gitCommit c7c0ba17, plus a sovereign-weights sha256 ONLY when a real weights
|
| 1714 |
+
# artifact is readable this request; honest null otherwise), predicateType
|
| 1715 |
+
# "https://szl.dev/chain-of-title/v1", predicate = doctrine v11 + provenance (corpus_sha, training
|
| 1716 |
+
# cfg read from the committed trainer, kernel_verified re-checked against the digest-verified
|
| 1717 |
+
# formula registry, kernel_pin) + energy_measured[] (HONESTLY EMPTY with no live joule meter) +
|
| 1718 |
+
# honesty_invariants + the tier-PROPOSED SEAL formula; DSSE-signed via szl_dsse (UNSIGNED and
|
| 1719 |
+
# labelled so when no runtime cosign secret exists) and structured for cosign keyless / Rekor.
|
| 1720 |
+
# GET+POST /api/a11oy/v1/attest/verify → PASSED / FAILED honestly, UNKNOWN when a required Rekor
|
| 1721 |
+
# inclusion proof is unreachable. NEVER a fabricated PASSED, MEASURED, or Rekor entry. Policy is
|
| 1722 |
+
# authoritative in ops/szl_chain_of_title.rego and mirrored in-process rule for rule. Registered
|
| 1723 |
+
# AFTER szl_attest_stack so the STATIC /attest/manifest + /attest/verify routes front-insert ahead
|
| 1724 |
+
# of the parametrized /attest/{receipt_hash} route, and BEFORE the SPA catch-all. Additive,
|
| 1725 |
+
# try/except-guarded. Adds NOTHING to the locked-8; Λ stays Conjecture 1.
|
| 1726 |
+
try:
|
| 1727 |
+
import szl_attest as _szl_attest
|
| 1728 |
+
_szl_attest_status = _szl_attest.register(app, ns="a11oy")
|
| 1729 |
+
print(f"[a11oy] L6 chain-of-title attestation registered: {_szl_attest_status}", file=__import__("sys").stderr)
|
| 1730 |
+
except Exception as _szl_attest_l6_e: # pragma: no cover
|
| 1731 |
+
print(f"[a11oy] L6 chain-of-title attestation NOT registered: {_szl_attest_l6_e!r}; SPA + API unaffected", file=__import__("sys").stderr)
|
| 1732 |
+
|
| 1733 |
# ── WAVE-H TEAM 3: ATTESTED INFERENCE (deepening of Wave-A cc-attest). Endpoint
|
| 1734 |
# GET /api/a11oy/v1/attest/infer?seed&model → deterministic MODELED flow: device attestation
|
| 1735 |
# (reuses szl_tee_attest measured-boot chain) → Λ-gate (weighted geomean, Conjecture 1) →
|
static/3d/holographic.html
CHANGED
|
@@ -423,6 +423,7 @@ const SURFACES = [
|
|
| 423 |
{ id: "open", cat: "more", flag: true, title: "Open Frontier · Live Hugging Face · MEASURED live Hugging Face Hub trending stream — one pillar per org/author (height = summed likes, bead = download reach); most-liked open models orbit as satellites coloured by task; log-scaling is display-only, no invented benchmark, score, or ranking beyond the Hub’s own", mod: "/static/3d/surfaces/open.js" },
|
| 424 |
{ id: "brainagent", cat: "brain", title: "Brain Agent · honesty-gated agentic graph reasoner · treats the brain graph as a state space and walks it one node at a time for a query, choosing EXPAND/FOLLOW/BACKTRACK/STOP by pure graph heuristics (no model call, fully deterministic); every candidate hop passes an honesty gate built from the sibling surfaces (grounding, provenance, contradiction, uncertainty) — an ungrounded/untraceable/contradicted/uncertain hop is refused with a recorded reason, an absent guard is UNAVAILABLE never a fabricated pass; within an explicit step/node budget it returns ANSWER-GROUNDED/PARTIAL or abstains ABSTAINED-BUDGET/ABSTAINED-INSUFFICIENT rather than answer under-grounded, emits an ordered trace + unsigned SHA-256 receipt-on-write, makes no sentience claim (MODELED)", mod: "/static/3d/surfaces/brainagent.js" },
|
| 425 |
{ id: "estateconstitution", cat: "governance", title: "Estate Constitution · the WHOLE ESTATE's honesty posture graded continuously against explicit estate-level ARTICLES (the per-query brain-constitution pattern lifted to the estate) · Art 1 the honesty wall holds (0 REACHABLE invariant violations), Art 2 no surface declares a fabricated MEASURED label (every declared label in the honest vocabulary, read VERBATIM), Art 3 manifest coverage DISCLOSED honestly (NATIVE-OK vs NO-MANIFEST counted out loud — a DISCLOSURE Article: admitting the gap is compliance, papering it over is the violation, full coverage never claimed while any surface is unverifiable), Art 4 doctrine invariants (Λ = Conjecture 1 never a theorem, locked-8 never inflated, trust ceiling 0.97 never 100%, no consciousness claim) · each graded COMPLIANT/VIOLATED/UNAVAILABLE over the szl_honestywall aggregate read in-process through a GUARDED import (an unreadable aggregate is UNAVAILABLE, never a fabricated pass) → CONSTITUTIONAL/IN-VIOLATION/INSUFFICIENT-SIGNAL, never CONSTITUTIONAL while any evaluable Article is VIOLATED, unsigned SHA-256 receipt-on-write (MODELED)", mod: "/static/3d/surfaces/estateconstitution.js" },
|
|
|
|
| 426 |
];
|
| 427 |
|
| 428 |
const stageEl = document.getElementById("stage");
|
|
|
|
| 423 |
{ id: "open", cat: "more", flag: true, title: "Open Frontier · Live Hugging Face · MEASURED live Hugging Face Hub trending stream — one pillar per org/author (height = summed likes, bead = download reach); most-liked open models orbit as satellites coloured by task; log-scaling is display-only, no invented benchmark, score, or ranking beyond the Hub’s own", mod: "/static/3d/surfaces/open.js" },
|
| 424 |
{ id: "brainagent", cat: "brain", title: "Brain Agent · honesty-gated agentic graph reasoner · treats the brain graph as a state space and walks it one node at a time for a query, choosing EXPAND/FOLLOW/BACKTRACK/STOP by pure graph heuristics (no model call, fully deterministic); every candidate hop passes an honesty gate built from the sibling surfaces (grounding, provenance, contradiction, uncertainty) — an ungrounded/untraceable/contradicted/uncertain hop is refused with a recorded reason, an absent guard is UNAVAILABLE never a fabricated pass; within an explicit step/node budget it returns ANSWER-GROUNDED/PARTIAL or abstains ABSTAINED-BUDGET/ABSTAINED-INSUFFICIENT rather than answer under-grounded, emits an ordered trace + unsigned SHA-256 receipt-on-write, makes no sentience claim (MODELED)", mod: "/static/3d/surfaces/brainagent.js" },
|
| 425 |
{ id: "estateconstitution", cat: "governance", title: "Estate Constitution · the WHOLE ESTATE's honesty posture graded continuously against explicit estate-level ARTICLES (the per-query brain-constitution pattern lifted to the estate) · Art 1 the honesty wall holds (0 REACHABLE invariant violations), Art 2 no surface declares a fabricated MEASURED label (every declared label in the honest vocabulary, read VERBATIM), Art 3 manifest coverage DISCLOSED honestly (NATIVE-OK vs NO-MANIFEST counted out loud — a DISCLOSURE Article: admitting the gap is compliance, papering it over is the violation, full coverage never claimed while any surface is unverifiable), Art 4 doctrine invariants (Λ = Conjecture 1 never a theorem, locked-8 never inflated, trust ceiling 0.97 never 100%, no consciousness claim) · each graded COMPLIANT/VIOLATED/UNAVAILABLE over the szl_honestywall aggregate read in-process through a GUARDED import (an unreadable aggregate is UNAVAILABLE, never a fabricated pass) → CONSTITUTIONAL/IN-VIOLATION/INSUFFICIENT-SIGNAL, never CONSTITUTIONAL while any evaluable Article is VIOLATED, unsigned SHA-256 receipt-on-write (MODELED)", mod: "/static/3d/surfaces/estateconstitution.js" },
|
| 426 |
+
{ id: "attest", cat: "governance", title: "Chain of Title · L6 attestation · the allodial claim made third-party verifiable · an in-toto v1 Statement whose SUBJECT binds the locked-8 kernel gitCommit c7c0ba17 (plus a sovereign-weights sha256 ONLY when a real weights artifact is readable this request — honest null otherwise, never an invented digest), predicateType https://szl.dev/chain-of-title/v1, predicate = doctrine v11 + provenance (corpus_sha, training config read VERBATIM from the committed trainer, kernel_verified RE-CHECKED this request against the digest-verified formula registry, kernel_pin) + energy_measured[] (HONESTLY EMPTY with no live joule meter — no joule fabricated) + honesty_invariants {no_fabricated_measured, lambda_is_conjecture_not_theorem, locked8_immutable, provenance_coverage 1.0} bound INTO the signed predicate so the doctrine itself becomes third-party checkable + the tier-PROPOSED SEAL formula (EU CSF SEAL + HHI prior art, no score asserted) · DSSE-signed through the estate cosign key (explicitly UNSIGNED-NO-KEY when no runtime secret is present, never a fabricated signature) and structured for cosign keyless + Rekor: a real inclusion proof reads RECORDED/MEASURED, an unreachable log reads UNREACHABLE and the verdict is UNKNOWN — never a fabricated Rekor entry or PASSED · the verdict is tri-state and FAILED beats UNKNOWN so a tampered Statement cannot hide behind an offline log; policy authoritative in ops/szl_chain_of_title.rego, mirrored in-process rule for rule (MODELED)", mod: "/static/3d/surfaces/attest.js" },
|
| 427 |
];
|
| 428 |
|
| 429 |
const stageEl = document.getElementById("stage");
|
static/3d/surfaces/attest.js
ADDED
|
@@ -0,0 +1,592 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
// © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
//
|
| 4 |
+
// surfaces/attest.js — CHAIN OF TITLE · L6 ATTESTATION. The allodial claim, drawn as the thing a
|
| 5 |
+
// third party can actually check. One PILLAR per chain-of-title policy rule (predicate type ·
|
| 6 |
+
// doctrine v11 · kernel verified · honesty invariants · provenance coverage 1.0 · subject binds a
|
| 7 |
+
// non-empty kernel commit), a CORE orb carrying the tri-state verdict PASSED / FAILED / UNKNOWN,
|
| 8 |
+
// two SUBJECT anchors on the floor (the locked-8 kernel gitCommit, always bound; the sovereign
|
| 9 |
+
// weights sha256, drawn grey and hollow when no weights artifact is readable — an absent subject
|
| 10 |
+
// is SHOWN, never invented), and a TRANSPARENCY beam standing for the Rekor strand.
|
| 11 |
+
//
|
| 12 |
+
// Pure honesty / provenance / observability. It advances NO detection, fusion, effector, targeting
|
| 13 |
+
// or cueing capability, and it proves nothing new about the locked-8 — it ATTESTS the pin.
|
| 14 |
+
//
|
| 15 |
+
// DATA: live snapshot from GET /api/a11oy/v1/attest/manifest (PURE READ; the ledger write is
|
| 16 |
+
// opt-in on SZL_LAKE_DIR and never happens on this path):
|
| 17 |
+
// ok, label, verdict, verdict_scope, statement_digest_sha256,
|
| 18 |
+
// statement{ _type, predicateType, subject[]{name,digest}, predicate{ doctrine,
|
| 19 |
+
// provenance{ corpus_sha, kernel_verified, kernel_pin, provenance_coverage },
|
| 20 |
+
// energy_measured[], honesty_invariants{...}, seal{ formula, tier }, lambda{...} } },
|
| 21 |
+
// envelope{ signed, payloadType, signatures[] },
|
| 22 |
+
// rekor{ status (RECORDED|UNREACHABLE|NOT_ATTEMPTED), log_index, inclusion_proof, label },
|
| 23 |
+
// verification{ policy{ checks{...}, failed[] }, signature{ status }, transparency{...} }.
|
| 24 |
+
//
|
| 25 |
+
// HONESTY LABEL: MODELED. It becomes MEASURED only for the transparency strand, and only when a
|
| 26 |
+
// REAL Rekor inclusion proof came back in the same request — the surface reads the server's
|
| 27 |
+
// label VERBATIM and never upgrades it. UNKNOWN is drawn as UNKNOWN: an unreachable
|
| 28 |
+
// transparency log is never coloured as a pass. A FAILED rule is drawn tallest so it cannot
|
| 29 |
+
// hide. Λ = Conjecture 1 (never a theorem, never green). Trust ceiling 0.97, never 100%. The
|
| 30 |
+
// SEAL formula is shown with its tier PROPOSED attached, and no score is asserted.
|
| 31 |
+
// COLOURS (approved palette only, no green): proof-teal 0x3af4c8 (PASSED / rule holds / RECORDED),
|
| 32 |
+
// lattice-blue 0x5b8dee (frame / UNKNOWN), violet-blue 0x8a6bff (FAILED / rule broken),
|
| 33 |
+
// grey 0x42505d (absent subject / NOT_ATTEMPTED / init).
|
| 34 |
+
// 0 RUNTIME CDN. Vendored three.js via the page importmap (ctx.THREE).
|
| 35 |
+
// CITED PRIOR ART (SZL claims none of it as its own): in-toto Attestation Framework; SLSA v1.1
|
| 36 |
+
// Build L0-L3 + Verification Summary Attestation; Sigstore/cosign keyless + Rekor; DSSE;
|
| 37 |
+
// sigstore/model-transparency; EU Cloud Sovereignty Framework SEAL + HHI (the SEAL formula).
|
| 38 |
+
// DOCTRINE v11: adds NOTHING to the locked-8 {F1,F4,F7,F11,F12,F18,F19,F22} @ c7c0ba17; introduces
|
| 39 |
+
// no theorem; makes no consciousness claim. Degrades grey on 404/error.
|
| 40 |
+
|
| 41 |
+
import { createShowcase } from "./_showcase.js";
|
| 42 |
+
|
| 43 |
+
const ID = "attest";
|
| 44 |
+
const TITLE = "Chain of Title · L6 attestation · the allodial claim, third-party verifiable (live)";
|
| 45 |
+
|
| 46 |
+
// same-origin, relative — no CDN, no cross-origin fetch. PURE-READ attestation endpoint.
|
| 47 |
+
const EP = "/api/a11oy/v1/attest/manifest";
|
| 48 |
+
|
| 49 |
+
const C_OK = 0x3af4c8; // proof-teal — PASSED / rule holds / RECORDED
|
| 50 |
+
const C_MID = 0x5b8dee; // lattice-blue — UNKNOWN / frame
|
| 51 |
+
const C_BAD = 0x8a6bff; // violet-blue — FAILED / rule broken
|
| 52 |
+
const C_NEUTRAL = 0x42505d; // grey — absent subject / NOT_ATTEMPTED / init
|
| 53 |
+
const C_GRID = 0x1b3a44;
|
| 54 |
+
|
| 55 |
+
// The six policy rules, in the order ops/szl_chain_of_title.rego declares them.
|
| 56 |
+
const RULES = [
|
| 57 |
+
["predicate_type_matches", "predicate type"],
|
| 58 |
+
["doctrine_is_v11", "doctrine v11"],
|
| 59 |
+
["kernel_verified", "kernel verified"],
|
| 60 |
+
["honesty_invariants_all_true", "honesty invariants"],
|
| 61 |
+
["provenance_coverage_is_one", "provenance 1.0"],
|
| 62 |
+
["subject_binds_kernel_commit", "subject binds kernel"],
|
| 63 |
+
];
|
| 64 |
+
|
| 65 |
+
function _verdictColor(v) {
|
| 66 |
+
const s = String(v || "").toUpperCase();
|
| 67 |
+
if (s === "PASSED") return C_OK;
|
| 68 |
+
if (s === "FAILED") return C_BAD;
|
| 69 |
+
if (s === "UNKNOWN") return C_MID;
|
| 70 |
+
return C_NEUTRAL;
|
| 71 |
+
}
|
| 72 |
+
function _ruleColor(held) {
|
| 73 |
+
if (held === true) return C_OK;
|
| 74 |
+
if (held === false) return C_BAD;
|
| 75 |
+
return C_NEUTRAL; // not evaluated this request
|
| 76 |
+
}
|
| 77 |
+
function _rekorColor(status) {
|
| 78 |
+
const s = String(status || "").toUpperCase();
|
| 79 |
+
if (s === "RECORDED") return C_OK;
|
| 80 |
+
if (s === "UNREACHABLE") return C_MID; // UNKNOWN, never a pass
|
| 81 |
+
return C_NEUTRAL; // NOT_ATTEMPTED / init
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
let _stage = null, _THREE = null, _ctx = null, _group = null, _show = null;
|
| 85 |
+
let _frameReg = false, _polls = [], _el = {}, _badge = null, _plain = false;
|
| 86 |
+
|
| 87 |
+
let _core = null; // verdict core orb
|
| 88 |
+
let _pillars = []; // [{ mesh, key, held }]
|
| 89 |
+
let _anchors = []; // [{ mesh, name, bound }]
|
| 90 |
+
let _beam = null; // transparency (Rekor) beam
|
| 91 |
+
let _spin = 0;
|
| 92 |
+
|
| 93 |
+
// live state — every field read from JSON; nothing invented
|
| 94 |
+
const S = {
|
| 95 |
+
label: null, // server label VERBATIM (MODELED, or MEASURED for a real inclusion proof)
|
| 96 |
+
verdict: null, // PASSED | FAILED | UNKNOWN
|
| 97 |
+
scope: null, // what the verdict actually covers
|
| 98 |
+
stmtDigest: null,
|
| 99 |
+
predType: null,
|
| 100 |
+
doctrine: null,
|
| 101 |
+
corpusSha: null,
|
| 102 |
+
kernelPin: null,
|
| 103 |
+
kernelOk: null,
|
| 104 |
+
coverage: null,
|
| 105 |
+
invariants: null, // { name: bool }
|
| 106 |
+
energyCount: null, // length of energy_measured[] — 0 is the honest offline state
|
| 107 |
+
sealFormula: null,
|
| 108 |
+
sealTier: null,
|
| 109 |
+
lambdaStat: null,
|
| 110 |
+
lambdaThm: null,
|
| 111 |
+
trustCeil: null,
|
| 112 |
+
signed: null,
|
| 113 |
+
sigStatus: null,
|
| 114 |
+
subjects: [], // [{ name, bound, digest }]
|
| 115 |
+
rekorStatus: null,
|
| 116 |
+
rekorIndex: null,
|
| 117 |
+
rekorLabel: null,
|
| 118 |
+
rekorNote: null,
|
| 119 |
+
checks: {}, // rule -> bool
|
| 120 |
+
failed: [],
|
| 121 |
+
state: "init",
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
// =============================================================================
|
| 125 |
+
export function mount(ctx) {
|
| 126 |
+
_ctx = ctx; _stage = ctx.stage; _THREE = ctx.THREE;
|
| 127 |
+
_group = new _THREE.Group();
|
| 128 |
+
_stage.scene.add(_group);
|
| 129 |
+
_stage.camera.position.set(0, 5.4, 19.0);
|
| 130 |
+
try {
|
| 131 |
+
if (_stage.controls && _stage.controls.target) {
|
| 132 |
+
_stage.controls.target.set(0, 2.6, 0); _stage.controls.update();
|
| 133 |
+
}
|
| 134 |
+
} catch (_) {}
|
| 135 |
+
try { _stage.setBloom(true); } catch (_) {}
|
| 136 |
+
|
| 137 |
+
_buildFloor();
|
| 138 |
+
_buildCore();
|
| 139 |
+
_buildBeam();
|
| 140 |
+
|
| 141 |
+
if (!_frameReg) { _stage.onFrame(_onFrame); _frameReg = true; }
|
| 142 |
+
|
| 143 |
+
_badge = ctx.live.createBadge();
|
| 144 |
+
_polls.push(ctx.live.poll(EP, 12000, _onData, {
|
| 145 |
+
badge: _badge,
|
| 146 |
+
onState: (m) => { S.state = m.state; _paintOverlay(); _paintCore(); },
|
| 147 |
+
}));
|
| 148 |
+
|
| 149 |
+
_buildOverlay();
|
| 150 |
+
return { id: ID, started: true };
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
// =============================================================================
|
| 154 |
+
function _buildFloor() {
|
| 155 |
+
const THREE = _THREE;
|
| 156 |
+
const grid = new THREE.GridHelper(40, 40, C_GRID, 0x0f2027);
|
| 157 |
+
grid.material.opacity = 0.16; grid.material.transparent = true; grid.position.y = -0.01;
|
| 158 |
+
_group.add(grid);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
function _buildCore() {
|
| 162 |
+
const THREE = _THREE;
|
| 163 |
+
_core = new THREE.Mesh(
|
| 164 |
+
new THREE.OctahedronGeometry(1.7, 1),
|
| 165 |
+
new THREE.MeshStandardMaterial({
|
| 166 |
+
color: C_NEUTRAL, emissive: C_NEUTRAL, emissiveIntensity: 0.34,
|
| 167 |
+
transparent: true, opacity: 0.9, flatShading: true,
|
| 168 |
+
}));
|
| 169 |
+
_core.position.set(0, 5.0, 0);
|
| 170 |
+
_group.add(_core);
|
| 171 |
+
|
| 172 |
+
// the "deed" ring the rules stand on
|
| 173 |
+
const pts = [];
|
| 174 |
+
const R = 6.2;
|
| 175 |
+
for (let i = 0; i <= 80; i++) {
|
| 176 |
+
const a = (i / 80) * Math.PI * 2;
|
| 177 |
+
pts.push(new THREE.Vector3(Math.cos(a) * R, 0.02, Math.sin(a) * R));
|
| 178 |
+
}
|
| 179 |
+
const ring = new THREE.Line(
|
| 180 |
+
new THREE.BufferGeometry().setFromPoints(pts),
|
| 181 |
+
new THREE.LineBasicMaterial({ color: C_MID, transparent: true, opacity: 0.4 }));
|
| 182 |
+
_group.add(ring);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
// The TRANSPARENCY beam — the Rekor strand. Teal and solid only for a real inclusion proof;
|
| 186 |
+
// lattice-blue and translucent for UNREACHABLE (UNKNOWN); grey for NOT_ATTEMPTED. There is no
|
| 187 |
+
// state in which an unanchored attestation is drawn as anchored.
|
| 188 |
+
function _buildBeam() {
|
| 189 |
+
const THREE = _THREE;
|
| 190 |
+
_beam = new THREE.Mesh(
|
| 191 |
+
new THREE.CylinderGeometry(0.16, 0.16, 9.0, 12, 1, true),
|
| 192 |
+
new THREE.MeshStandardMaterial({
|
| 193 |
+
color: C_NEUTRAL, emissive: C_NEUTRAL, emissiveIntensity: 0.2,
|
| 194 |
+
transparent: true, opacity: 0.22, side: THREE.DoubleSide,
|
| 195 |
+
}));
|
| 196 |
+
_beam.position.set(0, 9.6, 0);
|
| 197 |
+
_group.add(_beam);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
// One PILLAR per policy rule. A BROKEN rule stands tallest and reads violet so it cannot hide; an
|
| 201 |
+
// un-evaluated rule is a short grey stub, never a quiet pass. Rebuilt on every snapshot.
|
| 202 |
+
function _buildPillars() {
|
| 203 |
+
const THREE = _THREE;
|
| 204 |
+
_disposePillars();
|
| 205 |
+
|
| 206 |
+
const R = 5.4;
|
| 207 |
+
const geo = new THREE.BoxGeometry(0.95, 1.0, 0.95);
|
| 208 |
+
for (let i = 0; i < RULES.length; i++) {
|
| 209 |
+
const key = RULES[i][0];
|
| 210 |
+
const held = (key in S.checks) ? !!S.checks[key] : null;
|
| 211 |
+
const color = _ruleColor(held);
|
| 212 |
+
const h = held === false ? 4.9 : (held === true ? 3.4 : 1.2);
|
| 213 |
+
const a = (i / RULES.length) * Math.PI * 2 - Math.PI / 2;
|
| 214 |
+
|
| 215 |
+
const mesh = new THREE.Mesh(geo, new THREE.MeshStandardMaterial({
|
| 216 |
+
color, emissive: color, emissiveIntensity: 0.26,
|
| 217 |
+
transparent: true, opacity: held === null ? 0.4 : 0.92,
|
| 218 |
+
}));
|
| 219 |
+
mesh.scale.y = h;
|
| 220 |
+
mesh.position.set(Math.cos(a) * R, h / 2, Math.sin(a) * R);
|
| 221 |
+
_group.add(mesh);
|
| 222 |
+
_pillars.push({ mesh, key, held });
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
// SUBJECT anchors — the two things the deed can bind. The kernel anchor is solid (its gitCommit is
|
| 227 |
+
// always bound). The weights anchor is drawn HOLLOW and grey when no weights artifact is readable:
|
| 228 |
+
// the missing subject is displayed as missing rather than filled in.
|
| 229 |
+
function _buildAnchors() {
|
| 230 |
+
const THREE = _THREE;
|
| 231 |
+
_disposeAnchors();
|
| 232 |
+
|
| 233 |
+
const want = ["locked8_kernel", "sovereign_weights"];
|
| 234 |
+
for (let i = 0; i < want.length; i++) {
|
| 235 |
+
const name = want[i];
|
| 236 |
+
const found = S.subjects.find((s) => s.name === name);
|
| 237 |
+
const bound = !!(found && found.bound);
|
| 238 |
+
const color = bound ? C_OK : C_NEUTRAL;
|
| 239 |
+
const mesh = new THREE.Mesh(
|
| 240 |
+
new THREE.TorusGeometry(1.05, bound ? 0.2 : 0.07, 10, 40),
|
| 241 |
+
new THREE.MeshStandardMaterial({
|
| 242 |
+
color, emissive: color, emissiveIntensity: bound ? 0.3 : 0.1,
|
| 243 |
+
transparent: true, opacity: bound ? 0.9 : 0.35, wireframe: !bound,
|
| 244 |
+
}));
|
| 245 |
+
mesh.rotation.x = Math.PI / 2;
|
| 246 |
+
mesh.position.set(i === 0 ? -3.1 : 3.1, 0.35, 8.4);
|
| 247 |
+
_group.add(mesh);
|
| 248 |
+
_anchors.push({ mesh, name, bound });
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
function _rm(o) {
|
| 253 |
+
if (!o) return;
|
| 254 |
+
try {
|
| 255 |
+
if (o.geometry && o.geometry.dispose) o.geometry.dispose();
|
| 256 |
+
if (o.material) {
|
| 257 |
+
const ms = Array.isArray(o.material) ? o.material : [o.material];
|
| 258 |
+
ms.forEach((m) => m.dispose && m.dispose());
|
| 259 |
+
}
|
| 260 |
+
if (_group) _group.remove(o);
|
| 261 |
+
} catch (_) {}
|
| 262 |
+
}
|
| 263 |
+
function _disposePillars() { _pillars.forEach((p) => _rm(p.mesh)); _pillars = []; }
|
| 264 |
+
function _disposeAnchors() { _anchors.forEach((a) => _rm(a.mesh)); _anchors = []; }
|
| 265 |
+
|
| 266 |
+
// =============================================================================
|
| 267 |
+
// live data — read VERBATIM, never upgrade a label, never fabricate a pass
|
| 268 |
+
// =============================================================================
|
| 269 |
+
function _onData(j) {
|
| 270 |
+
const st = (j && j.statement) || {};
|
| 271 |
+
const pr = (st && st.predicate) || {};
|
| 272 |
+
const pv = (pr && pr.provenance) || {};
|
| 273 |
+
const ver = (j && j.verification) || {};
|
| 274 |
+
const pol = (ver && ver.policy) || {};
|
| 275 |
+
const env = (j && j.envelope) || {};
|
| 276 |
+
const rk = (j && j.rekor) || {};
|
| 277 |
+
|
| 278 |
+
// The server's own label, verbatim. MODELED unless it reported MEASURED for a real proof.
|
| 279 |
+
S.label = j && j.label ? String(j.label).toUpperCase() : "MODELED";
|
| 280 |
+
S.verdict = j && j.verdict ? String(j.verdict).toUpperCase() : null;
|
| 281 |
+
S.scope = j && j.verdict_scope ? String(j.verdict_scope) : null;
|
| 282 |
+
S.stmtDigest = j && j.statement_digest_sha256 ? String(j.statement_digest_sha256) : null;
|
| 283 |
+
|
| 284 |
+
S.predType = st.predicateType ? String(st.predicateType) : null;
|
| 285 |
+
S.doctrine = pr.doctrine ? String(pr.doctrine) : null;
|
| 286 |
+
S.corpusSha = typeof pv.corpus_sha === "string" ? pv.corpus_sha : null;
|
| 287 |
+
S.kernelPin = pv.kernel_pin ? String(pv.kernel_pin) : null;
|
| 288 |
+
S.kernelOk = typeof pv.kernel_verified === "boolean" ? pv.kernel_verified : null;
|
| 289 |
+
S.coverage = typeof pv.provenance_coverage === "number" ? pv.provenance_coverage : null;
|
| 290 |
+
|
| 291 |
+
S.invariants = (pr.honesty_invariants && typeof pr.honesty_invariants === "object")
|
| 292 |
+
? pr.honesty_invariants : null;
|
| 293 |
+
// 0 is the HONEST offline state (no meter answered) — it is displayed as 0, not hidden.
|
| 294 |
+
S.energyCount = Array.isArray(pr.energy_measured) ? pr.energy_measured.length : null;
|
| 295 |
+
|
| 296 |
+
const seal = (pr && pr.seal) || {};
|
| 297 |
+
S.sealFormula = seal.formula ? String(seal.formula) : null;
|
| 298 |
+
S.sealTier = seal.tier ? String(seal.tier).toUpperCase() : null;
|
| 299 |
+
|
| 300 |
+
const lam = (pr && pr.lambda) || {};
|
| 301 |
+
S.lambdaStat = lam.status ? String(lam.status) : null;
|
| 302 |
+
S.lambdaThm = typeof lam.is_theorem === "boolean" ? lam.is_theorem : null;
|
| 303 |
+
S.trustCeil = typeof lam.trust_ceiling === "number" ? lam.trust_ceiling : null;
|
| 304 |
+
|
| 305 |
+
S.signed = typeof env.signed === "boolean" ? env.signed : null;
|
| 306 |
+
S.sigStatus = (ver.signature && ver.signature.status)
|
| 307 |
+
? String(ver.signature.status).toUpperCase() : null;
|
| 308 |
+
|
| 309 |
+
const subs = Array.isArray(st.subject) ? st.subject : [];
|
| 310 |
+
S.subjects = subs.map((s) => {
|
| 311 |
+
const d = (s && s.digest) || {};
|
| 312 |
+
const val = d.gitCommit || d.sha256 || null;
|
| 313 |
+
return {
|
| 314 |
+
name: s && s.name ? String(s.name) : "?",
|
| 315 |
+
digest: val ? String(val) : null,
|
| 316 |
+
bound: !!(val && String(val).trim()),
|
| 317 |
+
};
|
| 318 |
+
});
|
| 319 |
+
|
| 320 |
+
S.rekorStatus = rk.status ? String(rk.status).toUpperCase() : null;
|
| 321 |
+
S.rekorIndex = (rk.log_index === null || rk.log_index === undefined) ? null : rk.log_index;
|
| 322 |
+
S.rekorLabel = rk.label ? String(rk.label).toUpperCase() : null;
|
| 323 |
+
S.rekorNote = rk.note ? String(rk.note) : null;
|
| 324 |
+
|
| 325 |
+
S.checks = (pol.checks && typeof pol.checks === "object") ? pol.checks : {};
|
| 326 |
+
S.failed = Array.isArray(pol.failed) ? pol.failed : [];
|
| 327 |
+
|
| 328 |
+
_buildPillars();
|
| 329 |
+
_buildAnchors();
|
| 330 |
+
_paintCore();
|
| 331 |
+
_paintBeam();
|
| 332 |
+
_paintOverlay();
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
// =============================================================================
|
| 336 |
+
function _onFrame() {
|
| 337 |
+
const t = performance.now();
|
| 338 |
+
if (_group) _group.rotation.y = Math.sin(t * 0.00005) * 0.07;
|
| 339 |
+
|
| 340 |
+
const live = S.state === "live";
|
| 341 |
+
if (_core) {
|
| 342 |
+
_core.rotation.y += 0.004; _core.rotation.x += 0.0013;
|
| 343 |
+
_core.material.emissiveIntensity =
|
| 344 |
+
0.34 + (live ? 0.24 : 0.07) * (0.5 + 0.5 * Math.sin(t * 0.003));
|
| 345 |
+
}
|
| 346 |
+
if (_beam) {
|
| 347 |
+
// The beam only pulses for a REAL inclusion proof; UNKNOWN sits still and dim.
|
| 348 |
+
const recorded = S.rekorStatus === "RECORDED";
|
| 349 |
+
_beam.material.emissiveIntensity =
|
| 350 |
+
recorded && live ? 0.42 + 0.28 * (0.5 + 0.5 * Math.sin(t * 0.004)) : 0.16;
|
| 351 |
+
}
|
| 352 |
+
_anchors.forEach((a) => { a.mesh.rotation.z += a.bound ? 0.006 : 0.0015; });
|
| 353 |
+
if (_pillars.length) {
|
| 354 |
+
_spin = (t * 0.0002) % 1;
|
| 355 |
+
const lead = Math.floor(_spin * _pillars.length);
|
| 356 |
+
for (let i = 0; i < _pillars.length; i++) {
|
| 357 |
+
const p = _pillars[i];
|
| 358 |
+
const base = p.held === false ? 0.62 : (p.held === true && live ? 0.26 : 0.11);
|
| 359 |
+
p.mesh.material.emissiveIntensity = (i === lead && live) ? Math.max(base, 0.85) : base;
|
| 360 |
+
}
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
// =============================================================================
|
| 365 |
+
function _paintCore() {
|
| 366 |
+
if (!_core) return;
|
| 367 |
+
const col = (S.state === "live") ? _verdictColor(S.verdict) : C_NEUTRAL;
|
| 368 |
+
_core.material.color.setHex(col);
|
| 369 |
+
_core.material.emissive.setHex(col);
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
function _paintBeam() {
|
| 373 |
+
if (!_beam) return;
|
| 374 |
+
const col = (S.state === "live") ? _rekorColor(S.rekorStatus) : C_NEUTRAL;
|
| 375 |
+
_beam.material.color.setHex(col);
|
| 376 |
+
_beam.material.emissive.setHex(col);
|
| 377 |
+
_beam.material.opacity = S.rekorStatus === "RECORDED" ? 0.5 : 0.2;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
// =============================================================================
|
| 381 |
+
// overlay (HUD)
|
| 382 |
+
// =============================================================================
|
| 383 |
+
function _buildOverlay() {
|
| 384 |
+
const ctx = _ctx;
|
| 385 |
+
_show = createShowcase(ctx, {
|
| 386 |
+
id: ID, title: TITLE, accent: "#5b8dee", badge: _badge,
|
| 387 |
+
chips: [{ label: "MODELED", text: "chain of title", name: "lbl" },
|
| 388 |
+
{ label: "—", text: "verdict", name: "vrd" }],
|
| 389 |
+
legend: ["MODELED"],
|
| 390 |
+
});
|
| 391 |
+
const host = _show.body;
|
| 392 |
+
|
| 393 |
+
const sub = document.createElement("div");
|
| 394 |
+
sub.style.cssText = "color:#9fb1bf;font-size:11px;line-height:1.55";
|
| 395 |
+
sub.innerHTML =
|
| 396 |
+
'The allodial claim is only worth what a <b>third party can check</b>. This surface reads the ' +
|
| 397 |
+
'estate\'s <b>in-toto v1 Statement</b>: its <b>subject</b> binds the locked-8 kernel ' +
|
| 398 |
+
'<b>gitCommit c7c0ba17</b> (and a sovereign-weights sha256 only when a real weights artifact ' +
|
| 399 |
+
'is readable that request — the hollow grey ring is an <i>absent</i> subject, shown rather ' +
|
| 400 |
+
'than invented); its <b>predicate</b> carries doctrine v11, the provenance strand ' +
|
| 401 |
+
'(corpus_sha, training config read verbatim from the committed trainer, kernel_verified ' +
|
| 402 |
+
're-checked against the digest-verified formula registry), <b>energy_measured[]</b> — empty ' +
|
| 403 |
+
'when no joule meter answered — and the <b>honesty_invariants</b> themselves, bound INTO the ' +
|
| 404 |
+
'signed predicate so the doctrine becomes checkable rather than asserted. It is DSSE-signed ' +
|
| 405 |
+
'with the estate cosign key and structured for cosign keyless + <b>Rekor</b>. The verdict is ' +
|
| 406 |
+
'tri-state: <b>PASSED</b>, <b>FAILED</b>, or <b>UNKNOWN</b> when a required transparency-log ' +
|
| 407 |
+
'inclusion proof cannot be obtained. A tampered Statement is FAILED — <b>FAILED beats ' +
|
| 408 |
+
'UNKNOWN</b>, so nothing hides behind an offline log. Strictly provenance/observability; adds ' +
|
| 409 |
+
'nothing to the locked-8. 0 runtime CDN.';
|
| 410 |
+
host.appendChild(sub);
|
| 411 |
+
|
| 412 |
+
const card = document.createElement("div");
|
| 413 |
+
card.style.cssText = "background:#0a1117;border:1px solid #1d2a36;border-radius:9px;padding:9px 10px;display:flex;flex-direction:column;gap:6px";
|
| 414 |
+
|
| 415 |
+
const grid = document.createElement("div");
|
| 416 |
+
grid.style.cssText = "display:grid;grid-template-columns:1fr;gap:4px";
|
| 417 |
+
function kpiRow(id, label) {
|
| 418 |
+
const r = document.createElement("div");
|
| 419 |
+
r.style.cssText = "display:flex;justify-content:space-between;gap:10px;font-size:11px";
|
| 420 |
+
const l = document.createElement("span"); l.style.cssText = "color:#9fb1bf"; l.textContent = label;
|
| 421 |
+
const v = document.createElement("b");
|
| 422 |
+
v.id = id;
|
| 423 |
+
v.style.cssText = "font-variant-numeric:tabular-nums;color:#eef3f6;text-align:right;max-width:62%;overflow-wrap:anywhere";
|
| 424 |
+
v.textContent = "—";
|
| 425 |
+
_el[id] = v;
|
| 426 |
+
r.appendChild(l); r.appendChild(v); return r;
|
| 427 |
+
}
|
| 428 |
+
grid.appendChild(kpiRow("at-verdict", "verdict"));
|
| 429 |
+
grid.appendChild(kpiRow("at-scope", "verdict covers"));
|
| 430 |
+
grid.appendChild(kpiRow("at-rules", "policy rules held"));
|
| 431 |
+
grid.appendChild(kpiRow("at-failed", "failed rules"));
|
| 432 |
+
grid.appendChild(kpiRow("at-predtype", "predicate type"));
|
| 433 |
+
grid.appendChild(kpiRow("at-doctrine", "doctrine"));
|
| 434 |
+
grid.appendChild(kpiRow("at-kernel", "kernel verified @ pin"));
|
| 435 |
+
grid.appendChild(kpiRow("at-subjects", "subjects bound"));
|
| 436 |
+
grid.appendChild(kpiRow("at-corpus", "corpus sha256"));
|
| 437 |
+
grid.appendChild(kpiRow("at-coverage", "provenance coverage"));
|
| 438 |
+
grid.appendChild(kpiRow("at-energy", "energy_measured readings"));
|
| 439 |
+
grid.appendChild(kpiRow("at-sig", "DSSE signature"));
|
| 440 |
+
grid.appendChild(kpiRow("at-rekor", "Rekor transparency"));
|
| 441 |
+
grid.appendChild(kpiRow("at-digest", "statement sha256"));
|
| 442 |
+
grid.appendChild(kpiRow("at-seal", "SEAL formula (tier)"));
|
| 443 |
+
grid.appendChild(kpiRow("at-lambda", "Λ"));
|
| 444 |
+
grid.appendChild(kpiRow("at-ceil", "trust ceiling"));
|
| 445 |
+
card.appendChild(grid);
|
| 446 |
+
host.appendChild(card);
|
| 447 |
+
|
| 448 |
+
const leg = document.createElement("div");
|
| 449 |
+
leg.style.cssText = "font-size:9.5px;color:#6b7a86;line-height:1.6";
|
| 450 |
+
leg.innerHTML =
|
| 451 |
+
'<span style="color:#3af4c8">■</span> PASSED / rule holds / RECORDED ' +
|
| 452 |
+
'<span style="color:#5b8dee">■</span> UNKNOWN (log unreachable) ' +
|
| 453 |
+
'<span style="color:#8a6bff">■</span> FAILED / rule broken ' +
|
| 454 |
+
'<span style="color:#8494a1">■</span> absent subject / NOT_ATTEMPTED. ' +
|
| 455 |
+
'MODELED — MEASURED only for a real Rekor inclusion proof returned that request. ' +
|
| 456 |
+
'Prior art cited, none claimed as SZL\'s: in-toto · SLSA v1.1 (Build L0-L3 + VSA) · ' +
|
| 457 |
+
'Sigstore/Rekor keyless · DSSE · sigstore/model-transparency · EU CSF SEAL + HHI. ' +
|
| 458 |
+
'Λ = Conjecture 1, never a theorem.';
|
| 459 |
+
card.appendChild(leg);
|
| 460 |
+
|
| 461 |
+
const pl = document.createElement("button");
|
| 462 |
+
pl.textContent = "◑ what this means";
|
| 463 |
+
pl.title = "Toggle plain-language explanation for investors & consumers.";
|
| 464 |
+
pl.style.cssText = "font:11px ui-monospace,monospace;padding:5px 11px;border-radius:7px;border:1px solid #3af4c8;background:#08140f;color:#3af4c8;cursor:pointer;width:fit-content";
|
| 465 |
+
pl.addEventListener("click", () => {
|
| 466 |
+
_plain = !_plain;
|
| 467 |
+
pl.style.background = _plain ? "#0f2a20" : "#08140f";
|
| 468 |
+
_applyPlain();
|
| 469 |
+
});
|
| 470 |
+
host.appendChild(pl);
|
| 471 |
+
|
| 472 |
+
const pd = document.createElement("div");
|
| 473 |
+
pd.id = "at-plain";
|
| 474 |
+
pd.style.cssText = "font-size:10.5px;color:#c9d6df;line-height:1.55;border:1px dashed #26333f;border-radius:7px;padding:7px 9px;display:none";
|
| 475 |
+
_el["plain"] = pd;
|
| 476 |
+
host.appendChild(pd);
|
| 477 |
+
|
| 478 |
+
_paintOverlay();
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
function _applyPlain() {
|
| 482 |
+
const pd = _el["plain"];
|
| 483 |
+
if (!pd) return;
|
| 484 |
+
pd.style.display = _plain ? "block" : "none";
|
| 485 |
+
if (!_plain) return;
|
| 486 |
+
pd.innerHTML =
|
| 487 |
+
"<b>What this means:</b> think of a property <b>deed</b>. Saying “we own this outright” is a " +
|
| 488 |
+
"claim; a deed is something a stranger can take to a registry and check. This surface is the " +
|
| 489 |
+
"deed for the software: a signed document that names exactly <i>what</i> is being claimed " +
|
| 490 |
+
"(the pinned proof kernel, and the model weights when a real weights file is there to point " +
|
| 491 |
+
"at), <i>where it came from</i> (which corpus, which training settings, read out of the " +
|
| 492 |
+
"actual training script rather than typed in by hand), and <i>which honesty rules the estate " +
|
| 493 |
+
"binds itself to</i> — those rules sit inside the signed document, so breaking one breaks the " +
|
| 494 |
+
"signature's claim. Then it tries to file that deed in a public append-only log (Rekor), the " +
|
| 495 |
+
"way you would record a deed at a county office. " +
|
| 496 |
+
"<b>The important part is what happens when something is missing.</b> No weights file, so no " +
|
| 497 |
+
"weights line on the deed — you see a hollow grey ring, not a made-up number. No power meter " +
|
| 498 |
+
"answering, so the energy list reads <b>0 readings</b>, not an estimate dressed up as a " +
|
| 499 |
+
"measurement. The public log unreachable, so the verdict reads <b>UNKNOWN</b> — not " +
|
| 500 |
+
"“passed”. And if the document itself has been altered, the verdict is <b>FAILED</b>, which " +
|
| 501 |
+
"always wins over UNKNOWN, so a tamper can never hide behind an offline log. " +
|
| 502 |
+
"Right now it reads: <b>" + (S.verdict || "—") + "</b> — " + (S.scope || "no live snapshot") +
|
| 503 |
+
". Λ stays <b>Conjecture 1</b> — a conjecture, never a theorem; confidence never reaches 100%.";
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
function _tok(s) {
|
| 507 |
+
if (s === "live") return null;
|
| 508 |
+
if (s === "missing") return "NO-LIVE-DATA";
|
| 509 |
+
if (s === "degraded") return "DEGRADED";
|
| 510 |
+
if (s === "error") return "OFFLINE";
|
| 511 |
+
return "…";
|
| 512 |
+
}
|
| 513 |
+
function _set(id, v) { if (_el[id]) _el[id].textContent = v; }
|
| 514 |
+
function _short(h, n) {
|
| 515 |
+
if (!h) return "—";
|
| 516 |
+
const s = String(h);
|
| 517 |
+
return s.length > n ? s.slice(0, n) + "…" : s;
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
function _paintOverlay() {
|
| 521 |
+
const t = _tok(S.state);
|
| 522 |
+
if (_show) {
|
| 523 |
+
_show.setChip("lbl", S.label || "MODELED", { text: "chain of title" });
|
| 524 |
+
_show.setChip("vrd", t || (S.verdict || "—"), { text: "verdict" });
|
| 525 |
+
}
|
| 526 |
+
const keys = RULES.map((r) => r[0]);
|
| 527 |
+
const held = keys.filter((k) => S.checks[k] === true).length;
|
| 528 |
+
const evaluated = keys.filter((k) => k in S.checks).length;
|
| 529 |
+
|
| 530 |
+
_set("at-verdict", t || (S.verdict || "—"));
|
| 531 |
+
_set("at-scope", t || (S.scope || "—"));
|
| 532 |
+
_set("at-rules", t || (evaluated ? held + " / " + evaluated : "—"));
|
| 533 |
+
_set("at-failed", t || (S.failed && S.failed.length ? S.failed.join(", ") : "none"));
|
| 534 |
+
_set("at-predtype", t || (S.predType || "—"));
|
| 535 |
+
_set("at-doctrine", t || (S.doctrine || "—"));
|
| 536 |
+
_set("at-kernel", t || (S.kernelOk === null ? "—"
|
| 537 |
+
: (S.kernelOk ? "verified" : "NOT VERIFIED") + " @ " + (S.kernelPin || "—")));
|
| 538 |
+
_set("at-subjects", t || (S.subjects.length
|
| 539 |
+
? S.subjects.map((s) => s.name + (s.bound ? " ✓" : " (absent)")).join(", ")
|
| 540 |
+
: "—"));
|
| 541 |
+
// An absent corpus digest reads ABSENT, never a placeholder hash.
|
| 542 |
+
_set("at-corpus", t || (S.corpusSha ? _short(S.corpusSha, 18) : "ABSENT (honest null)"));
|
| 543 |
+
_set("at-coverage", t || (S.coverage === null ? "—" : String(S.coverage)));
|
| 544 |
+
_set("at-energy", t || (S.energyCount === null ? "—"
|
| 545 |
+
: S.energyCount + (S.energyCount === 0 ? " (no meter answered)" : " MEASURED")));
|
| 546 |
+
_set("at-sig", t || (S.sigStatus || (S.signed === false ? "UNSIGNED-NO-KEY" : "—")));
|
| 547 |
+
_set("at-rekor", t || (S.rekorStatus
|
| 548 |
+
? S.rekorStatus + (S.rekorIndex !== null ? " · index " + S.rekorIndex : "")
|
| 549 |
+
: "—"));
|
| 550 |
+
_set("at-digest", t || _short(S.stmtDigest, 18));
|
| 551 |
+
_set("at-seal", t || (S.sealFormula
|
| 552 |
+
? S.sealFormula + " (" + (S.sealTier || "PROPOSED") + ")" : "—"));
|
| 553 |
+
_set("at-lambda", t || (S.lambdaStat
|
| 554 |
+
? S.lambdaStat + (S.lambdaThm === false ? " (not a theorem)" : "") : "—"));
|
| 555 |
+
_set("at-ceil", t || (S.trustCeil === null ? "—" : String(S.trustCeil)));
|
| 556 |
+
if (_plain) _applyPlain();
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
// =============================================================================
|
| 560 |
+
export function unmount() {
|
| 561 |
+
_polls.forEach((p) => { try { p.stop(); } catch (_) {} }); _polls = [];
|
| 562 |
+
try { if (_show) _show.destroy(); } catch (_) {}
|
| 563 |
+
try {
|
| 564 |
+
_disposePillars();
|
| 565 |
+
_disposeAnchors();
|
| 566 |
+
_rm(_beam); _beam = null;
|
| 567 |
+
if (_group && _stage) {
|
| 568 |
+
_group.traverse((o) => {
|
| 569 |
+
if (o.geometry && o.geometry.dispose) o.geometry.dispose();
|
| 570 |
+
if (o.material) {
|
| 571 |
+
const ms = Array.isArray(o.material) ? o.material : [o.material];
|
| 572 |
+
ms.forEach((mm) => { if (mm.dispose) mm.dispose(); });
|
| 573 |
+
}
|
| 574 |
+
});
|
| 575 |
+
_stage.scene.remove(_group);
|
| 576 |
+
}
|
| 577 |
+
} catch (_) {}
|
| 578 |
+
_group = _show = null;
|
| 579 |
+
_core = null; _pillars = []; _anchors = []; _beam = null;
|
| 580 |
+
_el = {}; _badge = null; _plain = false; _frameReg = false; _spin = 0;
|
| 581 |
+
_stage = _THREE = _ctx = null;
|
| 582 |
+
S.label = S.verdict = S.scope = S.stmtDigest = null;
|
| 583 |
+
S.predType = S.doctrine = S.corpusSha = S.kernelPin = null;
|
| 584 |
+
S.kernelOk = S.coverage = S.invariants = S.energyCount = null;
|
| 585 |
+
S.sealFormula = S.sealTier = S.lambdaStat = S.lambdaThm = S.trustCeil = null;
|
| 586 |
+
S.signed = S.sigStatus = null;
|
| 587 |
+
S.subjects = [];
|
| 588 |
+
S.rekorStatus = S.rekorIndex = S.rekorLabel = S.rekorNote = null;
|
| 589 |
+
S.checks = {}; S.failed = []; S.state = "init";
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
export default { id: ID, title: TITLE, endpoints: [EP], mount, unmount };
|
szl3d_holographic.py
CHANGED
|
@@ -166,6 +166,7 @@ SURFACES: List[Dict[str, str]] = [
|
|
| 166 |
{"id": "open", "cat": "more", "flag": True, "title": "Open Frontier · Live Hugging Face · MEASURED live Hugging Face Hub trending stream — one pillar per org/author (height = summed likes, bead = download reach); most-liked open models orbit as satellites coloured by task; log-scaling is display-only, no invented benchmark, score, or ranking beyond the Hub’s own", "owner": "Forge"},
|
| 167 |
{"id": "brainagent", "cat": "brain", "title": "Brain Agent · honesty-gated agentic graph reasoner · treats the brain graph as a state space and walks it one node at a time for a query, choosing EXPAND/FOLLOW/BACKTRACK/STOP by pure graph heuristics (no model call, fully deterministic); every candidate hop passes an honesty gate built from the sibling surfaces (grounding, provenance, contradiction, uncertainty) — an ungrounded/untraceable/contradicted/uncertain hop is refused with a recorded reason, an absent guard is UNAVAILABLE never a fabricated pass; within an explicit step/node budget it returns ANSWER-GROUNDED/PARTIAL or abstains ABSTAINED-BUDGET/ABSTAINED-INSUFFICIENT rather than answer under-grounded, emits an ordered trace + unsigned SHA-256 receipt-on-write, makes no sentience claim (MODELED)", "owner": "WaveT-Dev1"},
|
| 168 |
{"id": "estateconstitution", "cat": "governance", "title": "Estate Constitution · the WHOLE ESTATE's honesty posture graded continuously against explicit estate-level ARTICLES (the per-query brain-constitution pattern lifted to the estate) · Art 1 the honesty wall holds (0 REACHABLE invariant violations), Art 2 no surface declares a fabricated MEASURED label (every declared label in the honest vocabulary, read VERBATIM), Art 3 manifest coverage DISCLOSED honestly (NATIVE-OK vs NO-MANIFEST counted out loud — a DISCLOSURE Article: admitting the gap is compliance, papering it over is the violation, full coverage never claimed while any surface is unverifiable), Art 4 doctrine invariants (Λ = Conjecture 1 never a theorem, locked-8 never inflated, trust ceiling 0.97 never 100%, no consciousness claim) · each graded COMPLIANT/VIOLATED/UNAVAILABLE over the szl_honestywall aggregate read in-process through a GUARDED import (an unreadable aggregate is UNAVAILABLE, never a fabricated pass) → CONSTITUTIONAL/IN-VIOLATION/INSUFFICIENT-SIGNAL, never CONSTITUTIONAL while any evaluable Article is VIOLATED, unsigned SHA-256 receipt-on-write (MODELED)", "owner": "WaveS-Dev6"},
|
|
|
|
| 169 |
]
|
| 170 |
|
| 171 |
# Content-type by extension (the only extensions we serve from the 3d tree).
|
|
|
|
| 166 |
{"id": "open", "cat": "more", "flag": True, "title": "Open Frontier · Live Hugging Face · MEASURED live Hugging Face Hub trending stream — one pillar per org/author (height = summed likes, bead = download reach); most-liked open models orbit as satellites coloured by task; log-scaling is display-only, no invented benchmark, score, or ranking beyond the Hub’s own", "owner": "Forge"},
|
| 167 |
{"id": "brainagent", "cat": "brain", "title": "Brain Agent · honesty-gated agentic graph reasoner · treats the brain graph as a state space and walks it one node at a time for a query, choosing EXPAND/FOLLOW/BACKTRACK/STOP by pure graph heuristics (no model call, fully deterministic); every candidate hop passes an honesty gate built from the sibling surfaces (grounding, provenance, contradiction, uncertainty) — an ungrounded/untraceable/contradicted/uncertain hop is refused with a recorded reason, an absent guard is UNAVAILABLE never a fabricated pass; within an explicit step/node budget it returns ANSWER-GROUNDED/PARTIAL or abstains ABSTAINED-BUDGET/ABSTAINED-INSUFFICIENT rather than answer under-grounded, emits an ordered trace + unsigned SHA-256 receipt-on-write, makes no sentience claim (MODELED)", "owner": "WaveT-Dev1"},
|
| 168 |
{"id": "estateconstitution", "cat": "governance", "title": "Estate Constitution · the WHOLE ESTATE's honesty posture graded continuously against explicit estate-level ARTICLES (the per-query brain-constitution pattern lifted to the estate) · Art 1 the honesty wall holds (0 REACHABLE invariant violations), Art 2 no surface declares a fabricated MEASURED label (every declared label in the honest vocabulary, read VERBATIM), Art 3 manifest coverage DISCLOSED honestly (NATIVE-OK vs NO-MANIFEST counted out loud — a DISCLOSURE Article: admitting the gap is compliance, papering it over is the violation, full coverage never claimed while any surface is unverifiable), Art 4 doctrine invariants (Λ = Conjecture 1 never a theorem, locked-8 never inflated, trust ceiling 0.97 never 100%, no consciousness claim) · each graded COMPLIANT/VIOLATED/UNAVAILABLE over the szl_honestywall aggregate read in-process through a GUARDED import (an unreadable aggregate is UNAVAILABLE, never a fabricated pass) → CONSTITUTIONAL/IN-VIOLATION/INSUFFICIENT-SIGNAL, never CONSTITUTIONAL while any evaluable Article is VIOLATED, unsigned SHA-256 receipt-on-write (MODELED)", "owner": "WaveS-Dev6"},
|
| 169 |
+
{"id": "attest", "cat": "governance", "title": "Chain of Title · L6 attestation · the allodial claim made third-party verifiable · an in-toto v1 Statement whose SUBJECT binds the locked-8 kernel gitCommit c7c0ba17 (plus a sovereign-weights sha256 ONLY when a real weights artifact is readable this request — honest null otherwise, never an invented digest), predicateType https://szl.dev/chain-of-title/v1, predicate = doctrine v11 + provenance (corpus_sha, training config read VERBATIM from the committed trainer, kernel_verified RE-CHECKED this request against the digest-verified formula registry, kernel_pin) + energy_measured[] (HONESTLY EMPTY with no live joule meter — no joule fabricated) + honesty_invariants {no_fabricated_measured, lambda_is_conjecture_not_theorem, locked8_immutable, provenance_coverage 1.0} bound INTO the signed predicate so the doctrine itself becomes third-party checkable + the tier-PROPOSED SEAL formula (EU CSF SEAL + HHI prior art, no score asserted) · DSSE-signed through the estate cosign key (explicitly UNSIGNED-NO-KEY when no runtime secret is present, never a fabricated signature) and structured for cosign keyless + Rekor: a real inclusion proof reads RECORDED/MEASURED, an unreachable log reads UNREACHABLE and the verdict is UNKNOWN — never a fabricated Rekor entry or PASSED · the verdict is tri-state and FAILED beats UNKNOWN so a tampered Statement cannot hide behind an offline log; policy authoritative in ops/szl_chain_of_title.rego, mirrored in-process rule for rule (MODELED)", "owner": "Wave32-DevE"},
|
| 170 |
]
|
| 171 |
|
| 172 |
# Content-type by extension (the only extensions we serve from the 3d tree).
|
szl_attest.py
ADDED
|
@@ -0,0 +1,1242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
# © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
|
| 3 |
+
"""szl_attest — L6 CHAIN-OF-TITLE ATTESTATION ORGAN.
|
| 4 |
+
|
| 5 |
+
WHAT THIS IS
|
| 6 |
+
------------
|
| 7 |
+
The allodial claim ("the operator holds real title to this substrate, not a
|
| 8 |
+
rented tenancy") is only worth what a THIRD PARTY can check. This organ emits
|
| 9 |
+
that claim as a machine-checkable **in-toto v1 Statement**, DSSE-signs it with
|
| 10 |
+
the estate's existing cosign keypair (``szl_dsse``), structures it for
|
| 11 |
+
**Sigstore/Rekor** transparency-log inclusion, and evaluates it against an
|
| 12 |
+
explicit policy (mirrored in ``ops/szl_chain_of_title.rego``) that returns
|
| 13 |
+
PASSED / FAILED / UNKNOWN — never a fabricated pass.
|
| 14 |
+
|
| 15 |
+
subject = locked-8 kernel gitCommit (+ sovereign weights sha256 IF
|
| 16 |
+
a real weights artifact is readable this request; honest
|
| 17 |
+
null otherwise — a subject is never invented)
|
| 18 |
+
predicateType = "https://szl.dev/chain-of-title/v1"
|
| 19 |
+
predicate = doctrine v11 · provenance · energy_measured[] ·
|
| 20 |
+
honesty_invariants · seal
|
| 21 |
+
|
| 22 |
+
LEADERS FUSED (cited prior art; SZL claims none of them as its own)
|
| 23 |
+
------------------------------------------------------------------
|
| 24 |
+
* in-toto Attestation Framework — Statement/v1 envelope + subject/predicate
|
| 25 |
+
split. https://github.com/in-toto/attestation/blob/main/spec/v1/statement.md
|
| 26 |
+
* SLSA v1.1 (Apr 2025) — Build L0-L3 track + Verification Summary Attestation
|
| 27 |
+
(a verifier saying "this passed policy P"). https://slsa.dev/spec/v1.1/
|
| 28 |
+
and https://slsa.dev/spec/v1.1/verification_summary
|
| 29 |
+
* Sigstore / cosign keyless + Rekor transparency log — inclusion proof as the
|
| 30 |
+
third-party-checkable anchor. https://docs.sigstore.dev/logging/overview/
|
| 31 |
+
* DSSE (secure-systems-lab/dsse) — PAE signing envelope, via ``szl_dsse``.
|
| 32 |
+
https://github.com/secure-systems-lab/dsse
|
| 33 |
+
* sigstore/model-transparency — signing ML model weights as the subject.
|
| 34 |
+
https://github.com/sigstore/model-transparency
|
| 35 |
+
|
| 36 |
+
WHAT MAKES IT SZL'S OWN (not a re-skin of the above)
|
| 37 |
+
----------------------------------------------------
|
| 38 |
+
1. ``honesty_invariants`` are IN the signed predicate, so the doctrine itself
|
| 39 |
+
becomes a cryptographically bound, third-party-checkable claim:
|
| 40 |
+
no_fabricated_measured · lambda_is_conjecture_not_theorem ·
|
| 41 |
+
locked8_immutable · provenance_coverage 1.0.
|
| 42 |
+
2. The subject binds the **locked-8 kernel pin** (c7c0ba17) — the immutable
|
| 43 |
+
8-formula proof kernel — not just a container digest.
|
| 44 |
+
3. The verdict is TRI-STATE by construction. A missing transparency log is
|
| 45 |
+
UNKNOWN, never PASSED. A tampered statement is FAILED, never UNKNOWN.
|
| 46 |
+
4. Optional szl-lake receipt-on-write, so the attestation act itself lands in
|
| 47 |
+
the estate ledger.
|
| 48 |
+
|
| 49 |
+
HONESTY (Doctrine v11 — binding)
|
| 50 |
+
--------------------------------
|
| 51 |
+
* ``energy_measured`` is EMPTY unless a joule meter answered THIS request.
|
| 52 |
+
No joule is ever invented.
|
| 53 |
+
* ``rekor.status`` is RECORDED only with a real inclusion proof returned by a
|
| 54 |
+
reachable log; UNREACHABLE / NOT_ATTEMPTED otherwise. No Rekor entry, log
|
| 55 |
+
index, or inclusion proof is ever fabricated.
|
| 56 |
+
* No signature is fabricated: with no ``SZL_COSIGN_PRIVATE_PEM`` runtime
|
| 57 |
+
secret, ``szl_dsse`` emits an explicitly UNSIGNED envelope and this organ
|
| 58 |
+
reports ``signature.status = "UNSIGNED-NO-KEY"``.
|
| 59 |
+
* Λ = **Conjecture 1** — advisory, never a theorem, never green.
|
| 60 |
+
* locked-8 {F1,F4,F7,F11,F12,F18,F19,F22} @ c7c0ba17 — this organ adds
|
| 61 |
+
NOTHING to it and proves nothing new about it; it only ATTESTS the pin.
|
| 62 |
+
* Surface label: MODELED. It would be MEASURED only for the transparency
|
| 63 |
+
strand, and only when a real Rekor inclusion proof came back this request.
|
| 64 |
+
* The seal formula is tier PROPOSED (EU CSF SEAL + HHI prior art), never
|
| 65 |
+
presented as a validated metric.
|
| 66 |
+
|
| 67 |
+
Pure stdlib. No new dependency. Never raises into a request path.
|
| 68 |
+
|
| 69 |
+
Routes (registered additively, BEFORE the SPA catch-all):
|
| 70 |
+
GET /api/<ns>/v1/attest/manifest — statement + envelope + policy verdict
|
| 71 |
+
GET /api/<ns>/v1/attest/verify — verify the freshly built statement
|
| 72 |
+
POST /api/<ns>/v1/attest/verify — verify a caller-supplied envelope/statement
|
| 73 |
+
"""
|
| 74 |
+
from __future__ import annotations
|
| 75 |
+
|
| 76 |
+
import hashlib
|
| 77 |
+
import json
|
| 78 |
+
import os
|
| 79 |
+
import re
|
| 80 |
+
import sys
|
| 81 |
+
from datetime import datetime, timezone
|
| 82 |
+
from pathlib import Path
|
| 83 |
+
from typing import Any
|
| 84 |
+
|
| 85 |
+
# --------------------------------------------------------------------------- #
|
| 86 |
+
# Constants — the frozen vocabulary of this organ.
|
| 87 |
+
# --------------------------------------------------------------------------- #
|
| 88 |
+
SCHEMA = "szl.attest.chain-of-title/v1"
|
| 89 |
+
STATEMENT_TYPE = "https://in-toto.io/Statement/v1"
|
| 90 |
+
PREDICATE_TYPE = "https://szl.dev/chain-of-title/v1"
|
| 91 |
+
PAYLOAD_TYPE = "application/vnd.in-toto+json"
|
| 92 |
+
|
| 93 |
+
DOCTRINE_VERSION = "v11"
|
| 94 |
+
KERNEL_PIN = "c7c0ba17"
|
| 95 |
+
LOCKED_8 = ("F1", "F4", "F7", "F11", "F12", "F18", "F19", "F22")
|
| 96 |
+
TRUST_CEILING = 0.97
|
| 97 |
+
|
| 98 |
+
SUBJECT_KERNEL_NAME = "locked8_kernel"
|
| 99 |
+
SUBJECT_WEIGHTS_NAME = "sovereign_weights"
|
| 100 |
+
|
| 101 |
+
LABEL_MODELED = "MODELED"
|
| 102 |
+
LABEL_MEASURED = "MEASURED"
|
| 103 |
+
|
| 104 |
+
VERDICT_PASSED = "PASSED"
|
| 105 |
+
VERDICT_FAILED = "FAILED"
|
| 106 |
+
VERDICT_UNKNOWN = "UNKNOWN"
|
| 107 |
+
|
| 108 |
+
REKOR_RECORDED = "RECORDED"
|
| 109 |
+
REKOR_UNREACHABLE = "UNREACHABLE"
|
| 110 |
+
REKOR_NOT_ATTEMPTED = "NOT_ATTEMPTED"
|
| 111 |
+
|
| 112 |
+
# Public Rekor instance. Only contacted when SZL_REKOR_ENABLE is truthy — the
|
| 113 |
+
# estate never reaches out on a plain read by default.
|
| 114 |
+
DEFAULT_REKOR_URL = "https://rekor.sigstore.dev"
|
| 115 |
+
REKOR_URL_ENV = "SZL_REKOR_URL"
|
| 116 |
+
REKOR_ENABLE_ENV = "SZL_REKOR_ENABLE"
|
| 117 |
+
REKOR_TIMEOUT_ENV = "SZL_REKOR_TIMEOUT_S"
|
| 118 |
+
REQUIRE_TRANSPARENCY_ENV = "SZL_ATTEST_REQUIRE_REKOR"
|
| 119 |
+
WEIGHTS_PATH_ENV = "SZL_SOVEREIGN_WEIGHTS_PATH"
|
| 120 |
+
CORPUS_PATH_ENV = "SZL_SOVEREIGN_CORPUS_PATH"
|
| 121 |
+
JOULE_METER_ENV = "A11OY_JOULE_METER_URLS"
|
| 122 |
+
LAKE_DIR_ENV = "SZL_LAKE_DIR"
|
| 123 |
+
|
| 124 |
+
ROOT = Path(__file__).resolve().parent
|
| 125 |
+
|
| 126 |
+
# Candidate sovereign-weights artifacts, in resolution order. Absent = honest
|
| 127 |
+
# null; a weights subject is NEVER invented.
|
| 128 |
+
_WEIGHTS_CANDIDATES = (
|
| 129 |
+
"sovereign-weights/out-lora-szl/adapter_model.safetensors",
|
| 130 |
+
"sovereign-weights/out-lora-szl/adapter_model.bin",
|
| 131 |
+
"sovereign-weights/adapter_model.safetensors",
|
| 132 |
+
)
|
| 133 |
+
_CORPUS_CANDIDATES = (
|
| 134 |
+
("sovereign-weights/corpus.jsonl", "corpus"),
|
| 135 |
+
("corpus.jsonl", "corpus"),
|
| 136 |
+
("sovereign-weights/corpus_template.jsonl", "corpus_template"),
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
CITES = [
|
| 140 |
+
"in-toto Attestation Framework — Statement v1 — "
|
| 141 |
+
"https://github.com/in-toto/attestation/blob/main/spec/v1/statement.md",
|
| 142 |
+
"SLSA v1.1 (Apr 2025) Build track L0-L3 — https://slsa.dev/spec/v1.1/levels",
|
| 143 |
+
"SLSA v1.1 Verification Summary Attestation — "
|
| 144 |
+
"https://slsa.dev/spec/v1.1/verification_summary",
|
| 145 |
+
"Sigstore/Rekor transparency log — https://docs.sigstore.dev/logging/overview/",
|
| 146 |
+
"DSSE (secure-systems-lab/dsse) — https://github.com/secure-systems-lab/dsse",
|
| 147 |
+
"sigstore/model-transparency — https://github.com/sigstore/model-transparency",
|
| 148 |
+
]
|
| 149 |
+
SEAL_CITES = [
|
| 150 |
+
"EU Cloud Sovereignty Framework 2025 (SEAL / SovScore assurance levels 0-4)",
|
| 151 |
+
"Herfindahl-Hirschman Index (HHI) — dependency-concentration measure (DCI)",
|
| 152 |
+
]
|
| 153 |
+
SEAL_FORMULA = "A=[Σ wₖ·SEALₖ/4]×(1−DCI)×100"
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
# --------------------------------------------------------------------------- #
|
| 157 |
+
# Small deterministic helpers.
|
| 158 |
+
# --------------------------------------------------------------------------- #
|
| 159 |
+
def _now_iso() -> str:
|
| 160 |
+
return datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def canonical_json(obj: Any) -> bytes:
|
| 164 |
+
"""Deterministic canonical JSON (sorted keys, tight separators, UTF-8)."""
|
| 165 |
+
return json.dumps(obj, sort_keys=True, separators=(",", ":"),
|
| 166 |
+
ensure_ascii=False).encode("utf-8")
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def digest_hex(obj: Any) -> str:
|
| 170 |
+
return hashlib.sha256(canonical_json(obj)).hexdigest()
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def _sha256_file(path: Path, *, chunk: int = 1 << 20) -> str | None:
|
| 174 |
+
try:
|
| 175 |
+
h = hashlib.sha256()
|
| 176 |
+
with path.open("rb") as fh:
|
| 177 |
+
while True:
|
| 178 |
+
block = fh.read(chunk)
|
| 179 |
+
if not block:
|
| 180 |
+
break
|
| 181 |
+
h.update(block)
|
| 182 |
+
return h.hexdigest()
|
| 183 |
+
except Exception:
|
| 184 |
+
return None
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def _safe_under_root(raw: str) -> Path | None:
|
| 188 |
+
"""Resolve a caller/env supplied path and refuse anything outside ROOT."""
|
| 189 |
+
try:
|
| 190 |
+
p = Path(raw)
|
| 191 |
+
p = p if p.is_absolute() else (ROOT / p)
|
| 192 |
+
p = p.resolve()
|
| 193 |
+
p.relative_to(ROOT)
|
| 194 |
+
return p
|
| 195 |
+
except Exception:
|
| 196 |
+
return None
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
# --------------------------------------------------------------------------- #
|
| 200 |
+
# Subject strand 1 — sovereign weights (honest null when absent).
|
| 201 |
+
# --------------------------------------------------------------------------- #
|
| 202 |
+
def sovereign_weights_digest() -> dict[str, Any]:
|
| 203 |
+
"""sha256 of the sovereign weights artifact, or an HONEST null.
|
| 204 |
+
|
| 205 |
+
A trained-weights blob is not committed to this repo (it is an operator
|
| 206 |
+
artifact). When none is readable this returns ``sha256: None`` with the
|
| 207 |
+
reason spelled out — the attestation says "no weights subject THIS
|
| 208 |
+
request", it does not invent one.
|
| 209 |
+
"""
|
| 210 |
+
override = (os.environ.get(WEIGHTS_PATH_ENV) or "").strip()
|
| 211 |
+
candidates: list[Path] = []
|
| 212 |
+
if override:
|
| 213 |
+
p = _safe_under_root(override)
|
| 214 |
+
if p is not None:
|
| 215 |
+
candidates.append(p)
|
| 216 |
+
candidates.extend(ROOT / rel for rel in _WEIGHTS_CANDIDATES)
|
| 217 |
+
|
| 218 |
+
for path in candidates:
|
| 219 |
+
try:
|
| 220 |
+
if not path.is_file():
|
| 221 |
+
continue
|
| 222 |
+
except Exception:
|
| 223 |
+
continue
|
| 224 |
+
sha = _sha256_file(path)
|
| 225 |
+
if sha:
|
| 226 |
+
try:
|
| 227 |
+
rel = str(path.relative_to(ROOT))
|
| 228 |
+
except Exception:
|
| 229 |
+
rel = path.name
|
| 230 |
+
return {
|
| 231 |
+
"sha256": sha,
|
| 232 |
+
"path": rel,
|
| 233 |
+
"bytes": path.stat().st_size,
|
| 234 |
+
"present": True,
|
| 235 |
+
"note": "sha256 computed over the readable weights artifact this request",
|
| 236 |
+
}
|
| 237 |
+
return {
|
| 238 |
+
"sha256": None,
|
| 239 |
+
"path": None,
|
| 240 |
+
"bytes": None,
|
| 241 |
+
"present": False,
|
| 242 |
+
"note": ("no sovereign-weights artifact readable this request (operator "
|
| 243 |
+
f"artifact, not committed; set {WEIGHTS_PATH_ENV} to bind one) — "
|
| 244 |
+
"honest null, no weights digest fabricated"),
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
# --------------------------------------------------------------------------- #
|
| 249 |
+
# Subject strand 2 — the locked-8 kernel commit.
|
| 250 |
+
# --------------------------------------------------------------------------- #
|
| 251 |
+
def locked8_kernel_commit() -> dict[str, Any]:
|
| 252 |
+
"""The gitCommit the locked-8 proof kernel is pinned at.
|
| 253 |
+
|
| 254 |
+
Doctrine v11 pins the locked-8 {F1,F4,F7,F11,F12,F18,F19,F22} at commit
|
| 255 |
+
prefix ``c7c0ba17``. That pin — not the rolling build commit — is what the
|
| 256 |
+
chain-of-title subject binds, because the pin is the immutable thing. The
|
| 257 |
+
build commit is recorded separately in the provenance strand.
|
| 258 |
+
"""
|
| 259 |
+
return {
|
| 260 |
+
"gitCommit": KERNEL_PIN,
|
| 261 |
+
"locked_proven": list(LOCKED_8),
|
| 262 |
+
"locked_proven_count": len(LOCKED_8),
|
| 263 |
+
"source": "doctrine-v11 locked-kernel pin (immutable)",
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def build_commit() -> dict[str, Any]:
|
| 268 |
+
"""Best-effort build commit, read from .git without shelling out.
|
| 269 |
+
|
| 270 |
+
Reported honestly as ``null`` when the checkout metadata is unreadable (an
|
| 271 |
+
image build strips .git). Never confused with the locked-8 kernel pin.
|
| 272 |
+
"""
|
| 273 |
+
git = ROOT / ".git"
|
| 274 |
+
try:
|
| 275 |
+
head = (git / "HEAD").read_text(encoding="utf-8").strip()
|
| 276 |
+
except Exception:
|
| 277 |
+
return {"commit": None, "source": None,
|
| 278 |
+
"note": "no readable .git/HEAD in this image — honest null"}
|
| 279 |
+
if head.startswith("ref:"):
|
| 280 |
+
ref = head.split(":", 1)[1].strip()
|
| 281 |
+
try:
|
| 282 |
+
sha = (git / ref).read_text(encoding="utf-8").strip()
|
| 283 |
+
return {"commit": sha, "source": f".git/{ref}", "note": None}
|
| 284 |
+
except Exception:
|
| 285 |
+
pass
|
| 286 |
+
try:
|
| 287 |
+
for line in (git / "packed-refs").read_text(encoding="utf-8").splitlines():
|
| 288 |
+
if line.endswith(" " + ref):
|
| 289 |
+
return {"commit": line.split(" ", 1)[0].strip(),
|
| 290 |
+
"source": ".git/packed-refs", "note": None}
|
| 291 |
+
except Exception:
|
| 292 |
+
pass
|
| 293 |
+
return {"commit": None, "source": f".git/{ref}",
|
| 294 |
+
"note": "ref present but unresolvable — honest null"}
|
| 295 |
+
if re.fullmatch(r"[0-9a-f]{40}", head):
|
| 296 |
+
return {"commit": head, "source": ".git/HEAD (detached)", "note": None}
|
| 297 |
+
return {"commit": None, "source": ".git/HEAD",
|
| 298 |
+
"note": "unrecognised HEAD form — honest null"}
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
# --------------------------------------------------------------------------- #
|
| 302 |
+
# Provenance strand.
|
| 303 |
+
# --------------------------------------------------------------------------- #
|
| 304 |
+
def corpus_sha() -> dict[str, Any]:
|
| 305 |
+
"""sha256 of the declared training corpus, or an honest null.
|
| 306 |
+
|
| 307 |
+
``kind`` distinguishes a real corpus from the committed TEMPLATE, so a
|
| 308 |
+
template digest can never be read as a trained-corpus digest.
|
| 309 |
+
"""
|
| 310 |
+
override = (os.environ.get(CORPUS_PATH_ENV) or "").strip()
|
| 311 |
+
candidates: list[tuple[Path, str]] = []
|
| 312 |
+
if override:
|
| 313 |
+
p = _safe_under_root(override)
|
| 314 |
+
if p is not None:
|
| 315 |
+
candidates.append((p, "corpus"))
|
| 316 |
+
candidates.extend((ROOT / rel, kind) for rel, kind in _CORPUS_CANDIDATES)
|
| 317 |
+
|
| 318 |
+
for path, kind in candidates:
|
| 319 |
+
try:
|
| 320 |
+
if not path.is_file():
|
| 321 |
+
continue
|
| 322 |
+
except Exception:
|
| 323 |
+
continue
|
| 324 |
+
sha = _sha256_file(path)
|
| 325 |
+
if sha:
|
| 326 |
+
try:
|
| 327 |
+
rel = str(path.relative_to(ROOT))
|
| 328 |
+
except Exception:
|
| 329 |
+
rel = path.name
|
| 330 |
+
return {"sha256": sha, "path": rel, "kind": kind,
|
| 331 |
+
"note": ("template corpus digest — NOT a trained-corpus digest"
|
| 332 |
+
if kind == "corpus_template" else
|
| 333 |
+
"sha256 over the declared training corpus")}
|
| 334 |
+
return {"sha256": None, "path": None, "kind": None,
|
| 335 |
+
"note": "no training corpus readable this request — honest null"}
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
_TRAIN_SCRIPT = "sovereign-weights/train_lora.py"
|
| 339 |
+
_TRAIN_KNOBS = (
|
| 340 |
+
("base_model", "--base-model", str),
|
| 341 |
+
("lora_r", "--lora-r", int),
|
| 342 |
+
("lora_alpha", "--lora-alpha", int),
|
| 343 |
+
("lora_dropout", "--lora-dropout", float),
|
| 344 |
+
("per_device_batch", "--per-device-batch", int),
|
| 345 |
+
("grad_accum", "--grad-accum", int),
|
| 346 |
+
("max_seq_len", "--max-seq-len", int),
|
| 347 |
+
("epochs", "--epochs", float),
|
| 348 |
+
("learning_rate", "--learning-rate", float),
|
| 349 |
+
("seed", "--seed", int),
|
| 350 |
+
)
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
def training_config() -> dict[str, Any]:
|
| 354 |
+
"""The training configuration, READ from the committed trainer this request.
|
| 355 |
+
|
| 356 |
+
Parsed out of ``sovereign-weights/train_lora.py``'s argparse defaults with
|
| 357 |
+
a regex rather than hard-coded here, so the attestation cannot drift away
|
| 358 |
+
from the script it claims to describe. Unreadable script → honest nulls.
|
| 359 |
+
"""
|
| 360 |
+
path = ROOT / _TRAIN_SCRIPT
|
| 361 |
+
out: dict[str, Any] = {
|
| 362 |
+
"source": _TRAIN_SCRIPT,
|
| 363 |
+
"source_sha256": None,
|
| 364 |
+
"method": "LoRA (parameter-efficient fine-tune)",
|
| 365 |
+
"config": {},
|
| 366 |
+
"note": None,
|
| 367 |
+
}
|
| 368 |
+
try:
|
| 369 |
+
text = path.read_text(encoding="utf-8")
|
| 370 |
+
except Exception:
|
| 371 |
+
out["note"] = ("committed trainer not readable this request — honest "
|
| 372 |
+
"nulls, no training configuration fabricated")
|
| 373 |
+
out["config"] = {name: None for name, _, _ in _TRAIN_KNOBS}
|
| 374 |
+
return out
|
| 375 |
+
out["source_sha256"] = _sha256_file(path)
|
| 376 |
+
for name, flag, caster in _TRAIN_KNOBS:
|
| 377 |
+
m = re.search(
|
| 378 |
+
re.escape(flag) + r"\"[^)]*?default\s*=\s*(\"[^\"]*\"|[0-9eE.+-]+)",
|
| 379 |
+
text, re.S)
|
| 380 |
+
value: Any = None
|
| 381 |
+
if m:
|
| 382 |
+
raw = m.group(1)
|
| 383 |
+
try:
|
| 384 |
+
value = raw.strip('"') if raw.startswith('"') else caster(raw)
|
| 385 |
+
except Exception:
|
| 386 |
+
value = None
|
| 387 |
+
out["config"][name] = value
|
| 388 |
+
out["note"] = ("argparse defaults read verbatim from the committed trainer; "
|
| 389 |
+
"an operator run may override any knob on the command line")
|
| 390 |
+
return out
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def kernel_verification() -> dict[str, Any]:
|
| 394 |
+
"""Verify the locked-8 kernel claim against the digest-verified registry.
|
| 395 |
+
|
| 396 |
+
Real in-request verification (never a hard-coded True):
|
| 397 |
+
1. ``szl_formula_registry`` loads with digest verification ON — it
|
| 398 |
+
recomputes the canonical SHA-256 over the registry payload and
|
| 399 |
+
re-asserts its structural invariants, raising on any drift.
|
| 400 |
+
2. Every doctrine locked-8 id is COVERED by that registry.
|
| 401 |
+
3. The registry's locked_proven set is not inflated beyond the locked-8.
|
| 402 |
+
4. Λ is still ``CONJECTURE_1_ADVISORY`` — a promoted Λ invalidates the
|
| 403 |
+
kernel claim outright.
|
| 404 |
+
|
| 405 |
+
Any failed check, or an unreadable registry, yields ``verified: False`` with
|
| 406 |
+
the reason recorded. There is no path to a fabricated True.
|
| 407 |
+
"""
|
| 408 |
+
out: dict[str, Any] = {
|
| 409 |
+
"verified": False,
|
| 410 |
+
"kernel_pin": KERNEL_PIN,
|
| 411 |
+
"locked_proven": list(LOCKED_8),
|
| 412 |
+
"checks": {},
|
| 413 |
+
"registry": None,
|
| 414 |
+
"reason": None,
|
| 415 |
+
}
|
| 416 |
+
try:
|
| 417 |
+
import szl_formula_registry as _reg
|
| 418 |
+
except Exception as exc:
|
| 419 |
+
out["reason"] = f"formula registry unreadable ({type(exc).__name__}) — not verified"
|
| 420 |
+
return out
|
| 421 |
+
try:
|
| 422 |
+
basis = _reg.receipt_basis()
|
| 423 |
+
covered = tuple(getattr(_reg, "EXPECTED_COVERED_IDS", ()))
|
| 424 |
+
locked_ids = tuple(basis.get("locked_proven_ids") or ())
|
| 425 |
+
checks = {
|
| 426 |
+
"registry_digest_verified": bool(basis.get("formula_registry_digest")),
|
| 427 |
+
"locked8_covered": all(fid in covered for fid in LOCKED_8),
|
| 428 |
+
"locked_set_not_inflated": set(locked_ids).issubset(set(LOCKED_8)),
|
| 429 |
+
"lambda_is_conjecture": str(basis.get("lambda_status", "")).startswith(
|
| 430 |
+
"CONJECTURE_1"),
|
| 431 |
+
}
|
| 432 |
+
out["checks"] = checks
|
| 433 |
+
out["registry"] = {
|
| 434 |
+
"schema_version": basis.get("schema_version"),
|
| 435 |
+
"registry_version": basis.get("registry_version"),
|
| 436 |
+
"formula_registry_digest": basis.get("formula_registry_digest"),
|
| 437 |
+
"digest_algorithm": basis.get("digest_algorithm"),
|
| 438 |
+
"signature_status": basis.get("signature_status"),
|
| 439 |
+
"registry_locked_proven_ids": list(locked_ids),
|
| 440 |
+
"lambda_status": basis.get("lambda_status"),
|
| 441 |
+
}
|
| 442 |
+
out["verified"] = all(checks.values())
|
| 443 |
+
if not out["verified"]:
|
| 444 |
+
failed = sorted(k for k, v in checks.items() if not v)
|
| 445 |
+
out["reason"] = "failed kernel checks: " + ", ".join(failed)
|
| 446 |
+
return out
|
| 447 |
+
except Exception as exc:
|
| 448 |
+
out["reason"] = (f"kernel verification raised {type(exc).__name__} — "
|
| 449 |
+
"not verified (no fabricated pass)")
|
| 450 |
+
return out
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
# --------------------------------------------------------------------------- #
|
| 454 |
+
# Energy strand — empty unless a meter answered THIS request.
|
| 455 |
+
# --------------------------------------------------------------------------- #
|
| 456 |
+
def energy_measured(*, opener: Any = None) -> tuple[list[dict[str, Any]], dict[str, Any]]:
|
| 457 |
+
"""Return (readings, disclosure). Readings are [] with no live meter.
|
| 458 |
+
|
| 459 |
+
A joule is only ever recorded when a configured meter answered in this
|
| 460 |
+
request. No meter configured, or an unreachable one, yields an EMPTY list —
|
| 461 |
+
never a modelled or remembered joule dressed as MEASURED.
|
| 462 |
+
"""
|
| 463 |
+
raw = (os.environ.get(JOULE_METER_ENV) or "").strip()
|
| 464 |
+
urls = [u.strip() for u in raw.split(",") if u.strip()]
|
| 465 |
+
disclosure: dict[str, Any] = {
|
| 466 |
+
"meters_configured": len(urls),
|
| 467 |
+
"meter_env": JOULE_METER_ENV,
|
| 468 |
+
"label": "STRUCTURAL-ONLY",
|
| 469 |
+
"note": (f"no joule meter configured ({JOULE_METER_ENV} unset) — "
|
| 470 |
+
"energy_measured is honestly EMPTY; no joule fabricated"),
|
| 471 |
+
}
|
| 472 |
+
if not urls:
|
| 473 |
+
return [], disclosure
|
| 474 |
+
|
| 475 |
+
readings: list[dict[str, Any]] = []
|
| 476 |
+
errors: list[str] = []
|
| 477 |
+
timeout = 1.5
|
| 478 |
+
for url in urls[:8]:
|
| 479 |
+
try:
|
| 480 |
+
if opener is not None:
|
| 481 |
+
payload = opener(url, timeout)
|
| 482 |
+
else:
|
| 483 |
+
import urllib.request
|
| 484 |
+
|
| 485 |
+
with urllib.request.urlopen(url, timeout=timeout) as resp: # noqa: S310
|
| 486 |
+
payload = json.loads(resp.read().decode("utf-8", "replace"))
|
| 487 |
+
joules = payload.get("joules") if isinstance(payload, dict) else None
|
| 488 |
+
if isinstance(joules, (int, float)):
|
| 489 |
+
readings.append({
|
| 490 |
+
"meter": url,
|
| 491 |
+
"joules": float(joules),
|
| 492 |
+
"label": LABEL_MEASURED,
|
| 493 |
+
"read_at": _now_iso(),
|
| 494 |
+
})
|
| 495 |
+
else:
|
| 496 |
+
errors.append(f"{url}: no numeric joules field")
|
| 497 |
+
except Exception as exc:
|
| 498 |
+
errors.append(f"{url}: {type(exc).__name__}")
|
| 499 |
+
disclosure["errors"] = errors
|
| 500 |
+
if readings:
|
| 501 |
+
disclosure["label"] = LABEL_MEASURED
|
| 502 |
+
disclosure["note"] = (f"{len(readings)} live joule reading(s) taken this "
|
| 503 |
+
"request from the configured meter(s)")
|
| 504 |
+
else:
|
| 505 |
+
disclosure["label"] = "STRUCTURAL-ONLY"
|
| 506 |
+
disclosure["note"] = ("meter(s) configured but none answered with a joule "
|
| 507 |
+
"reading this request — energy_measured stays EMPTY, "
|
| 508 |
+
"no joule fabricated")
|
| 509 |
+
return readings, disclosure
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
# --------------------------------------------------------------------------- #
|
| 513 |
+
# The in-toto v1 Statement.
|
| 514 |
+
# --------------------------------------------------------------------------- #
|
| 515 |
+
def build_statement(*, ns: str = "a11oy", opener: Any = None) -> dict[str, Any]:
|
| 516 |
+
"""Assemble the in-toto v1 Statement for the L6 chain-of-title claim."""
|
| 517 |
+
weights = sovereign_weights_digest()
|
| 518 |
+
kernel = locked8_kernel_commit()
|
| 519 |
+
kern_v = kernel_verification()
|
| 520 |
+
corpus = corpus_sha()
|
| 521 |
+
training = training_config()
|
| 522 |
+
build = build_commit()
|
| 523 |
+
readings, energy_disclosure = energy_measured(opener=opener)
|
| 524 |
+
|
| 525 |
+
# in-toto requires each subject to carry at least one digest. The kernel
|
| 526 |
+
# subject always does (gitCommit). The weights subject is appended ONLY
|
| 527 |
+
# when a real sha256 exists — an empty digest set is never emitted.
|
| 528 |
+
subject: list[dict[str, Any]] = [{
|
| 529 |
+
"name": SUBJECT_KERNEL_NAME,
|
| 530 |
+
"digest": {"gitCommit": kernel["gitCommit"]},
|
| 531 |
+
"annotations": {
|
| 532 |
+
"locked_proven": kernel["locked_proven"],
|
| 533 |
+
"pin_source": kernel["source"],
|
| 534 |
+
},
|
| 535 |
+
}]
|
| 536 |
+
if weights["sha256"]:
|
| 537 |
+
subject.append({
|
| 538 |
+
"name": SUBJECT_WEIGHTS_NAME,
|
| 539 |
+
"digest": {"sha256": weights["sha256"]},
|
| 540 |
+
"annotations": {"path": weights["path"], "bytes": weights["bytes"]},
|
| 541 |
+
})
|
| 542 |
+
|
| 543 |
+
provenance_coverage = 1.0 # every field below is either a real read or an honest null
|
| 544 |
+
|
| 545 |
+
predicate: dict[str, Any] = {
|
| 546 |
+
"doctrine": DOCTRINE_VERSION,
|
| 547 |
+
"provenance": {
|
| 548 |
+
"corpus_sha": corpus["sha256"],
|
| 549 |
+
"corpus_source": {"path": corpus["path"], "kind": corpus["kind"],
|
| 550 |
+
"note": corpus["note"]},
|
| 551 |
+
"training": training,
|
| 552 |
+
"kernel_verified": bool(kern_v["verified"]),
|
| 553 |
+
"kernel_pin": KERNEL_PIN,
|
| 554 |
+
"kernel_verification": kern_v,
|
| 555 |
+
"build_commit": build,
|
| 556 |
+
"sovereign_weights": weights,
|
| 557 |
+
"provenance_coverage": provenance_coverage,
|
| 558 |
+
"coverage_rule": ("every provenance field is either a real read this "
|
| 559 |
+
"request or an explicit null with its reason — coverage "
|
| 560 |
+
"1.0 means fully DISCLOSED, not fully populated"),
|
| 561 |
+
},
|
| 562 |
+
# HONEST EMPTY when no meter answered this request. Never a fabricated joule.
|
| 563 |
+
"energy_measured": readings,
|
| 564 |
+
"energy_disclosure": energy_disclosure,
|
| 565 |
+
"honesty_invariants": {
|
| 566 |
+
"no_fabricated_measured": True,
|
| 567 |
+
"lambda_is_conjecture_not_theorem": True,
|
| 568 |
+
"locked8_immutable": True,
|
| 569 |
+
"provenance_coverage": provenance_coverage,
|
| 570 |
+
},
|
| 571 |
+
"honesty_invariants_meaning": {
|
| 572 |
+
"no_fabricated_measured": ("a MEASURED label is emitted only from a live "
|
| 573 |
+
"reading in the same request; energy_measured "
|
| 574 |
+
"is empty rather than invented"),
|
| 575 |
+
"lambda_is_conjecture_not_theorem": ("Λ is Conjecture 1 — advisory, never "
|
| 576 |
+
"a theorem, never green"),
|
| 577 |
+
"locked8_immutable": ("locked-8 {F1,F4,F7,F11,F12,F18,F19,F22} @ "
|
| 578 |
+
f"{KERNEL_PIN}; this organ adds nothing to it"),
|
| 579 |
+
"provenance_coverage": ("1.0 — every provenance field disclosed, nulls "
|
| 580 |
+
"included, none omitted"),
|
| 581 |
+
},
|
| 582 |
+
"seal": {
|
| 583 |
+
"formula": SEAL_FORMULA,
|
| 584 |
+
"tier": "PROPOSED",
|
| 585 |
+
"cites": list(SEAL_CITES),
|
| 586 |
+
"note": ("weights need calibration; the score is an engineering "
|
| 587 |
+
"composition of cited prior art, not a validated metric, and "
|
| 588 |
+
"no score is asserted here"),
|
| 589 |
+
},
|
| 590 |
+
"lambda": {
|
| 591 |
+
"status": "Conjecture 1",
|
| 592 |
+
"is_theorem": False,
|
| 593 |
+
"trust_ceiling": TRUST_CEILING,
|
| 594 |
+
},
|
| 595 |
+
"attestation": {
|
| 596 |
+
"schema": SCHEMA,
|
| 597 |
+
"namespace": ns,
|
| 598 |
+
"label": LABEL_MODELED,
|
| 599 |
+
"built_at": _now_iso(),
|
| 600 |
+
"cites": list(CITES),
|
| 601 |
+
"slsa": {
|
| 602 |
+
"build_track": "L0-L3 referenced as the cited direction; no SLSA "
|
| 603 |
+
"level is CLAIMED for this image",
|
| 604 |
+
"vsa": "this Statement is the SZL analogue of a SLSA v1.1 "
|
| 605 |
+
"Verification Summary Attestation over the policy in "
|
| 606 |
+
"ops/szl_chain_of_title.rego",
|
| 607 |
+
},
|
| 608 |
+
},
|
| 609 |
+
}
|
| 610 |
+
|
| 611 |
+
return {
|
| 612 |
+
"_type": STATEMENT_TYPE,
|
| 613 |
+
"subject": subject,
|
| 614 |
+
"predicateType": PREDICATE_TYPE,
|
| 615 |
+
"predicate": predicate,
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
|
| 619 |
+
# --------------------------------------------------------------------------- #
|
| 620 |
+
# DSSE signing (reuses szl_dsse — the estate is DSSE-LIVE).
|
| 621 |
+
# --------------------------------------------------------------------------- #
|
| 622 |
+
def sign_statement(statement: dict[str, Any]) -> dict[str, Any]:
|
| 623 |
+
"""DSSE-sign the Statement with the estate cosign key via ``szl_dsse``.
|
| 624 |
+
|
| 625 |
+
payloadType is the in-toto media type, so the envelope is byte-compatible
|
| 626 |
+
with ``cosign verify-blob`` / ``cosign verify-attestation``. With no runtime
|
| 627 |
+
private key the envelope is explicitly UNSIGNED — never a fake signature.
|
| 628 |
+
"""
|
| 629 |
+
try:
|
| 630 |
+
import szl_dsse
|
| 631 |
+
except Exception as exc: # pragma: no cover — dsse is in-image
|
| 632 |
+
return {
|
| 633 |
+
"payloadType": PAYLOAD_TYPE,
|
| 634 |
+
"payload": None,
|
| 635 |
+
"signatures": [],
|
| 636 |
+
"signed": False,
|
| 637 |
+
"honesty": f"szl_dsse unavailable ({type(exc).__name__}) — no envelope, "
|
| 638 |
+
"no fabricated signature",
|
| 639 |
+
}
|
| 640 |
+
env = szl_dsse.sign_payload(statement, PAYLOAD_TYPE)
|
| 641 |
+
env["_statement_digest_sha256"] = digest_hex(statement)
|
| 642 |
+
return env
|
| 643 |
+
|
| 644 |
+
|
| 645 |
+
def signature_status(envelope: dict[str, Any]) -> dict[str, Any]:
|
| 646 |
+
"""Honest signature verdict for an envelope. Never raises."""
|
| 647 |
+
out: dict[str, Any] = {
|
| 648 |
+
"signed": bool(envelope.get("signed")),
|
| 649 |
+
"verified": None,
|
| 650 |
+
"status": "UNSIGNED-NO-KEY",
|
| 651 |
+
"keyless_ready": True,
|
| 652 |
+
"note": None,
|
| 653 |
+
}
|
| 654 |
+
if not envelope.get("signatures"):
|
| 655 |
+
out["note"] = (envelope.get("honesty")
|
| 656 |
+
or "no signature present; no signature fabricated")
|
| 657 |
+
return out
|
| 658 |
+
try:
|
| 659 |
+
import szl_dsse
|
| 660 |
+
|
| 661 |
+
verdict = szl_dsse.verify_envelope(envelope)
|
| 662 |
+
out["verified"] = bool(verdict.get("verified"))
|
| 663 |
+
out["status"] = "VERIFIED" if out["verified"] else "SIGNATURE-INVALID"
|
| 664 |
+
out["keyid_expected"] = verdict.get("keyid_expected")
|
| 665 |
+
out["pub_fingerprint_sha256"] = verdict.get("pub_fingerprint_sha256")
|
| 666 |
+
out["note"] = ("ECDSA-P256-SHA256 over the DSSE PAE; also checkable by "
|
| 667 |
+
"`cosign verify-blob --key cosign.pub`")
|
| 668 |
+
except Exception as exc:
|
| 669 |
+
out["verified"] = None
|
| 670 |
+
out["status"] = "UNKNOWN-VERIFIER-ERROR"
|
| 671 |
+
out["note"] = f"verifier raised {type(exc).__name__} — UNKNOWN, not a pass"
|
| 672 |
+
return out
|
| 673 |
+
|
| 674 |
+
|
| 675 |
+
# --------------------------------------------------------------------------- #
|
| 676 |
+
# Rekor transparency log — HONEST GUARDED CALL.
|
| 677 |
+
# --------------------------------------------------------------------------- #
|
| 678 |
+
def _rekor_configured() -> tuple[bool, str]:
|
| 679 |
+
url = (os.environ.get(REKOR_URL_ENV) or DEFAULT_REKOR_URL).rstrip("/")
|
| 680 |
+
enabled = str(os.environ.get(REKOR_ENABLE_ENV, "")).strip().lower() in (
|
| 681 |
+
"1", "true", "yes", "on")
|
| 682 |
+
return enabled, url
|
| 683 |
+
|
| 684 |
+
|
| 685 |
+
def rekor_submit(envelope: dict[str, Any], *, submitter: Any = None) -> dict[str, Any]:
|
| 686 |
+
"""Structure the envelope for Rekor and submit it IF submission is enabled.
|
| 687 |
+
|
| 688 |
+
Tri-state, by construction:
|
| 689 |
+
* RECORDED — the log answered with a real entry carrying an
|
| 690 |
+
inclusion proof / log index. Only then is anything
|
| 691 |
+
recorded, and it is recorded VERBATIM.
|
| 692 |
+
* UNREACHABLE — submission was attempted and failed (offline sandbox,
|
| 693 |
+
DNS, timeout, non-2xx, unparseable body).
|
| 694 |
+
* NOT_ATTEMPTED — submission is not enabled in this runtime.
|
| 695 |
+
|
| 696 |
+
There is NO branch that writes a log index, UUID, or inclusion proof that
|
| 697 |
+
the log did not return. ``submitter`` is an injection seam for tests; the
|
| 698 |
+
default path uses urllib.
|
| 699 |
+
"""
|
| 700 |
+
enabled, url = _rekor_configured()
|
| 701 |
+
proposed = {
|
| 702 |
+
"kind": "intoto",
|
| 703 |
+
"apiVersion": "0.0.2",
|
| 704 |
+
"spec": {
|
| 705 |
+
"content": {
|
| 706 |
+
"envelope": {
|
| 707 |
+
"payloadType": envelope.get("payloadType"),
|
| 708 |
+
"payloadSha256": envelope.get("_statement_digest_sha256"),
|
| 709 |
+
"signatures": len(envelope.get("signatures") or []),
|
| 710 |
+
},
|
| 711 |
+
"hash": {"algorithm": "sha256",
|
| 712 |
+
"value": envelope.get("_statement_digest_sha256")},
|
| 713 |
+
},
|
| 714 |
+
},
|
| 715 |
+
}
|
| 716 |
+
out: dict[str, Any] = {
|
| 717 |
+
"status": REKOR_NOT_ATTEMPTED,
|
| 718 |
+
"log_url": url,
|
| 719 |
+
"attempted": False,
|
| 720 |
+
"reachable": None,
|
| 721 |
+
"log_index": None,
|
| 722 |
+
"entry_uuid": None,
|
| 723 |
+
"inclusion_proof": None,
|
| 724 |
+
"integrated_time": None,
|
| 725 |
+
"proposed_entry": proposed,
|
| 726 |
+
"label": "STRUCTURAL-ONLY",
|
| 727 |
+
"cite": "Sigstore Rekor — https://docs.sigstore.dev/logging/overview/",
|
| 728 |
+
"note": None,
|
| 729 |
+
}
|
| 730 |
+
if not envelope.get("signatures"):
|
| 731 |
+
out["note"] = ("envelope is UNSIGNED (no runtime cosign secret) — nothing "
|
| 732 |
+
"submitted; a transparency-log entry is never fabricated. "
|
| 733 |
+
"Structured for cosign keyless + Rekor upload once a key or "
|
| 734 |
+
"an OIDC identity is present.")
|
| 735 |
+
return out
|
| 736 |
+
if not enabled:
|
| 737 |
+
out["note"] = (f"Rekor submission not enabled in this runtime "
|
| 738 |
+
f"({REKOR_ENABLE_ENV} unset) — NOT_ATTEMPTED, never a "
|
| 739 |
+
"fabricated inclusion proof")
|
| 740 |
+
return out
|
| 741 |
+
|
| 742 |
+
out["attempted"] = True
|
| 743 |
+
try:
|
| 744 |
+
timeout = float(os.environ.get(REKOR_TIMEOUT_ENV, "3") or 3)
|
| 745 |
+
except Exception:
|
| 746 |
+
timeout = 3.0
|
| 747 |
+
body = canonical_json({"apiVersion": proposed["apiVersion"],
|
| 748 |
+
"kind": proposed["kind"],
|
| 749 |
+
"spec": proposed["spec"]})
|
| 750 |
+
try:
|
| 751 |
+
if submitter is not None:
|
| 752 |
+
payload = submitter(url, body, timeout)
|
| 753 |
+
else:
|
| 754 |
+
import urllib.request
|
| 755 |
+
|
| 756 |
+
req = urllib.request.Request( # noqa: S310
|
| 757 |
+
url + "/api/v1/log/entries", data=body,
|
| 758 |
+
headers={"Content-Type": "application/json",
|
| 759 |
+
"Accept": "application/json"},
|
| 760 |
+
method="POST")
|
| 761 |
+
with urllib.request.urlopen(req, timeout=timeout) as resp: # noqa: S310
|
| 762 |
+
payload = json.loads(resp.read().decode("utf-8", "replace"))
|
| 763 |
+
except Exception as exc:
|
| 764 |
+
out["status"] = REKOR_UNREACHABLE
|
| 765 |
+
out["reachable"] = False
|
| 766 |
+
out["note"] = (f"Rekor unreachable ({type(exc).__name__}) — transparency "
|
| 767 |
+
"strand is UNKNOWN; no entry, log index, or inclusion proof "
|
| 768 |
+
"fabricated")
|
| 769 |
+
return out
|
| 770 |
+
|
| 771 |
+
entry = _first_rekor_entry(payload)
|
| 772 |
+
proof = (entry or {}).get("verification", {}).get("inclusionProof")
|
| 773 |
+
log_index = (entry or {}).get("logIndex")
|
| 774 |
+
if not entry or proof is None or log_index is None:
|
| 775 |
+
out["status"] = REKOR_UNREACHABLE
|
| 776 |
+
out["reachable"] = True
|
| 777 |
+
out["note"] = ("log answered but returned no inclusion proof / log index — "
|
| 778 |
+
"transparency strand stays UNKNOWN rather than claim inclusion")
|
| 779 |
+
return out
|
| 780 |
+
|
| 781 |
+
out["status"] = REKOR_RECORDED
|
| 782 |
+
out["reachable"] = True
|
| 783 |
+
out["label"] = LABEL_MEASURED
|
| 784 |
+
out["log_index"] = log_index
|
| 785 |
+
out["entry_uuid"] = entry.get("_uuid")
|
| 786 |
+
out["integrated_time"] = entry.get("integratedTime")
|
| 787 |
+
out["inclusion_proof"] = proof
|
| 788 |
+
out["note"] = ("real inclusion proof returned by the transparency log this "
|
| 789 |
+
"request, recorded verbatim")
|
| 790 |
+
return out
|
| 791 |
+
|
| 792 |
+
|
| 793 |
+
def _first_rekor_entry(payload: Any) -> dict[str, Any] | None:
|
| 794 |
+
"""Rekor returns {uuid: entry}. Pull the first entry, tagging its uuid."""
|
| 795 |
+
if isinstance(payload, dict):
|
| 796 |
+
for uuid, entry in payload.items():
|
| 797 |
+
if isinstance(entry, dict):
|
| 798 |
+
out = dict(entry)
|
| 799 |
+
out["_uuid"] = entry.get("uuid") or uuid
|
| 800 |
+
return out
|
| 801 |
+
if isinstance(payload, list) and payload and isinstance(payload[0], dict):
|
| 802 |
+
return dict(payload[0])
|
| 803 |
+
return None
|
| 804 |
+
|
| 805 |
+
|
| 806 |
+
# --------------------------------------------------------------------------- #
|
| 807 |
+
# Policy evaluation — the Python twin of ops/szl_chain_of_title.rego.
|
| 808 |
+
# --------------------------------------------------------------------------- #
|
| 809 |
+
POLICY_RULES = (
|
| 810 |
+
"predicate_type_matches",
|
| 811 |
+
"doctrine_is_v11",
|
| 812 |
+
"kernel_verified",
|
| 813 |
+
"honesty_invariants_all_true",
|
| 814 |
+
"provenance_coverage_is_one",
|
| 815 |
+
"subject_binds_kernel_commit",
|
| 816 |
+
)
|
| 817 |
+
POLICY_PATH = "ops/szl_chain_of_title.rego"
|
| 818 |
+
POLICY_PACKAGE = "szl.attest.chain_of_title"
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
def evaluate_policy(statement: Any) -> dict[str, Any]:
|
| 822 |
+
"""Evaluate the chain-of-title policy over a Statement.
|
| 823 |
+
|
| 824 |
+
Deliberately mirrors ``ops/szl_chain_of_title.rego`` rule for rule so an
|
| 825 |
+
external OPA evaluation and this in-process evaluation agree. Returns
|
| 826 |
+
PASSED only when EVERY rule holds; any failure is FAILED with the failing
|
| 827 |
+
rule names named out loud.
|
| 828 |
+
"""
|
| 829 |
+
checks: dict[str, bool] = {k: False for k in POLICY_RULES}
|
| 830 |
+
if not isinstance(statement, dict):
|
| 831 |
+
return {"policy": VERDICT_FAILED, "checks": checks,
|
| 832 |
+
"failed": list(POLICY_RULES),
|
| 833 |
+
"reason": "statement is not a JSON object",
|
| 834 |
+
"rego": {"path": POLICY_PATH, "package": POLICY_PACKAGE}}
|
| 835 |
+
|
| 836 |
+
predicate = statement.get("predicate")
|
| 837 |
+
predicate = predicate if isinstance(predicate, dict) else {}
|
| 838 |
+
provenance = predicate.get("provenance")
|
| 839 |
+
provenance = provenance if isinstance(provenance, dict) else {}
|
| 840 |
+
inv = predicate.get("honesty_invariants")
|
| 841 |
+
inv = inv if isinstance(inv, dict) else {}
|
| 842 |
+
|
| 843 |
+
checks["predicate_type_matches"] = statement.get("predicateType") == PREDICATE_TYPE
|
| 844 |
+
checks["doctrine_is_v11"] = predicate.get("doctrine") == DOCTRINE_VERSION
|
| 845 |
+
checks["kernel_verified"] = provenance.get("kernel_verified") is True
|
| 846 |
+
checks["honesty_invariants_all_true"] = (
|
| 847 |
+
inv.get("no_fabricated_measured") is True
|
| 848 |
+
and inv.get("lambda_is_conjecture_not_theorem") is True
|
| 849 |
+
and inv.get("locked8_immutable") is True
|
| 850 |
+
and inv.get("provenance_coverage") == 1.0
|
| 851 |
+
)
|
| 852 |
+
checks["provenance_coverage_is_one"] = provenance.get("provenance_coverage") == 1.0
|
| 853 |
+
|
| 854 |
+
subjects = statement.get("subject")
|
| 855 |
+
subjects = subjects if isinstance(subjects, list) else []
|
| 856 |
+
kernel_bound = False
|
| 857 |
+
for s in subjects:
|
| 858 |
+
if not isinstance(s, dict) or s.get("name") != SUBJECT_KERNEL_NAME:
|
| 859 |
+
continue
|
| 860 |
+
digest = s.get("digest")
|
| 861 |
+
commit = digest.get("gitCommit") if isinstance(digest, dict) else None
|
| 862 |
+
if isinstance(commit, str) and commit.strip():
|
| 863 |
+
kernel_bound = True
|
| 864 |
+
break
|
| 865 |
+
checks["subject_binds_kernel_commit"] = kernel_bound
|
| 866 |
+
|
| 867 |
+
failed = [k for k, v in checks.items() if not v]
|
| 868 |
+
return {
|
| 869 |
+
"policy": VERDICT_PASSED if not failed else VERDICT_FAILED,
|
| 870 |
+
"checks": checks,
|
| 871 |
+
"failed": failed,
|
| 872 |
+
"reason": None if not failed else "failed policy rules: " + ", ".join(failed),
|
| 873 |
+
"rego": {"path": POLICY_PATH, "package": POLICY_PACKAGE,
|
| 874 |
+
"rule": "passed",
|
| 875 |
+
"note": "in-process evaluation mirrors the Rego policy rule for rule"},
|
| 876 |
+
}
|
| 877 |
+
|
| 878 |
+
|
| 879 |
+
# --------------------------------------------------------------------------- #
|
| 880 |
+
# Verify — the tri-state verdict.
|
| 881 |
+
# --------------------------------------------------------------------------- #
|
| 882 |
+
def _require_transparency_default() -> bool:
|
| 883 |
+
return str(os.environ.get(REQUIRE_TRANSPARENCY_ENV, "")).strip().lower() in (
|
| 884 |
+
"1", "true", "yes", "on")
|
| 885 |
+
|
| 886 |
+
|
| 887 |
+
def _statement_from(payload: Any) -> tuple[dict[str, Any] | None, dict[str, Any] | None, str | None]:
|
| 888 |
+
"""Accept a Statement, a DSSE envelope, or {statement}/{envelope}.
|
| 889 |
+
|
| 890 |
+
Returns (statement, envelope, error).
|
| 891 |
+
"""
|
| 892 |
+
import base64
|
| 893 |
+
|
| 894 |
+
if not isinstance(payload, dict):
|
| 895 |
+
return None, None, "body must be a JSON object"
|
| 896 |
+
if isinstance(payload.get("envelope"), dict):
|
| 897 |
+
payload = payload["envelope"]
|
| 898 |
+
elif isinstance(payload.get("statement"), dict):
|
| 899 |
+
stmt = payload["statement"]
|
| 900 |
+
return stmt, None, None
|
| 901 |
+
if payload.get("payload") and payload.get("payloadType"):
|
| 902 |
+
try:
|
| 903 |
+
body = base64.b64decode(payload["payload"])
|
| 904 |
+
stmt = json.loads(body.decode("utf-8"))
|
| 905 |
+
except Exception:
|
| 906 |
+
return None, payload, "envelope payload is not decodable JSON"
|
| 907 |
+
if not isinstance(stmt, dict):
|
| 908 |
+
return None, payload, "envelope payload is not a JSON object"
|
| 909 |
+
return stmt, payload, None
|
| 910 |
+
if payload.get("_type") or payload.get("predicateType"):
|
| 911 |
+
return payload, None, None
|
| 912 |
+
return None, None, "no in-toto Statement or DSSE envelope found in the body"
|
| 913 |
+
|
| 914 |
+
|
| 915 |
+
def verify(statement: Any, *, envelope: dict[str, Any] | None = None,
|
| 916 |
+
require_transparency: bool | None = None,
|
| 917 |
+
rekor: dict[str, Any] | None = None,
|
| 918 |
+
submitter: Any = None) -> dict[str, Any]:
|
| 919 |
+
"""Tri-state verification of a chain-of-title Statement.
|
| 920 |
+
|
| 921 |
+
FAILED — the policy failed, or a present signature did not verify. A
|
| 922 |
+
tampered statement is always FAILED, never UNKNOWN.
|
| 923 |
+
UNKNOWN — the policy passed but a REQUIRED transparency-log inclusion
|
| 924 |
+
proof could not be obtained (Rekor unreachable / not attempted).
|
| 925 |
+
PASSED — the policy passed and, when transparency is required, a real
|
| 926 |
+
inclusion proof came back this request.
|
| 927 |
+
|
| 928 |
+
``verdict_scope`` always states what the verdict covers, so a policy-only
|
| 929 |
+
PASSED is never mistaken for a transparency-anchored one.
|
| 930 |
+
"""
|
| 931 |
+
if require_transparency is None:
|
| 932 |
+
require_transparency = _require_transparency_default()
|
| 933 |
+
|
| 934 |
+
policy = evaluate_policy(statement)
|
| 935 |
+
sig = signature_status(envelope) if isinstance(envelope, dict) else {
|
| 936 |
+
"signed": False, "verified": None, "status": "NO-ENVELOPE-SUPPLIED",
|
| 937 |
+
"note": "verification ran over a bare Statement; no signature claimed",
|
| 938 |
+
}
|
| 939 |
+
if rekor is None:
|
| 940 |
+
rekor = (rekor_submit(envelope, submitter=submitter)
|
| 941 |
+
if isinstance(envelope, dict)
|
| 942 |
+
else {"status": REKOR_NOT_ATTEMPTED, "attempted": False,
|
| 943 |
+
"reachable": None, "inclusion_proof": None,
|
| 944 |
+
"label": "STRUCTURAL-ONLY",
|
| 945 |
+
"note": "no envelope supplied — nothing to submit"})
|
| 946 |
+
|
| 947 |
+
transparency_ok = rekor.get("status") == REKOR_RECORDED
|
| 948 |
+
|
| 949 |
+
reasons: list[str] = []
|
| 950 |
+
if policy["policy"] == VERDICT_FAILED:
|
| 951 |
+
verdict = VERDICT_FAILED
|
| 952 |
+
reasons.append(policy["reason"] or "policy failed")
|
| 953 |
+
elif sig.get("status") == "SIGNATURE-INVALID":
|
| 954 |
+
verdict = VERDICT_FAILED
|
| 955 |
+
reasons.append("DSSE signature present but did not verify (tamper)")
|
| 956 |
+
elif sig.get("status") == "UNKNOWN-VERIFIER-ERROR":
|
| 957 |
+
verdict = VERDICT_UNKNOWN
|
| 958 |
+
reasons.append("signature verifier error — UNKNOWN, not a pass")
|
| 959 |
+
elif require_transparency and not transparency_ok:
|
| 960 |
+
verdict = VERDICT_UNKNOWN
|
| 961 |
+
reasons.append("transparency-log inclusion required but "
|
| 962 |
+
f"{rekor.get('status')} — UNKNOWN, never a fabricated PASSED")
|
| 963 |
+
else:
|
| 964 |
+
verdict = VERDICT_PASSED
|
| 965 |
+
|
| 966 |
+
if verdict == VERDICT_PASSED and not transparency_ok:
|
| 967 |
+
scope = ("policy-only: every chain-of-title policy rule holds; the "
|
| 968 |
+
"transparency-log strand is UNKNOWN this request and is NOT "
|
| 969 |
+
"part of this verdict")
|
| 970 |
+
elif verdict == VERDICT_PASSED:
|
| 971 |
+
scope = ("policy + transparency: policy rules hold AND a real Rekor "
|
| 972 |
+
"inclusion proof was returned this request")
|
| 973 |
+
else:
|
| 974 |
+
scope = "; ".join(reasons)
|
| 975 |
+
|
| 976 |
+
return {
|
| 977 |
+
"ok": True,
|
| 978 |
+
"schema": SCHEMA,
|
| 979 |
+
"verdict": verdict,
|
| 980 |
+
"verdict_scope": scope,
|
| 981 |
+
"policy": policy,
|
| 982 |
+
"signature": sig,
|
| 983 |
+
"transparency": {
|
| 984 |
+
"required": bool(require_transparency),
|
| 985 |
+
"status": rekor.get("status"),
|
| 986 |
+
"label": rekor.get("label", "STRUCTURAL-ONLY"),
|
| 987 |
+
"log_index": rekor.get("log_index"),
|
| 988 |
+
"entry_uuid": rekor.get("entry_uuid"),
|
| 989 |
+
"inclusion_proof": rekor.get("inclusion_proof"),
|
| 990 |
+
"note": rekor.get("note"),
|
| 991 |
+
},
|
| 992 |
+
"reasons": reasons,
|
| 993 |
+
"label": LABEL_MEASURED if transparency_ok else LABEL_MODELED,
|
| 994 |
+
"label_rule": ("MEASURED only when a real transparency-log inclusion proof "
|
| 995 |
+
"was returned THIS request; MODELED otherwise"),
|
| 996 |
+
"lambda": {"status": "Conjecture 1", "is_theorem": False,
|
| 997 |
+
"trust_ceiling": TRUST_CEILING},
|
| 998 |
+
"verified_at": _now_iso(),
|
| 999 |
+
}
|
| 1000 |
+
|
| 1001 |
+
|
| 1002 |
+
# --------------------------------------------------------------------------- #
|
| 1003 |
+
# Manifest — statement + envelope + rekor + verdict in one read.
|
| 1004 |
+
# --------------------------------------------------------------------------- #
|
| 1005 |
+
def build_manifest(*, ns: str = "a11oy", require_transparency: bool | None = None,
|
| 1006 |
+
submitter: Any = None, opener: Any = None) -> dict[str, Any]:
|
| 1007 |
+
"""Build, sign, structure-for-Rekor and self-verify in one pure read."""
|
| 1008 |
+
statement = build_statement(ns=ns, opener=opener)
|
| 1009 |
+
envelope = sign_statement(statement)
|
| 1010 |
+
rekor = rekor_submit(envelope, submitter=submitter)
|
| 1011 |
+
verdict = verify(statement, envelope=envelope, rekor=rekor,
|
| 1012 |
+
require_transparency=require_transparency)
|
| 1013 |
+
return {
|
| 1014 |
+
"ok": True,
|
| 1015 |
+
"schema": SCHEMA,
|
| 1016 |
+
"label": verdict["label"],
|
| 1017 |
+
"statement": statement,
|
| 1018 |
+
"statement_digest_sha256": digest_hex(statement),
|
| 1019 |
+
"envelope": envelope,
|
| 1020 |
+
"rekor": rekor,
|
| 1021 |
+
"verdict": verdict["verdict"],
|
| 1022 |
+
"verdict_scope": verdict["verdict_scope"],
|
| 1023 |
+
"verification": verdict,
|
| 1024 |
+
"policy_source": {"path": POLICY_PATH, "package": POLICY_PACKAGE,
|
| 1025 |
+
"rules": list(POLICY_RULES)},
|
| 1026 |
+
"cites": list(CITES),
|
| 1027 |
+
"honest_note": (
|
| 1028 |
+
"This is a chain-of-title ATTESTATION, not a proof of correctness. It "
|
| 1029 |
+
"binds what is actually readable this request and says so when a strand "
|
| 1030 |
+
"is absent: no weights digest without weights, no joule without a meter, "
|
| 1031 |
+
"no Rekor entry without a log answer. Λ stays Conjecture 1; the locked-8 "
|
| 1032 |
+
"is attested, never extended; the SEAL score is tier PROPOSED."),
|
| 1033 |
+
"built_at": _now_iso(),
|
| 1034 |
+
}
|
| 1035 |
+
|
| 1036 |
+
|
| 1037 |
+
# --------------------------------------------------------------------------- #
|
| 1038 |
+
# szl-lake receipt (opt-in, guarded, off the hot path).
|
| 1039 |
+
# --------------------------------------------------------------------------- #
|
| 1040 |
+
def lake_receipt(manifest: dict[str, Any]) -> dict[str, Any]:
|
| 1041 |
+
"""Append an attestation receipt to the szl-lake ledger, IF configured.
|
| 1042 |
+
|
| 1043 |
+
Opt-in on ``SZL_LAKE_DIR`` so a plain read never writes to disk. Guarded:
|
| 1044 |
+
a lake failure is reported, never raised into the request.
|
| 1045 |
+
"""
|
| 1046 |
+
if not (os.environ.get(LAKE_DIR_ENV) or "").strip():
|
| 1047 |
+
return {"appended": False, "status": "NOT_CONFIGURED",
|
| 1048 |
+
"note": f"{LAKE_DIR_ENV} unset — no ledger write on a read path"}
|
| 1049 |
+
receipt = {
|
| 1050 |
+
"organ": "attest",
|
| 1051 |
+
"id": manifest.get("statement_digest_sha256"),
|
| 1052 |
+
"ts": manifest.get("built_at"),
|
| 1053 |
+
"schema": SCHEMA,
|
| 1054 |
+
"verdict": manifest.get("verdict"),
|
| 1055 |
+
"label": manifest.get("label"),
|
| 1056 |
+
"predicate_type": PREDICATE_TYPE,
|
| 1057 |
+
"kernel_pin": KERNEL_PIN,
|
| 1058 |
+
"rekor_status": (manifest.get("rekor") or {}).get("status"),
|
| 1059 |
+
"signed": bool((manifest.get("envelope") or {}).get("signed")),
|
| 1060 |
+
# energy is omitted rather than zero-filled — szl_lake_store labels an
|
| 1061 |
+
# absent reading UNAVAILABLE, which is the honest state here.
|
| 1062 |
+
}
|
| 1063 |
+
try:
|
| 1064 |
+
import szl_lake_store
|
| 1065 |
+
|
| 1066 |
+
store = szl_lake_store.LakeStore()
|
| 1067 |
+
res = store.append(receipt)
|
| 1068 |
+
return {"appended": bool(res.get("accepted")), "status": "APPENDED",
|
| 1069 |
+
"receipt_id": res.get("receipt_id"),
|
| 1070 |
+
"chain_index": res.get("chain_index"),
|
| 1071 |
+
"chain_head": res.get("chain_head")}
|
| 1072 |
+
except Exception as exc:
|
| 1073 |
+
print(f"[attest] lake receipt skipped (guarded): {type(exc).__name__}",
|
| 1074 |
+
file=sys.stderr)
|
| 1075 |
+
return {"appended": False, "status": "UNAVAILABLE",
|
| 1076 |
+
"note": f"lake append failed ({type(exc).__name__}) — not fabricated"}
|
| 1077 |
+
|
| 1078 |
+
|
| 1079 |
+
# --------------------------------------------------------------------------- #
|
| 1080 |
+
# FastAPI registration.
|
| 1081 |
+
#
|
| 1082 |
+
# GET manifest / verify and POST verify. All three are raw-Request handlers
|
| 1083 |
+
# so the POST is version-proof under fastapi==0.137.x (Starlette passes the
|
| 1084 |
+
# Request positionally); ``request`` is annotated as ``fastapi.Request`` for the
|
| 1085 |
+
# add_api_route fallback path.
|
| 1086 |
+
#
|
| 1087 |
+
# ROUTE-ORDER GOTCHA: szl_attest_stack already owns the PARAMETRIZED route
|
| 1088 |
+
# /api/<ns>/v1/attest/{receipt_hash}, which would otherwise swallow "manifest"
|
| 1089 |
+
# and "verify" as a receipt hash. So these STATIC routes are inserted BEFORE the
|
| 1090 |
+
# first parametrized /attest/ route (the proven szl_attested_inference pattern),
|
| 1091 |
+
# and in any case before the SPA catch-all.
|
| 1092 |
+
# --------------------------------------------------------------------------- #
|
| 1093 |
+
def register(app, ns: str = "a11oy") -> str:
|
| 1094 |
+
from fastapi.responses import JSONResponse
|
| 1095 |
+
|
| 1096 |
+
base = f"/api/{ns}/v1/attest"
|
| 1097 |
+
|
| 1098 |
+
def _truthy(v: Any) -> bool:
|
| 1099 |
+
return str(v or "").strip().lower() in ("1", "true", "yes", "on")
|
| 1100 |
+
|
| 1101 |
+
def _require_flag(request) -> bool | None:
|
| 1102 |
+
try:
|
| 1103 |
+
raw = request.query_params.get("require_transparency")
|
| 1104 |
+
except Exception:
|
| 1105 |
+
return None
|
| 1106 |
+
if raw is None:
|
| 1107 |
+
return None
|
| 1108 |
+
return _truthy(raw)
|
| 1109 |
+
|
| 1110 |
+
async def _h_manifest(request):
|
| 1111 |
+
"""GET manifest — build + sign + structure-for-Rekor + self-verify."""
|
| 1112 |
+
try:
|
| 1113 |
+
man = build_manifest(ns=ns, require_transparency=_require_flag(request))
|
| 1114 |
+
man["lake"] = lake_receipt(man)
|
| 1115 |
+
return JSONResponse(man)
|
| 1116 |
+
except Exception as exc: # never 500 into the console
|
| 1117 |
+
return JSONResponse({
|
| 1118 |
+
"ok": False, "schema": SCHEMA, "label": LABEL_MODELED,
|
| 1119 |
+
"verdict": VERDICT_UNKNOWN,
|
| 1120 |
+
"verdict_scope": f"manifest build error ({type(exc).__name__}) — "
|
| 1121 |
+
"UNKNOWN, never a fabricated PASSED",
|
| 1122 |
+
}, status_code=200)
|
| 1123 |
+
|
| 1124 |
+
async def _h_verify(request):
|
| 1125 |
+
"""GET/POST verify — PASSED / FAILED honestly, UNKNOWN when unreachable."""
|
| 1126 |
+
try:
|
| 1127 |
+
body: Any = None
|
| 1128 |
+
if request.method == "POST":
|
| 1129 |
+
try:
|
| 1130 |
+
body = await request.json()
|
| 1131 |
+
except Exception:
|
| 1132 |
+
body = None
|
| 1133 |
+
require = _require_flag(request)
|
| 1134 |
+
if body is None:
|
| 1135 |
+
statement = build_statement(ns=ns)
|
| 1136 |
+
envelope = sign_statement(statement)
|
| 1137 |
+
out = verify(statement, envelope=envelope, require_transparency=require)
|
| 1138 |
+
out["source"] = "freshly built statement (no body supplied)"
|
| 1139 |
+
return JSONResponse(out)
|
| 1140 |
+
statement, envelope, err = _statement_from(body)
|
| 1141 |
+
if statement is None:
|
| 1142 |
+
return JSONResponse({
|
| 1143 |
+
"ok": False, "schema": SCHEMA, "verdict": VERDICT_FAILED,
|
| 1144 |
+
"verdict_scope": err or "unparseable submission",
|
| 1145 |
+
"label": LABEL_MODELED,
|
| 1146 |
+
}, status_code=200)
|
| 1147 |
+
out = verify(statement, envelope=envelope, require_transparency=require)
|
| 1148 |
+
out["source"] = "caller-supplied " + ("envelope" if envelope else "statement")
|
| 1149 |
+
return JSONResponse(out)
|
| 1150 |
+
except Exception as exc:
|
| 1151 |
+
return JSONResponse({
|
| 1152 |
+
"ok": False, "schema": SCHEMA, "verdict": VERDICT_UNKNOWN,
|
| 1153 |
+
"verdict_scope": f"verifier error ({type(exc).__name__}) — UNKNOWN, "
|
| 1154 |
+
"never a fabricated PASSED",
|
| 1155 |
+
"label": LABEL_MODELED,
|
| 1156 |
+
}, status_code=200)
|
| 1157 |
+
|
| 1158 |
+
try:
|
| 1159 |
+
import fastapi as _fastapi
|
| 1160 |
+
_h_manifest.__annotations__["request"] = _fastapi.Request
|
| 1161 |
+
_h_verify.__annotations__["request"] = _fastapi.Request
|
| 1162 |
+
except Exception: # noqa: BLE001 — annotation is best-effort only
|
| 1163 |
+
pass
|
| 1164 |
+
|
| 1165 |
+
wired: list[str] = []
|
| 1166 |
+
specs = (
|
| 1167 |
+
(f"{base}/manifest", _h_manifest, ["GET"]),
|
| 1168 |
+
(f"{base}/verify", _h_verify, ["GET", "POST"]),
|
| 1169 |
+
)
|
| 1170 |
+
prefix = base + "/"
|
| 1171 |
+
for path, handler, methods in specs:
|
| 1172 |
+
try:
|
| 1173 |
+
from starlette.routing import Route
|
| 1174 |
+
|
| 1175 |
+
routes = app.router.routes
|
| 1176 |
+
insert_at = 0
|
| 1177 |
+
for i, rt in enumerate(routes):
|
| 1178 |
+
p = getattr(rt, "path", "") or ""
|
| 1179 |
+
if p.startswith(prefix) and "{" in p and p != path:
|
| 1180 |
+
insert_at = i
|
| 1181 |
+
break
|
| 1182 |
+
routes.insert(insert_at, Route(path, handler, methods=methods))
|
| 1183 |
+
wired.append(path)
|
| 1184 |
+
continue
|
| 1185 |
+
except Exception as exc:
|
| 1186 |
+
print(f"[{ns}] attest route front-insert failed for {path}: {exc!r}",
|
| 1187 |
+
file=sys.stderr)
|
| 1188 |
+
try:
|
| 1189 |
+
add_route = getattr(getattr(app, "router", None), "add_route", None)
|
| 1190 |
+
if callable(add_route):
|
| 1191 |
+
add_route(path, handler, methods=methods)
|
| 1192 |
+
else:
|
| 1193 |
+
app.add_api_route(path, handler, methods=methods)
|
| 1194 |
+
wired.append(path)
|
| 1195 |
+
except Exception as exc: # additive register must never break boot
|
| 1196 |
+
print(f"[{ns}] attest route NOT wired (guarded) {path}: {exc!r}",
|
| 1197 |
+
file=sys.stderr)
|
| 1198 |
+
|
| 1199 |
+
return f"attest-wired:{len(wired)}"
|
| 1200 |
+
|
| 1201 |
+
|
| 1202 |
+
# --------------------------------------------------------------------------- #
|
| 1203 |
+
# No-server self-test — the honesty invariants of this organ.
|
| 1204 |
+
# --------------------------------------------------------------------------- #
|
| 1205 |
+
def _selftest() -> dict[str, Any]:
|
| 1206 |
+
man = build_manifest()
|
| 1207 |
+
stmt = man["statement"]
|
| 1208 |
+
assert stmt["_type"] == STATEMENT_TYPE
|
| 1209 |
+
assert stmt["predicateType"] == PREDICATE_TYPE
|
| 1210 |
+
assert stmt["predicate"]["doctrine"] == DOCTRINE_VERSION
|
| 1211 |
+
# subject always binds a non-empty locked-8 kernel commit
|
| 1212 |
+
kernels = [s for s in stmt["subject"] if s["name"] == SUBJECT_KERNEL_NAME]
|
| 1213 |
+
assert len(kernels) == 1 and kernels[0]["digest"]["gitCommit"] == KERNEL_PIN
|
| 1214 |
+
# no fabricated joule, no fabricated Rekor entry in an offline runtime
|
| 1215 |
+
assert stmt["predicate"]["energy_measured"] == [] or all(
|
| 1216 |
+
r.get("label") == LABEL_MEASURED for r in stmt["predicate"]["energy_measured"])
|
| 1217 |
+
assert man["rekor"]["status"] in (REKOR_RECORDED, REKOR_UNREACHABLE,
|
| 1218 |
+
REKOR_NOT_ATTEMPTED)
|
| 1219 |
+
if man["rekor"]["status"] != REKOR_RECORDED:
|
| 1220 |
+
assert man["rekor"]["inclusion_proof"] is None
|
| 1221 |
+
assert man["rekor"]["log_index"] is None
|
| 1222 |
+
assert man["label"] == LABEL_MODELED
|
| 1223 |
+
# policy passes on a well-formed statement, fails on a tampered one
|
| 1224 |
+
assert evaluate_policy(stmt)["policy"] == VERDICT_PASSED, evaluate_policy(stmt)
|
| 1225 |
+
bad = json.loads(json.dumps(stmt))
|
| 1226 |
+
bad["predicate"]["honesty_invariants"]["locked8_immutable"] = False
|
| 1227 |
+
assert evaluate_policy(bad)["policy"] == VERDICT_FAILED
|
| 1228 |
+
assert verify(bad)["verdict"] == VERDICT_FAILED
|
| 1229 |
+
# required transparency with no log => UNKNOWN, never PASSED
|
| 1230 |
+
unk = verify(stmt, envelope=man["envelope"], require_transparency=True)
|
| 1231 |
+
if man["rekor"]["status"] != REKOR_RECORDED:
|
| 1232 |
+
assert unk["verdict"] == VERDICT_UNKNOWN, unk["verdict"]
|
| 1233 |
+
# Λ never a theorem
|
| 1234 |
+
assert stmt["predicate"]["lambda"]["is_theorem"] is False
|
| 1235 |
+
assert stmt["predicate"]["lambda"]["status"] == "Conjecture 1"
|
| 1236 |
+
print(f"szl_attest: ALL OK — verdict={man['verdict']} "
|
| 1237 |
+
f"rekor={man['rekor']['status']} signed={man['envelope'].get('signed')}")
|
| 1238 |
+
return man
|
| 1239 |
+
|
| 1240 |
+
|
| 1241 |
+
if __name__ == "__main__": # pragma: no cover
|
| 1242 |
+
_selftest()
|