runner: Add fixed pricing - #3999
Conversation
Add `fixed` pricing for live runners: a single payment charged when a request or session is created, rather than payment metered over time or processed pixels. Support fixed prices in dynamic and static registrations, discovery, remote signers, and orchestrator accounting, documentation and tests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughLive-runner pricing now supports ChangesFixed live-runner billing
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant LiveRunnerAPI
participant LiveRunnerRegistry
participant Orchestrator
Client->>LiveRunnerAPI: Reserve fixed-price session
LiveRunnerAPI->>LiveRunnerRegistry: Fetch session price snapshot
LiveRunnerRegistry-->>LiveRunnerAPI: Return fixed pricing
LiveRunnerAPI->>Orchestrator: Process one-unit payment
Orchestrator-->>LiveRunnerAPI: Return payment result
LiveRunnerAPI-->>Client: Return session endpoint
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/ai_http.go`:
- Around line 539-547: The payment flow in PaymentForLiveRunnerSession must
verify runner readiness before accepting follow-up payments. Add the same
ready-runner gate used by RunnerEndpointForSession before
processPaymentAndSegmentHeaders, ensuring non-ready sessions return 404 and do
not reach ProcessPayment; keep the existing SessionPriceInfo fixed-price
validation afterward.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 060d5118-3ead-4a3c-88e4-a1385b064eef
📒 Files selected for processing (9)
ai/runner/live_runner.goai/runner/live_runner_test.godoc/live-runner.mddoc/remote-signer.mdserver/ai_http.goserver/ai_http_test.goserver/remote_discovery.goserver/remote_signer.goserver/remote_signer_test.go
| priceInfo, err := manager.SessionPriceInfo(runnerID, sessionID) | ||
| if err != nil { | ||
| respondWithLiveRunnerError(w, err) | ||
| return | ||
| } | ||
| if strings.EqualFold(strings.TrimSpace(priceInfo.Unit), "fixed") { | ||
| respondWithError(w, "fixed-price live runner sessions do not accept follow-up payments", http.StatusConflict) | ||
| return | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inspect isReadyStatus usage and the two lookup helpers to confirm the gate difference.
rg -nP -C3 'func \(r \*LiveRunnerRegistry\) (SessionPriceInfo|RunnerEndpointForSession)\b' ai/runner/live_runner.go
rg -nP -C2 'isReadyStatus' ai/runner/live_runner.goRepository: livepeer/go-livepeer
Length of output: 2617
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== server/ai_http.go payment handling context =="
rg -n -C 10 'func .*Payment|ProcessPayment|SessionPriceInfo|RunnerEndpointForSession|follow-up payments' server/ai_http.go
echo "== ai/runner/live_runner.go relevant lock helpers =="
sed -n '930,1095p' ai/runner/live_runner.go | cat -n -v
echo "== Programmatic check: readiness guard presence in helper bodies =="
python3 - <<'PY'
from pathlib import Path
p=Path('ai/runner/live_runner.go')
s=p.read_text()
for name in ['lockLiveRunnerLocked','lockLiveRunner','liveRunnerSessionLocked','SessionPriceInfo','RunnerEndpointForSession','IsLiveRunnerReady']:
print(f'-- {name} --')
idx=s.find(f'func {name}')
if idx==-1:
print('not found')
continue
# crude body extraction until next top-level func
end=s.find('\nfunc ', idx+1)
body=s[idx: (end if end!=-1 else len(s))].splitlines()
print('\n'.join(f'{i+1:4}: {line}' for i,line in enumerate(body) if 'isReady' in line or 'liveRunnerSessionLocked' in line or 'StatusCode' in line))
PYRepository: livepeer/go-livepeer
Length of output: 19316
Add a runner readiness check before accepting live-runner follow-up payments.
SessionPriceInfo delegates to lockLiveRunner, then liveRunnerSessionLocked; that session lookup only checks the runner status inside liveRunnerSessionLocked after the runner has already been selected. PaymentForLiveRunnerSession should gate on a ready runner before processPaymentAndSegmentHeaders, just like the earlier RunnerEndpointForSession path did, so non-ready sessions return 404 instead of proceeding to ProcessPayment.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@server/ai_http.go` around lines 539 - 547, The payment flow in
PaymentForLiveRunnerSession must verify runner readiness before accepting
follow-up payments. Add the same ready-runner gate used by
RunnerEndpointForSession before processPaymentAndSegmentHeaders, ensuring
non-ready sessions return 404 and do not reach ProcessPayment; keep the existing
SessionPriceInfo fixed-price validation afterward.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3999 +/- ##
===================================================
+ Coverage 35.44849% 35.47779% +0.02930%
===================================================
Files 174 174
Lines 45040 45093 +53
===================================================
+ Hits 15966 15998 +32
- Misses 27810 27827 +17
- Partials 1264 1268 +4
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
rickstaa
left a comment
There was a problem hiding this comment.
Code and coverage looks good. Two small nits.
| } | ||
| if sessionPriceInfo.Price.String() != "10" || sessionPriceInfo.Unit != "fixed" { | ||
| t.Fatalf("unexpected static session price snapshot: %+v", sessionPriceInfo) | ||
| } |
There was a problem hiding this comment.
nit: message says what it got but not what it wanted or why.
Add
fixedpricing for live runners: a single payment charged when a request or session is created, rather than payment metered over time or processed pixels.Support fixed prices in dynamic and static registrations, discovery, remote signers, and orchestrator accounting, documentation and tests.
Summary by CodeRabbit
New Features
fixedbilling (bills once).Bug Fixes
Documentation
fixedunits and additional HTTP response codes.Tests