# How ledgers work

Ledgers use the same operations through CLI, Python SDK, MCP and hosted
HTTP. The selected connection determines where an operation runs. Local CLI, SDK
and MCP calls run in process, without a server or startup network request. Hosted
calls go directly to the selected authority: no enrollment, replica or sync bundle
is required. Configuring a connection does not upload a local ledger.

This guide describes the ledger operations and their data contracts.
It includes [files and references](/docs/raw/manuals/ledger-files.md),
[lifecycle and erasure](/docs/raw/manuals/ledger-lifecycle.md), [clone and synchronization](/docs/raw/manuals/ledger-replicas.md),
[append and recovery](/docs/raw/manuals/ledger-contributions.md), [authority transfer](/docs/raw/manuals/ledger-authority.md)
and [export/import](/docs/raw/manuals/ledger-portability.md). Ledger operations use only the current
contract; superseded interfaces and formats are not translated. See
[installation](/docs/raw/manuals/installation.md) for setup requirements.

For an end-to-end introduction, follow [Start with a ledger](/docs/raw/manuals/ledger-quickstart.md).

## Start locally

```sh
op-sys --output json ledgers create --name example
# Copy the returned ledger_id; names are optional and may be duplicated.
op-sys selection update --connection local --ledger <ledger-id>
op-sys --output json records append --payload '{"message":"Hello"}'
op-sys --output json records list --limit 20
op-sys --output json ledgers inspect
```

Creation installs a bounded permissive contract and gives the creator ledger
administration rights in one transaction. Records are consumer-defined JSON;
there are no built-in task or research ledger types. Unknown selectors fail.
`--ledger-id` overrides the selected ledger for one operation. JSON arguments
accept inline JSON, `@path.json` or `-` for standard input.

## Use the same SDK operations locally or remotely

```python
from op_sys import OpSys

client = OpSys()  # Or OpSys(connection="work") for an authenticated service.
ledger = client.ledgers.create(name="example")
ledger_id = ledger["ledger_id"]
result = client.records.append(
    ledger_id=ledger_id, payload={"message": "Hello"},
    operation_id="example-first-contribution",
)
if result["state"] == "accepted":
    record = client.records.get(
        ledger_id=ledger_id, record_id=result["acceptance"]["record_id"]
    )
    print(record["record"]["payload"])
else:
    outcome = client.records.outcome(
        ledger_id=ledger_id, operation_id=result["operation_id"]
    )
```

See [connection configuration](/docs/raw/manuals/client-connections.md) for named connections,
identity association and editable remotes. Calls remain pinned to the initialized
connection and principal until explicitly reconfigured. A failed hosted call never
falls back to local storage. Independent authorized contributors do not need to
be account administrators or workspace members. Creating hosted ledgers requires
creation permission in the workspace.

## Invite a participant to a ledger

Use a ledger invitation to offer explicit permissions in one ledger. For
membership in a workspace, use a [workspace invitation](/docs/raw/manuals/team-onboarding.md).

```sh
op-sys --output json invitations create --ledger-id <ledger-id> \
  --permissions '["ledger.read","contracts.read","records.read","records.append"]'
```

For a local ledger, the same operation resolves its hosting destination and human
sign-in, publishes its retained history and files through protected authority
transfer, and then issues the invitation. Supply `--endpoint` for your already
running service if no destination is selected. First-time setup uses a personal
workspace; service enrollment policy still applies. Only the selected ledger is
shared. Other local ledgers remain local. Managed public enrollment remains
unavailable until the service operator enables it.

CLI JSON, SDK and MCP calls return bounded progress. Follow the indicated next
action until the invitation is `ready` and returns the link. If the hosted
workspace needs billing activation, its owner gets a link to that workspace's
setup page and can then resume the invitation.

The supplied clients generate and save an operation ID when you start a new
invitation. The interactive CLI reuses it through setup and publication. Use
`invitations status` to find a saved operation, then resume with its
returned ledger and operation ID. Automation can supply its own ID to track
retries. Recovery also uses the invitation secret saved in the issuing
client's state. Direct HTTP requests carry an explicit operation ID and token hash. Permissions may
be omitted when resuming a saved intent. Changed permissions, destination or
verified identity require resolving the original intent. Local grant mappings
may be needed before sharing.

The issuing client saves a private secret before sending only its hash to the
service. A single-use link stays open until an eligible signed-in recipient
successfully accepts it, the link expires, or an owner revokes it.
For open enrollment, set `--max-joins` to the number of signed-in recipients the
link may admit, up to 1,000. Each recipient explicitly accepts the invitation.
While places remain, use **Copy invitation link** on its web page to share the
same enrollment link. The issuing client can also recover the original link
using the same operation ID and inputs. The default lifetime is 24 hours,
configurable from 1 to 168 hours.
Ledger access limits still apply when someone joins.

To share a purpose and contribution examples before sign-in, supply `--preview
@preview.json`. The same `preview` input is available through SDK, MCP, and HTTP.
The preview is visible to anyone who receives the link while it is open. Choose
the text and examples you are comfortable sharing. Contribution examples identify
an admitted `contract_id` and `version`, and any example payload must satisfy that
version's schema. With `--append-contract-ids`, the issued grant can append under
the listed contract IDs. Other grants for the same account can independently
authorize additional contracts. Create the preview file below after admitting
the example contract, then issue the invitation.

```sh
op-sys invitations create --ledger-id <ledger-id> \
  --permissions '["ledger.read","contracts.read","records.append"]' \
  --append-contract-ids '["submission"]' --max-joins 50 --preview @preview.json
```

```json
{
  "title": "Coating research challenge",
  "purpose": "Compare measurements of protective coatings.",
  "acceptance_meaning": "An accepted entry satisfies our submission rules.",
  "contributions": [{
    "contract_id": "submission",
    "version": "1",
    "description": "Submit one measured observation.",
    "example": { "measurement": 12 }
  }]
}
```

`invitations inspect --invitation <private-url>` previews the offered access
without authentication or redemption. The recipient uses `invitations
accept --invitation <private-url>`; it resolves authentication on that service using the
recipient's own identity. Saved acceptance can resume by `--operation-id` without
passing the private link again. Each eligible authenticated recipient accepts a
ledger grant once per link. Repeating acceptance as that identity returns its
original receipt without consuming another place or restoring revoked access.
The acceptance response includes the available contribution brief, which the
CLI can display and the SDK, MCP, and API can read. Enrollment status and the
brief reflect current access and admitted contracts when the recipient retries.
The recipient can then inspect the current ledger rules and contribute through
the existing operations.
Successful invitation creation and acceptance select the hosted ledger for current
reads and writes. Seeing each other's accepted records requires no manual sync.
Replicas remain optional, and an outage never silently falls back to local writes.

The invitation web page shows the offered access and a sign-in or join action.
**What to contribute** shows the optional structured brief and its first example
record before and after acceptance. The page removes the fragment before sign-in
and preserves the intent in the current browser tab. The address bar therefore
holds an incomplete link: use **Copy invitation link** to open the invitation in
another window or to give it to an agent.
Before joining, the agent prompt asks for a review and waits for your decision.
**Copy join command** gives you the explicit terminal acceptance command.
After joining, the handoff identifies the service, workspace and ledger. It uses
your existing account and gives only the instructions supported by the access
shown on the page. The post-join prompt and commands carry no invitation proof.

Use the same account in the terminal with the service and workspace shown in
the sign-in command. Select the ledger once sign-in is ready.

```sh
op-sys --connection local auth login --endpoint <service-url> --workspace <workspace-id>
# Once sign-in is ready:
op-sys selection update --ledger <ledger-id>
```

This selects the service context for an existing ledger grant. Reopen the
original invitation link with the same account to see current access, including
changes made by the owner.

`get` and `list` return metadata without the bearer secret and require
`access.manage`. `revoke` closes the link to new participants. Revoke accepted access
separately with `access revoke`; replaying acceptance returns its original receipt
and never reinstates access. Expiry and revocation, the active authority and
lifecycle, and the issuer's current ledger rights within their original credential
bounds are checked before granting access. Scoped recipient credentials retain
their own restrictions.

The private URL puts its secret in a fragment. Inspection and acceptance send the
secret only in POST bodies; GET requests never redeem it. Treat the URL as a
credential and keep it out of ordinary logs, analytics and shared transcripts.
Direct HTTP consumers generate a 256-bit proof as 64 lowercase hex characters.
Hash the UTF-8 encoding of the hex string and send that SHA-256 `token_hash`
to `POST /v1/invitations` with `ledger_id`, the issuance operation ID and
requested access. Keep the proof privately for retries. When the service returns
the ready invitation, append `#` and the original token to `link_base`. New
links look like `https://veylar.org/i#TOKEN` and use the account host of the
installation. To read the routing fields from a link, POST `{"token":"TOKEN"}`
to `/i/resolve` on that account host. For preview or acceptance, POST
`ledger_id`, `invitation_id` and the original
`token` to `/v1/invitations/inspect` or `/v1/invitations/accept`. Include the hosting
tenant selector on ledger requests and authenticate acceptance. Both targets
share these routes and the response identifies the offer with `target_type`.
`invitations` is the SDK namespace. The MCP issuance tool is
`op_sys_invitations_create`.

`invitations status` reads private client progress without returning bearer
secrets or authorization URLs. It is available through CLI, SDK and MCP; a remote
HTTP service cannot inspect a client's local journal. HTTP consumers use the
service issuance, preview and acceptance operations directly.

## Publish rules, then admit them

Discover the supported validator through `capabilities list --prefix contracts.`.
Use `contracts validate --payload-schema @schema.json` to check a proposed schema
and its root examples without publishing, admitting, or appending anything. Supply
`--examples @examples.json` to replace the example list. The same operation is
`client.contracts.validate(payload_schema=...)`, `op_sys_contracts_validate`, and
hosted `POST /v1/contracts/validate`. It checks caller-supplied rules and payload
shapes, not permissions, attachment bytes, admission, or factual truth.

```python
contract = client.contracts.publish(
    ledger_id=ledger_id, contract_id="example.message", version="1",
    payload_schema={"type": "object", "required": ["message"],
                    "properties": {"message": {"type": "string"}},
                    "additionalProperties": False},
)
reference = {key: contract[key] for key in ("contract_id", "version", "digest")}
current = client.ledgers.get(ledger_id=ledger_id)
client.ledgers.update(
    ledger_id=ledger_id, expected_revision=current["revision"],
    changes={"admission": {"mode": "replace", "contracts": [reference],
                           "default_contract": reference}},
)
```

Publishing an immutable version does not admit it. `replace` closes the previous
permissive admission path; `add` deliberately retains existing alternatives.
Changing only `default_contract` retains other admitted contracts. Old versions
remain retrievable by authorized readers to interpret history. Unsupported schema
keywords fail rather than being ignored. Payloads are bounded to 128 KiB, depth
32 and 10,000 nodes; contract documents and ledger metadata are each 64 KiB.

Configuration and policy updates compare the current ledger revision. On
`revision_conflict`, read the current definition and reconcile the change. A mixed
update requires every relevant permission; it cannot partially commit.

### Inspect the rules without changing them

`contracts.list` shows published versions, including versions that are no longer
admitted. `contracts.get` shows an exact version's payload schema, file rules and
digest. `ledgers.inspect` shows the admitted versions and marks the default. These
are different facts: publishing stores rules; admission allows new contributions;
the default selects a version when an append omits `contract`.

```sh
op-sys contracts list --ledger-id <ledger-id>
op-sys contracts get --ledger-id <ledger-id> --contract-id example.message --version 1
op-sys ledgers inspect --ledger-id <ledger-id>
```

Readable CLI contract output does not make additional requests to infer admission.
Inspect the ledger separately for its current configuration, and retain its
observation/freshness context when working from a local copy. Use `--output json`
for complete results and continuation tokens. Reading a contract requires
`contracts.read`; configuring admission requires `contracts.manage` at the authority.
`ledgers.inspect` requires `ledger.read`; it includes full contract bodies only
when the caller also has `contracts.read`. Knowing a version does not grant write access.

### Configure through your preferred interface

The Python example above works against the selected local or hosted authority.
For CLI use, save the same `payload_schema` object in `schema.json`:

```sh
op-sys --output json contracts publish --ledger-id <ledger-id> --contract-id example.message --version 1 --payload-schema @schema.json
op-sys --output json ledgers get --ledger-id <ledger-id>
```

From the returned contract, copy `contract_id`, `version` and the **returned
digest** into both references below. Save this as `admission.json`:

```json
{"admission":{"mode":"replace","contracts":[{"contract_id":"example.message","version":"1","digest":"<returned-digest>"}],"default_contract":{"contract_id":"example.message","version":"1","digest":"<returned-digest>"}}}
```

Then review and apply it using the ledger's current revision:

```sh
op-sys ledgers update --ledger-id <ledger-id> --expected-revision <current-revision> --changes @admission.json
op-sys records append --ledger-id <ledger-id> --operation-id example-valid --payload '{"message":"Hello"}'
op-sys records append --ledger-id <ledger-id> --operation-id example-invalid --payload '{"message":42}'
```

The first submission is accepted; the second returns `payload_invalid`. File
inputs are CLI conveniences. MCP and HTTP receive the JSON objects themselves,
not local filenames or `@file` strings:

| Operation | MCP tool | HTTP method and path | Arguments/body |
| --- | --- | --- | --- |
| Publish | `op_sys_contracts_publish` | `POST /v1/ledgers/{ledger_id}/contracts` | `contract_id`, `version`, `payload_schema`, optional `file_rules` |
| Inspect ledger | `op_sys_ledgers_get` | `GET /v1/ledgers/{ledger_id}` | Ledger selector |
| Admit | `op_sys_ledgers_update` | `PATCH /v1/ledgers/{ledger_id}` | `expected_revision`, `changes` |
| Contribute | `op_sys_records_append` | `POST /v1/ledgers/{ledger_id}/records` | `operation_id`, `payload`, optional `contract` and `attachments` |

MCP includes `ledger_id` in tool arguments. HTTP puts it in the path and uses the
authenticated tenant selection. For example, the admission request body is
`{"expected_revision": <current-revision>, "changes": <admission.json object>}`.
CLI JSON results are wrapped in `payload`; MCP results are in `structuredContent`;
HTTP and SDK return the domain result directly. All use the same contract references,
revision checks and authorization. An HTTP service is unnecessary for standalone
local CLI/SDK/MCP use.

### Change rules by publishing a new version

Publish version `2` with your revised schema. An existing version is immutable;
publishing different rules under the same ID and version returns `operation_conflict`.
Choose the admission change explicitly:

- `replace`: admit only the supplied versions. Use this to close an earlier
  permissive path or require the new version for future contributions.
- `add`: admit the new version alongside existing versions. Contributors may
  still explicitly select any admitted version, even if the default changed.

Set `default_contract` to the exact desired reference in the same update. Read
the current revision and reconsider concurrent changes before retrying a stale
update; do not blindly overwrite another administrator's decision. Consumers with
explicit old contract references must switch when that version is removed from
admission. Accepted history keeps its original contract reference and is not
rewritten or revalidated. Authorized readers can still retrieve the old rules.

### Understand a rejection

An explicit unadmitted version returns `contract_not_admitted`. A payload that
fails the selected contract returns `payload_invalid`; callers with `contracts.read`
can receive a JSON-pointer field such as `/payload/message` and a specific reason.
Append-only contributors receive general guidance without hidden schema details.
Ask an authorized administrator for the contribution requirements if necessary.
`permission_denied` concerns access, not schema validity. File rules and optional
state rules are additional acceptance checks; a matching payload alone does not
guarantee acceptance.

The example field `message` has no built-in meaning. Consumers choose their own
structures and rules. Correcting a rejected payload is a new submission; an
uncertain outcome instead requires `records.outcome` and the original operation
ID before deciding whether to retry identical input.

## Grant access independently

Use `access.get` to read direct grants and `ledgers.inspect` for the caller's
effective permissions. Grants identify a verified `{issuer, subject}` principal,
not a consumer-supplied actor label. A person or agent uses its authenticated
principal; a group uses the group's issuer and `group_id` as its subject.

For everyday changes, use `access.grant` and `access.revoke`. Both take one
principal, a nonempty set of `permissions`, and the current `expected_revision`.
They run atomically at the authority and require `access.manage`:

```python
policy = client.access.get(ledger_id=ledger_id)
policy = client.access.grant(
    ledger_id=ledger_id, expected_revision=policy["revision"],
    principal=participant_identity, permissions=["ledger.read", "records.read"],
)
policy = client.access.revoke(
    ledger_id=ledger_id, expected_revision=policy["revision"],
    principal=participant_identity, permissions=["records.read"],
)
```

Grant adds missing permissions; revoke removes only the specified direct
permissions. Other principals and unspecified permissions are preserved. An empty
direct grant is removed. Neither operation can remove the final `access.manage`
grant. Revoking a person's direct permission does not deny access inherited
through a group; change the group grant or membership if that is your intent.

Every successful call advances the ledger revision, even if the requested grant
or revocation was already satisfied. Stale revisions return `revision_conflict`
without changing the policy. After a conflict or lost response, read the policy,
reconsider the intended change, and use its current revision. There is no client
read/replace cycle inside these operations.

```sh
op-sys access get --ledger-id <ledger-id>
op-sys access grant --ledger-id <ledger-id> --expected-revision 1 \
  --principal '{"issuer":"verified-issuer","subject":"verified-subject"}' \
  --permissions '["records.read"]'
op-sys access revoke --ledger-id <ledger-id> --expected-revision 2 \
  --principal '{"issuer":"verified-issuer","subject":"verified-subject"}' \
  --permissions '["records.read"]'
```

MCP tools are `op_sys_access_grant` and `op_sys_access_revoke` with identical
arguments. HTTP uses POST `/v1/ledgers/{ledger_id}/access/grant` and
`/v1/ledgers/{ledger_id}/access/revoke` with `expected_revision`, `principal` and
`permissions` in the JSON body. All return the resulting policy and revision.

`access.update` remains available for deliberate full-policy replacement at an
expected revision. Supply every intended grant and preserve an administrator.

Use `append_contract_ids` on a grant or an invitation to allow specific record
types. The authority checks the selected contract ID on append and preflight,
including when the caller uses the ledger default. A scoped grant applies to all
currently admitted versions of the listed IDs. Grants are additive across direct
and group access. Use `ledgers.inspect` to see the effective scoped IDs and
`access.update` to narrow a direct grant.

Use `identity get` for the supplied client's identities and
`GET /v1/identity` for an authenticated hosted identity. Copy that
verified tuple into the policy. Schema, policy, record reading, appending and
outcome inspection are separate rights. A contributor can submit against the
authority's default contract without permission to inspect its schema. Service
credential restrictions remain an upper bound on ledger grants. A ledger grant
does not permit account administration.

## Handle uncertain writes

Reuse one operation ID with the identical intended input and principal when
retrying an append. Accepted replay returns the original acceptance even if its
contract was subsequently retired. Changed input under that ID conflicts. Retry
resolution reveals acceptance metadata only; record payload still requires read
permission. The authority durably binds an omitted contract to the version used
on the first accepted attempt.

Supplied clients generate an omitted ID and durably save private delivery intent before
dispatch. Client status exposes recoverable attempts after restart; explicit synchronization
can deliver them. For applications requiring restart recovery, explicitly save your own
operation ID alongside your business operation. Direct HTTP callers must provide
an ID. A lost or invalid response produces `state: uncertain`; use
`records.outcome` to inspect the result. Outcome inspection never appends or
schedules a retry. `absent` is qualified and does not cancel an in-flight request.
Retention-limited outcomes reserve the operation ID without recovering erased
content. Revocation can prevent further outcome disclosure.

SDK failures remain `OpSysError`, with canonical `core_error` fields for operation,
code, retry and recovery. CLI JSON and HTTP errors expose the same domain code.
When the caller can inspect the contract, `payload_invalid` also identifies the
failing location with a JSON Pointer, for example `field: "/payload/message"`,
and a type mismatch explains the expected type. Payload values and undeclared
property names are never echoed. Append-only callers without `contracts.read`
receive the same rejection code without schema details. Correct rejected input
using a new operation identity; do not change the input of an existing attempt.

Do not blindly retry changed governance or authorization failures.

## Page through records

`records.list` returns a fixed snapshot, permitted definition context and a
matching `changes_from` checkpoint. Resume `next` until null, then use
`changes.feed` to retrieve accepted records, definition changes and removals.
Authorization is rechecked on every page. See [Snapshots and changes](/docs/raw/manuals/ledger-reads.md)
for bounds, expiry, coverage, SDK iterators and recovery.

`ledgers.list` and `contracts.list` remain live catalog listings; their cursors
are not record-snapshot or change checkpoints. Keep their page size and caller
context unchanged while continuing.

## Find ledgers

`ledgers.search` finds readable ledger definitions in the selected local store or
service tenant. `ledgers.list` enumerates the catalogue; `records.search` searches
accepted records in the selected local store or service tenant.

```python
page = client.ledgers.search(
    filter={"name": "Example", "metadata": [{"path": ["reference_id"], "eq": "example-42"}]},
    limit=25,
)
ledger_ids = [item["ledger"]["ledger_id"] for item in page["items"]]
```

```sh
op-sys --output json ledgers search --filter '{"metadata":[{"path":["reference_id"],"eq":"example-42"}]}' --limit 25
```

MCP uses `op_sys_ledgers_search`; HTTP uses `POST /v1/ledgers/search` with the same
JSON arguments and ordinary authentication and tenant selection. Local SDK,
CLI and MCP searches need no server. Hosted searches use the selected connection.

Name matching is exact and case-sensitive; `name: null` selects unnamed ledgers.
Omit `filter` or use `{}` to match all readable ledgers. Metadata predicates use
the same `path` and scalar `eq` pattern as record payload filters: all conditions
must match, strings are literal object keys, integers are array indexes, no type
coercion occurs, and missing fields never equal null. `false`, `0` and `"0"` differ.
There are no predefined metadata fields. Add `query={"text": "your question"}` for relevance-ranked text search when the
search runtime is provisioned. Use `next_cursor` as `cursor` for additional ranked results. File queries use the same `query.files` input; see [file search](/docs/raw/manuals/search-files.md). Exact requests load no model.

Managed ranked searches accept `operation_id`, `service_class` and
`maximum_charge_minor` on SDK, CLI, MCP and HTTP. Paid searches require a caller
operation ID. Choose it before submitting and reuse it with the same arguments
to recover the first page after a lost response. Changing the query, scope,
filters, page size, class or maximum under the same identity conflicts. A new
intentional execution needs a new ID; identical query text does not deduplicate
different operations. These billing controls require a managed connection.

The accepted rate card defines text/file classes and their defaults. An omitted
class uses the published default for that query kind; requests are never silently
upgraded. `maximum_charge_minor` is an integer string in the organization's
billing currency (for example, `"2"` means two cents when the currency is USD).
The returned `usage` identifies the operation, selected class and whether it is
billable. Explicit evaluation stays non-billable; local and self-hosted operations
do not acquire managed-service charges.

One successful, durably retrievable execution counts once, including empty
results and searches spanning multiple ledgers. Cursor pages and replay are
included. Failed work and cancellation before completion do not count. A later
disconnect does not undo an already saved result. Replay always checks current
authorization; a usage receipt grants no record access. Expired or canceled
operation identities cannot silently execute again; use a new ID for a new search.

Each result contains `ledger` and `observation`. Replica results describe retained
data, not a fresh remote read. Search requires `ledger.read`; it neither grants
access nor searches the contents of records. Exact results sort by `ledger_id`; text queries sort by relevance.

Omit `ledger_ids` and `collection_id` to search all readable ledgers, or provide
one selector to narrow the scope. An empty ID list is invalid. An explicitly
inaccessible or missing ledger returns the same `permission_denied` error.
A readable collection silently includes only ledgers the caller may discover;
search responses disclose no hidden member identities or counts.

Each page examines at most 250 authorized catalogue candidates and returns at
most 25 matches, with an 8 MiB page budget. Filters allow eight metadata
predicates, 16 segments per path and 64 KiB. `continuation` reports `available`
or `exhausted`; `coverage.status` and bounded `reasons` describe retained-data
completeness independently of pagination. Every item retains its observation.
Continue with only `cursor=page["next_cursor"]` in the same configured environment.
Veylar restores the original scope, filters and limit; conflicting parameters are
invalid. Empty pages can still have a continuation. Use a page budget in loops.

Cursors expire 15 minutes after search starts. Editable ledger definitions are
kept consistent by invalidating incomplete searches when the catalogue, authority
or access changes, including ledger creation. Restart after
`record_selection_changed`; invalid, differently bound or expired tokens return
`record_cursor_invalid`. Ordinary record appends do not invalidate the search.
This does not hold a historical copy of each ledger definition after it changes.

## Discover CLI, MCP and HTTP contracts

```sh
op-sys --output json capabilities list
op-sys --output json capabilities get --name records.append
op-sys records append --help
```

MCP uses native tools such as `op_sys_ledgers_create`, `op_sys_records_append`,
`op_sys_records_outcome` and `op_sys_capabilities_get`, with typed JSON inputs
and results. No tool-specific login is required. Retired record bindings are not
aliases for these operations.

For direct HTTP, use the canonical OpenAPI artifact. For example:

```sh
curl --fail-with-body "$VEYLAR_ENDPOINT/v1/ledgers/$LEDGER_ID/records?tenant_id=$TENANT_ID" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"operation_id":"example-first-contribution","payload":{"message":"Hello"}}'
```

Tenant selection is a query parameter or `X-Veylar-Tenant` header, separate from
the operation's body. Managed and customer-hosted services use the same routes.
The service authenticates the principal and enforces its ledger rights regardless
of the client used. Successful operations return HTTP 200; errors use the catalog's
status mapping and `{ "error": ... }` envelope.

The canonical operation catalog records inputs, results, permissions, limits,
effects and availability for every operation. Discovery distinguishes supported,
enabled and authorized: `authorized: null` means unknown without the specific
ledger/input, not a grant. Disabled future capabilities cannot be invoked.

For optional Bash/Zsh completion, source the generated
`op_sys/contracts/ledger-core.completion.sh` from the installed package (or source
checkout). It completes enabled core commands and flags without opening storage,
querying a service or enumerating private ledger names. It does not replace the
surrounding-operation catalog. See [installation](/docs/raw/manuals/installation.md#shell-completion)
for explicit shell activation.

State rules configure ledger acceptance; collections and groups have their own
public resource operations. See
[Surrounding capabilities](/docs/raw/manuals/ledger-surrounding.md) for their contracts and the
retained account, execution and recovery boundaries.

## Clone, synchronization and conditional acceptance

Use `ledgers.clone`, `ledgers.sync` and `ledgers.status` for an optional local
copy and its explicit synchronization with named remotes. Clone keeps ledger
identity and accepted history; it is not an independently governed fork. A fork
operation is not part of this release. Low-level `ledgers.receive` and
`ledgers.checkpoint` serve custom HTTP synchronization clients, with the same
bindings in CLI/SDK/MCP; they do not inspect another device's private progress.

Configure optional `changes.state_rules` through `ledgers.update`; submit
ordinary records through `records.append` and inspect state with `records.state`.
See [conditional acceptance](/docs/raw/manuals/record-views.md) for exact fields and restrictions.
Groups govern authorization. Ledger collections save selections for repeated
retrieval; neither collection membership nor cloning grants source-ledger access.


## Local and hosted capability parity

Ledger, record, contract, file, access and state-rule operations share their public
contracts in the selected local store or hosted service. `ledgers.search`,
`records.search/feed`, groups and collections also work without a remote or account.
Use `OpSys(connection="local")` or `--connection local` for the local store; choose
an existing named connection to operate at a service. HTTP needs that service's
endpoint; local CLI/SDK/MCP use does not start a server.

Authority and permission checks still apply. A retained replica does not become
an authority, and its observations do not promise current remote data. Cross-ledger
search results expose compact coverage, per-result observations and a store retrieval
sequence, preserving the original acceptances. Feed retains its per-ledger coverage. Groups and collections remain scoped to their store and
issuer; they do not implicitly synchronize with a ledger. Account administration
and operations that actually contact a remote keep their service dependencies.

## Search indexing preferences

Use `ledgers.update` with `changes.search` and the current `expected_revision`.
It requires `ledger.configure`, independently of record contribution rights:

```python
client.ledgers.update(ledger_id=ledger_id, expected_revision=revision,
    changes={"search": {"enabled": True, "excluded_paths": ["/private_notes"]}})
```

`excluded_paths` contains JSON Pointers; each path and its descendants are omitted
from derived indexing. Paths address the record payload, or `/name` and `/metadata`
for ledger discovery. `""` excludes the whole projection. Setting `search` replaces
these preferences; omitted fields default to enabled with no exclusions.

These preferences do not change admission, exact retrieval or resource permissions.
Text queries use these derived projections; exact searches do not load a model.
See [search availability](/docs/raw/manuals/record-collections.md#semantic-query-availability).
