ENTITY Documentation Portal
Recipe 4

Create evidence attestations and a two-attestor trust policy

from pathlib import Path
import importlib.util, hashlib

ROOT=Path.cwd()
def load_source(path,name):
    spec=importlib.util.spec_from_file_location(name,ROOT/path)
    mod=importlib.util.module_from_spec(spec); spec.loader.exec_module(mod); return mod

identity_mod=load_source("src/01_Core_Runtime/identity/canonical_identity.py","entity_identity")
fabric_mod=load_source("src/30_Universal_Transaction_Fabric/canonical_universal_fabric.py","entity_fabric")
STATE=ROOT/".recipe-state"/"trust"
identity=identity_mod.EntityIdentityVault(STATE)
owner=identity.create("Owner","organization")
lab_a=identity.create("Lab A","organization")
lab_b=identity.create("Lab B","organization")
fabric=fabric_mod.UniversalTransactionFabric(STATE,identity)
obj=fabric.register_object(owner["entity_id"],"DOCUMENT","Quality Report")

policy=fabric.create_trust_policy(
    owner["entity_id"], "QUALITY_TEST",
    minimum_attestations=2,
    required_attestors=[lab_a["entity_id"]],
    allowed_attestors=[lab_a["entity_id"],lab_b["entity_id"]],
)

def attest(lab, evidence):
    return fabric.attest(
        lab["entity_id"], obj["object_id"], "QUALITY_TEST",
        hashlib.sha256(evidence).hexdigest(), claim={"result":"PASS"}
    )

attest(lab_a,b"lab-a-report")
first=fabric.evaluate_trust(policy["policy_id"],obj["object_id"])
assert first["policy_satisfied"] is False
assert first["truth_inferred"] is False

attest(lab_b,b"lab-b-report")
second=fabric.evaluate_trust(policy["policy_id"],obj["object_id"])
assert second["policy_satisfied"] is True
assert second["truth_inferred"] is False

Policy satisfaction proves the configured evidence rule passed; it deliberately does not claim objective truth.