Python bindings for Web4 trust-native infrastructure
Project description
web4-core
Foundational primitives for the Web4 trust-native ontology, implemented in Rust with optional Python bindings via PyO3.
AI is already taking actions in the world. We can't prove what it did. Web4 is the open standard that closes that gap.
This crate provides the cryptographic and semantic primitives — Linked Context Tokens, Trust/Value tensors, identity coherence, and Ed25519-bound presence — that compose into the larger Web4 standard.
What's in here
- LCT (Linked Context Token) — Non-transferable presence tokens with hardware-bindable cryptographic identity. Parent/child lineage, status (Active/Dormant/Void/Slashed), 5-level hardware-binding ladder.
- T3 (Trust Tensor) — 3 root dimensions (Talent / Training / Temperament). Each root is itself an open-ended RDF sub-graph of context-specific sub-dimensions via
web4:subDimensionOf. Fractally extensible, not a fixed-size vector. - V3 (Value Tensor) — 3 root dimensions (Valuation / Veracity / Validity). Same fractal RDF pattern as T3.
- Coherence — Identity coherence scoring
C × S × Φ × R(Continuity × Stability × Phi × Reachability). Multiplicative — a low score in any factor limits the whole. - Crypto — Ed25519 signing/verification, SHA-256 hashing.
Quick start
LCTs are inherently blockchain tokens. The canonical creation path mints
them into a ledger — Lct::new() alone leaves the LCT unanchored, which is
fine for tests and prototyping but not for any deployment where presence
needs to be verifiable.
use web4_core::{Lct, EntityType, T3, TrustDimension, Coherence, InMemoryLedger, Ledger};
// 1. Create an LCT (in-memory primitive)
let (lct, keypair) = Lct::new(EntityType::Human, None);
// 2. Anchor to a ledger
let mut ledger = InMemoryLedger::new();
let receipt = lct.mint(&mut ledger).unwrap();
println!("Minted at index {}, hash {}", receipt.entry_index, receipt.entry_hash);
// 3. Sign and verify
let message = b"Hello, Web4!";
let signature = keypair.sign(message);
assert!(lct.verify_signature(message, &signature).is_ok());
// 4. Generate proof of existence
let proof = ledger.anchor(lct.id).unwrap();
assert!(ledger.verify_proof(&proof).unwrap());
// 5. Build a trust tensor by observation
let mut trust = T3::new();
trust.observe(TrustDimension::Talent, 0.9).unwrap();
trust.observe(TrustDimension::Training, 0.85).unwrap();
let score = trust.aggregate();
// 6. Identity coherence
let coherence = Coherence::with_values(0.92, 0.92, 0.92, 0.92).unwrap();
assert!(coherence.meets_threshold(lct.coherence_threshold()));
For persistence, swap InMemoryLedger for LocalLedger:
use web4_core::{Lct, EntityType, LocalLedger, Ledger};
let mut ledger = LocalLedger::open("./team-ledger.jsonl").unwrap();
let (lct, _kp) = Lct::new(EntityType::AiSoftware, None);
let receipt = lct.mint(&mut ledger).unwrap();
// Reopen later — state is replayed from the file with chain-integrity checks
let ledger = LocalLedger::open("./team-ledger.jsonl").unwrap();
assert_eq!(ledger.lookup(lct.id).unwrap().map(|l| l.id), Some(lct.id));
Ledger backends
| Backend | Use case | Persistence | Distribution |
|---|---|---|---|
InMemoryLedger |
Tests, prototyping, ephemeral runs | None | Single process |
LocalLedger |
Solo dev, team-scoped accountability, regulated/air-gapped | File (JSON-lines, hash-chained) | Single host |
ActLedger (separate crate, future) |
Federation-wide consensus | ACT Cosmos chain | Distributed |
All backends implement the [Ledger] trait — the canonical surface is stable across them. Swap backends without changing your minting code.
Web4 ontology context
Web4 = MCP + RDF + LCT + T3/V3*MRH + ATP/ADP
web4-core implements the LCT + T3/V3 + Coherence primitives. The remaining Web4 components (MCP integration, MRH context scoping, ATP/ADP energy economics, RDF ontology) live in web4-standard/ and the broader Web4 SDK.
Python bindings
Available via maturin at web4-core/python/. Install:
pip install web4-core
Or build from source:
pip install maturin
cd python
maturin develop
Python API mirrors the Rust API — see python/README.md.
Architecture
See ARCHITECTURE.md for the rationale on why Web4 is implemented in Rust with Python bindings, and how this crate fits into the larger ecosystem.
Status
Working ontology with growing proof points. Demonstrated 0% → 94.85% on ARC-AGI-3 (same Claude Opus 4.6, structured around Web4 patterns via the SAGE harness). Public scorecard: https://arcprize.org/scorecards/c7dfb4f1-8642-4c9e-ab4d-152f5f8e33b4.
R&D — not production. See parent repo STATUS.md for honest assessment.
Patent notice
This software implements technology covered by US Patents 11,477,027 and 12,278,913, and pending application 19/178,619 (assigned to MetaLINXX Inc.). A royalty-free patent license is granted under AGPL-3.0 terms for non-commercial / research / open-source use. For commercial licensing, contact dp@metalinxx.io. See PATENTS.md for full terms.
License
AGPL-3.0-or-later. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file web4_core-0.1.1.tar.gz.
File metadata
- Download URL: web4_core-0.1.1.tar.gz
- Upload date:
- Size: 71.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
044ffc325837690115ef73c448a3a8377d33bf085c92b368c53dfc50d21b9428
|
|
| MD5 |
708761a51fe7c15cda58b32082ac63b2
|
|
| BLAKE2b-256 |
95abb4c43cc858bda8c9b1b25edf63fb100eb0dbd9110fafaa3437c8483802b5
|
File details
Details for the file web4_core-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: web4_core-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 622.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81021d1738b409af7e5c18e1e8066a668f54e066acc083569322638f3a849430
|
|
| MD5 |
f6a86bd8c3154a66e7c2b7ab589e3ccf
|
|
| BLAKE2b-256 |
26b8e901eb19c9eafe15e7d6acaeb914e9ac6ea72f84475fb43053441fee5594
|