Dipuce

Engineering notes

What keeps the answer honest

switchtender is a small program with a few stubborn habits. Most of them come back to one question. How far can you trust what it just told you?

  1. Unknown is not clear

    When a feed fails, the code hands back null. Never 0. A zero would claim there's no incident and no delay, which is a lie when the feed is simply down. Null admits it couldn't tell, and that's the honest answer.

  2. Trust the live query over the docs

    One routing provider documented its delay fields beautifully. Around DC, every one of them came back zero. Since then, no source gets in until it has answered a real query for the real area.

  3. What didn't make it

    SourceWhy it is out
    MapQuestThe delay fields are documented. On a live query they were all zero.
    DDOT MajorEventNo data after 2017.
    HSEMA road closuresNo data after 2023.
    WMATA GTFS-RTReal time only, so it can't warn you about planned work ahead of time.
  4. Freshness is two tests

    A feed has to prove it's alive. If its newest record isn't from this month, the source is out. After that, each record is judged by whether its window covers the commute. When it was filed doesn't matter. A closure posted last week can still be blocking the road this morning.

  5. A signal has to earn its vote

    Incidents, closures, events and track work all show up in what you hear, and each one costs some confidence. None of them can flip the verdict yet. A signal earns that only once the logs show it actually predicts a slower drive.

  6. No coordinates in source

    Every place lives in a config file that never gets committed. The engine has no idea where anyone lives. If a maintainer's coordinates ever turn up in the example config, a test fails.

  7. Rate limits are real

    Ticketmaster allows two requests a second. Looking up every venue on every run blew straight past that and came back with HTTP 429. Now the venue ids sit in config. Any lookups left over are spaced half a second apart, and a 429 gets exactly one retry, after waiting as long as Retry-After asks.

  8. Cost stays inside the free tier

    Each verdict makes three routing calls. Two verdicts a weekday fit inside the routing API's free monthly allowance. The repo's cost note does the math tier by tier.

  9. Tests never touch the network

    The whole suite runs offline in a fraction of a second. Each new feed arrives with a fixture recorded from the real source, contact details blanked before commit. So the tests see real payloads and never wait on somebody else's uptime.

All of this comes from the public repository atgithub.com/moneymikeMD/switchtender.