Skip to content

feat(operator): external backend connect-mode + self-advertised payment config + SDK e2e#10

Merged
tangletools merged 1 commit into
mainfrom
feat/operator-external-backend-e2e
May 25, 2026
Merged

feat(operator): external backend connect-mode + self-advertised payment config + SDK e2e#10
tangletools merged 1 commit into
mainfrom
feat/operator-external-backend-e2e

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

Summary

Makes the operator runnable against any OpenAI-compatible upstream with no GPU, and self-describing so clients need no hardcoded addresses — then proves the whole billed inference path end to end with the viem SDK.

  • vllm.external flag — when set, InferenceServer::start connects to an already-running server at host:port (VllmProcess::connect) instead of spawning vLLM, and the watchdog won't respawn a backend it doesn't manage. Lets the operator front cli-bridge / llama.cpp / a stub.
  • /v1/operator advertises shielded_credits + chain_id so a client can construct the ShieldedCredits EIP-712 domain from operator info alone (the Tangle Cloud UI relies on this to self-configure).
  • SDK e2e tooling (sdk/scripts/):
    • onchain-e2e.mjs — signs a SpendAuth and submits authorizeSpend against a live ShieldedCredits; the contract's ECDSA.recover must accept the SDK signature (asserts balance debited + nonce incremented).
    • local-onchain-proof.sh — deploys ShieldedCredits + a mock token, funds a credit account, runs the on-chain proof.
    • http-e2e.mjs — full path: SDK signs → operator-lite validates (recover + on-chain getAccount) → proxies to the backend → completion; asserts the on-chain spend nonce advances.

Verified locally

anvil + ShieldedCredits + operator-lite + cli-bridge (claude-code/sonnet):

  • 402 Payment Required without a SpendAuth;
  • SpendAuth-gated chat returns a real completion ("hello", usage reported);
  • on-chain spend nonce advances on settlement.

This is the GPU-free local e2e: operator-lite already had a connect() path; cli-bridge supplies a real backend via local coding-CLI subscriptions.

Test plan

  • cargo build --bin operator-lite clean (lib changes compile)
  • on-chain proof: ALL PASS (SDK signature accepted by authorizeSpend)
  • full HTTP e2e: ALL PASS (real completion through the billed path)

…nt config

Lets the operator run against any OpenAI-compatible upstream (cli-bridge,
llama.cpp, …) with no GPU, and makes its payment surface self-describing so
clients configure themselves with zero hardcoded addresses.

- config: `vllm.external` flag. When set, InferenceServer::start connects to
  an already-running server at host:port via VllmProcess::connect instead of
  spawning vLLM, and the watchdog no longer tries to respawn a backend it
  doesn't manage.
- server: /v1/operator now advertises `shielded_credits` + `chain_id`, so a
  client can build the ShieldedCredits EIP-712 domain from operator info alone.
- sdk/scripts: end-to-end proofs driving the viem SDK —
  - onchain-e2e.mjs: signs a SpendAuth and submits authorizeSpend against a
    live ShieldedCredits, asserting the contract's ECDSA.recover accepts the
    SDK signature (balance debited, nonce incremented).
  - local-onchain-proof.sh: deploys ShieldedCredits + a mock token, funds a
    credit account, runs onchain-e2e.
  - http-e2e.mjs: full path — SDK signs → operator-lite validates (recover +
    on-chain getAccount) → proxies to the backend → completion; verifies the
    on-chain spend nonce advances.

Verified locally: anvil + ShieldedCredits + operator-lite + cli-bridge
(claude-code/sonnet) — SpendAuth-gated chat returns a real completion, 402
without payment, settlement advances the on-chain nonce.

@tangletools tangletools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local e2e proven (on-chain SpendAuth acceptance + full HTTP path via cli-bridge). Connect-mode + self-advertised payment config are clean. Approving.

@tangletools tangletools merged commit 2db0337 into main May 25, 2026
2 of 5 checks passed
@tangletools tangletools deleted the feat/operator-external-backend-e2e branch May 25, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants