Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Changesets

Run `pnpm changeset` to describe a change for the changelog.

See [RELEASING.md](../RELEASING.md) for releases and npm setup.
2 changes: 1 addition & 1 deletion .changeset/calibration-history-bindings.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

Add direct `history` bindings for calibrations and `probeHistories` for automatic controls, so bound calibrations validate one selected premise instead of searching. Preserve fixed and enumerated history identity, including fixed declarations with unrelated `build` metadata, rebuild constructed histories from stable seeds, and resolve once per driver execution. Apply ordinary verdict ranking and optional difference requirements to bound mutants, validate clean declared reach, and retain selected-history error context. Retain search during migration with one warning per property outside collect-only runs, before search removal ahead of the first npm release.
Expand Down
2 changes: 1 addition & 1 deletion .changeset/constructed-stream-independent.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

A campaign's generated histories no longer depend on its constructed histories, and each constructed history runs several bases from a stream of its own. The `generated` unit draws only from the property's arbitrary. Constructed history k builds from each of the first `bases` draws of the arbitrary's sample at the campaign's seed plus k, and every base must enter the states it names. The new `histories.bases` option sets that number. It must be a whole number of at least 1 (default 5), or the property fails to load. So appending a constructed history keeps every fixed seed's generated histories and every other constructed history's bases. Before, half of the generated unit's runs were constructed histories, weighted by how many there were, so appending one moved every run's draw, and each constructed unit ran one history.
Expand Down
2 changes: 1 addition & 1 deletion .changeset/enumerated-declared-states.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

An enumerated source can declare the states its laws depend on: `histories: { enumerated, states, measured }`, where `enumerated` is the list a plain enumerated source passes, and `states` and `measured` are state names. Every enumerated history runs, so a required state needs no constructed history. A `reach` test after the histories fails when no enumerated history entered a state in `states`, and otherwise prints how many entered each declared state, as `<id> enumerated reach {...}`. A history counts once it is judged, passing or violating its law. The reach test reuses what each history's test recorded. It runs again only a history whose test never started, such as one that a `-t` filter left out. A history whose test failed before a verdict or timed out counts for nothing. A judged history that enters a state outside `states` and `measured` fails its test. An enumerated source fails to load when it holds a key other than `enumerated`, `states`, and `measured`, or a state that is not a name; only a generated source binds a probe to a state. A plain list of histories registers no `reach` test. Any enumerated source now fails to load when its `label` names a history `reach` or `determinism`, because the rerun command for that history would also select the framework test of that name.
2 changes: 1 addition & 1 deletion .changeset/gap-cli-baseline-report.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

The `oracle-gaps` report leads with the baseline, and a failing oracle file no longer stops the run.
Expand Down
2 changes: 1 addition & 1 deletion .changeset/gap-cli-block-per-law.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

A failing law no longer blocks the gap report for its whole file. In `oracle-gaps`, a test of an oracle file that fails with no mutant active judges nothing: it is left out per test, as a nondeterministic test is, and the passing tests of its file still judge the mutants the file owns. A failing law still runs in every copy of its file: its calls count toward the copy's call budget, its I/O and timers toward idle, and it keeps its reach, but its verdicts judge nothing and it is never charged extra work. A count cut that a failing law causes blocks the mutant by that law. A test of a `describe` whose `beforeAll` or `afterAll` throws is a failing law too. An owner file that fails outside its tests (it does not load, or a file-level hook throws) judges nothing, and another owner file's passing tests still judge the mutants they share. A mutant that no deterministic passing owner test reached is `blocked` by its owners' failing laws that reached it, and by owner files that judge nothing; its directive names them. The baseline prints one `oracle-gaps: blocked` line per failing law, named by its file and test names (or one per broken file), `results.json` lists each failing file's `laws`, and the report stays provisional.
2 changes: 1 addition & 1 deletion .changeset/gap-cli-extra-work.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

The `oracle-gaps` report no longer reports a shortcut for speed as `not-observed`. A survivor that changed no observation but made a test do more work is now `extra-work`. Before, its directive said to observe a value or widen the oracle, which cannot work for a branch whose fast and general paths give the same result, and an author who removed the code instead made it slower. Work is the number of site evaluations that the test's instrumented production code makes, a deterministic count, never a time. The `extra-work` directive names the test, its work before and after, and the bound to declare. `oracleProperty` takes a new `work: { ratio }` option. Under the gap report, a mutant whose work in one of the property's tests is more than `ratio` times the unmodified code's work is killed under the law `work bound`. `ratio` must be a finite number of at least 1. A plain Vitest run has no unmodified run to compare with, so there the bound judges nothing.
2 changes: 1 addition & 1 deletion .changeset/gap-cli-greppable-lines.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

Every line the `oracle-gaps` CLI writes for a check now starts with `oracle-gaps: ` and its kind, on stdout and stderr alike, cold and through `--daemon`, so an agent can act on the results as they stream with `grep '^oracle-gaps: '` and filter one kind by the word after the prefix:
Expand Down
2 changes: 1 addition & 1 deletion .changeset/gap-cli-never-crash.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

The `oracle-gaps` CLI no longer ends a run with a bare stack trace. A problem in the author's own files or arguments (bad arguments, a `--source` that is missing or not a file, a broken `owns` declaration, no oracle file or no owner, a Vitest config that throws when it loads, has no default export, or defines `test.projects`, a Vitest that does not load, a setup file that throws, an oracle file that fails with no mutant active, an authored mutant file that is not JSON or is incomplete) refuses the run: it exits 2 and prints `refused: <cause>` and `fix: <one step>`. When the output directory is known (even from `--out` alone, when other arguments are bad), the refusal is also written there as `results.json` (`{ "status": "refused", "cause", "directive" }`) and `summary.md`, replacing an earlier run's ending there, and the CLI's last line names that report (`oracle-gaps: done refused, report <path>`). Any other error is a bug in the CLI: it exits 3, says so, and writes its stack to `error.log` in the output directory (or the system's temporary directory when none is known), with `results.json` status `internal-error`. A check through `--daemon` ends the same way. A daemon serves only a CLI of its own code, so a second install of the CLI starts its own daemon rather than reading another version's reply.
Expand Down
2 changes: 1 addition & 1 deletion .changeset/gap-cli-runtime.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

The `oracle-gaps` CLI bounds a mutant's copies by counts, not by wall-clock limits, reports long runs, stops the processes it started, and writes nothing beside the tests.
Expand Down
2 changes: 1 addition & 1 deletion .changeset/gap-cli-temp-state.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

The `oracle-gaps` CLI keeps its working files out of the repository. The daemon's state (its lock, log, and evidence), the one-file bundles of workspace dependencies, and the default output directory now live in the OS temp directory, in a directory keyed by the package (`oracle-gaps-<hash>`, never a shared directory), which the OS cleans. A state that the OS removed is a cold start. `--out` is honored as before, and the run still prints its output path. While a run runs, its capture setup and Vitest configs are in `<package>/.oracle-gaps-<pid>/`, which it removes when it ends; one that a killed run left is removed by the next run. A run leaves nothing in the package, so there is nothing to add to `.gitignore` or to delete. Before, every run wrote `<package>/.oracle-gaps/` and `<dependency>/.oracle-gaps/bundle-*.mjs`.
2 changes: 1 addition & 1 deletion .changeset/gap-diff-base-limits-run.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

`oracle-gaps --diff-base <rev>` now judges only the mutants on lines changed since `<rev>`, for fast feedback after a change. Operator and authored mutants both count, and a mutant is on a changed line when any line from its first to its last is changed. Every line of a source file that git does not track is changed. The baseline still runs every test file that the run without the option runs, and each judged mutant gets the outcome it gets in the full run. An authored mutant that does not apply is reported on every run with the option, as it is without it. The run says so on its stream before the baseline, `oracle-gaps: note --diff-base <rev>: <n> of <m> mutants are on changed lines; the others are not judged in this run`, and in the same sentence in `summary.md`; `<m>` counts the run without the option, with the same `--only` or `--sample`. Its `results.json` and `summary.md` inputs say `a partial run (--only, --sample, or --diff-base)`, as an `--only` or `--sample` run's do (their text used to read `(--only or --sample)`). Authored mutants are marked `inDiff` too.
Expand Down
2 changes: 1 addition & 1 deletion .changeset/gap-report-directives.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

The `oracle-gaps` report gives each gap a class and one directive with a concrete next step. A message never offers an exit such as an equivalent mutant or a maintainer approval. Survivors are `not-judged`, `indeterminate`, `dead-code`, `branch-never-taken`, `not-infected`, or `not-observed`. A `crashed` gap names the error that production threw, and tells the author to record it as an observation and state the law. Standard output is short. It has the totals, one legend line for each class, and gaps grouped by function. It also has the unowned warnings counted for each function, and the paths of `summary.md` and `results.json`. The full report is in `summary.md`. The CLI also streams its progress: the baseline result first, then one line for each gap when the CLI judges it, then the summary.
7 changes: 7 additions & 0 deletions .changeset/initial-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/oracles': patch
'@tanstack/eslint-plugin-oracles': patch
---

Publish the first release of the oracle testing framework, the bundled
`oracle-gaps` CLI and skills, and the ESLint plugin for oracle tests.
2 changes: 1 addition & 1 deletion .changeset/oracle-property-const-inference.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

`oracleProperty` infers a history from a literal with `const`, so a zero-argument `constructed[].build` that returns a literal compiles, and an annotated `model` without `resolve` keeps its annotated type, as on main. `constructed[].build` may return the read-only view of a history, `ReadonlyHistory`, which is a new public type export.
Expand Down
2 changes: 1 addition & 1 deletion .changeset/oracle-property-owns.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/oracles': minor
'@tanstack/oracles': patch
---

`oracleProperty` takes an `owns` list: the production files or functions (`src/x.ts`, `src/x.ts#fn`) whose static call tree the oracle owns. The `oracle-gaps` CLI reads `owns` from an object-literal argument of any call in a test file, so a wrapper that forwards `owns` to `oracleProperty` (`registerX('id', { owns: [...] })`) names it at its call. A test file that calls `oracleProperty`, or passes such a list, is an oracle file, and it owns the union of its lists. Every test file is read, because a file that never calls `oracleProperty` still owns code when it passes `owns` to a wrapper that it imports. An `owns` key inside an assertion's arguments is data, so it is not read: an `expect` chain (including `.not`, `.soft`, a computed matcher, and an aliased `expect`), `assert` and its members, `chai`, `expectTypeOf`, `assertType`, and every binding imported from Node's `assert` (named, default, or namespace). An `owns` key in an object literal passed to any other call is read, so an unrelated domain object with that key makes the file an oracle file. A local function named like an assertion, such as `function assert() {}`, is skipped too. Each list must be a literal array of string or plain template literals. It refuses a run that has no oracle file, or in which no file owns a selected source, with one diagnostic. Before, such a run reported zero gaps without judging anything. `law.owner` is removed. Each run writes its output to a directory of its own by default, not to a shared `/tmp/oracle-gaps`.
8 changes: 4 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ name: PR

on:
pull_request:
push:
branches: [main]
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
# Only a newer push to the same pull request cancels a run. Every commit on
# main keeps its run, so every commit gets a preview.
# Cancel superseded PR checks. version.yml calls this on main pushes;
# release.yml calls it after a Changesets version PR is merged.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
Expand Down Expand Up @@ -62,6 +61,7 @@ jobs:
- run: pnpm run typecheck
# The classifier's unit check: sample changes and the sets they must turn on.
- run: pnpm run test:ci-paths
- run: pnpm run test:release
- run: pnpm --filter @tanstack/oracles run test
# Checks the partition of the end-to-end gap oracle into CI shards
# (packages/oracles/scripts/e2e-shards.mjs) ahead of the shard jobs,
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Release

on:
pull_request:
types: [closed]
branches: [main]

permissions:
contents: read

jobs:
checks:
name: Validate
if: >-
github.repository == 'TanStack/oracles' &&
github.event.pull_request.merged == true &&
github.event.pull_request.head.ref == 'changeset-release/main' &&
github.event.pull_request.head.repo.full_name == github.repository
# Keep the same-commit syntax supported by actionlint's workflow parser.
uses: ./.github/workflows/pr.yml # zizmor: ignore[self-repository]

release:
needs: checks
# Skipped PR closures never enter this queue. Retain eligible pending jobs.
concurrency:
group: release-main
cancel-in-progress: false
queue: max
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.merge_commit_sha }}
persist-credentials: true # Changesets pushes release tags.
- name: Setup Tools
uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
- name: Build packages
run: pnpm run build
- name: Check packages
run: pnpm run test:publint
- name: Publish packages
run: |
set -euo pipefail
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
if [ -n "$NPM_TOKEN" ]; then
export NPM_CONFIG_USERCONFIG="$RUNNER_TEMP/release.npmrc"
printf '//registry.npmjs.org/:_authToken=%s\n' "$NPM_TOKEN" > "$NPM_CONFIG_USERCONFIG"
fi

# Invoke only publication, even if future changesets remain at this merge.
pnpm run changeset:publish

head_commit=$(git rev-parse HEAD)
release_manifests=()
tag_refs=()
for manifest in packages/*/package.json; do
if [ "$(jq -r '.private // false' "$manifest")" = true ]; then
continue
fi
name=$(jq -r '.name' "$manifest")
version=$(jq -r '.version' "$manifest")
tag="$name@$version"
tagged_commit=$(git rev-list -n 1 "$tag" 2>/dev/null) || continue
if [ "$tagged_commit" != "$head_commit" ]; then
continue
fi

release_manifests+=("$manifest")
tag_refs+=("refs/tags/$tag")
done

# Push all eligible tags before creating releases so a fresh retry
# can recover after a GitHub API failure.
if [ "${#tag_refs[@]}" -eq 0 ]; then
exit 0
fi
git push --atomic origin "${tag_refs[@]}"
for manifest in "${release_manifests[@]}"; do
name=$(jq -r '.name' "$manifest")
version=$(jq -r '.version' "$manifest")
tag="$name@$version"
if gh release view "$tag" >/dev/null 2>&1; then
continue
fi
notes=$(mktemp "$RUNNER_TEMP/release-notes.XXXXXX")
awk -v heading="## $version" '
$0 == heading { found = 1; next }
found && /^## / { exit }
found { print }
END { if (!found) exit 1 }
' "$(dirname "$manifest")/CHANGELOG.md" > "$notes"
gh release create "$tag" --verify-tag --title "$tag" --notes-file "$notes"
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# New npm packages need a token for their first publication. Once
# trusted publishers are configured, remove the secret to use OIDC.
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # zizmor: ignore[use-trusted-publishing]
43 changes: 43 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Version Packages

on:
push:
branches: [main]

concurrency:
group: version-main
cancel-in-progress: false

permissions:
contents: read

jobs:
checks:
name: Validate
# Keep the same-commit syntax supported by actionlint's workflow parser.
uses: ./.github/workflows/pr.yml # zizmor: ignore[self-repository]

version:
needs: checks
if: github.repository == 'TanStack/oracles'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: true # Changesets pushes the version PR branch.
- name: Setup Tools
uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
- name: Create or update version PR
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
with:
version: pnpm run changeset:version
branch: main
commit: 'ci: Version Packages'
title: 'ci: Version Packages'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ Oracle-based testing for TypeScript: state a law, generate the histories where
it matters, and check production against an independent model.

This package is under construction while it is extracted from TanStack DB's
oracle suite. It is not published to npm yet; previews are published from
every commit with [pkg.pr.new](https://pkg.pr.new).
oracle suite. CI publishes previews for passing pull-request and `main`
commits with [pkg.pr.new](https://pkg.pr.new).

For npm releases, see [the release instructions](RELEASING.md).

## Packages

Expand Down
Loading
Loading