Skip to content

[codex] Preserve marketplace offer prices in policy fields - #20

Merged
jmlago merged 1 commit into
mainfrom
codex/offer-price-observation
Jun 25, 2026
Merged

[codex] Preserve marketplace offer prices in policy fields#20
jmlago merged 1 commit into
mainfrom
codex/offer-price-observation

Conversation

@MuncleUscles

@MuncleUscles MuncleUscles commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

  • make price_in / price_out observation prefer candidate marketplace offer prices over provider-family runtime metrics
  • add a regression test proving two marketplace offers for the same provider/model rank by their own prices even when provider-family metrics disagree

Root cause

Σ_pol field observation read ctx.state.ema[provider|family].price_* before candidate.price_*. For marketplace sources such as AntSeed, that collapsed multiple seller offers for the same family into one provider-family price, so policies could not actually select the cheapest seller/provider.

Validation

  • lua -e 'package.path = package.path .. ";./tests/unit/?.lua"; dofile("tests/unit/price_enrichment.lua")'
  • lua tests/run_lua.lua (564 passed, 0 failed, 0 errors)

Summary by CodeRabbit

  • Bug Fixes
    • Improved price handling so offer-specific prices are preserved when present, instead of being replaced by fallback values.
    • Updated candidate scoring behavior to better reflect marketplace offer pricing, helping the lowest-priced offer rank first when applicable.
  • Tests
    • Added coverage for marketplace pricing and candidate ranking to verify price values remain intact during scoring.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f6eb8838-526d-41d8-b6ae-c2637ceb4031

📥 Commits

Reviewing files that changed from the base of the PR and between 3d49132 and ee22c9e.

📒 Files selected for processing (2)
  • llm_policy/fields.lua
  • tests/unit/price_enrichment.lua

📝 Walkthrough

Walkthrough

price_in and price_out now prefer non-nil candidate values before falling back to EMA-based values. A new unit test checks that marketplace offer prices remain intact and determine candidate ordering during scoring.

Changes

Marketplace price precedence

Layer / File(s) Summary
Price fallback and ranking validation
llm_policy/fields.lua, tests/unit/price_enrichment.lua
price_in and price_out use explicit nil checks before EMA fallback, and a unit test verifies marketplace offer prices survive scoring and control rank order.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hop through prices, neat and clear,
No nils go missing from the rear.
My carrot math now stays in sight,
And marketplace hops rank just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: preserving marketplace offer prices in policy fields.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/offer-price-observation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MuncleUscles
MuncleUscles marked this pull request as ready for review June 25, 2026 10:34
@MuncleUscles
MuncleUscles requested a review from jmlago June 25, 2026 10:34
@jmlago
jmlago merged commit ee31e81 into main Jun 25, 2026
1 check passed
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