Repository navigation
fix(models): say model edits do not survive a restart, and log every override - #441
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The admin model editor lets an operator change a price or add a model, and the next startup undoes it:
db::seed_modelsre-assertsconfig.toml's[[models]]over every price column and deletes every row config does not contain. Measured ondb0160fin #440: an edited price reads back as its config value after a restart, and an added model disappears entirely.Both halves of this fix are about visibility, not precedence.
1. The panel stops promising something the server undoes.
admin.models.subsaid edits "take effect immediately" and said nothing about a restart — the opposite of what happens. It now says thatconfig.toml's[[models]]is the authoritative source, that a price changed in the editor and a model added there are overwritten at the next startup, and that an added model's row is deleted. Both language packs, the HTML default text, and the sentence inui/README.mdthat repeated the same claim are updated;js/i18n.js's cache-bust token moves with them.2. The startup seed stops being silent.
seed_modelsis split into a reporting function and a thin logging wrapper. For every row whose stored price differs from the config value it emits oneWARNnaming the model and each changed column asold -> new; for every row it deletes it emits oneWARNnaming the model. The existing INFO summary line keeps its shape and gains the override count, so the two numbers an operator cares about sit on one line.What this PR deliberately does not do: it does not decide which source wins. #440 leaves two ways out — make the write honest (this PR), or stop re-asserting prices over rows that already exist — and the second is a change of pricing authority that belongs to the owner. That question is left open in #440, so this PR names the issue without closing it.
Money impact
No arithmetic changes, no stored row rewritten, no bill moves.
usage_recordsandtransactionskeep whatever they were settled at; nothing here touches settlement,dao::get_model_price, or the router's pricing gate. What changes is that the operator is told the truth in the panel, and the startup log records each override with its figures.Evidence on a real binary
Temp data dir, temp config, admin API only — nothing near a real deployment.
Run 1:
PATCH /api/admin/models/9 {"input_per_m": 1.23}, thenPOSTaprobe/probe-model-x.input_per_m(claude-opus-5)5.01.23Run 2: SIGTERM, restart on the same data dir.
input_per_m5.0(restored)And the restart's own startup log now says why. The process logs in Chinese, like the rest of this repository's logs, so these three lines are carried here in English translation:
A startup over an untouched database reports
0 rows of prices overwritten, 0 config-removed rows deletedand emits no warning — the warnings are not noise on every boot, and that half is asserted by a test rather than by this paragraph.Tests
db::tests::seed_models_reports_the_prices_the_config_overwrites— seeding an unchanged database reports nothing; after an admin-styleUPDATE models SET input_per_m = 1.23the next seed reports exactly that one column as1.23 -> 4.5, the message carries both figures and names the model, and a third seed is quiet again.db::tests::seed_models_reports_the_rows_it_deletes— a row config does not contain is reported by name and really deleted, and a deletion is not reported as an override.cargo fmt --checkclean,cargo clippy --all-targets -- -D warningsclean,cargo test588 passed, 0 failed (baseline 586 plus the 2 new tests).Boundary
PriceOverridecompares the seven scalar price columns and the currency. It does not comparetiers_json: tier prices are a config-only field the admin interface does not express (patching a row clears it to[]), and rendering that JSON in the startup log is not a figure a reader can use. The override of tier prices still happens; it is simply not part of this warning.Refs #440 — the precedence question stays open there for the owner.