diff --git a/public/blog-assets/introducing-tanstack-oracles/examples-and-laws.png b/public/blog-assets/introducing-tanstack-oracles/examples-and-laws.png new file mode 100644 index 000000000..d16beabe7 Binary files /dev/null and b/public/blog-assets/introducing-tanstack-oracles/examples-and-laws.png differ diff --git a/public/blog-assets/introducing-tanstack-oracles/examples-and-laws.svg b/public/blog-assets/introducing-tanstack-oracles/examples-and-laws.svg new file mode 100644 index 000000000..6f9eab37c --- /dev/null +++ b/public/blog-assets/introducing-tanstack-oracles/examples-and-laws.svg @@ -0,0 +1,66 @@ + +Selected examples. Generated histories. +A conceptual comparison, not a coverage measurement. Unit tests check handpicked examples with expected answers written by the developer. TanStack Oracles checks laws across generated sequences of changes and compares real code with an independent model. Both panels show the same dotted boundary between allowed and forbidden behavior. The dots illustrate selected examples on the left and a broader sample of generated histories on the right. Neither panel claims exhaustive coverage. + + + + + + + + + +Selected examples.Generated histories. +A single law can check many generated sequences of changes. + + + +Unit Tests + +EXAMPLE-BASED + + +01 +Choose examples to test + +02 +Write their expected answers + +03 +Add cases as you discover bugs + +Selected examples + + + + +TanStack Oracles + +MODEL-BASED + + +01 +State the behavior as a law + +02 +Generate sequences of changes + +03 +Compare code with an independent model + +Generate histories → compare code +with an independent model + + + + +Allowed example + + +Forbidden example + + +Law: allowed behavior + +Conceptual illustration · not a coverage measurement + diff --git a/public/blog-assets/introducing-tanstack-oracles/header.png b/public/blog-assets/introducing-tanstack-oracles/header.png new file mode 100644 index 000000000..21f9358d8 Binary files /dev/null and b/public/blog-assets/introducing-tanstack-oracles/header.png differ diff --git a/public/blog-assets/introducing-tanstack-oracles/headroom-header-height.gif b/public/blog-assets/introducing-tanstack-oracles/headroom-header-height.gif new file mode 100644 index 000000000..68f1bc6ed Binary files /dev/null and b/public/blog-assets/introducing-tanstack-oracles/headroom-header-height.gif differ diff --git a/public/blog-assets/introducing-tanstack-oracles/model-versus-production.svg b/public/blog-assets/introducing-tanstack-oracles/model-versus-production.svg new file mode 100644 index 000000000..a427762dc --- /dev/null +++ b/public/blog-assets/introducing-tanstack-oracles/model-versus-production.svg @@ -0,0 +1,6 @@ + +Inside an oracle test. One history. Two answers.A worked, illustrative failure explains the mechanism of an oracle test. fast-check generates one history of task edits. The same edits run against the real implementation and a simple, independent model. After each batch of changes, the runner compares their outputs. The oracle expects A and B, but production incorrectly includes completed task C. fast-check reduces the failing history to adding and completing C, with expected empty output and observed C. The human and agent build and challenge the checker; the runner executes the comparisons. This is a conceptual example, not evidence of a particular production bug. + + +Inside an oracle test.One history. Two answers.Query: top 10 open tasks · highest priority first · ties ordered by ID1 · Generate a historyA sequence of task edits01Add A · priority 202Add B · priority 103Add C · priority 304Complete Cfast-check varies the records,edits, orderings, and timing.2 · Run the real implementationTanStack DBIndexes, caching, incremental updatesObserved[C, A, B]3 · Ask the oracleA simple, independent modelMap → filter open → sort → take 10Expected[A, B]4 · Compare the resultsAfter each batchExpected ≠ observedCompleted C is still returned.We have a counterexample.Reduce the failing historyfast-check removes irrelevant steps.Add C → Complete CExpected: []Observed: [C]Worked example · illustrative failureYou and the agent build and challenge the checker. The runner executes the comparisons. + diff --git a/public/blog-assets/introducing-tanstack-oracles/shifting-economics.svg b/public/blog-assets/introducing-tanstack-oracles/shifting-economics.svg new file mode 100644 index 000000000..0b55293d3 --- /dev/null +++ b/public/blog-assets/introducing-tanstack-oracles/shifting-economics.svg @@ -0,0 +1,17 @@ + + The shifting economics of programming + A conceptual diagram, not measured data. Moving from mostly handwritten code to mostly agent-generated code, implementation effort falls while the relative emphasis on verification rises. + + + The shifting economics of programming + Relative emphasis + + + + Verification + Implementation + Mostly handwritten code + Mostly agent-generated code + Conceptual illustration · not measured quantities + + diff --git a/src/blog/introducing-tanstack-oracles.md b/src/blog/introducing-tanstack-oracles.md new file mode 100644 index 000000000..8535d55a3 --- /dev/null +++ b/src/blog/introducing-tanstack-oracles.md @@ -0,0 +1,282 @@ +--- +title: Introducing TanStack Oracles +published: 2026-12-03 +library: oracles +excerpt: An early preview of TanStack Oracles, a framework for defining how software should behave and testing real implementations against those requirements. +authors: + - Kyle Mathews +--- + +# Introducing TanStack Oracles + +![An engraved mechanical recording machine with two styluses drawing separate traces on a shared drum.](/blog-assets/introducing-tanstack-oracles/header.png) + +I'm excited to share an early preview of **TanStack Oracles**, a framework that helps developers define how software should behave and tests real implementations against those requirements. It helps coding agents find bugs, compare implementations with independent models, and improve the checks as you learn more about your code. + +Oracles grew out of how hard it was to get [TanStack DB to 1.0 RC1](https://tanstack.com/blog/tanstack-db-1.0-rc1-going-all-in-on-oracles). I needed better ways to find bugs and preserve the behavior I wanted as the implementation changed. + +The challenge extends beyond DB. We want TanStack's libraries to be as correct, capable, and sophisticated as possible. Better verification lets us pursue designs and optimizations that previously cost too much to implement and validate. + +**I've now tested Oracles on more than 100 repositories—including [many of the most-downloaded](https://github.com/isaacs/node-lru-cache/issues/427) [packages on npm](https://github.com/immerjs/immer/issues/1367)—and it found bugs in every one.** It's especially fun to run it against [old projects I wrote by hand](https://github.com/KyleAMathews/react-headroom/pull/215) and see the [absurd number of bugs it digs up](https://github.com/KyleAMathews/react-spinkit/pull/103). + +## Try it in your repository + +Before reading further, open a coding agent in a project you know well and paste in the [prompt below](https://github.com/TanStack/oracles/blob/main/packages/oracles/README.md). See what bugs Oracles can find—and what it feels like to approach your code differently: start with a behavior the software should preserve, then see whether your agent can find a case where the implementation breaks it. + +```text +Show me what oracle testing with @tanstack/oracles can find in this repository. + +Download https://raw.githubusercontent.com/TanStack/oracles/main/packages/oracles/skills/oracles-explore/SKILL.md + +Read it in full and follow it to explore this repository with Oracles. +``` + +Your agent will read your code, documentation, and tests, exercise the code, and help you choose one behavior to check. You'll work out what should happen, then compare that expectation with what the code does. If the intended behavior is unclear, the agent asks you to clarify. + +Sometimes this exploration finds a problem before the oracle exists. The oracle then reproduces it and checks the broader behavior you want to preserve. You can turn a finding into a fix and a regression test in your existing suite, or keep the oracle and expand it as it proves useful. + +You can leave the agent exploring while you read on. + +## The verification problem + +As coding agents get better, we're running into a new problem: they can produce far more code than we can comfortably review. PRs pile up. How do we know these changes are correct? How do we know they actually do what we wanted? We can't keep scaling line-by-line human review to match what agents can generate. + +The economics of programming are changing. Writing implementations used to consume a huge share of our engineering effort. We invested in tests and review, of course, but implementation itself was expensive. Agents are making it dramatically cheaper. **Verification is becoming the bottleneck.** + +
+Conceptual diagram: implementation effort falls while the relative emphasis on verification rises as more code is generated by agents. +
+As agents make implementation cheaper, verifying that the software does what we intended becomes a larger part of the work. +
+
+ +Since publishing [my post about using Oracles to harden TanStack DB](https://tanstack.com/blog/tanstack-db-1.0-rc1-going-all-in-on-oracles), I've heard from lots of people exploring how to improve verification. [Anthropic has been using agents to formally verify properties of real software](https://www.anthropic.com/research/formal-verification), and [Microsoft Research is exploring formal verification of agent-written applications](https://www.microsoft.com/en-us/research/blog/formally-verifying-agent-written-full-stack-web-apps-with-pdd-kit/). There are different approaches, but we're increasingly running into the same question: + +**How do we turn human judgment about what software should do into something agents can act on and tools can enforce?** + +Getting this right could automate much of the behavioral correctness work in code review. Agents could work more independently, leaving us more time for deciding what software should do, exploring designs, and making tradeoffs. + +I think figuring all of this out will be a multi-year effort across the industry. But the starting point can be remarkably simple: one rule about how software should behave, and a way to test it. + +## A simple rule exposes a real bug + +Here's a bug from Headroom, my scrolling-header library. With its default settings, the rule was simple: **the wrapper must track the header's height, even as its contents change.** In Oracles, I record a rule like this as a **law**: a statement of expected behavior independent of how the code works. + +To test this rule, Oracles generated sequences of changes to the header, varying its content and size, and checked the layout after each change. One sequence exposed a bug in an earlier version of Headroom: when the header grew, its wrapper still reserved space for the old height. The header covered the content below it. The fix was to keep the reserved space in sync with the header's actual height. + +
+Before-and-after animation reproducing a historical Headroom bug: the header grows beyond the space reserved by its wrapper, covering the content below it. +
+When the header grows, its wrapper must keep pace instead of reserving space for the old height. +
+
+ +That's the basic idea behind Oracles. It combines property-based testing, model-based testing, fuzzing, and mutation testing into a framework that agents can use to discover and enforce behavioral requirements. Rather than writing out every example and its expected answer, I can describe the behavior I want and let the framework explore sequences I wouldn't have thought to test individually. + +
+Conceptual illustration comparing handpicked unit-test examples with generated histories checked against a law and an independent model. +
+A single law can check behavior across many generated sequences of changes, rather than only handpicked examples. +
+
+ +A layout rule like Headroom's can be checked directly: measure the header and compare it with the space its wrapper reserves. But what if determining the correct result requires calculating the effects of many interacting changes? + +## One history, two answers + +Consider a task list backed by TanStack DB. Complete a task, and it disappears from the list of open tasks. Reopen it, and it comes back. + +Easy enough. + +Now imagine displaying only the ten highest-priority open tasks, updating the list as tasks are added, completed, deleted, and reprioritized. Tasks with equal priority appear in ID order. TanStack DB maintains live queries incrementally, so it has to keep that result correct without filtering and sorting every task from scratch after each change. + +Suppose I add tasks A, B, and C, then complete C. C should disappear. But imagine the incremental implementation accidentally keeps it in the result. + +I could write a test for that exact sequence. But what about a tie at the tenth slot? A task that drops out of the list and returns? A batch that deletes one task and changes another's priority? There are far more sequences than I can write tests for individually. + +Instead, I can write a small model that calculates expected answers for sequences I never thought to test individually. + +The model keeps task records in a plain JavaScript `Map`. After applying each batch of changes, it filters out completed tasks, sorts the rest by priority and ID, and takes the first ten: + +```ts +function expectedTopTasks(tasks: Iterable) { + return [...tasks] + .filter(task => !task.completed) + .sort((a, b) => + b.priority - a.priority || + (a.id < b.id ? -1 : a.id > b.id ? 1 : 0) + ) + .slice(0, 10) + .map(task => task.id) +} +``` + +Let's give those three tasks priorities: A gets 2, B gets 1, and C gets 3. The model calculates `[C, A, B]`. + +Complete C, and it expects `[A, B]`. + +Now reopen C and raise B's priority to 4 in the same batch. The model expects `[B, C, A]`. + +I didn't have to write down the expected answer for each combination of edits. The model calculates it as the changes happen. + +Oracles runs the same sequence against the real TanStack DB query and compares the results after each batch. If production still includes C after completing it, the disagreement shows up immediately—even if a later change makes the final result correct. + +
+Illustrative oracle failure: the same task edits run against production and an independent model. After completing C, the model returns A and B while production still includes C; shrinking reduces the history to adding and completing C. +
+Illustrative failure: the model expects [A, B], while production still includes completed task C. +
+
+ +**One history. Two answers.** + +And the two answers are calculated very differently. Production might maintain sophisticated indexes, caches, and incremental algorithms to make the query fast. The model just recomputes everything from its `Map`. That independence matters: if the model reused production's query-maintenance code, it might reproduce the same bug. It's a design requirement the agent and I have to review, not something the framework can guarantee automatically. + +But which answer is right? + +Neither is automatically authoritative. The law records the behavior I've decided the software should have, and both the model and production need to honor it. + +When they disagree, that difference gives the agent a precise clue about what to investigate. It can replay the history, trace how each side arrived at its answer, and work out what needs to change to reconcile them with the law. If the law itself doesn't settle the question, the agent asks me to make the design decision. + +In Oracles, a sequence of actions like this is called a *history*. A **driver** executes those actions against production and records what happens. A **check** compares the observations with the answers calculated by the model. + +The framework brings these pieces together through `oracleProperty`: + +```ts +oracleProperty({ + id: 'top-open-tasks', + law: topTasksLaw, + histories: taskHistories, + model: expectedTaskResults, + driver: driveTaskQuery, + check: checkTaskResults, +}) +``` + +The **law** is a concrete record, not a special language. Here, `topTasksLaw` would contain a plain-English `statement` (return the ten highest-priority open tasks, breaking ties by ID), an `authority` (the decision or contract that established it), and `limits` (what this oracle doesn't claim to verify). The framework connects that law to histories, a model, a production driver, and a comparison that an agent can run, replay, and strengthen. + +When a generated history fails, Oracles can also **shrink** it to a much smaller reproduction while preserving the disagreement. + +For our illustrative bug, a long sequence of changes might reduce to just two actions: add C, then complete C. + +Expected: `[]`. Actual: `[C]`. + +The agent now has a short history to replay, the specific law it violated, and a precise disagreement to investigate. + +But this only works if the oracle can recognize when production is wrong. One of my TanStack DB oracles taught me how easily that can fail. + +## What if the oracle itself is wrong? + +During a review, another agent spotted a problem in one of my TanStack DB oracles. My test subscriber was accepting updates that should have been impossible. + +TanStack DB sends insert, update, and delete messages to subscribers, which use those messages to maintain their own copy of the data. An **insert** adds a row the subscriber doesn't have. An **update** changes a row it already has. + +But my test subscriber used `Map.set` for both. That meant an update to a nonexistent row would silently create it. The final data could look correct even though the sequence of messages was invalid. + +**And production was sending invalid updates.** + +The bug was buried in the interaction between optimistic mutations and synchronization. In certain sequences, a row disappeared from the subscriber's view, often following an optimistic delete. When a later sync made that key visible again, the state manager sometimes emitted an `update` because it remembered a completed optimistic request. + +But the subscriber had already removed the row. There was nothing to update. Production should have sent an `insert`. + +The state machine was complicated. The rule it violated was tiny: **every update must refer to a row the subscriber already has.** + +I [strengthened the checker](https://github.com/TanStack/db/commit/721a607e82e7d4c906e2ae1e23833842753be810) to enforce that rule, rejecting updates for missing rows and inserts for existing ones. + +And here's the surprising result: **without generating a single new history, 26 of the existing 378 cases started failing.** + +Those histories had already exercised the production bug. The original checker just couldn't recognize it. Once I fixed the checker, the existing histories immediately exposed the invalid messages. [Fixing production](https://github.com/TanStack/db/commit/182b992622cfdf65788af15a29c33442f224af5f) then made the cases pass again. + +That changed the question I ask whenever a bug gets through. Why did production get this wrong? And why didn't the oracle catch it? + +**The second question is often much more interesting than the first.** Fixing production addresses one bug. Understanding why the oracle missed it can uncover a whole class of bugs that the existing checks were incapable of detecting. + +## Testing the oracle + +The subscriber bug left me with two questions for any passing oracle: Did it reach the situations where bugs might hide? And if it did, would the checker recognize something wrong? + +**First, did it reach the right situation?** + +Our task query combines a ten-item limit with a tie-breaking rule. That suggests an interesting boundary: what happens when two tasks compete for the tenth slot? + +An agent can add a **constructed history** that starts with nine higher-priority tasks, then adds B and A with equal priority. A should take the final slot because its ID comes first. Complete A, and B should enter. Reopen A, and A should return. + +The model still calculates the expected results. I don't have to write those answers by hand. A reach check can also use production observations to confirm that execution actually entered the intended situation, rather than merely trusting the input history. + +Sometimes the law itself suggests where to look. Other times it's accumulated experience: bugs keep surfacing in one area, a subsystem is notoriously tricky, or a reviewing agent discovers a bug the oracle missed. + +Constructed histories capture that judgment. I want Oracles to guide agents through these decisions as part of the framework: which situations matter, why they matter, and how to reach them. + +**Second, would the checker notice a wrong answer?** + +For that I can add a **calibration**. Take an existing passing history where two equal-priority tasks both fit in the result, so the model expects `[A, B]`. I tell Oracles to feed the checker `[B, A]` instead. + +That deliberately wrong observation is called a *corruption*. I'm not changing production code. I'm checking whether the oracle would recognize this particular mistake. + +Oracles handles the execution: it runs the original history, substitutes the wrong answer, and requires the ordering law to reject it. If the change doesn't take effect, the wrong law fires, or the test crashes for an unrelated reason, the calibration fails. + +That's useful, but someone still had to think of reversing the order. I want Oracles to guide agents toward useful calibrations, helping them decide which mistakes to simulate and which law should catch them. + +**What if I want to challenge the whole oracle?** + +Oracles already does this automatically through its `oracle-gaps` CLI. It makes small changes to copies of the production code an oracle owns, runs the oracle against each variant, and reports changes that no law rejects. This is **gap investigation**. For our task query, a generated change to the ID tie-breaker tests whether the oracle notices tasks returning in the wrong order. + +Each reported gap comes with instructions for the agent to investigate why it went undetected. Did the histories miss the relevant situation? Did the driver fail to observe the consequences? Was the model or checker too weak? Or does the change preserve behavior the law already allows? + +**I don't allow enforcement gaps to be waived.** A surviving mutant might be a valid alternative implementation, but the agent has to establish that rather than dismissing it as harmless. Otherwise agents are remarkably good at finding reasons to excuse a failing check instead of fixing it. + +All of these techniques point toward something bigger. + +**The ideal oracle isn't a static collection of carefully designed tests. It's a system that actively searches for reasons not to trust itself.** + +That skepticism applies at two levels. Formal methods can help challenge the model itself, exploring its possible behaviors, finding counterexamples, and proving properties it should satisfy. Generated histories, calibrations, and production mutations challenge whether the implementation follows the model—and whether the checks can recognize violations. + +I want agents continuously searching for weaknesses in both. Every discovery should improve the model or its enforcement, leaving the next agent with a stronger oracle than the previous one had. + +## What changes when Oracles is in your codebase? + +Software accumulates thousands of design decisions. Why does this query break ties by ID? What happens when two optimistic updates overlap? When is a transaction allowed to become visible? + +Some answers are documented. Others live in PR discussions or are buried in the implementation. Now imagine a coding agent arriving a month later to optimize a query. How is it supposed to know which decisions matter? + +I can write long architectural documents and instructions, but an agent still has to know when to read them and which details apply to its task. + +**With Oracles, the decisions I've captured become executable.** + +Suppose an agent optimizes the task query and accidentally changes how equal-priority tasks are ordered. The oracle fails, identifies the exact history and the law it violated, and points back to the reason for the decision: break ties by ID so the same tasks always appear in the same order, regardless of which arrived first. + +The agent doesn't have to search through an architectural document hoping to discover that ordering matters. The relevant decision surfaces because the agent's change violated it. **It's a form of memory that becomes relevant when the code runs afoul of it.** + +And this memory can improve with every change. When an agent finds a bug the oracle missed, I ask it to investigate why. Maybe the model omitted an important case; maybe the history generator missed an interaction; maybe the checker ignored something that mattered. The fix to the oracle becomes part of what the next agent inherits. + +I think of these as two connected loops. The **design loop** makes and revises decisions about what software should do, informed by bugs, feature requests, and experience using it. The **enforcement loop** checks whether production follows those decisions and whether the checking machinery is capable of detecting violations. + +Every resolved bug, feature request, and design decision can make that memory more precise. The next agent inherits not just more instructions, but more of the project's accumulated judgment—and a way to check its work against that judgment. + +And as more of that judgment becomes explicit and enforceable, **the implementation itself starts to become replaceable.** + +## What could we build with this? + +That's led me to think of an agent implementing against an oracle as a kind of compiler. The laws and model describe the behavior I want; the agent turns them into code and uses the oracle to check its work. + +In pursuit of making that analogy more literal, I'd love to explore Oracles growing into an **agent-powered optimizing compiler**, progressively lowering high-level specifications into concrete plans and code while agents experiment with different implementations against the same laws. + +There's a lot to explore here, from using formal methods like Lean and TLA+ to strengthen models, to stronger verification, to finding implementations that are faster, smaller, or use less memory. + +But I don't think any one team is going to discover the best approaches to all of this. + +**I want Oracles to win by making the best tools work together.** + +LLVM is a useful model: shared compiler infrastructure that many programming languages build on and benefit from improving. I'd like Oracles to become similarly modular, with great defaults but room to plug in the best models, generators, verification techniques, and agent strategies wherever they come from. + +I'm also building shared evaluation infrastructure to compare approaches against real repositories. Which strategies find more bugs, faster and at lower cost? By pooling our efforts, improvements to one part of the framework can benefit everyone using it. + +In 2027, I'll be working with the [Protocol Institute](https://protocol-institute.org/) on a broader **Future of Programming** research effort. We'll bring people together to explore these questions, run experiments, and turn promising discoveries into tools people can use. + +My employer, Databricks, is sponsoring both my time on this work and the research group directly. + +If you tried the prompt at the beginning, take a look at what your agent found. Did it find a bug? And perhaps more interestingly, what might its oracle still be missing? + +I've had enormous fun exploring these questions, and I think we're just scratching the surface. + +If you'd like to join the exploration or simply follow along, [sign up for the Future of Programming research list](https://forms.gle/XGeS4rtwnn3QX5av9). I'll share what we're learning and opportunities to get involved. There's also space to tell me what you're working on—I'd love to find people to collaborate with as the research takes shape. diff --git a/src/components/landing/OraclesLanding.tsx b/src/components/landing/OraclesLanding.tsx new file mode 100644 index 000000000..a3bc592d7 --- /dev/null +++ b/src/components/landing/OraclesLanding.tsx @@ -0,0 +1,35 @@ +import { LibraryLandingShell } from './LibraryLanding' +import { LandingCopyPromptButton } from './LandingCopyPromptButton' + +const oraclesPrompt = `Show me what oracle testing with @tanstack/oracles can find in this repository. + +Download https://raw.githubusercontent.com/TanStack/oracles/main/packages/oracles/skills/oracles-explore/SKILL.md + +Read it in full and follow it to explore this repository with Oracles.` + +export default function OraclesLanding() { + return ( + +
+
+

Try it in your repository

+

+ Paste this prompt into your coding agent. +

+
+ +
+
+            {oraclesPrompt}
+          
+ + } + /> + ) +} diff --git a/src/libraries/categories.ts b/src/libraries/categories.ts index 8213a9a46..74f0bb49c 100644 --- a/src/libraries/categories.ts +++ b/src/libraries/categories.ts @@ -37,6 +37,7 @@ export const libraryCategories: Record = { config: 'tooling', cli: 'tooling', intent: 'tooling', + oracles: 'tooling', ranger: 'tooling', mcp: 'tooling', workflow: 'tooling', diff --git a/src/libraries/icons.ts b/src/libraries/icons.ts index 51fabb790..27542113e 100644 --- a/src/libraries/icons.ts +++ b/src/libraries/icons.ts @@ -10,6 +10,7 @@ import { GogglesIcon } from '@phosphor-icons/react/Goggles' import { HighlighterIcon } from '@phosphor-icons/react/Highlighter' import { MarkdownLogoIcon } from '@phosphor-icons/react/MarkdownLogo' import { PencilRulerIcon } from '@phosphor-icons/react/PencilRuler' +import { ScalesIcon } from '@phosphor-icons/react/Scales' import { SealQuestionIcon } from '@phosphor-icons/react/SealQuestion' import { SlidersIcon } from '@phosphor-icons/react/Sliders' import { SmileyMeltingIcon } from '@phosphor-icons/react/SmileyMelting' @@ -47,6 +48,7 @@ export const libraryIcons: Record = { config: GearSixIcon, cli: TerminalWindowIcon, intent: CrosshairIcon, + oracles: ScalesIcon, ranger: SlidersIcon, } diff --git a/src/libraries/ids.ts b/src/libraries/ids.ts index 548a742dd..a8d2f3b82 100644 --- a/src/libraries/ids.ts +++ b/src/libraries/ids.ts @@ -16,6 +16,7 @@ export const libraryIds = [ 'db', 'ai', 'intent', + 'oracles', 'workflow', 'config', 'devtools', @@ -45,4 +46,5 @@ export const SIDEBAR_LIBRARY_IDS = [ 'devtools', 'cli', 'intent', + 'oracles', ] as const satisfies readonly LibraryId[] diff --git a/src/libraries/index.tsx b/src/libraries/index.tsx index cb8029cb1..56fd687be 100644 --- a/src/libraries/index.tsx +++ b/src/libraries/index.tsx @@ -28,6 +28,7 @@ export { db, ai, intent, + oracles, config, devtools, workflow, diff --git a/src/libraries/libraries.ts b/src/libraries/libraries.ts index 5dda2dbf2..cb4cf400f 100644 --- a/src/libraries/libraries.ts +++ b/src/libraries/libraries.ts @@ -805,6 +805,32 @@ export const intent: LibrarySlim = { }, } +export const oracles: LibrarySlim = { + id: 'oracles', + ...categoryStyles.tooling, + name: 'TanStack Oracles', + to: '/oracles/latest', + tagline: 'Find bugs. Preserve the behavior you intended.', + description: + 'Oracle testing for TypeScript. State behavioral laws, generate histories, and compare real implementations with independent models. Help coding agents find bugs and strengthen the checks as you learn.', + badge: 'alpha', + repo: 'tanstack/oracles', + hasDiscussions: false, + frameworks: [], + corePackageName: '@tanstack/oracles', + npmPackageNames: ['@tanstack/oracles'], + latestVersion: 'v0', + latestBranch: 'main', + availableVersions: ['v0'], + docsRoot: 'packages/oracles/docs', + defaultDocs: 'overview', + statsAvailable: false, + sitemap: { + includeLandingPage: true, + includeDocsPages: true, + }, +} + export const config: LibrarySlim = { id: 'config', scarfId: '6e4c7302-6e7d-45ec-b963-9ac66c70c6b2', @@ -948,6 +974,7 @@ export const libraries: LibrarySlim[] = [ db, ai, intent, + oracles, virtual, pacer, hotkeys, @@ -1008,7 +1035,7 @@ export const librariesByGroup = { state: [query, db, store, ai], headlessUI: [table, charts, form, hotkeys, markdown, highlight], performance: [virtual, pacer], - tooling: [devtools, config, cli, intent], + tooling: [devtools, config, cli, intent, oracles], } export const librariesGroupNamesMap = { diff --git a/src/libraries/maintainers.ts b/src/libraries/maintainers.ts index 777322479..3aeeda42f 100644 --- a/src/libraries/maintainers.ts +++ b/src/libraries/maintainers.ts @@ -208,7 +208,7 @@ export const allMaintainers: Maintainer[] = [ latitude: 40.78, longitude: -111.911, }, - creatorOf: ['db', 'intent'], + creatorOf: ['db', 'intent', 'oracles'], frameworkExpertise: ['react'], specialties: ['Sync Engines'], }, diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 38af1b4ab..0889acc34 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -222,6 +222,7 @@ import { Route as LibraryHighlightVersionThemeEditorRouteImport } from './routes import { Route as LibraryHotkeysVersionIndexRouteImport } from './routes/_library/hotkeys.$version.index' import { Route as LibraryIntentVersionIndexRouteImport } from './routes/_library/intent.$version.index' import { Route as LibraryMarkdownVersionIndexRouteImport } from './routes/_library/markdown.$version.index' +import { Route as LibraryOraclesVersionIndexRouteImport } from './routes/_library/oracles.$version.index' import { Route as LibraryPacerVersionIndexRouteImport } from './routes/_library/pacer.$version.index' import { Route as LibraryQueryVersionIndexRouteImport } from './routes/_library/query.$version.index' import { Route as LibraryRangerVersionIndexRouteImport } from './routes/_library/ranger.$version.index' @@ -1427,6 +1428,12 @@ const LibraryMarkdownVersionIndexRoute = path: '/markdown/$version/', getParentRoute: () => LibraryRoute, } as any) +const LibraryOraclesVersionIndexRoute = + LibraryOraclesVersionIndexRouteImport.update({ + id: '/oracles/$version/', + path: '/oracles/$version/', + getParentRoute: () => LibraryRoute, + } as any) const LibraryPacerVersionIndexRoute = LibraryPacerVersionIndexRouteImport.update({ id: '/pacer/$version/', @@ -2304,6 +2311,7 @@ export interface FileRoutesByFullPath { '/hotkeys/$version/': typeof LibraryHotkeysVersionIndexRoute '/intent/$version/': typeof LibraryIntentVersionIndexRoute '/markdown/$version/': typeof LibraryMarkdownVersionIndexRoute + '/oracles/$version/': typeof LibraryOraclesVersionIndexRoute '/pacer/$version/': typeof LibraryPacerVersionIndexRoute '/query/$version/': typeof LibraryQueryVersionIndexRoute '/ranger/$version/': typeof LibraryRangerVersionIndexRoute @@ -2615,6 +2623,7 @@ export interface FileRoutesByTo { '/hotkeys/$version': typeof LibraryHotkeysVersionIndexRoute '/intent/$version': typeof LibraryIntentVersionIndexRoute '/markdown/$version': typeof LibraryMarkdownVersionIndexRoute + '/oracles/$version': typeof LibraryOraclesVersionIndexRoute '/pacer/$version': typeof LibraryPacerVersionIndexRoute '/query/$version': typeof LibraryQueryVersionIndexRoute '/ranger/$version': typeof LibraryRangerVersionIndexRoute @@ -2941,6 +2950,7 @@ export interface FileRoutesById { '/_library/hotkeys/$version/': typeof LibraryHotkeysVersionIndexRoute '/_library/intent/$version/': typeof LibraryIntentVersionIndexRoute '/_library/markdown/$version/': typeof LibraryMarkdownVersionIndexRoute + '/_library/oracles/$version/': typeof LibraryOraclesVersionIndexRoute '/_library/pacer/$version/': typeof LibraryPacerVersionIndexRoute '/_library/query/$version/': typeof LibraryQueryVersionIndexRoute '/_library/ranger/$version/': typeof LibraryRangerVersionIndexRoute @@ -3267,6 +3277,7 @@ export interface FileRouteTypes { | '/hotkeys/$version/' | '/intent/$version/' | '/markdown/$version/' + | '/oracles/$version/' | '/pacer/$version/' | '/query/$version/' | '/ranger/$version/' @@ -3578,6 +3589,7 @@ export interface FileRouteTypes { | '/hotkeys/$version' | '/intent/$version' | '/markdown/$version' + | '/oracles/$version' | '/pacer/$version' | '/query/$version' | '/ranger/$version' @@ -3903,6 +3915,7 @@ export interface FileRouteTypes { | '/_library/hotkeys/$version/' | '/_library/intent/$version/' | '/_library/markdown/$version/' + | '/_library/oracles/$version/' | '/_library/pacer/$version/' | '/_library/query/$version/' | '/_library/ranger/$version/' @@ -5628,6 +5641,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof LibraryMarkdownVersionIndexRouteImport parentRoute: typeof LibraryRoute } + '/_library/oracles/$version/': { + id: '/_library/oracles/$version/' + path: '/oracles/$version' + fullPath: '/oracles/$version/' + preLoaderRoute: typeof LibraryOraclesVersionIndexRouteImport + parentRoute: typeof LibraryRoute + } '/_library/pacer/$version/': { id: '/_library/pacer/$version/' path: '/pacer/$version' @@ -6575,6 +6595,7 @@ interface LibraryRouteChildren { LibraryHotkeysVersionIndexRoute: typeof LibraryHotkeysVersionIndexRoute LibraryIntentVersionIndexRoute: typeof LibraryIntentVersionIndexRoute LibraryMarkdownVersionIndexRoute: typeof LibraryMarkdownVersionIndexRoute + LibraryOraclesVersionIndexRoute: typeof LibraryOraclesVersionIndexRoute LibraryPacerVersionIndexRoute: typeof LibraryPacerVersionIndexRoute LibraryQueryVersionIndexRoute: typeof LibraryQueryVersionIndexRoute LibraryRangerVersionIndexRoute: typeof LibraryRangerVersionIndexRoute @@ -6603,6 +6624,7 @@ const LibraryRouteChildren: LibraryRouteChildren = { LibraryHotkeysVersionIndexRoute: LibraryHotkeysVersionIndexRoute, LibraryIntentVersionIndexRoute: LibraryIntentVersionIndexRoute, LibraryMarkdownVersionIndexRoute: LibraryMarkdownVersionIndexRoute, + LibraryOraclesVersionIndexRoute: LibraryOraclesVersionIndexRoute, LibraryPacerVersionIndexRoute: LibraryPacerVersionIndexRoute, LibraryQueryVersionIndexRoute: LibraryQueryVersionIndexRoute, LibraryRangerVersionIndexRoute: LibraryRangerVersionIndexRoute, diff --git a/src/routes/-library-landing.tsx b/src/routes/-library-landing.tsx index 6e4fb0ffc..e5fe1b9a6 100644 --- a/src/routes/-library-landing.tsx +++ b/src/routes/-library-landing.tsx @@ -13,6 +13,7 @@ export type LandingLibraryId = | 'highlight' | 'intent' | 'markdown' + | 'oracles' | 'pacer' | 'redact' | 'query' diff --git a/src/routes/_library/$libraryId/$version.index.tsx b/src/routes/_library/$libraryId/$version.index.tsx index 4e109f9d9..e5af60e74 100644 --- a/src/routes/_library/$libraryId/$version.index.tsx +++ b/src/routes/_library/$libraryId/$version.index.tsx @@ -44,6 +44,8 @@ function redirectToStaticLanding(libraryId: string, version: string) { throw redirect({ to: '/intent/$version', params: { version } }) case 'markdown': throw redirect({ to: '/markdown/$version', params: { version } }) + case 'oracles': + throw redirect({ to: '/oracles/$version', params: { version } }) case 'pacer': throw redirect({ to: '/pacer/$version', params: { version } }) case 'redact': diff --git a/src/routes/_library/oracles.$version.index.tsx b/src/routes/_library/oracles.$version.index.tsx new file mode 100644 index 000000000..e867ad328 --- /dev/null +++ b/src/routes/_library/oracles.$version.index.tsx @@ -0,0 +1,22 @@ +import { createFileRoute } from '@tanstack/react-router' +import OraclesLanding from '~/components/landing/OraclesLanding' +import { + beforeLoadLibraryLanding, + getLibraryLandingHead, + getLibraryLandingHeaders, + libraryLandingStaleTime, + loadLibraryLandingRouteData, +} from '../-library-landing-route' + +export const Route = createFileRoute('/_library/oracles/$version/')({ + staleTime: libraryLandingStaleTime, + beforeLoad: ({ params, location }) => { + beforeLoadLibraryLanding('oracles', params.version, location.href) + }, + loader: ({ params, context: { queryClient } }) => + loadLibraryLandingRouteData('oracles', params.version, queryClient), + head: ({ match }) => + getLibraryLandingHead('oracles', match.status === 'success'), + headers: () => getLibraryLandingHeaders('oracles'), + component: OraclesLanding, +}) diff --git a/src/utils/analytics/live-dashboard.ts b/src/utils/analytics/live-dashboard.ts index fc5e8671e..2c0cdcaf7 100644 --- a/src/utils/analytics/live-dashboard.ts +++ b/src/utils/analytics/live-dashboard.ts @@ -69,6 +69,7 @@ const libraryNames: Record = { ai: 'AI', charts: 'Charts', intent: 'Intent', + oracles: 'Oracles', devtools: 'Devtools', config: 'Config', cli: 'CLI', diff --git a/src/utils/analytics/live.ts b/src/utils/analytics/live.ts index 294dc2c3a..badc54fa3 100644 --- a/src/utils/analytics/live.ts +++ b/src/utils/analytics/live.ts @@ -28,7 +28,7 @@ export const liveActionSchema = z.enum([ // Only public content paths. Never store a query, fragment, or private route. export const livePublicPagePattern = - /^\/(?:$|(?:query|router|start|table|db|form|store|virtual|pacer|hotkeys|ai|charts|intent|devtools|config|cli|highlight|markdown|ranger|redact|mcp|workflow)(?:\/|$)|(?:blog|partners|application-starter|libraries|stack|stats)(?:\/|$)|(?:brand-guide|community-projects|ethos|explore|feedback-leaderboard|learn|maintainers|paid-support|privacy|showcase|showcases|support|tenets|terms|workshops)\/?$)/ + /^\/(?:$|(?:query|router|start|table|db|form|store|virtual|pacer|hotkeys|ai|charts|intent|oracles|devtools|config|cli|highlight|markdown|ranger|redact|mcp|workflow)(?:\/|$)|(?:blog|partners|application-starter|libraries|stack|stats)(?:\/|$)|(?:brand-guide|community-projects|ethos|explore|feedback-leaderboard|learn|maintainers|paid-support|privacy|showcase|showcases|support|tenets|terms|workshops)\/?$)/ export const liveForbiddenPagePattern = /[?#\\\s%]|\.\./ export function isLivePage(page: string) { diff --git a/tests/docs-redirects.test.ts b/tests/docs-redirects.test.ts index 823567d95..0023573df 100644 --- a/tests/docs-redirects.test.ts +++ b/tests/docs-redirects.test.ts @@ -20,6 +20,7 @@ const expectedLegacyOverviewTargets: Record = { hotkeys: 'overview', intent: null, markdown: 'overview', + oracles: null, pacer: 'overview', query: 'framework/react/overview', redact: 'overview', diff --git a/tests/live-presence.test.ts b/tests/live-presence.test.ts index d855526f7..cc3817eb7 100644 --- a/tests/live-presence.test.ts +++ b/tests/live-presence.test.ts @@ -3,6 +3,7 @@ import { test } from 'node:test' import { randomUUID } from 'node:crypto' import { runInNewContext } from 'node:vm' import { build } from 'esbuild' +import { publicLibraries } from '../src/libraries/libraries' import { isLivePage, liveEventSchema } from '../src/utils/analytics/live.ts' const browserBundle = build({ @@ -150,6 +151,11 @@ test('presence accepts only public paths and named actions', () => { '/query/latest/docs/framework/react/overview', '/partners/scarf', '/start', + ...publicLibraries.flatMap((library) => [ + `/${library.id}`, + `/${library.id}/latest`, + `/${library.id}/${library.latestVersion}/docs/${library.defaultDocs ?? 'overview'}`, + ]), ]) assert.ok(isLivePage(page), page) for (const page of [ @@ -162,6 +168,13 @@ test('presence accepts only public paths and named actions', () => { '/query/#secret', '/query/../account', '/query/%2e%2e/account', + ...publicLibraries.flatMap((library) => [ + `/${library.id}-private`, + `/${library.id}/latest?email=someone`, + `/${library.id}/#secret`, + `/${library.id}/../account`, + `/${library.id}/%2e%2e/account`, + ]), ]) assert.equal(isLivePage(page), false, page) assert.equal( @@ -178,6 +191,27 @@ test('presence accepts only public paths and named actions', () => { ) }) +test('presence follows every public library and stops reporting on private pages', async () => { + const visitor = await browser() + const pages = publicLibraries.map((library) => library.to) + for (const page of pages) { + visitor.location.pathname = page + visitor.api.trackLiveAction('page_view') + } + assert.deepEqual( + (await visitor.messages()).map((event) => event.page), + ['/query/latest/docs/framework/react/overview', ...pages], + ) + visitor.location.pathname = '/account' + visitor.api.trackLiveAction('page_view') + visitor.heartbeat() + const messages = await visitor.messages() + assert.equal(messages.length, pages.length + 2) + assert.equal(messages.at(-1)?.kind, 'leave') + assert.equal(messages.at(-1)?.page, pages.at(-1)) + visitor.stop() +}) + test('DNT and GPC prevent session cookies and beacons', async () => { for (const options of [{ dnt: '1' }, { gpc: true }]) { const visitor = await browser(options) diff --git a/tests/static-data-contracts.test.ts b/tests/static-data-contracts.test.ts index eb38a11d8..4d772b78d 100644 --- a/tests/static-data-contracts.test.ts +++ b/tests/static-data-contracts.test.ts @@ -28,7 +28,10 @@ assert.equal( ) for (const library of publicLibraries) { - assert.ok(library.scarfId, `${library.id} must have a Scarf pixel`) + // Oracles may launch before its dedicated Scarf pixel is configured. + if (library.id !== 'oracles') { + assert.ok(library.scarfId, `${library.id} must have a Scarf pixel`) + } assert.equal( library.to.startsWith('/'), true,