Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .agents/skills/oracles-design/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-design
description: Design, write, or change an oracle with @tanstack/oracles. Start from approved potential laws, write the oracle file with its law block and code, choose a model, and build histories that reach the states the law needs. Show the evidence the change needs, and close every gap. Use for a new oracle, an oracle repair, or a production change in owned code. Also use for any change to a model, history grammar, driver, or check.
---

Read `packages/oracles/skills/oracles-design/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .agents/skills/oracles-evaluate-review/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-evaluate-review
description: Evaluate a review of oracle work done with @tanstack/oracles. Keep a lossless ledger of every finding, and check each claim against the code. Extend the oracle so it shows each confirmed bug on unchanged production, then fix production and close the bug class. Use when review findings arrive for a branch that touches an oracle or owned code.
---

Read `packages/oracles/skills/oracles-evaluate-review/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .agents/skills/oracles-explore/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-explore
description: Explore an area of a codebase with @tanstack/oracles, or the whole repository. Probe the real API to prove each finding, propose a potential oracle and its potential laws, build it, fix confirmed bugs oracle first, and close gaps until bugs or design questions turn up. The first time in a repository, it also onboards the developer: what the session will do, new words explained as they come up, a walk-through, and the choice to finish setting up. Use when someone is trying @tanstack/oracles, asks where an oracle would help, or asks to explore an area ("explore the clearQueue API").
---

Read `packages/oracles/skills/oracles-explore/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .agents/skills/oracles-review/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-review
description: Review oracle work done with @tanstack/oracles. Challenge whether an oracle enforces its law, whether it is the right law, and whether the work took a shortcut. Use for a new or changed oracle, or a production change in owned code. Also use for a proposed change to what an oracle promises.
---

Read `packages/oracles/skills/oracles-review/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .agents/skills/oracles-setup/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-setup
description: Finish setting up a repository for oracles with @tanstack/oracles. Pin the packages, add the lint preset and the Vitest config, write the agent instructions, make the oracle skills findable by coding agents, and run the oracle through the gap check. Use when the developer wants to keep the work of a first session (a commit, or a pull request), when a repository adopts @tanstack/oracles, or when it upgrades its pinned commit. Its install and file-placement sections also cover the minimal setup that a first session needs.
---

Read `packages/oracles/skills/oracles-setup/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
5 changes: 5 additions & 0 deletions .changeset/capture-file-level-hook-assertion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/oracles': patch
---

Fix `oracle-gaps` failing a file whose file-level `afterAll` asserts. The capture harness hashes each assertion into the running test's row, and the row closes when its test ends. An assertion in a file-level hook runs after the last test, outside any test, so the harness updated a closed hash and threw `Digest already called` out of the hook. Vitest then failed a file whose every test passed, and the gap report blocked every mutant the file owns. The harness now records no assertion outside a test. The assertion itself still runs, so a failing hook assertion still fails the file. Under the gap check such an assertion is no verdict: a file whose file-level hook fails judges nothing.
9 changes: 9 additions & 0 deletions .claude/skills/oracles-design/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-design
description: Design, write, or change an oracle with @tanstack/oracles. Start from approved potential laws, write the oracle file with its law block and code, choose a model, and build histories that reach the states the law needs. Show the evidence the change needs, and close every gap. Use for a new oracle, an oracle repair, or a production change in owned code. Also use for any change to a model, history grammar, driver, or check.
---

Read `packages/oracles/skills/oracles-design/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .claude/skills/oracles-evaluate-review/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-evaluate-review
description: Evaluate a review of oracle work done with @tanstack/oracles. Keep a lossless ledger of every finding, and check each claim against the code. Extend the oracle so it shows each confirmed bug on unchanged production, then fix production and close the bug class. Use when review findings arrive for a branch that touches an oracle or owned code.
---

Read `packages/oracles/skills/oracles-evaluate-review/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .claude/skills/oracles-explore/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-explore
description: Explore an area of a codebase with @tanstack/oracles, or the whole repository. Probe the real API to prove each finding, propose a potential oracle and its potential laws, build it, fix confirmed bugs oracle first, and close gaps until bugs or design questions turn up. The first time in a repository, it also onboards the developer: what the session will do, new words explained as they come up, a walk-through, and the choice to finish setting up. Use when someone is trying @tanstack/oracles, asks where an oracle would help, or asks to explore an area ("explore the clearQueue API").
---

Read `packages/oracles/skills/oracles-explore/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .claude/skills/oracles-review/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-review
description: Review oracle work done with @tanstack/oracles. Challenge whether an oracle enforces its law, whether it is the right law, and whether the work took a shortcut. Use for a new or changed oracle, or a production change in owned code. Also use for a proposed change to what an oracle promises.
---

Read `packages/oracles/skills/oracles-review/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
9 changes: 9 additions & 0 deletions .claude/skills/oracles-setup/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: oracles-setup
description: Finish setting up a repository for oracles with @tanstack/oracles. Pin the packages, add the lint preset and the Vitest config, write the agent instructions, make the oracle skills findable by coding agents, and run the oracle through the gap check. Use when the developer wants to keep the work of a first session (a commit, or a pull request), when a repository adopts @tanstack/oracles, or when it upgrades its pinned commit. Its install and file-placement sections also cover the minimal setup that a first session needs.
---

Read `packages/oracles/skills/oracles-setup/SKILL.md` in full, and follow it. This repository is
`@tanstack/oracles`, so that file is the skill's source, at the version of
this checkout. If it does not exist, you are not in the TanStack/oracles
repository: say so and stop.
95 changes: 95 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!-- BEGIN @tanstack/oracles (template 4) -->

## Oracle tests

This repository is `@tanstack/oracles`, and it holds its own code to the
method it ships: each package's design is captured as laws, enforced by its
own oracles against an independent model. Work oracle first, production
second.

**Who owns what.** The laws belong to the people who maintain this
repository: what the code promises, the authority for each promise, and its
limits. Propose a law, but do not adopt or change one without their
approval. The production code that the oracles own is yours. Whenever you
change it, do a good job, not a minimal or lazy one: the fast, small,
elegant version, as an optimizing compiler for the oracle would write it.
Anything that keeps every oracle passing is allowed, so a big refactor is
fine when it makes the code better; the oracle is the review. Keep it in
proportion to the task: improve the code the work touches, and when you see
a larger win elsewhere, offer it instead of turning the task into a long
optimization project.

**How the work goes.**

- **Probe first.** Before you propose anything, call the real code with
small scripts and show what they print. Every law and every finding comes
with a probe that can be rerun.
- **Propose the laws, then build only the approved ones.** Each law is a
"For every …" sentence with where its promise is written: the docs, a
test, or a maintainer's decision. A question nobody has decided is fine:
state it as a limit.
- **Red first, like TDD, but the oracle goes red.** A bug becomes a law and
a history that fail on the unchanged code. Then fix production at once,
and show the run going green.
- **Never weaken or quarantine an oracle:** no skip, no `test.fails`, no
loosened expectation, no switch that turns a check off.
- **Build the strongest model the laws need.** Compare every observable
result they speak about. The model states the rule a user relies on,
never the code's algorithm, even when the docs describe that algorithm.
Give each law a calibration: a wrong answer the check must reject.
- **Run the oracles only through the gap check, never Vitest alone.** It
prints each test file's result first, then each gap as it is judged, and
ends with one `oracle-gaps: done` line. A run
can take minutes: start it in the background with output to a log at a
path of its own (never a fixed path under `/tmp`), and read the new lines
every few seconds, acting on a failure first. Stop a
run only by the process ID you recorded, never by name.
- **Green is not done.** A gap is a change to the owned code that no law
notices. There are no equivalent mutants: never call one equivalent.
Widen the histories or the check until the oracle sees it, and keep going
until a bug or a design question turns up.
- **Report classes of bugs:** the rule broken, and the measured share of
generated inputs that break it. Never call one minor.

**Skills.**

- To explore an area of the code (or the whole repository), find where an
oracle would help, or propose a new one, read
`packages/oracles/skills/oracles-explore/SKILL.md` in full
and follow it.
- Before you create or change an oracle, or change production code that an
oracle owns, read `packages/oracles/skills/oracles-design/SKILL.md`
in full and follow it.
- Before you review oracle work, read
`packages/oracles/skills/oracles-review/SKILL.md` in full.
- Before you act on review findings, read
`packages/oracles/skills/oracles-evaluate-review/SKILL.md` in
full.
- Lint each oracle file and each changed production file after you edit it.
Fix every report. Do not disable a rule.
- Typecheck each oracle file after you edit it (Vitest strips types without
checking them).
- Oracle files: `packages/**/*oracle.property.test.{ts,js,mjs}`. Gap check: `node packages/oracles/oracle-gaps/index.mjs --package <package dir> --source <src files>` (run `pnpm --filter @tanstack/oracles build` first, so the package resolves from `dist/`).

<!-- END @tanstack/oracles -->

## This repository

Agents working here have drifted from the block above in specific ways; each rule below closes one.

- **A law is an `oracleProperty` that owns the code it judges.** A whole-program dry run, a ledger or log audit, or an
end-to-end "calibration" run is not a substitute: it is slow, and the gap check cannot see it. Move decision logic
into pure functions that the laws own, and keep one integration run for the wiring only.
- **Unowned production code is a gap.** Run the gap check over every source file you changed, not one. A function no
law owns is either given a law or deleted. Do not leave old code beside its replacement.
- **The design-grammar trigger is not optional.** When one boundary has more than five laws, a law predicts no new
case, or the model has more than one branch per law, read
`packages/oracles/docs/instruments/design-grammar.md` and do its parts list before you write the model, as
`oracles-design` step 1 says.
- **Every feedback loop has a stated time budget, enforced as a law.** An oracle file finishes in seconds. A loop that
runs slower than its budget is a defect in its design, not something to wait out.
- **Delegation carries these rules.** When you hand oracle work to another agent, tell it to read this file and the
skill that applies before it starts. Check its result against the laws yourself: an agent's "done" or "passing"
report is not evidence.
- **A decision you were not given is a law change.** A tie-break, a threshold, a fallback, or a "deviation" that
changes what production promises goes to the maintainers before it goes into code.
5 changes: 5 additions & 0 deletions packages/oracles/oracle-gaps/capture-setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@ function render(value, seen = new Set(), depth = 0) {
// once per worker and call the hooks of the copy now running.
globalThis.__oracleGapsHooks = {
matcher(name, assertion) {
// Outside any test (a file-level hook, or async work that outlived its
// test) there is no row: the last one closed its hash (finishTest), and
// updating it throws out of the hook (#188). The assertion still runs,
// so a failing one still fails the file.
if (!inTest) return
try {
const rendered = `${name}(${render(chai.util.flag(assertion, `object`))})\n`
digest.update(rendered)
Expand Down
Loading