# references.resolve

Resolve a stable record reference using current target-ledger read permission.

Capability: op_sys_references_resolve
Protocol: op-sys.capabilities.v1
Runtime: 0.3.0
Availability: Local or hosted ledger operations
Optional integration: false
Canonical page: /docs/reference/op_sys_references_resolve

## Authority

File upload requires files.upload; metadata and byte reads require files.read. Attaching a file requires records.append and files.read. Erasure requires files.erase and the current ledger revision; hosted legal holds, credential scopes and raw-data policy remain upper bounds.

## Invocation

CLI, SDK and MCP use the same operation and arguments; where a hosted HTTP binding exists, its route carries the same domain contract. Host paths and environment references refer to the runtime host. Request template: replace placeholder IDs and supply complete contract-specific objects before use. This is not a complete runnable workflow.

### CLI

```sh
op-sys --output json tools call op_sys_references_resolve \
  --arguments '{"reference":{"ledger_id":"<ledger_id>","record_id":"<record_id>"}}'
```

### Python SDK

```python
import json
from op_sys import OpSys

client = OpSys()
arguments = json.loads("{\"reference\":{\"ledger_id\":\"<ledger_id>\",\"record_id\":\"<record_id>\"}}")
result = client.capabilities.call(
    "op_sys_references_resolve", arguments
)
print(result)
```

### MCP (initialized connection)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "op_sys_references_resolve",
    "arguments": {
      "reference": {
        "ledger_id": "<ledger_id>",
        "record_id": "<record_id>"
      }
    }
  }
}
```

### HTTP

```sh
curl --fail-with-body --request POST "$VEYLAR_ENDPOINT/v1/references/resolve" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "X-Veylar-Tenant: $TENANT_ID" \
  -H 'Content-Type: application/json' \
  --data '{"reference":{"ledger_id":"<ledger_id>","record_id":"<record_id>"}}'
```

Named CLI command: op-sys references resolve (use --help for flags).

SDK convenience: client.references.resolve(…). The capability adapter may wrap the result.

## Parameters

### reference

Required; object. Operation-specific reference. Record references identify ledger_id and record_id; immutable contract references identify contract_id, version and digest.


```json
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "ledger_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "record_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    }
  },
  "required": [
    "ledger_id",
    "record_id"
  ]
}
```


### Complete input schema

```json
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "reference": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ledger_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "record_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        }
      },
      "required": [
        "ledger_id",
        "record_id"
      ]
    }
  },
  "required": [
    "reference"
  ]
}
```

## Behavior

- Retry: read_only. Concurrency: none.
- Required rights: target.records.read. Check discovery for environment availability and effective authorization.
- File identities bind immutable SHA-256, size and declared media type. A hash is not a grant or public download URL. Record references resolve only with target-ledger permission.
- Files are bounded to 1 GiB, decoded chunks to 1 MiB, and the permissive contract permits 16 attachments per record. Consumer contracts may impose tighter file rules.
- Retry identical chunks at the same offset under the original uploader. Changed bytes or metadata conflict. Complete integrity verification before attaching a file.
- Metadata distinguishes missing, partial, available and erased files. Erasure keeps an identity tombstone; retained attachments do not guarantee that bytes remain available.

## Response

Returns RecordResult. See the complete result schema below; transport envelopes are separate.

### Complete result JSON Schema

```json
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "record": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ledger_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "record_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "payload": {},
        "attachments": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "file_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              }
            },
            "required": [
              "file_id"
            ]
          },
          "maxItems": 16
        },
        "acceptance": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "record_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "operation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "contract": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "contract_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "version": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "digest": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "contract_id",
                "version",
                "digest"
              ]
            },
            "authority_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "authority_epoch": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "position": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "accepted_at": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "principal": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "issuer": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 2048
                },
                "subject": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                }
              },
              "required": [
                "issuer",
                "subject"
              ]
            },
            "trust": {
              "type": "string",
              "enum": [
                "local",
                "authenticated"
              ]
            }
          },
          "required": [
            "record_id",
            "operation_id",
            "contract",
            "authority_id",
            "authority_epoch",
            "position",
            "accepted_at",
            "principal",
            "trust"
          ]
        },
        "provenance": {
          "const": "imported-unverified"
        }
      },
      "required": [
        "ledger_id",
        "record_id",
        "payload",
        "attachments",
        "acceptance"
      ]
    },
    "observation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "source": {
          "type": "string",
          "enum": [
            "authority",
            "replica"
          ]
        },
        "authority_epoch": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "observed_at": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "coverage": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096
        },
        "complete": {
          "type": "boolean"
        },
        "provenance": {
          "const": "imported-unverified"
        }
      },
      "required": [
        "source",
        "authority_epoch",
        "observed_at",
        "coverage",
        "complete"
      ]
    }
  },
  "required": [
    "record",
    "observation"
  ]
}
```


[Runtime output field catalog](/docs/output-contracts.json) (descriptive contracts, not JSON Schema validators).

CLI: use --output json. For tools call, read the operation result at payload.tool.result; payload.tool.name identifies the capability. The outer envelope is {schema_version: "v1", payload: {tool: {name, result}}}.

Python: client.capabilities.call(name, arguments) returns the operation result. SDK exceptions preserve reason and code.

MCP: tools/call returns JSON text and structuredContent. Application failures set isError; inspect reason/code instead of matching message text.

Related resource schemas (not necessarily a complete operation response):
- [ledger-core.v1.schema.json](/docs/schemas/ledger-core.v1.schema.json)

## Errors and recovery

[Ledger limits and operation catalog](/docs/ledger-core.json)

Canonical operation: references.resolve

Permissions: target.records.read

Retry: read_only; concurrency: none

Codes: invalid_input, contract_invalid, payload_invalid, contract_not_admitted, permission_denied, not_found, revision_conflict, operation_conflict, unsupported, authority_unavailable, outcome_uncertain, outcome_expired, validation_context_unavailable, file_unavailable, integrity_failure, ledger_archived, ledger_deleted, resnapshot_required, identity_changed, authority_fenced, withdrawal_requires_resolution, limit_exceeded, rate_limited, record_erased, payment_required

[HTTP status mappings and schemas](/docs/ledger-core.openapi.json)

- file_unavailable: Inspect file availability and finish any partial upload before attaching or reading bytes.
- permission_denied: Check the specific file or target-record permission, credential scope and hosted raw-data policy.
- operation_conflict: Preserve the original file identity, metadata and chunk bytes; use a new ID for new content.
- integrity_failure: Verify declared size, SHA-256, base64 bytes and exact chunk offsets.
- revision_conflict: Read the current ledger revision and reconsider before erasure.
- legal_hold: The service hold prevents removal; do not bypass it.

Family reasons are representative, not exhaustive.

A timeout is not proof that a write failed. Reuse the documented retry identity, batch, offset or mutation ID. If this operation has no documented retry identity, inspect its state before repeating it.

On authorization failure, correct the configured identity or grants; do not change the local actor to impersonate a hosted principal. On validation failure, correct the input against the published schema and selected contract.

On a revision or state conflict, retrieve current state and reconcile intent. Do not automatically overwrite a competing update. Preserve unknown additive response fields when building consumers.

## Source manuals

- [ledger-files](/docs/raw/manuals/ledger-files.md)
- [ledger-lifecycle](/docs/raw/manuals/ledger-lifecycle.md)
- [public-capabilities](/docs/raw/manuals/public-capabilities.md)
- [command-output-schema](/docs/raw/manuals/command-output-schema.md)
