Repository navigation
feat: save-more config — every shipped preset, priced and checked against history - #538
Conversation
OsherElhadad
left a comment
There was a problem hiding this comment.
Review: REQUEST CHANGES at 7102c2c (one blocker). (Posted as a comment: GitHub does not let the author account request changes.)
Blocker: a preset option is priced on a different config than the one apply stores.
- The preset arms are built from
adaptSpecFromDoc("preset: " + name + "\n"), so the replay runs the preset's own tuned blocks. adaptPresetDoc, the apply path, keeps the account's existingcomponents:blocks and only setspresetand dropspipeline. The loader lets those user blocks override the preset's.- I checked this with
config.LoadBytes:preset: housegivesextract.min_tokens400, whilepreset: houseplus a userextract: {min_tokens: 9999}gives 9999. - So for any account with a tuned block for a component in the chosen preset, the option's price, range and recommendation describe something other than what gets applied.
- Fix: build each preset arm from the same document apply will store, i.e. curDoc with
preset: <name>set andpipelineremoved (shareadaptPresetDoc's transform). Alternatively, have apply drop the user blocks for components the preset tunes. Add a round-trip test: apply, load, and require the same effective pipeline and settings as the replayed arm.
What I checked and found correct:
- The reproduction check is not circular.
run.replayis the raw replay, cached inpop.raw. The declaration, expand and unseen charges are added only ineval.ObservedUSDsumsr.observedover exactly the covered requests inpop.sessions, so both sides share one denominator and one pricing. Withreplayswapped foreval(which includes the unseen charge), TestSaveMoreReproductionGatesTheRecommendation fails. range_usd. The low end is the net. The high end is the net plus the refunded unseen charge, plus any gain over current scaled by the share of current's booked savings the replay sees, clamped at no less than 0.2. That is bounded, and documented on the field.- Preset replay. A preset plus an explicit pipeline keeps the preset's tuned blocks (house's
extract.min_tokens400 survives). Model components are listed innot_replayed, and such options are classestimate. TestSaveMorePricesEveryShippedPreset pins both. neighbours()swaps only adjacent candidates, and never across a non-candidate the account runs. TestSaveMoreCustomSearchOrder pins it.- Stale user blocks for components outside the new preset's pipeline load harmlessly. The apply stores
preset:with nopipelinekey and leavesmodeand the rest of the document intact. The cache block is untouched, and the per-kind revert works.
- Expand credit. An arm with no offloader is credited the recorded expand round trips at the repeat rate, as a negative delta. The sign is right and it is labelled in the method text.
- Checks.
go vetis clean. The dashAdapt|SaveMoretests and the proxyAdapt|SaveMoretests pass, and CI is green. The commit is signed off with no AI attribution, and the PR text has no experiment figures.
On the flaky TestKeepAliveStrategyControlRoutesResolveLiveWithNoRestart, the bug is in main's test, not in the product. The fixture's "all-day" window is 00:00–23:59. Window.contains treats End as exclusive, and the default TZ is Asia/Jerusalem (UTC+3 in October). So at 20:59 UTC, which is 23:59 local, the window does not match. The product documents 24:00 as the end of the day; the fixture should use "end":"24:00".
OsherElhadad
left a comment
There was a problem hiding this comment.
Re-review: APPROVE at 9837078 (8003752 + 9837078 on top of 7102c2c). (Posted as a comment: GitHub does not let the author account approve.)
- The blocker is fixed. Pricing and apply now go through one function,
dash.AdaptPresetDocWith. A preset arm is priced on exactly the document apply stores: the current config withpresetset,pipelineremoved, and the account's blocks kept. Removing that sharing breaks tests:- Pricing the bare
preset: <name>again makes TestSaveMorePricesThePresetDocumentApplyStores and TestSaveMoreOffersThePresetWithoutTheAccountsOverrides fail. - Applying with the overrides kept makes TestSaveMoreAppliesThePresetWithoutOverrides fail.
- Pricing the bare
- " without your overrides". This arm is offered only when the account's blocks change that preset. It drops only the account's blocks for components the preset runs that are replayable. The tool removal list, model components, components outside the preset and every other top-level key, cache settings included, are kept. It is priced on its own stored document, its option detail and recommendation say which settings it removes, and it goes through the normal offer, basis and revert path.
- No regressions. The reproduction check,
range_usdand the expand credit are unchanged since 7102c2c. gofmtandgo vetare clean, and the dash and proxy SaveMore/Adapt tests and./configpass. CI is green, both commits are signed off with no AI attribution, and the PR text carries only the product's own thresholds.
Approved. This approval covers 9837078.
…lay against history The compaction report now prices every shipped preset as an option (ids are the preset names), adds the bounded custom search with custom=1, and returns the savings to date with the current configuration, observed from the request rows on every priced request in the window. Before anything is recommended, the replay of the current configuration must reproduce what the rows booked for it on the same covered requests within 15% (or $0.05); otherwise the figures are shown and nothing is recommended. Each option carries a range that refunds what the replay is known to miss, its model components (excluded, class "estimate"), and the expand round trips it avoids. Applying a preset stores `preset: <name>` and keeps the rest of the document. GET /api/save-more/config and POST /api/save-more/config/apply serve the same report and offers. Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
…change its result Signed-off-by: Osher-Elhadad <[email protected]>
9837078 to
f6965f0
Compare
Stacked on #528 (base
feat/adapt-compaction). Backend for/context-guru:save-more config; the command and its rendering are in the plugin PR.What it does
GET /api/adapt/compaction(alsoGET /api/save-more/config):config.PresetNames()), pluscurrent,defaultandnone. Each is replayed on the account's stored requests with the same engine and pricing as before: gross per request, cache reads and writes at the tier billed, re-sends and prefix busts, sessions read from their start, the expand declaration, and the expand round trips an option with no offloader avoids.class: "estimate", itsnot_replayedlists them, anddetailsays so.range_usdbrackets each figure: the low end keeps every conservative assumption, the high end refunds the unseen-saving charge and scales any gain over the current configuration by how much of the current configuration's booked saving the replay reproduces.custom=1adds the bounded search over which deterministic components run, their order and two thresholds (as in feat: adapt compaction report and apply (hosted and local) #528), on top of the presets.to_date/observed: the savings to date with the current configuration, from the request rows on every priced request in the window (booked token counts re-priced at the gateway rates the replay uses).reproductioncompares the replay of the CURRENT configuration (before any unseen-saving charge) with what the rows booked for it on the same covered requests. If they differ by more than 15% (and more than $0.05), the figures are shown and nothing is recommended.gain_usd,gain_range_usd,gain_window_usd_est(scaled to the window, labelled an estimate) andper_week_usd.POST /api/adapt/compaction/apply(also/api/save-more/config/apply): a preset option storespreset: <name>without an explicit pipeline and keeps the rest of the document; custom options as in #528. Revert, identity, offers and limits are #528's.Tests
TestSaveMorePricesEveryShippedPreset): present, priced, range brackets the figure, model components listed and the class set, applying it switches to the preset, a preset with format saves on JSON content and a preset with nothing replayable saves nothing.TestSaveMoreCustomSearchOrder): only candidates move, neighbouring candidates swap, a non-candidate keeps its place, and custom adds to the presets.TestSaveMoreReproductionGatesTheRecommendation): a faithful history reproduces; the same history booked at ten times its real saving does not, and nothing is recommended.TestSaveMoreAppliesAPresetAndRevertsIt).go test ./dash/ ./proxy/ ./components/... ./cmd/... ./tenant/ ./config/passes.