feat: ready to submit, a run to watch, the README, the review's fixes

Sprint 08 (roadmap/08. ready to submit.md), the last milestone.

- scripts/watch.sh runs the collector with a live view of its log, stops
  cleanly on Ctrl-C, then checks the output (reconcile) and shows one
  symbol's book as text (show, a new binary).
- The README for the solution, with the final runs: Polymarket through an
  outage it recovered from on its own, Kalshi's demo with two slow
  connections recycled.
- From a review of the whole codebase: Kalshi takes RSA keys too
  (RSA-PSS-SHA256); a slow Kalshi connection takes the hourly recycle's
  next turn, which it nearly never got before; a market tracked again no
  longer fails reconcile; Book::add checks for overflow; usage and --help
  name the key variables; the first scan says how far it got.
- Tests for every gap the reviews found, an offline run of the whole
  orchestrator among them; ShellCheck in CI.
This commit is contained in:
pascal committed 2026-11-12 22:32:39 +01:00
1 parent 515e85941d
commit cf6c16c9cf
35 files changed
+2791 -207

No files matched your search

+8 -3
View File
@@ -237,9 +237,14 @@ is the demo's.
`api.elections.kalshi.com` and `demo-api.kalshi.co` still answer.
- **Auth:** the websocket handshake carries `KALSHI-ACCESS-KEY` (the key id),
`KALSHI-ACCESS-TIMESTAMP` (ms) and `KALSHI-ACCESS-SIGNATURE`: base64 of the
Ed25519 signature of `<timestamp>GET/trade-api/ws/v2`. Without them: 401.
The market listing needs no key. Keys are created per environment
(Account → Profile → API Keys); the private key is a PKCS#8 PEM shown once.
signature of `<timestamp>GET/trade-api/ws/v2`. Without them: 401. The
key is Ed25519 (RFC 8032 over that text) or 2048-bit RSA (RSA-PSS,
SHA-256, MGF1 SHA-256, a salt of the digest's length); Kalshi picks the
check from the public key it holds, and a PEM's header doesn't say which
(an RSA key may be PKCS#1, as Kalshi gives it, or PKCS#8; Kalshi's API
keys page, read 2026-11-12). The market listing needs no key. Keys are
created per environment (Account → Profile → API Keys); the private key
is shown once.
- **Subscribe:** `{"id":1,"cmd":"subscribe","params":{"channels":
["orderbook_delta"],"market_tickers":[...]}}` is answered
`{"type":"subscribed","id":1,"msg":{"channel":"orderbook_delta","sid":1}}`,
+4 -4
View File
@@ -161,11 +161,11 @@ schema debate). As settled in sprints 04 and 05:
- The **orchestrator** owns what is tracked (each market's two connections,
the timers) and decides: placing, moving, splitting, and recycling one
connection at a time, about hourly, and sooner a Kalshi connection whose
mean lateness stays above twice everyone's (sprint 07, LATENCY.md). It
never blocks on HTTP.
connection at a time, about hourly; a Kalshi connection whose mean
lateness stays above twice everyone's takes the next turn, in place of
the oldest (sprints 07 and 08, LATENCY.md). It never blocks on HTTP.
- The two **fetchers** only page the exchange's market listing on request
and stream what they read.
and send on what they read.
- A **connection** reads, stamps the receive time, parses, and routes each
event to the book thread of its market. Every symbol is on two connections,
chosen independently. One silent for 30 s reconnects.
+19 -4
View File
@@ -91,11 +91,17 @@ abstraction is *extracted* once a second exchange exists, not designed up front.
The source port can't be chosen here (a NAT rewrites it); first after
maintenance wasn't tried.
8. **Polish + submission** — *not started*
Final review, README for the solution (the template's README still says the
helpers are "demonstrated in `main.rs`", whose demo M1 replaced),
packaging/handoff for the challenge.
8. **Polish + submission** — *done (2026-11-12)*
A review of the whole codebase and its fixes, a run anyone can watch
(`scripts/watch.sh`, `show`), the README, final runs of both
exchanges, and the handoff as a public repo on git.pband.ch.
Sprint: [../roadmap/08. ready to submit.md](../roadmap/08.%20ready%20to%20submit.md).
*Ends:* ready to submit.
Result: Kalshi takes RSA keys too; the slow recycle, which the hourly
one nearly always pre-empted, now takes its turn and acted twice in 20
live minutes; a market tracked again no longer fails `reconcile`; 19
surviving mutants got their tests. Both final runs reconciled, one
through an outage of about two minutes (sprint 08's Outcome).
## Why this order
@@ -155,3 +161,12 @@ abstraction is *extracted* once a second exchange exists, not designed up front.
- Judging the connections' speed at the book threads' wall-clock minute,
not on the orchestrator's own timer (a judgment near the crossing sees
partial samples; sprint 07's review).
- Kalshi: a resync asked from a connection the symbol has since left stays
asked there while the other connection is down (sprint 08's review; rare,
and the resync count grows each minute).
- Paging Kalshi's listing in parallel: on 2026-11-12 the demo served a page
of 1,000 markets in 1.7 s, so the first scan took 7.5 minutes (under one
in sprint 06).
- Connecting to each of the exchange's addresses in turn, not only the
first the lookup returns (a host with IPv6 DNS but no IPv6 route would
never connect; sprint 08's review).