Aller au contenu
login
arrow_backRetour aux issues
Wayfare-labs/wayfare #21

ladder -replay: re-run a past measurement offline

ecoDébutant help wanted area:pricing difficulty:medium

descriptionDescription

### What Add `-replay ` to `cmd/ladder`, so a past measurement can be re-run offline from a recorded snapshot and produce the same table and the same `-json` output it produced when it was captured. (Go's `flag` package accepts `-replay` and `--replay` identically; the repo's existing flags are single-dash, e.g. `-json`, `-to`, `-sizes`.) ### Why it matters Right now a corridor measurement is unreproducible by anyone but its author, at the moment they ran it. Every figure in `docs/corridor-measurements.md` is a claim a reader has to take on trust, because re-running `ladder` today measures today's market — which is a different market, and on a corridor this thin, possibly a very different one. `-replay` turns each of those claims into something a reviewer can execute. It also makes the ladder demonstrable with no network at all: in a talk, on a plane, in a CI job, or in front of someone evaluating the project who should not have to hope Horizon is up during the two minutes they are looking. There is a bonus that falls out for free: replaying an old snapshot and a new one through the same code path is how you find out whether a difference is the market moving or the engine changing. ### Where to start - **Depends on #19** for the snapshot format and the replaying `RoundTripper`. - `cmd/ladder/main.go` — flags are parsed in `main`, and the engine is constructed there as `&route.Engine;{DEX: &dex.Client;{}, RefRate: &refrate.Checked;{Inner: &refrate.ExchangeRateAPI;{}}}`. Replay should swap the transports underneath those, not introduce a parallel engine — a second construction path is a second thing to keep honest. - `route/wire.go` — `ToCorridorJSON` is the shared wire shape for both `-json` and the HTTP API. Replay must go through it, not around it. - `printTable` / `printJSON` in the same file are where the replay banner belongs. ### Acceptance criteria - [ ] `go run ./cmd/ladder -replay ` reproduces the recorded run with **no network access** — verifiable by running it with networking disabled - [ ] Text output states, prominently, that it is a replay and shows the snapshot's recorded-at timestamp and reference-rate source - [ ] `-json` output carries the same, as explicit fields (e.g. `replayed_from`, `recorded_at`), so a downstream consumer cannot mistake a replay for a live measurement. **A replay must never be presentable as a live reading** — that is the project's central invariant, and this flag is the most likely place to breach it - [ ] `-replay` combined with a `-to` or `-sizes` the snapshot does not contain fails with a clear error naming what is missing, rather than silently measuring live - [ ] Replaying the same snapshot twice produces identical output apart from documented clock-derived fields - [ ] Money stays decimal strings through the replay path; no `float64` - [ ] A test replays a committed snapshot and asserts the resulting `CorridorJSON` - [ ] `make test` green; `go test -race ./...` clean ### Verify before you build None external — this is Wayfare's own snapshot format. Confirm with #19 that the manifest records enough to reconstruct the request set (corridor, sizes, Horizon base URL, provider name); if it does not, that gap belongs in #19 rather than being worked around here. **Difficulty:** medium Blocked on #19.
codeOuvre sur GitHub