Inspiration

Every public health analysis starts the same way: find data, check that you're allowed to use it, and join it to population counts so you can compute a rate. Coding agents are fast at the first step and bad at the other two. They hand back a Hugging Face copy whose license differs from the original, or write a join on FIPS codes that silently loses every county in Alabama. None of that shows up in a keyword search. The answer is in the relationships between datasets, which makes it a graph problem.

What it does

foxgraph is a graph of about 2,000 datasets from data.cdc.gov, health.data.ny.gov, the Census Bureau and Hugging Face. It records three things for each one:

  • License, checked along lineage. Each Hugging Face mirror is linked to the portal dataset it was copied from. A dataset's commercial-use status is the most restrictive license along its DERIVED_FROM chain. 110 mirrors of CDC data are labeled ODbL, a share-alike license, while the originals are public domain or federal data with no license stated.
  • Join keys. Columns are tagged as county FIPS, state, ZIP, census tract and so on, with risk flags like "stored as a number, leading zeros lost". 48 columns have that problem.
  • Verified joins. verify fetches the real key values from both sides and measures the match rate before and after cleanup. It writes the result back as a JOINED_WITH edge plus notes, so the next agent starts with what the last one learned.

Agents use it through an MCP server (7 tools) or a Claude Code skill. People use it through a CLI or the browser explorer at foxgraph.debugr.net, which runs Relate in WebAssembly.

The 27 tested joins found real problems:

  • Naive joins drop 9 to 10% of US counties because of lost leading zeros.
  • A CDC overdose table has a decoy countyfips column holding only 3 digits next to the real fips column. verify tries both and records which one works.
  • CDC's ozone and PM2.5 tables store only the county half of the code, so a direct join matches 0%. Putting statefips in front brings it to 99.7%.
  • Two NY tables have a county_code that isn't FIPS at all. foxgraph records "no join" and points to the name column instead.
  • County names are matched within each state, because 30 states have a Washington County.
  • Connecticut replaced its counties with planning regions in 2022, which breaks county joins in almost every dataset.

How it was built

  • Relate, single-file mode. The store is data/foxgraph.rl, committed to the repo. Agents open it in process with no server. Read-only opens let several agents query at once, and contributions take Relate's single writer only for one short transaction.
  • Vector search with pre-filtering. Dataset descriptions are embedded locally with bge-small (no API keys). SEARCH ... WHERE d.effective_commercial IN $ok filters on the lineage-derived license status before ranking.
  • Graph traversal. DERIVED_FROM*1..6 computes effective licenses. Join plans come from two datasets' columns pointing at the same KeyType node.
  • Transactions. verify writes the join edge and its notes atomically. Identical notes from different agents are merged with a confirmation count.
  • Ingest in Python from the Socrata Discovery API, the Hugging Face Hub API and the Census popest CSV. Raw metadata is cached in the repo, so foxgraph build rebuilds the store offline.
  • Browser explorer. Relate WASM (@relate/relate-wasm) loads a 2.2 MB snapshot into memory. Every view runs Cypher and shows the query and its timing.
  • Shared knowledge without a server. Every contribution is also appended to data/contributions.jsonl, which the build replays. Sharing what your agents learned is a pull request.

Challenges

  • Metadata lies. A column called countyfips can hold 5-digit codes, 3-digit codes or a state's own numbering. Detection from metadata is only a guess, so verify tests every candidate column on real values and repairs what it can.
  • Relate's browser build can't open a .rl file, only in-memory or OPFS stores. We export a compact JSON snapshot at build time and load it into Relate WASM.
  • Store size. The first build was 75 MB. Flushing after each bulk phase brought it to 33 MB.
  • The Census API now needs a key. We switched to the Census Bureau's keyless county population CSV so judges don't need an account.
  • TLS. data.cdc.gov's certificate chain fails with Python's bundled CA list, so requests use the OS trust store.

Accomplishments

  • The findings are real and checkable. Every number in the README comes from a query or a measured join you can rerun.
  • An agent's work outlives its session: a verified join becomes graph structure the next agent queries directly.
  • One file holds everything. Clone the repo and the Python package, the Relate CLI and the browser all read the same data.

What was learned

  • Licensing questions about data are lineage questions. The license on the copy you found is often not the one that matters.
  • Pre-filtering vector search on a property computed from graph traversal combines semantic search with hard constraints cleanly. You never rank results you'd have to throw away.
  • Most join failures are not exotic. Leading zeros, half keys and repeated names cover most of what we found.

What's next for foxgraph

  • Verify joins on Hugging Face datasets directly, not only their portal sources.
  • More portals: other states' Socrata portals and CMS.
  • A crosswalk for Connecticut's planning regions and NYC borough names.
  • A CI check that validates contribution pull requests before merging.

Built With

Share this project:

Updates

Submission history