diff --git a/packages/oracles/skills/oracles-design/SKILL.md b/packages/oracles/skills/oracles-design/SKILL.md index 63708fd1..6196c107 100644 --- a/packages/oracles/skills/oracles-design/SKILL.md +++ b/packages/oracles/skills/oracles-design/SKILL.md @@ -322,6 +322,11 @@ in the model. cannot collide with a generated value (a fixed boundary shape). Otherwise derive it from the generated history (for example "the initial value plus one"). +- **Annotate `constructed[].build` when TypeScript widens literals.** Inside + an unannotated `oracleProperty(...)` call, TypeScript can widen union + string literals or fixed-length tuples returned by `constructed[].build`. + Give `build` an explicit return type (`build: (base): History => ({ ... })`) + or use `as const` on narrowed literals so the file typechecks cleanly. - **Every arbitrary must take its histories back.** Each `fixed` and constructed history goes back through the arbitrary, and one that cannot fails when the file loads, naming the history. Give each `.map` its inverse @@ -461,11 +466,15 @@ The options of `oracleProperty` are typed in `node_modules/@tanstack/oracles/src/oracle-property.ts` (`OraclePropertyOptions`). Read them there. -**Lint as you go.** Run the repository's lint on each oracle file and each -changed production file after you edit it, and again before you finish. Fix -every report. Do not disable a rule. +**Lint and typecheck as you go.** Run the repository's lint on each oracle +file and each changed production file after you edit it, and again before +you finish. Fix every report. Do not disable a rule. In a first session, the oracles lint plugin is not installed yet: run the repository's own lint, if it covers the oracle file, and go on. +When the repository uses TypeScript 5 or newer, also run its typecheck +(`tsc --noEmit`) on each oracle file after you edit it: Vitest strips types +without checking them, so a passing run does not catch type errors. Do not +hide errors with `@ts-ignore` or `@ts-expect-error`. Techniques: [guide ยง The driver and the check](../../docs/guide.md#the-driver-and-the-check). diff --git a/packages/oracles/skills/oracles-explore/SKILL.md b/packages/oracles/skills/oracles-explore/SKILL.md index 5190d64b..0bac1643 100644 --- a/packages/oracles/skills/oracles-explore/SKILL.md +++ b/packages/oracles/skills/oracles-explore/SKILL.md @@ -547,6 +547,13 @@ them and stop. generated inputs and sequences, the driver calls their real code, and the check compares the two at each step. + When the repository uses TypeScript 5 or newer, check that the oracle + file passes its typecheck (`tsc --noEmit`) as well as runs: Vitest + strips types without checking them. Where production files are `.js` or + `.mjs` and the package has a typed entry, import through that entry + instead of untyped relative paths (see + [Problems you may hit](references/problems.md)). + Writing the oracle can take a while, so keep the developer with you: send a short update at each part, or every few minutes, on what you are building and what you are finding out about their code. For example: diff --git a/packages/oracles/skills/oracles-explore/references/problems.md b/packages/oracles/skills/oracles-explore/references/problems.md index 2a1e45c9..e6b58726 100644 --- a/packages/oracles/skills/oracles-explore/references/problems.md +++ b/packages/oracles/skills/oracles-explore/references/problems.md @@ -65,6 +65,24 @@ suite (thousands of tests). Run it again with `NODE_OPTIONS=--max-old-space-size=8192`, or with `--contexts 2`. Keep every test and history: do not shrink the oracle to make it fit. +**TypeScript reports untyped imports (`TS7016` / `TS7006`) on `.js` or `.mjs` +production files.** Import through the package's typed entry where one +exists instead of an untyped relative `.js` or `.mjs` path. When no typed +entry covers the module, enable `allowJs` in the test or oracle tsconfig +instead of hiding errors with `any` or `@ts-ignore`. + +**TypeScript rejects `constructed[].build` on a union literal or tuple.** +Inside an unannotated `oracleProperty(...)` call, TypeScript can widen union +string literals or fixed-length tuples returned by `build`. Give `build` an +explicit return type (`build: (generated): History => ({ ... })`) or narrow +the literal with `as const`. + +**The repository's `tsconfig.json` does not cover the oracle file.** Vitest +strips types without checking them, so an excluded oracle file can pass +`oracle-gaps` while failing `tsc --noEmit`. When the repository uses +TypeScript 5 or newer, check that the oracle file typechecks under the +repository's `tsc --noEmit` (or a test tsconfig that extends `tsconfig.json`). + ## Probes **The tests import a build that is not built yet.** Import the source that diff --git a/packages/oracles/skills/oracles-review/SKILL.md b/packages/oracles/skills/oracles-review/SKILL.md index b3f998fc..b03ec565 100644 --- a/packages/oracles/skills/oracles-review/SKILL.md +++ b/packages/oracles/skills/oracles-review/SKILL.md @@ -105,6 +105,12 @@ search is your main job. Require a history step that simulates the contradictory signal. Expect production to fail at the boundary, before it releases established state or publishes success. +- **Unchecked TypeScript in oracle files.** Vitest strips types without + checking them, so a passing gap check does not prove that oracle `.ts` + files typecheck. When the repository uses TypeScript 5 or newer, check + that its `tsconfig.json` (or test/oracle tsconfig) covers the oracle files + and that `tsc --noEmit` passes without `@ts-ignore` or `@ts-expect-error` + hiding type errors. ## 4. Choose challenges for the real uncertainty diff --git a/packages/oracles/skills/oracles-setup/SKILL.md b/packages/oracles/skills/oracles-setup/SKILL.md index 233c0f16..2d43e0fc 100644 --- a/packages/oracles/skills/oracles-setup/SKILL.md +++ b/packages/oracles/skills/oracles-setup/SKILL.md @@ -153,6 +153,22 @@ If the repository's own lint or formatter covers the oracle files (for example, an older ESLint with Prettier over `test/`), keep the oracle files out of its globs, or match its style. Say which in your report. +**Typecheck.** Vitest strips TypeScript types without checking them, so a +passing oracle run does not prove that the oracle files typecheck. When the +repository uses TypeScript 5 or newer: + +- Verify that its `tsconfig.json` (or its test tsconfig) includes the oracle + files, and run its typecheck (for example `tsc --noEmit`). If the main + `tsconfig.json` excludes tests, add the oracle glob to the test tsconfig + or add a small `tsconfig.oracles.json` that extends it. +- When production files are `.js` or `.mjs` without matching `.d.ts` files, + import through the package's typed entry where one exists, or enable + `allowJs` in the test or oracle tsconfig so TypeScript does not reject + untyped relative imports. +- When the repository uses TypeScript older than 5, or none, keep the oracle + files out of its `tsc` run (step 2) and do not add a typecheck that uses + the gap check's own `tsc`. + **Lint.** Add both presets to the ESLint flat config: ```js @@ -322,15 +338,18 @@ optimization project. 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: ``. Gap check: ``. ``` If lint is an environment limit (step 3), replace the lint line with "Lint: -not available here ()." Fill in the two placeholders in step 7, -once their values exist. A run that stops before step 7 leaves them in -place, and its report says so. +not available here ()." If the repository does not use +TypeScript 5 or newer, omit the typecheck line. Fill in the two placeholders +in step 7, once their values exist. A run that stops before step 7 leaves +them in place, and its report says so. In a workspace with a package-local install, put the block in the package's instruction file, where its `node_modules` paths resolve. A root copy must