fix(core): reject broker and trading pages that would misreport a session

From the 0.4.0 release review (Codex):
- IPOT pages with a short row, a rank out of order or a broker after a
  blank row are parse errors; skipping a row shifted later brokers up a
  rank and could flip a bandar reading (-2425 bps to -66 bps).
- A tbody end before its start is a parse error, not a panic.
- An IPOT page that echoes other dates than requested is rejected before
  it is cached, so one session's figures never pass as another's.
- An IDX trading summary with rows for other days only is an error, not
  an empty session cached for 30 days.
- Empty sessions count toward a flow's fetched_at and stale.
- The bandar imbalance uses checked i128 arithmetic: past i128 there is
  no reading instead of a wrapped one.
- The bandar table prints "No trades." only when no broker traded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
hermes 2026-10-18 11:48:00 +00:00
commit d82f7c6be9
6 changed files with 137 additions and 19 deletions

View file

@ -104,6 +104,9 @@ impl Flow<'_> {
Err(IdxError::CacheMiss(_)) if skip_misses => continue,
Err(err) => return Err(err),
};
// Every consulted session counts toward freshness, empty ones too.
fetched_at = Some(fetched_at.map_or(fetch.fetched_at, |at| at.min(fetch.fetched_at)));
stale |= fetch.stale;
match fetch.day {
Day::NoSession => continue,
Day::Absent => {}
@ -116,8 +119,6 @@ impl Flow<'_> {
}
}
sessions += 1;
fetched_at = Some(fetched_at.map_or(fetch.fetched_at, |at| at.min(fetch.fetched_at)));
stale |= fetch.stale;
}
if sessions == 0 {
return Err(if policy == CachePolicy::Offline {