Risk and intelligence

SDK reference

Risk

pg.risk — corridors, limits, exposures and breakers, approvals and their decision signature, approval rules, operators, identities, cases and the audit log.

pg.risk is an operator product: it acts on the whole deployment. Every call needs the risk scope; deciding an approval needs the approver scope of its action as well. Exercise it in the sandbox with test keys. In live mode it is available to a key whose agreement includes operator access, and every request carries the signature of a registered operator (operator).

A change that tightens applies at once. A change that loosens is requested without an approval id and applied with the id of its approval, once a second person has approved it.

What a payment is refused with is on Routing.

Corridors

A corridor runs from one asset on a network to another, ASSET@network>ASSET@network. A corridor is open, throttled or closed.

CallReturns
corridors()RiskCorridor[]Every corridor and its bounds
corridor(id)RiskCorridorOne corridor
putCorridor(id, corridor)RiskCorridor | ApprovalWaitingWrites a corridor (RiskCorridorRequest) under an approval corridor_open
closeCorridor(id, reason?)RiskCorridorCloses it. Applies at once
throttleCorridor(id, throttle, { approval?, reason? })RiskCorridor | ApprovalWaitingSets { per_minute, amount_per_hour }, at or above the corridor's throttle floor. A tightening applies at once; a loosening waits for an approval corridor_open
openCorridor(id, { approval?, reason? })RiskCorridor | ApprovalWaitingOpens it under an approval corridor_open

In the sandbox, a pair with no corridor gets one on first use, which advances recallable pay-ins under a limit (bounded_exposure). The values of live corridors are set by Path Global.

Limits, exposures and breakers

CallReturns
limits()ExposureLimit[]Every limit, <scope>:<subject>:<measure>[:<window>]
setLimit(id, limit, approval?)ExposureLimit | ApprovalWaitingA lower limit applies at once; a higher one under an approval limit_raise
exposures()Exposure[]Each limit with its value and utilisation_bps
breakers()Breaker[]Every breaker, <scope>:<subject>: closed, half_open or open
tripBreaker(id, cause)BreakerOpens a breaker. Applies at once
resetBreaker(id, { approval?, probe? })Breaker | ApprovalWaitingResets a breaker under an approval breaker_reset: to half_open with a probe amount, then closed

Breaker scopes: corridor, partner, network, asset, account, client, provider, system.

halt, stop, resume and switchLog are reserved to Path Global. A client reads 503 pathglobal.risk.halted: new work is paused.

Approvals

CallReturns
approvals(filter?)Approval[]Filter { state?, action?, subject?, after?, limit? }
approval(id)ApprovalOne approval, signed
approve(id, signature?)ApprovalApproves. In live mode signature is the checker's decision signature
reject(id, signature?)ApprovalRejects, under the same rule

An approval applies once, to the change it names (action, subject), at the version it names (target_version). It is requested, then approved or rejected, then consumed when the change applies, or expired.

The checker is another credential and another operator than the maker, and its key carries risk and the approver scope of the action:

Approver scopeActions
treasury_approvetreasury_transfer, allowlist_add, policy_change, funding_expect, break_resolve, rule_change, collateral_withdraw, pool_resume
risk_approvecorridor_open, limit_raise, breaker_reset, operator_register, identity_restore, case_decide, bounds_change, instruction_resolve, participant_onboard, cap_raise

Approvals gives the full contract.

The decision signature

In live mode the body of a decision carries signature: the checker's Ed25519 signature, in hexadecimal (128 characters), over the hexadecimal SHA-256 of the canonical JSON { approval, decision, payload_digest } (keys sorted, no whitespace). approval is the id, payload_digest is read from the approval, and decision is approve or reject. Test mode asks for no signature.

import { createHash, createPrivateKey, sign } from 'node:crypto';
import type { Approval } from '@pathglobal/sdk';

const checkerKey = createPrivateKey(process.env.OPERATOR_KEY_PEM!);

function decisionSignature(approval: Approval, decision: 'approve' | 'reject'): string {
  const canonical = JSON.stringify({ approval: approval.id, decision, payload_digest: approval.payload_digest });
  const digest = createHash('sha256').update(canonical).digest('hex');
  return sign(null, Buffer.from(digest), checkerKey).toString('hex');
}

const approval = await checker.risk.approval(approvalId);
await checker.risk.approve(approval.id, checker.mode === 'live' ? decisionSignature(approval, 'approve') : undefined);
CodeStatusWhen
pathglobal.risk.self_approval403The checker is the maker's credential or operator
pathglobal.risk.approval_pending409The change waits for a decision
pathglobal.risk.approval_invalid409The approval is absent, not approved, expired, already used, or for another change
pathglobal.risk.operator_required403Live mode: the request or the decision is not signed by an operator who carries the scope
pathglobal.auth.scope_missing403The key does not carry the approver scope of the action

Rules and operators

CallReturns
rule(id)ApprovalRuleOne approval rule
putRule(id, rule)ApprovalRule | ApprovalWaitingWrites a rule under an approval rule_change
operators()Operator[]The registered operators: id, public key, scopes, status
registerOperator({ id, public_key, scopes, approval? })Operator | ApprovalWaitingRegisters an operator under an approval operator_register. public_key is the Ed25519 public key, 64 hexadecimal characters
revokeOperator(id)OperatorRevokes an operator. Applies at once

Identities and cases

CallReturns
identity(subject)Identitypending, verified, restricted or blocked
restrictIdentity(subject, reason)IdentityApplies at once
blockIdentity(subject, reason)IdentityApplies at once
restoreIdentity(subject, approval?)Identity | ApprovalWaitingRestores it under an approval identity_restore
cases(filter?)RiskCase[]Filter { state?, subject?, after?, limit? }; a case is open, assigned or decided
assignCase(id)RiskCaseAssigns the case to the caller
decideCase(id, decision, approval?)RiskCase | ApprovalWaitingpass, fail or file, under an approval case_decide

In the sandbox, an unknown client reads as a verified identity with verdict sandbox.

The audit log

CallReturns
audit(from, to, page?)RiskDecision[]The decisions recorded between two instants; page is { after?, limit? }

No intelligence advice and no MCP tool approves, halts or resumes, opens, closes or throttles a corridor, or changes a limit.

The guide is Risk, limits and approvals. The routes are on Risk.

On this page