Repository navigation
FIX: learned costs survive updates, reset only by a declared cost epoch - #99
Merged
Merged
Conversation
…en a release declares a new cost epoch
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
Why
The server learns what each tool costs in RAM and VRAM (
tool_costs.json), and admission packs runs on the card from it. In the production service that file lived inSCHEMA_CACHE_DIR=/tmp/schema-cache, inside the container. Every update, server or tools, recreates the container, so every update silently forgot every measurement: each tool went back to "unmeasured", reserved the whole budget and ran alone until the table refilled.Change
COST_TABLE_PATH, set forinferenceandinference-cputo/workspace/server/.costs/tool_costs.json: in the bind-mounted checkout, gitignored, beside.historyand.update, which already outlive the container the same way. The update agent onlygit pull --ff-onlys, so it never removes it. Kept separate from the schema cache on purpose: a schema cache is something one deletes to force a regeneration, the cost table cannot be regenerated. Empty, the setting keeps the old location, so other deployments (the venvs image's volume, a plain checkout) do not move. Nothing underdocker/changed.[tool.sadt] cost_epoch = Nin the tool'spyproject.toml(absent = 0). Each entry records the epoch it was learned under; a tool whose declared epoch changed loses its own entry and relearns, the others are untouched. A tool release that does not changecost_epochkeeps everything.costs.TABLE_EPOCH, bumped in a server release to discard the whole table once. Stored as a reserved integer key in the same file, in the same atomic write;known(), the banner,/status, the admin panel and the nested runner never take it for a tool.cost_epochcounts as 0, so every existing table and entry is kept. Acost_epochthat is not an integer is ignored with one warning (a typo must not reset anything, nor take the tool away).ADDING_A_TOOL.md("When a release changes what the tool costs"),docs/INTERNALS.md,server/README.md,.env.example. Bumpcost_epochwhen a release changes what a tool costs (a new model, different input handling), not for every release.Tests
test_cost_table_lifetime.py(new) and two intest_schema_registry.py, each failing before the change: the production services keep the table where a recreate cannot reach it (parses the compose file); two processes with fresh/tmps sharing the persistent path keep every tool's figures (the actual defect); an unchanged epoch keeps everything, a bump drops only that tool, old entries count as epoch 0, a tool not loaded keeps its entry; a server epoch bump discards the table once; the marker is never listed as a tool anywhere; the registry readscost_epochand ignores a non-integer with one warning. Server suite: 1573 passed, knowntest_dev_mountsfailure unchanged.Deployment
The table currently in the running container's
/tmpis lost one last time by the recreate this update causes. It only holds what was measured since the previous update. The server createsserver/.costs/itself; it needsserver/writable by the container user, which.historyand.updatealready rely on, and a warning in the log says so if not.Companion: SADT-VISOR documents
cost_epochin CONTRIBUTING.md and the tool template.