fix(byoc): type:byoc payments + capabilities on orch discovery#41
fix(byoc): type:byoc payments + capabilities on orch discovery#41seanhanca wants to merge 2 commits into
Conversation
Use BYOC capability constraints for get_orch_info and /generate-live-payment so the signer can resolve per-cap pricing and usage labels without a legacy capability string field. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughBYOC payment generation now derives capability protobufs from the requested app, passes them to orchestrator discovery, and includes their base64-encoded serialization in BYOC signer requests. Tests cover capability construction, discovery threading, and signer payload encoding. ChangesBYOC payment signing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PaymentFlow
participant OrchestratorInfo
participant Signer
PaymentFlow->>OrchestratorInfo: get_orch_info(capabilities)
OrchestratorInfo-->>PaymentFlow: ticket_params
PaymentFlow->>Signer: generate-live-payment(type byoc, encoded capabilities)
Signer-->>PaymentFlow: payment response
🚥 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 `@src/livepeer_gateway/byoc.py`:
- Around line 193-204: Build `byoc_caps` before the orchestrator discovery call
and pass that same protobuf as the `capabilities=` argument to `get_orch_info`;
retain it for constructing `payment_payload` so discovery and signing use
identical BYOC capability constraints.
🪄 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
Run ID: 74aa7270-c9b2-4860-94ff-2cce17d75c50
📒 Files selected for processing (2)
src/livepeer_gateway/byoc.pysrc/livepeer_gateway/capabilities.py
TicketParams must use PriceInfoForCaps when ByocPerCapPricing is enabled. _create_byoc_payment now threads the same BYOC capabilities protobuf into orch discovery and the signer payment payload. Co-authored-by: Cursor <cursoragent@cursor.com>
Addendum — per-cap TicketParams alignment (Run 33)Prerequisite check for enabling Fix (commit
Tests: Deploy: not run this session — merge + image rebuild pending |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_byoc_payment.py (1)
93-116: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider
next()instead of single-element list slice.Ruff RUF015 flags line 108:
[r for r in reqs if ...][0]is less idiomatic thannext(...). In test code this is cosmetic, butnext()also gives a clearer error if no match is found.♻️ Optional refactor
- signer_req = [r for r in reqs if "generate-live-payment" in r.full_url][0] + signer_req = next(r for r in reqs if "generate-live-payment" in r.full_url)🤖 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 `@tests/test_byoc_payment.py` around lines 93 - 116, Replace the single-element list selection in test_create_byoc_payment_includes_capabilities_on_signer_payload with next() over a generator expression filtering reqs for "generate-live-payment", preserving the existing signer_req behavior while satisfying Ruff RUF015.Source: Linters/SAST tools
🤖 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.
Nitpick comments:
In `@tests/test_byoc_payment.py`:
- Around line 93-116: Replace the single-element list selection in
test_create_byoc_payment_includes_capabilities_on_signer_payload with next()
over a generator expression filtering reqs for "generate-live-payment",
preserving the existing signer_req behavior while satisfying Ruff RUF015.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: caf2c653-7b37-4ced-acec-88168fbaa4dd
📒 Files selected for processing (3)
src/livepeer_gateway/byoc.pytests/test_byoc_payment.pytests/test_capabilities.py
🚧 Files skipped from review as they are similar to previous changes (1)
- src/livepeer_gateway/byoc.py
Summary
submit_byoc_job/_create_byoc_payment: Sendtype:"byoc"with BYOCcapabilitiesprotobuf on/generate-live-payment(no legacycapabilitystring field). Matches John’s c6d312f intent on the inference path.get_orch_info: Pass the same BYOC capabilities protobuf during orch discovery so advertisedCapabilitiesPricesmatch the job constraint.capabilities.py: AddCapabilityId.BYOC+byoc_capabilities_from_app()helper (required onmain).Depends on
type:byocand verify V1 job creds before this path works end-to-end.Test plan
python -m pytest tests/test_capabilities.py(add if missing — manual import check OK)submit_byoc_job(...)with composite bearer → payment 200 → orch 200byoc/flux-schnellnotunknownNote for John
Live-runner (
type:"byoc"inLivePaymentSession) remains onja/live-runner/ bd8e780 lineage — this PR covers one-shot inference only. Stack live-runner change separately when deploying SDK canary.Made with Cursor
Summary by CodeRabbit