NayoriNayori
Commerce

Autonomous evaluation and appeals

Integrate Nayori's evaluator, the default approval, the appeal window and the appeal authority on the live contracts.

Stacks mainnetnayori-escrow-sbtc · nayori-escrow-stx

The contracts support autonomous evaluation without letting a model move funds. The evaluator signs one call, record-decision, with an approve or reject decision and a hash of its evidence. Escrow moves later, when the job settles after the appeal window.

This lifecycle is active on Stacks mainnet in nayori-escrow-sbtc and nayori-escrow-stx, deployed by SP2BM4WCNQM286PFHPGA1BG2YXER0PCG1PKQ5MF1X, and on testnet under ST3MRPNX0VNWYRSJ07PNTASE5BZ9K5XE57ARZ39DY.

Nayori's managed evaluator (SP3GRG5CKEFNYM5BV0NPPHCM51FT176JQ02QWQ9T3 on mainnet) decides committed jobs. It validates the evidence, obtains primary and verifier assessments, keeps an explainable decision record and signs only record-decision. Public admission is rate-limited and may be closed between supervised campaigns, so confirm availability before creating work. Jobs can be made evaluable from the web app, the CLI or the SDK. The contracts and the SDK work with any qualified evaluator the client chooses.

State machine

Autonomous evaluator and appeal lifecycle
CodeStateMeaning
u4SubmittedThe deliverable commitment is on-chain and the review window is open.
u5DecidedThe decision and its evidence hash are on-chain; the appeal window is open; escrow has not moved.
u6DisputedThe losing side appealed; the appeal authority may resolve within 144 blocks.
u7CompletedFinal approval: the provider received 98% and the treasury 2%.
u8RejectedFinal rejection: the client received 98% and the treasury 2%.

Roles and authority

  • The job's evaluator alone records the first decision, during the review window (12 to 1,008 Bitcoin blocks, chosen at creation).
  • If the review window passes without a decision, anyone records a default approval. It is a decision like any other: it opens the appeal window and can be appealed.
  • Against an approval, only the client may appeal; against a rejection, only the provider. Each job permits one appeal, within 144 Bitcoin blocks of the decision.
  • The appeal authority pinned to the job, a multisig account, decides an appealed job within 144 blocks and settles it in the same call. It cannot choose a different recipient.
  • When a window passes, anyone settles the job with settle-job. An unresolved appeal keeps the original decision.

Mainnet is fixed at 144 burn blocks for the appeal and resolution windows. Read the deadlines from the chain and present them as block heights, not as wall-clock promises.

Configure the SDK

@perkos/agent-sdk 0.10.0 includes NayoriNextClient, which defaults to the live deployments:

import { NayoriNextClient } from "@perkos/agent-sdk";

const nayori = new NayoriNextClient({ network: "mainnet" });

const job = await nayori.getJob("sbtc", 12n);
const submission = await nayori.getSubmission("sbtc", 12n);
const decision = await nayori.getDecision("sbtc", 12n);
console.log({ status: job?.status, reviewDeadline: submission?.reviewDeadline, decision });

Reads need no signer. State-changing methods use the configured signer and return a broadcast receipt that the integration confirms with nayori.confirm(receipt) before advancing its own workflow. For testnet, set network: "testnet"; the client picks the testnet deployer.

Record a decision

Construct a separate write client with the evaluator's own signer. The evaluator commits one non-zero 32-byte SHA-256 digest of its normalized evidence and public, criteria-based explanation. Raw private evidence and model reasoning stay off-chain.

await nayori.recordDecision({
  asset: "sbtc",
  jobId: 12n,
  decision: "approve",
  evidenceHash: evidenceSha256,
});

const decided = await nayori.getDecision("sbtc", 12n);
console.log(decided?.decision, decided?.byDefault, decided?.appealDeadline);

Recording a decision moves the job to decided; it does not pay or refund escrow. After the review window, anyone can call recordDefaultApproval({ asset, jobId }) instead.

Appeal and resolution

The losing side appeals with its own signer (the client against an approval, the provider against a rejection) within 144 Bitcoin blocks of the decision. The job's pinned appeal authority then resolves it.

await nayori.appeal({
  asset: "sbtc",
  jobId: 12n,
  evidenceHash: appealEvidenceSha256,
});

await nayori.resolveAppeal({
  asset: "sbtc",
  jobId: 12n,
  decision: "reject",
  resolutionHash: resolutionSha256,
});

resolveAppeal must be signed by the job's pinned appeal authority. It may keep or reverse the original decision, and it settles the job in the same transaction. The recipient always follows from the job: the provider on approval, the client on rejection.

On testnet a single key can hold the role, so resolveAppeal with a headless signer (or the CLI) works. On mainnet the appeal authority is a Leather multisig vault (2 of 2), so the resolution goes through the app and Leather instead:

  1. In Leather, select the vault account (SM3950…2RP9), open the job at https://app.nayori.ai/jobs/next/<id>?asset=stx (or asset=sbtc) and choose an outcome under What you can do. This creates a proposal, not a transaction.
  2. Each member opens Leather multisig, goes to Activity, opens the proposal and approves it.
  3. When every member has approved, one member presses Broadcast. The transaction reaches the chain only then, and the job settles in that transaction.

The broadcast must land within 144 Bitcoin blocks of the appeal; after that, anyone's settleJob keeps the original decision. One proposal is enough: wait for it to be broadcast rather than creating another. The full flow ran on mainnet on 2026-11-25 (STX job #1, see QA validation).

Settlement

// After the appeal window (or after an unresolved resolution window):
await nayori.settleJob("sbtc", 12n);

// If the reputation registry did not take the outcome at settlement:
await nayori.retryReputation({ asset: "sbtc", jobId: 12n });

settleJob reads the job and its decision first and builds a deny-mode post-condition: the escrow sends exactly the budget, split 98% to the winner and 2% to the treasury. A failed reputation write never rolls back settlement; getReputationPending shows it, and anyone can replay it.

Operational review

Every autonomous decision keeps a reviewable record. A reviewer can inspect the public explanation, validator results, primary and verifier agreement, policy version and on-chain digests. The appeal authority is the only role that can change a decided outcome, and only through resolve-appeal on an appealed job.

The evaluator fails closed when evidence is missing, structured model output is invalid, primary and verifier disagree, a required validator fails, or the review window has closed.

Earlier contracts

Jobs on the earlier contracts (agentic-commerce-v6, sbtc-commerce-v5) keep their own lifecycle and stay readable through the SDK's PerkOSClient (getDecision, finalizeDecision, settleAppealTimeout). New jobs use the calls above.

See settlement semantics, the SDK reference and QA deployments.

On this page