<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pablo Bravo</title>
    <description>The latest articles on DEV Community by Pablo Bravo (@pablobravo44).</description>
    <link>https://dev.to/pablobravo44</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4283079%2Fb48dd304-de6d-4a6d-92b7-b0c84c19392a.jpg</url>
      <title>DEV Community: Pablo Bravo</title>
      <link>https://dev.to/pablobravo44</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pablobravo44"/>
    <language>en</language>
    <item>
      <title>How we built a Cloudflare-native US public-records diff engine on TanStack Start, D1, R2 and Socrata</title>
      <dc:creator>Pablo Bravo</dc:creator>
      <pubDate>Fri, 04 Dec 2026 15:19:30 +0000</pubDate>
      <link>https://dev.to/pablobravo44/how-we-built-a-cloudflare-native-us-public-records-diff-engine-on-tanstack-start-d1-r2-and-socrata-4j82</link>
      <guid>https://dev.to/pablobravo44/how-we-built-a-cloudflare-native-us-public-records-diff-engine-on-tanstack-start-d1-r2-and-socrata-4j82</guid>
      <description>&lt;p&gt;Government open-data portals publish a lot of useful business data: contractor licenses, insurance filings, liquor license applications. What they don't publish is &lt;em&gt;what changed since yesterday&lt;/em&gt;. A Socrata dataset is a current-state table. If a roofing contractor's general liability policy moves to a new agency, the row just changes. The old value is gone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://countysignals.com" rel="noopener noreferrer"&gt;CountySignals&lt;/a&gt; exists to keep that history and turn the changes into dated events. This post covers how the pipeline works: one Cloudflare Worker, D1 for state, R2 for raw snapshots, Queues and Workflows for the work, and a pure diff function in the middle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sources
&lt;/h2&gt;

&lt;p&gt;Seven Socrata (SODA 2.1) datasets, read every day:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Adapter&lt;/th&gt;
&lt;th&gt;Portal&lt;/th&gt;
&lt;th&gt;What it gives us&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;wa-li-general&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;data.wa.gov&lt;/td&gt;
&lt;td&gt;Washington contractor licenses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;wa-li-insurance&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;data.wa.gov&lt;/td&gt;
&lt;td&gt;the general liability policy on file: carrier, agency, expiration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;wa-li-principals&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;data.wa.gov&lt;/td&gt;
&lt;td&gt;owners and officers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;wa-lcb-pending&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;data.wa.gov&lt;/td&gt;
&lt;td&gt;pending liquor license applications&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ny-sla-pending&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;data.ny.gov&lt;/td&gt;
&lt;td&gt;New York pending liquor licenses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nyc-dcwp-hic&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;data.cityofnewyork.us&lt;/td&gt;
&lt;td&gt;NYC home-improvement contractors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chi-licenses&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;data.cityofchicago.org&lt;/td&gt;
&lt;td&gt;City of Chicago business license applications&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each adapter declares a query window (for example "policies expiring in the next 60 days, plus policies created in the run window") rather than pulling the whole table. That keeps a daily run to thousands of rows, not millions.&lt;/p&gt;

&lt;h2&gt;
  
  
  One Worker, and a cron that does almost nothing
&lt;/h2&gt;

&lt;p&gt;Everything runs in a single Worker: the TanStack Start app, four queue consumers, three Workflows and a five-minute cron. The cron is the part I was most careful with. It reads D1, finds sources that are due, and sends one message per source to the ingest queue. That's all.&lt;/p&gt;

&lt;p&gt;To keep it that way, every outbound client (Socrata, the crawler, the AI gateway, email, webhooks) calls a guard first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;forbidInScheduled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;what&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;OutboundKind&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;inScheduled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"scheduled.forbidden_call"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;what&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`scheduled.forbidden_call: ${what}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cron body runs inside an &lt;code&gt;AsyncLocalStorage&lt;/code&gt; store, so &lt;code&gt;inScheduled()&lt;/code&gt; is true only for that call stack. Concurrent requests in the same isolate are unaffected. If someone later adds a "quick fetch" inside the cron, it fails loudly in the first test run instead of quietly eating the cron's CPU budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ingest: snapshot first, then decide whether to trust it
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;IngestWorkflow&lt;/code&gt; handles one source per step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Socrata fetch → sanitize → gzip snapshot to R2 → stale-data guard → normalize → D1 upsert → diff → signal_events
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few decisions worth calling out:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Raw snapshots go to R2 before anything else.&lt;/strong&gt; Each run writes &lt;code&gt;raw/&amp;lt;source&amp;gt;/&amp;lt;day&amp;gt;/&amp;lt;run&amp;gt;.json.gz&lt;/code&gt;. If the normalizer has a bug, I can replay any day without asking the portal again. Sanitizing happens &lt;em&gt;before&lt;/em&gt; the snapshot: the Washington liquor dataset includes applicants' birth dates, and those are stripped so they are never stored anywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Socrata client is boring on purpose.&lt;/strong&gt; &lt;code&gt;$limit&lt;/code&gt;/&lt;code&gt;$offset&lt;/code&gt; pagination over a stable &lt;code&gt;$order&lt;/code&gt;, a 250 ms pause between pages, bounded retries on 429 and 5xx, and an injected &lt;code&gt;fetch&lt;/code&gt; so unit tests never touch the network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A stale-data guard decides whether a run counts.&lt;/strong&gt; Open-data portals fail in quiet ways: a dataset returns zero rows for a day, or a column gets renamed. Diffing against a broken snapshot would produce a flood of fake "status changed" events. So every run is checked before it's used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;previousSchemaHash&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;fetched&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;previousSchemaHash&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;schemaHash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"anomaly"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`schema_changed:${previousSchemaHash}-&amp;gt;${schemaHash}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;median&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;med&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;med&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;med&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;fetched&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"anomaly"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zero_rows"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;median&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;med&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;med&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;recent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;med&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;deviation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fetched&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;med&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;med&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deviation&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;DEVIATION_LIMIT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"anomaly"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`count_deviation:${Math.round(deviation * 100)}%`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;median&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;med&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The schema hash covers the field names the portal declares. The row count is compared with the median of the last four good runs, and a deviation over 35% marks the run as an anomaly. Anomalous runs are stored and flagged, but they don't feed the diff.&lt;/p&gt;

&lt;h2&gt;
  
  
  The diff is a pure function
&lt;/h2&gt;

&lt;p&gt;Change Radar (&lt;code&gt;src/lib/pipeline/diff.ts&lt;/code&gt;) takes one normalized record plus the license state D1 held &lt;em&gt;before&lt;/em&gt; this run, and returns a list of events. No I/O. That makes it easy to test with fixtures, including all the awkward cases (a policy renewed on the same day it expired, a carrier name spelled two ways).&lt;/p&gt;

&lt;p&gt;Event types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;new_license&lt;/code&gt; (issued in the last 14 days)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pre_opening_filing&lt;/code&gt; (a liquor or food license application)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gl_expiring_60d&lt;/code&gt;, &lt;code&gt;gl_expiring_30d&lt;/code&gt;, &lt;code&gt;gl_expiring_15d&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;agency_change&lt;/code&gt;, &lt;code&gt;carrier_change&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;status_change&lt;/code&gt;, &lt;code&gt;license_renewal_60d&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Names from government data are inconsistent, so comparisons normalize first: lowercase, strip everything that isn't a letter or digit. "Ohio Cas. Ins. Co" and "OHIO CAS INS CO" are the same carrier.&lt;/p&gt;

&lt;p&gt;The X-date buckets are a small function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;glBucket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daysLeft&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daysLeft&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;daysLeft&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;GL_WINDOW_DAYS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daysLeft&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"gl_expiring_15d"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daysLeft&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"gl_expiring_30d"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"gl_expiring_60d"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Idempotency through the event key
&lt;/h2&gt;

&lt;p&gt;Workflows retry steps, and I sometimes re-run a day on purpose. Re-running must never emit the same event twice, but a &lt;em&gt;new&lt;/em&gt; fact about the same license must emit.&lt;/p&gt;

&lt;p&gt;Each event carries &lt;code&gt;keyParts&lt;/code&gt; built from the triggering fact: the license, the event type, and the value that changed (the new agency, the new status, the X-date bucket and the policy number). They're joined into &lt;code&gt;event_key&lt;/code&gt;, which is &lt;code&gt;UNIQUE&lt;/code&gt; in D1, and events are written with &lt;code&gt;INSERT OR IGNORE&lt;/code&gt;. A policy moving from the 30-day bucket to the 15-day bucket is a new key, so it emits. The same policy seen again tomorrow in the same bucket is the same key, so it doesn't.&lt;/p&gt;

&lt;p&gt;There's one special case on a source's first run, when there is no stored state yet: an agency or carrier switch seen between a contractor's two latest policies counts only if the new policy is at most 45 days old. Otherwise the first backfill would announce years of old switches as news.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dedupe
&lt;/h2&gt;

&lt;p&gt;The same business shows up in several datasets. Washington L&amp;amp;I and the liquor board both carry the state UBI number, so the key is &lt;code&gt;&amp;lt;hub&amp;gt;:id:&amp;lt;UBI&amp;gt;&lt;/code&gt; when one exists, and &lt;code&gt;&amp;lt;hub&amp;gt;:nz:&amp;lt;name without legal suffix&amp;gt;:&amp;lt;zip or city&amp;gt;&lt;/code&gt; when it doesn't. Chains and shell entities are flagged and kept for statistics, but left out of feeds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Delivery
&lt;/h2&gt;

&lt;p&gt;Events land in &lt;code&gt;signal_events&lt;/code&gt;, and the rest of the product reads from there: the web feed, CSV export, saved-search alerts, signed webhooks (one lead per POST, because most CRMs create one contact per call), a REST API, and an MCP server at &lt;code&gt;https://countysignals.com/mcp&lt;/code&gt; with three tools that need no token. All sending happens in queue consumers. The cron only enqueues a &lt;code&gt;tick&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell someone building something similar
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Store the raw snapshot before you parse it. Replays get much cheaper.&lt;/li&gt;
&lt;li&gt;Don't diff against a run you haven't checked. A schema hash and a median row count catch most portal failures.&lt;/li&gt;
&lt;li&gt;Keep the diff pure and make the event key describe the fact that triggered it. Retries stop being scary.&lt;/li&gt;
&lt;li&gt;Treat the cron as a scheduler, not a worker, and enforce it in code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The full description of sources, windows and event rules is on the &lt;a href="https://countysignals.com/methodology" rel="noopener noreferrer"&gt;methodology page&lt;/a&gt;. If you work with Socrata data and handle schema drift differently, I'd like to hear how.&lt;/p&gt;

</description>
      <category>cloudflare</category>
      <category>typescript</category>
      <category>opendata</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
