@agenticprimitives/agent-relationships 0.1.0-alpha.2

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agentic Trust Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # @agenticprimitives/agent-relationships
2
+
3
+ > ⚠️ **Experimental — do NOT use for confidential edges.**
4
+ >
5
+ > This package writes the trust-fabric edge graph **publicly on-chain**.
6
+ > Every edge — its endpoints, type, role set, and status — is visible to
7
+ > anyone reading the chain, forever. There is no on-chain confidentiality
8
+ > for the **fact that an edge exists**.
9
+ >
10
+ > That means this package is **structurally incompatible** with use-cases
11
+ > that bring a confidentiality requirement: financial counterparty graphs,
12
+ > medical referral networks, B2B partnership relationships under NDA,
13
+ > family/household membership, or any "who is connected to whom" graph
14
+ > where the connection itself is the secret. The `metadata-hash` field
15
+ > anchors off-chain JSON but cannot hide the existence of the edge or
16
+ > the identity of its endpoints.
17
+ >
18
+ > Concrete public exposure per edge: `subject` address, `object` address,
19
+ > `relationshipType` (e.g. `HAS_MEMBER`, `HAS_GOVERNANCE_OVER`), role set
20
+ > on each side, `EdgeStatus` lifecycle (proposed/confirmed/active/revoked),
21
+ > and the actor address that submitted each state transition.
22
+ >
23
+ > A future v2 private-edge variant (commitment-based, with
24
+ > selective-disclosure proofs) will live alongside this package. Until it
25
+ > ships, **adopters requiring confidentiality should not use this
26
+ > package** and should hold their relationship graph in an off-chain
27
+ > store with explicit access control.
28
+ >
29
+ > Tracked as the **Privacy Fork** (audit `PKG-agent-relationships-001` /
30
+ > `EXT-019`). `capability.manifest.json` sets `"stability": "experimental"`.
31
+
32
+ Trust-fabric edge primitive for Smart Agents. An `Edge` is a
33
+ `(subject, object, relationshipType)` triple with a role set on each
34
+ side, a status lifecycle (`PROPOSED → CONFIRMED → ACTIVE → REVOKED`),
35
+ and optional off-chain metadata anchored by a deterministic
36
+ content-hash.
37
+
38
+ Where [`agent-naming`](../agent-naming) resolves *names → addresses*
39
+ and [`agent-profile`](../agent-profile) owns the *profile layer*,
40
+ this package owns the **relationship layer**: the on-chain graph of
41
+ who-knows-whom that other layers compose against (org membership,
42
+ governance assertions, validation trust, etc.).
43
+
44
+ > **Layer:** Discover — the trust **graph** (not canonical identity — that is `agent-account`).
45
+ > **Canonical key:** Smart Agent addresses. An edge connects anchors; an edge is **not** a delegation.
46
+
47
+ ## Status
48
+
49
+ **Phase 1** — pure SDK + spec + API skeleton. Read methods on the
50
+ client throw `R Phase 2`; write methods throw `R Phase 4`. Contracts
51
+ (`AgentRelationship.sol` + `RelationshipTypeRegistry.sol`) land in
52
+ Phase 3. `AgentAssertion` (signed-claim layer) and
53
+ `AgentRelationshipResolver` (policy layer) are **deferred to v2** per
54
+ ADR-0007.
55
+
56
+ See [`specs/216-agent-relationships.md`](../../specs/216-agent-relationships.md)
57
+ for the full design + the phase plan, and:
58
+
59
+ - [ADR-0006](../../docs/architecture/decisions/0006-agent-naming-as-resolution-layer.md)
60
+ — why naming hierarchy is parent-pointer-based, NOT a
61
+ `NAMESPACE_CONTAINS` edge.
62
+ - [ADR-0007](../../docs/architecture/decisions/0007-agent-identity-stack-three-packages.md)
63
+ — why the identity stack is three packages, not one.
64
+
65
+ ## Install
66
+
67
+ This package is workspace-internal in the agenticprimitives monorepo
68
+ and not yet published.
69
+
70
+ ## Usage
71
+
72
+ ### Edge-ID derivation (pure)
73
+
74
+ ```ts
75
+ import {
76
+ computeEdgeId,
77
+ RELATIONSHIP_TYPE,
78
+ } from '@agenticprimitives/agent-relationships';
79
+
80
+ const id = computeEdgeId(
81
+ '0x1111…1111', // subject
82
+ '0x2222…2222', // object
83
+ RELATIONSHIP_TYPE.HAS_MEMBER, // type (bytes32 hash)
84
+ );
85
+ // 0x… — keccak256 of packed (subject || object || typeId)
86
+ ```
87
+
88
+ Same triple → same edge ID. Direction matters for non-symmetric types
89
+ (`HAS_MEMBER(A→B)` ≠ `HAS_MEMBER(B→A)`).
90
+
91
+ ### Relationship type + role taxonomy
92
+
93
+ ```ts
94
+ import {
95
+ RELATIONSHIP_TYPE,
96
+ ROLE,
97
+ TYPE_SEMANTICS,
98
+ } from '@agenticprimitives/agent-relationships/taxonomy';
99
+
100
+ RELATIONSHIP_TYPE.HAS_MEMBER; // bytes32 — keccak256("HAS_MEMBER")
101
+ RELATIONSHIP_TYPE.PARTNERSHIP; // bytes32 — symmetric
102
+ RELATIONSHIP_TYPE.HAS_GOVERNANCE_OVER; // bytes32 — hierarchical
103
+
104
+ ROLE.BOARD_MEMBER; // bytes32 — keccak256("BOARD_MEMBER")
105
+ ROLE.TREASURER; // bytes32
106
+
107
+ TYPE_SEMANTICS[RELATIONSHIP_TYPE.PARTNERSHIP].symmetric; // true
108
+ TYPE_SEMANTICS[RELATIONSHIP_TYPE.HAS_GOVERNANCE_OVER].hierarchical; // true
109
+ ```
110
+
111
+ `NAMESPACE_CONTAINS` is **intentionally absent** — naming hierarchy
112
+ lives in [`agent-naming`](../agent-naming) via parent-pointer per
113
+ ADR-0006.
114
+
115
+ ### Relationships client (Phase 2+)
116
+
117
+ ```ts
118
+ import {
119
+ AgentRelationshipsClient,
120
+ RELATIONSHIP_TYPE,
121
+ ROLE,
122
+ } from '@agenticprimitives/agent-relationships';
123
+
124
+ const rel = new AgentRelationshipsClient({
125
+ rpcUrl: 'https://base-sepolia.g.alchemy.com/v2/…',
126
+ chainId: 84532,
127
+ });
128
+
129
+ // Read (Phase 2+)
130
+ const edges = await rel.listEdgesFor('0x…', { relationshipType: RELATIONSHIP_TYPE.HAS_MEMBER });
131
+
132
+ // Write (Phase 4+)
133
+ await rel.proposeEdge({
134
+ subject: '0xAlice…',
135
+ object: '0xAcme…',
136
+ relationshipType: RELATIONSHIP_TYPE.HAS_MEMBER,
137
+ subjectRoles: [ROLE.BOARD_MEMBER],
138
+ });
139
+ await rel.confirmEdge({ edgeId: '0x…', selfRoles: [] });
140
+ ```
141
+
142
+ Each write is authorized via the actor's Smart Agent ERC-1271 →
143
+ its CustodyPolicy module. The relationships package itself stays
144
+ custody-agnostic (no `@agenticprimitives/account-custody` import).
145
+
146
+ ## Subpath exports
147
+
148
+ - `@agenticprimitives/agent-relationships/taxonomy` —
149
+ relationship-type + role constants + semantics map.
150
+
151
+ ## Security invariants
152
+
153
+ - Edge ID is **deterministic** —
154
+ `keccak256(subject || object || relationshipType)`. Off-chain and
155
+ on-chain derivations always match.
156
+ - `computeEdgeId` refuses self-edges (subject === object).
157
+ - Relationship-type + role IDs are `keccak256(name)` (matches
158
+ Solidity `keccak256(bytes(name))`).
159
+ - Two-side confirmation for non-symmetric types (Phase 3+ contract
160
+ enforcement).
161
+ - Permissionless revocation from either side (Phase 3+).
162
+ - Custody-agnostic — authority always routes through the actor's
163
+ Smart Agent ERC-1271.
164
+ - `NAMESPACE_CONTAINS` is intentionally absent (ADR-0006).
165
+
166
+ See `AUDIT.md` for the package audit + open findings.
167
+
168
+ ## License
169
+
170
+ UNLICENSED (internal monorepo, not published).