twin3-sdk 0.2.10a0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. twin3_sdk-0.2.10a0/LICENSE +67 -0
  2. twin3_sdk-0.2.10a0/MANIFEST.in +18 -0
  3. twin3_sdk-0.2.10a0/PKG-INFO +197 -0
  4. twin3_sdk-0.2.10a0/README.md +176 -0
  5. twin3_sdk-0.2.10a0/pyproject.toml +45 -0
  6. twin3_sdk-0.2.10a0/setup.cfg +4 -0
  7. twin3_sdk-0.2.10a0/twin3/__init__.py +40 -0
  8. twin3_sdk-0.2.10a0/twin3/_compat.py +25 -0
  9. twin3_sdk-0.2.10a0/twin3/cli.py +187 -0
  10. twin3_sdk-0.2.10a0/twin3/comm/__init__.py +83 -0
  11. twin3_sdk-0.2.10a0/twin3/comm/access_grant.py +109 -0
  12. twin3_sdk-0.2.10a0/twin3/comm/client.py +196 -0
  13. twin3_sdk-0.2.10a0/twin3/comm/counterparty.py +813 -0
  14. twin3_sdk-0.2.10a0/twin3/comm/envelope.py +152 -0
  15. twin3_sdk-0.2.10a0/twin3/comm/export.py +117 -0
  16. twin3_sdk-0.2.10a0/twin3/comm/inbox.py +793 -0
  17. twin3_sdk-0.2.10a0/twin3/conformance/__init__.py +101 -0
  18. twin3_sdk-0.2.10a0/twin3/conformance/artifacts.py +203 -0
  19. twin3_sdk-0.2.10a0/twin3/conformance/consumer_execution.py +253 -0
  20. twin3_sdk-0.2.10a0/twin3/conformance/contract_brain.py +1528 -0
  21. twin3_sdk-0.2.10a0/twin3/conformance/layers.py +494 -0
  22. twin3_sdk-0.2.10a0/twin3/discovery/__init__.py +96 -0
  23. twin3_sdk-0.2.10a0/twin3/discovery/adapters/__init__.py +75 -0
  24. twin3_sdk-0.2.10a0/twin3/discovery/adapters/a2a.py +355 -0
  25. twin3_sdk-0.2.10a0/twin3/discovery/adapters/mcp_registry_candidate.py +151 -0
  26. twin3_sdk-0.2.10a0/twin3/discovery/adapters/x402.py +323 -0
  27. twin3_sdk-0.2.10a0/twin3/discovery/cards.py +340 -0
  28. twin3_sdk-0.2.10a0/twin3/discovery/declaration.py +289 -0
  29. twin3_sdk-0.2.10a0/twin3/discovery/descriptor.py +192 -0
  30. twin3_sdk-0.2.10a0/twin3/discovery/diplomat.py +378 -0
  31. twin3_sdk-0.2.10a0/twin3/discovery/registry.py +82 -0
  32. twin3_sdk-0.2.10a0/twin3/governance/__init__.py +49 -0
  33. twin3_sdk-0.2.10a0/twin3/governance/arbitration.py +46 -0
  34. twin3_sdk-0.2.10a0/twin3/governance/evidence.py +334 -0
  35. twin3_sdk-0.2.10a0/twin3/governance/federation.py +184 -0
  36. twin3_sdk-0.2.10a0/twin3/jcs.py +147 -0
  37. twin3_sdk-0.2.10a0/twin3/matrix/__init__.py +74 -0
  38. twin3_sdk-0.2.10a0/twin3/matrix/profile.py +145 -0
  39. twin3_sdk-0.2.10a0/twin3/matrix/schema.py +380 -0
  40. twin3_sdk-0.2.10a0/twin3/matrix/vector.py +350 -0
  41. twin3_sdk-0.2.10a0/twin3/settlement/__init__.py +50 -0
  42. twin3_sdk-0.2.10a0/twin3/settlement/policy.py +217 -0
  43. twin3_sdk-0.2.10a0/twin3/settlement/x402.py +350 -0
  44. twin3_sdk-0.2.10a0/twin3/shield/__init__.py +102 -0
  45. twin3_sdk-0.2.10a0/twin3/shield/adapter.py +129 -0
  46. twin3_sdk-0.2.10a0/twin3/shield/classifier.py +284 -0
  47. twin3_sdk-0.2.10a0/twin3/shield/clearance.py +235 -0
  48. twin3_sdk-0.2.10a0/twin3/shield/corpus.py +165 -0
  49. twin3_sdk-0.2.10a0/twin3/shield/corpus_seed.py +75 -0
  50. twin3_sdk-0.2.10a0/twin3/shield/defense.py +390 -0
  51. twin3_sdk-0.2.10a0/twin3/shield/execution.py +196 -0
  52. twin3_sdk-0.2.10a0/twin3/shield/intel.py +476 -0
  53. twin3_sdk-0.2.10a0/twin3/shield/lease.py +119 -0
  54. twin3_sdk-0.2.10a0/twin3/shield/memory.py +186 -0
  55. twin3_sdk-0.2.10a0/twin3/shield/plan_diff.py +398 -0
  56. twin3_sdk-0.2.10a0/twin3/trust/__init__.py +215 -0
  57. twin3_sdk-0.2.10a0/twin3/trust/compare.py +113 -0
  58. twin3_sdk-0.2.10a0/twin3/trust/didweb.py +126 -0
  59. twin3_sdk-0.2.10a0/twin3/trust/disclosure.py +296 -0
  60. twin3_sdk-0.2.10a0/twin3/trust/identity_kinds.py +90 -0
  61. twin3_sdk-0.2.10a0/twin3/trust/kya.py +369 -0
  62. twin3_sdk-0.2.10a0/twin3/trust/lease.py +228 -0
  63. twin3_sdk-0.2.10a0/twin3/trust/passkey.py +572 -0
  64. twin3_sdk-0.2.10a0/twin3/trust/record_kinds.py +84 -0
  65. twin3_sdk-0.2.10a0/twin3/trust/records.py +513 -0
  66. twin3_sdk-0.2.10a0/twin3/trust/state.py +1065 -0
  67. twin3_sdk-0.2.10a0/twin3_sdk.egg-info/PKG-INFO +197 -0
  68. twin3_sdk-0.2.10a0/twin3_sdk.egg-info/SOURCES.txt +70 -0
  69. twin3_sdk-0.2.10a0/twin3_sdk.egg-info/dependency_links.txt +1 -0
  70. twin3_sdk-0.2.10a0/twin3_sdk.egg-info/entry_points.txt +2 -0
  71. twin3_sdk-0.2.10a0/twin3_sdk.egg-info/requires.txt +4 -0
  72. twin3_sdk-0.2.10a0/twin3_sdk.egg-info/top_level.txt +1 -0
@@ -0,0 +1,67 @@
1
+ Twin3 SDK Proprietary License
2
+
3
+ Copyright (c) 2026 Twin3 AI Limited (the "Licensor"). All rights reserved.
4
+
5
+ This software, together with its documentation, specifications, protocol
6
+ designs, test vectors, and cryptographic constructions (the "Software"), is the
7
+ proprietary property of the Licensor. It is not open-source software. Making a
8
+ distribution artifact publicly downloadable from a package registry or source
9
+ host does not place the Software in the public domain, does not grant any
10
+ open-source licence, and does not waive any right reserved below.
11
+
12
+ 1. Limited licence
13
+ Subject to continuous compliance with these terms, the Licensor grants you a
14
+ personal, non-exclusive, non-transferable, non-sublicensable, revocable
15
+ licence to download, install, and execute unmodified official distribution
16
+ artifacts of the Software, solely to evaluate the Software and to build and
17
+ operate applications that interoperate with it.
18
+
19
+ 2. Restrictions
20
+ Except where applicable law expressly prohibits such a restriction, you may
21
+ not: copy the Software beyond what is required to exercise the licence in
22
+ section 1; modify, adapt, translate, or create derivative works of the
23
+ Software; redistribute, publish, sublicense, sell, rent, lease, or provide
24
+ the Software to any third party, whether standalone or embedded in another
25
+ product or service; remove, obscure, or alter any proprietary or attribution
26
+ notice; or reverse engineer, decompile, or disassemble the Software.
27
+
28
+ 3. Reservation of rights
29
+ All rights not expressly granted in section 1 are reserved by the Licensor,
30
+ including every copyright, patent, trade secret, trademark, database, and
31
+ other intellectual property right in the Software. No patent licence is
32
+ granted by implication, estoppel, or otherwise. No trademark licence is
33
+ granted.
34
+
35
+ 4. Contributions and derivative work
36
+ Nothing in this licence grants any right to fork the Software, publish a
37
+ derivative of it, or contribute to it. Any such activity requires prior
38
+ written permission from the Licensor.
39
+
40
+ 5. Termination
41
+ This licence terminates automatically and immediately upon any breach of
42
+ these terms. On termination you must stop using the Software and destroy all
43
+ copies in your possession or control. Sections 2, 3, 6, 7, and 8 survive
44
+ termination.
45
+
46
+ 6. No warranty
47
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT. THE SOFTWARE
50
+ IMPLEMENTS SECURITY AND SETTLEMENT PROTOCOLS; THE LICENSOR DOES NOT WARRANT
51
+ THAT IT IS FREE OF DEFECTS OR FIT FOR ANY PARTICULAR DEPLOYMENT.
52
+
53
+ 7. Limitation of liability
54
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSOR SHALL NOT BE
55
+ LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
56
+ CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
57
+ SOFTWARE OR ITS USE, INCLUDING ANY INDIRECT, INCIDENTAL, SPECIAL,
58
+ CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS,
59
+ REVENUE, DATA, OR DIGITAL ASSETS.
60
+
61
+ 8. Entire terms
62
+ These terms are the entire licence for the Software and supersede any prior
63
+ or contemporaneous understanding. A separate written agreement signed by the
64
+ Licensor may grant broader rights; only that agreement can vary these terms.
65
+
66
+ For commercial licensing, redistribution rights, or any permission not granted
67
+ above, contact core@twin3.ai.
@@ -0,0 +1,18 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ recursive-include twin3 *.py
5
+ prune .github
6
+ prune docs
7
+ prune release
8
+ prune tests
9
+ exclude API.md
10
+ exclude API_ZH.md
11
+ exclude CHANGELOG.md
12
+ exclude CONTRIBUTING.md
13
+ exclude README_ZH.md
14
+ exclude index.d.ts
15
+ exclude package.json
16
+ global-exclude *.py[cod]
17
+ global-exclude __pycache__
18
+ global-exclude .DS_Store
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: twin3-sdk
3
+ Version: 0.2.10a0
4
+ Summary: The Universal Capability Motherboard for Autonomous AI Agents and Self-Sovereign Humans
5
+ Author-email: Twin3 AI Limited <core@twin3.ai>
6
+ License-Expression: LicenseRef-Twin3-Proprietary
7
+ Project-URL: Homepage, https://github.com/twin3-team/twin3-sdk
8
+ Project-URL: Repository, https://github.com/twin3-team/twin3-sdk.git
9
+ Project-URL: Documentation, https://github.com/twin3-team/twin3-sdk/blob/main/README.md
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: Topic :: Security :: Cryptography
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: cryptography>=42.0.0
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # Twin3 SDK (`twin3-sdk`)
23
+ > **The Universal Capability Motherboard for Autonomous AI Agents & Self-Sovereign Humans**
24
+
25
+ [English](README.md) | [繁體中文](README_ZH.md) | [GitHub: twin3-team/twin3-sdk](https://github.com/twin3-team/twin3-sdk)
26
+
27
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
28
+ [![Architecture: 7-Layer Symbiosis](https://img.shields.io/badge/Architecture-7--Layer%20Symbiosis-success.svg)](#the-seven-layer-symbiotic-architecture)
29
+ [![Dual-Projection](https://img.shields.io/badge/Dual--Use-Agent%20ID%20%7C%20Human%20ID-orange.svg)](#dual-application-projections)
30
+ [![Repo: twin3-team/twin3-sdk](https://img.shields.io/badge/GitHub-twin3--team%2Ftwin3--sdk-purple.svg)](https://github.com/twin3-team/twin3-sdk)
31
+
32
+ ---
33
+
34
+ ## 1. Overview & Vision
35
+
36
+ **Twin3 SDK** is a domain-agnostic, cryptographically secure foundational runtime designed to bridge autonomous AI agents and self-sovereign human individuals into a single symbiotic economic network.
37
+
38
+ As AI models evolve toward fully autonomous trading actors, the primary barrier to adoption is not intelligence, but **counterparty trust, deterministic authorization, cryptographic non-repudiation, and autonomous financial settlement**.
39
+
40
+ Twin3 SDK solves this by establishing a **Seven-Layer Symbiotic Architecture (L1 to L7)**. It serves as the universal hardware-like motherboard, while domain-specific applications plug into it as specialized software projections:
41
+ 1. **Agent ID (Enterprise Projection)**: Powers B2B autonomous commerce, procurement negotiation, and Dun & Bradstreet (D-U-N-S) enterprise identity verification across 20 commercial capabilities.
42
+ 2. **Human ID (Sovereign Projection)**: Protects 140,000+ real-world human identity assets, providing Passkey (WebAuthn) biometrics, personal sovereign cards, and paid anti-spam inboxes.
43
+
44
+ ---
45
+
46
+ ## 2. The Seven-Layer Symbiotic Architecture
47
+
48
+ Twin3 SDK organizes all distributed primitives into seven clean, composable layers:
49
+
50
+ ```
51
+ ┌─────────────────────────────────────────────────────────┐
52
+ │ Twin3 SDK Core Engine │
53
+ ├────┬───────────────────────┬────────────────────────────┤
54
+ │ L1 │ Discovery Layer │ twin3.discovery │
55
+ │ L2 │ Trust & Identity │ twin3.trust │
56
+ │ L3 │ Communication Layer │ twin3.comm │
57
+ │ L4 │ Shield & Guardrails │ twin3.shield │
58
+ │ L5 │ Matrix Understanding │ twin3.matrix │
59
+ │ L6 │ Clearing & Settlement │ twin3.settlement │
60
+ │ L7 │ Governance & Audit │ twin3.governance │
61
+ └────┴───────────────────────┴────────────────────────────┘
62
+ ▲ ▲
63
+ │ │
64
+ ┌────────────────────┴───────────┐ ┌────────────┴─────────────────┐
65
+ │ Agent ID (Enterprise) │ │ Human ID (Sovereign) │
66
+ ├────────────────────────────────┤ ├──────────────────────────────┤
67
+ │ • A2A 5-Stage Commercial Loop │ │ • Sovereign Identity Card │
68
+ │ • D-U-N-S Entity Verification │ │ • 140,000 Personality Vectors│
69
+ │ • Manufacturing Tolerance Match│ │ • Passkey WebAuthn Login │
70
+ │ • Corporate Multi-Sig Escrow │ │ • Paid Threshold Inbox │
71
+ └────────────────────────────────┘ └──────────────────────────────┘
72
+ ```
73
+
74
+ ### Layer Breakdown
75
+
76
+ | Layer | Module Path | Purpose | Key Primitives & Protocols |
77
+ | :--- | :--- | :--- | :--- |
78
+ | **L1 Discovery** | `twin3.discovery` | Agent Card & Sovereign Card specifications, public inbox declaration, in-memory registry. | `AgentCard`, `SovereignCard`, `build_declaration`, `DiscoveryRegistry` |
79
+ | **L2 Trust** | `twin3.trust` | Cryptographic identity handshake, public/private key verification, authority anchoring. | `create_challenge` / `complete_challenge` / `verify_binding`, `PasskeyAdapter`, `AuthorityAnchor`, `resolve_did_web`, nonce and sign-count stores |
80
+ | **L3 Communication** | `twin3.comm` | Non-repudiable message packaging, counterparty attention ladder, task inbox. | `build_envelope` / `validate_envelope` (Ed25519), `CounterpartyTable`, `TaskInbox`, owner access grants |
81
+ | **L4 Shield** | `twin3.shield` | Differential tampering defense, prompt injection filtering, and authorization guardrails. | `scan_text` / `scan_envelope` (T0–T3), `IntelEngine` (T1), `Ensemble` (T4), `diff_plans` / `authorize_execution` (T5), `MemoryGuard` |
82
+ | **L5 Matrix** | `twin3.matrix` | High-density vector space topological mapping and semantic cosine matching. | `DenseVector256`, `feature_distance`, `HumanMatrixSchema`, `EnterpriseMatrixSchema` |
83
+ | **L6 Settlement** | `twin3.settlement` | Signed-receipt verification for HTTP 402 gates, with externally supplied chain-finality and replay controls. | `PaymentDemand`, `PaymentReceipt`, `X402SettlementEngine` |
84
+ | **L7 Governance** | `twin3.governance` | Immutable evidence trail, appeals, advisory reputation federation, provisional arbitration helper. | `EvidenceTrail`, `open_appeal` / `resolve_appeal`, `export_reputation` / `import_reputation`, `ArbitrationEngine` (experimental), `DisputeCase` (experimental) |
85
+
86
+ `(experimental)` marks a capability whose row in [`tests/capability-inventory.json`](tests/capability-inventory.json) is not yet `available`: it is importable today and its surface may still change. Everything unmarked is `available`. A name written `Class.method` is a method, not a module export. Every name in this table is checked against a real public export by [`tests/test_readme_capability_claims.py`](tests/test_readme_capability_claims.py).
87
+
88
+ ---
89
+
90
+ ## 3. Pull Request Lineage & Provenance
91
+
92
+ The primitives in `twin3-sdk` are extracted from the `twin3-team/agent-id` Inbox line (PRs #615–#642, merged 2026-09-03 → 2026-09-05; spec: `docs/architecture/inbox-module-spec.md` in that repo). What each layer inherited:
93
+
94
+ * **Envelope, KYA handshake, counterparty ladder** — `agent_id/inbox/{envelope,kya,counterparty}.py`: canonical-JSON signed envelopes with `authority:"none"`, the mutual Ed25519 challenge that binds a declared identity to a key, and the G0→G3 attention ladder keyed on the counterparty rather than the request.
95
+ * **Task inbox and state machine** — `agent_id/inbox/state.py`: intake gate, review gate, rate limits, stale expiry, hash-chained audit.
96
+ * **Shield T0–T5** — `agent_id/inbox/{shield,intel,classifier,plandiff,corpus}.py`: deterministic layers, URL/domain/hash intelligence, the T4 ensemble, plan diffing, and the corpus that publishes error rates.
97
+ * **Settlement policy** — `agent_id/inbox/payments.py`: owner policy, signed quotes and receipts behind HTTP 402.
98
+ * **Governance** — `agent_id/inbox/governance.py`: appeals, pardons, advisory reputation federation.
99
+ * **Canonical Matrix Core**: High-density 256-Byte vector topological clustering powering 140k natural human personality profiles and industrial tolerance matching.
100
+
101
+ The 2026-09-05 sync also adds the **AI-era hardening** (mandatory T5, identity-cost tier caps, provenance-gated memory, rotation demotes, paid ≠ authorized). See `CHANGELOG.md`.
102
+
103
+ ---
104
+
105
+ ## 4. Package Distribution & Integration Model
106
+
107
+ ### Why Not File Copying?
108
+ Copying code (`vendoring`) causes **protocol drift** where Agent ID and Human ID implementations diverge within weeks, breaking cross-network signature validation.
109
+
110
+ ### Why Not Pure HTTP Microservices?
111
+ Cryptographic signatures (ECDSA/Ed25519) and 256-bit vector operations execute in under 0.2 milliseconds locally. Routing them through remote HTTP hops adds unnecessary latency and exposes private signing keys to network attack vectors.
112
+
113
+ ### The Standard Solution: Semantic Package Dependencies
114
+ Twin3 SDK follows standard modern packaging conventions (`pyproject.toml` / `npm`). Production consumers must use immutable registry artifacts and exact version pins; local links are development-only.
115
+
116
+ #### 1. Development Mode (Local Symlink / Editable Install)
117
+ During local development, both `agent-id` and `XHuman_ID` link directly to the local SDK workspace:
118
+ ```bash
119
+ # In agent-id or XHuman_ID virtual environment:
120
+ pip install -e /path/to/twin3-sdk
121
+ ```
122
+ **Benefits**:
123
+ * Zero code duplication.
124
+ * Any protocol or algorithm improvement in `twin3-sdk` is reflected in both applications in **0 milliseconds**.
125
+
126
+ #### 2. Production Distribution
127
+ The next release candidate is `0.2.10-pre-alpha` for npm and `0.2.10a0` for Python. It is not a production dependency until the GitHub release workflows have built, attested, rehearsed, and published the exact tagged artifacts. Consumers must then pin the exact released version and lock its registry integrity; never use a mutable range for a cryptographic protocol dependency. This candidate stays pre-alpha. Marketplace or sales copy may offer it for evaluation; it is not a stable release, and the npm dist-tag is `next`, not `latest`.
128
+
129
+ `package.json` `engines` sets Node.js to `>=18` and does not set an npm engine. Any npm that can install a tarball can consume the package. Packing this repository was checked with npm 10 or newer; the stricter npm version in the release runbook applies only to Trusted Publishing.
130
+
131
+ After the release workflow has published that exact version, install the pin. These commands are not evidence that the registry already serves the package:
132
+
133
+ ```bash
134
+ npm install twin3-sdk@0.2.10-pre-alpha
135
+ pip install twin3-sdk==0.2.10a0
136
+ ```
137
+
138
+ Until publication, evaluate the packed npm tarball only. Do not install from a git URL or a version range:
139
+
140
+ ```bash
141
+ npm pack --ignore-scripts
142
+ npm install ./twin3-sdk-0.2.10-pre-alpha.tgz
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 5. Dual-Application Projections
148
+
149
+ ### 🏢 Agent ID (Enterprise Commerce Projection)
150
+ Agent ID consumes Twin3 SDK to execute the **5-Stage A2A Autonomous Commercial Loop**:
151
+ 1. **Discovery**: Queries `twin3.discovery` for available suppliers and verified agent cards.
152
+ 2. **Understand**: Uses `twin3.matrix` to compute tolerance matching against industrial RFQs.
153
+ 3. **Negotiate**: Uses `twin3.comm` and `twin3.shield` to exchange signed quotes without prompt-tampering risks.
154
+ 4. **Settle**: Uses the Twin3 signed-receipt adapter at an HTTP 402 gate. Acceptance additionally requires a trusted signer key, a chain-specific finality verifier, and a shared replay store.
155
+ 5. **Dispute**: Invokes `twin3.governance` to resolve contractual non-performance.
156
+
157
+ ### 👤 Human ID (Personal Sovereignty Projection)
158
+ Human ID consumes Twin3 SDK to empower natural individuals:
159
+ 1. **140,000 Real Personality Assets**: Computes high-density personality matching via `twin3.matrix` without risking underlying database schemas.
160
+ 2. **Passkey WebAuthn Login**: Binds biometric secure enclaves to decentralized keys via `twin3.trust`.
161
+ 3. **Paid Inbox**: Protects individual inboxes against spam using `twin3.comm` and the signed-receipt adapter ($5 paywall threshold); the application supplies chain verification and shared replay state.
162
+ 4. **Sovereign Card**: Renders non-custodial credentials using `twin3.discovery`.
163
+
164
+ ---
165
+
166
+ ## 6. Directory Structure
167
+
168
+ ```
169
+ twin3-sdk/
170
+ ├── pyproject.toml # Standard packaging definition (PEP 621)
171
+ ├── README.md # Canonical English manual
172
+ ├── LICENSE # Proprietary licence, all rights reserved
173
+ ├── js/index.js # Node runtime; js/comm/counterparty.js = Inbox line, counterparty side
174
+ ├── twin3/ # Core SDK namespace
175
+ │ ├── __init__.py
176
+ │ ├── _compat.py # One import surface mirroring agent_id.inbox
177
+ │ ├── discovery/ # L1: Cards, Endpoints, agents.json, public inbox declaration
178
+ │ ├── trust/ # L2: KYA Handshake, did:web, Passkey Adapter
179
+ │ ├── comm/ # L3: Envelope, Counterparty Table, TaskInbox, export, client (counterparty side)
180
+ │ ├── shield/ # L4: T0–T3 defense, T1 intel, T4 classifier, T5 plan diff, corpus, memory gate
181
+ │ ├── matrix/ # L5: 256-Byte Vector Topology Engine
182
+ │ ├── settlement/ # L6: HTTP 402 Micropayments, owner policy, quotes, receipts
183
+ │ └── governance/ # L7: Evidence Trail, Arbitration, appeals, federation
184
+ └── tests/ # Hermetic standalone Python and Node test suites
185
+ ├── test_{discovery,trust,comm,shield,matrix,settlement,governance}.py
186
+ ├── test_{envelope,counterparty,kya_gate,inbox_gate,plan_diff_gate}.py # ported contracts
187
+ ├── test_{classifier,intel,corpus_eval,settlement_policy,governance_gate,declaration,export}.py
188
+ └── test_ai_era_hardening.py # the five hardening rules
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 7. License
194
+
195
+ **Proprietary. All rights reserved.** Twin3 SDK is not open-source software. See [`LICENSE`](LICENSE) for the exact terms.
196
+
197
+ Distribution artifacts are published to public package registries so that anyone can install and evaluate the SDK and build against it — **open access is not open source**. Public availability grants no right to copy, modify, redistribute, fork, or create derivative works, and no patent or trademark licence. For commercial licensing or redistribution rights, contact core@twin3.ai.
@@ -0,0 +1,176 @@
1
+ # Twin3 SDK (`twin3-sdk`)
2
+ > **The Universal Capability Motherboard for Autonomous AI Agents & Self-Sovereign Humans**
3
+
4
+ [English](README.md) | [繁體中文](README_ZH.md) | [GitHub: twin3-team/twin3-sdk](https://github.com/twin3-team/twin3-sdk)
5
+
6
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://python.org)
7
+ [![Architecture: 7-Layer Symbiosis](https://img.shields.io/badge/Architecture-7--Layer%20Symbiosis-success.svg)](#the-seven-layer-symbiotic-architecture)
8
+ [![Dual-Projection](https://img.shields.io/badge/Dual--Use-Agent%20ID%20%7C%20Human%20ID-orange.svg)](#dual-application-projections)
9
+ [![Repo: twin3-team/twin3-sdk](https://img.shields.io/badge/GitHub-twin3--team%2Ftwin3--sdk-purple.svg)](https://github.com/twin3-team/twin3-sdk)
10
+
11
+ ---
12
+
13
+ ## 1. Overview & Vision
14
+
15
+ **Twin3 SDK** is a domain-agnostic, cryptographically secure foundational runtime designed to bridge autonomous AI agents and self-sovereign human individuals into a single symbiotic economic network.
16
+
17
+ As AI models evolve toward fully autonomous trading actors, the primary barrier to adoption is not intelligence, but **counterparty trust, deterministic authorization, cryptographic non-repudiation, and autonomous financial settlement**.
18
+
19
+ Twin3 SDK solves this by establishing a **Seven-Layer Symbiotic Architecture (L1 to L7)**. It serves as the universal hardware-like motherboard, while domain-specific applications plug into it as specialized software projections:
20
+ 1. **Agent ID (Enterprise Projection)**: Powers B2B autonomous commerce, procurement negotiation, and Dun & Bradstreet (D-U-N-S) enterprise identity verification across 20 commercial capabilities.
21
+ 2. **Human ID (Sovereign Projection)**: Protects 140,000+ real-world human identity assets, providing Passkey (WebAuthn) biometrics, personal sovereign cards, and paid anti-spam inboxes.
22
+
23
+ ---
24
+
25
+ ## 2. The Seven-Layer Symbiotic Architecture
26
+
27
+ Twin3 SDK organizes all distributed primitives into seven clean, composable layers:
28
+
29
+ ```
30
+ ┌─────────────────────────────────────────────────────────┐
31
+ │ Twin3 SDK Core Engine │
32
+ ├────┬───────────────────────┬────────────────────────────┤
33
+ │ L1 │ Discovery Layer │ twin3.discovery │
34
+ │ L2 │ Trust & Identity │ twin3.trust │
35
+ │ L3 │ Communication Layer │ twin3.comm │
36
+ │ L4 │ Shield & Guardrails │ twin3.shield │
37
+ │ L5 │ Matrix Understanding │ twin3.matrix │
38
+ │ L6 │ Clearing & Settlement │ twin3.settlement │
39
+ │ L7 │ Governance & Audit │ twin3.governance │
40
+ └────┴───────────────────────┴────────────────────────────┘
41
+ ▲ ▲
42
+ │ │
43
+ ┌────────────────────┴───────────┐ ┌────────────┴─────────────────┐
44
+ │ Agent ID (Enterprise) │ │ Human ID (Sovereign) │
45
+ ├────────────────────────────────┤ ├──────────────────────────────┤
46
+ │ • A2A 5-Stage Commercial Loop │ │ • Sovereign Identity Card │
47
+ │ • D-U-N-S Entity Verification │ │ • 140,000 Personality Vectors│
48
+ │ • Manufacturing Tolerance Match│ │ • Passkey WebAuthn Login │
49
+ │ • Corporate Multi-Sig Escrow │ │ • Paid Threshold Inbox │
50
+ └────────────────────────────────┘ └──────────────────────────────┘
51
+ ```
52
+
53
+ ### Layer Breakdown
54
+
55
+ | Layer | Module Path | Purpose | Key Primitives & Protocols |
56
+ | :--- | :--- | :--- | :--- |
57
+ | **L1 Discovery** | `twin3.discovery` | Agent Card & Sovereign Card specifications, public inbox declaration, in-memory registry. | `AgentCard`, `SovereignCard`, `build_declaration`, `DiscoveryRegistry` |
58
+ | **L2 Trust** | `twin3.trust` | Cryptographic identity handshake, public/private key verification, authority anchoring. | `create_challenge` / `complete_challenge` / `verify_binding`, `PasskeyAdapter`, `AuthorityAnchor`, `resolve_did_web`, nonce and sign-count stores |
59
+ | **L3 Communication** | `twin3.comm` | Non-repudiable message packaging, counterparty attention ladder, task inbox. | `build_envelope` / `validate_envelope` (Ed25519), `CounterpartyTable`, `TaskInbox`, owner access grants |
60
+ | **L4 Shield** | `twin3.shield` | Differential tampering defense, prompt injection filtering, and authorization guardrails. | `scan_text` / `scan_envelope` (T0–T3), `IntelEngine` (T1), `Ensemble` (T4), `diff_plans` / `authorize_execution` (T5), `MemoryGuard` |
61
+ | **L5 Matrix** | `twin3.matrix` | High-density vector space topological mapping and semantic cosine matching. | `DenseVector256`, `feature_distance`, `HumanMatrixSchema`, `EnterpriseMatrixSchema` |
62
+ | **L6 Settlement** | `twin3.settlement` | Signed-receipt verification for HTTP 402 gates, with externally supplied chain-finality and replay controls. | `PaymentDemand`, `PaymentReceipt`, `X402SettlementEngine` |
63
+ | **L7 Governance** | `twin3.governance` | Immutable evidence trail, appeals, advisory reputation federation, provisional arbitration helper. | `EvidenceTrail`, `open_appeal` / `resolve_appeal`, `export_reputation` / `import_reputation`, `ArbitrationEngine` (experimental), `DisputeCase` (experimental) |
64
+
65
+ `(experimental)` marks a capability whose row in [`tests/capability-inventory.json`](tests/capability-inventory.json) is not yet `available`: it is importable today and its surface may still change. Everything unmarked is `available`. A name written `Class.method` is a method, not a module export. Every name in this table is checked against a real public export by [`tests/test_readme_capability_claims.py`](tests/test_readme_capability_claims.py).
66
+
67
+ ---
68
+
69
+ ## 3. Pull Request Lineage & Provenance
70
+
71
+ The primitives in `twin3-sdk` are extracted from the `twin3-team/agent-id` Inbox line (PRs #615–#642, merged 2026-09-03 → 2026-09-05; spec: `docs/architecture/inbox-module-spec.md` in that repo). What each layer inherited:
72
+
73
+ * **Envelope, KYA handshake, counterparty ladder** — `agent_id/inbox/{envelope,kya,counterparty}.py`: canonical-JSON signed envelopes with `authority:"none"`, the mutual Ed25519 challenge that binds a declared identity to a key, and the G0→G3 attention ladder keyed on the counterparty rather than the request.
74
+ * **Task inbox and state machine** — `agent_id/inbox/state.py`: intake gate, review gate, rate limits, stale expiry, hash-chained audit.
75
+ * **Shield T0–T5** — `agent_id/inbox/{shield,intel,classifier,plandiff,corpus}.py`: deterministic layers, URL/domain/hash intelligence, the T4 ensemble, plan diffing, and the corpus that publishes error rates.
76
+ * **Settlement policy** — `agent_id/inbox/payments.py`: owner policy, signed quotes and receipts behind HTTP 402.
77
+ * **Governance** — `agent_id/inbox/governance.py`: appeals, pardons, advisory reputation federation.
78
+ * **Canonical Matrix Core**: High-density 256-Byte vector topological clustering powering 140k natural human personality profiles and industrial tolerance matching.
79
+
80
+ The 2026-09-05 sync also adds the **AI-era hardening** (mandatory T5, identity-cost tier caps, provenance-gated memory, rotation demotes, paid ≠ authorized). See `CHANGELOG.md`.
81
+
82
+ ---
83
+
84
+ ## 4. Package Distribution & Integration Model
85
+
86
+ ### Why Not File Copying?
87
+ Copying code (`vendoring`) causes **protocol drift** where Agent ID and Human ID implementations diverge within weeks, breaking cross-network signature validation.
88
+
89
+ ### Why Not Pure HTTP Microservices?
90
+ Cryptographic signatures (ECDSA/Ed25519) and 256-bit vector operations execute in under 0.2 milliseconds locally. Routing them through remote HTTP hops adds unnecessary latency and exposes private signing keys to network attack vectors.
91
+
92
+ ### The Standard Solution: Semantic Package Dependencies
93
+ Twin3 SDK follows standard modern packaging conventions (`pyproject.toml` / `npm`). Production consumers must use immutable registry artifacts and exact version pins; local links are development-only.
94
+
95
+ #### 1. Development Mode (Local Symlink / Editable Install)
96
+ During local development, both `agent-id` and `XHuman_ID` link directly to the local SDK workspace:
97
+ ```bash
98
+ # In agent-id or XHuman_ID virtual environment:
99
+ pip install -e /path/to/twin3-sdk
100
+ ```
101
+ **Benefits**:
102
+ * Zero code duplication.
103
+ * Any protocol or algorithm improvement in `twin3-sdk` is reflected in both applications in **0 milliseconds**.
104
+
105
+ #### 2. Production Distribution
106
+ The next release candidate is `0.2.10-pre-alpha` for npm and `0.2.10a0` for Python. It is not a production dependency until the GitHub release workflows have built, attested, rehearsed, and published the exact tagged artifacts. Consumers must then pin the exact released version and lock its registry integrity; never use a mutable range for a cryptographic protocol dependency. This candidate stays pre-alpha. Marketplace or sales copy may offer it for evaluation; it is not a stable release, and the npm dist-tag is `next`, not `latest`.
107
+
108
+ `package.json` `engines` sets Node.js to `>=18` and does not set an npm engine. Any npm that can install a tarball can consume the package. Packing this repository was checked with npm 10 or newer; the stricter npm version in the release runbook applies only to Trusted Publishing.
109
+
110
+ After the release workflow has published that exact version, install the pin. These commands are not evidence that the registry already serves the package:
111
+
112
+ ```bash
113
+ npm install twin3-sdk@0.2.10-pre-alpha
114
+ pip install twin3-sdk==0.2.10a0
115
+ ```
116
+
117
+ Until publication, evaluate the packed npm tarball only. Do not install from a git URL or a version range:
118
+
119
+ ```bash
120
+ npm pack --ignore-scripts
121
+ npm install ./twin3-sdk-0.2.10-pre-alpha.tgz
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 5. Dual-Application Projections
127
+
128
+ ### 🏢 Agent ID (Enterprise Commerce Projection)
129
+ Agent ID consumes Twin3 SDK to execute the **5-Stage A2A Autonomous Commercial Loop**:
130
+ 1. **Discovery**: Queries `twin3.discovery` for available suppliers and verified agent cards.
131
+ 2. **Understand**: Uses `twin3.matrix` to compute tolerance matching against industrial RFQs.
132
+ 3. **Negotiate**: Uses `twin3.comm` and `twin3.shield` to exchange signed quotes without prompt-tampering risks.
133
+ 4. **Settle**: Uses the Twin3 signed-receipt adapter at an HTTP 402 gate. Acceptance additionally requires a trusted signer key, a chain-specific finality verifier, and a shared replay store.
134
+ 5. **Dispute**: Invokes `twin3.governance` to resolve contractual non-performance.
135
+
136
+ ### 👤 Human ID (Personal Sovereignty Projection)
137
+ Human ID consumes Twin3 SDK to empower natural individuals:
138
+ 1. **140,000 Real Personality Assets**: Computes high-density personality matching via `twin3.matrix` without risking underlying database schemas.
139
+ 2. **Passkey WebAuthn Login**: Binds biometric secure enclaves to decentralized keys via `twin3.trust`.
140
+ 3. **Paid Inbox**: Protects individual inboxes against spam using `twin3.comm` and the signed-receipt adapter ($5 paywall threshold); the application supplies chain verification and shared replay state.
141
+ 4. **Sovereign Card**: Renders non-custodial credentials using `twin3.discovery`.
142
+
143
+ ---
144
+
145
+ ## 6. Directory Structure
146
+
147
+ ```
148
+ twin3-sdk/
149
+ ├── pyproject.toml # Standard packaging definition (PEP 621)
150
+ ├── README.md # Canonical English manual
151
+ ├── LICENSE # Proprietary licence, all rights reserved
152
+ ├── js/index.js # Node runtime; js/comm/counterparty.js = Inbox line, counterparty side
153
+ ├── twin3/ # Core SDK namespace
154
+ │ ├── __init__.py
155
+ │ ├── _compat.py # One import surface mirroring agent_id.inbox
156
+ │ ├── discovery/ # L1: Cards, Endpoints, agents.json, public inbox declaration
157
+ │ ├── trust/ # L2: KYA Handshake, did:web, Passkey Adapter
158
+ │ ├── comm/ # L3: Envelope, Counterparty Table, TaskInbox, export, client (counterparty side)
159
+ │ ├── shield/ # L4: T0–T3 defense, T1 intel, T4 classifier, T5 plan diff, corpus, memory gate
160
+ │ ├── matrix/ # L5: 256-Byte Vector Topology Engine
161
+ │ ├── settlement/ # L6: HTTP 402 Micropayments, owner policy, quotes, receipts
162
+ │ └── governance/ # L7: Evidence Trail, Arbitration, appeals, federation
163
+ └── tests/ # Hermetic standalone Python and Node test suites
164
+ ├── test_{discovery,trust,comm,shield,matrix,settlement,governance}.py
165
+ ├── test_{envelope,counterparty,kya_gate,inbox_gate,plan_diff_gate}.py # ported contracts
166
+ ├── test_{classifier,intel,corpus_eval,settlement_policy,governance_gate,declaration,export}.py
167
+ └── test_ai_era_hardening.py # the five hardening rules
168
+ ```
169
+
170
+ ---
171
+
172
+ ## 7. License
173
+
174
+ **Proprietary. All rights reserved.** Twin3 SDK is not open-source software. See [`LICENSE`](LICENSE) for the exact terms.
175
+
176
+ Distribution artifacts are published to public package registries so that anyone can install and evaluate the SDK and build against it — **open access is not open source**. Public availability grants no right to copy, modify, redistribute, fork, or create derivative works, and no patent or trademark licence. For commercial licensing or redistribution rights, contact core@twin3.ai.
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["setuptools==80.9.0", "wheel==0.45.1"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "twin3-sdk"
7
+ version = "0.2.10a0"
8
+ description = "The Universal Capability Motherboard for Autonomous AI Agents and Self-Sovereign Humans"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "LicenseRef-Twin3-Proprietary"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "Twin3 AI Limited", email = "core@twin3.ai" }
15
+ ]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Operating System :: OS Independent",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ "Topic :: Security :: Cryptography",
21
+ ]
22
+ dependencies = [
23
+ "cryptography>=42.0.0",
24
+ ]
25
+
26
+ [project.scripts]
27
+ twin3 = "twin3.cli:main"
28
+
29
+ [project.optional-dependencies]
30
+ dev = [
31
+ "pytest>=8.0.0",
32
+ ]
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["."]
36
+ include = ["twin3*"]
37
+ exclude = ["tests*"]
38
+
39
+ [tool.setuptools]
40
+ include-package-data = false
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/twin3-team/twin3-sdk"
44
+ Repository = "https://github.com/twin3-team/twin3-sdk.git"
45
+ Documentation = "https://github.com/twin3-team/twin3-sdk/blob/main/README.md"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,40 @@
1
+ """Twin3 SDK — The Universal Capability Motherboard for AI Agents & Sovereign Humans.
2
+
3
+ Seven-Layer Symbiotic Architecture:
4
+ - L1: twin3.discovery (Twin3AgentCard, SovereignCard, declaration, signed descriptors, catalog, adapters)
5
+ - L2: twin3.trust (KYA Handshake, Passkey Binding, Ed25519)
6
+ - L3: twin3.comm (HMAC/ECDSA Envelope, Counterparty Table)
7
+ - L4: twin3.shield (T0-T5 Deterministic Defense, Plan Diff)
8
+ - L5: twin3.matrix (256-Byte Vector Topology, Cosine Distance)
9
+ - L6: twin3.settlement (HTTP 402 Micropayments, Clearing Protocol)
10
+ - L7: twin3.governance (Evidence Trail, Dispute Arbitration)
11
+ """
12
+
13
+ __version__ = "0.2.10a0"
14
+ __author__ = "Twin3 AI Limited"
15
+
16
+ from . import jcs
17
+ from . import discovery
18
+ from . import trust
19
+ from . import comm
20
+ from . import shield
21
+ from . import matrix
22
+ from . import settlement
23
+ from . import governance
24
+
25
+ inbox = comm
26
+ action = governance
27
+
28
+ __all__ = [
29
+ "__version__",
30
+ "jcs",
31
+ "discovery",
32
+ "trust",
33
+ "comm",
34
+ "inbox",
35
+ "shield",
36
+ "matrix",
37
+ "action",
38
+ "settlement",
39
+ "governance",
40
+ ]
@@ -0,0 +1,25 @@
1
+ """twin3._compat: one import surface for the Inbox line, mirroring agent_id.inbox.
2
+
3
+ Applications that were written against agent_id.inbox can switch with a
4
+ single import change. New code should import from the layer modules."""
5
+ from twin3.comm.counterparty import * # noqa: F401,F403
6
+ from twin3.comm.counterparty import CounterpartyTable, IdentityRequired, TierTransitionError, counterparty_key, decay_reputation, FREEZE_STRIKES, REPUTATION_HALF_LIFE_SECONDS # noqa: F401
7
+ from twin3.comm.envelope import * # noqa: F401,F403
8
+ from twin3.comm.envelope import build_envelope, envelope_digest, validate_envelope, EnvelopeLimits, EnvelopeRejected, ENVELOPE_SCHEMA # noqa: F401
9
+ from twin3.comm.inbox import * # noqa: F401,F403
10
+ from twin3.comm.inbox import TaskInbox, IntakeRejected, TransitionError, STATES, TRANSITIONS # noqa: F401
11
+ from twin3.comm.export import EXPORT_SCHEMA, export_task # noqa: F401
12
+ from twin3.trust.kya import * # noqa: F401,F403
13
+ from twin3.trust.kya import HandshakeError, create_challenge, complete_challenge, challenge_signature_payload, verify_owner_signature, sign_envelope, verify_envelope_signature, load_public_key, load_private_key, export_public_key, key_id, CHALLENGE_SCHEMA # noqa: F401
14
+ from twin3.trust.didweb import DidResolutionError, did_web_for_host, did_web_url, resolve_did_web # noqa: F401
15
+ from twin3.shield.defense import SHIELD_SCHEMA, ShieldVerdict, scan_text, scan_envelope # noqa: F401
16
+ from twin3.shield.plan_diff import AUTHORIZED_BY_KIND, PLANDIFF_SCHEMA, PlanDiffError, diff_plans, normalize_action, PlanDiffGuard, authorize_execution # noqa: F401
17
+ from twin3.shield.classifier import T4_SCHEMA, CallableClassifier, ClassifierUnavailable, Ensemble, HeuristicClassifier, HuggingFaceClassifier, ScamHeuristicClassifier, Score, default_ensemble # noqa: F401
18
+ from twin3.shield.intel import INTEL_SCHEMA, CallableFeed, FeedUnavailable, IntelEngine, LocalBlocklist, RdapDomainAge, URLhausFeed, YaraScanner, extract_domains, extract_urls, is_idn_homograph, registrable, typosquat_match # noqa: F401
19
+ from twin3.shield.corpus import CORPUS_SCHEMA, EVAL_SCHEMA, CorpusError, ShieldScorer, evaluate, gate, load_corpus, load_shard, validate_sample # noqa: F401
20
+ from twin3.shield.corpus_seed import SEED # noqa: F401
21
+ from twin3.shield.memory import MEMORY_SCHEMA, MemoryGuard, MemoryRejected # noqa: F401
22
+ from twin3.settlement.policy import DEFAULT_POLICY, POLICY_SCHEMA, QUOTE_SCHEMA, RECEIPT_SCHEMA, PaymentError, issue_receipt, normalize_policy, quote, verify_receipt # noqa: F401
23
+ from twin3.settlement.x402 import X402_DEMAND_SCHEMA, X402_RECEIPT_SCHEMA, REPLAY_RESERVATION_SECONDS, REPLAY_FINAL_EXPIRY, SettlementError, PaymentDemand, PaymentReceipt, ChainPaymentEvidence, ChainPaymentVerifier, X402SettlementEngine # noqa: F401
24
+ from twin3.governance.federation import APPEAL_SCHEMA, BUNDLE_SCHEMA, GovernanceError, export_reputation, import_reputation, list_appeals, open_appeal, resolve_appeal # noqa: F401
25
+ from twin3.discovery.declaration import DECLARATION_SCHEMA, build_declaration, can_stranger_decide # noqa: F401