Repository navigation
feat(gateway): measured switch costs, /v1/berth/cost and /v1/berth/plan - #102
Merged
Merged
Conversation
…swap book The gateway owns one swapcost.Book (CostFile, empty keeps it in memory) and records the switch the package defines: from the lease grant its run printed to the engine answering, never from the request, so a wait behind the holder or the juggle guard is not billed to the engine. The tier comes from the position read when the start is decided: parked from the lease table, cool or cold from the page cache's share of the engine's prefetch files. Failed starts record nothing; book load and save errors log WARN and the gateway keeps going.
…ed switch times One estimate per tier, known false where the book has no samples, so a figure it gives is one it measured. An engine berth.toml does not name is a 404 and a missing engine parameter a 400, behind the same key and Origin checks as the other /v1 routes.
The body names one step per engine the orchestrator plans to switch through, with the tier it expects to find each in. The answer carries the per-step estimate, the lower-bound total with its unmeasured count, the per-step prefetch, and the engines worth keeping parked. A bad body, an empty chain, an unknown tier or an engine outside the config is a 400 naming what is wrong.
…ecorded sample Table-driven httptest for the two routes: known and unknown estimates, hot as the free switch, the 404 and every 400 naming what is wrong, and the key and Origin refusals. One fake start through the test daemon and the fake runner: exactly one sample, on the cold tier, and elapsed minus took shows the queue before the grant stayed out of the sample.
README gateway section: what a switch costs, one curl example per route. CHANGELOG entry under Unreleased. The gateway half of the v0.3.x list item is done, the live-daemon half stays.
… gateway cannot time
Merged
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.
OME QCPJEEG. Stacked on #101: merge #101 first, then retarget this to main.
~/.local/state/berth/swapcost.json. Failed starts and adopted engines record nothing.GET /v1/berth/cost?engine=NAME: one estimate per tier;known:falsemeans no samples, never a guess.POST /v1/berth/plan: swapcost.Plan for a declared chain, with a lower-bound total, the unmeasured count, per-step prefetch and keep_parked. 400 on an empty chain, an unknown tier or an unknown engine.Proof: build, gofmt, vet,
go test ./...,go test -race -count=3 ./internal/gateway, GOOS=windows build and vet, golangci-lint v2.14.0: all green locally.