diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0a4cb20 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,100 @@ +# EditorConfig: https://editorconfig.org +# In VS Code, install the "EditorConfig for VS Code" extension (EditorConfig.EditorConfig). + +root = true + +# Defaults for every file +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +# Python +[*.{py,pyi}] +indent_size = 4 +max_line_length = 88 + +# Mojo (`mojo format` is Black-style, 88 columns; the fire emoji extension is also valid) +[*.{mojo,🔥}] +indent_size = 4 +max_line_length = 88 + +# Rust (rustfmt defaults: 4 spaces, 100 columns) +[*.rs] +indent_size = 4 +max_line_length = 100 + +# Cargo manifests and rustfmt config +[{Cargo.toml,Cargo.lock,rustfmt.toml,.rustfmt.toml,clippy.toml}] +indent_size = 4 + +# Mojo project manifest +[{mojoproject.toml,pixi.toml,pixi.lock}] +indent_size = 4 + +# YAML +[*.{yml,yaml}] +indent_size = 2 + +# JSON and friends +[*.{json,jsonc,json5}] +indent_size = 2 + +# Web +[*.{js,jsx,mjs,cjs,ts,tsx,css,scss,less,html,vue,svelte}] +indent_size = 2 + +# Config formats +[*.{toml,ini,cfg}] +indent_size = 4 + +[*.xml] +indent_size = 2 + +# Markdown: trailing spaces are significant (hard line breaks) +[*.{md,markdown}] +indent_size = 2 +trim_trailing_whitespace = false + +# typst +[*.{typ}] +indent_size = 4 +trim_trailing_whitespace = false + +# Shell scripts +[*.{sh,bash,zsh}] +indent_size = 2 + +# Makefiles require tabs +[{Makefile,makefile,*.mk}] +indent_style = tab + +# Go uses tabs +[*.go] +indent_style = tab + +# Windows-only scripts need CRLF +[*.{bat,cmd,ps1}] +end_of_line = crlf + +# Dockerfiles +[{Dockerfile,Dockerfile.*,*.dockerfile}] +indent_size = 4 + +# Terraform +[*.{tf,tfvars,hcl}] +indent_size = 2 + +# Don't touch these +[LICENSE*] +insert_final_newline = false + +[*.{diff,patch}] +trim_trailing_whitespace = false + +[*.min.{js,css}] +insert_final_newline = unset +trim_trailing_whitespace = unset diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..997504b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# SCM syntax highlighting & preventing 3-way merges +pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml new file mode 100644 index 0000000..7e5827c --- /dev/null +++ b/.gitea/workflows/test.yml @@ -0,0 +1,25 @@ +# pplus-core on Gitea Actions, with a runner that has no container image: the act_runner runs jobs directly on the +# host's shell ("host mode"; pplus-web's docs/deploy.md has the runner setup). Every push and pull request builds +# and tests core, and checks that every Mojo program of ours still passes, offline, from godbolt's stored answers. +name: Test +on: + push: + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: quarto-deploy + steps: + - uses: actions/checkout@v4 + - name: Toolchain on the host + run: | + node --version + npm --version + python3 --version || echo "python3 missing: the pipelines' tests are skipped" + - run: npm ci + - run: npm test + - name: Our Mojo programs pass + run: | + if command -v python3 >/dev/null; then python3 scripts/mojo/corpus.py status --strict + else echo "python3 missing: corpus status skipped"; fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de1b366 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +node_modules/ +dist/ +.DS_Store +patches/ +package/ +# the pinned Dafny, fetched by `pixi run dafny-fetch` (scripts/dafny.py) +.tools/ +# pixi environments +.pixi/* +!.pixi/config.toml + +# Python +__pycache__/ +*.pyc diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..ae27d0b --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,59 @@ +# AGENTS.md + +Instructions for coding agents (and people) changing pplus-core. Read this first, then the [README](README.md) for what core is and where things are. When this file and a task's instructions disagree, the task wins; say so in your summary. + +## Build, test, and the gate + +```bash +pixi run test # build, then every test (node --test against dist/, the pipelines' Python tests included) +pixi run ci # the gate: every test, and no Mojo program of ours failing +``` + +Without pixi (a sandbox with only Node and Python): + +```bash +npx tsc -p tsconfig.json && node --test tests/*.test.mjs +python3 scripts/mojo/corpus.py status --strict +``` + +**Finish every change with the gate green.** The baseline passes completely; there is no known failure to work around. If a test fails, fix the cause or stop and report it. Do not skip, loosen, or delete a test to get green. + +The full suite takes about two minutes. While iterating, build and run one file: `npx tsc -p tsconfig.json && node --test tests/sync-hub.test.mjs`. + +## Hard rules + +1. **Core has no DOM.** What a program means is decided without a browser. A library module never touches `document`, `window`, `localStorage` or `navigator`, never imports one of the course's page widgets, and never imports from outside `src/`; `tests/boundary.test.mjs` holds it to that. The widgets (listed in that test) live beside the engines only so the course and pplus-web take them from one place. +2. **Do not edit generated files by hand.** `src/mojo/generated/*` and `syntax/mojo.xml` come from the corpus pipeline (`pixi run mojo-emit`, `mojo-status`, `play`). `mojo/corpus/` comes from `mojo-harvest`. `mojo/golden/` holds godbolt's answers and comes only from `mojo-verify`. +3. **Do not edit a `.mojo` file's text unless the task needs it.** A stored godbolt answer is keyed by the whole source, header comments included, so any edit (even to a comment) makes the program unverified until it is asked again on the network. If you add or change one, say in your summary that it needs `pixi run mojo-verify-item '/'`. +4. **Never claim Mojo compiles, runs, or prints something without the real compiler's answer.** Mojo is pinned to 1.1.0. The checker may never report an error on a program the compiler accepts, and the interpreter must print exactly what godbolt printed or decline; `tests/mojo-check.test.mjs` and `tests/mojo-run.test.mjs` hold them to that. Every Mojo construct you write into core must pass `checkMojo`, and every standard-library name must exist in `src/mojo/generated/stdlib.ts` or `types.ts`. +5. **Never let the prover call something proved that a run breaks.** "Proved" must be a proof. A change to `src/engines/pseudo/logic.ts`, `solver.ts` or `vcgen.ts` keeps `tests/prover-soundness.test.mjs` and `tests/engine-solver.test.mjs` green, and a fact the prover assumes must hold for every value a run can produce, or be guarded by an obligation. When you find a soundness bug, add the program that shows it to `tests/prover/` with a `// MUST-NOT-PROVE:` (or `// RUN-STOPS:`) header first, see the test fail, then fix the rule ([docs/engines.md](docs/engines.md#soundness)). +6. **No new dependencies.** TypeScript is the only npm package; there is no runtime dependency. The pipelines (the Mojo corpus, the Dafny pin) are Python's standard library only. Tools that are not npm packages are pinned: Mojo, Node and Python by pixi, Dafny by `scripts/dafny.py` (a version and a SHA-256 per platform). +7. **You have no network** in most sandboxes. Godbolt (`mojo-verify`), GitHub (`mojo-harvest`, `mojo-fetch`, `dafny-fetch`) need one. Never fake their results; leave those steps to the owner and list them. +8. **Core's exports are pplus-web's API.** pplus-web imports core's built modules as `#core/` and builds against the declarations in `dist/`. Renaming or removing an export, or changing what a function returns, breaks the site; when you do it, say so in the summary so web is updated in the same release. + +## Conventions + +- **Commands are pixi tasks.** Name them as `pixi run ` in docs, comments, and messages. A new command is a task in `pixi.toml` with a `description` and a row in the README's Commands table; `tests/tasks.test.mjs` fails otherwise, and also fails on any `pixi run ` that names no task. `package.json` keeps only `build`, `watch`, `check`, `test` (what CI uses). +- **Docs.** The README is the front door: keep it short. Put the engines, the prover and its soundness in [docs/engines.md](docs/engines.md), verdicts in [docs/trust.md](docs/trust.md), exercises in [docs/exercises.md](docs/exercises.md), and Mojo of our own and the pipeline in [docs/mojo-corpus.md](docs/mojo-corpus.md). Update the document a change belongs in, in the same commit. +- **Tests run against `dist/` with no DOM.** A test that needs a piece of work uses a `Workspace` (`src/common/workspace.ts`) with `workForProblem` (`src/common/problems.ts`), not pplus-web's session. +- **TypeScript.** Strict mode, ES modules, imports with the `.js` suffix (`from './workspace.js'`). Indent like the file you are editing (some files use two spaces, some four). A JavaScript module's exported function gets JSDoc for its optional parameters, so the declaration pplus-web builds against says so. +- **Stable ids.** Diagnostic ids (`matho-refused`, `reserved-name`, ...) and obligation kinds (`index`, `argument`, ...) are asserted by tests and shown by pplus-web. Change one only on purpose, and update every test and link that names it. +- **Writing.** User-facing copy is US English (color, behavior, optimized, labeled). Plain sentences; say what a thing does, not how good it is. + +## Adding things + +| To add | Do | +|---|---| +| A catalog problem | `pixi run new-exercise ` for one built around a Mojo program, or copy `src/exercises/_template.ts` ([docs/exercises.md](docs/exercises.md)) | +| A question about the compiler | `pixi run new-probe ""` | +| Realistic Mojo for the interpreter | `pixi run new-stress ""`, with the output you predict in `# expect-stdout:` lines | +| A pseudo regression program | a file in `tests/corpus/` whose `// EXPECT:` lines are the output it must print | +| A prover soundness regression | a file in `tests/prover/` whose `// MUST-NOT-PROVE: @` names an obligation a run breaks, or `// RUN-STOPS: @` where a run must stop | +| A command | a task in `pixi.toml` and a row in the README's Commands table | +| A language | a `LanguageService` (`src/common/types.ts`) in `src/services/`, registered in `src/services/index.ts` | + +## Delivering work + +- One logical change per commit, with a message that says what changed and why: the problem first, then what each part of the change does. +- When the owner asks for patches, export them with `git format-patch -o patches/ ` (the `patches/` folder is ignored by git) and do not paste whole files into chat. +- End with a summary: what you changed, the gate's result, anything you could not verify (network steps), anything that changes core's exports, and anything you noticed but left alone. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2ed0308 --- /dev/null +++ b/README.md @@ -0,0 +1,108 @@ +# pplus-core + +pplus-core is the part of Programming+ that has to be right: the languages, the translators between them, the Mojo checker and interpreter, the prover, the fuzzer, the x86-64 machine model, and the stored answers of the real tools that everything it says rests on. It has no DOM. pplus-web (the site, the editor, the views and the Quarto extension) and the course site use it as a pinned dependency. + +- **Languages:** pseudo (parser, checker, interpreter, the English reader for lingo), matho (equations in LaTeX), speco (specifications), Mojo (a checker and an interpreter held to the real compiler), x86-64 on a model machine with caches, a pipeline and an out-of-order core. +- **Translators:** pseudo to Mojo, lingo, matho and speco, with line maps and located refusals, and the hub that keeps the linked languages in step (`src/sync/`). +- **Verification:** the prover (`src/engines/pseudo/logic.ts`, `solver.ts`, `vcgen.ts`), sound and held to it by tests; the fuzzer (`src/common/fuzz.ts`); and a pinned Dafny (`scripts/dafny.py`). +- **Stored answers:** the Mojo corpus (`mojo/`): material harvested from Modular's repositories at pinned commits, our own probes and programs, and godbolt's answers for every one of them (`mojo/golden/`). +- **A workspace:** `src/common/workspace.ts` is one piece of work and everything its sources mean. pplus-web's session extends it. +- **A command line:** `pixi run cli check|run|prove|fuzz|translate `. + +Everything it says about Mojo is pinned to **Mojo 1.1.0** and checked against the real compiler on [Compiler Explorer](https://godbolt.org). + +## Quick start + +With [pixi](https://pixi.sh) (it brings the pinned Mojo, Node and Python): + +```bash +pixi run test # build, then every test +pixi run ci # the gate: every test, and no Mojo program of ours failing +pixi run cli prove tests/corpus/27-quantifiers.pseudo +pixi run dafny-fetch # once: the pinned Dafny, into .tools/ +``` + +Without pixi, with Node 20 or later (and `python3` for the pipelines' tests): + +```bash +npm install && npm test +``` + +## Commands + +Every command is a pixi task (`pixi task list` shows them with their descriptions). `tests/tasks.test.mjs` fails if this table and `pixi.toml` disagree. + +| Task | What it does | +|---|---| +| **Build and test** | | +| `install` | Install TypeScript, the only npm dependency | +| `build` | Compile `src/` to `dist/`, with type declarations for pplus-web | +| `watch` | Rebuild `dist/` on every change | +| `check` | Type-check only | +| `test` | Build, then run every test, the pipelines' Python tests included | +| `cli` | `pplus check\|run\|prove\|fuzz\|translate `: core without a browser ([scripts/cli.mjs](scripts/cli.mjs)) | +| `engines-diff ` | Show what a course checkout has not taken yet from the engines ([docs/engines.md](docs/engines.md)) | +| `engines-export ` | Copy the engines into a course checkout, TypeScript modules as built ([docs/engines.md](docs/engines.md)) | +| **Dafny, pinned** ([scripts/dafny.py](scripts/dafny.py)) | | +| `dafny-fetch` | Download the pinned Dafny into `.tools/`, checked by SHA-256 (network, once) | +| `dafny` | Run the pinned Dafny with the arguments given, e.g. `pixi run dafny verify file.dfy` | +| **Write content** | | +| `new-exercise ` | Start an exercise whose Mojo lives in `mojo/local/.mojo` ([docs/exercises.md](docs/exercises.md)) | +| `new-probe ` | Start `mojo/probes/.mojo`: one question about the compiler ([docs/mojo-corpus.md](docs/mojo-corpus.md)) | +| `new-stress ` | Start `mojo/stress/.mojo`: realistic Mojo that tests the interpreter | +| `play ` | For `mojo/local/.mojo`: run, verify on godbolt, build, list the assembly, test | +| `play-watch ` | The same, again on every save (tests off) | +| **The Mojo corpus** ([docs/mojo-corpus.md](docs/mojo-corpus.md)) | | +| `mojo-verify` | Ask godbolt about every program with no answer yet (network) | +| `mojo-verify-item ` | Ask again about one item, e.g. `'probes/life-*'` (network) | +| `mojo-verify-dry` | Show what `mojo-verify` would send; send nothing | +| `mojo-verify-diagnostics` | Also check the compiler's own diagnostic tests (opt-in; network) | +| `mojo-status` | Judge every item from the stored answers, offline; writes `mojo/golden/STATUS.md` | +| `mojo-status-strict` | The same, and fail if a program we wrote fails | +| `mojo-harvest` | After editing `mojo/pin.json`: fetch Modular's sources, process, regenerate (network) | +| `mojo-harvest-local [dir]` | Harvest, with zips standing in for sources the pin leaves unresolved | +| `mojo-harvest-offline [dir]` | Harvest from zips only, no network | +| `mojo-fetch` | Re-resolve every ref in the pin and rewrite the lock (network) | +| `mojo-emit` | Regenerate `src/mojo/generated/` and `syntax/mojo.xml` from the pin and corpus, offline | +| `mojo-test` | The corpus pipeline's own tests | +| `mojo-run ` | Run one Mojo file on the pinned local compiler | +| `mojo-probes-local` | Run every probe on the local compiler (a quick look) | +| `mojo-update` | After editing the pin: harvest, verify, status, test | +| **Ship** | | +| `ci` | What CI runs: every test, and no program of ours failing | +| `package` | Zip what git tracks, and nothing it ignores, into `package/` for sharing | + +## Where things are + +``` +AGENTS.md rules for changing core (read first) +src/ + common/ the workspace, the problem catalog, the fuzzer, the run view's data, the language + reference, the machine presets, the shared types + engines/pseudo/ the pseudo language and the prover (logic, solver, vcgen in TypeScript), and the course's + page widgets for it (excluded from the build; see docs/engines.md) + engines/asm86/ the x86-64 model machine, and the course's widgets that draw it (views, hwviews) + engines/shared/ text helpers, and the course's DOM helpers + services/ one adapter per language behind LanguageService; the compiler request and backend + sync/ the translators and the hub that keeps the linked languages in step + mojo/ the Mojo checker, interpreter, lifetimes, practices, AT&T-to-Intel; generated/ from the corpus + exercises/ one file per catalog problem + curriculum/ a lesson corpus kept as an interpreter fixture +syntax/mojo.xml the Mojo words as a KDE syntax for Pandoc (generated; pplus-web copies it) +tests/ node --test against dist/; corpus/ (pseudo programs), prover/ (soundness regressions) +mojo/ the Mojo corpus: the pin and lock, harvested material, our programs, godbolt's answers +scripts/ the tasks above; scripts/mojo/ is the corpus pipeline; dafny.py the Dafny pin; cli.mjs +docs/ the documents below +``` + +## Read next + +| Document | For | +|---|---| +| [AGENTS.md](AGENTS.md) | Rules for anyone changing core, coding agents included: the gate, what not to edit, conventions | +| [docs/engines.md](docs/engines.md) | The engines, the prover and its soundness, and how the course takes them | +| [docs/trust.md](docs/trust.md) | Every verdict core produces: which tool earns it, what it means, and what it does not mean | +| [docs/mojo-corpus.md](docs/mojo-corpus.md) | Writing Mojo of our own and moving to a new Mojo version | +| [docs/exercises.md](docs/exercises.md) | Adding a catalog problem | +| [docs/sync-coverage.md](docs/sync-coverage.md) | What each translator can say, written by the tests | +| [docs/asm-coverage.md](docs/asm-coverage.md) | Which instructions compiled Mojo uses, against what the machine models | diff --git a/docs/engines.md b/docs/engines.md index d9f2008..4374400 100644 --- a/docs/engines.md +++ b/docs/engines.md @@ -1,15 +1,14 @@ # The engines -Programming+ runs the language engines that the course site also runs, and draws the hardware views with the course's stylesheets, so a program behaves the same in the app as on a course page. **This repository owns the engines.** Changes are made and tested here, and the course copies them from here (`pixi run engines-export`). The engines started as a copy of the course's modules; the course no longer sends changes the other way. +Programming+ runs the language engines that the course site also runs, so a program behaves the same in the app as on a course page. The course's widget stylesheets live in pplus-web (`styles/course/`), which compares them with the course's. **This repository owns the engines.** Changes are made and tested here, and the course copies them from here (`pixi run engines-export`). The engines started as a copy of the course's modules; the course no longer sends changes the other way. | Here | The course receives it as | What it is | |---|---|---| | `src/engines/pseudo/` | `static/js/pseudo/` | The pseudo language: parser, checker, interpreter, the English (lingo) reader, the prover (`logic.ts`, `solver.ts`, `vcgen.ts`), translation | | `src/engines/asm86/` | `static/js/asm86/` | The x86-64 model machine, its caches, pipeline and out-of-order core, and the widgets that draw them | | `src/engines/shared/` | `static/js/shared/` | DOM helpers, URL state, text distance, charts | -| `styles/course/` | `static/css/base/`, `static/css/widgets/` | The widget stylesheets ([styles/course/README.md](../styles/course/README.md)) | -The engines are wrapped behind one `LanguageService` interface (`src/core/types.ts`, adapters in `src/services/`). Modules the app does not use are excluded from the build in `tsconfig.json`. A change in `src/engines/` is a change to the course's language, so it needs a test here and goes to the course by export. +The engines are wrapped behind one `LanguageService` interface (`src/common/types.ts`, adapters in `src/services/`). The course's page widgets (the pseudo views, the asm86 `views`/`hwviews`, the shared DOM helpers) sit beside the engines so the course and pplus-web take them from one place; the pseudo ones and a few others are excluded from core's build in `tsconfig.json`, and `tests/boundary.test.mjs` keeps core's library modules from importing any of them. A change in `src/engines/` is a change to the course's language, so it needs a test here and goes to the course by export. ## The prover @@ -54,6 +53,6 @@ One addition to the pseudo language lives outside the engine, in app code: `DECL 1. `pixi run engines-diff /static` shows what the course has not taken yet: for each module, the file the course would receive (`src/engines/` as written, `dist/engines/` for a TypeScript module) against the course's copy, whitespace ignored, and the files only one side has. 2. `pixi run engines-export /static` builds and writes those files into the course's `static/js/`. A TypeScript module arrives as plain ES-module JavaScript, so the course's pages import it unchanged. Source maps are not copied. 3. In the course repository, review the diff and run its pages before committing. -4. For the stylesheets, follow [styles/course/README.md](../styles/course/README.md); they are still identical on both sides. +4. The course's stylesheets are pplus-web's to compare (`styles/course/README.md` there). A change someone makes in the course's copy is not picked up from there. Bring it here as a change with a test, then export. diff --git a/docs/mojo-corpus.md b/docs/mojo-corpus.md index 19b851b..67a7247 100644 --- a/docs/mojo-corpus.md +++ b/docs/mojo-corpus.md @@ -81,7 +81,7 @@ The dialect markers in the pin are a cheap first look: `newer` patterns are synt | `mojo/golden/.json` | Godbolt's answer for one program, keyed by compiler, mode, arguments, stdin and source | `verify` | | `mojo/golden/STATUS.md` | Every item's verdict against the goldens | `status` (also `harvest`, `verify`) | | `src/mojo/generated/` | What the app reads at run time: `pin.ts` (version, compiler), `tokens.ts` (the words, removed words and the compiler's messages for them), `editor.ts` (comment and indentation rules), `programs.ts` (`mojo/local/` programs with their verdicts), `stdlib.ts` and `types.ts` (which package exports each name, which types are copyable), and `listings.ts` (exercise listings, written by `scripts/mojo/listings.mjs` during `play`) | `harvest`/`emit`; `verify` and `status` refresh `programs.ts` | -| `quarto/_extensions/pplus/syntax/mojo.xml` | The same words as a KDE syntax for Pandoc listings | `harvest`/`emit` | +| `syntax/mojo.xml` | The same words as a KDE syntax for Pandoc listings (pplus-web copies it into its Quarto extension with its quarto-css task) | `harvest`/`emit` | Commit all of it. The stored answers are what make `pixi run test` and `mojo-status` work offline. diff --git a/docs/trust.md b/docs/trust.md index 89a2034..8cb20eb 100644 --- a/docs/trust.md +++ b/docs/trust.md @@ -1,12 +1,14 @@ # What each badge and verdict means +pplus-web shows the badges; the verdicts behind them come from pplus-core (the prover, the fuzzer, the translators, the compiler's stored and live answers, the model machine). This page is kept here, beside what produces them. + Programming+ is built for checking work that someone or something else produced, so every claim it shows names what answered it, and none claims more than that. This page lists each one: who earns it, what it means, and what it does not mean. When a new badge or verdict is added, it gets a row here in the same commit. ## Where code came from | Shown | Earned by | Means | Does not mean | |---|---|---|---| -| **Generated from pseudo** | The Bridge's Mojo tab, always (`mojoProvenance` in `src/core/provenance.ts`); Mojo copied from it with **Edit in Developer** | The translator wrote this Mojo from the pseudo, literally, with a header comment saying so | That anyone has read it, or that it is the Mojo a person would write | +| **Generated from pseudo** | The Bridge's Mojo tab, always (`mojoProvenance` in pplus-web's `src/core/provenance.ts`); Mojo copied from it with **Edit in Developer** | The translator wrote this Mojo from the pseudo, literally, with a header comment saying so | That anyone has read it, or that it is the Mojo a person would write | | **Started from generated Mojo** | Generated Mojo edited in the Developer area (`mojoOrigin: 'generated-edited'`) | A person has changed generated Mojo | That the person reviewed the parts they did not change | | (badge cleared) | **I've reviewed this**, in the Developer area only | The person says they reviewed it; the header comment goes too | That anything checked the review. Compiling and editing never clear the badge | @@ -36,7 +38,7 @@ The Prove tab reports every obligation in three statuses (`src/engines/pseudo/vc | Shown | Earned by | Means | Does not mean | |---|---|---|---| -| A routine's cases in the Tests tab | The fuzzer (`src/core/fuzz.ts`), with the seed and input count shown | Every input listed was run and checked against each claim and limit | That untried inputs pass. "Held on 300 inputs" is evidence, not proof | +| A routine's cases in the Tests tab | The fuzzer (`src/common/fuzz.ts`), with the seed and input count shown | Every input listed was run and checked against each claim and limit | That untried inputs pass. "Held on 300 inputs" is evidence, not proof | | A failure's smallest input | Shrinking in the fuzzer | The smallest input it found that fails the same way | The only failing input | ## What a translation says diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b630705 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,32 @@ +{ + "name": "pplus-core", + "version": "0.2.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pplus-core", + "version": "0.2.0", + "devDependencies": { + "typescript": "^6.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/typescript": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3f5c6a3 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "pplus-core", + "version": "0.2.0", + "private": true, + "type": "module", + "description": "Programming+ core: the languages, translators, Mojo checker and interpreter, prover, fuzzer and machine model, with the stored answers of the real tools. Day-to-day commands are pixi tasks (pixi.toml); these scripts are what CI and a machine without pixi need.", + "scripts": { + "build": "tsc -p tsconfig.json", + "watch": "tsc -p tsconfig.json --watch", + "check": "tsc -p tsconfig.json --noEmit", + "test": "tsc -p tsconfig.json && node --test tests/*.test.mjs" + }, + "devDependencies": { + "typescript": "^6.0.0" + }, + "engines": { + "node": ">=20" + } +} diff --git a/pixi.lock b/pixi.lock new file mode 100644 index 0000000..322a3fb --- /dev/null +++ b/pixi.lock @@ -0,0 +1,1395 @@ +version: 7 +platforms: +- name: linux-64 + virtual-packages: + - __unix=0=0 + - __linux=4.18 + - __glibc=2.28 + - __archspec=0=x86_64 +- name: osx-arm64 + virtual-packages: + - __unix=0=0 + - __osx=13.0 + - __archspec=0=m1 +environments: + default: + channels: + - url: https://conda.modular.com/max/ + - url: https://conda.anaconda.org/conda-forge/ + packages: + linux-64: + - conda: https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-20_gnu.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/bzip2-1.0.8-hda65f42_10.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/c-ares-1.34.8-hebe6cf0_2.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/icu-78.3-py310h44b86e0_2.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/keyutils-1.6.3-h7cc23a3_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/krb5-1.22.2-hbc21106_2.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.46.1-default_hbd61a6d_102.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libabseil-20260526.0-cxx17_h0dc7533_2.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libbrotlicommon-1.2.0-h39a168f_4.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libbrotlidec-1.2.0-ha411449_4.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libbrotlienc-1.2.0-h018ffa1_4.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libedit-3.1.20250104-pl5321h373387f_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libev-4.33-h280c20c_3.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libexpat-2.8.5-hd2095e1_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libffi-3.7.0-h81df57d_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libgcc-16.2.0-ha9f2e26_7.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libgomp-16.2.0-he0feb66_7.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/liblzma-5.8.3-hb03c661_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libmpdec-4.0.0-hb03c661_2.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libnghttp2-1.68.1-h74cf4be_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libpython-3.14.7-hdc7f604_106_cp314.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libsodium-1.0.22-hebe6cf0_3.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.53.4-h13e7031_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-16.2.0-h934c35e_7.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.42.4-hcfc3c73_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libuv-1.52.1-h280c20c_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.3.2-h25fd6f3_3.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.6-hdb14827_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/nodejs-26.10.0-ha5cdc1e_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/openssl-3.6.4-h781a0a9_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.14.7-hcd007b5_106_cp314.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/pyzmq-27.2.0-py312h8a5ba0d_2.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.3-hd6e31c0_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.13-noxft_h1df4ec4_4.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/tornado-6.5.10-py314h89acca1_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/zeromq-4.3.5-h901266b_12.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_7.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_3.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2026.7.22-hbd8a1cb_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/click-8.5.0-pyh5ded981_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/cpython-3.14.7-py314hd8ed1ab_106.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-9.0.1-pyhcf101f3_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/jupyter_client-8.6.3-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/jupyter_core-5.9.1-pyhc90fa1f_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/mypy_extensions-1.1.0-pyha770c72_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/packaging-26.3-pyhc364b38_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/platformdirs-4.12.2-pyh5ded981_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.14.7-h4df99d1_106.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-9_cp314.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/traitlets-5.16.1-pyhcf101f3_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2026c-h151e31d_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-4.1.0-pyhcf101f3_0.conda + - conda: https://conda.modular.com/max/linux-64/mojo-1.1.0-release.conda + - conda: https://conda.modular.com/max/linux-64/mojo-compiler-1.1.0-release.conda + - conda: https://conda.modular.com/max/noarch/mblack-26.6.0-release.conda + - conda: https://conda.modular.com/max/noarch/mojo-python-1.1.0-release.conda + osx-arm64: + - conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_3.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2026.7.22-hbd8a1cb_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/click-8.5.0-pyh5ded981_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/cpython-3.14.7-py314hd8ed1ab_106.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-9.0.1-pyhcf101f3_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/jupyter_client-8.6.3-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/jupyter_core-5.9.1-pyhc90fa1f_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/mypy_extensions-1.1.0-pyha770c72_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/packaging-26.3-pyhc364b38_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/platformdirs-4.12.2-pyh5ded981_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.14.7-h4df99d1_106.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-9_cp314.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/traitlets-5.16.1-pyhcf101f3_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2026c-h151e31d_0.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-4.1.0-pyhcf101f3_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/bzip2-1.0.8-h4e30115_10.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/c-ares-1.34.8-h74c22ad_2.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/icu-78.3-py310h579977c_2.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/krb5-1.22.2-h34f8a20_2.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libabseil-20260526.0-cxx17_h4c27e2a_2.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libbrotlicommon-1.2.0-h1dcdb26_4.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libbrotlidec-1.2.0-h5295a6a_4.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libbrotlienc-1.2.0-h2ddc9cb_4.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libcxx-23.1.2-h55c6f16_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libedit-3.1.20250104-pl5321h26f1114_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libev-4.33-h1a92334_3.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libexpat-2.8.5-h6111c0a_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libffi-3.7.0-h47dc5ef_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/liblzma-5.8.3-h8088a28_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libmpdec-4.0.0-h84a0fba_2.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libnghttp2-1.68.1-h435687b_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libpython-3.14.7-h4311e70_106_cp314.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsodium-1.0.22-h74c22ad_3.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsqlite-3.53.4-hca69786_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libuv-1.52.1-h1a92334_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libzlib-1.3.2-h8088a28_3.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ncurses-6.6-he64c551_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/nodejs-26.10.0-h8d74fab_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/openssl-3.6.4-h55eecbc_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.14.7-h0ae1c2c_106_cp314.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/pyzmq-27.2.0-py312hdfb5542_2.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.3-h8b90a29_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/tk-8.6.13-hbeba79b_4.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/tornado-6.5.10-py314hcd3153d_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zeromq-4.3.5-h6eb0046_12.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zstd-1.5.7-hf451053_7.conda + - conda: https://conda.modular.com/max/noarch/mblack-26.6.0-release.conda + - conda: https://conda.modular.com/max/noarch/mojo-python-1.1.0-release.conda + - conda: https://conda.modular.com/max/osx-arm64/mojo-1.1.0-release.conda + - conda: https://conda.modular.com/max/osx-arm64/mojo-compiler-1.1.0-release.conda +packages: +- conda: https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-20_gnu.conda + build_number: 20 + sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775bd88842135a4ddb4deb3c9 + md5: a9f577daf3de00bca7c3c76c0ecbd1de + depends: + - __glibc >=2.17,<3.0.a0 + - libgomp >=7.5.0 + constrains: + - openmp_impl <0.0a0 + license: BSD-3-Clause + license_family: BSD + run_exports: + strong: + - _openmp_mutex >=4.5 + size: 28948 + timestamp: 1770939786096 +- conda: https://conda.anaconda.org/conda-forge/linux-64/bzip2-1.0.8-hda65f42_10.conda + sha256: 1a0d382c515ebf55f8ee1f38c8b81bc95af5c2acc42ad53b66bc5df932032f96 + md5: e675fabcf81499adc7edf58124fb1e01 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + license: bzip2-1.0.6 + license_family: BSD + run_exports: + weak: + - bzip2 >=1.0.8,<2.0a0 + size: 257808 + timestamp: 1785906269155 +- conda: https://conda.anaconda.org/conda-forge/linux-64/c-ares-1.34.8-hebe6cf0_2.conda + sha256: 9c37cc233238adf366ea75b0e845662a5be07ceadf62e458183516369340274b + md5: 3ad2b403be8fc5612b9159e2ce621f69 + depends: + - libgcc >=15 + - __glibc >=2.17,<3.0.a0 + license: MIT + license_family: MIT + run_exports: + weak: + - c-ares >=1.34.8,<2.0a0 + size: 228700 + timestamp: 1787169971173 +- conda: https://conda.anaconda.org/conda-forge/linux-64/icu-78.3-py310h44b86e0_2.conda + sha256: 9f07834f0c546ab14d885ce0366285f61f44e326c0edd1fc63b8294e113ae432 + md5: 72a381cbad04f24b1c2a43ef707f45b4 + depends: + - __glibc >=2.17,<3.0.a0 + - libstdcxx >=14 + - libgcc >=14 + license: MIT + license_family: MIT + run_exports: + weak: + - icu >=78.3,<79.0a0 + size: 14459115 + timestamp: 1786545741408 +- conda: https://conda.anaconda.org/conda-forge/linux-64/keyutils-1.6.3-h7cc23a3_1.conda + sha256: dd053c96dcb0dcfd59422aefea9d2fe937a190167f34fba7893ec1e10a7e8963 + md5: ba55d1b89fd7775e67de8291029b4059 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + license: LGPL-2.1-or-later + run_exports: + weak: + - keyutils >=1.6.3,<2.0a0 + size: 135295 + timestamp: 1786739238128 +- conda: https://conda.anaconda.org/conda-forge/linux-64/krb5-1.22.2-hbc21106_2.conda + sha256: 2a5c38c85e63df84c4e69ee71439841ce570d259ae3060627bb9a49a938d66f4 + md5: 53318d715316929a574f83591308b1f8 + depends: + - __glibc >=2.17,<3.0.a0 + - keyutils >=1.6.3,<2.0a0 + - libedit >=3.1.20250104,<3.2.0a0 + - libedit >=3.1.20250104,<4.0a0 + - libgcc >=15 + - libstdcxx >=15 + - openssl >=3.5.7,<4.0a0 + license: MIT + license_family: MIT + run_exports: + weak: + - krb5 >=1.22.2,<1.23.0a0 + size: 1394333 + timestamp: 1786762112514 +- conda: https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.46.1-default_hbd61a6d_102.conda + sha256: 27d83f1188cd19bcb7754a078b3fa7f4cfb8527f8eb2fde54dd01fc529d1adec + md5: 449500f2c089da11c40f5c21312e3e07 + depends: + - __glibc >=2.17,<3.0.a0 + - zstd >=1.5.7,<1.6.0a0 + constrains: + - binutils_impl_linux-64 2.46.1 + license: GPL-3.0-only + license_family: GPL + run_exports: {} + size: 745303 + timestamp: 1784214507189 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libabseil-20260526.0-cxx17_h0dc7533_2.conda + sha256: 7bb3d495411b7059e85225aae500d84e7846a4bb02ebd77e4450200b20c180f0 + md5: 6983bfe8e09992014b9cf393769c7a84 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + - libstdcxx >=14 + constrains: + - abseil-cpp =20260526.0 + - libabseil-static =20260526.0=cxx17* + license: Apache-2.0 + license_family: Apache + run_exports: + weak: + - libabseil >=20260526.0,<20260527.0a0 + - libabseil =*=cxx17* + size: 1436888 + timestamp: 1787217011773 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libbrotlicommon-1.2.0-h39a168f_4.conda + sha256: c4e9854c585f3ee1785f651287ecdf8c28f30a2ea1b159a513005f8a0f6453a3 + md5: df210655e30a05e3b069c91b7aaddd2d + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + license: MIT + license_family: MIT + run_exports: + weak: + - libbrotlicommon >=1.2.0,<1.3.0a0 + size: 80561 + timestamp: 1788480364653 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libbrotlidec-1.2.0-ha411449_4.conda + sha256: d5ed24da3e583a92227fe77280978b7933f07a39a2b60156c5ad95e5c76733fa + md5: 0cfd601eb03cca403dcc248844787486 + depends: + - __glibc >=2.17,<3.0.a0 + - libbrotlicommon 1.2.0 h39a168f_4 + - libgcc >=15 + license: MIT + license_family: MIT + run_exports: + weak: + - libbrotlidec >=1.2.0,<1.3.0a0 + size: 34739 + timestamp: 1788480374261 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libbrotlienc-1.2.0-h018ffa1_4.conda + sha256: b9f3cb510337655485c2e79ce5f7dd468991b19ad29723ffa1175a0aed1b69ae + md5: 4136f6e4ef4835cc7df39a707cbd511c + depends: + - __glibc >=2.17,<3.0.a0 + - libbrotlicommon 1.2.0 h39a168f_4 + - libgcc >=15 + license: MIT + license_family: MIT + run_exports: + weak: + - libbrotlienc >=1.2.0,<1.3.0a0 + size: 298134 + timestamp: 1788480383223 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libedit-3.1.20250104-pl5321h373387f_1.conda + sha256: 6473eb8caf2aae830f37caa93db9b26dddf7ac84b63229e8bf7fc0e5c3ab95b0 + md5: 50708d3b951d0f8e2d7f2df5b5edc040 + depends: + - ncurses + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + - ncurses >=6.6,<7.0a0 + license: BSD-2-Clause + license_family: BSD + run_exports: + weak: + - libedit >=3.1.20250104,<3.2.0a0 + size: 135098 + timestamp: 1786616658086 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libev-4.33-h280c20c_3.conda + sha256: e4418f68d01a6307c4431b585c71b584f40189877364e542ee87deb777f5e85b + md5: 7bc31538d6e3fb349e897353969237ec + depends: + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + license: BSD-2-Clause OR GPL-2.0-or-later + license_family: GPL + run_exports: + weak: + - libev >=4.33,<4.34.0a0 + size: 43220 + timestamp: 1785917328200 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libexpat-2.8.5-hd2095e1_0.conda + sha256: 6de73033a7c5f712c9c5a54124e4581e025691029835e5bceaf10a333a7e7bc0 + md5: 72cfd2b95b0540247220b42f58a148d7 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + constrains: + - expat 2.8.5.* + license: MIT + license_family: MIT + run_exports: {} + size: 77893 + timestamp: 1790346247149 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libffi-3.7.0-h81df57d_1.conda + sha256: c8c7583ef063bc3c430f1d48298e5ad24f796a35c22ed5b14183325825a61106 + md5: 6525a0b06aa4fd390795f0740636a9dd + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + license: MIT + license_family: MIT + run_exports: + weak: + - libffi >=3.7.0,<3.8.0a0 + size: 68004 + timestamp: 1787753412298 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libgcc-16.2.0-ha9f2e26_7.conda + sha256: e031634c3a928f9594eba868bc46ef5230d6571a364a0c63215b06c4563bfcea + md5: 735629b400b70eeab21a2ba8f5b1c2ce + depends: + - __glibc >=2.17,<3.0.a0 + - _openmp_mutex >=4.5 + constrains: + - libgcc-ng ==16.2.0=*_7 + - libgomp 16.2.0 he0feb66_7 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + run_exports: {} + size: 1058444 + timestamp: 1790303109576 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libgomp-16.2.0-he0feb66_7.conda + sha256: 92a0bb350c7be6a4eedcb4e111c60aefd176018e6b1c009a6e025dbe9bbcd758 + md5: d904c7ddd95e026254b4b80808ee9e12 + depends: + - __glibc >=2.17,<3.0.a0 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + run_exports: + strong: + - _openmp_mutex >=4.5 + size: 640566 + timestamp: 1790303046034 +- conda: https://conda.anaconda.org/conda-forge/linux-64/liblzma-5.8.3-hb03c661_1.conda + sha256: 9787df8c22a59c9a70d3e5a10db9ad663485e75e9ccc3f09bd092cb7b95e0dab + md5: 1390b7c5ac0b1d8e447bc5efa6d3c8c2 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + constrains: + - xz 5.8.3.* + license: 0BSD + run_exports: + weak: + - liblzma >=5.8.3,<6.0a0 + size: 112995 + timestamp: 1786348617826 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libmpdec-4.0.0-hb03c661_2.conda + sha256: 46820b4a835e175940ae20bec00fdddaff804cda27a1408ab1b95e77a2196437 + md5: fcfed1dc5053eb1901b66e7b1fc32588 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + license: BSD-2-Clause + license_family: BSD + run_exports: {} + size: 92759 + timestamp: 1786650399772 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libnghttp2-1.68.1-h74cf4be_1.conda + sha256: 11a2f54a6f391e25738bce0023e6ef499600147bbcf21c1fa69d2e251b03cc6a + md5: 75d211f04ac87506f1f43420712a69fe + depends: + - __glibc >=2.17,<3.0.a0 + - c-ares >=1.34.8,<2.0a0 + - libev >=4.33,<4.34.0a0 + - libev >=4.33,<5.0a0 + - libgcc >=15 + - libstdcxx >=15 + - libzlib >=1.3.2,<2.0a0 + - openssl >=3.5.7,<4.0a0 + license: MIT + license_family: MIT + run_exports: + weak: + - libnghttp2 >=1.68.1,<2.0a0 + size: 649974 + timestamp: 1787177490105 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libpython-3.14.7-hdc7f604_106_cp314.conda + build_number: 106 + sha256: 5f879892bd439c3d94f4a97b06c214b9a19c4b92f74d84f0305c6ca1b2b239b2 + md5: 28af2158bb8dbb62e55b0af3b44f9d4a + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + - libstdcxx >=15 + license: Python-2.0 + run_exports: {} + size: 10520530 + timestamp: 1788383918299 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libsodium-1.0.22-hebe6cf0_3.conda + sha256: 2f73c05a1ad07e5a2cb43f0b3759cb04505f0c8bef30b43c9db0caa50218bfd8 + md5: 2d14868d78e969226e4ba07444c0dd25 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + license: ISC + run_exports: + weak: + - libsodium >=1.0.22,<1.0.23.0a0 + size: 270970 + timestamp: 1789425325397 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.53.4-h13e7031_1.conda + sha256: f20d70da54e5b31dd4a51fb1efeaafafd5ab6dd8d7ac9d1438eaa2526ac4ed3d + md5: e72bbec309c2b0f37823ee7d4fabfcd3 + depends: + - __glibc >=2.17,<3.0.a0 + - icu >=78.3,<79.0a0 + - libgcc >=15 + - libzlib >=1.3.2,<2.0a0 + license: blessing + run_exports: + weak: + - libsqlite >=3.53.4,<4.0a0 + size: 974348 + timestamp: 1787051145557 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-16.2.0-h934c35e_7.conda + sha256: fa7018298629fc429971fffd6ecba3d27a7b02e4e890d6a93ea01ffebe8cb745 + md5: 9b6707e0caca917fa6ea9ee473f37a5d + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc 16.2.0 ha9f2e26_7 + constrains: + - libstdcxx-ng ==16.2.0=*_7 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + run_exports: {} + size: 6615436 + timestamp: 1790303132935 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.42.4-hcfc3c73_0.conda + sha256: f34b8d1de9a2bf62476d8608057d9b8a918d97444236dc53a47128f2fae79041 + md5: 54a948337e66706380ff24d6b5fde63f + depends: + - libgcc >=15 + - __glibc >=2.17,<3.0.a0 + license: BSD-3-Clause + license_family: BSD + run_exports: + weak: + - libuuid >=2.42.4,<3.0a0 + size: 34442 + timestamp: 1790121449161 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libuv-1.52.1-h280c20c_1.conda + sha256: 67761d0206f84140047a367eaf9befe03a7e157a29ee25aee0047b40801cc6b6 + md5: 01c4ed87826af55996768af6dbc936b4 + depends: + - libgcc >=14 + - __glibc >=2.17,<3.0.a0 + license: MIT + license_family: MIT + run_exports: + weak: + - libuv >=1.52.1,<2.0a0 + size: 420040 + timestamp: 1785914567661 +- conda: https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.3.2-h25fd6f3_3.conda + sha256: eb8a0db0aa570124f7d2a93d7c7f596e3390df5e047818d873baad32985fc736 + md5: 0de0122d9570a8ab637c6b73db268389 + depends: + - __glibc >=2.17,<3.0.a0 + constrains: + - zlib 1.3.2 *_3 + license: Zlib + license_family: Other + run_exports: + weak: + - libzlib >=1.3.2,<2.0a0 + size: 63713 + timestamp: 1785362952714 +- conda: https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.6-hdb14827_1.conda + sha256: 5d46557214ed184381dafe835b7c94a474a1c3b307a08a250b1ea4779b44ffb3 + md5: ee6c0cd80a60961a1f48aa3e0b91f986 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=14 + license: X11 AND BSD-3-Clause + run_exports: + weak: + - ncurses >=6.6,<7.0a0 + size: 911196 + timestamp: 1786355078102 +- conda: https://conda.anaconda.org/conda-forge/linux-64/nodejs-26.10.0-ha5cdc1e_0.conda + sha256: ea1ae98c7352198d6d6a4027f4a60d2b634e05d5fd6f0b97e72fc6c16712b2c7 + md5: 46a3d9861f49b845fbd54897ff07fe4f + depends: + - libgcc >=15 + - __glibc >=2.28,<3.0.a0 + - libstdcxx >=15 + - zstd >=1.5.7,<1.6.0a0 + - libzlib >=1.3.2,<2.0a0 + - libuv >=1.52.1,<2.0a0 + - openssl >=3.5.8,<4.0a0 + - libnghttp2 >=1.68.1,<2.0a0 + - libabseil >=20260526.0,<20260527.0a0 + - libabseil * cxx17* + - icu >=78.3,<79.0a0 + - c-ares >=1.34.8,<2.0a0 + - libsqlite >=3.53.4,<4.0a0 + - libbrotlicommon >=1.2.0,<1.3.0a0 + - libbrotlienc >=1.2.0,<1.3.0a0 + - libbrotlidec >=1.2.0,<1.3.0a0 + license: MIT + license_family: MIT + run_exports: + weak: + - nodejs >=26.10.0,<27.0a0 + size: 20474429 + timestamp: 1790238478566 +- conda: https://conda.anaconda.org/conda-forge/linux-64/openssl-3.6.4-h781a0a9_0.conda + sha256: 4747b2d6a8336f52343bceb8a1ebf41a9e6e665b9d2e3f989972de53a310599e + md5: 16e3034a330cc625f2c685edec60cf4e + depends: + - __glibc >=2.17,<3.0.a0 + - ca-certificates + - libgcc >=15 + license: Apache-2.0 + license_family: Apache + run_exports: + weak: + - openssl >=3.6.4,<4.0a0 + size: 3202955 + timestamp: 1787698780103 +- conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.14.7-hcd007b5_106_cp314.conda + build_number: 106 + sha256: 4cd05407d6b07d00fd5b6cc78bd2f60ae5e21f777eb26ead82be2e3751c610a1 + md5: 56ee91e118243e46bfc0c41e4030d354 + depends: + - __glibc >=2.17,<3.0.a0 + - bzip2 >=1.0.8,<2.0a0 + - ld_impl_linux-64 >=2.36.1 + - libexpat >=2.8.1,<3.0a0 + - libffi >=3.7.0,<3.8.0a0 + - libgcc >=15 + - liblzma >=5.8.3,<6.0a0 + - libmpdec >=4.0.0,<5.0a0 + - libpython 3.14.7 hdc7f604_106_cp314 + - libsqlite >=3.53.4,<4.0a0 + - libuuid >=2.42.3,<3.0a0 + - libzlib >=1.3.2,<2.0a0 + - ncurses >=6.6,<7.0a0 + - openssl >=3.5.8,<4.0a0 + - python_abi 3.14.* *_cp314 + - readline >=8.3,<9.0a0 + - tk >=8.6.13,<8.7.0a0 + - tzdata + - zstd >=1.5.7,<1.6.0a0 + license: Python-2.0 + run_exports: + weak: + - python_abi 3.14.* *_cp314 + noarch: + - python + size: 26484459 + timestamp: 1788383955577 + python_site_packages_path: lib/python3.14/site-packages +- conda: https://conda.anaconda.org/conda-forge/linux-64/pyzmq-27.2.0-py312h8a5ba0d_2.conda + noarch: python + sha256: d1323678d9403504d05cdf6a65bbd648f8667a89d9d5d4146ff96bae0e5311a7 + md5: 2186325469ffe83c7b8807d638a478d9 + depends: + - python + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + - libstdcxx >=15 + - zeromq >=4.3.5,<4.4.0a0 + - _python_abi3_support 1.* + - cpython >=3.12 + license: BSD-3-Clause + license_family: BSD + run_exports: {} + size: 216556 + timestamp: 1789730121925 +- conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.3-hd6e31c0_1.conda + sha256: 01b3fe073a66e321970d09e04b388708f8cbdca5cdfbfcb7c9eeb470ad10383d + md5: 69c01c781e7c8190bbdaf79e3848c5ca + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + - ncurses >=6.6,<7.0a0 + license: GPL-3.0-only + license_family: GPL + run_exports: + weak: + - readline >=8.3,<9.0a0 + size: 348899 + timestamp: 1787033801506 +- conda: https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.13-noxft_h1df4ec4_4.conda + build_number: 104 + sha256: a1a241d172c1ccab067ba245206dd048bc3c2d1b84504b53c9468e99adfc16a1 + md5: 676a2f9b1c4fcf57b70aa5c65f6c60d0 + depends: + - libgcc >=15 + - __glibc >=2.17,<3.0.a0 + - libzlib >=1.3.2,<2.0a0 + constrains: + - xorg-libx11 >=1.8.13,<2.0a0 + license: TCL + run_exports: + weak: + - tk >=8.6.13,<8.7.0a0 + size: 3566806 + timestamp: 1787272857910 +- conda: https://conda.anaconda.org/conda-forge/linux-64/tornado-6.5.10-py314h89acca1_0.conda + sha256: c205ceaa1536a8729bdad405ca711e94d2196aba30771029793557f250294598 + md5: d2bd0918d9c10df4fe2355e33fe7bc63 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + - python >=3.14,<3.15.0a0 + - python_abi 3.14.* *_cp314 + license: Apache-2.0 + license_family: Apache + run_exports: {} + size: 950218 + timestamp: 1789911064461 +- conda: https://conda.anaconda.org/conda-forge/linux-64/zeromq-4.3.5-h901266b_12.conda + sha256: 37dc9a5ff564fdce07c5ad002ee572057cf41dedda274d7abc154e77094d981a + md5: 292a05f1436b98e17055090b5ef07746 + depends: + - __glibc >=2.17,<3.0.a0 + - libgcc >=15 + - libstdcxx >=15 + - libsodium >=1.0.22,<1.0.23.0a0 + - krb5 >=1.22.2,<1.23.0a0 + license: MPL-2.0 + license_family: MOZILLA + run_exports: + weak: + - zeromq >=4.3.5,<4.4.0a0 + size: 321839 + timestamp: 1789076548604 +- conda: https://conda.anaconda.org/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_7.conda + sha256: 47d682b9f6d6ec9eb1a6e6c3e75ea6273e899e78fb7fc59f81d39745009fbc60 + md5: aa459086047c0e5e27023ab19f8cb86a + depends: + - __glibc >=2.17,<3.0.a0 + - libzlib >=1.3.2,<2.0a0 + license: BSD-3-Clause + license_family: BSD + run_exports: + weak: + - zstd >=1.5.7,<1.6.0a0 + size: 601301 + timestamp: 1786599621503 +- conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_3.conda + sha256: 2a7204314663eeda5dec482a956f0e2eaf289bd5b9953eaaaad0e81aa64638f2 + md5: 3845f3d75991bae0fb90884662f4327c + depends: + - cpython + - python-gil + license: MIT + license_family: MIT + run_exports: {} + size: 8144 + timestamp: 1784221492234 +- conda: https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2026.7.22-hbd8a1cb_0.conda + sha256: 0a0544cf95f64394fe4959286f5c71f5444ad58feb0602e53becb27448d24da6 + md5: 0f51e2391ade309db462a55611263e9c + depends: + - __unix + license: ISC + run_exports: {} + size: 131780 + timestamp: 1784754889428 +- conda: https://conda.anaconda.org/conda-forge/noarch/click-8.5.0-pyh5ded981_0.conda + sha256: 9afb0c2c089330321a219c7ee5a25313bd574d4024be606cbb33e7a5735df662 + md5: dea5b13a211bbf99876deb980b408a66 + depends: + - python >=3.11 + - python + license: BSD-3-Clause + license_family: BSD + run_exports: {} + size: 112341 + timestamp: 1788802215348 +- conda: https://conda.anaconda.org/conda-forge/noarch/cpython-3.14.7-py314hd8ed1ab_106.conda + noarch: generic + sha256: fd701880cf6f696420aa5b4b530dbdf0c83a16bdb50aeb760b3159eec5c416bf + md5: 3b52b830ac00367685c08f98f50963bf + depends: + - python >=3.14,<3.15.0a0 + - python_abi * *_cp314 + license: Python-2.0 + run_exports: {} + size: 51289 + timestamp: 1788383537525 +- conda: https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-9.0.1-pyhcf101f3_0.conda + sha256: 95a074a7d3f58b3494c068d4789c364dcb591c56b70ca6b12f149a540f9aeea4 + md5: 77ec68e0aa61c3fff9ecbf840f93d64e + depends: + - python >=3.10 + - zipp >=3.20 + - python + license: Apache-2.0 + license_family: APACHE + run_exports: {} + size: 34920 + timestamp: 1787943971257 +- conda: https://conda.anaconda.org/conda-forge/noarch/jupyter_client-8.6.3-pyhd8ed1ab_1.conda + sha256: 19d8bd5bb2fde910ec59e081eeb59529491995ce0d653a5209366611023a0b3a + md5: 4ebae00eae9705b0c3d6d1018a81d047 + depends: + - importlib-metadata >=4.8.3 + - jupyter_core >=4.12,!=5.0.* + - python >=3.9 + - python-dateutil >=2.8.2 + - pyzmq >=23.0 + - tornado >=6.2 + - traitlets >=5.3 + license: BSD-3-Clause + license_family: BSD + run_exports: {} + size: 106342 + timestamp: 1733441040958 +- conda: https://conda.anaconda.org/conda-forge/noarch/jupyter_core-5.9.1-pyhc90fa1f_0.conda + sha256: 1d34b80e5bfcd5323f104dbf99a2aafc0e5d823019d626d0dce5d3d356a2a52a + md5: b38fe4e78ee75def7e599843ef4c1ab0 + depends: + - __unix + - python + - platformdirs >=2.5 + - python >=3.10 + - traitlets >=5.3 + - python + constrains: + - pywin32 >=300 + license: BSD-3-Clause + license_family: BSD + run_exports: {} + size: 65503 + timestamp: 1760643864586 +- conda: https://conda.anaconda.org/conda-forge/noarch/mypy_extensions-1.1.0-pyha770c72_0.conda + sha256: 6ed158e4e5dd8f6a10ad9e525631e35cee8557718f83de7a4e3966b1f772c4b1 + md5: e9c622e0d00fa24a6292279af3ab6d06 + depends: + - python >=3.9 + license: MIT + license_family: MIT + run_exports: {} + size: 11766 + timestamp: 1745776666688 +- conda: https://conda.anaconda.org/conda-forge/noarch/packaging-26.3-pyhc364b38_0.conda + sha256: c432626b16768b8dab228bfb706f7060c2d462a21c516d240f68f2f902b5a044 + md5: 936687ed80f295a1f5dbcf8bd34c252c + depends: + - python >=3.9 + - python + license: Apache-2.0 + license_family: APACHE + run_exports: {} + size: 116363 + timestamp: 1785888127370 +- conda: https://conda.anaconda.org/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda + sha256: 6eaee417d33f298db79bc7185ab1208604c0e6cf51dade34cd513c6f9db9c6f3 + md5: 11adc78451c998c0fd162584abfa3559 + depends: + - python >=3.10 + license: MPL-2.0 + license_family: MOZILLA + run_exports: {} + size: 56559 + timestamp: 1777271601895 +- conda: https://conda.anaconda.org/conda-forge/noarch/platformdirs-4.12.2-pyh5ded981_0.conda + sha256: f23f022bbbf809cd248940eca853d1132f05752e0404984cde7b014fd6384c97 + md5: 4b76957bed5e02e067a348eda60c6f94 + depends: + - python >=3.11 + - python + license: MIT + license_family: MIT + run_exports: {} + size: 33868 + timestamp: 1790738680369 +- conda: https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.9.0.post0-pyhe01879c_2.conda + sha256: d6a17ece93bbd5139e02d2bd7dbfa80bee1a4261dced63f65f679121686bf664 + md5: 5b8d21249ff20967101ffa321cab24e8 + depends: + - python >=3.9 + - six >=1.5 + - python + license: Apache-2.0 + license_family: APACHE + run_exports: {} + size: 233310 + timestamp: 1751104122689 +- conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.14.7-h4df99d1_106.conda + sha256: 801ef80bc9f9394d9b3b5cae5a90c33cbbc33004b3e93195b93af818aad8888b + md5: b672ecb44198ade19ef249bf99f4b1ff + depends: + - cpython 3.14.7.* + - python_abi * *_cp314 + license: Python-2.0 + run_exports: {} + size: 51276 + timestamp: 1788383547342 +- conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-9_cp314.conda + build_number: 9 + sha256: e7f8e965bbfb98e08feb2365cacdad8bb218fa5b5a0a2752f747287f425f213c + md5: 350d89b50d7de805abf2e63e29dee451 + constrains: + - python 3.14.* *_cp314 + license: BSD-3-Clause + license_family: BSD + run_exports: {} + size: 6791 + timestamp: 1788302824440 +- conda: https://conda.anaconda.org/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda + sha256: 458227f759d5e3fcec5d9b7acce54e10c9e1f4f4b7ec978f3bfd54ce4ee9853d + md5: 3339e3b65d58accf4ca4fb8748ab16b3 + depends: + - python >=3.9 + - python + license: MIT + license_family: MIT + run_exports: {} + size: 18455 + timestamp: 1753199211006 +- conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.4.1-pyhcf101f3_0.conda + sha256: 91cafdb64268e43e0e10d30bd1bef5af392e69f00edd34dfaf909f69ab2da6bd + md5: b5325cf06a000c5b14970462ff5e4d58 + depends: + - python >=3.10 + - python + license: MIT + license_family: MIT + run_exports: {} + size: 21561 + timestamp: 1774492402955 +- conda: https://conda.anaconda.org/conda-forge/noarch/traitlets-5.16.1-pyhcf101f3_0.conda + sha256: 03dba5917f944c6684ab44c81daacac1624cd148e4b2cae215dcec594a210c48 + md5: a79bf97561232a31447b6246c2153ab5 + depends: + - python >=3.10 + - python + license: BSD-3-Clause + license_family: BSD + run_exports: {} + size: 116935 + timestamp: 1785761789772 +- conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2026c-h151e31d_0.conda + sha256: b928c30ddcb0e3f544c6eade8352737e6e610e263276b90232db6a578ef899d8 + md5: fcb489df604d100968b737f2cb6076c6 + license: LicenseRef-Public-Domain + run_exports: {} + size: 118849 + timestamp: 1784250406640 +- conda: https://conda.anaconda.org/conda-forge/noarch/zipp-4.1.0-pyhcf101f3_0.conda + sha256: 210bd31c22bb88f5e2a167df24c95bb5f152b2ada7502f9b8c49d1f5366db423 + md5: ba3dcdc8584155c97c648ae9c044b7a3 + depends: + - python >=3.10 + - python + license: MIT + license_family: MIT + run_exports: {} + size: 24190 + timestamp: 1779159948016 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/bzip2-1.0.8-h4e30115_10.conda + sha256: 8ec22f0ba25cbfc2e64d70cf29459eccd7ffdf6436f6a6ff15bbfef799f7d4f6 + md5: b50612e7d190b8061ab4e7dc119cf4d5 + depends: + - __osx >=11.0 + license: bzip2-1.0.6 + license_family: BSD + run_exports: + weak: + - bzip2 >=1.0.8,<2.0a0 + size: 124965 + timestamp: 1785906749812 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/c-ares-1.34.8-h74c22ad_2.conda + sha256: 82bdd5a3fcada6afef6255a9bf41172f07b362f36e04a354dc2abc0a29bfb756 + md5: 4cc01a374215de38387d45e19c8c5c9c + depends: + - __osx >=11.0 + license: MIT + license_family: MIT + run_exports: + weak: + - c-ares >=1.34.8,<2.0a0 + size: 197819 + timestamp: 1787169996553 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/icu-78.3-py310h579977c_2.conda + sha256: 6cdb5dee54c72e56ab189fb3ad33cb28533553d42590e7e831160248f4416a43 + md5: a5efc0b42bb8b42e97d0a29ae3e3c187 + depends: + - __osx >=11.0 + license: MIT + license_family: MIT + run_exports: + weak: + - icu >=78.3,<79.0a0 + size: 14070242 + timestamp: 1786545847761 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/krb5-1.22.2-h34f8a20_2.conda + sha256: aaea1d42b07769920db2af7471ece9399d2613448863da64ad8272998db5db34 + md5: 15235dd10450d67bc25ccafd5b46d2bc + depends: + - __osx >=11.0 + - libcxx >=21 + - libedit >=3.1.20250104,<3.2.0a0 + - libedit >=3.1.20250104,<4.0a0 + - openssl >=3.5.7,<4.0a0 + license: MIT + license_family: MIT + run_exports: + weak: + - krb5 >=1.22.2,<1.23.0a0 + size: 1165740 + timestamp: 1786762145768 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libabseil-20260526.0-cxx17_h4c27e2a_2.conda + sha256: d9c62dae9d8f5bebadf72fcf369c00cc353183cb2521f9fffbf4c2f70b58bef9 + md5: 2aa5e7dc7b5d218908effd2a8c70a8a8 + depends: + - __osx >=11.0 + - libcxx >=19 + constrains: + - abseil-cpp =20260526.0 + - libabseil-static =20260526.0=cxx17* + license: Apache-2.0 + license_family: Apache + run_exports: + weak: + - libabseil >=20260526.0,<20260527.0a0 + - libabseil =*=cxx17* + size: 1277537 + timestamp: 1787217005681 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libbrotlicommon-1.2.0-h1dcdb26_4.conda + sha256: 8a6e4789a6049dabb41c6fcaf6719232245484d81dfeb199b5abdb95c84c9fc2 + md5: 8f3981871d167a6cd323e636e1929dd4 + depends: + - __osx >=11.0 + license: MIT + license_family: MIT + run_exports: + weak: + - libbrotlicommon >=1.2.0,<1.3.0a0 + size: 79648 + timestamp: 1788480342707 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libbrotlidec-1.2.0-h5295a6a_4.conda + sha256: 4e1f5989561de4546209b42c935795a41fa4265e0b670861480f1adffec623a8 + md5: da537a1643ef3e13bdccf16cca206f2c + depends: + - __osx >=11.0 + - libbrotlicommon 1.2.0 h1dcdb26_4 + license: MIT + license_family: MIT + run_exports: + weak: + - libbrotlidec >=1.2.0,<1.3.0a0 + size: 29864 + timestamp: 1788480352084 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libbrotlienc-1.2.0-h2ddc9cb_4.conda + sha256: 4d2da97825b221054a39f492e4dffe361e1931c8381d0367f1e0598a50d02f34 + md5: 39a25d500b191c16996239c4afa104f1 + depends: + - __osx >=11.0 + - libbrotlicommon 1.2.0 h1dcdb26_4 + license: MIT + license_family: MIT + run_exports: + weak: + - libbrotlienc >=1.2.0,<1.3.0a0 + size: 295505 + timestamp: 1788480359341 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libcxx-23.1.2-h55c6f16_0.conda + sha256: 087a610bacee7901d259ef72c6f060d795ab26831bd7541ba75ced786a5a63f9 + md5: 01af3f03d850cbab9ae9b86d726a9921 + depends: + - __osx >=11.0 + license: Apache-2.0 WITH LLVM-exception + license_family: Apache + run_exports: {} + size: 579372 + timestamp: 1790163402114 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libedit-3.1.20250104-pl5321h26f1114_1.conda + sha256: 257c926f19e32bdb981fc674c76966049b6fc73f706bae58e9fed8757ad1da70 + md5: 843ef89082f368cb889305084d3b483c + depends: + - ncurses + - __osx >=11.0 + - ncurses >=6.6,<7.0a0 + license: BSD-2-Clause + license_family: BSD + run_exports: + weak: + - libedit >=3.1.20250104,<3.2.0a0 + size: 107742 + timestamp: 1786616721640 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libev-4.33-h1a92334_3.conda + sha256: c0100064506ae8abb432c5a506d474f10af2cf48c33d62bc221fb28b6d6ff6ac + md5: 19e86c8a6a47e92bb2e70ca12e758c5c + depends: + - __osx >=11.0 + license: BSD-2-Clause OR GPL-2.0-or-later + license_family: GPL + run_exports: + weak: + - libev >=4.33,<4.34.0a0 + size: 39991 + timestamp: 1785917376956 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libexpat-2.8.5-h6111c0a_0.conda + sha256: 50aa761b83fc7a116ca88fe0cb4cefce5abababb10a926bf8afbafd5c298d102 + md5: 5383c550b785bdaafcc4eaf638071a7c + depends: + - __osx >=11.0 + constrains: + - expat 2.8.5.* + license: MIT + license_family: MIT + run_exports: {} + size: 69565 + timestamp: 1790370026495 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libffi-3.7.0-h47dc5ef_1.conda + sha256: 2783389a7b9dda04c62cc54c6bbeb03dd3cef24b3fc642715d02a3fa19464a9a + md5: 216bbcc23c11e9695b3db4a8771d76eb + depends: + - __osx >=11.0 + license: MIT + license_family: MIT + run_exports: + weak: + - libffi >=3.7.0,<3.8.0a0 + size: 43637 + timestamp: 1787753403688 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/liblzma-5.8.3-h8088a28_1.conda + sha256: 23d0630046a3e8b164d8f80f2b74ed2605af2e7050ab9913018056402fae4311 + md5: 8ab10323068b107661a4b9a4af84f3b5 + depends: + - __osx >=11.0 + constrains: + - xz 5.8.3.* + license: 0BSD + run_exports: + weak: + - liblzma >=5.8.3,<6.0a0 + size: 91720 + timestamp: 1786348695846 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libmpdec-4.0.0-h84a0fba_2.conda + sha256: 04cc136c5a956a73aa14e0a160b5822b0b29714e67b299fa1b1fd16dbcba5366 + md5: ff33a4dbd93abc8a798cc4e0e7c8136d + depends: + - __osx >=11.0 + license: BSD-2-Clause + license_family: BSD + run_exports: {} + size: 73289 + timestamp: 1786651074391 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libnghttp2-1.68.1-h435687b_1.conda + sha256: 445440d8cccccb6585f71d1eb7c949d64a2af2ced5481d924621424ff3b6a398 + md5: ac9902dcbe0417f50cf95ab2bde062fa + depends: + - __osx >=11.0 + - c-ares >=1.34.8,<2.0a0 + - libcxx >=21 + - libev >=4.33,<4.34.0a0 + - libev >=4.33,<5.0a0 + - libzlib >=1.3.2,<2.0a0 + - openssl >=3.5.7,<4.0a0 + license: MIT + license_family: MIT + run_exports: + weak: + - libnghttp2 >=1.68.1,<2.0a0 + size: 567024 + timestamp: 1787177422467 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libpython-3.14.7-h4311e70_106_cp314.conda + build_number: 106 + sha256: b239028180e1ba2f7daff4053c89e41f7c0f1a3c21bb82f6dcb09384d123ec1f + md5: 4d7a303343eff82e8b92d52c5fd3991a + depends: + - __osx >=11.0 + - libcxx >=20 + license: Python-2.0 + run_exports: {} + size: 1875368 + timestamp: 1788383432953 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsodium-1.0.22-h74c22ad_3.conda + sha256: 0fb001d9b28dc19096388beadaed3af98100f4260707ecb9c177fae68b0e9ece + md5: b237804d151d3d05d4d7fd9052c5664b + depends: + - __osx >=11.0 + license: ISC + run_exports: + weak: + - libsodium >=1.0.22,<1.0.23.0a0 + size: 249403 + timestamp: 1789425371505 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsqlite-3.53.4-hca69786_1.conda + sha256: 839b31d4830e896b4d315b551d27f2bb08026bc946df04bcc360d8627c3ba2cd + md5: fde96d40ebe9a9cb34e4122380189ddb + depends: + - __osx >=11.0 + - icu >=78.3,<79.0a0 + - libzlib >=1.3.2,<2.0a0 + license: blessing + run_exports: + weak: + - libsqlite >=3.53.4,<4.0a0 + size: 942754 + timestamp: 1787051243846 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libuv-1.52.1-h1a92334_1.conda + sha256: 4f47de9de1990efd998edbbd6793f89c8f02ffde987ae8120b1c006acefd2a04 + md5: de09bd0f175611e94f21b28f8c708e80 + depends: + - __osx >=11.0 + license: MIT + license_family: MIT + run_exports: + weak: + - libuv >=1.52.1,<2.0a0 + size: 122729 + timestamp: 1785914645797 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libzlib-1.3.2-h8088a28_3.conda + sha256: a18fa5d5bac452401459f966cf0d872224e8080c4ff93c77e168d43ab42ef9d7 + md5: f39288f0ea63ae962e1a2e4f355a0d75 + depends: + - __osx >=11.0 + constrains: + - zlib 1.3.2 *_3 + license: Zlib + license_family: Other + run_exports: + weak: + - libzlib >=1.3.2,<2.0a0 + size: 47822 + timestamp: 1785277049190 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/ncurses-6.6-he64c551_1.conda + sha256: 7024a48c8c0d0114ed4ab53c76bf9275d50e91ba7cea367a9aead638d3c29c68 + md5: 3dfa0d0316dc246cd44937a557de4501 + depends: + - __osx >=11.0 + license: X11 AND BSD-3-Clause + run_exports: + weak: + - ncurses >=6.6,<7.0a0 + size: 804298 + timestamp: 1786355189145 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/nodejs-26.10.0-h8d74fab_0.conda + sha256: e08552a430a3683f1cbc3bc8934449e301cd3ad6cc38fe34627de0301893ab44 + md5: 2f4e4682e0a68bd0e15a7964d6ceb73b + depends: + - __osx >=12.0 + - libcxx >=21 + - c-ares >=1.34.8,<2.0a0 + - libbrotlicommon >=1.2.0,<1.3.0a0 + - libbrotlienc >=1.2.0,<1.3.0a0 + - libbrotlidec >=1.2.0,<1.3.0a0 + - libsqlite >=3.53.4,<4.0a0 + - openssl >=3.5.8,<4.0a0 + - zstd >=1.5.7,<1.6.0a0 + - icu >=78.3,<79.0a0 + - libnghttp2 >=1.68.1,<2.0a0 + - libzlib >=1.3.2,<2.0a0 + - libuv >=1.52.1,<2.0a0 + - libabseil >=20260526.0,<20260527.0a0 + - libabseil * cxx17* + license: MIT + license_family: MIT + run_exports: + weak: + - nodejs >=26.10.0,<27.0a0 + size: 18529792 + timestamp: 1790238394580 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/openssl-3.6.4-h55eecbc_0.conda + sha256: f23239eacd75c4c50705e68fae1aa3292da473e6a3a4abe2330f1e6afa680704 + md5: ae71ab40048c19a389a7dcccb86c2481 + depends: + - __osx >=11.0 + - ca-certificates + license: Apache-2.0 + license_family: Apache + run_exports: + weak: + - openssl >=3.6.4,<4.0a0 + size: 3110142 + timestamp: 1787698648639 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.14.7-h0ae1c2c_106_cp314.conda + build_number: 106 + sha256: 5ffc8349ca089ec5ac39ad36a095323ad177ebe05cbfc690c1e135560cfd68b7 + md5: 5fd37c78250b4f57c2bcf9ad2e54beb1 + depends: + - __osx >=11.0 + - bzip2 >=1.0.8,<2.0a0 + - libexpat >=2.8.1,<3.0a0 + - libffi >=3.7.0,<3.8.0a0 + - liblzma >=5.8.3,<6.0a0 + - libmpdec >=4.0.0,<5.0a0 + - libpython 3.14.7 h4311e70_106_cp314 + - libsqlite >=3.53.4,<4.0a0 + - libzlib >=1.3.2,<2.0a0 + - ncurses >=6.6,<7.0a0 + - openssl >=3.5.8,<4.0a0 + - python_abi 3.14.* *_cp314 + - readline >=8.3,<9.0a0 + - tk >=8.6.13,<8.7.0a0 + - tzdata + - zstd >=1.5.7,<1.6.0a0 + license: Python-2.0 + run_exports: + weak: + - python_abi 3.14.* *_cp314 + noarch: + - python + size: 12223441 + timestamp: 1788383470498 + python_site_packages_path: lib/python3.14/site-packages +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/pyzmq-27.2.0-py312hdfb5542_2.conda + noarch: python + sha256: 42941c85f5f6435ccd84e9aed37de8fd9b3b40ab1c14ae2542ffb4c5e1c84e4e + md5: 8f718ff26a7f93e460445351c20929ef + depends: + - python + - libcxx >=21 + - __osx >=11.0 + - zeromq >=4.3.5,<4.4.0a0 + - _python_abi3_support 1.* + - cpython >=3.12 + license: BSD-3-Clause + license_family: BSD + run_exports: {} + size: 197695 + timestamp: 1789730185188 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.3-h8b90a29_1.conda + sha256: d6782b430e6dce4fe8c7ac118cd988d5a193eb4a7f60741edfaede58016b6110 + md5: 9347fd56a002e6b58946831d48fe62f6 + depends: + - __osx >=11.0 + - ncurses >=6.6,<7.0a0 + license: GPL-3.0-only + license_family: GPL + run_exports: + weak: + - readline >=8.3,<9.0a0 + size: 314395 + timestamp: 1787033878899 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/tk-8.6.13-hbeba79b_4.conda + sha256: 857d89087ae7f2c328cf256728affcb7343031a148b4af847334d248a9cf564c + md5: 90a01bf394d1c594e0eb9258f967d828 + depends: + - __osx >=11.0 + - libzlib >=1.3.2,<2.0a0 + license: TCL + run_exports: + weak: + - tk >=8.6.13,<8.7.0a0 + size: 3342183 + timestamp: 1787272852357 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/tornado-6.5.10-py314hcd3153d_0.conda + sha256: b18706fdd0022f0467912956a24d2e28180ba37d14555be5e382bea51869a6ae + md5: 9079ddcc60b0cf5848f665fa0e7088f9 + depends: + - __osx >=11.0 + - python >=3.14,<3.15.0a0 + - python_abi 3.14.* *_cp314 + license: Apache-2.0 + license_family: Apache + run_exports: {} + size: 952431 + timestamp: 1789911042938 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/zeromq-4.3.5-h6eb0046_12.conda + sha256: 4fe0cd73a686cc4466ca005166a5aa351dc665aa26166b68752d90930f214382 + md5: 89102eac6e230f7636c40a1411223484 + depends: + - libcxx >=21 + - __osx >=11.0 + - libsodium >=1.0.22,<1.0.23.0a0 + - krb5 >=1.22.2,<1.23.0a0 + license: MPL-2.0 + license_family: MOZILLA + run_exports: + weak: + - zeromq >=4.3.5,<4.4.0a0 + size: 244219 + timestamp: 1789076600961 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/zstd-1.5.7-hf451053_7.conda + sha256: da867f5092eb0cb746d353694f0098031fd9817a4ce7d5743121209ae0f406ca + md5: 4ec2684c73812cc2c3d78379384a39cc + depends: + - __osx >=11.0 + - libzlib >=1.3.2,<2.0a0 + license: BSD-3-Clause + license_family: BSD + run_exports: + weak: + - zstd >=1.5.7,<1.6.0a0 + size: 433687 + timestamp: 1786599629846 +- conda: https://conda.modular.com/max/linux-64/mojo-1.1.0-release.conda + sha256: 06af8313018ba5defb63bdb3bf479df73925450100e4744a5c8d39a2869d9369 + md5: 28c2d4266e928830dde8feb340d1565c + depends: + - python >=3.10 + - mojo-compiler ==1.1.0 + - mblack ==26.6.0 + - jupyter_client >=8.6.2,<8.7 + license: LicenseRef-Modular-Proprietary + run_exports: {} + size: 117682275 + timestamp: 1789083812846 +- conda: https://conda.modular.com/max/linux-64/mojo-compiler-1.1.0-release.conda + sha256: 1ff52b39a0d2a1bedb8c4705aadc460205ca62fc19f63426bc545e4b60a31aa0 + md5: 00573b31817025e7ccf97478780bd9d1 + depends: + - mojo-python ==1.1.0 + license: LicenseRef-Modular-Proprietary + run_exports: {} + size: 69781261 + timestamp: 1789083806628 +- conda: https://conda.modular.com/max/noarch/mblack-26.6.0-release.conda + noarch: python + sha256: b1ee3bbc2a5cf72930ef88b57769422d35f8a91d6f31ed3e4036e5c082835057 + md5: 11c333269deaf3983e7418e4d5c63f40 + depends: + - python >=3.10 + - click >=8.0.0 + - mypy_extensions >=0.4.3 + - packaging >=22.0 + - pathspec >=1.1.0 + - platformdirs >=2 + - tomli >=1.1.0 + license: LicenseRef-Modular-Proprietary + run_exports: {} + size: 138160 + timestamp: 1789083634107 +- conda: https://conda.modular.com/max/noarch/mojo-python-1.1.0-release.conda + noarch: python + sha256: a00d79bd9f8124706d50994d42e0072dfb7c531171370b27ca0ebb647af87137 + md5: 781af5600ba005649cd1b1931c5d0555 + depends: + - python >=3.10 + license: LicenseRef-Modular-Proprietary + run_exports: {} + size: 24150 + timestamp: 1789083634309 +- conda: https://conda.modular.com/max/osx-arm64/mojo-1.1.0-release.conda + sha256: f3980180219c22988bc5314edb4ac6a756b27c33956c7debf7dfd497bc0c61a9 + md5: 1d791e402d45e8134e786563fd6c2888 + depends: + - python >=3.10 + - mojo-compiler ==1.1.0 + - mblack ==26.6.0 + - jupyter_client >=8.6.2,<8.7 + license: LicenseRef-Modular-Proprietary + run_exports: {} + size: 103047784 + timestamp: 1789083874942 +- conda: https://conda.modular.com/max/osx-arm64/mojo-compiler-1.1.0-release.conda + sha256: 6b0bac64c58040eed477c77a998ee685168b52f34256397867e85e1024d7f0a9 + md5: c4d63d6620d6a756adf9eb0f617041fa + depends: + - mojo-python ==1.1.0 + license: LicenseRef-Modular-Proprietary + run_exports: {} + size: 62368467 + timestamp: 1789083852431 diff --git a/pixi.toml b/pixi.toml new file mode 100644 index 0000000..8c13b28 --- /dev/null +++ b/pixi.toml @@ -0,0 +1,63 @@ +# pplus-core — every command a person runs, in one place. +# +# pixi run [args] list them all: `pixi task list` +# +# The README's "Commands" table lists every task here; tests/tasks.test.mjs +# keeps the two in step. Without pixi, `npm install && npm test` builds and +# tests core with whatever node and python3 are on the PATH (that is what CI +# does); everything else assumes the pinned environment below. + +[workspace] +authors = ["Alex Maldonado "] +channels = ["https://conda.modular.com/max/", "conda-forge"] +name = "pplus-core" +platforms = ["linux-64", "osx-arm64"] +version = "0.2.0" + +[dependencies] +mojo = "==1.1.0" # the compiler the corpus is pinned to (mojo/pin.json) +nodejs = ">=26.10.0,<26.11" # the build and tests; the quest processor needs >= 22.6 +python = ">=3.14.7,<3.15" # the corpus pipeline and the Dafny pin (standard library only) + +[tasks] +# --- build and test -------------------------------------------------------- +install = { cmd = "npm install", inputs = ["package.json"], outputs = ["node_modules/.package-lock.json"], description = "Install TypeScript (the only npm dependency)" } +build = { cmd = "npx tsc -p tsconfig.json", depends-on = ["install"], description = "Compile src/ to dist/, with type declarations for pplus-web" } +watch = { cmd = "npx tsc -p tsconfig.json --watch", depends-on = ["install"], description = "Rebuild dist/ on every change" } +check = { cmd = "npx tsc -p tsconfig.json --noEmit", depends-on = ["install"], description = "Type-check only" } +test = { cmd = "node --test tests/*.test.mjs", depends-on = ["build"], description = "Build, then run every test (the corpus pipeline's and the Dafny pin's Python tests included)" } +cli = { cmd = "node scripts/cli.mjs", depends-on = ["build"], description = "pplus check|run|prove|fuzz|translate : core without a browser, e.g. pixi run cli prove tests/corpus/27-quantifiers.pseudo" } +engines-diff = { cmd = "node scripts/engines-diff.mjs {{ static }}", args = ["static"], depends-on = ["build"], description = "Show what a course checkout's static/ directory has not taken yet from src/engines/ (docs/engines.md)" } +engines-export = { cmd = "node scripts/engines-export.mjs {{ static }}", args = ["static"], depends-on = ["build"], description = "Copy the engines into a course checkout's static/js/, TypeScript modules as built (docs/engines.md)" } + +# --- Dafny, pinned (scripts/dafny.py) --------------------------------------- +dafny-fetch = { cmd = "python scripts/dafny.py fetch", description = "Download the pinned Dafny into .tools/, checked by SHA-256 (network, once)" } +dafny = { cmd = "python scripts/dafny.py", description = "Run the pinned Dafny with the arguments given, e.g. pixi run dafny verify file.dfy (fetches it first if missing)" } + +# --- write content --------------------------------------------------------- +new-exercise = { cmd = "node scripts/new-exercise.mjs {{ id }}", args = ["id"], description = "Start an exercise: mojo/local/.mojo and src/exercises/.ts, registered in index.ts" } +new-probe = { cmd = "node scripts/mojo/new-program.mjs probe {{ name }} \"{{ question }}\"", args = ["name", "question"], description = "Start mojo/probes/.mojo: one question about the pinned compiler" } +new-stress = { cmd = "node scripts/mojo/new-program.mjs stress {{ name }} \"{{ about }}\"", args = ["name", "about"], description = "Start mojo/stress/.mojo: realistic Mojo that tests the interpreter" } +play = { cmd = "node scripts/play.mjs {{ name }}", args = ["name"], depends-on = ["install"], description = "For mojo/local/.mojo: run, verify on godbolt, build, list the assembly, test" } +play-watch = { cmd = "node scripts/play.mjs {{ name }} --watch", args = ["name"], depends-on = ["install"], description = "The same, again on every save (tests off)" } + +# --- the Mojo corpus (docs/mojo-corpus.md) --------------------------------- +mojo-verify = { cmd = "python scripts/mojo/corpus.py verify", description = "Ask godbolt about every program with no answer yet (network)" } +mojo-verify-item = { cmd = "python scripts/mojo/corpus.py verify --force --item '{{ id }}'", args = ["id"], description = "Ask again about one item; a trailing * matches a prefix, e.g. 'probes/life-*' (network)" } +mojo-verify-dry = { cmd = "python scripts/mojo/corpus.py verify --dry-run", description = "Show what mojo-verify would send; send nothing" } +mojo-verify-diagnostics = { cmd = "python scripts/mojo/corpus.py verify --corpus diagnostics", description = "Also check the compiler's own diagnostic tests (opt-in, about 140 files; network)" } +mojo-status = { cmd = "python scripts/mojo/corpus.py status", description = "Judge every item from the stored answers, offline; writes mojo/golden/STATUS.md" } +mojo-status-strict = { cmd = "python scripts/mojo/corpus.py status --strict", description = "The same, and fail if a program we wrote (probes, local, stress) fails" } +mojo-harvest = { cmd = "python scripts/mojo/corpus.py harvest", description = "After editing mojo/pin.json: fetch Modular's sources, process them, regenerate src/mojo/generated/ and syntax/ (network)" } +mojo-harvest-local = { cmd = "python scripts/mojo/corpus.py harvest --local-dir {{ dir }}", args = [{ arg = "dir", default = "zips" }], description = "Harvest, using zips in for sources the pin leaves UNRESOLVED" } +mojo-harvest-offline = { cmd = "python scripts/mojo/corpus.py harvest --local-dir {{ dir }} --offline", args = [{ arg = "dir", default = "zips" }], description = "Harvest from zips in only, no network" } +mojo-fetch = { cmd = "python scripts/mojo/corpus.py fetch --update", description = "Re-resolve every ref in the pin and rewrite mojo/mojo.lock.json (network)" } +mojo-emit = { cmd = "python scripts/mojo/corpus.py emit", description = "Regenerate src/mojo/generated/ and syntax/mojo.xml from the pin and the corpus, offline" } +mojo-test = { cmd = "python -m unittest discover -s scripts/mojo/tests", description = "The corpus pipeline's own tests (also run by test)" } +mojo-run = { cmd = "mojo run {{ file }}", args = ["file"], description = "Run one Mojo file on the pinned local compiler, e.g. mojo/probes/int-floordiv.mojo" } +mojo-probes-local = { cmd = "for f in mojo/probes/*.mojo; do echo \"== $f\"; mojo run \"$f\" < /dev/null; echo \"exit $?\"; done", description = "Run every probe on the local compiler (a quick look; godbolt's answers stay the reference)" } +mojo-update = { depends-on = ["mojo-harvest", "mojo-verify", "mojo-status", "test"], description = "After editing mojo/pin.json: harvest, verify, status, test" } + +# --- ship ------------------------------------------------------------------ +ci = { depends-on = ["test", "mojo-status-strict"], description = "What CI runs: every test, and no program of ours failing" } +package = { cmd = "python scripts/package.py", description = "Zip the files git tracks (and new ones it does not ignore) into package/ for sharing" } diff --git a/scripts/cli.mjs b/scripts/cli.mjs new file mode 100644 index 0000000..801e2be --- /dev/null +++ b/scripts/cli.mjs @@ -0,0 +1,107 @@ +#!/usr/bin/env node +/** + * pplus: pplus-core without a browser. The same engines, translators, prover and fuzzer the app runs, on a file. + * + * pixi run cli check what the language's own reader says + * pixi run cli run [--call C] [--input F] run it, print what it prints + * pixi run cli prove [--speco F] every obligation: proved, broken or open + * pixi run cli fuzz [--seed N] [--budget N] the fuzzer's report per routine + * pixi run cli translate --to mojo|lingo|matho|speco + * + * The language comes from the extension: .pseudo, .lingo, .matho (or .tex), .speco, .mojo, .asm (or .s). Add --json + * for machine-readable output. Exit status: 0 when nothing is wrong, 1 when the command found a problem (an error, + * a broken obligation, a failing input, a run that stopped), 2 for a usage error. Build first (`pixi run build`): + * this reads dist/. + */ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath, pathToFileURL } from 'node:url'; + +const ROOT = fileURLToPath(new URL('..', import.meta.url)); +const dist = (p) => pathToFileURL(path.join(ROOT, 'dist', p)).href; +const usage = (why) => { + if (why) console.error(`pplus: ${why}`); + console.error('usage: pplus [--call C] [--input F] [--speco F] [--seed N] [--budget N] [--to LANG] [--json]'); + process.exit(2); +}; +if (!fs.existsSync(path.join(ROOT, 'dist', 'common', 'workspace.js'))) usage('dist/ is missing; run `pixi run build` first'); + +const [cmd, file, ...rest] = process.argv.slice(2); +if (!cmd || !file) usage(); +const opt = (name) => { const i = rest.indexOf(`--${name}`); return i >= 0 ? rest[i + 1] : undefined; }; +const json = rest.includes('--json'); +const LANG_OF = { '.pseudo': 'pseudo', '.lingo': 'lingo', '.matho': 'matho', '.tex': 'matho', '.speco': 'speco', '.mojo': 'mojo', '.asm': 'asm', '.s': 'asm' }; +const lang = LANG_OF[path.extname(file).toLowerCase()]; +if (!lang) usage(`cannot tell the language of ${file} from its extension (${Object.keys(LANG_OF).join(', ')})`); +if (!fs.existsSync(file)) usage(`${file} does not exist`); + +const { Workspace } = await import(dist('common/workspace.js')); +const text = fs.readFileSync(file, 'utf8'); +const sources = { [lang]: text }; +const speco = opt('speco'); +if (speco) sources.speco = fs.readFileSync(speco, 'utf8'); +const input = opt('input') ? fs.readFileSync(opt('input'), 'utf8') : ''; +const ws = new Workspace({ sources, lang, call: opt('call') ?? null, input }); + +const out = (obj, lines) => { if (json) console.log(JSON.stringify(obj, null, 2)); else for (const l of lines) console.log(l); }; +const where = (d) => `${file}:${d.line ?? 1}:${d.col ?? 1}`; + +switch (cmd) { + case 'check': { + const ds = ws.diagnostics(lang); + out(ds, ds.length ? ds.map((d) => `${where(d)}: ${d.severity}: ${d.message}${d.id ? ` [${d.id}]` : ''}`) : [`${file}: no problems`]); + process.exit(ds.some((d) => d.severity === 'error') ? 1 : 0); + } + case 'run': { + const errors = ws.diagnostics(lang).filter((d) => d.severity === 'error'); + if (errors.length) { out({ errors }, errors.map((d) => `${where(d)}: error: ${d.message}`)); process.exit(1); } + const tr = ws.trace(); + if (!tr) { out({ error: ws.runError ?? 'nothing to run' }, [`pplus: ${ws.runError ?? 'nothing to run'}`]); process.exit(1); } + const lines = [...(tr.output ?? [])]; + if (tr.error) lines.push(`stopped at line ${tr.error.line}: ${tr.error.message}`); + out({ output: tr.output, error: tr.error, steps: tr.count }, lines); + process.exit(tr.error ? 1 : 0); + } + case 'prove': { + if (lang !== 'pseudo') usage('prove reads a .pseudo file (with --speco for a separate spec)'); + const p = ws.proof(); + if (!p) { out({ error: 'the pseudo does not parse' }, ['pplus: the pseudo does not parse; run `pplus check` first']); process.exit(1); } + const { report } = p; + const lines = []; + for (const u of report.units) { + lines.push(`${u.name}${u.partial ? ' (partial: not every path was examined)' : ''}`); + for (const o of u.obligations) lines.push(` ${o.status.padEnd(6)} line ${String(o.line).padEnd(4)} ${o.label}`); + for (const n of u.notes) lines.push(` note: ${n}`); + } + lines.push(`${report.counts.proved} proved, ${report.counts.broken} broken, ${report.counts.open} open`); + out(report, lines); + process.exit(report.counts.broken ? 1 : 0); + } + case 'fuzz': { + const reports = ws.fuzz({ seed: Number(opt('seed') ?? 1), budget: Number(opt('budget') ?? 300) }); + const lines = []; + for (const r of reports) { + if (r.problem) { lines.push(`${r.name}: ${r.problem}`); continue; } + lines.push(`${r.name}: ${r.cases.length} cases, ${r.failures.length} failure${r.failures.length === 1 ? '' : 's'}`); + for (const f of r.failures) lines.push(` ${f.call}: ${f.message}`); + } + out(reports.map((r) => ({ name: r.name, problem: r.problem, cases: r.cases.length, failures: r.failures })), lines.length ? lines : [`${file}: no routine to fuzz`]); + process.exit(reports.some((r) => r.failures.length) ? 1 : 0); + } + case 'translate': { + if (lang !== 'pseudo') usage('translate reads a .pseudo file'); + const to = opt('to'); + let result; + if (to === 'mojo') result = ws.derivedMojo(); + else if (to === 'speco') { const { extractSpec } = await import(dist('services/speco.js')); result = { source: extractSpec(text) ?? '' }; } + else if (to === 'lingo' || to === 'matho') { + const { SyncHub } = await import(dist('sync/hub.js')); + const f = new SyncHub({ pseudo: text }).fill(); + result = { source: f.sources[to] ?? '', stale: f.stale[to] }; + } else usage('--to must be mojo, lingo, matho or speco'); + if (result.stale) { out({ refused: result.stale }, [`pplus: ${to} cannot say this program: ${result.stale}`]); process.exit(1); } + if (json) console.log(JSON.stringify(result, null, 2)); else process.stdout.write(result.source.endsWith('\n') ? result.source : result.source + '\n'); + process.exit(0); + } + default: usage(`unknown command ${cmd}`); +} diff --git a/scripts/dafny.py b/scripts/dafny.py new file mode 100644 index 0000000..0d7ac3b --- /dev/null +++ b/scripts/dafny.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +"""Dafny, pinned: fetch the release this project uses, check it, and run it. + + pixi run dafny-fetch download Dafny into .tools/ once (network), checked by SHA-256 + pixi run dafny verify file.dfy run the pinned Dafny (fetches first if it is missing) + pixi run dafny --version + +Dafny is not on conda-forge, so pixi cannot install it directly; this script is the pin instead. It downloads the +official release zip for this machine from GitHub, refuses it unless its SHA-256 is the one written below, and unpacks +it into .tools/dafny-/ (ignored by git). The zip is self-contained: it carries its own .NET runtime and the Z3 +builds Dafny was tested with, so the solver is pinned too. To move to another Dafny, change VERSION and every hash in +RELEASES in one commit, and expect every stored proof answer to be asked again. + +Standard library only, like the corpus pipeline. +""" +from __future__ import annotations + +import hashlib +import os +import platform +import shutil +import stat +import subprocess +import sys +import urllib.request +import zipfile +from pathlib import Path + +VERSION = "4.11.0" +# platform -> (release asset, SHA-256 of the zip) +RELEASES = { + ("Linux", "x86_64"): ("dafny-4.11.0-x64-ubuntu-22.04.zip", "a46a9ff7cdd720f7955854c78e95df13f4cfe6b80691b05f8654fe19e8267179"), + ("Darwin", "arm64"): ("dafny-4.11.0-arm64-macos-13.zip", "c90c75e7d5db9c6ccbb7127840dfe43f0ac938b039a7ebed146d8ead383a572f"), +} +URL = "https://github.com/dafny-lang/dafny/releases/download/v{version}/{asset}" + +ROOT = Path(__file__).resolve().parent.parent +TOOLS = ROOT / ".tools" +HOME = TOOLS / f"dafny-{VERSION}" +EXE = HOME / "dafny" / "dafny" + + +def release(system: str | None = None, machine: str | None = None) -> tuple[str, str]: + key = (system or platform.system(), machine or platform.machine()) + if key not in RELEASES: + raise SystemExit(f"dafny: no pinned Dafny {VERSION} for {key[0]} {key[1]}; the pinned platforms are " + + ", ".join(f"{s} {m}" for s, m in RELEASES)) + return RELEASES[key] + + +def sha256(path: Path) -> str: + h = hashlib.sha256() + with path.open("rb") as f: + for block in iter(lambda: f.read(1 << 20), b""): + h.update(block) + return h.hexdigest() + + +def unpack(zip_path: Path, into: Path) -> None: + """Unzip, keeping each file's Unix permission bits (zipfile drops them), so dafny and z3 stay executable.""" + with zipfile.ZipFile(zip_path) as z: + for info in z.infolist(): + target = into / info.filename + z.extract(info, into) + mode = (info.external_attr >> 16) & 0o777 + if mode and not info.is_dir(): + os.chmod(target, mode | stat.S_IRUSR) + + +def fetch(quiet: bool = False) -> Path: + """Make sure the pinned Dafny is in .tools/, and return its executable.""" + if EXE.exists(): + return EXE + asset, want = release() + TOOLS.mkdir(exist_ok=True) + zip_path = TOOLS / asset + if not zip_path.exists() or sha256(zip_path) != want: + url = URL.format(version=VERSION, asset=asset) + if not quiet: + print(f"dafny: downloading {url}", file=sys.stderr) + part = zip_path.with_suffix(".part") + with urllib.request.urlopen(url) as r, part.open("wb") as f: + shutil.copyfileobj(r, f) + part.replace(zip_path) + got = sha256(zip_path) + if got != want: + zip_path.unlink() + raise SystemExit(f"dafny: {asset} has SHA-256 {got}, not the pinned {want}; refusing it") + staging = TOOLS / f".dafny-{VERSION}.unpacking" + shutil.rmtree(staging, ignore_errors=True) + unpack(zip_path, staging) + staging.replace(HOME) + zip_path.unlink() + if not quiet: + print(f"dafny: Dafny {VERSION} is in {HOME.relative_to(ROOT)}", file=sys.stderr) + return EXE + + +def main(argv: list[str]) -> int: + if argv[:1] == ["fetch"]: + fetch() + print(subprocess.run([str(EXE), "--version"], capture_output=True, text=True).stdout.strip()) + return 0 + if argv[:1] == ["path"]: + print(fetch(quiet=True)) + return 0 + exe = fetch() + return subprocess.run([str(exe), *argv]).returncode + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/scripts/engines-diff.mjs b/scripts/engines-diff.mjs index 7a2b988..b61274b 100644 --- a/scripts/engines-diff.mjs +++ b/scripts/engines-diff.mjs @@ -9,7 +9,7 @@ * this shows what the course has not taken yet. For each engine module (pseudo, * asm86, shared) it compares the file the course would receive (src/engines/ * as written, or dist/engines/ for a module written in TypeScript) with the - * course's copy, and each stylesheet in styles/course/ with the course's; + * course's copy (the course's stylesheets are compared in pplus-web); * prints whether they are the same, differ only in whitespace and line * endings, or differ in content (with the number of changed lines, whitespace * ignored), and lists files only one side has. It changes nothing. @@ -26,8 +26,6 @@ if (!dir || !fs.existsSync(path.join(dir, 'js'))) { process.exit(2); } -const CSS = { 'tokens.css': 'css/base/tokens.css', 'kit.css': 'css/widgets/kit.css', 'asm86.css': 'css/widgets/asm86.css' }; - const squash = (s) => s.replace(/\r/g, '').split('\n').map((l) => l.replace(/\s+/g, ' ').trim()).filter(Boolean); /** Lines changed, whitespace ignored: the size of the symmetric difference of the two line multisets. */ @@ -67,12 +65,6 @@ for (const d of ENGINE_DIRS) { if (!mine.some((m) => m.dir === d && m.file === f)) rows.push([`js/${d}/${f}`, 'only in the course']); } } -for (const [f, course] of Object.entries(CSS)) { - const a = path.join(ROOT, 'styles/course', f), b = path.join(dir, course); - const label = `styles/course/${f}`; - if (!fs.existsSync(b)) rows.push([label, 'missing in the course']); - else { const r = compare(a, b); rows.push([label, r.kind === 'content' ? `differs: ${r.n} lines` : r.kind === 'whitespace' ? 'whitespace only' : 'same']); } -} const w = Math.max(...rows.map((r) => r[0].length)); for (const [f, v] of rows) console.log(`${f.padEnd(w)} ${v}`); diff --git a/scripts/mojo/mojocorpus/emit_ts.py b/scripts/mojo/mojocorpus/emit_ts.py index 2f9ea8f..20ca607 100644 --- a/scripts/mojo/mojocorpus/emit_ts.py +++ b/scripts/mojo/mojocorpus/emit_ts.py @@ -9,7 +9,7 @@ pin and the corpus, so they cannot drift. src/mojo/generated/tokens.ts the words of the language, from corpus/tokens/tokens.json src/mojo/generated/editor.ts comment and indentation rules, from corpus/editor/editor.json src/mojo/generated/programs.ts our own programs (mojo/local/), each with its verdict from the goldens - quarto/_extensions/pplus/syntax/mojo.xml the same words, as a KDE syntax for Pandoc listings (kde.py) + syntax/mojo.xml the same words, as a KDE syntax for Pandoc listings (kde.py); pplus-web copies it into its Quarto extension """ from __future__ import annotations @@ -20,7 +20,7 @@ from pathlib import Path from .common import CORPUS, GENERATED_TS, REPO, Pin, PipelineError, load_lock, read_json, write_text from .kde import mojo_xml -QUARTO_SYNTAX = REPO / "quarto" / "_extensions" / "pplus" / "syntax" +SYNTAX_DIR = REPO / "syntax" # pplus-web copies it into its Quarto extension (its quarto-css task) BANNER = "// Generated by scripts/mojo/corpus.py emit. Do not edit; change mojo/pin.json or re-harvest.\n" @@ -29,7 +29,7 @@ def ts(value) -> str: return json.dumps(value, ensure_ascii=False, indent=4).replace("\n", "\n") -def emit(pin: Pin, out_dir: Path = GENERATED_TS, corpus: Path = CORPUS, syntax_dir: Path = QUARTO_SYNTAX) -> list[Path]: +def emit(pin: Pin, out_dir: Path = GENERATED_TS, corpus: Path = CORPUS, syntax_dir: Path = SYNTAX_DIR) -> list[Path]: written = [] lock = load_lock() commits = {k: (v.get("commit") or f"local:{v.get('sha256', '')[:12]}") for k, v in lock.get("sources", {}).items()} diff --git a/scripts/mojo/tests/test_pipeline.py b/scripts/mojo/tests/test_pipeline.py index 7eae725..21753cd 100644 --- a/scripts/mojo/tests/test_pipeline.py +++ b/scripts/mojo/tests/test_pipeline.py @@ -362,12 +362,12 @@ class CommittedCorpusTests(unittest.TestCase): committed = (common.GENERATED_TS / f).read_text(encoding="utf-8") self.assertEqual((Path(d) / f).read_text(encoding="utf-8"), committed, f"src/mojo/generated/{f} is stale; run `python3 scripts/mojo/corpus.py emit`") - self.assertEqual((Path(d) / "mojo.xml").read_text(encoding="utf-8"), (emit_ts.QUARTO_SYNTAX / "mojo.xml").read_text(encoding="utf-8"), - "quarto/_extensions/pplus/syntax/mojo.xml is stale; run `python3 scripts/mojo/corpus.py emit`") + self.assertEqual((Path(d) / "mojo.xml").read_text(encoding="utf-8"), (emit_ts.SYNTAX_DIR / "mojo.xml").read_text(encoding="utf-8"), + "syntax/mojo.xml is stale; run `python3 scripts/mojo/corpus.py emit`") def test_the_quarto_syntax_is_well_formed_with_the_1_1_0_words(self): import xml.etree.ElementTree as ET - root = ET.parse(emit_ts.QUARTO_SYNTAX / "mojo.xml").getroot() + root = ET.parse(emit_ts.SYNTAX_DIR / "mojo.xml").getroot() lists = {l.get("name"): [i.text for i in l] for l in root.iter("list")} self.assertIn("def", lists["keywords"]) self.assertNotIn("fn", lists["keywords"]) diff --git a/scripts/package.py b/scripts/package.py new file mode 100644 index 0000000..a705cda --- /dev/null +++ b/scripts/package.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +"""Zip the repository for sharing: the files git tracks, plus new files it does not ignore. + + pixi run package # writes package/pplus-core-.zip + +Nothing git ignores goes in: no .DS_Store, __pycache__, scratch/, dist/, site/, node_modules/ or +.pixi/. Files are stored under a top folder named pplus-core/. +Standard library only, like the corpus pipeline. +""" +import pathlib +import subprocess +import sys +import zipfile + +ROOT = pathlib.Path(__file__).resolve().parent.parent + + +def git(*args: str) -> str: + return subprocess.run(["git", *args], cwd=ROOT, check=True, capture_output=True, text=True).stdout + + +def main() -> int: + try: + commit = git("rev-parse", "--short", "HEAD").strip() + except (subprocess.CalledProcessError, FileNotFoundError): + print("package: this needs a git checkout (git init and commit first)", file=sys.stderr) + return 1 + dirty = bool(git("status", "--porcelain").strip()) + names = sorted(set(git("ls-files", "-z", "--cached", "--others", "--exclude-standard").split("\0")) - {""}) + names = [n for n in names if (ROOT / n).is_file()] + out_dir = ROOT / "package" + out_dir.mkdir(exist_ok=True) + out = out_dir / f"pplus-core-{commit}{'-dirty' if dirty else ''}.zip" + with zipfile.ZipFile(out, "w", compression=zipfile.ZIP_DEFLATED) as z: + for n in names: + z.write(ROOT / n, f"pplus-core/{n}") + size = out.stat().st_size / 1e6 + print(f"wrote {out.relative_to(ROOT)}: {len(names)} files, {size:.1f} MB{' (with uncommitted changes)' if dirty else ''}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/tests/test_dafny.py b/scripts/tests/test_dafny.py new file mode 100644 index 0000000..8b0ac5d --- /dev/null +++ b/scripts/tests/test_dafny.py @@ -0,0 +1,47 @@ +"""The Dafny pin, offline: every pinned platform has a release and a hash, an unpinned one is refused, and unpacking +keeps the executable bits Dafny and Z3 need.""" +import os +import stat +import sys +import tempfile +import unittest +import zipfile +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) +import dafny # noqa: E402 + + +class Pin(unittest.TestCase): + def test_every_pinned_platform_names_this_version_and_a_sha256(self): + self.assertTrue(dafny.RELEASES) + for (system, machine), (asset, digest) in dafny.RELEASES.items(): + self.assertIn(dafny.VERSION, asset, f"{system} {machine}") + self.assertRegex(digest, r"^[0-9a-f]{64}$", f"{system} {machine}") + + def test_the_two_platforms_pixi_pins_are_covered(self): + self.assertIn(("Linux", "x86_64"), dafny.RELEASES) + self.assertIn(("Darwin", "arm64"), dafny.RELEASES) + + def test_an_unpinned_platform_is_refused_by_name(self): + with self.assertRaises(SystemExit) as e: + dafny.release("Plan9", "mips") + self.assertIn("Plan9 mips", str(e.exception)) + + +class Unpack(unittest.TestCase): + def test_unpacking_keeps_executable_bits(self): + with tempfile.TemporaryDirectory() as d: + z = Path(d) / "a.zip" + with zipfile.ZipFile(z, "w") as w: + info = zipfile.ZipInfo("dafny/dafny") + info.external_attr = (0o755 | stat.S_IFREG) << 16 + w.writestr(info, "#!/bin/sh\n") + w.writestr("dafny/readme.txt", "text") + dafny.unpack(z, Path(d) / "out") + self.assertTrue(os.access(Path(d) / "out/dafny/dafny", os.X_OK)) + self.assertTrue((Path(d) / "out/dafny/readme.txt").exists()) + + +if __name__ == "__main__": + unittest.main() diff --git a/src/common/workspace.ts b/src/common/workspace.ts index b8aced5..6f770a1 100644 --- a/src/common/workspace.ts +++ b/src/common/workspace.ts @@ -75,6 +75,9 @@ export class Workspace { return true; } + /** Make a stale pane the authority without changing its text: the others are regenerated from it. */ + takeAuthority(lang: Linked): boolean { return this.edit(lang, this.source(lang), true); } + /** The linked panes as shown: what is written, with an empty one generated from the pseudo until the first edit. */ protected fill(): { sources: Sources; stale: Partial>; maps: HubMaps } { if (this.state.sync) return { sources: this.state.sources, stale: {}, maps: this.maps }; diff --git a/src/engines/asm86/machine.js b/src/engines/asm86/machine.js index a779d55..54a7cbe 100644 --- a/src/engines/asm86/machine.js +++ b/src/engines/asm86/machine.js @@ -283,6 +283,7 @@ const cache = new WeakMap(); * perf() totals in the style of `perf stat` * } */ +/** @param {any} trace @param {any} [machine] the machine preset or spec; absent: the trace's own */ export function hardwareFor(trace, machine) { const cfg = resolveMachine(machine ?? trace.spec?.machine); const key = JSON.stringify(cfg); diff --git a/src/exercises/types.ts b/src/exercises/types.ts index 625465c..799554e 100644 --- a/src/exercises/types.ts +++ b/src/exercises/types.ts @@ -4,8 +4,8 @@ * the embeds, and the tests pick it up. `npm test` checks every exercise: * its pseudocode parses, its call runs, and its expected answer matches. */ -import type { LangId, ViewId } from '../core/types.js'; -import type { AreaId } from '../core/types.js'; +import type { LangId, ViewId } from '../common/types.js'; +import type { AreaId } from '../common/types.js'; export interface Exercise { /** URL id: lowercase, hyphens. */ diff --git a/src/mojo/check.ts b/src/mojo/check.ts index da63e39..e71d7d3 100644 --- a/src/mojo/check.ts +++ b/src/mojo/check.ts @@ -9,7 +9,7 @@ * Everything else waits for the Compile button, whose answer replaces these * findings; Stage 2's checker grows this file. */ -import type { Diagnostic } from '../core/types.js'; +import type { Diagnostic } from '../common/types.js'; import { MOJO_REMOVED_MESSAGES, MOJO_REMOVED_WORDS } from './generated/tokens.js'; import { MOJO_VERSION } from './generated/pin.js'; import { tokenizeMojo } from './tokenize.js'; diff --git a/src/mojo/interp.ts b/src/mojo/interp.ts index bc472ad..daa480e 100644 --- a/src/mojo/interp.ts +++ b/src/mojo/interp.ts @@ -23,7 +23,7 @@ import type { Arg, Expr, Module, Param, Pos, Stmt } from './parse.js'; import { parseModule } from './parse.js'; import { lifetimes, type Lifetimes } from './lifetimes.js'; -import type { Trace } from '../core/types.js'; +import type { Trace } from '../common/types.js'; import { type V, INT_TYPES, int, float, bool, str, NONE, floordiv, mod, truncdiv, show, display, typeName, keyOf, deepCopy, truthy, equal, utf8, codepoints, roundHalfEven, Unprintable, diff --git a/src/mojo/practices.ts b/src/mojo/practices.ts index eb00ecd..a703b83 100644 --- a/src/mojo/practices.ts +++ b/src/mojo/practices.ts @@ -8,7 +8,7 @@ * tests to pass the checker and to print what the original printed. A rule that cannot promise that explains and * leaves the editing to the student. */ -import type { QuickFix, Diagnostic } from '../core/types.js'; +import type { QuickFix, Diagnostic } from '../common/types.js'; import { parseModule, type Expr, type Module, type Stmt } from './parse.js'; import { checkMojo } from './check.js'; import { MOJO_PRELUDE_RAISES } from './generated/stdlib.js'; diff --git a/src/mojo/properties.ts b/src/mojo/properties.ts index 951791a..a1f5855 100644 --- a/src/mojo/properties.ts +++ b/src/mojo/properties.ts @@ -23,7 +23,7 @@ import type { Expr, Module, Stmt } from './parse.js'; import { callMojo } from './interp.js'; import { type V, int, float, bool, str, INT_TYPES, show, reprFloat } from './values.js'; -import type { PropertyReport } from '../core/types.js'; +import type { PropertyReport } from '../common/types.js'; type DefStmt = Extract; export type Gen = { edges: V[]; random: (rnd: () => number) => V; size: (v: V) => number }; diff --git a/src/mojo/typecheck.ts b/src/mojo/typecheck.ts index 235c55e..bb21625 100644 --- a/src/mojo/typecheck.ts +++ b/src/mojo/typecheck.ts @@ -26,7 +26,7 @@ */ import type { Expr, Module, Param, Pos, Stmt } from './parse.js'; import { parseModule } from './parse.js'; -import type { QuickFix } from '../core/types.js'; +import type { QuickFix } from '../common/types.js'; import { MOJO_STD_STRUCTS, MOJO_STD_TRAITS } from './generated/types.js'; export interface Finding3 { severity: 'error' | 'note'; line: number; col: number; message: string; id: string; question?: { text: string; options: QuickFix[] } } diff --git a/src/services/asm.ts b/src/services/asm.ts index 1f4a5a1..ec7a5e8 100644 --- a/src/services/asm.ts +++ b/src/services/asm.ts @@ -6,8 +6,8 @@ */ import { assemble, run as runAsm, AsmError } from '../engines/asm86/interp.js'; import { hardwareFor } from '../engines/asm86/machine.js'; -import { MACHINE_PRESETS, machineName, machineSpec, parseMachine } from '../core/machine.js'; -import type { Diagnostic, LanguageService, Parsed, RunOptions, Trace } from '../core/types.js'; +import { MACHINE_PRESETS, machineName, machineSpec, parseMachine } from '../common/machine.js'; +import type { Diagnostic, LanguageService, Parsed, RunOptions, Trace } from '../common/types.js'; export type AsmProgram = any; export type AsmState = any; diff --git a/src/services/godbolt.ts b/src/services/godbolt.ts index 4777a86..4040b71 100644 --- a/src/services/godbolt.ts +++ b/src/services/godbolt.ts @@ -22,7 +22,7 @@ * default arguments point at line 218 of io.mojo), so a line is the * program's only when godbolt says it comes from the program's file. */ -import type { Diagnostic, QuickFix } from '../core/types.js'; +import type { Diagnostic, QuickFix } from '../common/types.js'; import { GODBOLT_BASE, GODBOLT_COMPILER, MOJO_VERSION } from '../mojo/generated/pin.js'; /** How the program is built: as written (every function kept, -O0) or as `mojo build` does by default. */ diff --git a/src/services/index.ts b/src/services/index.ts index 478fe49..85d7a26 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,4 +1,4 @@ -import type { LangId, LanguageService } from '../core/types.js'; +import type { LangId, LanguageService } from '../common/types.js'; import { lingoService } from './lingo.js'; import { mathoService } from './matho.js'; import { pseudoService } from './pseudo.js'; diff --git a/src/services/lingo.ts b/src/services/lingo.ts index 47e3c9f..d657632 100644 --- a/src/services/lingo.ts +++ b/src/services/lingo.ts @@ -6,7 +6,7 @@ * service so the trace is the same shape. */ import { readSteps, SENTENCE_FORMS } from '../engines/pseudo/english.js'; -import type { Diagnostic, LanguageService, Lowered, Parsed, RunOptions, Trace } from '../core/types.js'; +import type { Diagnostic, LanguageService, Lowered, Parsed, RunOptions, Trace } from '../common/types.js'; import { toDiagnostic, studyOf, runPseudo, defaultCall as pseudoDefaultCall } from './pseudo.js'; export type Reading = any; diff --git a/src/services/matho.ts b/src/services/matho.ts index 1b42eb2..d58900f 100644 --- a/src/services/matho.ts +++ b/src/services/matho.ts @@ -31,9 +31,9 @@ * which are lists, where a 1-based sum meets a 0-based list) are reported * as notes on the equation's line, so nothing is decided silently. */ -import type { Diagnostic, LanguageService, Lowered, Parsed, RunOptions, Trace } from '../core/types.js'; +import type { Diagnostic, LanguageService, Lowered, Parsed, RunOptions, Trace } from '../common/types.js'; import { studyOf, runPseudo, defaultCall as pseudoDefaultCall } from './pseudo.js'; -import { reservedNames } from '../core/reference.js'; +import { reservedNames } from '../common/reference.js'; /* ------------------------------------------------------------------ */ /* Tokens */ diff --git a/src/services/mojo.ts b/src/services/mojo.ts index 81849f1..0a59bcd 100644 --- a/src/services/mojo.ts +++ b/src/services/mojo.ts @@ -6,7 +6,7 @@ * Mojo runs on the real compiler through the Compile button (src/services/godbolt), * and Programming+'s own stepping arrives with the interpreter in Stage 3. */ -import type { LanguageService, Parsed } from '../core/types.js'; +import type { LanguageService, Parsed } from '../common/types.js'; import { tokenizeMojo, tokenizeMojoLine } from '../mojo/tokenize.js'; import { checkMojo } from '../mojo/check.js'; import type { Module } from '../mojo/parse.js'; diff --git a/src/services/pseudo.ts b/src/services/pseudo.ts index 0fd133f..3231725 100644 --- a/src/services/pseudo.ts +++ b/src/services/pseudo.ts @@ -9,7 +9,7 @@ import { parseExpression, sourceOf } from '../engines/pseudo/parse.js'; import { verify } from '../engines/pseudo/vcgen.js'; import { checkProperties } from '../engines/pseudo/testing.js'; import { typeName, PArray, formatValue, KEYWORDS, BUILTINS } from '../engines/pseudo/lang.js'; -import type { Diagnostic, LanguageService, Parsed, ProofReport, PropertyReport, RunOptions, Trace } from '../core/types.js'; +import type { Diagnostic, LanguageService, Parsed, ProofReport, PropertyReport, RunOptions, Trace } from '../common/types.js'; /* The engine's own shapes, typed loosely: they are JavaScript. */ export type Study = any; diff --git a/src/services/speco.ts b/src/services/speco.ts index 0e77127..942464b 100644 --- a/src/services/speco.ts +++ b/src/services/speco.ts @@ -18,9 +18,9 @@ * and the reverse direction renders a pseudocode program's contracts as a * speco document, so existing examples show up in the pane. */ -import type { Diagnostic, LanguageService, Lowered, Parsed, ProofReport } from '../core/types.js'; +import type { Diagnostic, LanguageService, Lowered, Parsed, ProofReport } from '../common/types.js'; import { studyOf, provePseudo } from './pseudo.js'; -import { SPECO_SYMBOLS } from '../core/reference.js'; +import { SPECO_SYMBOLS } from '../common/reference.js'; export interface SpecLoop { selector: string; /** 1-based line of the LOOP header in the speco source */ line?: number; lines: Array<{ kind: 'INVARIANT' | 'DECREASES'; text: string; line: number }> } export interface SpecUnit { diff --git a/src/sync/hub.ts b/src/sync/hub.ts index 297d7ab..f782092 100644 --- a/src/sync/hub.ts +++ b/src/sync/hub.ts @@ -15,7 +15,7 @@ * 6. Opening a problem rewrites nothing: `fill` generates only the linked panes that are empty. * 7. Line maps compose through the hub: `relate` answers "which lines of that pane match this line here". */ -import type { Diagnostic, LangId } from '../core/types.js'; +import type { Diagnostic, LangId } from '../common/types.js'; import { readLingo, lowerLingo } from '../services/lingo.js'; import { parseMatho, lowerMatho } from '../services/matho.js'; import { studyOf, defaultCall } from '../services/pseudo.js'; diff --git a/src/sync/pseudo-to-lingo.ts b/src/sync/pseudo-to-lingo.ts index 73b3fb5..2d4e8a1 100644 --- a/src/sync/pseudo-to-lingo.ts +++ b/src/sync/pseudo-to-lingo.ts @@ -27,7 +27,7 @@ import { studyPseudo as study } from '../services/pseudo-study.js'; import { readSteps } from '../engines/pseudo/english.js'; import { walkStatements, walkExpr, statementExprs } from '../engines/pseudo/analyze.js'; import { toDiagnostic } from '../services/pseudo.js'; -import type { Diagnostic } from '../core/types.js'; +import type { Diagnostic } from '../common/types.js'; import type { LineMap } from './types.js'; export interface LingoResult { source: string; map: LineMap; notes: Diagnostic[] } diff --git a/src/sync/pseudo-to-matho.ts b/src/sync/pseudo-to-matho.ts index 3dbe748..0392fef 100644 --- a/src/sync/pseudo-to-matho.ts +++ b/src/sync/pseudo-to-matho.ts @@ -30,7 +30,7 @@ import { studyPseudo as study } from '../services/pseudo-study.js'; import { walkExpr } from '../engines/pseudo/analyze.js'; import { studyOf, runPseudo, toDiagnostic } from '../services/pseudo.js'; import { parseMatho } from '../services/matho.js'; -import type { Diagnostic } from '../core/types.js'; +import type { Diagnostic } from '../common/types.js'; import type { LineMap, NameMap } from './types.js'; export interface MathoResult { source: string; map: LineMap; notes: Diagnostic[] } diff --git a/src/sync/pseudo-to-mojo.ts b/src/sync/pseudo-to-mojo.ts index 0e13b8e..df41c50 100644 --- a/src/sync/pseudo-to-mojo.ts +++ b/src/sync/pseudo-to-mojo.ts @@ -30,7 +30,7 @@ import { sourceOf, parseExpression } from '../engines/pseudo/parse.js'; import { walkStatements, walkExpr, statementExprs, rootName } from '../engines/pseudo/analyze.js'; import { toDiagnostic } from '../services/pseudo.js'; import { MOJO_STD_EXPORTS } from '../mojo/generated/stdlib.js'; -import type { Diagnostic } from '../core/types.js'; +import type { Diagnostic } from '../common/types.js'; import type { LineMap } from './types.js'; import { GENERATED_HEADER } from './header.js'; diff --git a/src/sync/types.ts b/src/sync/types.ts index eb3afd8..23d55bf 100644 --- a/src/sync/types.ts +++ b/src/sync/types.ts @@ -4,7 +4,7 @@ * Pseudo is the hub: lingo, matho, and Mojo each translate to or from pseudo, * never to each other. A translator is a pure function of text. */ -import type { Diagnostic } from '../core/types.js'; +import type { Diagnostic } from '../common/types.js'; /** * Where each line of a translator's output came from. Entry `i` is the diff --git a/syntax/mojo.xml b/syntax/mojo.xml new file mode 100644 index 0000000..fa17eeb --- /dev/null +++ b/syntax/mojo.xml @@ -0,0 +1,310 @@ + + + + + + + False + None + Self + True + _ + abi + and + as + assert + async + await + break + capturing + case + class + comptime + conforms_to + continue + def + del + elif + else + escaping + except + finally + for + from + global + if + import + in + is + lambda + match + nonlocal + not + or + origin_of + pass + raise + raises + return + struct + thin + trait + try + type_of + where + while + with + yield + + + deinit + imm + mut + out + ref + var + + + fn + read + + + Absable + AddressSpace + AnyOrigin + AnyType + Array + BFloat16 + Bool + Boolable + Byte + Codepoint + Comparable + Copyable + DType + Defaultable + Deinitable + Dict + Equatable + Error + FileDescriptor + FileHandle + Float16 + Float32 + Float4_e2m1fn + Float64 + Float8_e4m3fn + Float8_e4m3fnuz + Float8_e5m2 + Float8_e5m2fnuz + Float8_e8m0fnu + FloatLiteral + Floatable + FloatableRaising + Hashable + Identifiable + ImmOpaquePointer + ImmOrigin + ImmPointer + ImmSpan + ImmStaticOrigin + ImmStringSlice + ImmStringSpan + ImmUnsafeAnyOrigin + ImmUntrackedOrigin + ImmutAnyOrigin + ImplicitlyCopyable + Indexer + InlineLevel + Int + Int128 + Int16 + Int256 + Int32 + Int64 + Int8 + IntLiteral + Intable + IntableRaising + Iterable + IterableOwned + Iterator + KeyElement + List + Movable + MutAnyOrigin + MutOpaquePointer + MutOrigin + MutPointer + MutSpan + MutStringSlice + MutStringSpan + MutUnsafeAnyOrigin + MutUntrackedOrigin + Never + NoneType + OpaquePointer + Optional + OptionalPointer + Origin + OriginSet + ParameterList + Pointer + Powable + RegisterPassable + ReversibleRange + Roundable + SIMD + SIMDLength + Scalar + Sized + SizedRaising + Slice + Some + SomeTypeList + Span + StaticString + StopIteration + String + StringLiteral + StringSlice + StringSpan + TrivialRegisterPassable + Tuple + TypeList + UInt + UInt128 + UInt16 + UInt256 + UInt32 + UInt64 + UInt8 + UnsafeAnyOrigin + UnsafePointer + UntrackedOrigin + VariadicList + VariadicPack + Writable + Writer + abs + all + alloc + any + ascii + atof + atol + bin + breakpoint + chr + debug_assert + deinit + divmod + doc_hidden + enumerate + hash + hex + index + input + iter + len + map + materialize + max + min + next + oct + open + ord + partition + pow + print + range + rebind + rebind_var + reflect + repr + reversed + round + slice + sort + swap + zip + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/boundary.test.mjs b/tests/boundary.test.mjs new file mode 100644 index 0000000..f0c696d --- /dev/null +++ b/tests/boundary.test.mjs @@ -0,0 +1,57 @@ +// pplus-core has no DOM: what a program means is decided without a browser. Its library modules never touch the +// document, the window or browser storage, and never import the course's page widgets, which live beside the +// engines only so the course and pplus-web can take them from one place (docs/engines.md). +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; + +const ROOT = new URL('..', import.meta.url).pathname; +const SRC = path.join(ROOT, 'src'); + +/** The course's page widgets: they draw into a page, and only pages (the course's, pplus-web's) import them. */ +export const WIDGETS = new Set([ + 'engines/pseudo/dom.js', 'engines/pseudo/views.js', 'engines/pseudo/views-analysis.js', 'engines/pseudo/lab.js', + 'engines/pseudo/editor.js', 'engines/pseudo/exercise.js', 'engines/pseudo/sharpen.js', 'engines/pseudo/plan.js', + 'engines/pseudo/planner.js', 'engines/pseudo/highlight.js', + 'engines/asm86/views.js', 'engines/asm86/hwviews.js', 'engines/asm86/dom.js', 'engines/asm86/sandbox.js', 'engines/asm86/specs-hw.js', + 'engines/shared/dom.js', 'engines/shared/share.js', 'engines/shared/viz.js', +]); + +function walk(dir, out = []) { + for (const e of fs.readdirSync(dir, { withFileTypes: true })) { + const p = path.join(dir, e.name); + if (e.isDirectory()) walk(p, out); else if (/\.(ts|js)$/.test(e.name)) out.push(path.relative(SRC, p)); + } + return out; +} +const asJs = (p) => p.replace(/\.ts$/, '.js'); +const files = walk(SRC); +const library = files.filter((f) => !WIDGETS.has(asJs(f))); + +test('every widget named here exists, so the list cannot rot', () => { + for (const w of WIDGETS) assert.ok(files.some((f) => asJs(f) === w), `${w} is not in src/`); +}); + +test('no library module touches the document, the window or browser storage', () => { + const bad = []; + for (const f of library) { + const code = fs.readFileSync(path.join(SRC, f), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, ''); + for (const w of ['document.', 'window.', 'localStorage', 'sessionStorage', 'navigator.', 'HTMLElement']) if (code.includes(w)) bad.push(`${f}: ${w}`); + } + assert.deepEqual(bad, []); +}); + +test('no library module imports a widget, and nothing imports from outside core', () => { + const bad = []; + for (const f of library) { + const code = fs.readFileSync(path.join(SRC, f), 'utf8'); + for (const m of code.matchAll(/(?:from|import)\s*\(?\s*['"](\.{1,2}\/[^'"]+)['"]/g)) { + const target = path.normalize(path.join(path.dirname(f), m[1])); + if (target.startsWith('..')) bad.push(`${f} imports ${m[1]}, outside src/`); + else if (WIDGETS.has(asJs(target))) bad.push(`${f} imports the widget ${m[1]}`); + } + if (/['"]#core\//.test(code)) bad.push(`${f} uses #core/, which is how pplus-web reaches core`); + } + assert.deepEqual(bad, []); +}); diff --git a/tests/curriculum.test.mjs b/tests/curriculum.test.mjs index 5ef0086..423a10b 100644 --- a/tests/curriculum.test.mjs +++ b/tests/curriculum.test.mjs @@ -3,7 +3,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { LESSONS, CONCEPTS, CONCEPT_BY_ID, FLAVORS, teacherOf, prerequisitesOf, depthOf, allPrerequisitesOf, statusOf, solutionOf, starterOf } from '../dist/curriculum/index.js'; import { studyOf, runPseudo } from '../dist/services/pseudo.js'; -import { problemById } from '../dist/core/problems.js'; +import { problemById } from '../dist/common/problems.js'; const conceptIds = new Set(CONCEPTS.map((c) => c.id)); const flavorIds = new Set(FLAVORS.map((f) => f.id)); diff --git a/tests/dafny.test.mjs b/tests/dafny.test.mjs new file mode 100644 index 0000000..f45c453 --- /dev/null +++ b/tests/dafny.test.mjs @@ -0,0 +1,28 @@ +// The pinned Dafny (scripts/dafny.py): its offline tests, and, when it has been fetched, that it is the pinned +// version and verifies a program. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { spawnSync } from 'node:child_process'; + +const py = spawnSync('python3', ['--version']); +const ROOT = new URL('..', import.meta.url).pathname; + +test('the Dafny pin\'s own tests pass (python3)', { skip: py.status !== 0 ? 'python3 is not installed' : false }, () => { + const r = spawnSync('python3', ['-m', 'unittest', 'discover', '-s', 'scripts/tests'], { encoding: 'utf8', cwd: ROOT }); + assert.equal(r.status, 0, r.stderr); +}); + +const exe = ROOT + '.tools/dafny-4.11.0/dafny/dafny'; +test('the fetched Dafny is the pinned one, and verifies a program', { skip: fs.existsSync(exe) ? false : 'Dafny has not been fetched (pixi run dafny-fetch)' }, () => { + const v = spawnSync(exe, ['--version'], { encoding: 'utf8' }); + assert.match(v.stdout, /^4\.11\.0\+/); + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'pplus-dafny-')); + fs.writeFileSync(dir + '/max.dfy', 'method Max(a: int, b: int) returns (m: int) ensures m >= a && m >= b { if a > b { m := a; } else { m := b; } }\n'); + const r = spawnSync(exe, ['verify', dir + '/max.dfy'], { encoding: 'utf8' }); + fs.rmSync(dir, { recursive: true, force: true }); + assert.equal(r.status, 0, r.stdout + r.stderr); + assert.match(r.stdout, /1 verified, 0 errors/); +}); diff --git a/tests/exercises.test.mjs b/tests/exercises.test.mjs index e9b4fc3..a69d710 100644 --- a/tests/exercises.test.mjs +++ b/tests/exercises.test.mjs @@ -2,11 +2,10 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { EXERCISES } from '../dist/exercises/index.js'; -import { PROBLEMS, stateForProblem } from '../dist/core/catalog.js'; -import { Session } from '../dist/core/session.js'; import template from '../dist/exercises/_template.js'; +import { Workspace } from '../dist/common/workspace.js'; +import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js'; -globalThis.localStorage = { getItem() { return null; }, setItem() { }, removeItem() { } }; test('exercise ids are unique, URL-safe, and the template is not registered', () => { const ids = EXERCISES.map((e) => e.id); @@ -18,9 +17,9 @@ test('exercise ids are unique, URL-safe, and the template is not registered', () test('every exercise with an expected answer produces it', () => { for (const p of PROBLEMS) { if (!p.expect) continue; - const st = stateForProblem(p); + const st = workForProblem(p); if (st.sources.pseudo) st.lang = 'pseudo'; - const s = new Session(st); + const s = new Workspace(st); const tr = s.trace(); assert.ok(tr && !tr.error, `${p.id}: ${s.runError || tr?.error?.message}`); const last = tr.output.at(-1); @@ -29,7 +28,7 @@ test('every exercise with an expected answer produces it', () => { }); test('the template itself is a valid exercise', () => { - const s = new Session(stateForProblem({ ...template, lang: 'pseudo' })); + const s = new Workspace(workForProblem({ ...template, lang: 'pseudo' })); const tr = s.trace(); assert.ok(tr && !tr.error, s.runError || tr?.error?.message); assert.ok(tr.output.at(-1).endsWith(`returned ${template.expect}`)); diff --git a/tests/fuzz.test.mjs b/tests/fuzz.test.mjs index ae41260..57f41a5 100644 --- a/tests/fuzz.test.mjs +++ b/tests/fuzz.test.mjs @@ -2,13 +2,12 @@ // is what the engines do. Run on every exercise, in pseudo and in Mojo. import test from 'node:test'; import assert from 'node:assert/strict'; -import { Session } from '../dist/core/session.js'; -import { PROBLEMS, stateForProblem, problemById } from '../dist/core/catalog.js'; -import { STRATEGY } from '../dist/core/fuzz.js'; +import { STRATEGY } from '../dist/common/fuzz.js'; +import { Workspace } from '../dist/common/workspace.js'; +import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js'; -globalThis.localStorage = { getItem() { return null; }, setItem() { }, removeItem() { } }; -const open = (p, lang, call) => { const st = stateForProblem(p); st.lang = lang; if (call) st.call = call; return new Session(st, { area: lang === 'mojo' ? 'dev' : 'bridge', storageId: null }); }; +const open = (p, lang, call) => { const st = workForProblem(p); st.lang = lang; if (call) st.call = call; return new Workspace(st); }; const ALL = []; for (const p of PROBLEMS) for (const lang of ['pseudo', 'mojo']) if ((p.sources?.[lang] ?? '').trim()) ALL.push({ p, lang, s: open(p, lang) }); @@ -44,7 +43,7 @@ test('every report says what it tried, what it checked, and what happened, and a test('the same seed makes the same inputs; another seed makes others', () => { const s = open(problemById('count-base'), 'pseudo'); const a = s.fuzz({ seed: 7, budget: 100 })[0].cases.map((c) => c.call); - const b = new Session(s.state, { storageId: null }).fuzz({ seed: 7, budget: 100 })[0].cases.map((c) => c.call); + const b = new Workspace(s.state).fuzz({ seed: 7, budget: 100 })[0].cases.map((c) => c.call); const c = s.fuzz({ seed: 8, budget: 100 })[0].cases.map((c) => c.call); assert.deepEqual(a, b); assert.notDeepEqual(a, c); diff --git a/tests/hardware.test.mjs b/tests/hardware.test.mjs new file mode 100644 index 0000000..588924e --- /dev/null +++ b/tests/hardware.test.mjs @@ -0,0 +1,85 @@ +// The x86-64 model machine: for every problem that has assembly, on every machine, the hardware model runs, the +// machine presets reach it, and the pipeline, micro-op, out-of-order and encoding data hold together. The app's +// board, which decides what the course views are given, is tested in pplus-web. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { stageOccupancy, STAGES } from '../dist/engines/asm86/pipeline.js'; +import { coreAt } from '../dist/engines/asm86/ooo.js'; +import { decompose } from '../dist/engines/asm86/uops.js'; +import fs from 'node:fs'; +import { stripHeader, buildListing } from '../scripts/mojo/listings.mjs'; +import { forSimulator, simulatorSetup } from '../dist/mojo/att.js'; +import { listingFunctions } from '../dist/services/godbolt.js'; +import { hardwareFor, resolveMachine } from '../dist/engines/asm86/machine.js'; +import { viewNames } from '../dist/engines/asm86/views.js'; +import { SERVICES } from '../dist/services/index.js'; +import { MACHINE_PRESETS, parseMachine, machineName, machineSpec, machineLabel } from '../dist/common/machine.js'; +import { Workspace } from '../dist/common/workspace.js'; +import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js'; + + +/** Every catalog problem with an x86-64 pane, run as the Hardware area runs it. */ +const WITH_ASM = PROBLEMS.filter((p) => (p.sources?.asm ?? '').trim()); +const traceOf = (p, machine) => { + const st = workForProblem(p); + if (machine) st.machine = machine; + st.lang = 'asm'; + const s = new Workspace(st); + const tr = s.trace(); + assert.ok(tr && tr.lang === 'asm', `${p.id}: the x86-64 pane runs`); + return { session: s, tr, raw: tr.raw.trace }; +}; + +test('the hardware model runs on every problem with assembly, on both machines, with and without virtual memory', () => { + for (const p of WITH_ASM) for (const machine of ['teaching', 'realistic', 'teaching+paging', 'realistic+paging']) { + const { raw, tr } = traceOf(p, machine); + const hw = hardwareFor(raw); + assert.doesNotThrow(() => { hw.memory(); hw.pipeline(); hw.core(); }, `${p.id} on ${machine}`); + const perf = tr.raw.hardware().perf(); + assert.equal(perf.instructions, raw.stats.instructions, `${p.id} on ${machine}: the counters read the same run`); + for (const t of [0, 1, Math.floor(raw.count / 2), raw.count]) assert.ok(hw.memory().stateAt(t).h, `${p.id}: caches at step ${t}`); + } +}); + +test('a machine is a preset with virtual memory on or off, and the run carries it to the hardware model', () => { + assert.deepEqual(MACHINE_PRESETS.slice(0, 2), ['teaching', 'realistic']); + for (const preset of MACHINE_PRESETS) for (const paging of [false, true]) { + const name = machineName({ preset, paging }); + assert.deepEqual(parseMachine(name), { preset, paging }, name); + assert.equal(resolveMachine(machineSpec(name)).paging.enabled, paging, `${name}: paging`); + assert.match(machineLabel(name), new RegExp(`^${preset}`)); + } + assert.deepEqual(parseMachine(undefined), { preset: 'teaching', paging: false }); + assert.deepEqual(parseMachine('warp'), { preset: 'teaching', paging: false }, 'an unknown machine is the teaching one'); + const p = PROBLEMS.find((x) => x.id === 'asm-two-pointers'); + const { session, tr, raw } = traceOf(p, 'realistic+paging'); + assert.equal(tr.raw.machine, 'realistic+paging'); + const hw = hardwareFor(raw); + assert.equal(hw.config.caches.l1d.line, 64, 'the views see the realistic machine'); + assert.ok(hw.config.paging.enabled, 'and its virtual memory'); + assert.ok(hw.memory().steps.some((r) => r.translations.length), 'addresses are translated'); + session.state.machine = 'teaching'; + assert.notEqual(session.trace(), tr, 'a new machine is a new run'); + assert.equal(hardwareFor(session.trace().raw.trace).config.paging.enabled, false); +}); + +test('time: the pipeline, micro-op, out-of-order and encoding data the Pipeline and Whole chip presets draw', () => { + for (const p of WITH_ASM) for (const machine of ['teaching', 'realistic']) { + const { raw } = traceOf(p, machine); + const hw = hardwareFor(raw); + const pipe = hw.pipeline(); + const core = hw.core(); + assert.equal(pipe.rows.length >= raw.count, true, `${p.id}: a pipeline row per instruction run (and any wrong-path fetches)`); + for (const r of pipe.rows.slice(0, 200)) { + for (const st of STAGES) assert.equal(stageOccupancy(pipe, r.E[st])[st] != null, true, `${p.id}: ${st} is occupied when a row enters it`); + } + for (let c = 0; c <= core.cycles; c += Math.max(1, Math.floor(core.cycles / 50))) { + const at = coreAt(core, c); + assert.ok(at.rob.length <= hw.config.core.rob, `${p.id} cycle ${c}: the reorder buffer never holds more than it has room for`); + } + for (const ins of raw.program.instrs) { const u = decompose(ins); assert.ok(Array.isArray(u) && u.length >= 1, `${p.id}: ${ins.text} splits into micro-ops`); } + // the encoding view and the listing's bytes need the program laid out in memory + if (raw.layout?.ok) for (const ins of raw.program.instrs) assert.ok(raw.layout.len[ins.index] >= 1 && raw.layout.len[ins.index] <= 15, `${p.id}: ${ins.text} is 1 to 15 bytes`); + } + assert.ok(WITH_ASM.some((p) => traceOf(p).raw.layout?.ok), 'the problems encode'); +}); diff --git a/tests/mojo.test.mjs b/tests/mojo.test.mjs new file mode 100644 index 0000000..2c073af --- /dev/null +++ b/tests/mojo.test.mjs @@ -0,0 +1,269 @@ +// The Mojo corpus as the app sees it: the generated modules agree with mojo/pin.json +// and the harvested corpus, and the Python pipeline's own tests pass. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import { spawnSync } from 'node:child_process'; +import { MOJO_VERSION, GODBOLT_BASE, GODBOLT_COMPILER, MOJO_SOURCES } from '../dist/mojo/generated/pin.js'; +import { MOJO_KEYWORDS, MOJO_SOFT_KEYWORDS, MOJO_REMOVED_WORDS, MOJO_DECORATORS, MOJO_PRELUDE, MOJO_PUNCTUATION } from '../dist/mojo/generated/tokens.js'; +import { Workspace } from '../dist/common/workspace.js'; +import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js'; + +const pin = JSON.parse(fs.readFileSync(new URL('../mojo/pin.json', import.meta.url), 'utf8')); + +test('the generated pin is mojo/pin.json', () => { + assert.equal(MOJO_VERSION, pin.mojo.version); + assert.equal(GODBOLT_BASE, pin.godbolt.base); + assert.equal(GODBOLT_COMPILER, pin.godbolt.compiler); + assert.deepEqual(Object.keys(MOJO_SOURCES).sort(), Object.keys(pin.sources).sort()); +}); + +test('the generated words are the 1.1.0 language', () => { + for (const w of ['def', 'struct', 'trait', 'var', 'ref', 'comptime', 'raise', 'Self']) assert.ok(MOJO_KEYWORDS.includes(w), w); + assert.ok(!MOJO_KEYWORDS.includes('fn'), 'fn is removed in 1.1.0, not a keyword to highlight as valid'); + assert.equal(MOJO_REMOVED_WORDS.fn, 'def'); + assert.equal(MOJO_REMOVED_WORDS.read, 'imm'); + for (const w of ['imm', 'mut', 'out', 'deinit']) assert.ok(MOJO_SOFT_KEYWORDS.includes(w), w); + for (const d of ['fieldwise_init', 'always_inline', 'export']) assert.ok(MOJO_DECORATORS.includes(d), d); + for (const n of ['Int', 'String', 'List', 'Dict', 'Optional', 'print', 'input', 'range', 'len']) assert.ok(MOJO_PRELUDE.includes(n), n); + assert.ok(MOJO_PUNCTUATION.indexOf('**=') < MOJO_PUNCTUATION.indexOf('**'), 'longest spellings first'); +}); + +const py = spawnSync('python3', ['--version']); +test('the corpus pipeline tests pass (python3)', { skip: py.status !== 0 ? 'python3 is not installed' : false }, () => { + const r = spawnSync('python3', ['-m', 'unittest', 'discover', '-s', 'scripts/mojo/tests'], { encoding: 'utf8', cwd: new URL('..', import.meta.url).pathname }); + assert.equal(r.status, 0, r.stderr.split('\n').slice(-30).join('\n')); +}); + +/* --------------------------------------------------------------------------- + * Stage 1: the Mojo pane. Wherever possible these use godbolt's real answers + * (mojo/golden), so they test against what the compiler said, not what we assume. + * ------------------------------------------------------------------------- */ +import { tokenizeMojo } from '../dist/mojo/tokenize.js'; +import { removedSyntax } from '../dist/mojo/check.js'; +import { nextIndent } from '../dist/mojo/editing.js'; +import { mojoRequestBody, mojoRequestUrl, normaliseAnswer, compilerDiagnostics, listingFunctions, demangle, sourceOf as lineSource, BUILD_ARGS } from '../dist/services/godbolt.js'; +import { intelLine, labelMap, forSimulator } from '../dist/mojo/att.js'; +import { parseAsm, runAsmProgram } from '../dist/services/asm.js'; +import { runMojo } from '../dist/mojo/interp.js'; +import { parseModule } from '../dist/mojo/parse.js'; +import { MOJO_PROGRAMS } from '../dist/mojo/generated/programs.js'; + +const ROOT = new URL('..', import.meta.url).pathname; +const goldens = fs.readdirSync(new URL('../mojo/golden/', import.meta.url)).filter((f) => /^[0-9a-f]{64}\.json$/.test(f)) + .map((f) => JSON.parse(fs.readFileSync(new URL(`../mojo/golden/${f}`, import.meta.url), 'utf8'))); +/** godbolt's answer for one corpus item, rebuilt as the raw JSON the browser receives. */ +function answerFor(item) { + const g = goldens.find((x) => x.firstItem === item); + assert.ok(g, `no golden for ${item}; run pixi run mojo-verify`); + const source = (a) => a.line ? { line: a.line, ...('file' in a ? { file: a.file } : {}), ...('main' in a ? { mainsource: a.main } : {}) } : null; + return { golden: g, raw: { ...g.raw, asm: (g.result.asm || []).map((a) => ({ text: a.text, source: source(a) })) } }; +} +const sourceOf = (item) => fs.readFileSync(new URL(`../mojo/${item.replace('probes/', 'probes/')}.mojo`, import.meta.url), 'utf8'); +function applyFix(src, f) { + const lines = src.split('\n'); const l = lines[f.line - 1]; + lines[f.line - 1] = l.slice(0, f.col - 1) + f.text + l.slice(f.endCol == null ? l.length : f.endCol - 1); + return lines.join('\n'); +} +const kinds = (line) => tokenizeMojo(line)[0].filter((t) => t.cls).map((t) => `${t.cls.replace('tok-', '')}:${t.text}`); + +test('highlighting agrees with the Mojo grammar\'s own tests', () => { + const { cases } = JSON.parse(fs.readFileSync(new URL('../mojo/corpus/syntax/cases.json', import.meta.url), 'utf8')); + assert.ok(cases.length >= 20); + for (const c of cases) { + const toks = tokenizeMojo(c.text)[0]; + let at = 0; const hit = toks.find((t) => { const ok = c.start >= at && c.start < at + t.text.length; at += t.text.length; return ok; }); + const isKeyword = hit?.cls === 'tok-keyword'; + const wantsKeyword = c.scopes.some((x) => /^(keyword|storage)\./.test(x)); + // syntax 1.1.0 removed (alias) is not a keyword any more, whatever the grammar says + const expected = c.dialect?.older ? false : wantsKeyword; + assert.equal(isKeyword, expected, `${c.file}:${c.line} ${JSON.stringify(c.slice)} in ${JSON.stringify(c.text)} wants ${c.scopes.join(' ')}`); + } +}); + +test('highlighting: docstrings span lines, ^ transfers or XORs, conventions are ownership words', () => { + const doc = tokenizeMojo('def f():\n """One\n two."""\n return 1'); + assert.ok(doc[1].some((t) => t.cls === 'tok-string') && doc[2].every((t) => !t.text.trim() || t.cls === 'tok-string')); + assert.ok(doc[3].some((t) => t.cls === 'tok-keyword' && t.text === 'return')); + assert.ok(kinds('consume(b^, c)').includes('transfer:^')); + assert.ok(kinds('var b = a^').includes('transfer:^')); + assert.ok(kinds('var m = f ^ 0xFF').includes('op:^')); + assert.deepEqual(kinds('def g(mut self, var x: Int, deinit other: T):').filter((k) => k.startsWith('convention')), ['convention:mut', 'convention:var', 'convention:deinit']); + assert.ok(kinds(' var name: String').includes('keyword:var'), 'a field declaration is not a convention'); + assert.ok(kinds('def h(read x: Int):').includes('error:read')); + assert.ok(kinds('var data = file.read()').includes('name:read'), 'read is only an error as a convention'); + assert.ok(kinds('fn old():').includes('error:fn')); + assert.ok(kinds('@fieldwise_init').includes('label:fieldwise_init')); + assert.ok(kinds('print(t"n={n * 2}")').includes('name:n'), 't-string interpolations highlight as code'); +}); + +test('removed syntax is caught before compiling, in the compiler\'s words, with its fix', () => { + const src = 'fn main():\n show(1)\n\ndef show(read x: Int):\n print(x)\n'; + const ds = removedSyntax(src); + assert.deepEqual(ds.map((d) => [d.line, d.message]), [[1, "'fn' has been removed; use 'def' instead"], [4, "'read' was removed; use 'imm'"]]); + let fixed = src; + for (const d of [...ds].reverse()) fixed = applyFix(fixed, d.fix); + assert.equal(fixed, 'def main():\n show(1)\n\ndef show(imm x: Int):\n print(x)\n'); + assert.deepEqual(removedSyntax(fixed), []); + // and it is exactly what the real compiler said about the fn probe + const real = compilerDiagnostics(goldens.find((g) => g.firstItem === 'probes/dialect-fn').result.buildStderr); + assert.equal(real[0].message, ds[0].message); + const realRead = compilerDiagnostics(goldens.find((g) => g.firstItem === 'probes/dialect-read').result.buildStderr); + assert.equal(realRead[0].message, ds[1].message); +}); + +test('Enter indents after a block opener and dedents after return', () => { + assert.equal(nextIndent('def f(x: Int) -> Int:', ' '), ' '); + assert.equal(nextIndent(' comptime for i in range(3):', ' '), ' '); + assert.equal(nextIndent(' return x # done', ' '), ' '); + assert.equal(nextIndent(' var y = 1', ' '), ' '); +}); + +test('the Compile button asks godbolt exactly what the corpus harness asks', () => { + const src = 'def main():\n print(input())\n'; + const py = spawnSync('python3', ['-c', `import sys, json; sys.path.insert(0, 'scripts/mojo')\nfrom mojocorpus import godbolt\nprint(json.dumps(godbolt.request_body(${JSON.stringify(src)}, 'both', '7\\n', '-O0')))`], { encoding: 'utf8', cwd: ROOT }); + if (py.status !== 0) return; // no python3 here; the pipeline tests cover the Python side + assert.deepEqual(mojoRequestBody(src, '7\n', '-O0'), JSON.parse(py.stdout)); + assert.equal(mojoRequestUrl(), `${pin.godbolt.base}/api/compiler/${pin.godbolt.compiler}/compile`); +}); + +test('compiler errors land on their lines, and its fix-its become one-click fixes', () => { + // The probes were asked in run mode, where errors come in buildResult; the button's mode puts them in stderr. Same text. + const stderrOf = (item) => goldens.find((g) => g.firstItem === item).result.buildStderr; + const fnDiag = compilerDiagnostics(stderrOf('probes/dialect-fn')); + assert.equal(fnDiag[0].line, 3); + assert.equal(applyFix(sourceOf('probes/dialect-fn'), fnDiag[0].fix).split('\n')[2], 'def main():'); + const copy = compilerDiagnostics(stderrOf('probes/check-implicit-copy')); + const err = copy.find((d) => d.severity === 'error'); + assert.match(err.message, /cannot be implicitly copied/); + assert.equal(err.origin, 'the Mojo 1.1.0 compiler'); + const fixes = err.question.options.map((o) => applyFix(sourceOf('probes/check-implicit-copy'), o).split('\n')[err.line - 1].trim()); + assert.deepEqual(fixes, ['var b = a^', 'var b = a.copy()']); + const alias = compilerDiagnostics(stderrOf('probes/check-aliasing')); + assert.match(alias[0].message, /aliasing values passed mutably to 's' argument/); + assert.ok(alias.slice(1).every((d) => d.severity === 'note')); + assert.deepEqual(compilerDiagnostics(stderrOf('probes/check-use-after-move')).map((d) => [d.severity, d.message]), + [['error', "use of uninitialized value 'a'"], ['note', "'a' declared here"]]); +}); + +test('the real listing of add, translated to Intel, runs on the model machine', () => { + const ans = normaliseAnswer(answerFor('probes/godbolt-opt-O0').raw); + const fns = listingFunctions(ans.asm); + assert.deepEqual(fns.filter((f) => f.kind === 'user').map((f) => f.name), ['add(Int, Int)', 'main()']); + assert.deepEqual(fns.filter((f) => f.kind === 'entry').map((f) => f.name), ['main']); + const add = fns.find((f) => f.name === 'add(Int, Int)'); + const sim = forSimulator(fns, add); + assert.deepEqual(sim.source.split('\n').filter((l) => l.trim() && !l.trim().endsWith(':') && !l.includes(';')).map((l) => l.trim()), ['mov rax, rdi', 'add rax, rsi', 'ret']); + const run = runAsmProgram(parseAsm(sim.source), { setup: 'rdi = 2\nrsi = 3' }); + assert.ok(!run.error, run.error?.message); + assert.equal(run.output.at(-1), 'rax = 5 (0x5)'); + // main calls print, which the model machine cannot run: it assembles with a stub for print, steps up to the call, and stops there saying so + const main = forSimulator(fns, fns.find((f) => f.name === 'main()')); + assert.ok(main.refusedCalls.some((c) => /print/.test(c))); + const mp = parseAsm(main.source); + assert.ok(mp.ok, mp.diagnostics.map((d) => d.message).join('; ')); + const mr = runAsmProgram(mp, { setup: main.data.join('\n') }); + assert.ok(mr.count > 5, 'main steps its own instructions before the call'); + assert.match(mr.error.message, /print: standard library, not on the model machine/); +}); + +test('the optimized listing keeps no function of the user\'s, and one request returned listing and output', () => { + const ans = normaliseAnswer(answerFor('probes/godbolt-asm-and-run').raw); + assert.equal(ans.stdout, '5'); + assert.ok(ans.asm.length > 0 && ans.compiled && ans.executed && ans.exitCode === 0); + assert.deepEqual(listingFunctions(ans.asm).filter((f) => f.kind === 'user'), []); +}); + +test('AT&T to Intel: operands reverse, sizes become ptr, names become labels', () => { + const m = labelMap([{ label: '"example::add(::SIMD[DType.int, 1],::SIMD[DType.int, 1])"', name: 'add(Int, Int)', kind: 'user', lines: [] }]); + const cases = [ + ['movq %rdi, 16(%rsp)', 'mov qword ptr [rsp + 16], rdi'], + ['movl $0, -4(%rbp)', 'mov dword ptr [rbp - 4], 0'], + ['movzbl (%rdi,%rcx), %eax', 'movzx eax, byte ptr [rdi + rcx*1]'], + ['movslq 8(%rsi,%rax,4), %rdx', 'movsxd rdx, dword ptr [rsi + rax*4 + 8]'], + ['leaq static_string_ab(%rip), %rax', 'lea rax, [rip + static_string_ab]'], + ['imulq $3, %rsi, %rax', 'imul rax, rsi, 3'], + ['cmovneq %rcx, %rax', 'cmovne rax, rcx'], + ['callq "example::add(::SIMD[DType.int, 1],::SIMD[DType.int, 1])"@PLT', 'call add'], + ['jne .LBB2_2', 'jne .LBB2_2'], + ['retq', 'ret'], + ['cqto', 'cqo'], + ['.cfi_startproc', null], + ]; + for (const [att, intel] of cases) assert.equal(intelLine(att, m), intel, att); + assert.equal(demangle('"example::add(::SIMD[DType.int, 1],::SIMD[DType.float64, 1])"'), 'add(Int, Float64)'); +}); + +test('an exercise\'s Mojo is a verified program from the corpus', () => { + assert.equal(MOJO_PROGRAMS['count-base'].verified, true); + const p = PROBLEMS.find((x) => x.id === 'count-base'); + assert.equal(p.mojo.id, 'count-base'); + assert.equal(p.sources.mojo, MOJO_PROGRAMS['count-base'].source); + assert.ok(workForProblem(p).sources.mojo, 'the state carries the exercise\'s Mojo'); + for (const q of PROBLEMS) if (q.mojo) assert.ok(MOJO_PROGRAMS[q.mojo.id], `${q.id} names a Mojo program that does not exist`); + // every exercise with pseudo has its Mojo too, so the Mojo/pseudo switch always has both sides + for (const q of PROBLEMS) if (q.sources.pseudo) assert.ok(q.mojo, `${q.id} has pseudo but no Mojo program`); +}); + +test('each exercise\'s Mojo prints, in the interpreter, what the exercise expects of the pseudo', () => { + const norm = (s) => s.trim().replace(/^"(.*)"$/, '$1').replace(/^TRUE$/, 'True').replace(/^FALSE$/, 'False'); + for (const q of PROBLEMS) { + if (!q.mojo || !q.expect) continue; + const r = runMojo(parseModule(q.mojo.source), q.mojo.source, { maxSteps: 200000, record: false }); + if (r.refused) continue; // the stepper says why; the compiler is the judge + assert.equal(norm(r.stdout), norm(q.expect), `${q.id}: its Mojo printed ${JSON.stringify(r.stdout)}`); + } +}); + +test('the Compile button builds with exactly the flags a passing probe verified', () => { + const text = fs.readFileSync(new URL('../mojo/probes/godbolt-compile-button.mojo', import.meta.url), 'utf8'); + const args = /^# args: (.*)$/m.exec(text)[1].trim(); + assert.equal(BUILD_ARGS.O0, args, 'change the probe and re-verify before changing the button'); + const g = goldens.find((x) => x.firstItem === 'probes/godbolt-compile-button'); + if (!g) return; // a checkout without that golden; the corpus tests cover it + assert.equal(g.result.compiled && g.result.executed && g.result.exitCode, 0); + assert.equal(g.result.stdout.trim(), '5'); +}); + +test('a source line is the program\'s only when godbolt says it comes from the program\'s file', () => { + assert.deepEqual(lineSource({ line: 10, file: null }), { line: 10 }); + assert.deepEqual(lineSource({ line: 10 }), { line: 10 }); + assert.deepEqual(lineSource({ line: 10, file: '/app/example.mojo' }), { line: 10 }); + assert.deepEqual(lineSource({ line: 10, file: 'other', mainsource: true }), { line: 10 }); + assert.deepEqual(lineSource({ line: 218, file: '/opt/mojo/lib/std/io/io.mojo' }), { line: null, from: { file: 'io.mojo', line: 218 } }); + assert.deepEqual(lineSource({ line: 218, file: null, mainsource: false }), { line: null, from: { file: '?', line: 218 } }); + assert.deepEqual(lineSource(null), { line: null }); +}); + +test('with line tables, the program\'s own instructions point at the program\'s own lines', (t) => { + const g = goldens.find((x) => x.firstItem === 'probes/godbolt-compile-button'); + if (!g) return t.skip('no golden for probes/godbolt-compile-button'); + const marked = (g.result.asm || []).some((a) => 'file' in a || 'main' in a); + if (!marked) return t.skip("this golden predates file marking; run: pixi run mojo-verify-item 'probes/godbolt-*'"); + const fns = listingFunctions(normaliseAnswer(answerFor('probes/godbolt-compile-button').raw).asm); + const lines = (name) => [...new Set(fns.find((f) => f.name === name).lines.map((l) => l.line).filter((x) => x != null))]; + assert.deepEqual(lines('add(Int, Int)'), [5, 6]); + assert.deepEqual(lines('main()').sort(), [10, 9].sort()); + assert.ok(fns.find((f) => f.name === 'main()').lines.some((l) => l.from && l.from.file.endsWith('.mojo')), 'print\'s inlined defaults are marked as library code'); +}); + +test('Stage 6: a function\'s calls into the standard library are named, from the real listing', async () => { + const g = goldens.find((x) => x.firstItem === 'probes/godbolt-compile-button'); + if (!g) return; + const { libraryCalls } = await import('../dist/ui/views/compiler.js').catch(() => ({ libraryCalls: null })); + if (!libraryCalls) return; // the view needs a DOM to load; covered by the browser check + const fns = listingFunctions(normaliseAnswer(answerFor('probes/godbolt-compile-button').raw).asm); + assert.deepEqual(libraryCalls(fns.find((f) => f.name === 'main()')), ['print (std.io.io)']); + assert.deepEqual(libraryCalls(fns.find((f) => f.name === 'add(Int, Int)')), []); +}); + +test('Stage 6b: code sent to the x86-64 pane keeps each instruction\'s Mojo line', async () => { + const g = goldens.find((x) => x.firstItem === 'probes/godbolt-compile-button'); + if (!g) return; + const { forSimulator } = await import('../dist/mojo/att.js'); + const fns = listingFunctions(normaliseAnswer(answerFor('probes/godbolt-compile-button').raw).asm); + const { source } = forSimulator(fns, fns.find((f) => f.name === 'add(Int, Int)')); + const marks = source.split('\n').filter((l) => /; mojo line \d+/.test(l)).map((l) => Number(/; mojo line (\d+)/.exec(l)[1])); + assert.deepEqual([...new Set(marks)], [5, 6], 'the instructions of add carry lines 5 and 6'); +}); + diff --git a/tests/prover-soundness.test.mjs b/tests/prover-soundness.test.mjs index f8e954b..63ef4d1 100644 --- a/tests/prover-soundness.test.mjs +++ b/tests/prover-soundness.test.mjs @@ -18,7 +18,7 @@ import path from 'node:path'; import { studyOf, runPseudo } from '../dist/services/pseudo.js'; import { verify } from '../dist/engines/pseudo/vcgen.js'; import { checkProperties } from '../dist/engines/pseudo/testing.js'; -import { PROBLEMS } from '../dist/core/problems.js'; +import { PROBLEMS } from '../dist/common/problems.js'; import { LESSONS, solutionOf } from '../dist/curriculum/index.js'; const PROVER_DIR = 'tests/prover'; diff --git a/tests/reference.test.mjs b/tests/reference.test.mjs index 9fb4634..308e401 100644 --- a/tests/reference.test.mjs +++ b/tests/reference.test.mjs @@ -1,7 +1,7 @@ // The reference is only trustworthy if its examples run through the real parsers. import test from 'node:test'; import assert from 'node:assert/strict'; -import { REFERENCE, PSEUDO_REF, LINGO_REF, SPECO_REF, ASM_REF, MATHO_REF, explain, SPECO_SYMBOLS } from '../dist/core/reference.js'; +import { REFERENCE, PSEUDO_REF, LINGO_REF, SPECO_REF, ASM_REF, MATHO_REF, explain, SPECO_SYMBOLS } from '../dist/common/reference.js'; import { parseMatho } from '../dist/services/matho.js'; import { studyOf } from '../dist/services/pseudo.js'; import { readLingo } from '../dist/services/lingo.js'; diff --git a/tests/runview.test.mjs b/tests/runview.test.mjs index 090f8cd..f3c9d2f 100644 --- a/tests/runview.test.mjs +++ b/tests/runview.test.mjs @@ -3,15 +3,14 @@ // interpreters' own traces for every exercise, in pseudo and in Mojo. import test from 'node:test'; import assert from 'node:assert/strict'; -import { Session } from '../dist/core/session.js'; -import { PROBLEMS, stateForProblem, problemById } from '../dist/core/catalog.js'; -import { runColumns, runRows, defaultFollow, valuesAt, rulerCells, gridCells } from '../dist/core/runview.js'; +import { runColumns, runRows, defaultFollow, valuesAt, rulerCells, gridCells } from '../dist/common/runview.js'; +import { Workspace } from '../dist/common/workspace.js'; +import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js'; -globalThis.localStorage = { getItem() { return null; }, setItem() { }, removeItem() { } }; const traceOf = (p, lang) => { - const st = stateForProblem(p); st.lang = lang; - const s = new Session(st, { area: lang === 'mojo' ? 'dev' : null, storageId: null }); + const st = workForProblem(p); st.lang = lang; + const s = new Workspace(st); return s.trace(); }; const RUNS = []; diff --git a/tests/services.test.mjs b/tests/services.test.mjs new file mode 100644 index 0000000..5ffbb06 --- /dev/null +++ b/tests/services.test.mjs @@ -0,0 +1,100 @@ +// Runs against the compiled output: `npm test` builds first. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { toAscii, toMath, parseSpec, weave, extractSpec } from '../dist/services/speco.js'; +import { studyOf, runPseudo, provePseudo } from '../dist/services/pseudo.js'; +import { readLingo, runLingo } from '../dist/services/lingo.js'; +import { parseAsm, runAsmProgram, parseSetup } from '../dist/services/asm.js'; +import { Workspace } from '../dist/common/workspace.js'; +import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js'; + + +test('every catalog problem parses, runs, and (where it has pseudocode) proves without throwing', () => { + for (const p of PROBLEMS) { + const s = new Workspace(workForProblem(p)); + s.allDiagnostics(); + const tr = s.trace(); + const empty = !Object.values(p.sources).some((src) => src && src.trim()); + if (p.id !== 'five-bugs' && !empty) assert.ok(tr, `${p.id} produced no trace: ${s.runError}`); + if (p.sources.pseudo || p.sources.lingo) { s.proof(); s.tests(); } + } +}); + +test('the known-good examples give the lesson answers', () => { + const by = Object.fromEntries(PROBLEMS.map((p) => [p.id, p])); + const last = (id, lang) => { const st = workForProblem(by[id]); if (lang) st.lang = lang; const s = new Workspace(st); return s.trace().output.at(-1); }; + assert.equal(last('count-base', 'pseudo'), 'COUNT_BASE returned 3'); + assert.equal(last('count-base', 'lingo'), 'COUNT_BASES returned 3'); + assert.equal(last('match', 'pseudo'), 'MATCH returned [1]'); + assert.equal(last('revcomp', 'pseudo'), 'REVERSE_COMPLEMENT returned "TGTAATC"'); + assert.match(last('asm-first-instructions'), /^rax = 6/); +}); + +test('the off-by-one bug is caught by the run, the tests, and the proof', () => { + const st = workForProblem(PROBLEMS.find((p) => p.id === 'match-off-by-one')); st.lang = 'pseudo'; + const s = new Workspace(st); + assert.equal(s.trace().error.kind, 'index'); + assert.ok(s.tests().some((t) => t.failures.length > 0)); + assert.ok(s.proof().report.counts.broken >= 1); +}); + +test('speco: math notation lowers to the pseudocode spelling and back', () => { + assert.equal(toAscii('result = |{ k ∈ [0, |T|) : T[k] = B }|'), 'RESULT == LENGTH({ k IN [0, LENGTH(T)) : T[k] == B })'); + assert.equal(toAscii('∀ K ∈ [0, M) : A[K] ≤ B ∧ ¬ (X ≠ Y)'), 'FORALL K IN [0, M) : A[K] <= B AND NOT (X != Y)'); + assert.equal(toMath('RESULT == LENGTH({ K IN [0, LENGTH(T)) : T[K] == B })'), 'result = |{ K ∈ [0, |T|) : T[K] = B }|'); + assert.equal(toAscii(toMath('FORALL K IN [0, J) : T[I + K] == P[K]')), 'FORALL K IN [0, J) : T[I + K] == P[K]'); +}); + +test('speco: a spec written separately weaves in, proves, and does not duplicate what is already there', () => { + const pseudo = PROBLEMS.find((p) => p.id === 'count-base').sources.pseudo; + const spec = parseSpec(`SPEC COUNT_BASE(B, T)\n ENSURE result = |{ K ∈ [0, |T|) : T[K] = B }|\n LOOP FOR I\n INVARIANT Total = |{ K ∈ [0, I) : T[K] = B }|`); + assert.equal(spec.diagnostics.length, 0); + const w = weave(pseudo, spec); + assert.equal(w.diagnostics.length, 0); + assert.match(w.source, /FUNCTION COUNT_BASE[^\n]*\n\s+ENSURE RESULT == LENGTH/); + assert.match(w.source, /FOR I <- 0 TO N\n\s+INVARIANT Total == LENGTH/); + const st = studyOf(w.source); + assert.ok(st.ok, st.diagnostics.map((d) => d.message).join('; ')); + const pr = provePseudo(st); + assert.equal(pr.counts.open + pr.counts.broken, 0, JSON.stringify(pr.counts)); + assert.ok(pr.counts.proved >= 3); + // weaving the same spec again adds nothing + const again = weave(w.source, spec); + assert.equal(again.source, w.source); + // and extracting it back gives a spec that round-trips + const ex = extractSpec(w.source); + assert.match(ex, /^SPEC COUNT_BASE\(B, T\)/); + assert.equal(weave(pseudo, parseSpec(ex)).source, w.source); +}); + +test('speco: a spec for a routine that does not exist is reported, not silently dropped', () => { + const w = weave('FUNCTION F() RETURNS INTEGER\n RETURN 1\nENDFUNCTION', parseSpec('SPEC G()\n ENSURE RESULT == 1')); + assert.equal(w.diagnostics.length, 1); + assert.equal(w.diagnostics[0].id, 'no-routine'); +}); + +test('lingo: English steps lower, run, and report English line numbers', () => { + const r = readLingo('To count the G bases in T:\n Start with Count at 0.\n For each letter b of T:\n If b is \'G\', add 1 to Count.\n The answer is Count.\n'); + assert.ok(r.ok, r.diagnostics.map((d) => d.message).join('; ')); + const tr = runLingo(r, { call: 'COUNT_BASE("GGA")' }); // a call aimed at another routine is re-aimed + assert.equal(tr.output.at(-1), 'COUNT_G_BASES returned 2'); + assert.ok(tr.steps.every((s) => s.line == null || s.line <= 5), 'steps carry English lines'); +}); + +test('lingo: an ambiguous range asks a question with two rewrites', () => { + const r = readLingo('To count in T:\n Start with Count at 0.\n For each i from 0 to the length of T:\n Add 1 to Count.\n The answer is Count.\n'); + const q = r.diagnostics.find((d) => d.id === 'range-ends'); + assert.ok(q && q.question && q.question.options.length === 2); + assert.match(q.question.options[0].text, /up to but not including/); +}); + +test('asm: setup lines, assembly errors, and a run', () => { + const setup = parseSetup('rdi = 0x1000\nrsi = 7\ndl = \'A\'\nmemory 0x1000 "GATTACA"\nflags CF'); + assert.equal(setup.registers.rdi, 0x1000n); assert.equal(setup.registers.dl, 65n); assert.equal(setup.memory[0].text, 'GATTACA'); assert.equal(setup.flags.CF, true); + const bad = parseAsm(' mov rax, [rbx], [rcx]\n'); + assert.equal(bad.ok, false); assert.equal(bad.diagnostics[0].line, 1); + const good = parseAsm(' mov eax, 40\n add eax, 2\n ret\n'); + const tr = runAsmProgram(good, {}); + assert.equal(tr.count, 3); + assert.match(tr.output.at(-1), /rax = 42/); +}); diff --git a/tests/sync-hub.test.mjs b/tests/sync-hub.test.mjs new file mode 100644 index 0000000..9e63233 --- /dev/null +++ b/tests/sync-hub.test.mjs @@ -0,0 +1,242 @@ +// Stage 8: the sync hub (restructure plan, section 2.3), without any UI. Pseudo is the hub; the pane that is +// edited is the authority and is never rewritten; an authority with errors changes nothing; a language that +// cannot say the program goes stale rather than blank; contracts ride along; opening rewrites nothing; and the +// whole cascade is fast enough that typing stays instant. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { SyncHub, LINKED, namesFromMatho } from '../dist/sync/hub.js'; +import { pseudoToLingo } from '../dist/sync/pseudo-to-lingo.js'; +import { checkMojo } from '../dist/mojo/check.js'; +import { studyOf } from '../dist/services/pseudo.js'; +import { EQUATIONS, FIXTURES } from './helpers/sync-programs.mjs'; +import { Workspace } from '../dist/common/workspace.js'; +import { PROBLEMS, problemById, workForProblem } from '../dist/common/problems.js'; + + +const sync = (r) => ({ authority: r.authority, stale: r.stale, names: r.names }); +const next = (r, lang, text) => new SyncHub(r.sources, sync(r)).edit(lang, text); + +const COUNT = `FUNCTION COUNT_BASE(B : CHAR, T : STRING) RETURNS INTEGER + DECLARE Total : INTEGER + Total <- 0 + FOR EACH C IN T + IF C == B THEN + Total <- Total + 1 + ENDIF + NEXT C + RETURN Total +ENDFUNCTION`; +const SIMPLE = `FUNCTION SUMMED(N : INTEGER, X : LIST OF FLOAT) RETURNS FLOAT + DECLARE S : FLOAT + S <- 0.0 + FOR I <- 0 TO N + S <- S + X[I] + NEXT I + RETURN S +ENDFUNCTION`; +const WHILE_PSEUDO = FIXTURES['fixture:div-mod'][0]; + +test('a lingo edit updates pseudo, matho and Mojo, and does not rewrite the lingo', () => { + const mean = new SyncHub({}).edit('matho', EQUATIONS['mean'][0]); + assert.ok(mean.sources.lingo.includes('Start with Total'), 'the equations also became English'); + const lingo = mean.sources.lingo.replace('The answer is 1 / N * Total.', 'The answer is 2 / N * Total.'); + const r = next(mean, 'lingo', lingo); + assert.equal(r.authority, 'lingo'); + assert.equal(r.sources.lingo, lingo, 'the edited pane is exactly what was typed'); + assert.match(r.sources.pseudo, /RETURN 2 \/ N \* Total/); + assert.match(r.sources.matho, /\\frac\{2\}\{n\}|2/, 'matho follows'); + assert.match(r.sources.matho, /\\sum/); + assert.match(r.mojo.source, /Float64\(2\) \/ Float64\(n\) \* total/); + assert.deepEqual(r.stale, {}); + assert.ok(r.changed.includes('pseudo') && r.changed.includes('matho') && !r.changed.includes('lingo')); +}); + +test('a pseudo edit updates lingo', () => { + const r0 = new SyncHub({}).edit('pseudo', SIMPLE); + assert.match(r0.sources.lingo, /Start with S at 0\.0/); + const r = next(r0, 'pseudo', SIMPLE.replace('S <- 0.0', 'S <- 2.0')); + assert.match(r.sources.lingo, /Start with S at 2\.0/); + assert.equal(r.sources.pseudo, SIMPLE.replace('S <- 0.0', 'S <- 2.0')); + assert.equal(r.authority, 'pseudo'); +}); + +test('an edit in X never rewrites X, for every linked language', () => { + const base = new SyncHub({}).edit('pseudo', SIMPLE); + for (const lang of LINKED) { + const text = base.sources[lang]; + if (!text) continue; + const r = new SyncHub(base.sources, sync(base)).edit(lang, text + '\n'); + assert.equal(r.sources[lang], text + '\n', `${lang} is kept as typed, trailing blank line included`); + } +}); + +test('an error in the authority changes nothing: the others keep their last good text and say why', () => { + const ok = new SyncHub({}).edit('pseudo', SIMPLE); + const before = { ...ok.sources }; + const r = next(ok, 'lingo', 'Gibberish that is no sentence of lingo at all.'); + assert.equal(r.sources.lingo, 'Gibberish that is no sentence of lingo at all.'); + for (const l of ['pseudo', 'matho', 'speco']) assert.equal(r.sources[l] ?? '', before[l] ?? '', `${l} kept its text`); + for (const l of ['pseudo', 'matho', 'speco']) assert.match(r.stale[l], /lingo line 1 does not read yet/); + assert.equal(r.stale.lingo, undefined, 'the pane being typed in is not stale'); + // a pseudo with errors does the same + const bad = next(ok, 'pseudo', 'FUNCTION BROKEN(\nRETURN'); + assert.match(bad.stale.lingo, /pseudo line \d+ does not read yet/); + assert.equal(bad.sources.lingo, before.lingo); + // and a good edit afterwards clears every mark + const fixed = next(bad, 'pseudo', SIMPLE); + assert.deepEqual(fixed.stale, {}); +}); + +test('matho goes stale, not blank, on a WHILE; a later expressible program brings it back', () => { + const r0 = new SyncHub({}).edit('matho', EQUATIONS['mean'][0]); + const matho = r0.sources.matho; + const r = next(r0, 'pseudo', WHILE_PSEUDO); + assert.equal(r.sources.matho, matho, 'matho keeps its last good text'); + assert.match(r.stale.matho, /matho has no form for a WHILE loop \(line \d+\)/); + assert.equal(r.stale.lingo, undefined, 'lingo can say a WHILE'); + assert.match(r.sources.lingo, /\S/); + const back = next(r, 'pseudo', SIMPLE); + assert.equal(back.stale.matho, undefined); + assert.notEqual(back.sources.matho, matho); +}); + +test('contracts survive an edit in English or in equations', () => { + const p = problemById('count-base-proved'); + const st = workForProblem(p); + const filled = new SyncHub(st.sources).fill(); + const spec = filled.sources.speco; + assert.match(spec, /ENSURE/); + const r = next({ sources: filled.sources, authority: 'speco', stale: {}, names: {} }, 'lingo', filled.sources.lingo.replace('Add 1 to Total.', 'Add 2 to Total.')); + assert.equal(r.sources.speco, spec, 'the speco is what it was'); + assert.match(r.sources.pseudo, /Total <- Total \+ 2/, 'the edit took'); + assert.match(r.sources.pseudo, /ENSURE RESULT == LENGTH/, 'the contract is woven into the pseudo the English lowered to'); + assert.match(r.sources.pseudo, /INVARIANT/); + assert.match(r.mojo.source, /# ENSURE/, 'the translator carries the contract as a comment'); + // a claim about a routine the English no longer has is kept in the speco, not dropped + const renamed = filled.sources.lingo.replace('To count base for B and T:', 'To tally base for B and T:'); + const r2 = next({ sources: filled.sources, authority: 'speco', stale: {}, names: {} }, 'lingo', renamed); + assert.match(r2.sources.speco, /kept:/); + assert.match(r2.sources.speco, /ENSURE/); +}); + +test('an edit in speco puts its contracts into the pseudo, then lingo and matho follow', () => { + const r0 = new SyncHub({}).edit('pseudo', SIMPLE); + const spec = 'SPEC SUMMED(N, X)\n REQUIRE N >= 0\n'; + const r = next(r0, 'speco', spec); + assert.equal(r.sources.speco, spec); + assert.match(r.sources.pseudo, /REQUIRE N >= 0/); + assert.equal(r.authority, 'speco'); + // replacing it replaces: the old REQUIRE is gone + const r2 = next(r, 'speco', 'SPEC SUMMED(N, X)\n REQUIRE N >= 1\n'); + assert.match(r2.sources.pseudo, /REQUIRE N >= 1/); + assert.doesNotMatch(r2.sources.pseudo, /REQUIRE N >= 0/); + // a speco with a syntax error changes nothing + const bad = next(r, 'speco', 'SPEC SUMMED(N, X\n REQUIRE ??\n'); + assert.equal(bad.sources.pseudo, r.sources.pseudo); + assert.ok(bad.stale.pseudo); +}); + +test('the student\'s spelling of equation names survives a trip through pseudo', () => { + const r0 = new SyncHub({}).edit('matho', '\\overline{x} = \\frac{1}{n} \\sum_{i=0}^{n-1} x_i'); + assert.deepEqual(r0.names, { X_BAR: '\\overline{x}' }); + const r = next(r0, 'pseudo', r0.sources.pseudo.replace('RETURN 1 / N * Total', 'RETURN 2 / N * Total')); + assert.match(r.sources.matho, /^\\overline\{x\} = /m); + assert.deepEqual(namesFromMatho('f(x) = x + 1'), {}, 'a function written with its inputs is spelled by the generator'); +}); + +test('loading an authored exercise changes nothing until the first edit', () => { + for (const p of PROBLEMS) { + const st = workForProblem(p); + const before = JSON.stringify(st.sources); + const filled = new SyncHub(st.sources).fill(); + for (const l of [...LINKED, 'mojo', 'asm']) if ((st.sources[l] ?? '').trim()) assert.equal(filled.sources[l], st.sources[l], `${p.id}: authored ${l} is shown as written`); + assert.equal(JSON.stringify(st.sources), before, `${p.id}: the state's own sources are untouched`); + } + // through the session: reading never writes, and nothing is saved or marked as edited + const p = problemById('count-base'); + const s = new Workspace(workForProblem(p)); + const raw = JSON.stringify(s.state.sources); + assert.match(s.source('lingo'), /\S/, 'a missing pane is shown, generated from the pseudo'); + s.parsedLingo(); s.derivedMojo(); s.lineMaps(); + assert.equal(JSON.stringify(s.state.sources), raw); + assert.equal(s.state.sync, undefined); + assert.equal(s.linkState('lingo').kind, 'authored'); +}); + +test('takeAuthority makes a stale pane the authority and regenerates the others from it', () => { + const s = new Workspace(workForProblem(problemById('count-base'))); + s.edit('matho', 'x = '); // does not read: everything else is stale + assert.equal(s.linkState('pseudo').kind, 'stale'); + s.edit('pseudo', COUNT); + assert.equal(s.state.sync.authority, 'pseudo'); + assert.ok(s.linkState('matho').kind === 'stale' || s.linkState('matho').kind === 'sync'); + s.takeAuthority('lingo'); + assert.equal(s.state.sync.authority, 'lingo'); +}); + +test('line maps compose through the hub', () => { + const r = new SyncHub({}).edit('pseudo', SIMPLE); + // pseudo line 3 is `S <- 0.0`; its lingo and Mojo lines come back through the maps + const lingoLines = SyncHub.relate(r.maps, 'pseudo', 3, 'lingo'); + assert.ok(lingoLines.length, 'a lingo line matches'); + assert.match(r.sources.lingo.split('\n')[lingoLines[0] - 1], /Start with S at 0\.0/); + const mojoLines = SyncHub.relate(r.maps, 'pseudo', 3, 'mojo'); + assert.match(r.mojo.source.split('\n')[mojoLines[0] - 1], /s = 0\.0/); + // from Mojo back to lingo, through the pseudo + const back = SyncHub.relate(r.maps, 'mojo', mojoLines[0], 'lingo'); + assert.deepEqual(back, lingoLines); + // an authority's own lowering is used the other way: lingo line -> pseudo line + const l = new SyncHub({}).edit('lingo', pseudoToLingo(SIMPLE).source); + const lingoLine = l.sources.lingo.split('\n').findIndex((t) => /Start with S at/.test(t)) + 1; + const ps = SyncHub.relate(l.maps, 'lingo', lingoLine, 'pseudo'); + assert.ok(ps.some((n) => /S <- 0\.0/.test(l.sources.pseudo.split('\n')[n - 1])), 'the lingo line maps to the assignment'); + assert.ok(SyncHub.relate(l.maps, 'lingo', lingoLine, 'mojo').length); +}); + +test('line maps stay right when contracts are woven into the pseudo an English edit produced', () => { + const filled = new SyncHub(workForProblem(problemById('count-base-proved')).sources).fill(); + const r = new SyncHub(filled.sources).edit('lingo', filled.sources.lingo); + const lingoLine = r.sources.lingo.split('\n').findIndex((t) => /Add 1 to Total/.test(t)) + 1; + const ps = SyncHub.relate(r.maps, 'lingo', lingoLine, 'pseudo'); + assert.ok(ps.length); + assert.match(r.sources.pseudo.split('\n')[ps[0] - 1], /Total <- Total \+ 1/); +}); + +test('every exercise: an edit in any linked pane leaves the Mojo in step with the pseudo and checking clean', () => { + let n = 0; + for (const p of PROBLEMS) { + const st = workForProblem(p); + if (!(st.sources.pseudo ?? '').trim() || !st.call) continue; + if (!studyOf(st.sources.pseudo).ok) continue; + const r = new SyncHub(st.sources, undefined, { call: st.call }).edit('pseudo', st.sources.pseudo); + assert.equal(r.sources.pseudo, st.sources.pseudo); + assert.match(r.mojo.source, /Generated by Programming\+/, p.id); + n++; + } + assert.ok(n >= 12, `${n} exercises went through the hub`); +}); + +test('timing: a full cascade (lingo edit -> pseudo, matho, speco, Mojo) on the largest exercise stays under 50 ms', () => { + let big = null; + for (const p of PROBLEMS) { + const st = workForProblem(p); + const t = st.sources.pseudo ?? ''; + if (t.trim() && studyOf(t).ok && (!big || t.length > big.pseudo.length)) big = { id: p.id, pseudo: t, st }; + } + assert.ok(big); + const filled = new SyncHub(big.st.sources, undefined, { call: big.st.call }).fill(); + // a lingo that reads: whatever the English generator wrote, or, when it has no English, the smallest program + const lingo = filled.sources.lingo || pseudoToLingo(SIMPLE).source; + const start = filled.sources.lingo ? filled.sources : { lingo }; + const hub = () => new SyncHub(start, undefined, { call: big.st.call }); + hub().edit('lingo', lingo); // warm up the engines + const times = []; + for (let i = 0; i < 7; i++) { + const t0 = performance.now(); + hub().edit('lingo', lingo + (i % 2 ? '' : '\n')); + times.push(performance.now() - t0); + } + times.sort((a, b) => a - b); + const median = times[3]; + assert.ok(median < 50, `${big.id}: the median cascade took ${median.toFixed(1)} ms (limit 50)`); +}); diff --git a/tests/tasks.test.mjs b/tests/tasks.test.mjs new file mode 100644 index 0000000..9a79969 --- /dev/null +++ b/tests/tasks.test.mjs @@ -0,0 +1,67 @@ +// The commands people run live in pixi.toml; the README's table lists them. These tests keep the +// two in step, and keep every `pixi run ` mentioned anywhere pointing at a task that exists. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; + +const ROOT = new URL('..', import.meta.url).pathname; +const read = (p) => fs.readFileSync(path.join(ROOT, p), 'utf8'); + +/** Task names in pixi.toml's [tasks] table: `name = {` at the start of a line, until the next table. */ +function pixiTasks() { + const text = read('pixi.toml'); + const body = text.slice(text.indexOf('\n[tasks]') + 1).split(/\n\[(?!tasks\])/)[0]; + return [...body.matchAll(/^([a-z][a-z0-9-]*)\s*=\s*\{/gm)].map((m) => m[1]); +} + +/** Task names in the README's Commands table: the first cell, a backticked name with optional arguments. */ +function readmeTasks() { + const readme = read('README.md'); + const section = readme.slice(readme.indexOf('## Commands'), readme.indexOf('\n## ', readme.indexOf('## Commands') + 1)); + return [...section.matchAll(/^\| `([a-z][a-z0-9-]*)(?: [^`]*)?` \|/gm)].map((m) => m[1]); +} + +test('the README lists every pixi task, once, and nothing else', () => { + const tasks = pixiTasks(); + assert.ok(tasks.length > 20, `only ${tasks.length} tasks read from pixi.toml`); + const listed = readmeTasks(); + assert.deepEqual([...listed].sort(), [...tasks].sort()); + assert.equal(new Set(listed).size, listed.length, 'a task is listed twice'); +}); + +test('every pixi task has a description', () => { + const text = read('pixi.toml'); + for (const t of pixiTasks()) { + const line = text.split('\n').find((l) => l.startsWith(`${t} = {`)); + assert.match(line, /description = "[^"]+"/, `${t} has no description`); + } +}); + +test('every `pixi run ` in the docs, scripts and sources names a real task', () => { + const tasks = new Set(pixiTasks()); + const files = []; + const walk = (dir) => { + for (const e of fs.readdirSync(path.join(ROOT, dir), { withFileTypes: true })) { + const p = path.join(dir, e.name); + if (e.isDirectory()) { if (!['node_modules', 'dist', '.git', '.pixi', '.tools', 'corpus', 'golden', 'package'].includes(e.name)) walk(p); } + else if (/\.(md|mjs|ts|py|lua|yml|toml)$/.test(e.name)) files.push(p); + } + }; + walk('.'); + const unknown = []; + for (const f of files) { + for (const m of read(f).matchAll(/pixi run ([a-z][a-z0-9-]*)/g)) if (!tasks.has(m[1])) unknown.push(`${f}: pixi run ${m[1]}`); + } + assert.deepEqual(unknown, []); +}); + +test('package.json keeps only what CI and a machine without pixi need', () => { + const pkg = JSON.parse(read('package.json')); + assert.deepEqual(Object.keys(pkg.scripts).sort(), ['build', 'check', 'test', 'watch']); +}); + +test('every document the README points to exists', () => { + const readme = read('README.md'); + for (const m of readme.matchAll(/\]\(((?:docs|mojo|scripts)\/[^)#]+)\)/g)) assert.ok(fs.existsSync(path.join(ROOT, m[1])), `${m[1]} is linked from the README but missing`); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b8fe2bb --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,42 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "Bundler", + "lib": [ + "ES2022", + "DOM", + "DOM.Iterable" + ], + "rootDir": "src", + "outDir": "dist", + "allowJs": true, + "checkJs": false, + "strict": true, + "noImplicitAny": true, + "skipLibCheck": true, + "sourceMap": true, + "declaration": true, + "types": [] + }, + "include": [ + "src/**/*.ts", + "src/engines/**/*.js" + ], + "exclude": [ + "src/engines/pseudo/dom.js", + "src/engines/pseudo/views.js", + "src/engines/pseudo/views-analysis.js", + "src/engines/pseudo/lab.js", + "src/engines/pseudo/editor.js", + "src/engines/pseudo/exercise.js", + "src/engines/pseudo/sharpen.js", + "src/engines/pseudo/plan.js", + "src/engines/pseudo/planner.js", + "src/engines/pseudo/highlight.js", + "src/engines/asm86/sandbox.js", + "src/engines/asm86/specs-hw.js", + "src/engines/shared/share.js", + "src/engines/shared/viz.js" + ] +}