Skip to main content

Link identities with sameAs

Version: V2
View Markdown

Prepare a sameAs triple when two existing atoms refer to the same recording and a reviewer has checked the evidence.

Prompt for your agentReview the evidence and plan a sameAs claim
Goal: decide whether two atoms describe the same recording and, if they do, plan a sameAs claim.
Read https://docs.intuition.systems/docs/build/link-identities.md, https://docs.intuition.systems/docs/concepts/same-as.md and https://docs.intuition.systems/docs/identifier/entity-types.md.
Use exact package versions from https://docs.intuition.systems/intuition-release.json and public entry points only.
Input: the exact original bytes of both atoms and the source records behind them.
Compare entity level and identifiers, not titles alone. Record each piece of evidence and the decision.
If the evidence supports a link, output the planned sameAs triple with its IDs. Otherwise output the reason for not linking.
Preserve both original payloads and IDs. Never rebuild either atom under a new profile.
Do not create the triple or send transactions.
Report the checks you actually ran and anything you could not verify.

Paste this into your coding agent. It points the agent at the Markdown version of each page and leaves every signature to you.

Before you start​

Retain the exact original bytes for both atoms, their entity levels, and the source records used to identify them. Read sameAs and triples.

For your own project, follow Install the packages. To run the offline example, install its locked dependencies from the documentation repository root with Node.js 22.21.0.

npm ci --prefix examples/v2 --ignore-scripts

Steps​

1. Compare the two source records​

In the synthetic catalog, the older atom stores a JSON payload with a title and a catalog URL in its sameAs field. The newer atom stores the bare IID int:isrc:USRC17607839. The catalog editor has verified that both source entries describe the recording with that ISRC. The URL in the older payload is a reference the editor can inspect. Adding another URL would change those serialized bytes and produce a different atom ID.

2. Screen the candidates and record the review​

Check what each candidate identifies before comparing its identifiers. A review article can quote the exact ISRC while identifying a different entity. A second recording can share a title while carrying a different ISRC. Leave candidates with missing evidence for later review. This catalog requires a matching canonical ISRC and explicit approval for this particular workflow. Other domains need evidence appropriate to their entity level.

import type { Hex } from 'viem';
import { inspectIntuitionId } from '@0xintuition/iid';
import { calculateAtomId } from '@0xintuition/ids';
import { sameAsId } from '@0xintuition/predicates/sameAs';
import { buildTriple } from '@0xintuition/primitives/triple';

type CatalogRecord = {
atomData: Hex;
level: 'recording' | 'article';
recordingIid?: string;
};

export function planLink(
left: CatalogRecord,
right: CatalogRecord,
reviewerApproved: boolean,
) {
if (left.level !== 'recording' || right.level !== 'recording')
return { reason: 'Different entity level' };
if (!left.recordingIid || !right.recordingIid)
return { reason: 'Missing recording identifier' };
const a = inspectIntuitionId(left.recordingIid);
const b = inspectIntuitionId(right.recordingIid);
if (
!a.valid ||
!b.valid ||
a.scheme !== 'isrc' ||
b.scheme !== 'isrc' ||
a.iid !== b.iid
) {
return { reason: 'Recording identifiers do not match' };
}
if (!reviewerApproved) return { reason: 'Awaiting review' };
const subjectId = calculateAtomId(left.atomData);
const objectId = calculateAtomId(right.atomData);
if (subjectId === objectId) return { reason: 'Already the same atom' };
const claim = buildTriple(subjectId, 'sameAs', objectId);
if (!claim.success) throw new Error(claim.errors.join(', '));
return { claim: claim.value };
}

3. Review the edge before creating it​

Supply each original payload as hex-encoded bytes in atomData. For UTF-8 text, call stringToHex on the exact stored string, including any spaces. For example, the six literal characters 0x6162 encode as 0x307836313632. If the archive already gives the two binary bytes as 0x6162, pass that hex value directly. Compare the printed subject, predicate, and object IDs with the intended terms. The locally built triple is a proposal. To publish the reviewed edge, follow Create triples. Both original atom IDs continue to identify their respective payloads.

Check the result​

node examples/v2/identity-linking/src/link-identities.ts

The accepted fixture prints two distinct atom IDs and the claim ID 0x84c9260e71757e9c7d5e33fa8bd370a7794160910b8e59ced21cb4e27911402f. The article produces “Different entity level,” the title alone produces “Missing recording identifier,” and the second recording produces “Recording identifiers do not match.” A matching pair without approval remains “Awaiting review.”

Identity ladders, equivalence and candidate review, IID inspection, and triple blueprints.

Applies to V2 · @0xintuition/primitives 0.1.1 · @0xintuition/predicates 0.1.1 · @0xintuition/iid 0.1.1