9 Commits

Author SHA1 Message Date
b110508926 feat: expose operator vault state for the console
Adds buildOperatorState (bucket balances, held total, today's UTC-day spend
vs caps, pending escalations) and OperatorRuntime.state(), read from the
vault executor (on-chain reads when OperatorVault is configured), served at
GET /v1/operator/state for the operator org.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:59:41 +03:00
0a86d7af03 fix: harden operator against double execution and payee swaps
- Events and escalation resolutions are claimed atomically in the store
  (operator_claims, INSERT ... ON CONFLICT DO NOTHING) before any money
  moves, so concurrent API/worker processes cannot execute twice; claims
  are released only when nothing was executed.
- x402 purchases pin the policy-approved payee and price: the settler
  refuses a re-read challenge that names another payTo or a higher price.
- A broadcast vault transaction whose receipt is unavailable or reverted
  is recorded as failed with its txHash (VaultTxError) for reconciliation.
- verifyDecision never reports a decision that moved money as valid
  without checking its DecisionAnchored logs on Arc.
- The worker's shared runtime reads the current run's clock and logger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:40:43 +03:00
b7d674bbc2 feat: add live Arc e2e script for the operator
scripts/operator-arc-e2e.ts (refuses without LIVE=1) deploys OperatorVault
from the Foundry artifact when no vault is given, sets caps and allowlist as
the owner, pays the vault from a customer wallet, lets the operator allocate
the sale, pays a small bill, escalates a larger one in the vault, has the
owner approve it on-chain, then verifies every decision's chain, commitment
and DecisionAnchored log and prints the proof. Adds reusable arc-live
helpers (deploy, USDC transfer, balance, signer address).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:27:02 +03:00
bb5daed488 feat: add operator proof, verification, policy admin and runtime
computeProof aggregates the hash-chained logs (orgs, counterparties, USDC
in/out, outcomes incl. blocked by policy and blocked on-chain, latency,
model cost, Arcscan anchors) and always excludes the demo org.
verifyDecision recomputes the chain prefix and the pre-execution commitment
and checks each transaction receipt on Arc for DecisionAnchored from the
vault. PolicyAdmin parses USDC policy bodies and refuses caps or allowlist
entries that drift from the vault. createOperatorRuntime assembles store,
DCW or viem vault executors (or a clearly labelled local simulation),
Claude or heuristic engine, screening, x402, alerts and bill intake from env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:01:08 +03:00
341b977c28 feat: add AP bill intake and escalation notifications
BillIntake accepts manual bills or raw invoice text; Claude extracts vendor,
amount, due date and wallet through a single record_invoice tool, and the
wallet must appear verbatim in the invoice. Payees missing from the policy
allowlist are escalated at intake with their own decision record; due bills
go straight to the operator. Escalation notifications go to email via
@settlekit/notifications and to a Discord webhook (mentions disabled) behind
an AlertChannel interface; channel failures never block an escalation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:53:29 +03:00
fee0101b44 feat: add OperatorVault executor over Circle DCW and viem
VaultExecutor reads the vault through viem, simulates every write as the
signer so vault reverts surface as VaultError codes without spending gas,
then sends through a VaultTransport: Circle developer-controlled wallet
contract execution (buildContractExecutionRequest via createContractExecution,
pollTransaction to COMPLETE, deterministic idempotency keys) on ARC-TESTNET,
or a viem private-key signer when DCW cannot target the chain. pay() reads
the Escalated log for vault escalation ids. Includes per-request Circle
entity-secret ciphertext (RSA-OAEP SHA-256) and Arc viem client factories.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:47:56 +03:00
8c1d704a96 feat: add Claude operator agent, tools and decision service
OperatorAgent drives the Anthropic SDK tool runner (betaZodTool) over read
tools (treasury state, open bills, counterparty risk, payment history, x402
quotes) and policy-checked action tools that require rationale,
alternatives and confidence. claude-sonnet-5 handles revenue and ticks,
claude-opus-5-5 bills, refunds and disputes; at most 12 iterations, with
HeuristicOperator fallback when no key is set or the API fails.

OperatorService turns each event into one hash-chained DecisionRecord with
the tool trace, verdict, usage cost and outcome. The vault anchors a
pre-execution commitment hash of the reasoning; owner approvals, rejections
and 72h expiries are recorded as decisions too. Invoice and customer text
is passed as escaped untrusted data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:41:33 +03:00
f30aef513d feat: add operator heuristic engine, executors, escalations and stores
Deterministic HeuristicOperator for revenue, bills, refunds, disputes and
ticks with rationale, alternatives and confidence. LocalExecutor simulates
OperatorVault independently for parity tests; executeProposal routes
proposals and holds off-chain escalations. 72h escalation queue, and
in-memory plus self-creating Postgres jsonb stores (doc projection) that
reject decision-chain forks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:17:34 +03:00
858a1a1485 feat: add @settlekit/operator policy, allocation and decision log
OperatorPolicy.evaluate mirrors OperatorVault check order (deny reasons map
1:1 to vault errors), reuses @settlekit/treasury for allowlist and UTC-day
window, and adds stricter off-chain gates (risk, compliance, min float,
x402 budget). Exact bigint revenue split, validated operator events, and a
sha256 hash-chained decision log with tamper detection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:17:30 +03:00