Fixes 2 critical, 2 important, and 5 minor findings from review of 069edcb:
- C1: add a happy-path test that reaches postOcrEscrow.ts's escrowLockFloor
call and asserts the locked amount; verified it fails against a bare
economicTotal and passes against the real code.
- C2: gate /v1/ocr/extract (auth + rate limits) before the 16mb body parser
so an unauthenticated caller can no longer force a full buffer/JSON.parse.
- I2: hoist result/used/escrowRef in the OCR one-shot handler so the failure
path records escrow_ref/supplier/cost when an escrow was actually posted,
and emit an ocr_failed structured log line mirroring ocr_settled.
- I3: export venueAttribution and cover its sanitization directly; add a
stubbed happy-path route test asserting the first-party-brokered
disclosure label reaches the response.
- Minor: drop unused hfWeightsSource end to end, rename a misleading test,
make the OCR capability template's pinning language conditional on the
self-hosted upstream, tighten the /v1/ocr path-prefix guard, and make
preflight's required_lovelace use the same escrowLockFloor the builder
locks (exported from the shared tx barrel for gateway use).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
84 lines
5.3 KiB
Plaintext
84 lines
5.3 KiB
Plaintext
# supplier/.env.chandra.example — Chandra OCR-2 supplier (ocr capability)
|
|
#
|
|
# Copy to supplier/.env.chandra on the host, chmod 600, fill the blanks.
|
|
# TESTNET FIRST: run the full lifecycle (advert → escrow → claim → submit →
|
|
# accept) on testnet before any mainnet value enters this file. Mainnet ops
|
|
# (funding, advert post, container start) are operator-executed.
|
|
#
|
|
# The upstream is any OpenAI-compatible VISION endpoint serving
|
|
# datalab-to/chandra-ocr-2 (vLLM recommended; `chandra_vllm` docker or
|
|
# `vllm serve datalab-to/chandra-ocr-2 --revision <sha>`).
|
|
# LICENSING: the model weights and the hosted API each carry their own
|
|
# terms. Confirm your own licensing position with the model provider before
|
|
# serving commercially.
|
|
|
|
# ── Identity / chain ──────────────────────────────────────────────────────
|
|
SUPPLIER_PRIV_KEY_HEX= # gen-keypair output; NEW wallet, working float only
|
|
NETWORK_ID= # 0 testnet | 1 mainnet — set explicitly, never default
|
|
OGMIOS_URL= # wss://ogmios.vector.testnet... | mainnet equivalent
|
|
ADVERT_REF= # <txHash>#<index> from tx:post-advert (below)
|
|
LIVE_CHAIN= # 1 only when submitting for real
|
|
VECTOR_ZERO_TIME_MS= # per deploy/README (mainnet 1756485600000)
|
|
|
|
# ── Capability ────────────────────────────────────────────────────────────
|
|
CAPABILITY_KIND=ocr
|
|
|
|
# ── Upstream selection ────────────────────────────────────────────────────
|
|
# "datalab" = Datalab hosted document API (v0 deployment, decided 2026-08-06)
|
|
# "openai-vision" = self-hosted vLLM (the attestation upgrade path)
|
|
OCR_UPSTREAM=datalab
|
|
|
|
# ── Datalab upstream (OCR_UPSTREAM=datalab) ───────────────────────────────
|
|
# TERMS: the upstream provider's end-user terms govern how you may use and
|
|
# redistribute output, and they vary by account and plan. Confirm your own
|
|
# position with the provider before serving third parties.
|
|
DATALAB_API_KEY= # provider account key; never commit
|
|
DATALAB_BASE_URL=https://www.datalab.to
|
|
DATALAB_MODE=accurate # fast | balanced | accurate
|
|
DATALAB_TIMEOUT_MS=120000 # submit + poll budget; keep < advert max_processing_ms
|
|
|
|
# ── OpenAI-compatible vision upstream (OCR_UPSTREAM=openai-vision) ────────
|
|
# No /v1 suffix — supplier/src/ocrVision.ts appends /v1/chat/completions.
|
|
# OPENAI_BASE_URL= # e.g. http://chandra-vllm:8000
|
|
# OPENAI_API_KEY= # empty for a local vLLM; token for hosted endpoints
|
|
OPENAI_TIMEOUT_MS=120000 # page inference is seconds; keep < advert max_processing_ms
|
|
# OPENAI_MAX_TOKENS=8192 # optional output ceiling (advert cap applies regardless)
|
|
|
|
# ── OCR extras ────────────────────────────────────────────────────────────
|
|
# Datalab upstream: the pre-Claim probe defaults to per_job liveness against
|
|
# {DATALAB_BASE_URL}/api/v1/health - no further config needed. Set
|
|
# REVISION_PROBE_MODE=off only if you want claims without the health gate.
|
|
#
|
|
# openai-vision upstream only (attestation upgrade path):
|
|
# OCR_PROMPT_OVERRIDE= # exact serving prompt, pinned at integration
|
|
# HF_MODEL_REVISION= # 40-hex checkpoint SHA; mismatch refuses Claim
|
|
# REVISION_PROBE_URL= # e.g. http://chandra-vllm:8000/info
|
|
|
|
# ── Service ───────────────────────────────────────────────────────────────
|
|
PORT=8080
|
|
|
|
# ── Advert posting (run once per network, testnet first) ──────────────────
|
|
# Model string convention: datalab upstream = "datalab/convert-accurate"
|
|
# (honest: hosted engine + mode); self-hosted = "datalab-to/chandra-ocr-2@<sha7>".
|
|
# Endpoint host: your deployed supplier's public HTTPS endpoint (deploy
|
|
# target tracked outside this repo, not in this file).
|
|
#
|
|
# pnpm --filter @marketplace/supplier tx:post-advert -- \
|
|
# --ogmios-url $OGMIOS_URL \
|
|
# --priv-key $SUPPLIER_PRIV_KEY_HEX \
|
|
# --capability-id ocr.page.extract.chandra-ocr-2.v1 \
|
|
# --model "datalab/convert-accurate" \
|
|
# --max-output-tokens 8192 \
|
|
# --max-processing-ms 150000 \
|
|
# --price-lovelace 200000 \
|
|
# --endpoint-url https://<your-supplier-host> \
|
|
# --detail-uri https://<your-supplier-host>/chandra-detail.json \
|
|
# --detail-hash <sha256 of the detail JSON>
|
|
#
|
|
# max_processing_ms 150000 covers DATALAB_TIMEOUT_MS (120s) + chain legs.
|
|
# Price 200000 (0.2 AP3X) is the fleet convention placeholder — a future
|
|
# pricing decision supersedes it. Bonds default to 1 AP3X each.
|
|
# The detail JSON template lives at supplier/chandra-detail.example.json.
|
|
# Testnet: DNS is not required — a direct http://<host-ip>:<port> endpoint
|
|
# works for the testnet advert (retire it after the drills).
|