Skip to main content

Python bindings for Web4 trust-native infrastructure

Project description

web4-core

License: AGPL-3.0-or-later

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 ledgerLct::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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web4_core-0.1.0.tar.gz (70.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

web4_core-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (621.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

Details for the file web4_core-0.1.0.tar.gz.

File metadata

  • Download URL: web4_core-0.1.0.tar.gz
  • Upload date:
  • Size: 70.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for web4_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78ca11b1c09c40e2b7ccb504a6244187fb4822f8d58cc4526a3da60dc702d24d
MD5 5c88dc286b92108fe39206b20c6349cf
BLAKE2b-256 3380499a299f956ebcb038d60c19f0bf03b2523470317acc37761adf290aed88

See more details on using hashes here.

File details

Details for the file web4_core-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for web4_core-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a76e584b1b3839fa6a2eb8c8d280897f928e093400c62281d3c5a81f9b3c29ce
MD5 2e45a6ae4b4158cc2dcbac97af011a9b
BLAKE2b-256 4b1da07ac24b660548eaefb56484e3e0df25d0797e39d9e0c42609454185234f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page