Skip to content

Keep Piebald usage loading when no service-tier table exists - #284

Merged
mike1858 merged 1 commit into
mainfrom
fix/piebald-tier-without-settings-tables
Oct 19, 2026
Merged

mike1858 merged 1 commit into
mainfrom
fix/piebald-tier-without-settings-tables

Conversation

@mike1858

@mike1858 mike1858 commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Why

On a current Piebald database every scan of app.db fails, and Piebald reports no usage at all:

Failed to parse Piebald source ".../piebald/app.db": no such table: override_gen_cfg_data_openai_responses

Tier detection knew only two places a service tier could live. It treated "the per-profile settings tables are missing" as "this is an older database" and joined the per-turn override tables instead. A database that has moved past both keeps neither. The tier only adjusts pricing, but the failed join aborted the whole query, so the TUI, stats, and uploads all lost every Piebald message.

What changed

  • Each tier source is detected by its own storage, in order: per-profile settings tables, per-turn override tables, then a custom_override_fields column on profiles. A missing source is never joined.
  • With only custom properties, the tier is the chat profile's service_tier property, which Piebald merges into the request body as-is. As before, the chat's own (possibly hidden) profile is used.
  • Malformed JSON or a non-string value prices at standard rather than failing the query.
  • A database with no tier source at all prices at standard instead of failing.
  • Layouts with typed tier storage are untouched.

Pricing note

A database that moved from typed settings to custom properties no longer records the earlier typed tiers, so those turns now price at standard, already-uploaded ones included (same global_hash, new cost).

Validation

  • cargo test (503 passed), with new fixtures for a custom-property tier, eight unusable property values, and a database with no tier storage
  • cargo clippy -- -D warnings, cargo doc, cargo fmt --check
  • Read-only against a real Piebald database: v3.11.1 fails as above, while this branch loads every conversation. On a snapshot taken before the layout change, Piebald stats are byte-identical to v3.11.1's. Across 275 days, messages, tokens, and tool calls match, and cost differs only on the days that had non-standard-tier turns.

Summary by CodeRabbit

  • Bug Fixes
    • Improved service-tier pricing for conversations in Piebald layouts without typed settings. Valid custom profile tiers are now applied to pricing, including the tier from a chat’s hidden profile.
    • Conversations without a usable custom tier, or without a tier source, are priced at Standard instead of failing to parse.
    • Preserved existing pricing behavior when typed settings are available, including precedence for Responses settings over Completions settings.

Tier detection treated a database without per-profile settings tables as
an older one and joined the per-turn override tables instead. A database
that has moved past both keeps neither, so every read failed with "no
such table" and all Piebald usage disappeared, although the tier only
adjusts pricing.

Detect each tier source by its own storage: per-profile settings, then
per-turn overrides, then the chat profile's custom `service_tier` request
property, which Piebald merges into the request body as-is. Unusable
property values price at the standard tier, as does a database with no
tier source at all. Layouts with typed tier storage price exactly as
before.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b663bf0-6a01-42d3-af77-9184184964fe
📥 Commits

Reviewing files that changed from the base of the PR and between 2041926 and de1b62b.

📒 Files selected for processing: 2
  • src/analyzers/piebald.rs
  • src/analyzers/piebald_schema_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Walkthrough

The Piebald analyzer now detects profile custom fields and missing tier sources. It reads custom-field service tiers from the chat’s profile when the value is valid, and uses standard pricing when tier data is absent or invalid. Tests cover these layouts and existing typed-source precedence.

Changes: Piebald tier-source handling

Layer / File(s) Summary
Detect and read tier sources
src/analyzers/piebald.rs
Layout detection selects profile settings, generation configs, profile custom fields, or an unrecorded source. Message queries use the selected source; custom-field tiers require valid JSON with a string-valued service_tier.
Verify tier pricing across layouts
src/analyzers/piebald_schema_tests.rs
Tests cover priority pricing from the hidden profile, standard pricing for absent or invalid custom tiers and missing settings tables, and folded-generation-config pricing.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: jimyag

Merge Risk: ⚪ Minimal · up to de1b6

This change lets Piebald usage load on databases that lack a service-tier table. Layouts with typed tier storage are unchanged. No merge-blocking risk was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the primary change: preserving Piebald usage loading when no service-tier table exists.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@mike1858
mike1858 merged commit 499be37 into main Oct 19, 2026
8 checks passed
@mike1858
mike1858 deleted the fix/piebald-tier-without-settings-tables branch October 19, 2026 16:31
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.

1 participant