Y2 Elite workspaces are rolling out for teams
Y2Y2Docs
Ontology & Fusion

Tutorial: Read a Company Ledger

Check a supplied example, inspect its supplier claim, and produce a STIX bundle locally.

This lesson uses the repository's fictional company ledger. You will check its records, inspect a supplier claim, and produce a STIX bundle. The commands run locally and do not require a Y2 account or API key.

Before you begin

You need a checkout of the Y2 platform repository, Bun, and jq. Run each command from the repository root in the same shell. The fixture is already supplied in packages/ontology/v0/examples. Its companies, identifiers, and source URLs are fictional.

Check the supplied ledger

Set the fixture path:

ledger_fixture=packages/ontology/v0/examples/fictional-cyber-market.ndjson

Run the checker:

bun packages/ontology/src/cli.ts check "$ledger_fixture"

Expected output:

packages/ontology/v0/examples/fictional-cyber-market.ndjson: ok (22 lines)

The checker accepts all 22 records, their hashes, and their chain links.

Read the current claims

A fold computes the current view from the recorded claims. Run this command to count the subjects and claims:

bun packages/ontology/src/cli.ts fold "$ledger_fixture" \
  | jq '{subjects: [.subjects[].subject.id], claims: (.claims | length)}'

Expected output:

{
  "subjects": ["sbj_issuer", "sbj_supplier", "sbj_portal"],
  "claims": 9
}

The subjects represent the company, its supplier, and its portal.

Inspect the supplier claim

Select the claim with the supplies predicate:

bun packages/ontology/src/cli.ts fold "$ledger_fixture" \
  | jq '.claims[] | select(.predicate == "supplies") | {from, to, verification, evidence_refs}'

Expected output:

{
  "from": "sbj_supplier",
  "to": "sbj_issuer",
  "verification": "located",
  "evidence_refs": ["obv_filing"]
}

The direction runs from the supplier to the company. The claim cites obv_filing as its evidence. Its located state means that a retrieved page supports the link.

Produce the STIX relationship

Project the ledger to STIX 2.1:

bun packages/ontology/src/cli.ts stix "$ledger_fixture" --scope tutorial \
  | jq '.objects[] | select(.type == "relationship" and .relationship_type == "supplies") | {relationship_type, confidence}'

Expected output:

{
  "relationship_type": "supplies",
  "confidence": 70
}

The STIX relationship preserves the supplier predicate and the claim's confidence. The export does not add new evidence.

Continue with your own research