Skip to main content

sameAs identity linking

Version: V2
View Markdown

Time: 15 minutes · Steps: 3

What you'll build​

Review three candidates for an archived recording. One carries the same recording identifier, one is a review article, and one has only a matching title. The result is an offline plan containing a directed sameAs triple for the approved pair and a reason for each skipped candidate.

Prompt for your agentRun the sameAs review on your own records
Goal: run the sameAs review from this example on my own records.
Read https://docs.intuition.systems/docs/examples/identity-linking.md and https://docs.intuition.systems/docs/build/link-identities.md.
Use exact package versions from https://docs.intuition.systems/intuition-release.json and public entry points only.
Input: [one archived record and its candidate atoms, with their exact bytes].
Preserve the historical bytes. For each candidate, record the evidence and approve or skip it with a reason. A matching title alone is not enough.
Output an offline plan with the directed sameAs triple for each approved pair.
Do not create triples 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​

Use Node.js 22.21.0. From the documentation repository root at the revision in Full source, install the example workspace once. npm needs registry access for installation. The runner uses only local data.

cd examples/v2
npm ci --ignore-scripts

Read sameAs and identity linking for the meaning of the claim. See Install the packages for the pinned packages. All catalog evidence below is synthetic.

Steps​

1. Preserve the historical atom bytes​

The archive contains an exact UTF-8 JSON string with a reference URL in its sameAs property. The newer recording anchor contains a bare IID. The fixtures call stringToHex on each original text string. Parsing and serializing the JSON again could change the bytes used to identify that atom. UTF-8 text such as 0x6162 encodes as 0x307836313632. If your catalog already stores binary bytes in hex, supply them directly. The two bytes 0x6162 identify a different atom.

import { stringToHex } from 'viem';

const recordingIid = 'int:isrc:USRC12600001';
export const archive = {
level: 'recording' as const,
atomData: stringToHex(
'{"name":"Paper Moon Demo","sameAs":["https://example.org/recordings/17"]}',
),
recordingIid,
};

export const candidates = {
anchor: {
level: 'recording',
atomData: stringToHex(recordingIid),
recordingIid,
},
review: {
level: 'article',
atomData: stringToHex('Review of Paper Moon Demo'),
recordingIid,
},
namesake: {
level: 'recording',
atomData: stringToHex('{"name":"Paper Moon Demo"}'),
},
} as const;

The URL inside the JSON is part of the archived payload. A graph edge requires a separate predicate atom and two term IDs. Keep the recording-level evidence beside the original data while reviewing candidates.

2. Record each decision and its evidence​

The fixture editor compared the two catalog records and confirmed the same take and recording code. The critic’s article cites the recording but describes a different entity. The namesake has no recording identifier to distinguish it from a different take.

  const recording = {
candidate: 'anchor' as const,
evidence:
'The two catalog records credit the same take and list the same recording code.',
};
const accepted = reviewLink({ ...recording, approved: true });
const waiting = reviewLink({ ...recording, approved: false });
const article = reviewLink({
candidate: 'review',
approved: false,
evidence: 'The critic cites the recording in a review.',
});
const namesake = reviewLink({
candidate: 'namesake',
approved: false,
evidence: 'Only the title matches.',
});

The second call for the same recording pair exercises the pending case. A matching identifier supplies evidence. The reviewer supplies approval. This example assigns no confidence score.

3. Plan the ordered claim​

The review wrapper requires an evidence note and passes the archived bytes, candidate, and explicit decision to planLink.

type Decision = {
candidate: keyof typeof candidates;
approved: boolean;
evidence: string;
};

export function reviewLink({ candidate, approved, evidence }: Decision) {
if (!evidence.trim())
return { candidate, reason: 'Record the evidence for review.' };
const result = planLink(archive, candidates[candidate], approved);
return { candidate, evidence, ...result };
}

The link planner checks the entity level, inspects both IIDs, and requires matching canonical ISRC identifiers for this fixture. After approval it derives each atom ID from the original payload, rejects identical term IDs, and builds the ordered sameAs triple. Both original atoms keep their IDs and bytes. This local plan makes no changes to either record and submits no transaction.

Run it​

From examples/v2, run the TypeScript entrypoint.

node identity-linking/src/run-linking.ts
Subject 0x70e43f5beab9b630229717d40da0874927cd3cf2a4d9f34979e4e88abb60b4ab
sameAs 0x1908b7994ca437c84c67a4799ae710355591790a726bf5890277f3aa70828c0a
Object 0xfdbf117d9e9df5675c5b4f75747598424fc9beb2d2a50e20408f4cd4dfb3d4ed
Triple 0xc40d319e82c15a049aa3688e2a4cc0fbc51441f05311ad403beaba3382496ef1
anchor Awaiting review
review Different entity level
namesake Missing recording identifier

The subject is the archived JSON atom. The object is the bare recording IID atom. The middle ID belongs to the registry’s sameAs predicate. The fourth ID identifies the proposed edge itself.

Full source​

Review fixtures, link planner, and runner. The canonical equivalence discussion describes the role of reviewed claims. Compare the package’s identity example, review interface, IID inspection, and triple builder.

Next steps​

Use Derive IDs to trace a single recording from identifier to term ID, or follow the music catalog tutorial to model artist and album relationships.

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