# Ledger batch

Apply a batch of retained ledger operations.

Capability: op_sys_command_ledger_batch
Protocol: op-sys.capabilities.v1
Runtime: 0.3.0
Availability: Optional local integration
Optional integration: true
Canonical page: /docs/reference/op_sys_command_ledger_batch

## Authority

Existing local policies, approvals and cooperative actor controls apply. These operations are retained capabilities, not the definition of a Veylar Record ledger.

## 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_command_ledger_batch \
  --arguments '{"operation":["<operation>"]}'
```

### Python SDK

```python
import json
from op_sys import OpSys

client = OpSys()
arguments = json.loads("{\"operation\":[\"<operation>\"]}")
result = client.capabilities.call(
    "op_sys_command_ledger_batch", arguments
)
print(result)
```

### MCP (initialized connection)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "op_sys_command_ledger_batch",
    "arguments": {
      "operation": [
        "<operation>"
      ]
    }
  }
}
```

Named CLI command: op-sys ledger batch (use --help for flags).

## Parameters

### actor

Optional; string. Actor recorded on writes and audit entries.

Schema default: "operator". Send null only if the input schema permits it.



### approval

Optional; string. Approval id required by policy-gated writes.



### contract

Optional; string. Workflow contract JSON path used for strict contract validation.



### idempotency_key

Optional; string. Replay key for the full batch.



### operation

Required; array. Operation JSON or one explicit operation envelope.


```json
{
  "description": "Operation JSON or one explicit operation envelope.",
  "items": {
    "type": "string"
  },
  "type": "array"
}
```


### precondition

Optional; array. Batch precondition JSON, repeatable.


```json
{
  "description": "Batch precondition JSON, repeatable.",
  "items": {
    "type": "string"
  },
  "type": "array"
}
```


### strict_contract

Optional; boolean. Validate every write against the workflow contract.

Schema default: false. Send null only if the input schema permits it.



### Complete input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "actor": {
      "default": "operator",
      "description": "Actor recorded on writes and audit entries.",
      "type": "string"
    },
    "approval": {
      "description": "Approval id required by policy-gated writes.",
      "type": "string"
    },
    "contract": {
      "description": "Workflow contract JSON path used for strict contract validation.",
      "type": "string"
    },
    "idempotency_key": {
      "description": "Replay key for the full batch.",
      "type": "string"
    },
    "operation": {
      "description": "Operation JSON or one explicit operation envelope.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "precondition": {
      "description": "Batch precondition JSON, repeatable.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "strict_contract": {
      "default": false,
      "description": "Validate every write against the workflow contract.",
      "type": "boolean"
    }
  },
  "required": [
    "operation"
  ],
  "type": "object"
}
```

## Behavior

- Entities, claims, comments and artifacts use the retained event model. They do not create a universal task schema in generic ledgers.
- Mutation operations can record local execution events and audits. The former automatic source-upload path is removed; these events do not synchronize as ledger records.
- Where idempotency keys are accepted, preserve them across uncertain retries. Where no retry identity is available, inspect the result before repeating a mutation.

## Response

Returns the command’s structured payload. The runtime output manual documents the payload families; no standalone response JSON Schema is published for this operation.

[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.

No standalone response JSON Schema is published for this operation. The input schema is not a response contract.

## Errors and recovery



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

- [sdk](/docs/raw/manuals/sdk.md)
- [cli-contract](/docs/raw/manuals/cli-contract.md)
- [command-output-schema](/docs/raw/manuals/command-output-schema.md)
- [operational-boundaries](/docs/raw/manuals/operational-boundaries.md)
- [public-capabilities](/docs/raw/manuals/public-capabilities.md)
